Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
json.bufferViews.forEach((bufferView, bufferViewIndex) => {
if (bufferViewMap[bufferViewIndex] !== meshName) return;
const bufferData = container.getBuffer(bufferView.buffer);
const bufferViewData = bufferData.slice(bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength);
const newBufferURI = `${meshName}.bin`;
const newBuffer = container.json.buffers.find((buffer) => buffer.uri === newBufferURI)
|| GLTFUtil.addBuffer(container, meshName, new ArrayBuffer(0));
const newBufferIndex = container.json.buffers.indexOf(newBuffer);
const newBufferView = GLTFUtil.addBufferView(container, bufferViewData, newBufferIndex);
const newBufferViewIndex = container.json.bufferViews.indexOf(newBufferView);
container.json.accessors.forEach((accessor) => {
if (accessor.bufferView === bufferViewIndex) {
accessor.bufferView = newBufferViewIndex;
}
})
removedBufferViews.push(bufferViewIndex);
});