提交 d04f3f06 编写于 作者: F Fernando Serrano

Add SetPath to XRHandModelFactory

上级 4e0e65fc
......@@ -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 );
}
......
......@@ -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
......
......@@ -8,7 +8,7 @@ import {
class XRHandPrimitiveModel {
constructor( handModel, controller, handedness, options ) {
constructor( handModel, controller, path, handedness, options ) {
this.controller = controller;
this.handModel = handModel;
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册