提交 33d85af5 编写于 作者: M Mugen87

Examples: Clean up.

上级 2f741c0a
import {
Object3D
} from "../../../build/three.module.js";
} from '../../../build/three.module.js';
import {
XRHandPrimitiveModel
} from "./XRHandPrimitiveModel.js";
} from './XRHandPrimitiveModel.js';
import {
XRHandOculusMeshModel
} from "./XRHandOculusMeshModel.js";
} from './XRHandOculusMeshModel.js';
function XRHandModel( controller ) {
......@@ -40,7 +40,7 @@ XRHandModel.prototype = Object.assign( Object.create( Object3D.prototype ), {
} );
var XRHandModelFactory = ( function () {
const XRHandModelFactory = ( function () {
function XRHandModelFactory() {
......@@ -62,7 +62,6 @@ var XRHandModelFactory = ( function () {
createHandModel: function ( controller, profile, options ) {
const handModel = new XRHandModel( controller );
let scene = null;
controller.addEventListener( 'connected', ( event ) => {
......@@ -74,15 +73,15 @@ var XRHandModelFactory = ( function () {
handModel.xrInputSource = xrInputSource;
// @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 );
......
import { FBXLoader } from "../loaders/FBXLoader.js";
import { FBXLoader } from '../loaders/FBXLoader.js';
class XRHandOculusMeshModel {
......@@ -8,17 +8,17 @@ class XRHandOculusMeshModel {
this.handModel = handModel;
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.load( `OculusHand_${handedness === "right" ? "R" : "L"}${low}.fbx`, object => {
loader.load( `OculusHand_${handedness === 'right' ? 'R' : 'L'}${low}.fbx`, object => {
this.handModel.add( object );
// Hack because of the scale of the skinnedmesh
object.scale.setScalar( 0.01 );
const mesh = object.getObjectByProperty( "type", "SkinnedMesh" );
const mesh = object.getObjectByProperty( 'type', 'SkinnedMesh' );
mesh.frustumCulled = false;
mesh.castShadow = true;
mesh.receiveShadow = true;
......@@ -59,7 +59,7 @@ class XRHandOculusMeshModel {
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 );
} else {
......@@ -78,7 +78,7 @@ class XRHandOculusMeshModel {
// XR 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 XRJoint = XRJoints[ i ];
......@@ -93,7 +93,7 @@ class XRHandOculusMeshModel {
bone.position.copy( position.clone().multiplyScalar( 100 ) );
bone.quaternion.copy( XRJoint.quaternion );
// bone.scale.setScalar( XRJoint.jointRadius || defaultRadius );
// bone.scale.setScalar( XRJoint.jointRadius || defaultRadius );
}
......
......@@ -4,7 +4,7 @@ import {
MeshStandardMaterial,
Mesh,
Group
} from "../../../build/three.module.js";
} from '../../../build/three.module.js';
class XRHandPrimitiveModel {
......@@ -20,28 +20,29 @@ class XRHandPrimitiveModel {
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 );
} else if ( options.primitive === "box" ) {
} else if ( options.primitive === 'box' ) {
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 = [
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 );
cube.castShadow = true;
......@@ -61,7 +62,8 @@ class XRHandPrimitiveModel {
// XR 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 XRJoint = XRJoints[ i ];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册