Kaynağa Gözat

Pass `onLoad` callback to `XRHandModelFactory` and `OculusHandModel` (#28074)

* Allow passing `gltfLoader` and `onLoad` callback to `XRHandModelFactory`

* Allow passing `onLoad` callback to `OculusHandModel`

* Update XRHandModelFactory.js

Clean up.

---------

Co-authored-by: Michael Herzog <[email protected]>
Fermin Lozano 1 yıl önce
ebeveyn
işleme
6421f3a49e

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

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

+ 4 - 2
examples/jsm/webxr/XRHandModelFactory.js

@@ -40,9 +40,11 @@ class XRHandModel extends Object3D {
 
 class XRHandModelFactory {
 
-	constructor() {
+	constructor( gltfLoader = null, onLoad = null ) {
 
+		this.gltfLoader = gltfLoader;
 		this.path = null;
+		this.onLoad = onLoad;
 
 	}
 
@@ -77,7 +79,7 @@ class XRHandModelFactory {
 
 				} else if ( profile === 'mesh' ) {
 
-					handModel.motionController = new XRHandMeshModel( handModel, controller, this.path, xrInputSource.handedness );
+					handModel.motionController = new XRHandMeshModel( handModel, controller, this.path, xrInputSource.handedness, this.gltfLoader, this.onLoad );
 
 				}