提交 e65e086d 编写于 作者: M Mr.doob

Removed PointCloud.sortParticles. See #5668.

上级 8134ef1a
......@@ -16,7 +16,6 @@
<h2>Constructor</h2>
<h3>[name]( [page:Geometry geometry], [page:Material material] )</h3>
<div>
......@@ -24,6 +23,7 @@
material — An instance of [page:Material] (optional).
</div>
<h2>Properties</h2>
<h3>[property:Geometry geometry]</h3>
......@@ -34,10 +34,6 @@
<div>An instance of [page:Material], defining the object's appearance. Default is a [page:PointCloudMaterial] with randomised colour.</div>
<h3>[property:boolean sortParticles]</h3>
<div>
When set, then the particles should be depth sorted (from far to near), based on camera, in the renderer every frame.
</div>
<h2>Methods</h2>
......@@ -46,8 +42,10 @@
This creates a clone of the particle system.
</div>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -148,9 +148,6 @@
sphere = new THREE.PointCloud( geometry, shaderMaterial );
sphere.dynamic = true;
//sphere.sortParticles = true;
var vertices = sphere.geometry.vertices;
var values_size = attributes.size.value;
var values_color = attributes.customColor.value;
......
......@@ -67,8 +67,11 @@
void main() {
gl_FragColor = vec4( color * vColor, 1.0 );
gl_FragColor = gl_FragColor * texture2D( texture, gl_PointCoord );
vec4 color = vec4( color * vColor, 1.0 ) * texture2D( texture, gl_PointCoord );
if ( color.w < 0.5 ) discard;
gl_FragColor = color;
}
......@@ -136,9 +139,6 @@
sphere = new THREE.PointCloud( geometry, shaderMaterial );
sphere.dynamic = true;
sphere.sortParticles = true;
var vertices = sphere.geometry.vertices;
var values_size = attributes.size.value;
var values_color = attributes.ca.value;
......
......@@ -81,11 +81,10 @@
}
material = new THREE.PointCloudMaterial( { size: 35, sizeAttenuation: false, map: sprite, transparent: true } );
material = new THREE.PointCloudMaterial( { size: 35, sizeAttenuation: false, map: sprite, alphaTest: 0.5, transparent: true } );
material.color.setHSL( 1.0, 0.3, 0.7 );
particles = new THREE.PointCloud( geometry, material );
particles.sortParticles = true;
scene.add( particles );
//
......
......@@ -86,12 +86,10 @@
geometry.colors = colors;
material = new THREE.PointCloudMaterial( { size: 85, map: sprite, vertexColors: THREE.VertexColors, transparent: true } );
material = new THREE.PointCloudMaterial( { size: 85, map: sprite, vertexColors: THREE.VertexColors, alphaTest: 0.5, transparent: true } );
material.color.setHSL( 1.0, 0.2, 0.7 );
particles = new THREE.PointCloud( geometry, material );
particles.sortParticles = true;
scene.add( particles );
//
......
......@@ -346,9 +346,6 @@
particleCloud = new THREE.PointCloud( particles, shaderMaterial );
particleCloud.dynamic = true;
// particleCloud.sortParticles = true;
var vertices = particleCloud.geometry.vertices;
var values_size = attributes.size.value;
var values_color = attributes.pcolor.value;
......
......@@ -11,8 +11,6 @@ THREE.PointCloud = function ( geometry, material ) {
this.geometry = geometry !== undefined ? geometry : new THREE.Geometry();
this.material = material !== undefined ? material : new THREE.PointCloudMaterial( { color: Math.random() * 0xffffff } );
this.sortParticles = false;
};
THREE.PointCloud.prototype = Object.create( THREE.Object3D.prototype );
......@@ -149,8 +147,6 @@ THREE.PointCloud.prototype.clone = function ( object ) {
if ( object === undefined ) object = new THREE.PointCloud( this.geometry, this.material );
object.sortParticles = this.sortParticles;
THREE.Object3D.prototype.clone.call( this, object );
return object;
......
......@@ -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 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册