diff --git a/examples/js/math/Lut.js b/examples/js/math/Lut.js index 0190ab7ed4f5361c447a86fb716a8fd231539a13..e5f1c5c572002c15fc524ae0d2241be8b3a566b6 100644 --- a/examples/js/math/Lut.js +++ b/examples/js/math/Lut.js @@ -451,16 +451,16 @@ THREE.Lut.prototype = { var material = new THREE.LineBasicMaterial( { color: 0x000000, linewidth: 2 } ); - var geometry = new THREE.Geometry(); + var points = []; if ( this.legend.layout == 'vertical' ) { var linePosition = ( this.legend.position.y - ( this.legend.dimensions.height * 0.5 ) + 0.01 ) + ( this.legend.dimensions.height ) * ( ( value - this.minV ) / ( this.maxV - this.minV ) * 0.99 ); - geometry.vertices.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.55, linePosition, this.legend.position.z ) ); + points.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.55, linePosition, this.legend.position.z ) ); - geometry.vertices.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.7, linePosition, this.legend.position.z ) ); + points.push( new THREE.Vector3( this.legend.position.x + this.legend.dimensions.width * 0.7, linePosition, this.legend.position.z ) ); } @@ -468,12 +468,14 @@ THREE.Lut.prototype = { var linePosition = ( this.legend.position.x - ( this.legend.dimensions.height * 0.5 ) + 0.01 ) + ( this.legend.dimensions.height ) * ( ( value - this.minV ) / ( this.maxV - this.minV ) * 0.99 ); - geometry.vertices.push( new THREE.Vector3( linePosition, this.legend.position.y - this.legend.dimensions.width * 0.55, this.legend.position.z ) ); + points.push( new THREE.Vector3( linePosition, this.legend.position.y - this.legend.dimensions.width * 0.55, this.legend.position.z ) ); - geometry.vertices.push( new THREE.Vector3( linePosition, this.legend.position.y - this.legend.dimensions.width * 0.7, this.legend.position.z ) ); + points.push( new THREE.Vector3( linePosition, this.legend.position.y - this.legend.dimensions.width * 0.7, this.legend.position.z ) ); } + var geometry = new THREE.BufferGeometry().setFromPoints( points ); + var line = new THREE.Line( geometry, material ); lines[ i ] = line; diff --git a/examples/webgl_trails.html b/examples/webgl_trails.html index be6446d8ee3273097b5286fe8fa1b51ad9f77fd1..be4f0ad77623fe823d46173c1f0dfc1dec11f419 100644 --- a/examples/webgl_trails.html +++ b/examples/webgl_trails.html @@ -40,26 +40,29 @@ document.body.appendChild( container ); camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10000 ); - camera.position.set( 100000, 0, 3200 ); + camera.position.set( 0, 0, 1000 ); scene = new THREE.Scene(); - var colors = [ 0x000000, 0xff0080, 0x8000ff, 0xffffff ]; - var geometry = new THREE.Geometry(); + var colorArray = [ new THREE.Color( 0xff0080 ), new THREE.Color( 0xffffff ), new THREE.Color( 0x8000ff ) ]; + var positions = []; + var colors = []; - for ( var i = 0; i < 2000; i ++ ) { + for ( var i = 0; i < 100; i ++ ) { - var vertex = new THREE.Vector3(); - vertex.x = Math.random() * 4000 - 2000; - vertex.y = Math.random() * 4000 - 2000; - vertex.z = Math.random() * 4000 - 2000; - geometry.vertices.push( vertex ); + positions.push( 4000 * ( Math.random() - 0.5 ), 4000 * ( Math.random() - 0.5 ), 4000 * ( Math.random() - 0.5 ) ); - geometry.colors.push( new THREE.Color( colors[ Math.floor( Math.random() * colors.length ) ] ) ); + var clr = colorArray[ Math.floor( Math.random() * colorArray.length ) ]; + + colors.push( clr.r, clr.g, clr.b ); } - var material = new THREE.PointsMaterial( { size: 1, vertexColors: THREE. VertexColors, depthTest: false, opacity: 0.5, sizeAttenuation: false, transparent: true } ); + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) ); + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + var material = new THREE.PointsMaterial( { size: 4, vertexColors: THREE.VertexColors, depthTest: false, sizeAttenuation: false } ); var mesh = new THREE.Points( geometry, material ); scene.add( mesh ); diff --git a/examples/webvr_vive_dragging.html b/examples/webvr_vive_dragging.html index b81e91da118d1f296ed8df554a9d491cffeae1d7..7f6522903723012282b03a1f3975e90451f64224 100644 --- a/examples/webvr_vive_dragging.html +++ b/examples/webvr_vive_dragging.html @@ -64,7 +64,7 @@ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1, 10 ); user.add( camera ); - var geometry = new THREE.PlaneGeometry( 4, 4 ); + var geometry = new THREE.PlaneBufferGeometry( 4, 4 ); var material = new THREE.MeshStandardMaterial( { color: 0xeeeeee, roughness: 1.0, @@ -91,11 +91,11 @@ scene.add( group ); var geometries = [ - new THREE.BoxGeometry( 0.2, 0.2, 0.2 ), - new THREE.ConeGeometry( 0.2, 0.2, 64 ), - new THREE.CylinderGeometry( 0.2, 0.2, 0.2, 64 ), - new THREE.IcosahedronGeometry( 0.2, 3 ), - new THREE.TorusGeometry( 0.2, 0.04, 64, 32 ) + new THREE.BoxBufferGeometry( 0.2, 0.2, 0.2 ), + new THREE.ConeBufferGeometry( 0.2, 0.2, 64 ), + new THREE.CylinderBufferGeometry( 0.2, 0.2, 0.2, 64 ), + new THREE.IcosahedronBufferGeometry( 0.2, 3 ), + new THREE.TorusBufferGeometry( 0.2, 0.04, 64, 32 ) ]; for ( var i = 0; i < 50; i ++ ) { @@ -171,9 +171,7 @@ // - var geometry = new THREE.Geometry(); - geometry.vertices.push( new THREE.Vector3( 0, 0, 0 ) ); - geometry.vertices.push( new THREE.Vector3( 0, 0, - 1 ) ); + var geometry = new THREE.BufferGeometry().setFromPoints( [ new THREE.Vector3( 0, 0, 0 ), new THREE.Vector3( 0, 0, - 1 ) ] ); var line = new THREE.Line( geometry ); line.name = 'line';