You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -76,10 +76,7 @@ Object.assign(pc, function () {
76
76
* * {@link pc.XRHAND_RIGHT}: Right - indicates that input source is meant to be held in right hand.
77
77
*
78
78
* @property {string[]} profiles List of input profile names indicating both the prefered visual representation and behavior of the input source.
79
-
* @property {pc.Ray} ray Ray that is calculated based on {@link pc.XrInputSource#targetRayMode} that can be used for interacting with virtual objects. Its origin and direction are in local space of XR session.
80
79
* @property {boolean} grip If input source can be held, then it will have node with its world transformation, that can be used to position and rotate virtual joystics based on it.
81
-
* @property {pc.Vec3|null} position If {@link pc.XrInputSource#grip} is true, then position will represent position of handheld input source in local space of XR session.
82
-
* @property {pc.Quat|null} rotation If {@link pc.XrInputSource#grip} is true, then rotation will represent rotation of handheld input source in local space of XR session.
83
80
* @property {Gamepad|null} gamepad If input source has buttons, triggers, thumbstick or touchpad, then this object provides access to its states.
84
81
* @property {boolean} selecting True if input source is in active primary action between selectstart and selectend events.
85
82
* @property {pc.XrHitTestSource[]} hitTestSources list of active {@link pc.XrHitTestSource} created by this input source.
@@ -91,9 +88,17 @@ Object.assign(pc, function () {
91
88
this._xrInputSource=xrInputSource;
92
89
93
90
this._ray=newpc.Ray();
91
+
this._rayLocal=newpc.Ray();
94
92
this._grip=false;
95
-
this._position=null;
96
-
this._rotation=null;
93
+
94
+
this._localTransform=null;
95
+
this._worldTransform=null;
96
+
this._position=newpc.Vec3();
97
+
this._rotation=newpc.Quat();
98
+
this._localPosition=null;
99
+
this._localRotation=null;
100
+
this._dirtyLocal=true;
101
+
97
102
this._selecting=false;
98
103
99
104
this._hitTestSources=[];
@@ -117,8 +122,10 @@ Object.assign(pc, function () {
117
122
* @description Fired when input source has triggered primary action. This could be pressing a trigger button, or touching a screen.
118
123
* @param {object} evt - XRInputSourceEvent event data from WebXR API
* @description Get the local space position of input source if it is handheld ({@link pc.XrInputSource#grip} is true). Local space is relative to parent of the XR camera. Otherwise it will return null.
284
+
* @returns {pc.Vec3|null} The world space position of handheld input source.
* @description Get the world space rotation of input source if it is handheld ({@link pc.XrInputSource#grip} is true). Otherwise it will return null.
294
+
* @returns {pc.Vec3|null} The world space rotation of handheld input source.
295
+
*/
296
+
XrInputSource.prototype.getRotation=function(){
297
+
if(!this._rotation)returnnull;
298
+
299
+
this._updateTransforms();
300
+
this._rotation.setFromMat4(this._worldTransform);
301
+
302
+
returnthis._rotation;
303
+
};
304
+
305
+
/**
306
+
* @function
307
+
* @name pc.XrInputSource#getLocalRotation
308
+
* @description Get the local space rotation of input source if it is handheld ({@link pc.XrInputSource#grip} is true). Local space is relative to parent of the XR camera. Otherwise it will return null.
309
+
* @returns {pc.Vec3|null} The world space rotation of handheld input source.
0 commit comments