xeolabs / xeogl

A WebGL-based 3D engine for technical visualization. Not actively maintained.
http://xeogl.org
Other
1.15k stars 264 forks source link

GLTFModel needlessly caches typed arrays for glTF buffer views #288

Open xeolabs opened 6 years ago

xeolabs commented 6 years ago

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.