提交 9e322bc2 编写于 作者: B Brage Nilsson

Fix instancing examples (see #6473)

上级 191bb16c
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
var offsets = new THREE.InstancedBufferAttribute( new Float32Array( instances * 3 ), 3, 1, false ); var offsets = new THREE.InstancedBufferAttribute( new Float32Array( instances * 3 ), 3, 1, false );
for ( var i = 0, ul = offsets.length / 3; i < ul; i++ ) { for ( var i = 0, ul = offsets.length; i < ul; i++ ) {
offsets.setXYZ( i, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5 ); offsets.setXYZ( i, Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5 );
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
var colors = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, false ); var colors = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, false );
for ( var i = 0, ul = colors.length / 4; i < ul; i++ ) { for ( var i = 0, ul = colors.length; i < ul; i++ ) {
colors.setXYZW( i, Math.random(), Math.random(), Math.random(), Math.random() ); colors.setXYZW( i, Math.random(), Math.random(), Math.random(), Math.random() );
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
var orientationsStart = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, false ); var orientationsStart = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, false );
for ( var i = 0, ul = orientationsStart.length / 4; i < ul; i++ ) { for ( var i = 0, ul = orientationsStart.length; i < ul; i++ ) {
vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ); vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 );
vector.normalize(); vector.normalize();
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
var orientationsEnd = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, false ); var orientationsEnd = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, false );
for ( var i = 0, ul = orientationsEnd.length / 4; i < ul; i++ ) { for ( var i = 0, ul = orientationsEnd.length; i < ul; i++ ) {
vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ); vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 );
vector.normalize(); vector.normalize();
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
var offsets = new THREE.InstancedBufferAttribute( new Float32Array( instances * 3 ), 3, 1, false ); var offsets = new THREE.InstancedBufferAttribute( new Float32Array( instances * 3 ), 3, 1, false );
var vector = new THREE.Vector4(); var vector = new THREE.Vector4();
for ( var i = 0, ul = offsets.length / 3; i < ul; i++ ) { for ( var i = 0, ul = offsets.length; i < ul; i++ ) {
var x = Math.random() * 100 - 50; var x = Math.random() * 100 - 50;
var y = Math.random() * 100 - 50; var y = Math.random() * 100 - 50;
var z = Math.random() * 100 - 50; var z = Math.random() * 100 - 50;
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
orientations = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, true ); orientations = new THREE.InstancedBufferAttribute( new Float32Array( instances * 4 ), 4, 1, true );
for ( var i = 0, ul = orientations.length / 4; i < ul; i++ ) { for ( var i = 0, ul = orientations.length; i < ul; i++ ) {
vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 ); vector.set( Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random() * 2 - 1 );
vector.normalize(); vector.normalize();
...@@ -318,7 +318,7 @@ ...@@ -318,7 +318,7 @@
var delta = ( time - lastTime ) / 5000; var delta = ( time - lastTime ) / 5000;
tmpQ.set( moveQ.x * delta, moveQ.y * delta, moveQ.z * delta, 1 ).normalize(); tmpQ.set( moveQ.x * delta, moveQ.y * delta, moveQ.z * delta, 1 ).normalize();
for ( var i = 0, ul = orientations.length / 4; i < ul; i++ ) { for ( var i = 0, ul = orientations.length; i < ul; i++ ) {
var index = i * 4; var index = i * 4;
currentQ.set( orientations.array[index], orientations.array[index + 1], orientations.array[index + 2], orientations.array[index + 3] ); currentQ.set( orientations.array[index], orientations.array[index + 1], orientations.array[index + 2], orientations.array[index + 3] );
currentQ.multiply( tmpQ ); currentQ.multiply( tmpQ );
...@@ -338,4 +338,4 @@ ...@@ -338,4 +338,4 @@
</html> </html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册