Skip to content

Commit

Permalink
Merge pull request #19939 from fernandojsg/handpath
Browse files Browse the repository at this point in the history
[WebXR Hand input] Add setPath on the XRHandModelFactory
  • Loading branch information
mrdoob committed Jul 27, 2020
2 parents 4e0e65f + ff91a9e commit 33f1f8f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
19 changes: 15 additions & 4 deletions examples/jsm/webxr/XRHandModelFactory.js
Expand Up @@ -42,12 +42,23 @@ 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;
return this;

},

createHandModel: function ( controller, profile, options ) {

const handModel = new XRHandModel( controller );
Expand All @@ -65,15 +76,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 );

}

Expand Down
5 changes: 3 additions & 2 deletions examples/jsm/webxr/XRHandOculusMeshModel.js
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/webxr/XRHandPrimitiveModel.js
Expand Up @@ -8,7 +8,7 @@ import {

class XRHandPrimitiveModel {

constructor( handModel, controller, handedness, options ) {
constructor( handModel, controller, path, handedness, options ) {

this.controller = controller;
this.handModel = handModel;
Expand Down
2 changes: 1 addition & 1 deletion examples/webxr_vr_handinput.html
Expand Up @@ -101,7 +101,7 @@
scene.add( controller2 );

var controllerModelFactory = new XRControllerModelFactory();
var handModelFactory = new XRHandModelFactory();
var handModelFactory = new XRHandModelFactory().setPath( "./models/" );

// Hand 1
controllerGrip1 = renderer.xr.getControllerGrip( 0 );
Expand Down
2 changes: 1 addition & 1 deletion examples/webxr_vr_handinput_profiles.html
Expand Up @@ -103,7 +103,7 @@
scene.add( controller2 );

var controllerModelFactory = new XRControllerModelFactory();
var handModelFactory = new XRHandModelFactory();
var handModelFactory = new XRHandModelFactory().setPath( "./models/" );

// Hand 1

Expand Down
2 changes: 1 addition & 1 deletion examples/webxr_vr_handinput_simple.html
Expand Up @@ -91,7 +91,7 @@
scene.add( controller2 );

var controllerModelFactory = new XRControllerModelFactory();
var handModelFactory = new XRHandModelFactory();
var handModelFactory = new XRHandModelFactory().setPath( "./models/" );

// Hand 1
controllerGrip1 = renderer.xr.getControllerGrip( 0 );
Expand Down

0 comments on commit 33f1f8f

Please sign in to comment.