ソースを参照

[XR] Feat: Allow passing GLTFLoader into OculusHandModel/XRHandMeshModel (#25013)

* feat: allow passing GLTFLoader into OculusHandModel/XRHandMeshModel

* apply review feedback
hybridherbst 2 年 前
コミット
08b7401eb5

+ 3 - 2
examples/jsm/webxr/OculusHandModel.js

@@ -6,13 +6,14 @@ const POINTING_JOINT = 'index-finger-tip';
 
 class OculusHandModel extends Object3D {
 
-	constructor( controller ) {
+	constructor( controller, loader ) {
 
 		super();
 
 		this.controller = controller;
 		this.motionController = null;
 		this.envMap = null;
+		this.loader = loader;
 
 		this.mesh = null;
 
@@ -24,7 +25,7 @@ class OculusHandModel extends Object3D {
 
 				this.xrInputSource = xrInputSource;
 
-				this.motionController = new XRHandMeshModel( this, controller, this.path, xrInputSource.handedness );
+				this.motionController = new XRHandMeshModel( this, controller, this.path, xrInputSource.handedness, this.loader );
 
 			}
 

+ 8 - 3
examples/jsm/webxr/XRHandMeshModel.js

@@ -4,15 +4,20 @@ const DEFAULT_HAND_PROFILE_PATH = 'https://cdn.jsdelivr.net/npm/@webxr-input-pro
 
 class XRHandMeshModel {
 
-	constructor( handModel, controller, path, handedness ) {
+	constructor( handModel, controller, path, handedness, loader = null ) {
 
 		this.controller = controller;
 		this.handModel = handModel;
 
 		this.bones = [];
 
-		const loader = new GLTFLoader();
-		loader.setPath( path || DEFAULT_HAND_PROFILE_PATH );
+		if ( loader === null ) {
+
+			loader = new GLTFLoader();
+			loader.setPath( path || DEFAULT_HAND_PROFILE_PATH );
+
+		}
+
 		loader.load( `${handedness}.glb`, gltf => {
 
 			const object = gltf.scene.children[ 0 ];