Browse Source

Examples: Clean up.

Mugen87 5 years ago
parent
commit
33d85af555

+ 9 - 10
examples/jsm/webxr/XRHandModelFactory.js

@@ -1,14 +1,14 @@
 import {
 import {
 	Object3D
 	Object3D
-} from "../../../build/three.module.js";
+} from '../../../build/three.module.js';
 
 
 import {
 import {
 	XRHandPrimitiveModel
 	XRHandPrimitiveModel
-} from "./XRHandPrimitiveModel.js";
+} from './XRHandPrimitiveModel.js';
 
 
 import {
 import {
 	XRHandOculusMeshModel
 	XRHandOculusMeshModel
-} from "./XRHandOculusMeshModel.js";
+} from './XRHandOculusMeshModel.js';
 
 
 function XRHandModel( controller ) {
 function XRHandModel( controller ) {
 
 
@@ -40,7 +40,7 @@ XRHandModel.prototype = Object.assign( Object.create( Object3D.prototype ), {
 } );
 } );
 
 
 
 
-var XRHandModelFactory = ( function () {
+const XRHandModelFactory = ( function () {
 
 
 	function XRHandModelFactory() {
 	function XRHandModelFactory() {
 
 
@@ -62,7 +62,6 @@ var XRHandModelFactory = ( function () {
 		createHandModel: function ( controller, profile, options ) {
 		createHandModel: function ( controller, profile, options ) {
 
 
 			const handModel = new XRHandModel( controller );
 			const handModel = new XRHandModel( controller );
-			let scene = null;
 
 
 			controller.addEventListener( 'connected', ( event ) => {
 			controller.addEventListener( 'connected', ( event ) => {
 
 
@@ -74,15 +73,15 @@ var XRHandModelFactory = ( function () {
 					handModel.xrInputSource = xrInputSource;
 					handModel.xrInputSource = xrInputSource;
 
 
 					// @todo Detect profile if not provided
 					// @todo Detect profile if not provided
-					if ( profile === undefined || profile === "spheres" ) {
+					if ( profile === undefined || profile === 'spheres' ) {
 
 
-						handModel.motionController = new XRHandPrimitiveModel( handModel, controller, this.path, xrInputSource.handedness, { primitive: "sphere" } );
+						handModel.motionController = new XRHandPrimitiveModel( handModel, controller, this.path, xrInputSource.handedness, { primitive: 'sphere' } );
 
 
-					} else if ( profile === "boxes" ) {
+					} else if ( profile === 'boxes' ) {
 
 
-						handModel.motionController = new XRHandPrimitiveModel( handModel, controller, this.path, xrInputSource.handedness, { primitive: "box" } );
+						handModel.motionController = new XRHandPrimitiveModel( handModel, controller, this.path, xrInputSource.handedness, { primitive: 'box' } );
 
 
-					} else if ( profile === "oculus" ) {
+					} else if ( profile === 'oculus' ) {
 
 
 						handModel.motionController = new XRHandOculusMeshModel( handModel, controller, this.path, xrInputSource.handedness, options );
 						handModel.motionController = new XRHandOculusMeshModel( handModel, controller, this.path, xrInputSource.handedness, options );
 
 

+ 8 - 8
examples/jsm/webxr/XRHandOculusMeshModel.js

@@ -1,4 +1,4 @@
-import { FBXLoader } from "../loaders/FBXLoader.js";
+import { FBXLoader } from '../loaders/FBXLoader.js';
 
 
 class XRHandOculusMeshModel {
 class XRHandOculusMeshModel {
 
 
@@ -8,17 +8,17 @@ class XRHandOculusMeshModel {
 		this.handModel = handModel;
 		this.handModel = handModel;
 
 
 		this.bones = [];
 		this.bones = [];
-		var loader = new FBXLoader();
-		const low = options && options.model === "lowpoly" ? "_low" : "";
+		const loader = new FBXLoader();
+		const low = options && options.model === 'lowpoly' ? '_low' : '';
 
 
 		loader.setPath( path );
 		loader.setPath( path );
-		loader.load( `OculusHand_${handedness === "right" ? "R" : "L"}${low}.fbx`, object => {
+		loader.load( `OculusHand_${handedness === 'right' ? 'R' : 'L'}${low}.fbx`, object => {
 
 
 			this.handModel.add( object );
 			this.handModel.add( object );
 			// Hack because of the scale of the skinnedmesh
 			// Hack because of the scale of the skinnedmesh
 			object.scale.setScalar( 0.01 );
 			object.scale.setScalar( 0.01 );
 
 
-			const mesh = object.getObjectByProperty( "type", "SkinnedMesh" );
+			const mesh = object.getObjectByProperty( 'type', 'SkinnedMesh' );
 			mesh.frustumCulled = false;
 			mesh.frustumCulled = false;
 			mesh.castShadow = true;
 			mesh.castShadow = true;
 			mesh.receiveShadow = true;
 			mesh.receiveShadow = true;
@@ -59,7 +59,7 @@ class XRHandOculusMeshModel {
 
 
 				if ( boneName ) {
 				if ( boneName ) {
 
 
-					const bone = object.getObjectByName( boneName.replace( "%", handedness === "right" ? "r" : "l" ) );
+					const bone = object.getObjectByName( boneName.replace( /%/g, handedness === 'right' ? 'r' : 'l' ) );
 					this.bones.push( bone );
 					this.bones.push( bone );
 
 
 				} else {
 				} else {
@@ -78,7 +78,7 @@ class XRHandOculusMeshModel {
 
 
 		// XR Joints
 		// XR Joints
 		const XRJoints = this.controller.joints;
 		const XRJoints = this.controller.joints;
-		for ( var i = 0; i < this.bones.length; i ++ ) {
+		for ( let i = 0; i < this.bones.length; i ++ ) {
 
 
 			const bone = this.bones[ i ];
 			const bone = this.bones[ i ];
 			const XRJoint = XRJoints[ i ];
 			const XRJoint = XRJoints[ i ];
@@ -93,7 +93,7 @@ class XRHandOculusMeshModel {
 
 
 						bone.position.copy( position.clone().multiplyScalar( 100 ) );
 						bone.position.copy( position.clone().multiplyScalar( 100 ) );
 						bone.quaternion.copy( XRJoint.quaternion );
 						bone.quaternion.copy( XRJoint.quaternion );
-						// bone.scale.setScalar( XRJoint.jointRadius || defaultRadius );
+						// bone.scale.setScalar( XRJoint.jointRadius || defaultRadius );
 
 
 					}
 					}
 
 

+ 15 - 13
examples/jsm/webxr/XRHandPrimitiveModel.js

@@ -4,7 +4,7 @@ import {
 	MeshStandardMaterial,
 	MeshStandardMaterial,
 	Mesh,
 	Mesh,
 	Group
 	Group
-} from "../../../build/three.module.js";
+} from '../../../build/three.module.js';
 
 
 class XRHandPrimitiveModel {
 class XRHandPrimitiveModel {
 
 
@@ -20,28 +20,29 @@ class XRHandPrimitiveModel {
 
 
 		if ( window.XRHand ) {
 		if ( window.XRHand ) {
 
 
-			var geometry;
-			if ( ! options || ! options.primitive || options.primitive === "sphere" ) {
+			let geometry;
+
+			if ( ! options || ! options.primitive || options.primitive === 'sphere' ) {
 
 
 				geometry = new SphereBufferGeometry( 1, 10, 10 );
 				geometry = new SphereBufferGeometry( 1, 10, 10 );
 
 
-			} else if ( options.primitive === "box" ) {
+			} else if ( options.primitive === 'box' ) {
 
 
 				geometry = new BoxBufferGeometry( 1, 1, 1 );
 				geometry = new BoxBufferGeometry( 1, 1, 1 );
 
 
 			}
 			}
 
 
-			var jointMaterial = new MeshStandardMaterial( { color: 0xffffff, roughness: 1, metalness: 0 } );
-			var tipMaterial = new MeshStandardMaterial( { color: 0x999999, roughness: 1, metalness: 0 } );
+			const jointMaterial = new MeshStandardMaterial( { color: 0xffffff, roughness: 1, metalness: 0 } );
+			const tipMaterial = new MeshStandardMaterial( { color: 0x999999, roughness: 1, metalness: 0 } );
 
 
 			const tipIndexes = [
 			const tipIndexes = [
-				XRHand.THUMB_PHALANX_TIP,
-				XRHand.INDEX_PHALANX_TIP,
-				XRHand.MIDDLE_PHALANX_TIP,
-				XRHand.RING_PHALANX_TIP,
-				XRHand.LITTLE_PHALANX_TIP
+				window.XRHand.THUMB_PHALANX_TIP,
+				window.XRHand.INDEX_PHALANX_TIP,
+				window.XRHand.MIDDLE_PHALANX_TIP,
+				window.XRHand.RING_PHALANX_TIP,
+				window.XRHand.LITTLE_PHALANX_TIP
 			];
 			];
-			for ( let i = 0; i <= XRHand.LITTLE_PHALANX_TIP; i ++ ) {
+			for ( let i = 0; i <= window.XRHand.LITTLE_PHALANX_TIP; i ++ ) {
 
 
 				var cube = new Mesh( geometry, tipIndexes.indexOf( i ) !== - 1 ? tipMaterial : jointMaterial );
 				var cube = new Mesh( geometry, tipIndexes.indexOf( i ) !== - 1 ? tipMaterial : jointMaterial );
 				cube.castShadow = true;
 				cube.castShadow = true;
@@ -61,7 +62,8 @@ class XRHandPrimitiveModel {
 
 
 		// XR Joints
 		// XR Joints
 		const XRJoints = this.controller.joints;
 		const XRJoints = this.controller.joints;
-		for ( var i = 0; i < objects.length; i ++ ) {
+
+		for ( let i = 0; i < objects.length; i ++ ) {
 
 
 			const jointMesh = objects[ i ];
 			const jointMesh = objects[ i ];
 			const XRJoint = XRJoints[ i ];
 			const XRJoint = XRJoints[ i ];