|
@@ -1202,28 +1202,12 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
a, ca, cal, value,
|
|
|
customAttribute;
|
|
|
|
|
|
- if ( object.sortParticles ) {
|
|
|
-
|
|
|
- _projScreenMatrixPS.copy( _projScreenMatrix );
|
|
|
- _projScreenMatrixPS.multiply( object.matrixWorld );
|
|
|
+ if ( dirtyVertices ) {
|
|
|
|
|
|
for ( v = 0; v < vl; v ++ ) {
|
|
|
|
|
|
vertex = vertices[ v ];
|
|
|
|
|
|
- _vector3.copy( vertex );
|
|
|
- _vector3.applyProjection( _projScreenMatrixPS );
|
|
|
-
|
|
|
- sortArray[ v ] = [ _vector3.z, v ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- sortArray.sort( numericalSort );
|
|
|
-
|
|
|
- for ( v = 0; v < vl; v ++ ) {
|
|
|
-
|
|
|
- vertex = vertices[ sortArray[ v ][ 1 ] ];
|
|
|
-
|
|
|
offset = v * 3;
|
|
|
|
|
|
vertexArray[ offset ] = vertex.x;
|
|
@@ -1232,11 +1216,18 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglVertexBuffer );
|
|
|
+ _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( dirtyColors ) {
|
|
|
+
|
|
|
for ( c = 0; c < cl; c ++ ) {
|
|
|
|
|
|
- offset = c * 3;
|
|
|
+ color = colors[ c ];
|
|
|
|
|
|
- color = colors[ sortArray[ c ][ 1 ] ];
|
|
|
+ offset = c * 3;
|
|
|
|
|
|
colorArray[ offset ] = color.r;
|
|
|
colorArray[ offset + 1 ] = color.g;
|
|
@@ -1244,25 +1235,28 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( customAttributes ) {
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglColorBuffer );
|
|
|
+ _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint );
|
|
|
|
|
|
- for ( i = 0, il = customAttributes.length; i < il; i ++ ) {
|
|
|
+ }
|
|
|
|
|
|
- customAttribute = customAttributes[ i ];
|
|
|
+ if ( customAttributes ) {
|
|
|
|
|
|
- if ( ! ( customAttribute.boundTo === undefined || customAttribute.boundTo === 'vertices' ) ) continue;
|
|
|
+ for ( i = 0, il = customAttributes.length; i < il; i ++ ) {
|
|
|
|
|
|
- offset = 0;
|
|
|
+ customAttribute = customAttributes[ i ];
|
|
|
+
|
|
|
+ if ( customAttribute.needsUpdate && ( customAttribute.boundTo === undefined || customAttribute.boundTo === 'vertices' ) ) {
|
|
|
|
|
|
cal = customAttribute.value.length;
|
|
|
|
|
|
+ offset = 0;
|
|
|
+
|
|
|
if ( customAttribute.size === 1 ) {
|
|
|
|
|
|
for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
|
|
|
- index = sortArray[ ca ][ 1 ];
|
|
|
-
|
|
|
- customAttribute.array[ ca ] = customAttribute.value[ index ];
|
|
|
+ customAttribute.array[ ca ] = customAttribute.value[ ca ];
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1270,9 +1264,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
|
|
|
- index = sortArray[ ca ][ 1 ];
|
|
|
-
|
|
|
- value = customAttribute.value[ index ];
|
|
|
+ value = customAttribute.value[ ca ];
|
|
|
|
|
|
customAttribute.array[ offset ] = value.x;
|
|
|
customAttribute.array[ offset + 1 ] = value.y;
|
|
@@ -1287,11 +1279,9 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
|
|
|
- index = sortArray[ ca ][ 1 ];
|
|
|
-
|
|
|
- value = customAttribute.value[ index ];
|
|
|
+ value = customAttribute.value[ ca ];
|
|
|
|
|
|
- customAttribute.array[ offset ] = value.r;
|
|
|
+ customAttribute.array[ offset ] = value.r;
|
|
|
customAttribute.array[ offset + 1 ] = value.g;
|
|
|
customAttribute.array[ offset + 2 ] = value.b;
|
|
|
|
|
@@ -1303,9 +1293,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
|
|
|
- index = sortArray[ ca ][ 1 ];
|
|
|
-
|
|
|
- value = customAttribute.value[ index ];
|
|
|
+ value = customAttribute.value[ ca ];
|
|
|
|
|
|
customAttribute.array[ offset ] = value.x;
|
|
|
customAttribute.array[ offset + 1 ] = value.y;
|
|
@@ -1321,9 +1309,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
|
|
|
- index = sortArray[ ca ][ 1 ];
|
|
|
-
|
|
|
- value = customAttribute.value[ index ];
|
|
|
+ value = customAttribute.value[ ca ];
|
|
|
|
|
|
customAttribute.array[ offset ] = value.x;
|
|
|
customAttribute.array[ offset + 1 ] = value.y;
|
|
@@ -1338,160 +1324,10 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- if ( dirtyVertices ) {
|
|
|
-
|
|
|
- for ( v = 0; v < vl; v ++ ) {
|
|
|
-
|
|
|
- vertex = vertices[ v ];
|
|
|
-
|
|
|
- offset = v * 3;
|
|
|
-
|
|
|
- vertexArray[ offset ] = vertex.x;
|
|
|
- vertexArray[ offset + 1 ] = vertex.y;
|
|
|
- vertexArray[ offset + 2 ] = vertex.z;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( dirtyColors ) {
|
|
|
-
|
|
|
- for ( c = 0; c < cl; c ++ ) {
|
|
|
-
|
|
|
- color = colors[ c ];
|
|
|
-
|
|
|
- offset = c * 3;
|
|
|
-
|
|
|
- colorArray[ offset ] = color.r;
|
|
|
- colorArray[ offset + 1 ] = color.g;
|
|
|
- colorArray[ offset + 2 ] = color.b;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( customAttributes ) {
|
|
|
-
|
|
|
- for ( i = 0, il = customAttributes.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- customAttribute = customAttributes[ i ];
|
|
|
-
|
|
|
- if ( customAttribute.needsUpdate &&
|
|
|
- ( customAttribute.boundTo === undefined ||
|
|
|
- customAttribute.boundTo === 'vertices' ) ) {
|
|
|
-
|
|
|
- cal = customAttribute.value.length;
|
|
|
-
|
|
|
- offset = 0;
|
|
|
-
|
|
|
- if ( customAttribute.size === 1 ) {
|
|
|
-
|
|
|
- for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
-
|
|
|
- customAttribute.array[ ca ] = customAttribute.value[ ca ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( customAttribute.size === 2 ) {
|
|
|
-
|
|
|
- for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
-
|
|
|
- value = customAttribute.value[ ca ];
|
|
|
-
|
|
|
- customAttribute.array[ offset ] = value.x;
|
|
|
- customAttribute.array[ offset + 1 ] = value.y;
|
|
|
-
|
|
|
- offset += 2;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( customAttribute.size === 3 ) {
|
|
|
-
|
|
|
- if ( customAttribute.type === 'c' ) {
|
|
|
-
|
|
|
- for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
-
|
|
|
- value = customAttribute.value[ ca ];
|
|
|
-
|
|
|
- customAttribute.array[ offset ] = value.r;
|
|
|
- customAttribute.array[ offset + 1 ] = value.g;
|
|
|
- customAttribute.array[ offset + 2 ] = value.b;
|
|
|
-
|
|
|
- offset += 3;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
-
|
|
|
- value = customAttribute.value[ ca ];
|
|
|
-
|
|
|
- customAttribute.array[ offset ] = value.x;
|
|
|
- customAttribute.array[ offset + 1 ] = value.y;
|
|
|
- customAttribute.array[ offset + 2 ] = value.z;
|
|
|
-
|
|
|
- offset += 3;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else if ( customAttribute.size === 4 ) {
|
|
|
-
|
|
|
- for ( ca = 0; ca < cal; ca ++ ) {
|
|
|
-
|
|
|
- value = customAttribute.value[ ca ];
|
|
|
-
|
|
|
- customAttribute.array[ offset ] = value.x;
|
|
|
- customAttribute.array[ offset + 1 ] = value.y;
|
|
|
- customAttribute.array[ offset + 2 ] = value.z;
|
|
|
- customAttribute.array[ offset + 3 ] = value.w;
|
|
|
-
|
|
|
- offset += 4;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( dirtyVertices || object.sortParticles ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglVertexBuffer );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( dirtyColors || object.sortParticles ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.__webglColorBuffer );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if ( customAttributes ) {
|
|
|
-
|
|
|
- for ( i = 0, il = customAttributes.length; i < il; i ++ ) {
|
|
|
-
|
|
|
- customAttribute = customAttributes[ i ];
|
|
|
-
|
|
|
- if ( customAttribute.needsUpdate || object.sortParticles ) {
|
|
|
-
|
|
|
- _gl.bindBuffer( _gl.ARRAY_BUFFER, customAttribute.buffer );
|
|
|
- _gl.bufferData( _gl.ARRAY_BUFFER, customAttribute.array, hint );
|
|
|
+ _gl.bindBuffer( _gl.ARRAY_BUFFER, customAttribute.buffer );
|
|
|
+ _gl.bufferData( _gl.ARRAY_BUFFER, customAttribute.array, hint );
|
|
|
|
|
|
- }
|
|
|
+ customAttribute.needsUpdate = false;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1582,9 +1418,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
customAttribute = customAttributes[ i ];
|
|
|
|
|
|
- if ( customAttribute.needsUpdate &&
|
|
|
- ( customAttribute.boundTo === undefined ||
|
|
|
- customAttribute.boundTo === 'vertices' ) ) {
|
|
|
+ if ( customAttribute.needsUpdate && ( customAttribute.boundTo === undefined || customAttribute.boundTo === 'vertices' ) ) {
|
|
|
|
|
|
offset = 0;
|
|
|
|
|
@@ -1663,6 +1497,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
_gl.bindBuffer( _gl.ARRAY_BUFFER, customAttribute.buffer );
|
|
|
_gl.bufferData( _gl.ARRAY_BUFFER, customAttribute.array, hint );
|
|
|
|
|
|
+ customAttribute.needsUpdate = false;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -4137,7 +3973,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
customAttributesDirty = material.attributes && areCustomAttributesDirty( material );
|
|
|
|
|
|
- if ( geometry.verticesNeedUpdate || geometry.colorsNeedUpdate || object.sortParticles || customAttributesDirty ) {
|
|
|
+ if ( geometry.verticesNeedUpdate || geometry.colorsNeedUpdate || customAttributesDirty ) {
|
|
|
|
|
|
setParticleBuffers( geometry, _gl.DYNAMIC_DRAW, object );
|
|
|
|