Pārlūkot izejas kodu

Examples: *Attribute to *BufferAttribute.

Mr.doob 8 gadi atpakaļ
vecāks
revīzija
724b535553

+ 7 - 7
examples/js/controls/TransformControls.js

@@ -233,13 +233,13 @@
 		arrowGeometry.merge( mesh.geometry, mesh.matrix );
 
 		var lineXGeometry = new THREE.BufferGeometry();
-		lineXGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0,  1, 0, 0 ], 3 ) );
+		lineXGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0,  1, 0, 0 ], 3 ) );
 
 		var lineYGeometry = new THREE.BufferGeometry();
-		lineYGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0,  0, 1, 0 ], 3 ) );
+		lineYGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0,  0, 1, 0 ], 3 ) );
 
 		var lineZGeometry = new THREE.BufferGeometry();
-		lineZGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0,  0, 0, 1 ], 3 ) );
+		lineZGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0,  0, 0, 1 ], 3 ) );
 
 		this.handleGizmos = {
 
@@ -372,7 +372,7 @@
 
 			}
 
-			geometry.addAttribute( 'position', new THREE.Float32Attribute( vertices, 3 ) );
+			geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
 			return geometry;
 
 		};
@@ -516,13 +516,13 @@
 		arrowGeometry.merge( mesh.geometry, mesh.matrix );
 
 		var lineXGeometry = new THREE.BufferGeometry();
-		lineXGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0,  1, 0, 0 ], 3 ) );
+		lineXGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0,  1, 0, 0 ], 3 ) );
 
 		var lineYGeometry = new THREE.BufferGeometry();
-		lineYGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0,  0, 1, 0 ], 3 ) );
+		lineYGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0,  0, 1, 0 ], 3 ) );
 
 		var lineZGeometry = new THREE.BufferGeometry();
-		lineZGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0,  0, 0, 1 ], 3 ) );
+		lineZGeometry.addAttribute( 'position', new THREE.Float32BufferAttribute( [ 0, 0, 0,  0, 0, 1 ], 3 ) );
 
 		this.handleGizmos = {
 

+ 1 - 1
examples/js/loaders/ColladaLoader2.js

@@ -1235,7 +1235,7 @@ THREE.ColladaLoader.prototype = {
 
 			}
 
-			return new THREE.Float32Attribute( array, sourceStride );
+			return new THREE.Float32BufferAttribute( array, sourceStride );
 
 		}
 

+ 7 - 7
examples/js/loaders/MMDLoader.js

@@ -2110,7 +2110,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 			var m = model.morphs[ i ];
 			var params = { name: m.name };
 
-			var attribute = new THREE.Float32Attribute( model.metadata.vertexCount * 3, 3 );
+			var attribute = new THREE.Float32BufferAttribute( model.metadata.vertexCount * 3, 3 );
 
 			for ( var j = 0; j < model.metadata.vertexCount * 3; j++ ) {
 
@@ -2802,12 +2802,12 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress
 
 	var initGeometry = function () {
 
-		geometry.setIndex( ( buffer.indices.length > 65535 ? THREE.Uint32Attribute : THREE.Uint16Attribute )( buffer.indices, 1 ) );
-		geometry.addAttribute( 'position', THREE.Float32Attribute( buffer.vertices, 3 ) );
-		geometry.addAttribute( 'normal', THREE.Float32Attribute( buffer.normals, 3 ) );
-		geometry.addAttribute( 'uv', THREE.Float32Attribute( buffer.uvs, 2 ) );
-		geometry.addAttribute( 'skinIndex', THREE.Float32Attribute( buffer.skinIndices, 4 ) );
-		geometry.addAttribute( 'skinWeight', THREE.Float32Attribute( buffer.skinWeights, 4 ) );
+		geometry.setIndex( new ( buffer.indices.length > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
+		geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
+		geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
+		geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );
+		geometry.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( buffer.skinIndices, 4 ) );
+		geometry.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( buffer.skinWeights, 4 ) );
 
 		geometry.computeBoundingSphere();
 		geometry.mmdFormat = model.metadata.format;

+ 5 - 5
examples/js/loaders/PLYLoader.js

@@ -312,26 +312,26 @@ THREE.PLYLoader.prototype = {
 
 			// mandatory buffer data
 
-			geometry.setIndex( ( buffer.indices.length > 65535 ? THREE.Uint32Attribute : THREE.Uint16Attribute )( buffer.indices, 1 ) );
-			geometry.addAttribute( 'position', THREE.Float32Attribute( buffer.vertices, 3 ) );
+			geometry.setIndex( new ( buffer.indices.length > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( buffer.indices, 1 ) );
+			geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( buffer.vertices, 3 ) );
 
 			// optional buffer data
 
 			if ( buffer.normals.length > 0 ) {
 
-				geometry.addAttribute( 'normal', THREE.Float32Attribute( buffer.normals, 3 ) );
+				geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( buffer.normals, 3 ) );
 
 			}
 
 			if ( buffer.uvs.length > 0 ) {
 
-				geometry.addAttribute( 'uv', THREE.Float32Attribute( buffer.uvs, 2 ) );
+				geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( buffer.uvs, 2 ) );
 
 			}
 
 			if ( buffer.colors.length > 0 ) {
 
-				geometry.addAttribute( 'color', THREE.Float32Attribute( buffer.colors, 3 ) );
+				geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( buffer.colors, 3 ) );
 
 			}
 

