Skip to content

Commit 7130191

Browse files
committed
PR fix
1 parent 2c2f05b commit 7130191

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

Packages/webxr/Runtime/Plugins/WebGL/webxr.jspre

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ setTimeout(function () {
6565
}
6666

6767
function XRControllerData() {
68-
this.bufferIndex = 0;
6968
this.frameIndex = 0;
7069
this.enabledIndex = 0;
7170
this.handIndex = 0;
@@ -99,7 +98,6 @@ setTimeout(function () {
9998
this.updatedProfiles = 0;
10099

101100
this.setIndices = function(index) {
102-
this.bufferIndex = index;
103101
this.frameIndex = index++;
104102
this.enabledIndex = index++;
105103
this.handIndex = index++;
@@ -127,7 +125,7 @@ setTimeout(function () {
127125
this.gripRotationXIndex = index++;
128126
this.gripRotationYIndex = index++;
129127
this.gripRotationZIndex = index++;
130-
this.gripRotationWIndex = index++;
128+
this.gripRotationWIndex = index;
131129
}
132130
}
133131

@@ -143,7 +141,22 @@ setTimeout(function () {
143141
}
144142

145143
function XRHitPoseData() {
146-
this.bufferIndex = 0;
144+
this.frameIndex = 0;
145+
this.availableIndex = 0;
146+
this.positionIndices = [0, 0, 0];
147+
this.rotationIndices = [0, 0, 0, 0];
148+
149+
this.setIndices = function(index) {
150+
this.frameIndex = index++;
151+
this.availableIndex = index++;
152+
this.positionIndices[0] = index++;
153+
this.positionIndices[1] = index++;
154+
this.positionIndices[2] = index++;
155+
this.rotationIndices[0] = index++;
156+
this.rotationIndices[1] = index++;
157+
this.rotationIndices[2] = index++;
158+
this.rotationIndices[3] = index;
159+
}
147160
}
148161

149162
function lerp(start, end, percentage)
@@ -811,15 +824,15 @@ setTimeout(function () {
811824
this.xrData.controllerB.setIndices(Module.ControllersArrayOffset + 28);
812825
this.xrData.handLeft.bufferIndex = Module.HandsArrayOffset;
813826
this.xrData.handRight.bufferIndex = Module.HandsArrayOffset + 205;
814-
this.xrData.viewerHitTestPose.bufferIndex = Module.ViewerHitTestPoseArrayOffset;
827+
this.xrData.viewerHitTestPose.setIndices(Module.ViewerHitTestPoseArrayOffset);
815828
this.xrData.controllerA.updatedProfiles = 0;
816829
this.xrData.controllerB.updatedProfiles = 0;
817830
this.xrData.controllerA.profiles = [];
818831
this.xrData.controllerB.profiles = [];
819832
Module.HEAPF32[this.xrData.controllerA.updatedGripIndex] = 0; // XRControllerData.updatedGrip
820833
Module.HEAPF32[this.xrData.controllerB.updatedGripIndex] = 0; // XRControllerData.updatedGrip
821-
Module.HEAPF32[this.xrData.viewerHitTestPose.bufferIndex] = -1; // XRHitPoseData.frame
822-
Module.HEAPF32[this.xrData.viewerHitTestPose.bufferIndex + 1] = 0; // XRHitPoseData.available
834+
Module.HEAPF32[this.xrData.viewerHitTestPose.frameIndex] = -1; // XRHitPoseData.frame
835+
Module.HEAPF32[this.xrData.viewerHitTestPose.availableIndex] = 0; // XRHitPoseData.available
823836
}
824837
var thisXRMananger = this;
825838
session.requestReferenceSpace(refSpaceType).then(function (refSpace) {
@@ -906,21 +919,21 @@ setTimeout(function () {
906919
this.getXRControllersData(frame, session.inputSources, session.refSpace, xrData);
907920

908921
if (session.isAR && this.viewerHitTestSource) {
909-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex] = xrData.frameNumber; // XRHitPoseData.frame
922+
Module.HEAPF32[xrData.viewerHitTestPose.frameIndex] = xrData.frameNumber; // XRHitPoseData.frame
910923
var viewerHitTestResults = frame.getHitTestResults(this.viewerHitTestSource);
911924
if (viewerHitTestResults.length > 0) {
912925
var hitTestPose = viewerHitTestResults[0].getPose(session.localRefSpace);
913-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 1] = 1; // XRHitPoseData.available
914-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 2] = hitTestPose.transform.position.x; // XRHitPoseData.position[0]
926+
Module.HEAPF32[xrData.viewerHitTestPose.availableIndex] = 1; // XRHitPoseData.available
927+
Module.HEAPF32[xrData.viewerHitTestPose.positionIndices[0]] = hitTestPose.transform.position.x; // XRHitPoseData.position[0]
915928
var hitTestPoseBase = viewerHitTestResults[0].getPose(session.refSpace); // Ugly hack for y position on Samsung Internet
916-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 3] = hitTestPose.transform.position.y + Math.abs(hitTestPose.transform.position.y - hitTestPoseBase.transform.position.y); // XRHitPoseData.position[1]
917-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 4] = -hitTestPose.transform.position.z; // XRHitPoseData.position[2]
918-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 5] = -hitTestPose.transform.orientation.x; // XRHitPoseData.rotation[0]
919-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 6] = -hitTestPose.transform.orientation.y; // XRHitPoseData.rotation[1]
920-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 7] = hitTestPose.transform.orientation.z; // XRHitPoseData.rotation[2]
921-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 8] = hitTestPose.transform.orientation.w; // XRHitPoseData.rotation[3]
929+
Module.HEAPF32[xrData.viewerHitTestPose.positionIndices[1]] = hitTestPose.transform.position.y + Math.abs(hitTestPose.transform.position.y - hitTestPoseBase.transform.position.y); // XRHitPoseData.position[1]
930+
Module.HEAPF32[xrData.viewerHitTestPose.positionIndices[2]] = -hitTestPose.transform.position.z; // XRHitPoseData.position[2]
931+
Module.HEAPF32[xrData.viewerHitTestPose.rotationIndices[0]] = -hitTestPose.transform.orientation.x; // XRHitPoseData.rotation[0]
932+
Module.HEAPF32[xrData.viewerHitTestPose.rotationIndices[1]] = -hitTestPose.transform.orientation.y; // XRHitPoseData.rotation[1]
933+
Module.HEAPF32[xrData.viewerHitTestPose.rotationIndices[2]] = hitTestPose.transform.orientation.z; // XRHitPoseData.rotation[2]
934+
Module.HEAPF32[xrData.viewerHitTestPose.rotationIndices[3]] = hitTestPose.transform.orientation.w; // XRHitPoseData.rotation[3]
922935
} else {
923-
Module.HEAPF32[xrData.viewerHitTestPose.bufferIndex + 1] = 0; // XRHitPoseData.available
936+
Module.HEAPF32[xrData.viewerHitTestPose.availableIndex] = 0; // XRHitPoseData.available
924937
}
925938
}
926939

0 commit comments

Comments
 (0)