瀏覽代碼

Updated builds.

Mugen87 2 年之前
父節點
當前提交
ebf6d68e08
共有 4 個文件被更改,包括 116 次插入51 次删除
  1. 34 18
      build/three.cjs
  2. 34 18
      build/three.js
  3. 0 0
      build/three.min.js
  4. 48 15
      build/three.module.js

+ 34 - 18
build/three.cjs

@@ -16091,6 +16091,22 @@ class WebXRController {
 		}
 		return this;
 	}
+	connect(inputSource) {
+		if (inputSource && inputSource.hand) {
+			const hand = this._hand;
+			if (hand) {
+				for (const inputjoint of inputSource.hand.values()) {
+					// Initialize hand with joints when connected
+					this._getHandJoint(hand, inputjoint);
+				}
+			}
+		}
+		this.dispatchEvent({
+			type: 'connected',
+			data: inputSource
+		});
+		return this;
+	}
 	disconnect(inputSource) {
 		this.dispatchEvent({
 			type: 'disconnected',
@@ -16120,16 +16136,9 @@ class WebXRController {
 				for (const inputjoint of inputSource.hand.values()) {
 					// Update the joints groups with the XRJoint poses
 					const jointPose = frame.getJointPose(inputjoint, referenceSpace);
-					if (hand.joints[inputjoint.jointName] === undefined) {
-						// The transform of this joint will be updated with the joint pose on each frame
-						const joint = new Group();
-						joint.matrixAutoUpdate = false;
-						joint.visible = false;
-						hand.joints[inputjoint.jointName] = joint;
-						// ??
-						hand.add(joint);
-					}
-					const joint = hand.joints[inputjoint.jointName];
+
+					// The transform of this joint will be updated with the joint pose on each frame
+					const joint = this._getHandJoint(hand, inputjoint);
 					if (jointPose !== null) {
 						joint.matrix.fromArray(jointPose.transform.matrix);
 						joint.matrix.decompose(joint.position, joint.rotation, joint.scale);
@@ -16219,6 +16228,19 @@ class WebXRController {
 		}
 		return this;
 	}
+
+	// private method
+
+	_getHandJoint(hand, inputjoint) {
+		if (hand.joints[inputjoint.jointName] === undefined) {
+			const joint = new Group();
+			joint.matrixAutoUpdate = false;
+			joint.visible = false;
+			hand.joints[inputjoint.jointName] = joint;
+			hand.add(joint);
+		}
+		return hand.joints[inputjoint.jointName];
+	}
 }
 
 class DepthTexture extends Texture {
@@ -16482,10 +16504,7 @@ class WebXRManager extends EventDispatcher {
 				const index = controllerInputSources.indexOf(inputSource);
 				if (index >= 0) {
 					controllerInputSources[index] = null;
-					controllers[index].dispatchEvent({
-						type: 'disconnected',
-						data: inputSource
-					});
+					controllers[index].disconnect(inputSource);
 				}
 			}
 
@@ -16515,10 +16534,7 @@ class WebXRManager extends EventDispatcher {
 				}
 				const controller = controllers[controllerIndex];
 				if (controller) {
-					controller.dispatchEvent({
-						type: 'connected',
-						data: inputSource
-					});
+					controller.connect(inputSource);
 				}
 			}
 		}

+ 34 - 18
build/three.js

@@ -16093,6 +16093,22 @@
 			}
 			return this;
 		}
+		connect(inputSource) {
+			if (inputSource && inputSource.hand) {
+				const hand = this._hand;
+				if (hand) {
+					for (const inputjoint of inputSource.hand.values()) {
+						// Initialize hand with joints when connected
+						this._getHandJoint(hand, inputjoint);
+					}
+				}
+			}
+			this.dispatchEvent({
+				type: 'connected',
+				data: inputSource
+			});
+			return this;
+		}
 		disconnect(inputSource) {
 			this.dispatchEvent({
 				type: 'disconnected',
@@ -16122,16 +16138,9 @@
 					for (const inputjoint of inputSource.hand.values()) {
 						// Update the joints groups with the XRJoint poses
 						const jointPose = frame.getJointPose(inputjoint, referenceSpace);
-						if (hand.joints[inputjoint.jointName] === undefined) {
-							// The transform of this joint will be updated with the joint pose on each frame
-							const joint = new Group();
-							joint.matrixAutoUpdate = false;
-							joint.visible = false;
-							hand.joints[inputjoint.jointName] = joint;
-							// ??
-							hand.add(joint);
-						}
-						const joint = hand.joints[inputjoint.jointName];
+
+						// The transform of this joint will be updated with the joint pose on each frame
+						const joint = this._getHandJoint(hand, inputjoint);
 						if (jointPose !== null) {
 							joint.matrix.fromArray(jointPose.transform.matrix);
 							joint.matrix.decompose(joint.position, joint.rotation, joint.scale);
@@ -16221,6 +16230,19 @@
 			}
 			return this;
 		}
+
+		// private method
+
+		_getHandJoint(hand, inputjoint) {
+			if (hand.joints[inputjoint.jointName] === undefined) {
+				const joint = new Group();
+				joint.matrixAutoUpdate = false;
+				joint.visible = false;
+				hand.joints[inputjoint.jointName] = joint;
+				hand.add(joint);
+			}
+			return hand.joints[inputjoint.jointName];
+		}
 	}
 
 	class DepthTexture extends Texture {
@@ -16484,10 +16506,7 @@
 					const index = controllerInputSources.indexOf(inputSource);
 					if (index >= 0) {
 						controllerInputSources[index] = null;
-						controllers[index].dispatchEvent({
-							type: 'disconnected',
-							data: inputSource
-						});
+						controllers[index].disconnect(inputSource);
 					}
 				}
 
@@ -16517,10 +16536,7 @@
 					}
 					const controller = controllers[controllerIndex];
 					if (controller) {
-						controller.dispatchEvent({
-							type: 'connected',
-							data: inputSource
-						});
+						controller.connect(inputSource);
 					}
 				}
 			}

