|
41 | 41 | this.buttonA = 0;
|
42 | 42 | this.buttonB = 0;
|
43 | 43 | this.gamepad = null;
|
| 44 | + this.profiles = []; |
| 45 | + this.updatedProfiles = 0; |
44 | 46 | }
|
45 | 47 |
|
46 | 48 | function XRHandData() {
|
|
257 | 259 | this.viewerHitTestSource.cancel();
|
258 | 260 | this.viewerHitTestSource = null;
|
259 | 261 | }
|
| 262 | + |
| 263 | + this.xrData.controllerA.enabled = 0; |
| 264 | + this.xrData.controllerB.enabled = 0; |
| 265 | + this.xrData.handLeft.enabled = 0; |
| 266 | + this.xrData.handRight.enabled = 0; |
| 267 | + |
| 268 | + this.xrData.controllerA.frame = -1; |
| 269 | + this.xrData.controllerB.frame = -1; |
| 270 | + this.xrData.handLeft.frame = -1; |
| 271 | + this.xrData.handRight.frame = -1; |
| 272 | + |
| 273 | + document.dispatchEvent(new CustomEvent('XRControllersData', { detail: { |
| 274 | + controllerA: this.xrData.controllerA, |
| 275 | + controllerB: this.xrData.controllerB |
| 276 | + }})); |
| 277 | + |
| 278 | + document.dispatchEvent(new CustomEvent('XRHandsData', { detail: { |
| 279 | + handLeft: this.xrData.handLeft, |
| 280 | + handRight: this.xrData.handRight |
| 281 | + }})); |
260 | 282 |
|
261 | 283 | this.gameModule.WebXR.OnEndXR();
|
262 | 284 | this.didNotifyUnity = false;
|
|
534 | 556 |
|
535 | 557 | controller.enabled = 1;
|
536 | 558 | controller.hand = hand;
|
| 559 | + |
| 560 | + if (controller.updatedProfiles == 0) |
| 561 | + { |
| 562 | + controller.profiles = inputSource.profiles; |
| 563 | + controller.updatedProfiles = 1; |
| 564 | + } |
537 | 565 |
|
538 | 566 | controller.positionX = position.x;
|
539 | 567 | controller.positionY = position.y;
|
|
677 | 705 | session.addEventListener('squeeze', this.onInputEvent);
|
678 | 706 | session.addEventListener('squeezestart', this.onInputEvent);
|
679 | 707 | session.addEventListener('squeezeend', this.onInputEvent);
|
| 708 | + |
| 709 | + this.xrData.controllerA.updatedProfiles = 0; |
| 710 | + this.xrData.controllerB.updatedProfiles = 0; |
| 711 | + this.xrData.controllerA.profiles = []; |
| 712 | + this.xrData.controllerB.profiles = []; |
680 | 713 | }
|
681 | 714 |
|
682 | 715 | session.requestReferenceSpace(refSpaceType).then((refSpace) => {
|
|
754 | 787 | viewerHitTestPose: xrData.viewerHitTestPose
|
755 | 788 | }}));
|
756 | 789 | }
|
| 790 | + |
| 791 | + if (xrData.controllerA.updatedProfiles == 1 || xrData.controllerB.updatedProfiles == 1) |
| 792 | + { |
| 793 | + let inputProfiles = {}; |
| 794 | + inputProfiles.conrtoller1 = xrData.controllerA.profiles; |
| 795 | + inputProfiles.conrtoller2 = xrData.controllerB.profiles; |
| 796 | + if (xrData.controllerA.updatedProfiles == 1) |
| 797 | + { |
| 798 | + xrData.controllerA.updatedProfiles = 2; |
| 799 | + } |
| 800 | + if (xrData.controllerB.updatedProfiles == 1) |
| 801 | + { |
| 802 | + xrData.controllerB.updatedProfiles = 2; |
| 803 | + } |
| 804 | + this.gameModule.WebXR.OnInputProfiles(JSON.stringify(inputProfiles)); |
| 805 | + } |
757 | 806 |
|
758 | 807 | // Dispatch event with headset data to be handled in webxr.jslib
|
759 | 808 | document.dispatchEvent(new CustomEvent('XRData', { detail: {
|
|
0 commit comments