xeogl icon indicating copy to clipboard operation
xeogl copied to clipboard

GLTFModel needlessly caches typed arrays for glTF buffer views

Open xeolabs opened this issue 7 years ago • 0 comments

Describe the bug GLTFModel caches some typed array data for buffer views, which is never used.

Within GLTFModel's loadBufferView() function we need to remove the lines between the REMOVE comments below:

function loadBufferView(ctx, bufferViewInfo) {

            var buffer = ctx.json.buffers[bufferViewInfo.buffer];

            bufferViewInfo._typedArray = null;

            var byteLength = bufferViewInfo.byteLength || 0;
            var byteOffset = bufferViewInfo.byteOffset || 0;

            bufferViewInfo._buffer = buffer._buffer.slice(byteOffset, byteOffset + byteLength);

            // REMOVE
            if (bufferViewInfo.target === 34963) {
                 bufferViewInfo._typedArray = new Uint16Array(bufferViewInfo._buffer);          
            } else if (bufferViewInfo.target == 34962) {
                bufferViewInfo._typedArray = new Float32Array(bufferViewInfo._buffer);            /
            } else {           
             }
            // REMOVE
        }

Expected behavior Less memory used while loading glTF files.

xeolabs avatar Oct 24 '18 23:10 xeolabs