diff --git a/examples/js/renderers/SoftwareRenderer.js b/examples/js/renderers/SoftwareRenderer.js index 35495b961f4c4eb7cbd9665b7105bf4fe054f409..aed927cc3c727696f2991933c5d8cde449b70a0a 100644 --- a/examples/js/renderers/SoftwareRenderer.js +++ b/examples/js/renderers/SoftwareRenderer.js @@ -540,7 +540,7 @@ THREE.SoftwareRenderer = function ( parameters ) { } else { - if ( material.vertexColors === THREE.FaceColors ) { + if ( material.vertexColors === THREE.FaceColors || material.vertexColors === THREE.VertexColors ) { string = [ 'var colorOffset = offset * 4;', diff --git a/examples/software_lines_splines.html b/examples/software_lines_splines.html index 1ea9e339bdb61cf99f2d905d3c6e9c7737dd0157..9b665fb8bcbf69c0c8b6b6f1ce42df1d921c7494 100644 --- a/examples/software_lines_splines.html +++ b/examples/software_lines_splines.html @@ -66,9 +66,7 @@ function init() { - var i, container; - - container = document.createElement( 'div' ); + var container = document.createElement( 'div' ); document.body.appendChild( container ); camera = new THREE.PerspectiveCamera( 33, window.innerWidth / window.innerHeight, 1, 10000 ); @@ -81,38 +79,51 @@ container.appendChild( renderer.domElement ); - var geometry = new THREE.Geometry(), - geometry2 = new THREE.Geometry(), - geometry3 = new THREE.Geometry(), - points = hilbert3D( new THREE.Vector3(), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 ), - colors = [], colors2 = [], colors3 = []; + // + + var hilbertPoints = hilbert3D( new THREE.Vector3( 0, 0, 0 ), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 ); + + var geometry1 = new THREE.BufferGeometry(); + var geometry2 = new THREE.BufferGeometry(); + var geometry3 = new THREE.BufferGeometry(); var subdivisions = 6; - var spline = new THREE.CatmullRomCurve3( points ); + var vertices = []; + var colors1 = []; + var colors2 = []; + var colors3 = []; + var point = new THREE.Vector3(); + var color = new THREE.Color(); + + var spline = new THREE.CatmullRomCurve3( hilbertPoints ); + + for ( var i = 0; i < hilbertPoints.length * subdivisions; i ++ ) { - for ( i = 0; i < points.length * subdivisions; i ++ ) { + var t = i / ( hilbertPoints.length * subdivisions ); + spline.getPoint( t, point ); - var t = i / ( points.length * subdivisions ); - geometry.vertices[ i ] = spline.getPoint( t ); + vertices.push( point.x, point.y, point.z ); - colors[ i ] = new THREE.Color( 0xffffff ); - colors[ i ].setHSL( 0.6, 1.0, Math.max( 0, - point.x / 200 ) + 0.5 ); + color.setHSL( 0.6, 1.0, Math.max( 0, - point.x / 200 ) + 0.5 ); + colors1.push( color.r, color.g, color.b ); - colors2[ i ] = new THREE.Color( 0xffffff ); - colors2[ i ].setHSL( 0.9, 1.0, Math.max( 0, - point.y / 200 ) + 0.5 ); + color.setHSL( 0.9, 1.0, Math.max( 0, - point.y / 200 ) + 0.5 ); + colors2.push( color.r, color.g, color.b ); - colors3[ i ] = new THREE.Color( 0xffffff ); - colors3[ i ].setHSL( i / ( points.length * subdivisions ), 1.0, 0.5 ); + color.setHSL( i / ( hilbertPoints.length * subdivisions ), 1.0, 0.5 ); + colors3.push( color.r, color.g, color.b ); } - geometry2.vertices = geometry3.vertices = geometry.vertices; + geometry1.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + geometry2.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); + geometry3.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); - geometry.colors = colors; - geometry2.colors = colors2; - geometry3.colors = colors3; + geometry1.addAttribute( 'color', new THREE.Float32BufferAttribute( colors1, 3 ) ); + geometry2.addAttribute( 'color', new THREE.Float32BufferAttribute( colors2, 3 ) ); + geometry3.addAttribute( 'color', new THREE.Float32BufferAttribute( colors3, 3 ) ); // lines @@ -120,12 +131,12 @@ var line, p, scale = 0.3, d = 225; var parameters = [ - [ material, scale * 1.5, [ - d, 0, 0 ], geometry ], + [ material, scale * 1.5, [ - d, 0, 0 ], geometry1 ], [ material, scale * 1.5, [ 0, 0, 0 ], geometry2 ], [ material, scale * 1.5, [ d, 0, 0 ], geometry3 ] ]; - for ( i = 0; i < parameters.length; ++ i ) { + for ( var i = 0; i < parameters.length; ++ i ) { p = parameters[ i ]; line = new THREE.Line( p[ 3 ], p[ 0 ] ); diff --git a/examples/software_sandbox.html b/examples/software_sandbox.html index 280acc53610d694e9f456fab2b4b6288a06ebad9..0a7e296268dda4958dc7c1181e93544078ad6537 100644 --- a/examples/software_sandbox.html +++ b/examples/software_sandbox.html @@ -7,14 +7,31 @@ +
+ three.js - software renderer
+ drag to change the point of view +
+ @@ -23,9 +40,7 @@