From d04f3f0677f8663e144bae02cddc7dcdf1a164bb Mon Sep 17 00:00:00 2001 From: Fernando Serrano Date: Tue, 28 Jul 2020 00:54:21 +0200 Subject: [PATCH] Add SetPath to XRHandModelFactory --- examples/jsm/webxr/XRHandModelFactory.js | 18 ++++++++++++++---- examples/jsm/webxr/XRHandOculusMeshModel.js | 5 +++-- examples/jsm/webxr/XRHandPrimitiveModel.js | 2 +- examples/webxr_vr_handinput_profiles.html | 3 ++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/examples/jsm/webxr/XRHandModelFactory.js b/examples/jsm/webxr/XRHandModelFactory.js index 37b840e2fb..09c4149d1b 100644 --- a/examples/jsm/webxr/XRHandModelFactory.js +++ b/examples/jsm/webxr/XRHandModelFactory.js @@ -42,12 +42,22 @@ XRHandModel.prototype = Object.assign( Object.create( Object3D.prototype ), { var XRHandModelFactory = ( function () { - function XRHandModelFactory() {} + function XRHandModelFactory() { + + this.path = ''; + + } XRHandModelFactory.prototype = { constructor: XRHandModelFactory, + setPath: function ( path ) { + + this.path = path; + + }, + createHandModel: function ( controller, profile, options ) { const handModel = new XRHandModel( controller ); @@ -65,15 +75,15 @@ var XRHandModelFactory = ( function () { // @todo Detect profile if not provided if ( profile === undefined || profile === "spheres" ) { - handModel.motionController = new XRHandPrimitiveModel( handModel, controller, xrInputSource.handedness, { primitive: "sphere" } ); + handModel.motionController = new XRHandPrimitiveModel( handModel, controller, this.path, xrInputSource.handedness, { primitive: "sphere" } ); } else if ( profile === "boxes" ) { - handModel.motionController = new XRHandPrimitiveModel( handModel, controller, xrInputSource.handedness, { primitive: "box" } ); + handModel.motionController = new XRHandPrimitiveModel( handModel, controller, this.path, xrInputSource.handedness, { primitive: "box" } ); } else if ( profile === "oculus" ) { - handModel.motionController = new XRHandOculusMeshModel( handModel, controller, xrInputSource.handedness, options ); + handModel.motionController = new XRHandOculusMeshModel( handModel, controller, this.path, xrInputSource.handedness, options ); } diff --git a/examples/jsm/webxr/XRHandOculusMeshModel.js b/examples/jsm/webxr/XRHandOculusMeshModel.js index 8516de82ed..8b931e3851 100644 --- a/examples/jsm/webxr/XRHandOculusMeshModel.js +++ b/examples/jsm/webxr/XRHandOculusMeshModel.js @@ -2,7 +2,7 @@ import { FBXLoader } from "../loaders/FBXLoader.js"; class XRHandOculusMeshModel { - constructor( handModel, controller, handedness, options ) { + constructor( handModel, controller, path, handedness, options ) { this.controller = controller; this.handModel = handModel; @@ -11,7 +11,8 @@ class XRHandOculusMeshModel { var loader = new FBXLoader(); const low = options && options.model === "lowpoly" ? "_low" : ""; - loader.load( `../../models/fbx/OculusHand_${handedness === "right" ? "R" : "L"}${low}.fbx`, object => { + loader.setPath( path ); + loader.load( `fbx/OculusHand_${handedness === "right" ? "R" : "L"}${low}.fbx`, object => { this.handModel.add( object ); // Hack because of the scale of the skinnedmesh diff --git a/examples/jsm/webxr/XRHandPrimitiveModel.js b/examples/jsm/webxr/XRHandPrimitiveModel.js index 1f53c66ad7..969987bef1 100644 --- a/examples/jsm/webxr/XRHandPrimitiveModel.js +++ b/examples/jsm/webxr/XRHandPrimitiveModel.js @@ -8,7 +8,7 @@ import { class XRHandPrimitiveModel { - constructor( handModel, controller, handedness, options ) { + constructor( handModel, controller, path, handedness, options ) { this.controller = controller; this.handModel = handModel; diff --git a/examples/webxr_vr_handinput_profiles.html b/examples/webxr_vr_handinput_profiles.html index 97a250c067..f371630285 100644 --- a/examples/webxr_vr_handinput_profiles.html +++ b/examples/webxr_vr_handinput_profiles.html @@ -92,7 +92,7 @@ container.appendChild( renderer.domElement ); - document.body.appendChild( VRButton.createButton( renderer ) ); + document.body.appendChild( VRButton.createButton( renderer, { handTracking: true } ) ); // controllers @@ -104,6 +104,7 @@ var controllerModelFactory = new XRControllerModelFactory(); var handModelFactory = new XRHandModelFactory(); + handModelFactory.setPath( "./models/" ); // Hand 1 -- GitLab