[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] ArrayBuffer, Concatenation and String-Array Conversion, a proposal



On Tue, Oct 5, 2010 at 2:20 PM, Vladimir Vukicevic <vladimir@mozilla.com> wrote:
>
>
> ----- Original Message -----
>> > The question here is why isn't there a function for doing these
>> > conversions between JavaScript Strings and Arrays? I suppose the
>> > answer is that it's not common enough; storing a unicode value in an
>> > array isn't done very much.
>>
>> I think it will be.
>>
>> My use case here would be to send, as single JSON file, a complete 3d
>> model in a format parsable by javascript. In the ideal case, that 3d
>> model could include shader code, and binary data. JSON can be parsed
>> using the built-in accelerated function for doing so, but then you
>> need a way of transforming likely large blocks of text to array
>> buffers.
>
> Sending this stuff as text is generally not a good idea, no matter how it's done; it'll be inefficient for the browser/js engine to work with, at the very least.  In this case a two-file solution, one JSON and one raw binary, would probably be the most efficient.  I understand the desire to work with a single file, though.  One thing we could do is add something to the DataView class for reading/writing strings to/from an ArrayBuffer using a given format; that might be a fairly natural fit for that type of functionality (which has been requested in other contexts as well -- e.g. reading a binary file that has an embedded string that refers to a texture file or something).

The author of node.js raised the issue of encoding and decoding typed
arrays using multiple character encodings a few months ago. See
https://www.khronos.org/webgl/public-mailing-list/archives/1006/msg00191.html
and follow-ups on the thread. To avoid making the Typed Array
specification too monolithic I think it would be best to factor
conversions to and from strings into a separate specification. However
I would personally be very happy to help implement any such
specification in WebKit.

Would anybody be willing to step up and draft such a spec?

-Ken

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: