소스 검색

docs: clean up.

linbingquan 4 년 전
부모
커밋
f9cfd70c63

+ 3 - 7
docs/api/zh/core/EventDispatcher.html

@@ -20,19 +20,15 @@
 		<code>
 		// 为自定义对象添加事件
 
-		const Car = function () {
+		const Car extends EventDispatcher () {
 
-			this.start = function () {
+			start() {
 
 				this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
 
 			};
 
-		};
-
-		// 将 EventDispatcher.prototype 与自定义对象 prototype 进行混合
-
-		Object.assign( Car.prototype, EventDispatcher.prototype );
+		}
 
 		// 使用自定义对象的事件
 

+ 13 - 12
docs/api/zh/geometries/TubeBufferGeometry.html

@@ -35,26 +35,27 @@
 		<h2>代码示例</h2>
 
 		<code>
-		function CustomSinCurve( scale ) {
+		class CustomSinCurve extends THREE.Curve {
 
-			THREE.Curve.call( this );
+			constructor( scale = 1 ) {
 
-			this.scale = ( scale === undefined ) ? 1 : scale;
+				super();
 
-		}
+				this.scale = scale;
+
+			}
 
-		CustomSinCurve.prototype = Object.create( THREE.Curve.prototype );
-		CustomSinCurve.prototype.constructor = CustomSinCurve;
+			getPoint( t, optionalTarget = new THREE.Vector3() ) {
 
-		CustomSinCurve.prototype.getPoint = function ( t ) {
+				const tx = t * 3 - 1.5;
+				const ty = Math.sin( 2 * Math.PI * t );
+				const tz = 0;
 
-			const tx = t * 3 - 1.5;
-			const ty = Math.sin( 2 * Math.PI * t );
-			const tz = 0;
+				return optionalTarget.set( tx, ty, tz ).multiplyScalar( this.scale );
 
-			return new THREE.Vector3( tx, ty, tz ).multiplyScalar( this.scale );
+			}
 
-		};
+		}
 
 		const path = new CustomSinCurve( 10 );
 		const geometry = new THREE.TubeBufferGeometry( path, 20, 2, 8, false );

+ 13 - 12
docs/api/zh/geometries/TubeGeometry.html

@@ -35,26 +35,27 @@
 		<h2>代码示例</h2>
 
 		<code>
-		function CustomSinCurve( scale ) {
+		class CustomSinCurve extends THREE.Curve {
 
-			THREE.Curve.call( this );
+			constructor( scale = 1 ) {
 
-			this.scale = ( scale === undefined ) ? 1 : scale;
+				super();
 
-		}
+				this.scale = scale;
+
+			}
 
-		CustomSinCurve.prototype = Object.create( THREE.Curve.prototype );
-		CustomSinCurve.prototype.constructor = CustomSinCurve;
+			getPoint( t, optionalTarget = new THREE.Vector3() ) {
 
-		CustomSinCurve.prototype.getPoint = function ( t ) {
+				const tx = t * 3 - 1.5;
+				const ty = Math.sin( 2 * Math.PI * t );
+				const tz = 0;
 
-			const tx = t * 3 - 1.5;
-			const ty = Math.sin( 2 * Math.PI * t );
-			const tz = 0;
+				return optionalTarget.set( tx, ty, tz ).multiplyScalar( this.scale );
 
-			return new THREE.Vector3( tx, ty, tz ).multiplyScalar( this.scale );
+			}
 
-		};
+		}
 
 		const path = new CustomSinCurve( 10 );
 		const geometry = new THREE.TubeGeometry( path, 20, 2, 8, false );

+ 5 - 5
docs/api/zh/lights/shadows/DirectionalLightShadow.html

@@ -27,15 +27,15 @@
 
 		//Create a DirectionalLight and turn on shadows for the light
 		const light = new THREE.DirectionalLight( 0xffffff, 1, 100 );
-		light.position.set( 0, 1, 0 ); 			//default; light shining from top
-		light.castShadow = true;            // default false
+		light.position.set( 0, 1, 0 ); //default; light shining from top
+		light.castShadow = true; // default false
 		scene.add( light );
 
 		//Set up shadow properties for the light
-		light.shadow.mapSize.width = 512;  // default
+		light.shadow.mapSize.width = 512; // default
 		light.shadow.mapSize.height = 512; // default
-		light.shadow.camera.near = 0.5;    // default
-		light.shadow.camera.far = 500;     // default
+		light.shadow.camera.near = 0.5; // default
+		light.shadow.camera.far = 500; // default
 
 		//Create a sphere that cast shadows (but does not receive them)
 		const sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 );

