Skip to content

Commit

Permalink
Updated examples with the new .add/.remove methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Sep 5, 2011
1 parent 6141390 commit a940f05
Show file tree
Hide file tree
Showing 119 changed files with 435 additions and 463 deletions.
12 changes: 6 additions & 6 deletions examples/canvas_camera_orthographic.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@

var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ) );
line.position.z = ( i * 50 ) - 500;
scene.addObject( line );
scene.add( line );

var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0x000000, opacity: 0.2 } ) );
line.position.x = ( i * 50 ) - 500;
line.rotation.y = 90 * Math.PI / 180;
scene.addObject( line );
scene.add( line );

}

Expand All @@ -84,28 +84,28 @@
cube.position.y = ( cube.scale.y * 50 ) / 2;
cube.position.z = Math.floor( ( Math.random() * 1000 - 500 ) / 50 ) * 50 + 25;

scene.addObject(cube);
scene.add(cube);

}

// Lights

var ambientLight = new THREE.AmbientLight( Math.random() * 0x10 );
scene.addLight( ambientLight );
scene.add( ambientLight );

var directionalLight = new THREE.DirectionalLight( Math.random() * 0xffffff );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.addLight( directionalLight );
scene.add( directionalLight );

var directionalLight = new THREE.DirectionalLight( Math.random() * 0xffffff );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.addLight( directionalLight );
scene.add( directionalLight );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_geometry_birds.html
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
bird.position = boids[ i ].position;
bird.doubleSided = true;
// bird.scale.x = bird.scale.y = bird.scale.z = 10;
scene.addObject( bird );
scene.add( bird );


}
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_geometry_cube.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() );
cube.position.y = 150;
cube.overdraw = true;
scene.addObject( cube );
scene.add( cube );

// Plane

plane = new THREE.Mesh( new THREE.PlaneGeometry( 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xe0e0e0 } ) );
plane.rotation.x = - 90 * ( Math.PI / 180 );
plane.overdraw = true;
scene.addObject( plane );
scene.add( plane );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_geometry_earth.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@
mesh.overdraw = true;
mesh.position.y = - 250;
mesh.rotation.x = - 90 * Math.PI / 180;
scene.addObject(mesh);
scene.add(mesh);

mesh = new THREE.Mesh( new THREE.SphereGeometry( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ) );
mesh.overdraw = true;
scene.addObject(mesh);
scene.add(mesh);

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_geometry_hierarchy.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();

group.addChild( mesh );
group.add( mesh );

}

scene.addObject( group );
scene.add( group );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_geometry_panorama.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

mesh = new THREE.Mesh( new THREE.CubeGeometry( 300, 300, 300, 7, 7, 7, materials, true ), new THREE.MeshFaceMaterial() );
mesh.overdraw = true;
scene.addObject( mesh );
scene.add( mesh );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_geometry_panorama_fisheye.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

mesh = new THREE.Mesh( new THREE.CubeGeometry( 300, 300, 300, 7, 7, 7, materials, true ), new THREE.MeshFaceMaterial() );
mesh.overdraw = true;
scene.addObject( mesh );
scene.add( mesh );

for ( var i = 0, l = mesh.geometry.vertices.length; i < l; i ++ ) {

Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_geometry_terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
mesh = new THREE.Mesh( plane, material );
mesh.rotation.x = -90 * Math.PI / 180;
mesh.overdraw = true;
scene.addObject( mesh );
scene.add( mesh );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_geometry_text.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@
text.overdraw = true;

parent = new THREE.Object3D();
parent.addChild( text );
parent.add( text );

scene.addObject( parent );
scene.add( parent );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_interactive_cubes.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
object.rotation.x = ( Math.random() * 360 ) * Math.PI / 180;
object.rotation.y = ( Math.random() * 360 ) * Math.PI / 180;
object.rotation.z = ( Math.random() * 360 ) * Math.PI / 180;
scene.addObject( object );
scene.add( object );

objects.push( object );

Expand Down Expand Up @@ -118,7 +118,7 @@
var particle = new THREE.Particle( particleMaterial );
particle.position = intersects[ 0 ].point;
particle.scale.x = particle.scale.y = 8;
scene.addObject( particle );
scene.add( particle );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_interactive_cubes_tween.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
object.rotation.x = ( Math.random() * 360 ) * Math.PI / 180;
object.rotation.y = ( Math.random() * 360 ) * Math.PI / 180;
object.rotation.z = ( Math.random() * 360 ) * Math.PI / 180;
scene.addObject( object );
scene.add( object );

}

Expand Down
2 changes: 1 addition & 1 deletion examples/canvas_interactive_particles.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
particle.position.y = Math.random() * 800 - 400;
particle.position.z = Math.random() * 800 - 400;
particle.scale.x = particle.scale.y = Math.random() * 10 + 10;
scene.addObject( particle );
scene.add( particle );

}

Expand Down
16 changes: 8 additions & 8 deletions examples/canvas_interactive_voxelpainter.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,42 +62,42 @@

var line = new THREE.Line( geometry, material );
line.position.z = ( i * 50 ) - 500;
scene.addObject( line );
scene.add( line );

