浏览代码

Examples: Clean up.

Mugen87 5 年之前
父节点
当前提交
df2b71d48e

+ 7 - 8
examples/js/loaders/SVGLoader.js

@@ -879,7 +879,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 		// Conversion: [ fromUnit ][ toUnit ] (-1 means dpi dependent)
 		var unitConversion = {
 
-			"mm" : {
+			"mm": {
 				"mm": 1,
 				"cm": 0.1,
 				"in": 1 / 25.4,
@@ -887,7 +887,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 				"pc": 6 / 25.4,
 				"px": - 1
 			},
-			"cm" : {
+			"cm": {
 				"mm": 10,
 				"cm": 1,
 				"in": 1 / 2.54,
@@ -895,7 +895,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 				"pc": 6 / 2.54,
 				"px": - 1
 			},
-			"in" : {
+			"in": {
 				"mm": 25.4,
 				"cm": 2.54,
 				"in": 1,
@@ -903,7 +903,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 				"pc": 6,
 				"px": - 1
 			},
-			"pt" : {
+			"pt": {
 				"mm": 25.4 / 72,
 				"cm": 2.54 / 72,
 				"in": 1 / 72,
@@ -911,7 +911,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 				"pc": 6 / 72,
 				"px": - 1
 			},
-			"pc" : {
+			"pc": {
 				"mm": 25.4 / 6,
 				"cm": 2.54 / 6,
 				"in": 1 / 6,
@@ -919,7 +919,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 				"pc": 1,
 				"px": - 1
 			},
-			"px" : {
+			"px": {
 				"px": 1
 			}
 
@@ -955,8 +955,7 @@ THREE.SVGLoader.prototype = Object.assign( Object.create( THREE.Loader.prototype
 
 				scale = unitConversion[ "in" ][ scope.defaultUnit ] / scope.defaultDPI;
 
-			}
-			else {
+			} else {
 
 				scale = unitConversion[ theUnit ][ scope.defaultUnit ];
 

+ 7 - 8
examples/jsm/loaders/SVGLoader.js

@@ -892,7 +892,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		// Conversion: [ fromUnit ][ toUnit ] (-1 means dpi dependent)
 		var unitConversion = {
 
-			"mm" : {
+			"mm": {
 				"mm": 1,
 				"cm": 0.1,
 				"in": 1 / 25.4,
@@ -900,7 +900,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				"pc": 6 / 25.4,
 				"px": - 1
 			},
-			"cm" : {
+			"cm": {
 				"mm": 10,
 				"cm": 1,
 				"in": 1 / 2.54,
@@ -908,7 +908,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				"pc": 6 / 2.54,
 				"px": - 1
 			},
-			"in" : {
+			"in": {
 				"mm": 25.4,
 				"cm": 2.54,
 				"in": 1,
@@ -916,7 +916,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				"pc": 6,
 				"px": - 1
 			},
-			"pt" : {
+			"pt": {
 				"mm": 25.4 / 72,
 				"cm": 2.54 / 72,
 				"in": 1 / 72,
@@ -924,7 +924,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				"pc": 6 / 72,
 				"px": - 1
 			},
-			"pc" : {
+			"pc": {
 				"mm": 25.4 / 6,
 				"cm": 2.54 / 6,
 				"in": 1 / 6,
@@ -932,7 +932,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 				"pc": 1,
 				"px": - 1
 			},
-			"px" : {
+			"px": {
 				"px": 1
 			}
 
@@ -968,8 +968,7 @@ SVGLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 
 				scale = unitConversion[ "in" ][ scope.defaultUnit ] / scope.defaultDPI;
 
-			}
-			else {
+			} else {
 
 				scale = unitConversion[ theUnit ][ scope.defaultUnit ];
 

+ 1 - 1
examples/jsm/nodes/accessors/NormalNode.js

@@ -41,7 +41,7 @@ NormalNode.prototype.build = function ( builder, output, uuid, ns ) {
 
 	return TempNode.prototype.build.call( this, builder, output, uuid );
 
-}
+};
 
 NormalNode.prototype.generate = function ( builder, output ) {
 

+ 2 - 2
examples/jsm/nodes/core/NodeBuilder.js

@@ -164,7 +164,7 @@ NodeBuilder.prototype = {
 		this.buildShader( 'vertex', vertex );
 		this.buildShader( 'fragment', fragment );
 
-		for ( var i = 0; i < this.requires.uv.length; i++ ) {
+		for ( var i = 0; i < this.requires.uv.length; i ++ ) {
 
 			if ( this.requires.uv[ i ] ) {
 
@@ -178,7 +178,7 @@ NodeBuilder.prototype = {
 
 				}
 
-				this.addVertexFinalCode( 'vUv' + uvIndex + ' = uv' + uvIndex +';' );
+				this.addVertexFinalCode( 'vUv' + uvIndex + ' = uv' + uvIndex + ';' );
 
 			}
 

+ 1 - 1
examples/jsm/nodes/materials/nodes/StandardNode.js

@@ -339,7 +339,7 @@ StandardNode.prototype.build = function ( builder ) {
 			'material.specularRoughness = max( roughnessFactor, 0.0525 );',
 			'material.specularRoughness += geometryRoughness;',
 			'material.specularRoughness = min( material.specularRoughness, 1.0 );',
-			
+
 			'material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );'
 		);
 

+ 3 - 3
examples/jsm/renderers/CSS2DRenderer.d.ts

@@ -9,8 +9,8 @@ export class CSS2DObject extends Object3D {
 	constructor( element: HTMLElement );
 	element: HTMLElement;
 
-	onBeforeRender: (renderer: unknown, scene: Scene, camera: Camera) => void;
- 	onAfterRender: (renderer: unknown, scene: Scene, camera: Camera) => void;
+	onBeforeRender: ( renderer: unknown, scene: Scene, camera: Camera ) => void;
+ 	onAfterRender: ( renderer: unknown, scene: Scene, camera: Camera ) => void;
 
 }
 
@@ -19,7 +19,7 @@ export class CSS2DRenderer {
 	constructor();
 	domElement: HTMLElement;
 
-	getSize(): {width: number, height: number};
+	getSize(): { width: number, height: number };
 	setSize( width: number, height: number ): void;
 	render( scene: Scene, camera: Camera ): void;
 

+ 3 - 3
examples/jsm/renderers/CSS3DRenderer.d.ts

@@ -9,8 +9,8 @@ export class CSS3DObject extends Object3D {
 	constructor( element: HTMLElement );
 	element: HTMLElement;
 
-	onBeforeRender: (renderer: unknown, scene: Scene, camera: Camera) => void;
-	onAfterRender: (renderer: unknown, scene: Scene, camera: Camera) => void;
+	onBeforeRender: ( renderer: unknown, scene: Scene, camera: Camera ) => void;
+	onAfterRender: ( renderer: unknown, scene: Scene, camera: Camera ) => void;
 
 }
 
@@ -25,7 +25,7 @@ export class CSS3DRenderer {
 	constructor();
 	domElement: HTMLElement;
 
-	getSize(): {width: number, height: number};
+	getSize(): { width: number, height: number };
 	setSize( width: number, height: number ): void;
 	render( scene: Scene, camera: Camera ): void;
 

+ 5 - 5
examples/jsm/utils/GeometryCompressionUtils.d.ts

@@ -1,9 +1,9 @@
-import * as THREE from "../../../build/three.module.js";
+import { Mesh } from '../../../src/Three';
 
 export namespace GeometryCompressionUtils {
 
-	export function compressNormals( mesh: THREE.Mesh, encodeMethod: String );
-	export function compressPositions( mesh: THREE.Mesh );
-	export function compressUvs( mesh: THREE.Mesh );
+	export function compressNormals( mesh: Mesh, encodeMethod: String );
+	export function compressPositions( mesh: Mesh );
+	export function compressUvs( mesh: Mesh );
 
-}
+}

文件差异内容过多而无法显示
+ 547 - 452
examples/jsm/utils/GeometryCompressionUtils.js


+ 5 - 1
examples/jsm/webxr/XRControllerModelFactory.d.ts

@@ -7,17 +7,21 @@ import {
 import { GLTFLoader } from '../loaders/GLTFLoader';
 
 export class XRControllerModel extends Object3D {
-	constructor( );
+
+	constructor();
 
 	motionController: any;
 
 	setEnvironmentMap( envMap: Texture ): XRControllerModel;
+
 }
 
 export class XRControllerModelFactory {
+
 	constructor( gltfLoader?: GLTFLoader );
 	gltfLoader: GLTFLoader | null;
 	path: string;
 
 	createControllerModel( controller: Group ): XRControllerModel;
+
 }

+ 50 - 44
examples/jsm/webxr/XRControllerModelFactory.js

@@ -44,7 +44,7 @@ XRControllerModel.prototype = Object.assign( Object.create( Object3D.prototype )
 		}
 
 		this.envMap = envMap;
-		this.traverse(( child ) => {
+		this.traverse( ( child ) => {
 
 			if ( child.isMesh ) {
 
@@ -53,7 +53,7 @@ XRControllerModel.prototype = Object.assign( Object.create( Object3D.prototype )
 
 			}
 
-		});
+		} );
 
 		return this;
 
@@ -67,22 +67,22 @@ XRControllerModel.prototype = Object.assign( Object.create( Object3D.prototype )
 
 		Object3D.prototype.updateMatrixWorld.call( this, force );
 
-		if ( !this.motionController ) return;
+		if ( ! this.motionController ) return;
 
 		// Cause the MotionController to poll the Gamepad for data
 		this.motionController.updateFromGamepad();
 
 		// Update the 3D model to reflect the button, thumbstick, and touchpad state
-		Object.values( this.motionController.components ).forEach(( component ) => {
+		Object.values( this.motionController.components ).forEach( ( component ) => {
 
 			// Update node data based on the visual responses' current states
-			Object.values( component.visualResponses ).forEach(( visualResponse ) => {
+			Object.values( component.visualResponses ).forEach( ( visualResponse ) => {
 
 				const { valueNode, minNode, maxNode, value, valueNodeProperty } = visualResponse;
 
 				// Skip if the visual response node is not found. No error is needed,
 				// because it will have been reported at load time.
-				if ( !valueNode ) return;
+				if ( ! valueNode ) return;
 
 				// Calculate the new properties based on the weight supplied
 				if ( valueNodeProperty === MotionControllerConstants.VisualResponseProperty.VISIBILITY ) {
@@ -106,9 +106,9 @@ XRControllerModel.prototype = Object.assign( Object.create( Object3D.prototype )
 
 				}
 
-			});
+			} );
 
-		});
+		} );
 
 	}
 
@@ -122,75 +122,80 @@ XRControllerModel.prototype = Object.assign( Object.create( Object3D.prototype )
 function findNodes( motionController, scene ) {
 
 	// Loop through the components and find the nodes needed for each components' visual responses
-	Object.values( motionController.components ).forEach(( component ) => {
+	Object.values( motionController.components ).forEach( ( component ) => {
 
 		const { type, touchPointNodeName, visualResponses } = component;
 
-		if (type === MotionControllerConstants.ComponentType.TOUCHPAD) {
+		if ( type === MotionControllerConstants.ComponentType.TOUCHPAD ) {
 
 			component.touchPointNode = scene.getObjectByName( touchPointNodeName );
 			if ( component.touchPointNode ) {
 
 				// Attach a touch dot to the touchpad.
 				const sphereGeometry = new SphereGeometry( 0.001 );
-				const material = new MeshBasicMaterial({ color: 0x0000FF });
+				const material = new MeshBasicMaterial( { color: 0x0000FF } );
 				const sphere = new Mesh( sphereGeometry, material );
 				component.touchPointNode.add( sphere );
 
 			} else {
 
-				console.warn(`Could not find touch dot, ${component.touchPointNodeName}, in touchpad component ${componentId}`);
+				console.warn( `Could not find touch dot, ${component.touchPointNodeName}, in touchpad component ${componentId}` );
 
 			}
 
 		}
 
 		// Loop through all the visual responses to be applied to this component
-		Object.values( visualResponses ).forEach(( visualResponse ) => {
+		Object.values( visualResponses ).forEach( ( visualResponse ) => {
 
 			const { valueNodeName, minNodeName, maxNodeName, valueNodeProperty } = visualResponse;
 
 			// If animating a transform, find the two nodes to be interpolated between.
 			if ( valueNodeProperty === MotionControllerConstants.VisualResponseProperty.TRANSFORM ) {
 
-				visualResponse.minNode = scene.getObjectByName(minNodeName);
-				visualResponse.maxNode = scene.getObjectByName(maxNodeName);
+				visualResponse.minNode = scene.getObjectByName( minNodeName );
+				visualResponse.maxNode = scene.getObjectByName( maxNodeName );
 
 				// If the extents cannot be found, skip this animation
-				if ( !visualResponse.minNode ) {
+				if ( ! visualResponse.minNode ) {
 
-					console.warn(`Could not find ${minNodeName} in the model`);
+					console.warn( `Could not find ${minNodeName} in the model` );
 					return;
 
 				}
 
-				if ( !visualResponse.maxNode ) {
+				if ( ! visualResponse.maxNode ) {
 
-					console.warn(`Could not find ${maxNodeName} in the model`);
+					console.warn( `Could not find ${maxNodeName} in the model` );
 					return;
 
 				}
+
 			}
 
 			// If the target node cannot be found, skip this animation
-			visualResponse.valueNode = scene.getObjectByName(valueNodeName);
-			if ( !visualResponse.valueNode ) {
+			visualResponse.valueNode = scene.getObjectByName( valueNodeName );
+			if ( ! visualResponse.valueNode ) {
 
-				console.warn(`Could not find ${valueNodeName} in the model`);
+				console.warn( `Could not find ${valueNodeName} in the model` );
 
 			}
-		});
-	});
+
+		} );
+
+	} );
+
 }
 
 function addAssetSceneToControllerModel( controllerModel, scene ) {
+
 	// Find the nodes needed for animation and cache them on the motionController.
 	findNodes( controllerModel.motionController, scene );
 
 	// Apply any environment map that the mesh already has set.
 	if ( controllerModel.envMap ) {
 
-		scene.traverse(( child ) => {
+		scene.traverse( ( child ) => {
 
 			if ( child.isMesh ) {
 
@@ -199,12 +204,13 @@ function addAssetSceneToControllerModel( controllerModel, scene ) {
 
 			}
 
-		});
+		} );
 
 	}
 
 	// Add the glTF scene to the controllerModel.
 	controllerModel.add( scene );
+
 }
 
 var XRControllerModelFactory = ( function () {
@@ -216,7 +222,7 @@ var XRControllerModelFactory = ( function () {
 		this._assetCache = {};
 
 		// If a GLTFLoader wasn't supplied to the constructor create a new one.
-		if ( !this.gltfLoader ) {
+		if ( ! this.gltfLoader ) {
 
 			this.gltfLoader = new GLTFLoader();
 
@@ -237,9 +243,9 @@ var XRControllerModelFactory = ( function () {
 
 				const xrInputSource = event.data;
 
-				if (xrInputSource.targetRayMode !== 'tracked-pointer' || !xrInputSource.gamepad ) return;
+				if ( xrInputSource.targetRayMode !== 'tracked-pointer' || ! xrInputSource.gamepad ) return;
 
-				fetchProfile( xrInputSource, this.path, DEFAULT_PROFILE ).then(({ profile, assetPath }) => {
+				fetchProfile( xrInputSource, this.path, DEFAULT_PROFILE ).then( ( { profile, assetPath } ) => {
 
 					controllerModel.motionController = new MotionController(
 						xrInputSource,
@@ -247,47 +253,47 @@ var XRControllerModelFactory = ( function () {
 						assetPath
 					);
 
-					let cachedAsset = this._assetCache[controllerModel.motionController.assetUrl];
-					if (cachedAsset) {
+					let cachedAsset = this._assetCache[ controllerModel.motionController.assetUrl ];
+					if ( cachedAsset ) {
 
 						scene = cachedAsset.scene.clone();
 
-						addAssetSceneToControllerModel(controllerModel, scene);
+						addAssetSceneToControllerModel( controllerModel, scene );
 
 					} else {
 
-						if ( !this.gltfLoader ) {
+						if ( ! this.gltfLoader ) {
 
-							throw new Error(`GLTFLoader not set.`);
+							throw new Error( `GLTFLoader not set.` );
 
 						}
 
-						this.gltfLoader.setPath('');
+						this.gltfLoader.setPath( '' );
 						this.gltfLoader.load( controllerModel.motionController.assetUrl, ( asset ) => {
 
-							this._assetCache[controllerModel.motionController.assetUrl] = asset;
+							this._assetCache[ controllerModel.motionController.assetUrl ] = asset;
 
 							scene = asset.scene.clone();
 
-							addAssetSceneToControllerModel(controllerModel, scene);
+							addAssetSceneToControllerModel( controllerModel, scene );
 
 						},
 						null,
 						() => {
 
-							throw new Error(`Asset ${motionController.assetUrl} missing or malformed.`);
+							throw new Error( `Asset ${motionController.assetUrl} missing or malformed.` );
 
-						});
+						} );
 
 					}
 
-				}).catch((err) => {
+				} ).catch( ( err ) => {
 
-					console.warn(err);
+					console.warn( err );
 
-				});
+				} );
 
-			});
+			} );
 
 			controller.addEventListener( 'disconnected', () => {
 
@@ -295,7 +301,7 @@ var XRControllerModelFactory = ( function () {
 				controllerModel.remove( scene );
 				scene = null;
 
-			});
+			} );
 
 			return controllerModel;
 

+ 0 - 1
src/math/Matrix3.d.ts

@@ -1,5 +1,4 @@
 import { Matrix4 } from './Matrix4';
-import { Quaternion } from './Quaternion';
 import { Vector3 } from './Vector3';
 
 /**

部分文件因为文件数量过多而无法显示