+ 1 - 1
examples/js/loaders/PlayCanvasLoader.js

@@ -55,7 +55,7 @@ THREE.PlayCanvasLoader.prototype = {
 
 			var geometry = new THREE.BufferGeometry();
 
-			geometry.setIndex( new THREE.Uint16Attribute( data.indices, 1 ) );
+			geometry.setIndex( new THREE.Uint16BufferAttribute( data.indices, 1 ) );
 
 			var attributes = model.vertices[ data.vertices ]._attributes;
 

+ 9 - 9
examples/js/loaders/sea3d/SEA3DLoader.js

@@ -579,7 +579,7 @@ THREE.SEA3D.Animator.prototype.play = function( name, crossfade, offset, weight
 
 	if ( animation == this.currentAnimation ) {
 
-		if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : 
+		if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset :
 			( this.mixer.timeScale >= 0 ? 0 : this.currentAnimation.duration );
 
 		this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 );
@@ -604,7 +604,7 @@ THREE.SEA3D.Animator.prototype.play = function( name, crossfade, offset, weight
 
 		this.updateTimeScale();
 
-		if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : 
+		if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset :
 			( this.mixer.timeScale >= 0 ? 0 : this.currentAnimation.duration );
 
 		this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 );
@@ -1535,8 +1535,8 @@ THREE.SEA3D.prototype.readGeometryBuffer = function( sea ) {
 
 	if ( sea.joint ) {
 
-		geo.addAttribute( 'skinIndex', new THREE.Float32Attribute( sea.joint, sea.jointPerVertex ) );
-		geo.addAttribute( 'skinWeight', new THREE.Float32Attribute( sea.weight, sea.jointPerVertex ) );
+		geo.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( sea.joint, sea.jointPerVertex ) );
+		geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( sea.weight, sea.jointPerVertex ) );
 
 	}
 
@@ -1584,7 +1584,7 @@ THREE.SEA3D.prototype.readLine = function( sea ) {
 	if ( sea.closed )
 		sea.vertex.push( sea.vertex[ 0 ], sea.vertex[ 1 ], sea.vertex[ 2 ] );
 
-	geo.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( sea.vertex ), 3 ) );
+	geo.addAttribute( 'position', new THREE.Float32BufferAttribute( sea.vertex, 3 ) );
 
 	var line = new THREE.Line( geo, new THREE.LineBasicMaterial( { color: THREE.SEA3D.HELPER_COLOR, linewidth: 3 } ) );
 	line.name = sea.name;
@@ -2487,12 +2487,12 @@ THREE.SEA3D.prototype.readMorpher = function( sea ) {
 
 		var node = sea.node[ i ];
 
-		attribs.position[ i ] = new THREE.Float32Attribute( new Float32Array( node.vertex ), 3 );
+		attribs.position[ i ] = new THREE.Float32BufferAttribute( node.vertex, 3 );
 
 		if ( node.normal ) {
 
 			attribs.normal = attribs.normal || [];
-			attribs.normal[ i ] = new THREE.Float32Attribute( new Float32Array( node.normal ), 3 );
+			attribs.normal[ i ] = new THREE.Float32BufferAttribute( node.normal, 3 );
 
 		}
 
@@ -2590,12 +2590,12 @@ THREE.SEA3D.prototype.readVertexAnimation = function( sea ) {
 
 		var frame = sea.frame[ i ];
 
-		attribs.position[ i ] = new THREE.Float32Attribute( new Float32Array( frame.vertex ), 3 );
+		attribs.position[ i ] = new THREE.Float32BufferAttribute( frame.vertex, 3 );
 
 		if ( frame.normal ) {
 
 			attribs.normal = attribs.normal || [];
-			attribs.normal[ i ] = new THREE.Float32Attribute( new Float32Array( frame.normal ), 3 );
+			attribs.normal[ i ] = new THREE.Float32BufferAttribute( frame.normal, 3 );
 
 		}
 

+ 3 - 3
examples/webgl_custom_attributes_lines.html

@@ -139,13 +139,13 @@
 
 			var buffergeometry = new THREE.BufferGeometry();
 
-			var position = new THREE.Float32Attribute( vertices.length * 3, 3 ).copyVector3sArray( vertices );
+			var position = new THREE.Float32BufferAttribute( vertices.length * 3, 3 ).copyVector3sArray( vertices );
 			buffergeometry.addAttribute( 'position', position )
 
-			var displacement = new THREE.Float32Attribute( vertices.length * 3, 3 );
+			var displacement = new THREE.Float32BufferAttribute( vertices.length * 3, 3 );
 			buffergeometry.addAttribute( 'displacement', displacement );
 
-			var customColor = new THREE.Float32Attribute( vertices.length * 3, 3 );
+			var customColor = new THREE.Float32BufferAttribute( vertices.length * 3, 3 );
 			buffergeometry.addAttribute( 'customColor', customColor );
 
 			var color = new THREE.Color( 0xffffff );

+ 1 - 1
examples/webgl_shaders_vector.html

@@ -276,7 +276,7 @@
 				bezierGeometry.computeVertexNormals();
 
 				bezierGeometry = new THREE.BufferGeometry().fromGeometry( bezierGeometry );
-				bezierGeometry.addAttribute( 'invert', new THREE.Float32Attribute( invert, 1 ) );
+				bezierGeometry.addAttribute( 'invert', new THREE.Float32BufferAttribute( invert, 1 ) );
 
 				//