Expose ‘attributes’ and ‘geometries’ from WebGLRenderer

If I add these two lines to WebGLRenderer.initGLContext

	_this.attributes = attributes;
	_this.geometries = geometries;

Then I can do this to grab the underlying WebGL vertex and index buffers for my BufferGeometry and populate them from external WebGL code.

            var bufferGeometry = new THREE.BufferGeometry();
            bufferGeometry.setIndex([]);
            bufferGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute([], 3));            
            bufferGeometry.addAttribute( 'normal', new THREE.Float32BufferAttribute([], 3));            
            bufferGeometry.addAttribute( 'uv', new THREE.Uint16BufferAttribute([], 2, true));

            renderer.geometries.update(bufferGeometry);
            var posBuf = renderer.attributes.get(bufferGeometry.attributes['position']).buffer;
            var norBuf = renderer.attributes.get(bufferGeometry.attributes['normal']).buffer;            
            var uvBuf = renderer.attributes.get(bufferGeometry.attributes['uv']).buffer;
            var indexBuf = renderer.attributes.get(bufferGeometry.index).buffer;

Is this a change you guys would consider taking? This is with the goal of getting volumetric video content playing inside of THREE.js scenes.

Thanks!
Evan

Author: Fantashit

2 thoughts on “Expose ‘attributes’ and ‘geometries’ from WebGLRenderer

  1. I just wanted to chip in and say this feature is exactly what I need 🙂 We stream geometry in chunks and doing the roundtrip through BufferGeometry really is a pain. The GLBufferAttribute of #13196 also looks pretty good, so that would be totally OK too.

Comments are closed.