|
@@ -6927,7 +6927,6 @@ THREE.EventDispatcher.prototype = {
|
|
var material = object.material;
|
|
var material = object.material;
|
|
|
|
|
|
if ( material === undefined ) return intersects;
|
|
if ( material === undefined ) return intersects;
|
|
- if ( geometry.dynamic === false ) return intersects;
|
|
|
|
|
|
|
|
var a, b, c;
|
|
var a, b, c;
|
|
var precision = raycaster.precision;
|
|
var precision = raycaster.precision;
|
|
@@ -9533,10 +9532,6 @@ THREE.BufferGeometry = function () {
|
|
|
|
|
|
this.attributes = {};
|
|
this.attributes = {};
|
|
|
|
|
|
- // attributes typed arrays are kept only if dynamic flag is set
|
|
|
|
-
|
|
|
|
- this.dynamic = true;
|
|
|
|
-
|
|
|
|
// offsets for chunks when using indexed elements
|
|
// offsets for chunks when using indexed elements
|
|
|
|
|
|
this.offsets = [];
|
|
this.offsets = [];
|
|
@@ -20174,6 +20169,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
_precision = parameters.precision !== undefined ? parameters.precision : 'highp',
|
|
_precision = parameters.precision !== undefined ? parameters.precision : 'highp',
|
|
|
|
|
|
|
|
+ _buffers = {},
|
|
|
|
+
|
|
_alpha = parameters.alpha !== undefined ? parameters.alpha : false,
|
|
_alpha = parameters.alpha !== undefined ? parameters.alpha : false,
|
|
_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
|
|
_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,
|
|
_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
|
|
_antialias = parameters.antialias !== undefined ? parameters.antialias : false,
|
|
@@ -20301,7 +20298,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
_currentWidth = 0,
|
|
_currentWidth = 0,
|
|
_currentHeight = 0,
|
|
_currentHeight = 0,
|
|
|
|
|
|
- _enabledAttributes = {},
|
|
|
|
|
|
+ _enabledAttributes = new Uint8Array( 16 ),
|
|
|
|
|
|
// frustum
|
|
// frustum
|
|
|
|
|
|
@@ -21241,6 +21238,27 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ function initGeometry2Buffers( geometry ) {
|
|
|
|
+
|
|
|
|
+ var buffers = {};
|
|
|
|
+ var attributes = [ 'vertices', 'normals', 'uvs' ];
|
|
|
|
+
|
|
|
|
+ for ( var key in attributes ) {
|
|
|
|
+
|
|
|
|
+ var array = geometry[ attributes[ key ] ];
|
|
|
|
+ var buffer = _gl.createBuffer();
|
|
|
|
+
|
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
|
|
|
|
+ _gl.bufferData( _gl.ARRAY_BUFFER, array, _gl.STATIC_DRAW );
|
|
|
|
+
|
|
|
|
+ buffers[ attributes[ key ] ] = buffer;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _buffers[ geometry.id ] = buffers;
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
// Buffer setting
|
|
// Buffer setting
|
|
|
|
|
|
function setParticleBuffers ( geometry, hint, object ) {
|
|
function setParticleBuffers ( geometry, hint, object ) {
|
|
@@ -22579,7 +22597,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- function setDirectBuffers ( geometry, hint, dispose ) {
|
|
|
|
|
|
+ function setDirectBuffers( geometry, hint ) {
|
|
|
|
|
|
var attributes = geometry.attributes;
|
|
var attributes = geometry.attributes;
|
|
|
|
|
|
@@ -22607,14 +22625,29 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- if ( dispose && ! attributeItem.dynamic ) {
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- attributeItem.array = null;
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ function setGeometry2Buffers( geometry, hint ) {
|
|
|
|
+
|
|
|
|
+ if ( geometry.needsUpdate === false ) return;
|
|
|
|
+
|
|
|
|
+ var attributes = [ 'vertices', 'normals', 'uvs' ];
|
|
|
|
+ var buffers = _buffers[ geometry.id ];
|
|
|
|
+
|
|
|
|
+ for ( var key in attributes ) {
|
|
|
|
+
|
|
|
|
+ var array = geometry[ attributes[ key ] ];
|
|
|
|
+ var buffer = buffers[ attributes[ key ] ];
|
|
|
|
+
|
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, buffer );
|
|
|
|
+ _gl.bufferData( _gl.ARRAY_BUFFER, array, hint );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ geometry.needsUpdate = false;
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
// Buffer rendering
|
|
// Buffer rendering
|
|
@@ -22712,6 +22745,56 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ this.renderBufferGeometry2 = function ( camera, lights, fog, material, geometry, object ) {
|
|
|
|
+
|
|
|
|
+ var program = setProgram( camera, lights, fog, material, object );
|
|
|
|
+
|
|
|
|
+ var programAttributes = program.attributes;
|
|
|
|
+
|
|
|
|
+ var attributes = { 'position': 'vertices', 'normal': 'normals', 'uv': 'uvs' };
|
|
|
|
+ var itemSizes = { 'position': 3, 'normal': 3, 'uv': 2 };
|
|
|
|
+
|
|
|
|
+ var buffers = _buffers[ geometry.id ];
|
|
|
|
+
|
|
|
|
+ disableAttributes();
|
|
|
|
+
|
|
|
|
+ for ( var name in programAttributes ) {
|
|
|
|
+
|
|
|
|
+ var attributePointer = programAttributes[ name ];
|
|
|
|
+
|
|
|
|
+ if ( attributePointer >= 0 ) {
|
|
|
|
+
|
|
|
|
+ var array = geometry[ attributes[ name ] ];
|
|
|
|
+
|
|
|
|
+ if ( array !== undefined && array.length > 0 ) {
|
|
|
|
+
|
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, buffers[ attributes[ name ] ] );
|
|
|
|
+ enableAttribute( attributePointer );
|
|
|
|
+ _gl.vertexAttribPointer( attributePointer, itemSizes[ name ], _gl.FLOAT, false, 0, 0 );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ if ( itemSizes[ name ] === 3 ) {
|
|
|
|
+
|
|
|
|
+ _gl.vertexAttrib3fv( attributePointer, [ 0, 0, 0 ] );
|
|
|
|
+
|
|
|
|
+ } else if ( itemSizes[ name ] === 2 ) {
|
|
|
|
+
|
|
|
|
+ _gl.vertexAttrib2fv( attributePointer, [ 0, 0 ] );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _gl.drawArrays( _gl.TRIANGLES, 0, geometry.vertices.length / 3 );
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
this.renderBufferDirect = function ( camera, lights, fog, material, geometry, object ) {
|
|
this.renderBufferDirect = function ( camera, lights, fog, material, geometry, object ) {
|
|
|
|
|
|
if ( material.visible === false ) return;
|
|
if ( material.visible === false ) return;
|
|
@@ -23210,10 +23293,10 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
function enableAttribute( attribute ) {
|
|
function enableAttribute( attribute ) {
|
|
|
|
|
|
- if ( ! _enabledAttributes[ attribute ] ) {
|
|
|
|
|
|
+ if ( _enabledAttributes[ attribute ] === 0 ) {
|
|
|
|
|
|
_gl.enableVertexAttribArray( attribute );
|
|
_gl.enableVertexAttribArray( attribute );
|
|
- _enabledAttributes[ attribute ] = true;
|
|
|
|
|
|
+ _enabledAttributes[ attribute ] = 1;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -23223,10 +23306,10 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
for ( var attribute in _enabledAttributes ) {
|
|
for ( var attribute in _enabledAttributes ) {
|
|
|
|
|
|
- if ( _enabledAttributes[ attribute ] ) {
|
|
|
|
|
|
+ if ( _enabledAttributes[ attribute ] === 1 ) {
|
|
|
|
|
|
_gl.disableVertexAttribArray( attribute );
|
|
_gl.disableVertexAttribArray( attribute );
|
|
- _enabledAttributes[ attribute ] = false;
|
|
|
|
|
|
+ _enabledAttributes[ attribute ] = 0;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -23626,7 +23709,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
- function renderObjects ( renderList, reverse, materialType, camera, lights, fog, useBlending, overrideMaterial ) {
|
|
|
|
|
|
+ function renderObjects( renderList, reverse, materialType, camera, lights, fog, useBlending, overrideMaterial ) {
|
|
|
|
|
|
var webglObject, object, buffer, material, start, end, delta;
|
|
var webglObject, object, buffer, material, start, end, delta;
|
|
|
|
|
|
@@ -23676,6 +23759,10 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
_this.renderBufferDirect( camera, lights, fog, material, buffer, object );
|
|
_this.renderBufferDirect( camera, lights, fog, material, buffer, object );
|
|
|
|
|
|
|
|
+ } else if ( buffer instanceof THREE.Geometry2 ) {
|
|
|
|
+
|
|
|
|
+ _this.renderBufferGeometry2( camera, lights, fog, material, buffer, object );
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
|
|
|
|
_this.renderBuffer( camera, lights, fog, material, buffer, object );
|
|
_this.renderBuffer( camera, lights, fog, material, buffer, object );
|
|
@@ -23960,6 +24047,10 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
initDirectBuffers( geometry );
|
|
initDirectBuffers( geometry );
|
|
|
|
|
|
|
|
+ } else if ( geometry instanceof THREE.Geometry2 ) {
|
|
|
|
+
|
|
|
|
+ initGeometry2Buffers( geometry );
|
|
|
|
+
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
|
|
|
|
material = object.material;
|
|
material = object.material;
|
|
@@ -24034,6 +24125,10 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
addBuffer( scene.__webglObjects, geometry, object );
|
|
addBuffer( scene.__webglObjects, geometry, object );
|
|
|
|
|
|
|
|
+ } else if ( geometry instanceof THREE.Geometry2 ) {
|
|
|
|
+
|
|
|
|
+ addBuffer( scene.__webglObjects, geometry, object );
|
|
|
|
+
|
|
} else if ( geometry instanceof THREE.Geometry ) {
|
|
} else if ( geometry instanceof THREE.Geometry ) {
|
|
|
|
|
|
for ( g in geometry.geometryGroups ) {
|
|
for ( g in geometry.geometryGroups ) {
|
|
@@ -24110,7 +24205,11 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
if ( geometry instanceof THREE.BufferGeometry ) {
|
|
|
|
|
|
- setDirectBuffers( geometry, _gl.DYNAMIC_DRAW, !geometry.dynamic );
|
|
|
|
|
|
+ setDirectBuffers( geometry, _gl.DYNAMIC_DRAW );
|
|
|
|
+
|
|
|
|
+ } else if ( geometry instanceof THREE.Geometry2 ) {
|
|
|
|
+
|
|
|
|
+ setGeometry2Buffers( geometry, _gl.DYNAMIC_DRAW );
|
|
|
|
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
} else if ( object instanceof THREE.Mesh ) {
|
|
|
|
|