var line = new THREE.Line( geometry, material );
line.position.x = ( i * 50 ) - 500;
line.rotation.y = 90 * Math.PI / 180;
scene.addObject( line );
scene.add( line );

}

projector = new THREE.Projector();

plane = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshFaceMaterial() );
plane.rotation.x = - 90 * Math.PI / 180;
scene.addObject( plane );
scene.add( plane );

mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
ray = new THREE.Ray( camera.position, null );

// Lights

var ambientLight = new THREE.AmbientLight( 0x606060 );
scene.addLight( ambientLight );
scene.add( ambientLight );

var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.addLight( directionalLight );
scene.add( directionalLight );

var directionalLight = new THREE.DirectionalLight( 0x808080 );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.addLight( directionalLight );
scene.add( directionalLight );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down Expand Up @@ -137,7 +137,7 @@

if ( intersects[ 0 ].object != plane ) {

scene.removeObject( intersects[ 0 ].object );
scene.remove( intersects[ 0 ].object );

}

Expand All @@ -152,7 +152,7 @@
voxel.matrixAutoUpdate = false;
voxel.updateMatrix();
voxel.overdraw = true;
scene.addObject( voxel );
scene.add( voxel );

}

Expand Down
16 changes: 8 additions & 8 deletions examples/canvas_lights_pointlights.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@

scene = new THREE.Scene();

scene.addLight( new THREE.AmbientLight( 0x00020 ) );
scene.add( new THREE.AmbientLight( 0x00020 ) );

light1 = new THREE.PointLight( 0xff0040, 1, 50 );
scene.addLight( light1 );
scene.add( light1 );

light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
scene.addLight( light2 );
scene.add( light2 );

light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
scene.addLight( light3 );
scene.add( light3 );

var PI2 = Math.PI * 2;
var program = function ( context ) {
Expand All @@ -85,19 +85,19 @@

particle1 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0xff0040, program: program } ) );
particle1.scale.x = particle1.scale.y = particle1.scale.z = 0.5;
scene.addObject( particle1 );
scene.add( particle1 );

particle2 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x0040ff, program: program } ) );
particle2.scale.x = particle2.scale.y = particle2.scale.z = 0.5;
scene.addObject( particle2 );
scene.add( particle2 );

particle3 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x80ff80, program: program } ) );
particle3.scale.x = particle3.scale.y = particle3.scale.z = 0.5;
scene.addObject( particle3 );
scene.add( particle3 );

mesh = new THREE.Mesh( new WaltHead(), new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ) );
mesh.overdraw = true;
scene.addObject( mesh );
scene.add( mesh );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
16 changes: 8 additions & 8 deletions examples/canvas_lights_pointlights_smooth.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@

scene = new THREE.Scene();

scene.addLight( new THREE.AmbientLight( 0x00020 ) );
scene.add( new THREE.AmbientLight( 0x00020 ) );

light1 = new THREE.PointLight( 0xff0040, 1, 50 );
scene.addLight( light1 );
scene.add( light1 );

light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
scene.addLight( light2 );
scene.add( light2 );

light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
scene.addLight( light3 );
scene.add( light3 );

var PI2 = Math.PI * 2;
var program = function ( context ) {
Expand All @@ -85,22 +85,22 @@

particle1 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0xff0040, program: program } ) );
particle1.scale.x = particle1.scale.y = particle1.scale.z = 0.5;
scene.addObject( particle1 );
scene.add( particle1 );

particle2 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x0040ff, program: program } ) );
particle2.scale.x = particle2.scale.y = particle2.scale.z = 0.5;
scene.addObject( particle2 );
scene.add( particle2 );

particle3 = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: 0x80ff80, program: program } ) );
particle3.scale.x = particle3.scale.y = particle3.scale.z = 0.5;
scene.addObject( particle3 );
scene.add( particle3 );

geometry = new WaltHead();
geometry.computeVertexNormals();

mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ) );
mesh.overdraw = true;
scene.addObject( mesh );
scene.add( mesh );

renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_lines.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
particle.position.normalize();
particle.position.multiplyScalar( Math.random() * 10 + 450 );
particle.scale.x = particle.scale.y = 5;
scene.addObject( particle );
scene.add( particle );

geometry.vertices.push( new THREE.Vertex( particle.position ) );

Expand All @@ -92,7 +92,7 @@
// lines

var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffffff, opacity: 0.5 } ) );
scene.addObject( line );
scene.add( line );

document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false );
Expand Down
4 changes: 2 additions & 2 deletions examples/canvas_lines_sphere.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
particle.position.z = Math.random() * 2 - 1;
particle.position.normalize();
particle.position.multiplyScalar( Math.random() * 10 + 450 );
scene.addObject( particle );
scene.add( particle );

}

Expand All @@ -105,7 +105,7 @@
geometry.vertices.push( new THREE.Vertex( vector2 ) );

var line = new THREE.Line( geometry, new THREE.LineBasicMaterial( { color: 0xffffff, opacity: Math.random() } ) );
scene.addObject( line );
scene.add( line );
}

document.addEventListener( 'mousemove', onDocumentMouseMove, false );
Expand Down
Loading

0 comments on commit a940f05

Please sign in to comment.