diff --git a/CHANGES.md b/CHANGES.md index 842f287..919cf37 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Change Log +### 3.1.5 - ????-??-?? + +- Fixed crash when writing GLB files above 2GB. [#280](https://github.com/CesiumGS/obj2gltf/pull/280) + ### 3.1.4 - 2021-10-15 - Unlocked CesiumJS package now that CesiumJS 1.86.1 is released with a fix for Node 16. [#270](https://github.com/CesiumGS/obj2gltf/pull/270) diff --git a/lib/createGltf.js b/lib/createGltf.js index 6bdf34a..3d07008 100644 --- a/lib/createGltf.js +++ b/lib/createGltf.js @@ -1,5 +1,7 @@ "use strict"; -const BUFFER_MAX_BYTE_LENGTH = require("buffer").constants.MAX_LENGTH; +const FS_WRITE_MAX_LENGTH = 2147479552; // See https://github.com/nodejs/node/issues/35605 +const BUFFER_MAX_LENGTH = require("buffer").constants.MAX_LENGTH; +const BUFFER_MAX_BYTE_LENGTH = Math.min(FS_WRITE_MAX_LENGTH, BUFFER_MAX_LENGTH); const Cesium = require("cesium"); const getBufferPadded = require("./getBufferPadded"); const getDefaultMaterial = require("./loadMtl").getDefaultMaterial;