From 4e07037493baaf6184c669d4b997f977dd9e46f5 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Sat, 1 Jul 2023 11:09:15 +0200 Subject: [PATCH] Manual: Honor latest changes. (#26355) --- manual/en/textures.html | 27 +- manual/en/voxel-geometry.html | 1 + .../examples/render-on-demand-w-damping.html | 161 +-- manual/examples/render-on-demand-w-gui.html | 215 ++-- manual/examples/render-on-demand.html | 165 +-- manual/examples/render-target.html | 218 ++-- manual/examples/responsive-editor.html | 32 +- manual/examples/responsive-hd-dpi.html | 146 ++- manual/examples/responsive-no-resize.html | 105 +- manual/examples/responsive-update-camera.html | 111 +- manual/examples/responsive.html | 144 ++- manual/examples/scenegraph-car.html | 183 +-- .../scenegraph-sun-earth-moon-axes-grids.html | 276 +++-- .../scenegraph-sun-earth-moon-axes.html | 198 +-- .../examples/scenegraph-sun-earth-moon.html | 180 +-- .../scenegraph-sun-earth-orbit-fixed.html | 152 ++- .../examples/scenegraph-sun-earth-orbit.html | 144 ++- manual/examples/scenegraph-sun-earth.html | 144 ++- manual/examples/scenegraph-sun.html | 134 +- manual/examples/scenegraph-tank.html | 493 ++++---- manual/examples/shadertoy-as-texture.html | 166 +-- manual/examples/shadertoy-basic-x40.html | 102 +- manual/examples/shadertoy-basic.html | 102 +- manual/examples/shadertoy-bleepy-blocks.html | 116 +- manual/examples/shadertoy-prep.html | 80 +- ...shadows-directional-light-shadow-acne.html | 432 ++++--- ...ows-directional-light-with-camera-gui.html | 429 ++++--- ...-directional-light-with-camera-helper.html | 299 +++-- .../examples/shadows-directional-light.html | 293 +++-- manual/examples/shadows-fake.html | 299 ++--- manual/examples/shadows-point-light.html | 373 +++--- .../shadows-spot-light-with-camera-gui.html | 413 ++++--- ...shadows-spot-light-with-shadow-radius.html | 419 ++++--- manual/examples/textured-cube-6-textures.html | 140 ++- manual/examples/textured-cube-adjust.html | 241 ++-- .../textured-cube-wait-for-all-textures.html | 170 +-- .../textured-cube-wait-for-texture.html | 128 +- manual/examples/textured-cube.html | 125 +- manual/examples/threejs-responsive.js | 3 +- .../examples/tips-preservedrawingbuffer.html | 201 +-- manual/examples/tips-screenshot-bad.html | 190 +-- manual/examples/tips-screenshot-good.html | 213 ++-- manual/examples/tips-tabindex.html | 57 +- manual/examples/tips-transparent-canvas.html | 160 +-- .../transparency-doubleside-hack.html | 210 ++-- manual/examples/transparency-doubleside.html | 198 +-- ...parency-intersecting-planes-alphatest.html | 257 ++-- ...ransparency-intersecting-planes-fixed.html | 201 +-- .../transparency-intersecting-planes.html | 173 +-- manual/examples/transparency.html | 196 +-- .../voxel-geometry-culled-faces-ui.html | 1093 ++++++++++------- ...l-geometry-culled-faces-with-textures.html | 605 +++++---- .../examples/voxel-geometry-culled-faces.html | 518 ++++---- manual/examples/voxel-geometry-merged.html | 181 +-- .../voxel-geometry-separate-cubes.html | 203 +-- manual/examples/webxr-basic-vr-optional.html | 204 +-- manual/examples/webxr-basic-w-background.html | 176 +-- manual/examples/webxr-basic.html | 152 ++- .../webxr-look-to-select-selector.html | 204 +-- .../webxr-look-to-select-w-cursor.html | 434 ++++--- manual/examples/webxr-look-to-select.html | 246 ++-- .../webxr-point-to-select-w-move.html | 458 ++++--- manual/examples/webxr-point-to-select.html | 398 +++--- manual/ko/voxel-geometry.html | 1 + 64 files changed, 8114 insertions(+), 6374 deletions(-) diff --git a/manual/en/textures.html b/manual/en/textures.html index d5e9febd6cb712..297e476c62084c 100644 --- a/manual/en/textures.html +++ b/manual/en/textures.html @@ -66,10 +66,12 @@

Hello Texture

load method with the URL of an image and set the material's map property to the result instead of setting its color.

+const loader = new THREE.TextureLoader();
++const texture = loader.load( 'resources/images/wall.jpg' );
++texture.colorSpace = THREE.SRGBColorSpace;
 
 const material = new THREE.MeshBasicMaterial({
 -  color: 0xFF8844,
-+  map: loader.load('resources/images/wall.jpg'),
++  map: texture,
 });
 

Note that we're using MeshBasicMaterial so no need for any lights.

@@ -96,20 +98,28 @@

We just make 6 materials and pass them as an array when we create the Mesh

const loader = new THREE.TextureLoader();
+-const texture = loader.load( 'resources/images/wall.jpg' );
+-texture.colorSpace = THREE.SRGBColorSpace;
 
 -const material = new THREE.MeshBasicMaterial({
--  map: loader.load('resources/images/wall.jpg'),
+-  map: texture,
 -});
 +const materials = [
-+  new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-1.jpg')}),
-+  new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-2.jpg')}),
-+  new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-3.jpg')}),
-+  new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-4.jpg')}),
-+  new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-5.jpg')}),
-+  new THREE.MeshBasicMaterial({map: loader.load('resources/images/flower-6.jpg')}),
++  new THREE.MeshBasicMaterial({map: loadColorTexture('resources/images/flower-1.jpg')}),
++  new THREE.MeshBasicMaterial({map: loadColorTexture('resources/images/flower-2.jpg')}),
++  new THREE.MeshBasicMaterial({map: loadColorTexture('resources/images/flower-3.jpg')}),
++  new THREE.MeshBasicMaterial({map: loadColorTexture('resources/images/flower-4.jpg')}),
++  new THREE.MeshBasicMaterial({map: loadColorTexture('resources/images/flower-5.jpg')}),
++  new THREE.MeshBasicMaterial({map: loadColorTexture('resources/images/flower-6.jpg')}),
 +];
 -const cube = new THREE.Mesh(geometry, material);
 +const cube = new THREE.Mesh(geometry, materials);
+
++function loadColorTexture( path ) {
++  const texture = loader.load( path );
++  texture.colorSpace = THREE.SRGBColorSpace;
++  return texture;
++}
 

It works!

@@ -152,6 +162,7 @@

Wait like this

const loader = new THREE.TextureLoader();
 loader.load('resources/images/wall.jpg', (texture) => {
+  texture.colorSpace = THREE.SRGBColorSpace;
   const material = new THREE.MeshBasicMaterial({
     map: texture,
   });
diff --git a/manual/en/voxel-geometry.html b/manual/en/voxel-geometry.html
index e69ac281c43b90..6b08887a04114d 100644
--- a/manual/en/voxel-geometry.html
+++ b/manual/en/voxel-geometry.html
@@ -691,6 +691,7 @@ 

Voxel(Minecraft Like) Geometry

const texture = loader.load('resources/images/minecraft/flourish-cc-by-nc-sa.png', render); texture.magFilter = THREE.NearestFilter; texture.minFilter = THREE.NearestFilter; +texture.colorSpace = THREE.SRGBColorSpace;

and pass the settings to the VoxelWorld class

+const tileSize = 16;
diff --git a/manual/examples/render-on-demand-w-damping.html b/manual/examples/render-on-demand-w-damping.html
index 61e910c70adfc1..35b8bcf063cc2f 100644
--- a/manual/examples/render-on-demand-w-damping.html
+++ b/manual/examples/render-on-demand-w-damping.html
@@ -35,90 +35,111 @@
 
 
 
diff --git a/manual/examples/responsive-hd-dpi.html b/manual/examples/responsive-hd-dpi.html
index 998c004b97b1aa..19d6032a2a8500 100644
--- a/manual/examples/responsive-hd-dpi.html
+++ b/manual/examples/responsive-hd-dpi.html
@@ -36,82 +36,100 @@
 import * as THREE from 'three';
 
 function main() {
-  const canvas = document.querySelector('#c');
-  const renderer = new THREE.WebGLRenderer({antialias: true, canvas});
-
-  const fov = 75;
-  const aspect = 2;  // the canvas default
-  const near = 0.1;
-  const far = 5;
-  const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
-  camera.position.z = 2;
-
-  const scene = new THREE.Scene();
-
-  {
-    const color = 0xFFFFFF;
-    const intensity = 1;
-    const light = new THREE.DirectionalLight(color, intensity);
-    light.position.set(-1, 2, 4);
-    scene.add(light);
-  }
 
-  const boxWidth = 1;
-  const boxHeight = 1;
-  const boxDepth = 1;
-  const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
+	const canvas = document.querySelector( '#c' );
+	const renderer = new THREE.WebGLRenderer( { antialias: true, canvas } );
+	renderer.useLegacyLights = false;
 
-  function makeInstance(geometry, color, x) {
-    const material = new THREE.MeshPhongMaterial({color});
+	const fov = 75;
+	const aspect = 2; // the canvas default
+	const near = 0.1;
+	const far = 5;
+	const camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	camera.position.z = 2;
 
-    const cube = new THREE.Mesh(geometry, material);
-    scene.add(cube);
+	const scene = new THREE.Scene();
 
-    cube.position.x = x;
+	{
 
-    return cube;
-  }
+		const color = 0xFFFFFF;
+		const intensity = 3;
+		const light = new THREE.DirectionalLight( color, intensity );
+		light.position.set( - 1, 2, 4 );
+		scene.add( light );
 
-  const cubes = [
-    makeInstance(geometry, 0x44aa88,  0),
-    makeInstance(geometry, 0x8844aa, -2),
-    makeInstance(geometry, 0xaa8844,  2),
-  ];
-
-  function resizeRendererToDisplaySize(renderer) {
-    const canvas = renderer.domElement;
-    const pixelRatio = window.devicePixelRatio;
-    const width  = canvas.clientWidth  * pixelRatio | 0;
-    const height = canvas.clientHeight * pixelRatio | 0;
-    const needResize = canvas.width !== width || canvas.height !== height;
-    if (needResize) {
-      renderer.setSize(width, height, false);
-    }
-    return needResize;
-  }
+	}
 
-  function render(time) {
-    time *= 0.001;
+	const boxWidth = 1;
+	const boxHeight = 1;
+	const boxDepth = 1;
+	const geometry = new THREE.BoxGeometry( boxWidth, boxHeight, boxDepth );
 
-    if (resizeRendererToDisplaySize(renderer)) {
-      const canvas = renderer.domElement;
-      camera.aspect = canvas.clientWidth / canvas.clientHeight;
-      camera.updateProjectionMatrix();
-    }
+	function makeInstance( geometry, color, x ) {
 
-    cubes.forEach((cube, ndx) => {
-      const speed = 1 + ndx * .1;
-      const rot = time * speed;
-      cube.rotation.x = rot;
-      cube.rotation.y = rot;
-    });
+		const material = new THREE.MeshPhongMaterial( { color } );
 
-    renderer.render(scene, camera);
+		const cube = new THREE.Mesh( geometry, material );
+		scene.add( cube );
 
-    requestAnimationFrame(render);
-  }
+		cube.position.x = x;
+
+		return cube;
+
+	}
+
+	const cubes = [
+		makeInstance( geometry, 0x44aa88, 0 ),
+		makeInstance( geometry, 0x8844aa, - 2 ),
+		makeInstance( geometry, 0xaa8844, 2 ),
+	];
+
+	function resizeRendererToDisplaySize( renderer ) {
+
+		const canvas = renderer.domElement;
+		const pixelRatio = window.devicePixelRatio;
+		const width = canvas.clientWidth * pixelRatio | 0;
+		const height = canvas.clientHeight * pixelRatio | 0;
+		const needResize = canvas.width !== width || canvas.height !== height;
+		if ( needResize ) {
+
+			renderer.setSize( width, height, false );
+
+		}
+
+		return needResize;
+
+	}
+
+	function render( time ) {
+
+		time *= 0.001;
+
+		if ( resizeRendererToDisplaySize( renderer ) ) {
+
+			const canvas = renderer.domElement;
+			camera.aspect = canvas.clientWidth / canvas.clientHeight;
+			camera.updateProjectionMatrix();
+
+		}
+
+		cubes.forEach( ( cube, ndx ) => {
+
+			const speed = 1 + ndx * .1;
+			const rot = time * speed;
+			cube.rotation.x = rot;
+			cube.rotation.y = rot;
+
+		} );
+
+		renderer.render( scene, camera );
+
+		requestAnimationFrame( render );
+
+	}
+
+	requestAnimationFrame( render );
 
-  requestAnimationFrame(render);
 }
 
 main();
diff --git a/manual/examples/responsive-no-resize.html b/manual/examples/responsive-no-resize.html
index 9a53477da516e4..60fe7f1ccda468 100644
--- a/manual/examples/responsive-no-resize.html
+++ b/manual/examples/responsive-no-resize.html
@@ -36,64 +36,75 @@
 import * as THREE from 'three';
 
 function main() {
-  const canvas = document.querySelector('#c');
-  const renderer = new THREE.WebGLRenderer({antialias: true, canvas});
-
-  const fov = 75;
-  const aspect = 2;  // the canvas default
-  const near = 0.1;
-  const far = 5;
-  const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
-  camera.position.z = 2;
-
-  const scene = new THREE.Scene();
-
-  {
-    const color = 0xFFFFFF;
-    const intensity = 1;
-    const light = new THREE.DirectionalLight(color, intensity);
-    light.position.set(-1, 2, 4);
-    scene.add(light);
-  }
 
-  const boxWidth = 1;
-  const boxHeight = 1;
-  const boxDepth = 1;
-  const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
+	const canvas = document.querySelector( '#c' );
+	const renderer = new THREE.WebGLRenderer( { antialias: true, canvas } );
+	renderer.useLegacyLights = false;
 
-  function makeInstance(geometry, color, x) {
-    const material = new THREE.MeshPhongMaterial({color});
+	const fov = 75;
+	const aspect = 2; // the canvas default
+	const near = 0.1;
+	const far = 5;
+	const camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	camera.position.z = 2;
 
-    const cube = new THREE.Mesh(geometry, material);
-    scene.add(cube);
+	const scene = new THREE.Scene();
 
-    cube.position.x = x;
+	{
 
-    return cube;
-  }
+		const color = 0xFFFFFF;
+		const intensity = 3;
+		const light = new THREE.DirectionalLight( color, intensity );
+		light.position.set( - 1, 2, 4 );
+		scene.add( light );
 
-  const cubes = [
-    makeInstance(geometry, 0x44aa88,  0),
-    makeInstance(geometry, 0x8844aa, -2),
-    makeInstance(geometry, 0xaa8844,  2),
-  ];
+	}
 
-  function render(time) {
-    time *= 0.001;
+	const boxWidth = 1;
+	const boxHeight = 1;
+	const boxDepth = 1;
+	const geometry = new THREE.BoxGeometry( boxWidth, boxHeight, boxDepth );
 
-    cubes.forEach((cube, ndx) => {
-      const speed = 1 + ndx * .1;
-      const rot = time * speed;
-      cube.rotation.x = rot;
-      cube.rotation.y = rot;
-    });
+	function makeInstance( geometry, color, x ) {
 
-    renderer.render(scene, camera);
+		const material = new THREE.MeshPhongMaterial( { color } );
 
-    requestAnimationFrame(render);
-  }
+		const cube = new THREE.Mesh( geometry, material );
+		scene.add( cube );
+
+		cube.position.x = x;
+
+		return cube;
+
+	}
+
+	const cubes = [
+		makeInstance( geometry, 0x44aa88, 0 ),
+		makeInstance( geometry, 0x8844aa, - 2 ),
+		makeInstance( geometry, 0xaa8844, 2 ),
+	];
+
+	function render( time ) {
+
+		time *= 0.001;
+
+		cubes.forEach( ( cube, ndx ) => {
+
+			const speed = 1 + ndx * .1;
+			const rot = time * speed;
+			cube.rotation.x = rot;
+			cube.rotation.y = rot;
+
+		} );
+
+		renderer.render( scene, camera );
+
+		requestAnimationFrame( render );
+
+	}
+
+	requestAnimationFrame( render );
 
-  requestAnimationFrame(render);
 }
 
 main();
diff --git a/manual/examples/responsive-update-camera.html b/manual/examples/responsive-update-camera.html
index bd8c25711e1214..d3811154fa7e78 100644
--- a/manual/examples/responsive-update-camera.html
+++ b/manual/examples/responsive-update-camera.html
@@ -36,68 +36,79 @@
 import * as THREE from 'three';
 
 function main() {
-  const canvas = document.querySelector('#c');
-  const renderer = new THREE.WebGLRenderer({antialias: true, canvas});
-
-  const fov = 75;
-  const aspect = 2;  // the canvas default
-  const near = 0.1;
-  const far = 5;
-  const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
-  camera.position.z = 2;
-
-  const scene = new THREE.Scene();
-
-  {
-    const color = 0xFFFFFF;
-    const intensity = 1;
-    const light = new THREE.DirectionalLight(color, intensity);
-    light.position.set(-1, 2, 4);
-    scene.add(light);
-  }
 
-  const boxWidth = 1;
-  const boxHeight = 1;
-  const boxDepth = 1;
-  const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
+	const canvas = document.querySelector( '#c' );
+	const renderer = new THREE.WebGLRenderer( { antialias: true, canvas } );
+	renderer.useLegacyLights = false;
 
-  function makeInstance(geometry, color, x) {
-    const material = new THREE.MeshPhongMaterial({color});
+	const fov = 75;
+	const aspect = 2; // the canvas default
+	const near = 0.1;
+	const far = 5;
+	const camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	camera.position.z = 2;
 
-    const cube = new THREE.Mesh(geometry, material);
-    scene.add(cube);
+	const scene = new THREE.Scene();
 
-    cube.position.x = x;
+	{
 
-    return cube;
-  }
+		const color = 0xFFFFFF;
+		const intensity = 3;
+		const light = new THREE.DirectionalLight( color, intensity );
+		light.position.set( - 1, 2, 4 );
+		scene.add( light );
 
-  const cubes = [
-    makeInstance(geometry, 0x44aa88,  0),
-    makeInstance(geometry, 0x8844aa, -2),
-    makeInstance(geometry, 0xaa8844,  2),
-  ];
+	}
 
-  function render(time) {
-    time *= 0.001;
+	const boxWidth = 1;
+	const boxHeight = 1;
+	const boxDepth = 1;
+	const geometry = new THREE.BoxGeometry( boxWidth, boxHeight, boxDepth );
 
-    const canvas = renderer.domElement;
-    camera.aspect = canvas.clientWidth / canvas.clientHeight;
-    camera.updateProjectionMatrix();
+	function makeInstance( geometry, color, x ) {
 
-    cubes.forEach((cube, ndx) => {
-      const speed = 1 + ndx * .1;
-      const rot = time * speed;
-      cube.rotation.x = rot;
-      cube.rotation.y = rot;
-    });
+		const material = new THREE.MeshPhongMaterial( { color } );
 
-    renderer.render(scene, camera);
+		const cube = new THREE.Mesh( geometry, material );
+		scene.add( cube );
 
-    requestAnimationFrame(render);
-  }
+		cube.position.x = x;
+
+		return cube;
+
+	}
+
+	const cubes = [
+		makeInstance( geometry, 0x44aa88, 0 ),
+		makeInstance( geometry, 0x8844aa, - 2 ),
+		makeInstance( geometry, 0xaa8844, 2 ),
+	];
+
+	function render( time ) {
+
+		time *= 0.001;
+
+		const canvas = renderer.domElement;
+		camera.aspect = canvas.clientWidth / canvas.clientHeight;
+		camera.updateProjectionMatrix();
+
+		cubes.forEach( ( cube, ndx ) => {
+
+			const speed = 1 + ndx * .1;
+			const rot = time * speed;
+			cube.rotation.x = rot;
+			cube.rotation.y = rot;
+
+		} );
+
+		renderer.render( scene, camera );
+
+		requestAnimationFrame( render );
+
+	}
+
+	requestAnimationFrame( render );
 
-  requestAnimationFrame(render);
 }
 
 main();
diff --git a/manual/examples/responsive.html b/manual/examples/responsive.html
index b111d216eb8de8..d9d146e07ed048 100644
--- a/manual/examples/responsive.html
+++ b/manual/examples/responsive.html
@@ -36,81 +36,99 @@
 import * as THREE from 'three';
 
 function main() {
-  const canvas = document.querySelector('#c');
-  const renderer = new THREE.WebGLRenderer({antialias: true, canvas});
-
-  const fov = 75;
-  const aspect = 2;  // the canvas default
-  const near = 0.1;
-  const far = 5;
-  const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
-  camera.position.z = 2;
-
-  const scene = new THREE.Scene();
-
-  {
-    const color = 0xFFFFFF;
-    const intensity = 1;
-    const light = new THREE.DirectionalLight(color, intensity);
-    light.position.set(-1, 2, 4);
-    scene.add(light);
-  }
 
-  const boxWidth = 1;
-  const boxHeight = 1;
-  const boxDepth = 1;
-  const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth);
+	const canvas = document.querySelector( '#c' );
+	const renderer = new THREE.WebGLRenderer( { antialias: true, canvas } );
+	renderer.useLegacyLights = false;
 
-  function makeInstance(geometry, color, x) {
-    const material = new THREE.MeshPhongMaterial({color});
+	const fov = 75;
+	const aspect = 2; // the canvas default
+	const near = 0.1;
+	const far = 5;
+	const camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	camera.position.z = 2;
 
-    const cube = new THREE.Mesh(geometry, material);
-    scene.add(cube);
+	const scene = new THREE.Scene();
 
-    cube.position.x = x;
+	{
 
-    return cube;
-  }
+		const color = 0xFFFFFF;
+		const intensity = 3;
+		const light = new THREE.DirectionalLight( color, intensity );
+		light.position.set( - 1, 2, 4 );
+		scene.add( light );
 
-  const cubes = [
-    makeInstance(geometry, 0x44aa88,  0),
-    makeInstance(geometry, 0x8844aa, -2),
-    makeInstance(geometry, 0xaa8844,  2),
-  ];
-
-  function resizeRendererToDisplaySize(renderer) {
-    const canvas = renderer.domElement;
-    const width = canvas.clientWidth;
-    const height = canvas.clientHeight;
-    const needResize = canvas.width !== width || canvas.height !== height;
-    if (needResize) {
-      renderer.setSize(width, height, false);
-    }
-    return needResize;
-  }
+	}
 
-  function render(time) {
-    time *= 0.001;
+	const boxWidth = 1;
+	const boxHeight = 1;
+	const boxDepth = 1;
+	const geometry = new THREE.BoxGeometry( boxWidth, boxHeight, boxDepth );
 
-    if (resizeRendererToDisplaySize(renderer)) {
-      const canvas = renderer.domElement;
-      camera.aspect = canvas.clientWidth / canvas.clientHeight;
-      camera.updateProjectionMatrix();
-    }
+	function makeInstance( geometry, color, x ) {
 
-    cubes.forEach((cube, ndx) => {
-      const speed = 1 + ndx * .1;
-      const rot = time * speed;
-      cube.rotation.x = rot;
-      cube.rotation.y = rot;
-    });
+		const material = new THREE.MeshPhongMaterial( { color } );
 
-    renderer.render(scene, camera);
+		const cube = new THREE.Mesh( geometry, material );
+		scene.add( cube );
 
-    requestAnimationFrame(render);
-  }
+		cube.position.x = x;
+
+		return cube;
+
+	}
+
+	const cubes = [
+		makeInstance( geometry, 0x44aa88, 0 ),
+		makeInstance( geometry, 0x8844aa, - 2 ),
+		makeInstance( geometry, 0xaa8844, 2 ),
+	];
+
+	function resizeRendererToDisplaySize( renderer ) {
+
+		const canvas = renderer.domElement;
+		const width = canvas.clientWidth;
+		const height = canvas.clientHeight;
+		const needResize = canvas.width !== width || canvas.height !== height;
+		if ( needResize ) {
+
+			renderer.setSize( width, height, false );
+
+		}
+
+		return needResize;
+
+	}
+
+	function render( time ) {
+
+		time *= 0.001;
+
+		if ( resizeRendererToDisplaySize( renderer ) ) {
+
+			const canvas = renderer.domElement;
+			camera.aspect = canvas.clientWidth / canvas.clientHeight;
+			camera.updateProjectionMatrix();
+
+		}
+
+		cubes.forEach( ( cube, ndx ) => {
+
+			const speed = 1 + ndx * .1;
+			const rot = time * speed;
+			cube.rotation.x = rot;
+			cube.rotation.y = rot;
+
+		} );
+
+		renderer.render( scene, camera );
+
+		requestAnimationFrame( render );
+
+	}
+
+	requestAnimationFrame( render );
 
-  requestAnimationFrame(render);
 }
 
 main();
diff --git a/manual/examples/scenegraph-car.html b/manual/examples/scenegraph-car.html
index fdf741f861b448..5ba5609959dce0 100644
--- a/manual/examples/scenegraph-car.html
+++ b/manual/examples/scenegraph-car.html
@@ -37,95 +37,116 @@
 import * as THREE from 'three';
 
 function main() {
-  const canvas = document.querySelector('#c');
-  const renderer = new THREE.WebGLRenderer({antialias: true, canvas});
-  renderer.setClearColor(0xAAAAAA);
-
-  const fov = 40;
-  const aspect = 2;  // the canvas default
-  const near = 0.1;
-  const far = 1000;
-  const camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
-  camera.position.set(8, 4, 10);
-  camera.lookAt(0, 0, 0);
-
-  const scene = new THREE.Scene();
-
-  {
-    const light = new THREE.DirectionalLight(0xffffff, 1);
-    light.position.set(-1, 2, 4);
-    scene.add(light);
-  }
-  {
-    const light = new THREE.DirectionalLight(0xffffff, 1);
-    light.position.set(1, -2, -4);
-    scene.add(light);
-  }
 
-  const carWidth = 4;
-  const carHeight = 1;
-  const carLength = 8;
-
-  const bodyGeometry = new THREE.BoxGeometry(carWidth, carHeight, carLength);
-  const bodyMaterial = new THREE.MeshPhongMaterial({color: 0x6688AA});
-  const bodyMesh = new THREE.Mesh(bodyGeometry, bodyMaterial);
-  scene.add(bodyMesh);
-
-  const wheelRadius = 1;
-  const wheelThickness = .5;
-  const wheelSegments = 6;
-  const wheelGeometry = new THREE.CylinderGeometry(
-      wheelRadius,     // top radius
-      wheelRadius,     // bottom radius
-      wheelThickness,  // height of cylinder
-      wheelSegments);
-  const wheelMaterial = new THREE.MeshPhongMaterial({color: 0x888888});
-  const wheelPositions = [
-    [-carWidth / 2 + wheelThickness / 2, -carHeight / 2,  carLength / 3],
-    [ carWidth / 2 + wheelThickness / 2, -carHeight / 2,  carLength / 3],
-    [-carWidth / 2 + wheelThickness / 2, -carHeight / 2, -carLength / 3],
-    [ carWidth / 2 + wheelThickness / 2, -carHeight / 2, -carLength / 3],
-  ];
-  const wheelMeshes = wheelPositions.map((position) => {
-    const mesh = new THREE.Mesh(wheelGeometry, wheelMaterial);
-    mesh.position.set(...position);
-    mesh.rotation.z = Math.PI * .5;
-    scene.add(mesh);
-    return mesh;
-  });
-
-  function resizeRendererToDisplaySize(renderer) {
-    const canvas = renderer.domElement;
-    const width = canvas.clientWidth;
-    const height = canvas.clientHeight;
-    const needResize = canvas.width !== width || canvas.height !== height;
-    if (needResize) {
-      renderer.setSize(width, height, false);
-    }
-    return needResize;
-  }
+	const canvas = document.querySelector( '#c' );
+	const renderer = new THREE.WebGLRenderer( { antialias: true, canvas } );
+	renderer.useLegacyLights = false;
+	renderer.setClearColor( 0xAAAAAA );
 
-  // const carPosition = [0, 0, 0];
+	const fov = 40;
+	const aspect = 2; // the canvas default
+	const near = 0.1;
+	const far = 1000;
+	const camera = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	camera.position.set( 8, 4, 10 );
+	camera.lookAt( 0, 0, 0 );
 
-  function render(time) {
-    time *= 0.001;
+	const scene = new THREE.Scene();
 
-    if (resizeRendererToDisplaySize(renderer)) {
-      const canvas = renderer.domElement;
-      camera.aspect = canvas.clientWidth / canvas.clientHeight;
-      camera.updateProjectionMatrix();
-    }
+	{
 
-    wheelMeshes.forEach((obj) => {
-      obj.rotation.x = time;
-    });
+		const light = new THREE.DirectionalLight( 0xffffff, 3 );
+		light.position.set( - 1, 2, 4 );
+		scene.add( light );
 
-    renderer.render(scene, camera);
+	}
 
-    requestAnimationFrame(render);
-  }
+	{
+
+		const light = new THREE.DirectionalLight( 0xffffff, 3 );
+		light.position.set( 1, - 2, - 4 );
+		scene.add( light );
+
+	}
+
+	const carWidth = 4;
+	const carHeight = 1;
+	const carLength = 8;
+
+	const bodyGeometry = new THREE.BoxGeometry( carWidth, carHeight, carLength );
+	const bodyMaterial = new THREE.MeshPhongMaterial( { color: 0x6688AA } );
+	const bodyMesh = new THREE.Mesh( bodyGeometry, bodyMaterial );
+	scene.add( bodyMesh );
+
+	const wheelRadius = 1;
+	const wheelThickness = .5;
+	const wheelSegments = 6;
+	const wheelGeometry = new THREE.CylinderGeometry(
+		wheelRadius, // top radius
+		wheelRadius, // bottom radius
+		wheelThickness, // height of cylinder
+		wheelSegments );
+	const wheelMaterial = new THREE.MeshPhongMaterial( { color: 0x888888 } );
+	const wheelPositions = [
+		[ - carWidth / 2 + wheelThickness / 2, - carHeight / 2, carLength / 3 ],
+		[ carWidth / 2 + wheelThickness / 2, - carHeight / 2, carLength / 3 ],
+		[ - carWidth / 2 + wheelThickness / 2, - carHeight / 2, - carLength / 3 ],
+		[ carWidth / 2 + wheelThickness / 2, - carHeight / 2, - carLength / 3 ],
+	];
+	const wheelMeshes = wheelPositions.map( ( position ) => {
+
+		const mesh = new THREE.Mesh( wheelGeometry, wheelMaterial );
+		mesh.position.set( ...position );
+		mesh.rotation.z = Math.PI * .5;
+		scene.add( mesh );
+		return mesh;
+
+	} );
+
+	function resizeRendererToDisplaySize( renderer ) {
+
+		const canvas = renderer.domElement;
+		const width = canvas.clientWidth;
+		const height = canvas.clientHeight;
+		const needResize = canvas.width !== width || canvas.height !== height;
+		if ( needResize ) {
+
+			renderer.setSize( width, height, false );
+
+		}
+
+		return needResize;
+
+	}
+
+	// const carPosition = [0, 0, 0];
+
+	function render( time ) {
+
+		time *= 0.001;
+
+		if ( resizeRendererToDisplaySize( renderer ) ) {
+
+			const canvas = renderer.domElement;
+			camera.aspect = canvas.clientWidth / canvas.clientHeight;
+			camera.updateProjectionMatrix();
+
+		}
+
+		wheelMeshes.forEach( ( obj ) => {
+
+			obj.rotation.x = time;
+
+		} );
+
+		renderer.render( scene, camera );
+
+		requestAnimationFrame( render );
+
+	}
+
+	requestAnimationFrame( render );
 
-  requestAnimationFrame(render);
 }
 
 main();
diff --git a/manual/examples/scenegraph-sun-earth-moon-axes-grids.html b/manual/examples/scenegraph-sun-earth-moon-axes-grids.html
index 11faf65670dead..703bf3d4cdbcb8 100644
--- a/manual/examples/scenegraph-sun-earth-moon-axes-grids.html
+++ b/manual/examples/scenegraph-sun-earth-moon-axes-grids.html
@@ -61,142 +61,168 @@
 
 
 
diff --git a/manual/examples/tips-transparent-canvas.html b/manual/examples/tips-transparent-canvas.html
index 6607b41e76c90f..91f0b743aefd5d 100644
--- a/manual/examples/tips-transparent-canvas.html
+++ b/manual/examples/tips-transparent-canvas.html
@@ -63,89 +63,107 @@ 

Cubes-R-Us!

import * as THREE from 'three'; function main() { - const canvas = document.querySelector('#c'); - const renderer = new THREE.WebGLRenderer({ - canvas, - alpha: true, - premultipliedAlpha: false, - antialias: true - }); - - const fov = 75; - const aspect = 2; // the canvas default - const near = 0.1; - const far = 5; - const camera = new THREE.PerspectiveCamera(fov, aspect, near, far); - camera.position.z = 2; - - const scene = new THREE.Scene(); - - { - const color = 0xFFFFFF; - const intensity = 1; - const light = new THREE.DirectionalLight(color, intensity); - light.position.set(-1, 2, 4); - scene.add(light); - } - const boxWidth = 1; - const boxHeight = 1; - const boxDepth = 1; - const geometry = new THREE.BoxGeometry(boxWidth, boxHeight, boxDepth); + const canvas = document.querySelector( '#c' ); + const renderer = new THREE.WebGLRenderer( { + canvas, + alpha: true, + premultipliedAlpha: false, + antialias: true + } ); + renderer.useLegacyLights = false; - function makeInstance(geometry, color, x) { - const material = new THREE.MeshPhongMaterial({ - color, - opacity: 0.5, - }); + const fov = 75; + const aspect = 2; // the canvas default + const near = 0.1; + const far = 5; + const camera = new THREE.PerspectiveCamera( fov, aspect, near, far ); + camera.position.z = 2; - const cube = new THREE.Mesh(geometry, material); - scene.add(cube); + const scene = new THREE.Scene(); - cube.position.x = x; + { - return cube; - } + const color = 0xFFFFFF; + const intensity = 3; + const light = new THREE.DirectionalLight( color, intensity ); + light.position.set( - 1, 2, 4 ); + scene.add( light ); - const cubes = [ - makeInstance(geometry, 0x44aa88, 0), - makeInstance(geometry, 0x8844aa, -2), - makeInstance(geometry, 0xaa8844, 2), - ]; - - function resizeRendererToDisplaySize(renderer) { - const canvas = renderer.domElement; - const width = canvas.clientWidth; - const height = canvas.clientHeight; - const needResize = canvas.width !== width || canvas.height !== height; - if (needResize) { - renderer.setSize(width, height, false); - } - return needResize; - } + } - function render(time) { - time *= 0.001; + const boxWidth = 1; + const boxHeight = 1; + const boxDepth = 1; + const geometry = new THREE.BoxGeometry( boxWidth, boxHeight, boxDepth ); - if (resizeRendererToDisplaySize(renderer)) { - const canvas = renderer.domElement; - camera.aspect = canvas.clientWidth / canvas.clientHeight; - camera.updateProjectionMatrix(); - } + function makeInstance( geometry, color, x ) { - cubes.forEach((cube, ndx) => { - const speed = 1 + ndx * .1; - const rot = time * speed; - cube.rotation.x = rot; - cube.rotation.y = rot; - }); + const material = new THREE.MeshPhongMaterial( { + color, + opacity: 0.5, + } ); - renderer.render(scene, camera); + const cube = new THREE.Mesh( geometry, material ); + scene.add( cube ); - requestAnimationFrame(render); - } + cube.position.x = x; + + return cube; + + } + + const cubes = [ + makeInstance( geometry, 0x44aa88, 0 ), + makeInstance( geometry, 0x8844aa, - 2 ), + makeInstance( geometry, 0xaa8844, 2 ), + ]; + + function resizeRendererToDisplaySize( renderer ) { + + const canvas = renderer.domElement; + const width = canvas.clientWidth; + const height = canvas.clientHeight; + const needResize = canvas.width !== width || canvas.height !== height; + if ( needResize ) { + + renderer.setSize( width, height, false ); + + } + + return needResize; + + } + + function render( time ) { + + time *= 0.001; + + if ( resizeRendererToDisplaySize( renderer ) ) { + + const canvas = renderer.domElement; + camera.aspect = canvas.clientWidth / canvas.clientHeight; + camera.updateProjectionMatrix(); + + } + + cubes.forEach( ( cube, ndx ) => { + + const speed = 1 + ndx * .1; + const rot = time * speed; + cube.rotation.x = rot; + cube.rotation.y = rot; + + } ); + + renderer.render( scene, camera ); + + requestAnimationFrame( render ); + + } + + requestAnimationFrame( render ); - requestAnimationFrame(render); } main(); diff --git a/manual/examples/transparency-doubleside-hack.html b/manual/examples/transparency-doubleside-hack.html index 636d494f285f6b..44daca30564cc5 100644 --- a/manual/examples/transparency-doubleside-hack.html +++ b/manual/examples/transparency-doubleside-hack.html @@ -35,108 +35,136 @@