提交 28ad7aa2 编写于 作者: M Mr.doob

Renamed scene.objects to scene.__objects and fixed all the examples that relied on it.

上级 4e2f5aaa
......@@ -190,19 +190,25 @@
camera.lookAt( scene.position );
for ( var i = 0, l = scene.objects.length; i < l; i ++ ) {
for ( var i = 0, l = scene.children.length; i < l; i ++ ) {
if ( i%3 == 1 )
var object = scene.children[ i ];
scene.objects[i].rotation.z += 0.05;
if ( object instanceof THREE.Mesh ) {
else if ( i%3 == 2 )
if ( i % 3 == 1 )
scene.objects[i].rotation.y += 0.05;
object.rotation.z += 0.05;
else if ( i%3 == 0 )
else if ( i % 3 == 2 )
scene.objects[i].rotation.x += 0.05;
object.rotation.y += 0.05;
else if ( i % 3 == 0 )
object.rotation.x += 0.05;
}
}
......
......@@ -369,8 +369,8 @@
//
renderer = new THREE.WebGLRenderer( { antialias: true, clearColor: 0xf0f0f0 } );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
......
......@@ -269,9 +269,10 @@
var time = Date.now() * 0.0005;
for( var i = 0; i < scene.objects.length; i ++ ) {
for ( var i = 0; i < scene.children.length; i ++ ) {
scene.objects[ i ].rotation.y = time * ( i % 2 ? 1 : -1 );
var object = scene.children[ i ];
if ( object instanceof THREE.Line ) object.rotation.y = time * ( i % 2 ? 1 : -1 );
}
......
......@@ -218,9 +218,10 @@
var time = Date.now() * 0.0015;
for( var i = 0; i < scene.objects.length; i ++ ) {
for ( var i = 0; i < scene.children.length; i ++ ) {
scene.objects[ i ].rotation.y = time * ( i % 2 ? 1 : -1 );
var object = scene.children[ i ];
if ( object instanceof THREE.Line ) object.rotation.y = time * ( i % 2 ? 1 : -1 );
}
......
......@@ -176,11 +176,17 @@
var time = Date.now() * 0.0001;
for( var i = 0; i < scene.objects.length; i ++ ) {
for ( var i = 0; i < scene.children.length; i ++ ) {
scene.objects[ i ].rotation.y = time * ( i < 4 ? ( i + 1 ) : - ( i + 1 ) );
var object = scene.children[ i ];
if ( i < 5 ) scene.objects[i].scale.x = scene.objects[i].scale.y = scene.objects[i].scale.z = scene.objects[i].originalScale * (i/5+1) * (1 + 0.5 * Math.sin( 7*time ) );
if ( object instanceof THREE.Line ) {
object.rotation.y = time * ( i < 4 ? ( i + 1 ) : - ( i + 1 ) );
if ( i < 5 ) object.scale.x = object.scale.y = object.scale.z = object.originalScale * (i/5+1) * (1 + 0.5 * Math.sin( 7*time ) );
}
}
......
......@@ -247,9 +247,15 @@
var time = Date.now() * 0.0005;
for( var i = 0; i < scene.objects.length; i ++ ) {
for ( var i = 0; i < scene.children.length; i ++ ) {
scene.objects[ i ].rotation.y = time * ( i % 2 ? 1 : -1 );
var object = scene.children[ i ];
if ( object instanceof THREE.Line ) {
object.rotation.y = time * ( i % 2 ? 1 : -1 );
}
}
......
......@@ -162,14 +162,6 @@
camera.lookAt( scene.position );
/*
for( i = 0; i < scene.objects.length; i++ ) {
scene.objects[i].rotation.y = 5*time * ( i < 4 ? i+1 : - (i+1) );
}
*/
h = ( 360 * ( 1.0 + time ) % 360 ) / 360;
material.color.setHSV( h, 0.75, 0.8 );
......
......@@ -167,13 +167,19 @@
camera.lookAt( scene.position );
for( i = 0; i < scene.objects.length; i ++ ) {
for ( i = 0; i < scene.children.length; i ++ ) {
scene.objects[i].rotation.y = time * ( i < 4 ? i+1 : - (i+1) );
var object = scene.children[ i ];
if ( object instanceof THREE.ParticleSystem ) {
object.rotation.y = time * ( i < 4 ? i + 1 : - ( i + 1 ) );
}
}
for( i = 0; i < materials.length; i ++ ) {
for ( i = 0; i < materials.length; i ++ ) {
color = parameters[i][0];
......
......@@ -176,13 +176,19 @@
camera.lookAt( scene.position );
for( i = 0; i < scene.objects.length; i ++ ) {
for ( i = 0; i < scene.children.length; i ++ ) {
scene.objects[i].rotation.y = time * ( i < 4 ? i+1 : - (i+1) );
var object = scene.children[ i ];
if ( object instanceof THREE.ParticleSystem ) {
object.rotation.y = time * ( i < 4 ? i + 1 : - ( i + 1 ) );
}
}
for( i = 0; i < materials.length; i ++ ) {
for ( i = 0; i < materials.length; i ++ ) {
color = parameters[i][0];
......
......@@ -3269,7 +3269,7 @@ THREE.WebGLRenderer = function ( parameters ) {
webglObject, object,
renderList,
lights = scene.lights,
lights = scene.__lights,
fog = scene.fog;
_currentMaterialId = -1;
......@@ -4298,7 +4298,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function setMaterialShaders ( material, shaders ) {
function setMaterialShaders( material, shaders ) {
material.uniforms = THREE.UniformsUtils.clone( shaders.uniforms );
material.vertexShader = shaders.vertexShader;
......@@ -4306,7 +4306,7 @@ THREE.WebGLRenderer = function ( parameters ) {
};
function setProgram ( camera, lights, fog, material, object ) {
function setProgram( camera, lights, fog, material, object ) {
if ( ! material.program ) {
......
......@@ -11,8 +11,8 @@ THREE.Scene = function () {
this.matrixAutoUpdate = false;
this.objects = [];
this.lights = [];
this.__objects = [];
this.__lights = [];
this.__objectsAdded = [];
this.__objectsRemoved = [];
......@@ -26,17 +26,17 @@ THREE.Scene.prototype.addObject = function ( object ) {
if ( object instanceof THREE.Light ) {
if ( this.lights.indexOf( object ) === - 1 ) {
if ( this.__lights.indexOf( object ) === - 1 ) {
this.lights.push( object );
this.__lights.push( object );
}
} else if ( !( object instanceof THREE.Camera || object instanceof THREE.Bone ) ) {
if ( this.objects.indexOf( object ) === - 1 ) {
if ( this.__objects.indexOf( object ) === - 1 ) {
this.objects.push( object );
this.__objects.push( object );
this.__objectsAdded.push( object );
// check if previously removed
......@@ -65,21 +65,21 @@ THREE.Scene.prototype.removeObject = function ( object ) {
if ( object instanceof THREE.Light ) {
var i = this.lights.indexOf( object );
var i = this.__lights.indexOf( object );
if ( i !== -1 ) {
this.lights.splice( i, 1 );
this.__lights.splice( i, 1 );
}
} else if ( !( object instanceof THREE.Camera ) ) {
var i = this.objects.indexOf( object );
var i = this.__objects.indexOf( object );
if( i !== -1 ) {
this.objects.splice( i, 1 );
this.__objects.splice( i, 1 );
this.__objectsRemoved.push( object );
// check if previously added
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册