Remove string size limitation

This commit is contained in:
Sean Lilley 2019-02-05 18:41:32 -05:00
parent b458856904
commit 75c8dc6163
2 changed files with 5 additions and 4 deletions

View File

@ -5,6 +5,7 @@ Change Log
* Breaking changes
* The `--materialsCommon` flag has been removed. Use `--unlit` instead which uses the `KHR_materials_unlit` extension. [#152](https://github.com/AnalyticalGraphicsInc/obj2gltf/pull/152)
* No longer throws an error always if the glTF buffer is greater than 192 MB. The string node size limitation increased in Node 9.0.0. See https://bugs.chromium.org/p/v8/issues/detail?id=6148#c10.
### 2.3.2 2018-11-02

View File

@ -145,12 +145,12 @@ function writeEmbeddedBuffer(gltf) {
var buffer = gltf.buffers[0];
var source = buffer.extras._obj2gltf.source;
// Buffers larger than ~192MB cannot be base64 encoded due to a NodeJS limitation. Source: https://github.com/nodejs/node/issues/4266
if (source.length > 201326580) {
try {
buffer.uri = 'data:application/octet-stream;base64,' + source.toString('base64');
} catch(error) {
// In some versions of Node a buffer larger than ~192MB cannot be base64 encoded due to string size limitations. Source: https://stackoverflow.com/posts/47781288/revisions
throw new RuntimeError('Buffer is too large to embed in the glTF. Use the --separate flag instead.');
}
buffer.uri = 'data:application/octet-stream;base64,' + source.toString('base64');
}
function writeEmbeddedTextures(gltf) {