文件差異過大導致無法顯示
+ 0 - 0
build/three.min.js


+ 48 - 15
build/three.module.js

@@ -24761,6 +24761,31 @@ class WebXRController {
 
 	}
 
+	connect( inputSource ) {
+
+		if ( inputSource && inputSource.hand ) {
+
+			const hand = this._hand;
+
+			if ( hand ) {
+
+				for ( const inputjoint of inputSource.hand.values() ) {
+
+					// Initialize hand with joints when connected
+					this._getHandJoint( hand, inputjoint );
+
+				}
+
+			}
+
+		}
+
+		this.dispatchEvent( { type: 'connected', data: inputSource } );
+
+		return this;
+
+	}
+
 	disconnect( inputSource ) {
 
 		this.dispatchEvent( { type: 'disconnected', data: inputSource } );
@@ -24808,19 +24833,8 @@ class WebXRController {
 					// Update the joints groups with the XRJoint poses
 					const jointPose = frame.getJointPose( inputjoint, referenceSpace );
 
-					if ( hand.joints[ inputjoint.jointName ] === undefined ) {
-
-						// The transform of this joint will be updated with the joint pose on each frame
-						const joint = new Group();
-						joint.matrixAutoUpdate = false;
-						joint.visible = false;
-						hand.joints[ inputjoint.jointName ] = joint;
-						// ??
-						hand.add( joint );
-
-					}
-
-					const joint = hand.joints[ inputjoint.jointName ];
+					// The transform of this joint will be updated with the joint pose on each frame
+					const joint = this._getHandJoint( hand, inputjoint );
 
 					if ( jointPose !== null ) {
 
@@ -24972,6 +24986,25 @@ class WebXRController {
 
 	}
 
+	// private method
+
+	_getHandJoint( hand, inputjoint ) {
+
+		if ( hand.joints[ inputjoint.jointName ] === undefined ) {
+
+			const joint = new Group();
+			joint.matrixAutoUpdate = false;
+			joint.visible = false;
+			hand.joints[ inputjoint.jointName ] = joint;
+
+			hand.add( joint );
+
+		}
+
+		return hand.joints[ inputjoint.jointName ];
+
+	}
+
 }
 
 class DepthTexture extends Texture {
@@ -25371,7 +25404,7 @@ class WebXRManager extends EventDispatcher {
 				if ( index >= 0 ) {
 
 					controllerInputSources[ index ] = null;
-					controllers[ index ].dispatchEvent( { type: 'disconnected', data: inputSource } );
+					controllers[ index ].disconnect( inputSource );
 
 				}
 
@@ -25417,7 +25450,7 @@ class WebXRManager extends EventDispatcher {
 
 				if ( controller ) {
 
-					controller.dispatchEvent( { type: 'connected', data: inputSource } );
+					controller.connect( inputSource );
 
 				}
 

部分文件因文件數量過多而無法顯示