+ 4 - 4
docs/api/zh/lights/shadows/PointLightShadow.html

@@ -27,14 +27,14 @@
 		//Create a PointLight and turn on shadows for the light
 		const light = new THREE.PointLight( 0xffffff, 1, 100 );
 		light.position.set( 0, 10, 0 );
-		light.castShadow = true;            // default false
+		light.castShadow = true; // default false
 		scene.add( light );
 
 		//Set up shadow properties for the light
-		light.shadow.mapSize.width = 512;  // default
+		light.shadow.mapSize.width = 512; // default
 		light.shadow.mapSize.height = 512; // default
-		light.shadow.camera.near = 0.5;       // default
-		light.shadow.camera.far = 500      // default
+		light.shadow.camera.near = 0.5; // default
+		light.shadow.camera.far = 500 // default
 
 		//Create a sphere that cast shadows (but does not receive them)
 		const sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 );

+ 5 - 5
docs/api/zh/materials/ShadowMaterial.html

@@ -19,13 +19,13 @@
 		<h2>代码示例</h2>
 
 		<code>
-		const planeGeometry = new THREE.PlaneBufferGeometry( 2000, 2000 );
-		planeGeometry.rotateX( - Math.PI / 2 );
+		const geometry = new THREE.PlaneBufferGeometry( 2000, 2000 );
+		geometry.rotateX( - Math.PI / 2 );
 
-		const planeMaterial = new THREE.ShadowMaterial();
-		planeMaterial.opacity = 0.2;
+		const material = new THREE.ShadowMaterial();
+		material.opacity = 0.2;
 
-		const plane = new THREE.Mesh( planeGeometry, planeMaterial );
+		const plane = new THREE.Mesh( geometry, material );
 		plane.position.y = -200;
 		plane.receiveShadow = true;
 		scene.add( plane );

+ 3 - 5
docs/api/zh/materials/SpriteMaterial.html

@@ -17,13 +17,11 @@
 		<h2>代码示例</h2>
 
 		<code>
-		const spriteMap = new THREE.TextureLoader().load( 'textures/sprite.png' );
+		const map = new THREE.TextureLoader().load( 'textures/sprite.png' );
+		const material = new THREE.SpriteMaterial( { map: map, color: 0xffffff } );
 
-		const spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap, color: 0xffffff } );
-
-		const sprite = new THREE.Sprite( spriteMaterial );
+		const sprite = new THREE.Sprite( material );
 		sprite.scale.set(200, 200, 1)
-
 		scene.add( sprite );
 		</code>
 

+ 7 - 7
docs/api/zh/math/Color.html

@@ -19,24 +19,24 @@
 		颜色可以用以下任意一种方式初始化。
 		<code>
 		//empty constructor - will default white
-		const color = new THREE.Color();
+		const color1 = new THREE.Color();
 
 		//Hexadecimal color (recommended)
-		const color = new THREE.Color( 0xff0000 );
+		const color2 = new THREE.Color( 0xff0000 );
 
 		//RGB string
-		const color = new THREE.Color("rgb(255, 0, 0)");
-		const color = new THREE.Color("rgb(100%, 0%, 0%)");
+		const color3 = new THREE.Color("rgb(255, 0, 0)");
+		const color4 = new THREE.Color("rgb(100%, 0%, 0%)");
 
 		//X11 color name - all 140 color names are supported.
 		//Note the lack of CamelCase in the name
-		const color = new THREE.Color( 'skyblue' );
+		const color5 = new THREE.Color( 'skyblue' );
 
 		//HSL string
-		const color = new THREE.Color("hsl(0, 100%, 50%)");
+		const color6 = new THREE.Color("hsl(0, 100%, 50%)");
 
 		//Separate RGB values between 0 and 1
