From 029b4e511e51fa36d791448bd5ec09e609431c71 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 11 May 2015 16:38:33 -0400 Subject: [PATCH] TransformControls: Updated some Geometries to BufferGeometries. --- examples/js/controls/TransformControls.js | 35 ++++++++++++----------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/js/controls/TransformControls.js b/examples/js/controls/TransformControls.js index a3a2e95ec4..25b0085ef1 100644 --- a/examples/js/controls/TransformControls.js +++ b/examples/js/controls/TransformControls.js @@ -225,14 +225,14 @@ arrowGeometry.merge( mesh.geometry, mesh.matrix ); - var lineXGeometry = new THREE.Geometry(); - lineXGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ) ); + var lineXGeometry = new THREE.BufferGeometry(); + lineXGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0, 1, 0, 0 ], 3 ) ); - var lineYGeometry = new THREE.Geometry(); - lineYGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) ); + var lineYGeometry = new THREE.BufferGeometry(); + lineYGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) ); - var lineZGeometry = new THREE.Geometry(); - lineZGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 1 ) ); + var lineZGeometry = new THREE.BufferGeometry(); + lineZGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) ); this.handleGizmos = { X: [ @@ -331,14 +331,15 @@ var CircleGeometry = function ( radius, facing, arc ) { - var geometry = new THREE.Geometry(); + var geometry = new THREE.BufferGeometry(); + var vertices = []; arc = arc ? arc : 1; for ( var i = 0; i <= 64 * arc; ++ i ) { - if ( facing == 'x' ) geometry.vertices.push( new THREE.Vector3( 0, Math.cos( i / 32 * Math.PI ), Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) ); - if ( facing == 'y' ) geometry.vertices.push( new THREE.Vector3( Math.cos( i / 32 * Math.PI ), 0, Math.sin( i / 32 * Math.PI ) ).multiplyScalar(radius) ); - if ( facing == 'z' ) geometry.vertices.push( new THREE.Vector3( Math.sin( i / 32 * Math.PI ), Math.cos( i / 32 * Math.PI ), 0 ).multiplyScalar(radius) ); + if ( facing == 'x' ) vertices.push( 0, Math.cos( i / 32 * Math.PI ) * radius, Math.sin( i / 32 * Math.PI ) * radius ); + if ( facing == 'y' ) vertices.push( Math.cos( i / 32 * Math.PI ) * radius, 0, Math.sin( i / 32 * Math.PI ) * radius ); + if ( facing == 'z' ) vertices.push( Math.sin( i / 32 * Math.PI ) * radius, Math.cos( i / 32 * Math.PI ) * radius, 0 ); } - + geometry.addAttribute( 'position', new THREE.Float32Attribute( vertices, 3 ) ); return geometry; }; @@ -463,14 +464,14 @@ arrowGeometry.merge( mesh.geometry, mesh.matrix ); - var lineXGeometry = new THREE.Geometry(); - lineXGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 1, 0, 0 ) ); + var lineXGeometry = new THREE.BufferGeometry(); + lineXGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0, 1, 0, 0 ], 3 ) ); - var lineYGeometry = new THREE.Geometry(); - lineYGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 1, 0 ) ); + var lineYGeometry = new THREE.BufferGeometry(); + lineYGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0, 0, 1, 0 ], 3 ) ); - var lineZGeometry = new THREE.Geometry(); - lineZGeometry.vertices.push( new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, 1 ) ); + var lineZGeometry = new THREE.BufferGeometry(); + lineZGeometry.addAttribute( 'position', new THREE.Float32Attribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) ); this.handleGizmos = { X: [ -- GitLab