在 JavaScript 中解析二进制数据
我想用 JavaScript 设计和编写一个 3D 图像查看 Web 应用程序。我已经用java和flash编写了它,并且基本上想移植它。我希望 3D 图像导出文件采用二进制格式,就像我编写的 Java 和 flash 版本一样,但是,我不确定 JavaScript 是否可以有效地处理二进制格式的数据。 JavaScript 可以快速处理二进制数据吗?与 Java 和 Flash 相比,它的处理能力如何?
I want to design and write a 3d image viewing web application in JavaScript. I've already written it in java and flash and basically want to port it. I want the 3d image export files to be in a binary format just like the Java and flash versions I've written however, I'm unsure if JavaScript can handle data in binary format efficiently. Can JavaScript handle binary data quickly? How good/bad is it at handling compared with Java and Flash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
JavaScript 可以通过类型化数组处理二进制数据。这是一个用于处理二进制文件的库,您可以将其用作应用程序的参考点。
JavaScript 有多快 - 我不确定这个问题是否正确。这取决于浏览器和用户的机器。
JavaScript can handle binary data via typed arrays. And here is a library for dealing with binary files, that you can use as a reference point for your application.
How quick is JavaScript - I'm not sure that this is the right question. It depends on browser, and user`s machine.
正如@Bakudan所说,您可以使用
TypedArray
s。大多数现代浏览器都支持
DataView
API,它为您提供对ArrayBuffer
s。此外,您还可以使用
BlobReader
来处理 blob。解析二进制协议(Blob、ArrayBuffers、DataViews、TypedArrays、Binary Data over WebSockets)的整个过程在这篇博文。
As @Bakudan said, you can use the
TypedArray
s.Most modern browsers support the
DataView
API, which provides you random access toArrayBuffer
s.As addition, you can use
BlobReader
to process blobs.The whole process of parsing binary protocols (Blobs, ArrayBuffers, DataViews, TypedArrays, Binary Data over WebSockets) is described in this blog post.