-		const color = new THREE.Color( 1, 0, 0 );
+		const color7 = new THREE.Color( 1, 0, 0 );
 		</code>
 
 

+ 1 - 1
docs/api/zh/math/Quaternion.html

@@ -235,7 +235,7 @@ q.slerp( qb, t )
 			// Code setup
 			const startQuaternion = new THREE.Quaternion().set( 0, 0, 0, 1 ).normalize();
 			const endQuaternion = new THREE.Quaternion().set( 1, 1, 1, 1 ).normalize();
-			const t = 0;
+			let t = 0;
 
 			// Update a mesh's rotation in the loop
 			t = ( t + 0.01 ) % 1; // constant angular momentum

+ 5 - 4
docs/api/zh/objects/Sprite.html

@@ -20,10 +20,11 @@
 		<h2>代码示例</h2>
 
 		<code>
-const spriteMap = new THREE.TextureLoader().load( "sprite.png" );
-const spriteMaterial = new THREE.SpriteMaterial( { map: spriteMap } );
-const sprite = new THREE.Sprite( spriteMaterial );
-scene.add( sprite );
+		const map = new THREE.TextureLoader().load( "sprite.png" );
+		const material = new THREE.SpriteMaterial( { map: map } );
+
+		const sprite = new THREE.Sprite( material );
+		scene.add( sprite );
 		</code>
 
 

+ 4 - 0
docs/api/zh/textures/DataTexture.html

@@ -37,8 +37,12 @@
 		<code>
 		// create a buffer with color data
 
+		const width = 512;
+		const height = 512;
+
 		const size = width * height;
 		const data = new Uint8Array( 3 * size );
+		const color = new THREE.Color( 0xffffff );
 
 		const r = Math.floor( color.r * 255 );
 		const g = Math.floor( color.g * 255 );

+ 4 - 1
docs/api/zh/textures/DataTexture2DArray.html

@@ -39,10 +39,13 @@
 		<code>
 		// create a buffer with color data
 
+		const width = 512;
+		const height = 512;
+		const depth = 100;
+
 		const size = width * height;
 		const data = new Uint8Array( 3 * size * depth );
 
-
 		for ( let i = 0; i < depth; i ++ ) {
 
 			const color = new THREE.Color( Math.random(), Math.random(), Math.random() );

+ 1 - 2
docs/examples/zh/animations/MMDAnimationHelper.html

@@ -39,8 +39,7 @@
 					function ( buffer ) {
 
 						const listener = new THREE.AudioListener();
-						const audio = new THREE.Audio( listener )
-							.setBuffer( buffer );
+						const audio = new THREE.Audio( listener ).setBuffer( buffer );
 
 						listener.position.z = 1;
 

+ 1 - 1
docs/examples/zh/exporters/ColladaExporter.html

@@ -26,7 +26,7 @@
 
 		// Parse the input and generate the ply output
 		const data = exporter.parse( scene, null, options );
-		downloadFile(data);
+		downloadFile( data );
 		</code>
 
 		<h2>Constructor</h2>

+ 1 - 1
docs/examples/zh/exporters/PLYExporter.html

@@ -27,7 +27,7 @@
 
 		// Parse the input and generate the ply output
 		const data = exporter.parse( scene, options );
-		downloadFile(data);
+		downloadFile( data );
 		</code>
 
 		<h2>Constructor</h2>

+ 1 - 1
docs/manual/zh/introduction/Animation-system.html

@@ -99,7 +99,7 @@
 		<h2>范例</h2>
 
 		<code>
-		const mesh;
+		let mesh;
 
 		// 新建一个AnimationMixer, 并取得AnimationClip实例列表
 		const mixer = new THREE.AnimationMixer( mesh );

+ 1 - 1
docs/manual/zh/introduction/How-to-update-things.html

@@ -79,7 +79,7 @@ scene.add( line );
 			<code>
 const positions = line.geometry.attributes.position.array;
 
-const x, y, z, index;
+let x, y, z, index;
 x = y = z = index = 0;
 
 for ( let i = 0, l = MAX_POINTS; i < l; i ++ ) {