gltf-pipeline
Advanced tools
Comparing version 2.1.2 to 2.1.3
Change Log | ||
========== | ||
### 2.1.3 - 2019-03-21 | ||
* Fixed a crash when saving separate resources that would exceed the Node buffer size limit. [#468](https://github.com/AnalyticalGraphicsInc/gltf-pipeline/pull/468) | ||
### 2.1.2 - 2019-03-14 | ||
@@ -5,0 +9,0 @@ |
'use strict'; | ||
const BUFFER_MAX_BYTE_LENGTH = require('buffer').constants.MAX_LENGTH; | ||
const Cesium = require('cesium'); | ||
@@ -26,3 +27,12 @@ const ForEach = require('./ForEach'); | ||
let buffersByteLength = 0; | ||
ForEach.buffer(gltf, function(buffer) { | ||
buffersByteLength += buffer.extras._pipeline.source.length; | ||
}); | ||
// Don't merge buffers if the merged buffer will exceed the Node limit. | ||
const splitBuffers = (buffersByteLength > mergeBuffers._getBufferMaxByteLength()); | ||
const buffersToMerge = {}; | ||
const mergedNameCount = {}; | ||
@@ -33,2 +43,10 @@ ForEach.bufferView(gltf, function(bufferView) { | ||
mergedName = defined(mergedName) ? baseBufferName + '-' + mergedName : baseBufferName; | ||
if (splitBuffers) { | ||
if (!defined(mergedNameCount[mergedName])) { | ||
mergedNameCount[mergedName] = 0; | ||
} | ||
mergedName += '-' + mergedNameCount[mergedName]++; | ||
} | ||
if (!defined(buffersToMerge[mergedName])) { | ||
@@ -47,4 +65,6 @@ buffersToMerge[mergedName] = { | ||
const bufferViewPadding = allocateBufferPadding(byteLength); | ||
buffers.push(bufferViewPadding); | ||
byteLength += bufferViewPadding.byteLength; | ||
if (defined(bufferViewPadding)) { | ||
buffers.push(bufferViewPadding); | ||
byteLength += bufferViewPadding.byteLength; | ||
} | ||
@@ -69,4 +89,6 @@ bufferView.byteOffset = byteLength; | ||
const bufferPadding = allocateBufferPadding(byteLength); | ||
buffers.push(bufferPadding); | ||
const mergedSource = Buffer.concat(buffers); | ||
if (defined(bufferPadding)) { | ||
buffers.push(bufferPadding); | ||
} | ||
const mergedSource = (buffers.length > 1) ? Buffer.concat(buffers) : buffers[0]; | ||
gltf.buffers[index] = { | ||
@@ -93,3 +115,8 @@ name: mergedName, | ||
} | ||
return Buffer.alloc(0); | ||
return undefined; | ||
} | ||
// Exposed for testing | ||
mergeBuffers._getBufferMaxByteLength = function() { | ||
return BUFFER_MAX_BYTE_LENGTH; | ||
}; |
{ | ||
"name": "gltf-pipeline", | ||
"version": "2.1.2", | ||
"version": "2.1.3", | ||
"description": "Content pipeline tools for optimizing glTF assets.", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
214683
4367