iwer 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/build/iwer.js +243 -200
- package/build/iwer.min.js +1 -1
- package/build/iwer.module.js +243 -200
- package/build/iwer.module.min.js +1 -1
- package/lib/device/XRController.d.ts +6 -1
- package/lib/device/XRController.d.ts.map +1 -1
- package/lib/device/XRController.js +16 -5
- package/lib/device/XRController.js.map +1 -1
- package/lib/device/XRDevice.d.ts +6 -1
- package/lib/device/XRDevice.d.ts.map +1 -1
- package/lib/device/XRDevice.js +15 -2
- package/lib/device/XRDevice.js.map +1 -1
- package/lib/device/configs/headset/meta.d.ts.map +1 -1
- package/lib/device/configs/headset/meta.js +4 -0
- package/lib/device/configs/headset/meta.js.map +1 -1
- package/lib/session/XRSession.d.ts.map +1 -1
- package/lib/session/XRSession.js +16 -1
- package/lib/session/XRSession.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
package/build/iwer.module.js
CHANGED
|
@@ -1281,11 +1281,11 @@ var normalize = normalize$1;
|
|
|
1281
1281
|
* This source code is licensed under the MIT license found in the
|
|
1282
1282
|
* LICENSE file in the root directory of this source tree.
|
|
1283
1283
|
*/
|
|
1284
|
-
const PRIVATE$
|
|
1284
|
+
const PRIVATE$l = Symbol('@immersive-web-emulation-runtime/xr-space');
|
|
1285
1285
|
class XRSpace extends EventTarget {
|
|
1286
1286
|
constructor(parentSpace, offsetMatrix) {
|
|
1287
1287
|
super();
|
|
1288
|
-
this[PRIVATE$
|
|
1288
|
+
this[PRIVATE$l] = {
|
|
1289
1289
|
parentSpace,
|
|
1290
1290
|
offsetMatrix: offsetMatrix ? clone(offsetMatrix) : create$3(),
|
|
1291
1291
|
emulated: true,
|
|
@@ -1300,27 +1300,27 @@ class GlobalSpace extends XRSpace {
|
|
|
1300
1300
|
class XRSpaceUtils {
|
|
1301
1301
|
// Update the position component of the offsetMatrix of a given XRSpace
|
|
1302
1302
|
static updateOffsetPosition(space, position) {
|
|
1303
|
-
const offsetMatrix = space[PRIVATE$
|
|
1303
|
+
const offsetMatrix = space[PRIVATE$l].offsetMatrix;
|
|
1304
1304
|
fromTranslation(offsetMatrix, position);
|
|
1305
1305
|
}
|
|
1306
1306
|
// Update the rotation component of the offsetMatrix of a given XRSpace using a quaternion
|
|
1307
1307
|
static updateOffsetQuaternion(space, quaternion) {
|
|
1308
|
-
const offsetMatrix = space[PRIVATE$
|
|
1308
|
+
const offsetMatrix = space[PRIVATE$l].offsetMatrix;
|
|
1309
1309
|
const translation = create$2();
|
|
1310
1310
|
getTranslation(translation, offsetMatrix);
|
|
1311
1311
|
fromRotationTranslation(offsetMatrix, quaternion, translation);
|
|
1312
1312
|
}
|
|
1313
1313
|
// Update the offsetMatrix of a given XRSpace directly
|
|
1314
1314
|
static updateOffsetMatrix(space, matrix) {
|
|
1315
|
-
const offsetMatrix = space[PRIVATE$
|
|
1315
|
+
const offsetMatrix = space[PRIVATE$l].offsetMatrix;
|
|
1316
1316
|
copy$3(offsetMatrix, matrix);
|
|
1317
1317
|
}
|
|
1318
1318
|
// Calculate the global offset matrix for a given XRSpace
|
|
1319
1319
|
static calculateGlobalOffsetMatrix(space, globalOffset = create$3()) {
|
|
1320
|
-
const parentOffset = space[PRIVATE$
|
|
1321
|
-
? XRSpaceUtils.calculateGlobalOffsetMatrix(space[PRIVATE$
|
|
1320
|
+
const parentOffset = space[PRIVATE$l].parentSpace
|
|
1321
|
+
? XRSpaceUtils.calculateGlobalOffsetMatrix(space[PRIVATE$l].parentSpace)
|
|
1322
1322
|
: create$3(); // Identity matrix for GlobalSpace
|
|
1323
|
-
multiply$1(globalOffset, parentOffset, space[PRIVATE$
|
|
1323
|
+
multiply$1(globalOffset, parentOffset, space[PRIVATE$l].offsetMatrix);
|
|
1324
1324
|
return globalOffset;
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
@@ -1464,7 +1464,7 @@ class Quaternion {
|
|
|
1464
1464
|
* This source code is licensed under the MIT license found in the
|
|
1465
1465
|
* LICENSE file in the root directory of this source tree.
|
|
1466
1466
|
*/
|
|
1467
|
-
const PRIVATE$
|
|
1467
|
+
const PRIVATE$k = Symbol('@immersive-web-emulation-runtime/gamepad');
|
|
1468
1468
|
var GamepadMappingType;
|
|
1469
1469
|
(function (GamepadMappingType) {
|
|
1470
1470
|
GamepadMappingType["None"] = "";
|
|
@@ -1473,7 +1473,7 @@ var GamepadMappingType;
|
|
|
1473
1473
|
})(GamepadMappingType || (GamepadMappingType = {}));
|
|
1474
1474
|
class GamepadButton {
|
|
1475
1475
|
constructor(type, eventTrigger) {
|
|
1476
|
-
this[PRIVATE$
|
|
1476
|
+
this[PRIVATE$k] = {
|
|
1477
1477
|
type,
|
|
1478
1478
|
eventTrigger,
|
|
1479
1479
|
pressed: false,
|
|
@@ -1484,23 +1484,23 @@ class GamepadButton {
|
|
|
1484
1484
|
};
|
|
1485
1485
|
}
|
|
1486
1486
|
get pressed() {
|
|
1487
|
-
if (this[PRIVATE$
|
|
1488
|
-
return this[PRIVATE$
|
|
1487
|
+
if (this[PRIVATE$k].type === 'manual') {
|
|
1488
|
+
return this[PRIVATE$k].pressed;
|
|
1489
1489
|
}
|
|
1490
1490
|
else {
|
|
1491
|
-
return this[PRIVATE$
|
|
1491
|
+
return this[PRIVATE$k].value > 0;
|
|
1492
1492
|
}
|
|
1493
1493
|
}
|
|
1494
1494
|
get touched() {
|
|
1495
|
-
if (this[PRIVATE$
|
|
1496
|
-
return this[PRIVATE$
|
|
1495
|
+
if (this[PRIVATE$k].type === 'manual') {
|
|
1496
|
+
return this[PRIVATE$k].touched;
|
|
1497
1497
|
}
|
|
1498
1498
|
else {
|
|
1499
|
-
return this[PRIVATE$
|
|
1499
|
+
return this[PRIVATE$k].touched || this.pressed;
|
|
1500
1500
|
}
|
|
1501
1501
|
}
|
|
1502
1502
|
get value() {
|
|
1503
|
-
return this[PRIVATE$
|
|
1503
|
+
return this[PRIVATE$k].value;
|
|
1504
1504
|
}
|
|
1505
1505
|
}
|
|
1506
1506
|
class EmptyGamepadButton {
|
|
@@ -1512,7 +1512,7 @@ class EmptyGamepadButton {
|
|
|
1512
1512
|
}
|
|
1513
1513
|
class Gamepad {
|
|
1514
1514
|
constructor(gamepadConfig, id = '', index = -1) {
|
|
1515
|
-
this[PRIVATE$
|
|
1515
|
+
this[PRIVATE$k] = {
|
|
1516
1516
|
id,
|
|
1517
1517
|
index,
|
|
1518
1518
|
connected: false,
|
|
@@ -1527,43 +1527,43 @@ class Gamepad {
|
|
|
1527
1527
|
gamepadConfig.buttons.forEach((buttonConfig) => {
|
|
1528
1528
|
var _a;
|
|
1529
1529
|
if (buttonConfig === null) {
|
|
1530
|
-
this[PRIVATE$
|
|
1530
|
+
this[PRIVATE$k].buttonsSequence.push(null);
|
|
1531
1531
|
}
|
|
1532
1532
|
else {
|
|
1533
|
-
this[PRIVATE$
|
|
1534
|
-
this[PRIVATE$
|
|
1533
|
+
this[PRIVATE$k].buttonsSequence.push(buttonConfig.id);
|
|
1534
|
+
this[PRIVATE$k].buttonsMap[buttonConfig.id] = new GamepadButton(buttonConfig.type, (_a = buttonConfig.eventTrigger) !== null && _a !== void 0 ? _a : null);
|
|
1535
1535
|
}
|
|
1536
1536
|
});
|
|
1537
1537
|
gamepadConfig.axes.forEach((axisConfig) => {
|
|
1538
1538
|
if (axisConfig === null) {
|
|
1539
|
-
this[PRIVATE$
|
|
1539
|
+
this[PRIVATE$k].axesSequence.push(null);
|
|
1540
1540
|
}
|
|
1541
1541
|
else {
|
|
1542
|
-
this[PRIVATE$
|
|
1543
|
-
if (!this[PRIVATE$
|
|
1544
|
-
this[PRIVATE$
|
|
1542
|
+
this[PRIVATE$k].axesSequence.push(axisConfig.id + axisConfig.type);
|
|
1543
|
+
if (!this[PRIVATE$k].axesMap[axisConfig.id]) {
|
|
1544
|
+
this[PRIVATE$k].axesMap[axisConfig.id] = { x: 0, y: 0 };
|
|
1545
1545
|
}
|
|
1546
1546
|
}
|
|
1547
1547
|
});
|
|
1548
1548
|
}
|
|
1549
1549
|
get id() {
|
|
1550
|
-
return this[PRIVATE$
|
|
1550
|
+
return this[PRIVATE$k].id;
|
|
1551
1551
|
}
|
|
1552
1552
|
get index() {
|
|
1553
|
-
return this[PRIVATE$
|
|
1553
|
+
return this[PRIVATE$k].index;
|
|
1554
1554
|
}
|
|
1555
1555
|
get connected() {
|
|
1556
|
-
return this[PRIVATE$
|
|
1556
|
+
return this[PRIVATE$k].connected;
|
|
1557
1557
|
}
|
|
1558
1558
|
get timestamp() {
|
|
1559
|
-
return this[PRIVATE$
|
|
1559
|
+
return this[PRIVATE$k].timestamp;
|
|
1560
1560
|
}
|
|
1561
1561
|
get mapping() {
|
|
1562
|
-
return this[PRIVATE$
|
|
1562
|
+
return this[PRIVATE$k].mapping;
|
|
1563
1563
|
}
|
|
1564
1564
|
get axes() {
|
|
1565
1565
|
const axes = [];
|
|
1566
|
-
this[PRIVATE$
|
|
1566
|
+
this[PRIVATE$k].axesSequence.forEach((id) => {
|
|
1567
1567
|
if (id === null) {
|
|
1568
1568
|
axes.push(null);
|
|
1569
1569
|
}
|
|
@@ -1573,17 +1573,17 @@ class Gamepad {
|
|
|
1573
1573
|
axes.push(
|
|
1574
1574
|
// if axis type is manual, then return the x value
|
|
1575
1575
|
axisType === 'y-axis'
|
|
1576
|
-
? this[PRIVATE$
|
|
1577
|
-
: this[PRIVATE$
|
|
1576
|
+
? this[PRIVATE$k].axesMap[axisId].y
|
|
1577
|
+
: this[PRIVATE$k].axesMap[axisId].x);
|
|
1578
1578
|
}
|
|
1579
1579
|
});
|
|
1580
1580
|
return axes;
|
|
1581
1581
|
}
|
|
1582
1582
|
get buttons() {
|
|
1583
|
-
return this[PRIVATE$
|
|
1583
|
+
return this[PRIVATE$k].buttonsSequence.map((id) => id === null ? new EmptyGamepadButton() : this[PRIVATE$k].buttonsMap[id]);
|
|
1584
1584
|
}
|
|
1585
1585
|
get hapticActuators() {
|
|
1586
|
-
return this[PRIVATE$
|
|
1586
|
+
return this[PRIVATE$k].hapticActuators;
|
|
1587
1587
|
}
|
|
1588
1588
|
get vibrationActuator() {
|
|
1589
1589
|
return null;
|
|
@@ -1611,10 +1611,10 @@ var XRTargetRayMode;
|
|
|
1611
1611
|
})(XRTargetRayMode || (XRTargetRayMode = {}));
|
|
1612
1612
|
class XRInputSourceArray extends Array {
|
|
1613
1613
|
}
|
|
1614
|
-
const PRIVATE$
|
|
1614
|
+
const PRIVATE$j = Symbol('@immersive-web-emulation-runtime/xr-input-source');
|
|
1615
1615
|
class XRInputSource {
|
|
1616
1616
|
constructor(handedness, targetRayMode, profiles, targetRaySpace, gamepad, gripSpace, hand) {
|
|
1617
|
-
this[PRIVATE$
|
|
1617
|
+
this[PRIVATE$j] = {
|
|
1618
1618
|
handedness,
|
|
1619
1619
|
targetRayMode,
|
|
1620
1620
|
targetRaySpace,
|
|
@@ -1625,25 +1625,25 @@ class XRInputSource {
|
|
|
1625
1625
|
};
|
|
1626
1626
|
}
|
|
1627
1627
|
get handedness() {
|
|
1628
|
-
return this[PRIVATE$
|
|
1628
|
+
return this[PRIVATE$j].handedness;
|
|
1629
1629
|
}
|
|
1630
1630
|
get targetRayMode() {
|
|
1631
|
-
return this[PRIVATE$
|
|
1631
|
+
return this[PRIVATE$j].targetRayMode;
|
|
1632
1632
|
}
|
|
1633
1633
|
get targetRaySpace() {
|
|
1634
|
-
return this[PRIVATE$
|
|
1634
|
+
return this[PRIVATE$j].targetRaySpace;
|
|
1635
1635
|
}
|
|
1636
1636
|
get gripSpace() {
|
|
1637
|
-
return this[PRIVATE$
|
|
1637
|
+
return this[PRIVATE$j].gripSpace;
|
|
1638
1638
|
}
|
|
1639
1639
|
get profiles() {
|
|
1640
|
-
return this[PRIVATE$
|
|
1640
|
+
return this[PRIVATE$j].profiles;
|
|
1641
1641
|
}
|
|
1642
1642
|
get gamepad() {
|
|
1643
|
-
return this[PRIVATE$
|
|
1643
|
+
return this[PRIVATE$j].gamepad;
|
|
1644
1644
|
}
|
|
1645
1645
|
get hand() {
|
|
1646
|
-
return this[PRIVATE$
|
|
1646
|
+
return this[PRIVATE$j].hand;
|
|
1647
1647
|
}
|
|
1648
1648
|
}
|
|
1649
1649
|
|
|
@@ -1673,7 +1673,7 @@ class XRInputSourceEvent extends Event {
|
|
|
1673
1673
|
* This source code is licensed under the MIT license found in the
|
|
1674
1674
|
* LICENSE file in the root directory of this source tree.
|
|
1675
1675
|
*/
|
|
1676
|
-
const PRIVATE$
|
|
1676
|
+
const PRIVATE$i = Symbol('@immersive-web-emulation-runtime/xr-tracked-input');
|
|
1677
1677
|
const DEFAULT_TRANSFORM = {
|
|
1678
1678
|
[XRHandedness.Left]: {
|
|
1679
1679
|
position: new Vector3(-0.25, 1.5, -0.4),
|
|
@@ -1690,7 +1690,7 @@ const DEFAULT_TRANSFORM = {
|
|
|
1690
1690
|
};
|
|
1691
1691
|
class XRTrackedInput {
|
|
1692
1692
|
constructor(inputSource) {
|
|
1693
|
-
this[PRIVATE$
|
|
1693
|
+
this[PRIVATE$i] = {
|
|
1694
1694
|
inputSource,
|
|
1695
1695
|
position: DEFAULT_TRANSFORM[inputSource.handedness].position.clone(),
|
|
1696
1696
|
quaternion: DEFAULT_TRANSFORM[inputSource.handedness].quaternion.clone(),
|
|
@@ -1700,59 +1700,59 @@ class XRTrackedInput {
|
|
|
1700
1700
|
};
|
|
1701
1701
|
}
|
|
1702
1702
|
get position() {
|
|
1703
|
-
return this[PRIVATE$
|
|
1703
|
+
return this[PRIVATE$i].position;
|
|
1704
1704
|
}
|
|
1705
1705
|
get quaternion() {
|
|
1706
|
-
return this[PRIVATE$
|
|
1706
|
+
return this[PRIVATE$i].quaternion;
|
|
1707
1707
|
}
|
|
1708
1708
|
get inputSource() {
|
|
1709
|
-
return this[PRIVATE$
|
|
1709
|
+
return this[PRIVATE$i].inputSource;
|
|
1710
1710
|
}
|
|
1711
1711
|
get connected() {
|
|
1712
|
-
return this[PRIVATE$
|
|
1712
|
+
return this[PRIVATE$i].connected;
|
|
1713
1713
|
}
|
|
1714
1714
|
set connected(value) {
|
|
1715
|
-
this[PRIVATE$
|
|
1716
|
-
this[PRIVATE$
|
|
1715
|
+
this[PRIVATE$i].connected = value;
|
|
1716
|
+
this[PRIVATE$i].inputSource.gamepad[PRIVATE$k].connected = value;
|
|
1717
1717
|
}
|
|
1718
1718
|
onFrameStart(frame) {
|
|
1719
|
-
const targetRaySpace = this[PRIVATE$
|
|
1720
|
-
fromRotationTranslation(targetRaySpace[PRIVATE$
|
|
1719
|
+
const targetRaySpace = this[PRIVATE$i].inputSource.targetRaySpace;
|
|
1720
|
+
fromRotationTranslation(targetRaySpace[PRIVATE$l].offsetMatrix, this[PRIVATE$i].quaternion.quat, this[PRIVATE$i].position.vec3);
|
|
1721
1721
|
const session = frame.session;
|
|
1722
|
-
this[PRIVATE$
|
|
1722
|
+
this[PRIVATE$i].inputSource.gamepad.buttons.forEach((button) => {
|
|
1723
1723
|
if (button instanceof GamepadButton) {
|
|
1724
1724
|
// apply pending values and record last frame values
|
|
1725
|
-
button[PRIVATE$
|
|
1726
|
-
if (button[PRIVATE$
|
|
1727
|
-
button[PRIVATE$
|
|
1728
|
-
button[PRIVATE$
|
|
1725
|
+
button[PRIVATE$k].lastFrameValue = button[PRIVATE$k].value;
|
|
1726
|
+
if (button[PRIVATE$k].pendingValue != null) {
|
|
1727
|
+
button[PRIVATE$k].value = button[PRIVATE$k].pendingValue;
|
|
1728
|
+
button[PRIVATE$k].pendingValue = null;
|
|
1729
1729
|
}
|
|
1730
1730
|
// trigger input source events
|
|
1731
|
-
if (button[PRIVATE$
|
|
1732
|
-
if (button[PRIVATE$
|
|
1733
|
-
button[PRIVATE$
|
|
1734
|
-
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$
|
|
1731
|
+
if (button[PRIVATE$k].eventTrigger != null) {
|
|
1732
|
+
if (button[PRIVATE$k].lastFrameValue === 0 &&
|
|
1733
|
+
button[PRIVATE$k].value > 0) {
|
|
1734
|
+
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$k].eventTrigger, {
|
|
1735
1735
|
frame,
|
|
1736
|
-
inputSource: this[PRIVATE$
|
|
1736
|
+
inputSource: this[PRIVATE$i].inputSource,
|
|
1737
1737
|
}));
|
|
1738
|
-
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$
|
|
1738
|
+
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$k].eventTrigger + 'start', {
|
|
1739
1739
|
frame,
|
|
1740
|
-
inputSource: this[PRIVATE$
|
|
1740
|
+
inputSource: this[PRIVATE$i].inputSource,
|
|
1741
1741
|
}));
|
|
1742
1742
|
}
|
|
1743
|
-
else if (button[PRIVATE$
|
|
1744
|
-
button[PRIVATE$
|
|
1745
|
-
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$
|
|
1743
|
+
else if (button[PRIVATE$k].lastFrameValue > 0 &&
|
|
1744
|
+
button[PRIVATE$k].value === 0) {
|
|
1745
|
+
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$k].eventTrigger + 'end', {
|
|
1746
1746
|
frame,
|
|
1747
|
-
inputSource: this[PRIVATE$
|
|
1747
|
+
inputSource: this[PRIVATE$i].inputSource,
|
|
1748
1748
|
}));
|
|
1749
1749
|
}
|
|
1750
1750
|
}
|
|
1751
1751
|
}
|
|
1752
1752
|
});
|
|
1753
|
-
this[PRIVATE$
|
|
1754
|
-
this.connected !== this[PRIVATE$
|
|
1755
|
-
this[PRIVATE$
|
|
1753
|
+
this[PRIVATE$i].inputSourceChanged =
|
|
1754
|
+
this.connected !== this[PRIVATE$i].lastFrameConnected;
|
|
1755
|
+
this[PRIVATE$i].lastFrameConnected = this.connected;
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
1758
|
|
|
@@ -1762,6 +1762,7 @@ class XRTrackedInput {
|
|
|
1762
1762
|
* This source code is licensed under the MIT license found in the
|
|
1763
1763
|
* LICENSE file in the root directory of this source tree.
|
|
1764
1764
|
*/
|
|
1765
|
+
const PRIVATE$h = Symbol('@immersive-web-emulation-runtime/xr-controller');
|
|
1765
1766
|
class XRController extends XRTrackedInput {
|
|
1766
1767
|
constructor(controllerConfig, handedness, globalSpace) {
|
|
1767
1768
|
if (!controllerConfig.layout[handedness]) {
|
|
@@ -1777,30 +1778,38 @@ class XRController extends XRTrackedInput {
|
|
|
1777
1778
|
];
|
|
1778
1779
|
const inputSource = new XRInputSource(handedness, XRTargetRayMode.TrackedPointer, profiles, targetRaySpace, new Gamepad(controllerConfig.layout[handedness].gamepad), gripSpace);
|
|
1779
1780
|
super(inputSource);
|
|
1781
|
+
this[PRIVATE$h] = {
|
|
1782
|
+
gamepadConfig: controllerConfig.layout[handedness].gamepad,
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
get gamepadConfig() {
|
|
1786
|
+
return this[PRIVATE$h].gamepadConfig;
|
|
1780
1787
|
}
|
|
1781
1788
|
updateButtonValue(id, value) {
|
|
1782
1789
|
if (value > 1 || value < 0) {
|
|
1783
1790
|
console.warn(`Out-of-range value ${value} provided for button ${id}.`);
|
|
1784
1791
|
return;
|
|
1785
1792
|
}
|
|
1786
|
-
const gamepadButton = this[PRIVATE$
|
|
1793
|
+
const gamepadButton = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1794
|
+
.buttonsMap[id];
|
|
1787
1795
|
if (gamepadButton) {
|
|
1788
|
-
if (gamepadButton[PRIVATE$
|
|
1796
|
+
if (gamepadButton[PRIVATE$k].type === 'binary' &&
|
|
1789
1797
|
value != 1 &&
|
|
1790
1798
|
value != 0) {
|
|
1791
1799
|
console.warn(`Non-binary value ${value} provided for binary button ${id}.`);
|
|
1792
1800
|
return;
|
|
1793
1801
|
}
|
|
1794
|
-
gamepadButton[PRIVATE$
|
|
1802
|
+
gamepadButton[PRIVATE$k].pendingValue = value;
|
|
1795
1803
|
}
|
|
1796
1804
|
else {
|
|
1797
1805
|
console.warn(`Current controller does not have button ${id}.`);
|
|
1798
1806
|
}
|
|
1799
1807
|
}
|
|
1800
1808
|
updateButtonTouch(id, touched) {
|
|
1801
|
-
const gamepadButton = this[PRIVATE$
|
|
1809
|
+
const gamepadButton = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1810
|
+
.buttonsMap[id];
|
|
1802
1811
|
if (gamepadButton) {
|
|
1803
|
-
gamepadButton[PRIVATE$
|
|
1812
|
+
gamepadButton[PRIVATE$k].touched = touched;
|
|
1804
1813
|
}
|
|
1805
1814
|
else {
|
|
1806
1815
|
console.warn(`Current controller does not have button ${id}.`);
|
|
@@ -1811,7 +1820,8 @@ class XRController extends XRTrackedInput {
|
|
|
1811
1820
|
console.warn(`Out-of-range value ${value} provided for ${id} axes.`);
|
|
1812
1821
|
return;
|
|
1813
1822
|
}
|
|
1814
|
-
const axesById = this[PRIVATE$
|
|
1823
|
+
const axesById = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1824
|
+
.axesMap[id];
|
|
1815
1825
|
if (axesById) {
|
|
1816
1826
|
if (type === 'x-axis') {
|
|
1817
1827
|
axesById.x = value;
|
|
@@ -1829,7 +1839,8 @@ class XRController extends XRTrackedInput {
|
|
|
1829
1839
|
console.warn(`Out-of-range value x:${x}, y:${y} provided for ${id} axes.`);
|
|
1830
1840
|
return;
|
|
1831
1841
|
}
|
|
1832
|
-
const axesById = this[PRIVATE$
|
|
1842
|
+
const axesById = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1843
|
+
.axesMap[id];
|
|
1833
1844
|
if (axesById) {
|
|
1834
1845
|
axesById.x = x;
|
|
1835
1846
|
axesById.y = y;
|
|
@@ -2764,20 +2775,20 @@ class XRHandInput extends XRTrackedInput {
|
|
|
2764
2775
|
const targetJointMatrix = targetPose.jointTransforms[jointName].offsetMatrix;
|
|
2765
2776
|
const pinchJointMatrix = pinchPose.jointTransforms[jointName].offsetMatrix;
|
|
2766
2777
|
const jointSpace = this.inputSource.hand.get(jointName);
|
|
2767
|
-
interpolateMatrix(jointSpace[PRIVATE$
|
|
2778
|
+
interpolateMatrix(jointSpace[PRIVATE$l].offsetMatrix, targetJointMatrix, pinchJointMatrix, this.pinchValue);
|
|
2768
2779
|
if (this.inputSource.handedness === XRHandedness.Right) {
|
|
2769
|
-
mirrorMatrixToRight(jointSpace[PRIVATE$
|
|
2780
|
+
mirrorMatrixToRight(jointSpace[PRIVATE$l].offsetMatrix);
|
|
2770
2781
|
}
|
|
2771
2782
|
jointSpace[PRIVATE$f].radius =
|
|
2772
2783
|
(1 - this.pinchValue) * targetPose.jointTransforms[jointName].radius +
|
|
2773
2784
|
this.pinchValue * pinchPose.jointTransforms[jointName].radius;
|
|
2774
2785
|
});
|
|
2775
2786
|
if (targetPose.gripOffsetMatrix && pinchPose.gripOffsetMatrix) {
|
|
2776
|
-
interpolateMatrix(this.inputSource.gripSpace[PRIVATE$
|
|
2787
|
+
interpolateMatrix(this.inputSource.gripSpace[PRIVATE$l].offsetMatrix, targetPose.gripOffsetMatrix, pinchPose.gripOffsetMatrix, this.pinchValue);
|
|
2777
2788
|
}
|
|
2778
2789
|
}
|
|
2779
2790
|
get pinchValue() {
|
|
2780
|
-
return this[PRIVATE$
|
|
2791
|
+
return this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
2781
2792
|
.buttonsMap['pinch'].value;
|
|
2782
2793
|
}
|
|
2783
2794
|
updatePinchValue(value) {
|
|
@@ -2785,9 +2796,9 @@ class XRHandInput extends XRTrackedInput {
|
|
|
2785
2796
|
console.warn(`Out-of-range value ${value} provided for pinch`);
|
|
2786
2797
|
return;
|
|
2787
2798
|
}
|
|
2788
|
-
const gamepadButton = this[PRIVATE$
|
|
2799
|
+
const gamepadButton = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
2789
2800
|
.buttonsMap['pinch'];
|
|
2790
|
-
gamepadButton[PRIVATE$
|
|
2801
|
+
gamepadButton[PRIVATE$k].pendingValue = value;
|
|
2791
2802
|
}
|
|
2792
2803
|
onFrameStart(frame) {
|
|
2793
2804
|
super.onFrameStart(frame);
|
|
@@ -2998,7 +3009,7 @@ class XRFrame {
|
|
|
2998
3009
|
y: orientation[1],
|
|
2999
3010
|
z: orientation[2],
|
|
3000
3011
|
w: orientation[3],
|
|
3001
|
-
}), space[PRIVATE$
|
|
3012
|
+
}), space[PRIVATE$l].emulated);
|
|
3002
3013
|
}
|
|
3003
3014
|
getViewerPose(referenceSpace) {
|
|
3004
3015
|
if (!this[PRIVATE$9].animationFrame) {
|
|
@@ -3399,6 +3410,7 @@ class XRSession extends EventTarget {
|
|
|
3399
3410
|
return this[PRIVATE$6].isSystemKeyboardSupported;
|
|
3400
3411
|
}
|
|
3401
3412
|
updateRenderState(state = {}) {
|
|
3413
|
+
var _a, _b, _c, _d;
|
|
3402
3414
|
if (this[PRIVATE$6].ended) {
|
|
3403
3415
|
throw new DOMException('XRSession has already ended.', 'InvalidStateError');
|
|
3404
3416
|
}
|
|
@@ -3410,7 +3422,21 @@ class XRSession extends EventTarget {
|
|
|
3410
3422
|
this[PRIVATE$6].mode !== XRSessionMode.Inline) {
|
|
3411
3423
|
throw new DOMException('InlineVerticalFieldOfView must not be set for an immersive session', 'InvalidStateError');
|
|
3412
3424
|
}
|
|
3413
|
-
|
|
3425
|
+
const compoundStateInit = {
|
|
3426
|
+
baseLayer: state.baseLayer ||
|
|
3427
|
+
((_a = this[PRIVATE$6].pendingRenderState) === null || _a === void 0 ? void 0 : _a.baseLayer) ||
|
|
3428
|
+
undefined,
|
|
3429
|
+
depthFar: state.depthFar ||
|
|
3430
|
+
((_b = this[PRIVATE$6].pendingRenderState) === null || _b === void 0 ? void 0 : _b.depthFar) ||
|
|
3431
|
+
undefined,
|
|
3432
|
+
depthNear: state.depthNear ||
|
|
3433
|
+
((_c = this[PRIVATE$6].pendingRenderState) === null || _c === void 0 ? void 0 : _c.depthNear) ||
|
|
3434
|
+
undefined,
|
|
3435
|
+
inlineVerticalFieldOfView: state.inlineVerticalFieldOfView ||
|
|
3436
|
+
((_d = this[PRIVATE$6].pendingRenderState) === null || _d === void 0 ? void 0 : _d.inlineVerticalFieldOfView) ||
|
|
3437
|
+
undefined,
|
|
3438
|
+
};
|
|
3439
|
+
this[PRIVATE$6].pendingRenderState = new XRRenderState(compoundStateInit, this[PRIVATE$6].renderState);
|
|
3414
3440
|
}
|
|
3415
3441
|
// the nominal frame rate updates are emulated, no actual update to the
|
|
3416
3442
|
// display frame rate of the device will be executed
|
|
@@ -3449,7 +3475,7 @@ class XRSession extends EventTarget {
|
|
|
3449
3475
|
break;
|
|
3450
3476
|
case XRReferenceSpaceType.Local:
|
|
3451
3477
|
// creating an XRReferenceSpace with the current headset transform in global space
|
|
3452
|
-
referenceSpace = new XRReferenceSpace(type, this[PRIVATE$6].device[PRIVATE$1].globalSpace, this[PRIVATE$6].device.viewerSpace[PRIVATE$
|
|
3478
|
+
referenceSpace = new XRReferenceSpace(type, this[PRIVATE$6].device[PRIVATE$1].globalSpace, this[PRIVATE$6].device.viewerSpace[PRIVATE$l].offsetMatrix);
|
|
3453
3479
|
break;
|
|
3454
3480
|
case XRReferenceSpaceType.LocalFloor:
|
|
3455
3481
|
case XRReferenceSpaceType.BoundedFloor:
|
|
@@ -3715,7 +3741,76 @@ class XRWebGLLayer extends XRLayer {
|
|
|
3715
3741
|
* This source code is licensed under the MIT license found in the
|
|
3716
3742
|
* LICENSE file in the root directory of this source tree.
|
|
3717
3743
|
*/
|
|
3718
|
-
const PRIVATE$4 = Symbol('@immersive-web-emulation-runtime/
|
|
3744
|
+
const PRIVATE$4 = Symbol('@immersive-web-emulation-runtime/xr-system');
|
|
3745
|
+
class XRSystem extends EventTarget {
|
|
3746
|
+
constructor(device) {
|
|
3747
|
+
super();
|
|
3748
|
+
this[PRIVATE$4] = { device };
|
|
3749
|
+
// Initialize device change monitoring here if applicable
|
|
3750
|
+
}
|
|
3751
|
+
isSessionSupported(mode) {
|
|
3752
|
+
return new Promise((resolve, _reject) => {
|
|
3753
|
+
if (mode === XRSessionMode.Inline) {
|
|
3754
|
+
resolve(true);
|
|
3755
|
+
}
|
|
3756
|
+
else {
|
|
3757
|
+
// Check for spatial tracking permission if necessary
|
|
3758
|
+
resolve(this[PRIVATE$4].device.supportedSessionModes.includes(mode));
|
|
3759
|
+
}
|
|
3760
|
+
});
|
|
3761
|
+
}
|
|
3762
|
+
requestSession(mode, options = {}) {
|
|
3763
|
+
return new Promise((resolve, reject) => {
|
|
3764
|
+
this.isSessionSupported(mode)
|
|
3765
|
+
.then((isSupported) => {
|
|
3766
|
+
if (!isSupported) {
|
|
3767
|
+
reject(new DOMException('The requested XRSession mode is not supported.', 'NotSupportedError'));
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
// Check for active sessions and other constraints here
|
|
3771
|
+
if (this[PRIVATE$4].activeSession) {
|
|
3772
|
+
reject(new DOMException('An active XRSession already exists.', 'InvalidStateError'));
|
|
3773
|
+
return;
|
|
3774
|
+
}
|
|
3775
|
+
// Handle required and optional features
|
|
3776
|
+
const { requiredFeatures = [], optionalFeatures = [] } = options;
|
|
3777
|
+
const { supportedFeatures } = this[PRIVATE$4].device;
|
|
3778
|
+
// Check if all required features are supported
|
|
3779
|
+
const allRequiredSupported = requiredFeatures.every((feature) => supportedFeatures.includes(feature));
|
|
3780
|
+
if (!allRequiredSupported) {
|
|
3781
|
+
reject(new Error('One or more required features are not supported by the device.'));
|
|
3782
|
+
return;
|
|
3783
|
+
}
|
|
3784
|
+
// Filter out unsupported optional features
|
|
3785
|
+
const supportedOptionalFeatures = optionalFeatures.filter((feature) => supportedFeatures.includes(feature));
|
|
3786
|
+
// Combine required and supported optional features into enabled features
|
|
3787
|
+
const enabledFeatures = Array.from(new Set([
|
|
3788
|
+
...requiredFeatures,
|
|
3789
|
+
...supportedOptionalFeatures,
|
|
3790
|
+
WebXRFeatures.Viewer,
|
|
3791
|
+
WebXRFeatures.Local,
|
|
3792
|
+
]));
|
|
3793
|
+
// Proceed with session creation
|
|
3794
|
+
const session = new XRSession(this[PRIVATE$4].device, mode, enabledFeatures);
|
|
3795
|
+
this[PRIVATE$4].activeSession = session;
|
|
3796
|
+
// Listen for session end to clear the active session
|
|
3797
|
+
session.addEventListener('end', () => {
|
|
3798
|
+
this[PRIVATE$4].activeSession = undefined;
|
|
3799
|
+
});
|
|
3800
|
+
resolve(session);
|
|
3801
|
+
})
|
|
3802
|
+
.catch(reject);
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3805
|
+
}
|
|
3806
|
+
|
|
3807
|
+
/**
|
|
3808
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3809
|
+
*
|
|
3810
|
+
* This source code is licensed under the MIT license found in the
|
|
3811
|
+
* LICENSE file in the root directory of this source tree.
|
|
3812
|
+
*/
|
|
3813
|
+
const PRIVATE$3 = Symbol('@immersive-web-emulation-runtime/action-player');
|
|
3719
3814
|
class ActionPlayer {
|
|
3720
3815
|
constructor(refSpace, recording, ipd) {
|
|
3721
3816
|
const { schema, frames } = recording;
|
|
@@ -3728,7 +3823,7 @@ class ActionPlayer {
|
|
|
3728
3823
|
[XREye.Right]: new XRSpace(viewerSpace),
|
|
3729
3824
|
[XREye.None]: new XRSpace(viewerSpace),
|
|
3730
3825
|
};
|
|
3731
|
-
this[PRIVATE$
|
|
3826
|
+
this[PRIVATE$3] = {
|
|
3732
3827
|
refSpace,
|
|
3733
3828
|
inputSources: new Map(),
|
|
3734
3829
|
inputSchemas: new Map(),
|
|
@@ -3743,8 +3838,8 @@ class ActionPlayer {
|
|
|
3743
3838
|
vec3: create$2(),
|
|
3744
3839
|
quat: create(),
|
|
3745
3840
|
};
|
|
3746
|
-
fromTranslation(this[PRIVATE$
|
|
3747
|
-
fromTranslation(this[PRIVATE$
|
|
3841
|
+
fromTranslation(this[PRIVATE$3].viewSpaces[XREye.Left][PRIVATE$l].offsetMatrix, fromValues$2(-ipd / 2, 0, 0));
|
|
3842
|
+
fromTranslation(this[PRIVATE$3].viewSpaces[XREye.Right][PRIVATE$l].offsetMatrix, fromValues$2(ipd / 2, 0, 0));
|
|
3748
3843
|
schema.forEach((schemaEntry) => {
|
|
3749
3844
|
const index = schemaEntry[0];
|
|
3750
3845
|
const schema = schemaEntry[1];
|
|
@@ -3773,53 +3868,53 @@ class ActionPlayer {
|
|
|
3773
3868
|
});
|
|
3774
3869
|
}
|
|
3775
3870
|
const inputSource = new XRInputSource(schema.handedness, schema.targetRayMode, schema.profiles, targetRaySpace, gamepad, schema.hasGrip ? new XRSpace(refSpace) : undefined, schema.hasHand ? hand : undefined);
|
|
3776
|
-
this[PRIVATE$
|
|
3871
|
+
this[PRIVATE$3].inputSources.set(index, {
|
|
3777
3872
|
active: false,
|
|
3778
3873
|
source: inputSource,
|
|
3779
3874
|
});
|
|
3780
|
-
this[PRIVATE$
|
|
3875
|
+
this[PRIVATE$3].inputSchemas.set(index, schema);
|
|
3781
3876
|
});
|
|
3782
3877
|
}
|
|
3783
3878
|
play() {
|
|
3784
|
-
this[PRIVATE$
|
|
3785
|
-
this[PRIVATE$
|
|
3786
|
-
this[PRIVATE$
|
|
3787
|
-
this[PRIVATE$
|
|
3879
|
+
this[PRIVATE$3].recordedFramePointer = 0;
|
|
3880
|
+
this[PRIVATE$3].playbackTime = this[PRIVATE$3].startingTimeStamp;
|
|
3881
|
+
this[PRIVATE$3].playing = true;
|
|
3882
|
+
this[PRIVATE$3].actualTimeStamp = performance.now();
|
|
3788
3883
|
}
|
|
3789
3884
|
stop() {
|
|
3790
|
-
this[PRIVATE$
|
|
3885
|
+
this[PRIVATE$3].playing = false;
|
|
3791
3886
|
}
|
|
3792
3887
|
get playing() {
|
|
3793
|
-
return this[PRIVATE$
|
|
3888
|
+
return this[PRIVATE$3].playing;
|
|
3794
3889
|
}
|
|
3795
3890
|
get viewerSpace() {
|
|
3796
|
-
return this[PRIVATE$
|
|
3891
|
+
return this[PRIVATE$3].viewerSpace;
|
|
3797
3892
|
}
|
|
3798
3893
|
get viewSpaces() {
|
|
3799
|
-
return this[PRIVATE$
|
|
3894
|
+
return this[PRIVATE$3].viewSpaces;
|
|
3800
3895
|
}
|
|
3801
3896
|
get inputSources() {
|
|
3802
|
-
return Array.from(this[PRIVATE$
|
|
3897
|
+
return Array.from(this[PRIVATE$3].inputSources.values())
|
|
3803
3898
|
.filter((wrapper) => wrapper.active)
|
|
3804
3899
|
.map((wrapper) => wrapper.source);
|
|
3805
3900
|
}
|
|
3806
3901
|
playFrame() {
|
|
3807
3902
|
const now = performance.now();
|
|
3808
|
-
const delta = now - this[PRIVATE$
|
|
3809
|
-
this[PRIVATE$
|
|
3810
|
-
this[PRIVATE$
|
|
3811
|
-
if (this[PRIVATE$
|
|
3903
|
+
const delta = now - this[PRIVATE$3].actualTimeStamp;
|
|
3904
|
+
this[PRIVATE$3].actualTimeStamp = now;
|
|
3905
|
+
this[PRIVATE$3].playbackTime += delta;
|
|
3906
|
+
if (this[PRIVATE$3].playbackTime > this[PRIVATE$3].endingTimeStamp) {
|
|
3812
3907
|
this.stop();
|
|
3813
3908
|
return;
|
|
3814
3909
|
}
|
|
3815
|
-
while (this[PRIVATE$
|
|
3816
|
-
this[PRIVATE$
|
|
3910
|
+
while (this[PRIVATE$3].frames[this[PRIVATE$3].recordedFramePointer + 1][0] < this[PRIVATE$3].playbackTime) {
|
|
3911
|
+
this[PRIVATE$3].recordedFramePointer++;
|
|
3817
3912
|
}
|
|
3818
|
-
const lastFrameData = this[PRIVATE$
|
|
3819
|
-
const nextFrameData = this[PRIVATE$
|
|
3820
|
-
const alpha = (this[PRIVATE$
|
|
3913
|
+
const lastFrameData = this[PRIVATE$3].frames[this[PRIVATE$3].recordedFramePointer];
|
|
3914
|
+
const nextFrameData = this[PRIVATE$3].frames[this[PRIVATE$3].recordedFramePointer + 1];
|
|
3915
|
+
const alpha = (this[PRIVATE$3].playbackTime - lastFrameData[0]) /
|
|
3821
3916
|
(nextFrameData[0] - lastFrameData[0]);
|
|
3822
|
-
this.updateXRSpaceFromMergedFrames(this[PRIVATE$
|
|
3917
|
+
this.updateXRSpaceFromMergedFrames(this[PRIVATE$3].viewerSpace, lastFrameData.slice(1, 8), nextFrameData.slice(1, 8), alpha);
|
|
3823
3918
|
const lastFrameInputs = new Map();
|
|
3824
3919
|
for (let i = 8; i < lastFrameData.length; i++) {
|
|
3825
3920
|
const { index, inputData } = this.processRawInputData(lastFrameData[i]);
|
|
@@ -3830,13 +3925,13 @@ class ActionPlayer {
|
|
|
3830
3925
|
const { index, inputData } = this.processRawInputData(nextFrameData[i]);
|
|
3831
3926
|
nextFrameInputs.set(index, inputData);
|
|
3832
3927
|
}
|
|
3833
|
-
this[PRIVATE$
|
|
3928
|
+
this[PRIVATE$3].inputSources.forEach((sourceWrapper) => {
|
|
3834
3929
|
sourceWrapper.active = false;
|
|
3835
3930
|
});
|
|
3836
3931
|
nextFrameInputs.forEach((inputData, index) => {
|
|
3837
|
-
this[PRIVATE$
|
|
3838
|
-
const inputSource = this[PRIVATE$
|
|
3839
|
-
const schema = this[PRIVATE$
|
|
3932
|
+
this[PRIVATE$3].inputSources.get(index).active = true;
|
|
3933
|
+
const inputSource = this[PRIVATE$3].inputSources.get(index).source;
|
|
3934
|
+
const schema = this[PRIVATE$3].inputSchemas.get(index);
|
|
3840
3935
|
this.updateInputSource(inputSource, schema, lastFrameInputs.has(index) ? lastFrameInputs.get(index) : inputData, inputData, alpha);
|
|
3841
3936
|
});
|
|
3842
3937
|
}
|
|
@@ -3861,16 +3956,16 @@ class ActionPlayer {
|
|
|
3861
3956
|
const gamepad = inputSource.gamepad;
|
|
3862
3957
|
nextInputData.buttons.forEach((states, index) => {
|
|
3863
3958
|
const gamepadButton = gamepad.buttons[index];
|
|
3864
|
-
gamepadButton[PRIVATE$
|
|
3865
|
-
gamepadButton[PRIVATE$
|
|
3959
|
+
gamepadButton[PRIVATE$k].pressed = states[0] === 1 ? true : false;
|
|
3960
|
+
gamepadButton[PRIVATE$k].touched = states[1] === 1 ? true : false;
|
|
3866
3961
|
const lastValue = lastInputData.buttons[index][2];
|
|
3867
3962
|
const nextValue = states[2];
|
|
3868
|
-
gamepadButton[PRIVATE$
|
|
3963
|
+
gamepadButton[PRIVATE$k].value =
|
|
3869
3964
|
(nextValue - lastValue) * alpha + lastValue;
|
|
3870
3965
|
});
|
|
3871
3966
|
nextInputData.axes.forEach((nextValue, index) => {
|
|
3872
3967
|
const lastValue = lastInputData.axes[index];
|
|
3873
|
-
gamepad[PRIVATE$
|
|
3968
|
+
gamepad[PRIVATE$k].axesMap[index.toString()].x =
|
|
3874
3969
|
(nextValue - lastValue) * alpha + lastValue;
|
|
3875
3970
|
});
|
|
3876
3971
|
}
|
|
@@ -3880,13 +3975,13 @@ class ActionPlayer {
|
|
|
3880
3975
|
const f1q = fromValues(lastTransform[3], lastTransform[4], lastTransform[5], lastTransform[6]);
|
|
3881
3976
|
const f2p = fromValues$2(nextTransform[0], nextTransform[1], nextTransform[2]);
|
|
3882
3977
|
const f2q = fromValues(nextTransform[3], nextTransform[4], nextTransform[5], nextTransform[6]);
|
|
3883
|
-
lerp(this[PRIVATE$
|
|
3884
|
-
slerp(this[PRIVATE$
|
|
3885
|
-
fromRotationTranslation(space[PRIVATE$
|
|
3978
|
+
lerp(this[PRIVATE$3].vec3, f1p, f2p, alpha);
|
|
3979
|
+
slerp(this[PRIVATE$3].quat, f1q, f2q, alpha);
|
|
3980
|
+
fromRotationTranslation(space[PRIVATE$l].offsetMatrix, this[PRIVATE$3].quat, this[PRIVATE$3].vec3);
|
|
3886
3981
|
}
|
|
3887
3982
|
processRawInputData(inputDataRaw) {
|
|
3888
3983
|
const index = inputDataRaw[0];
|
|
3889
|
-
const schema = this[PRIVATE$
|
|
3984
|
+
const schema = this[PRIVATE$3].inputSchemas.get(index);
|
|
3890
3985
|
const targetRayTransform = inputDataRaw.slice(1, 8);
|
|
3891
3986
|
const inputData = { targetRayTransform };
|
|
3892
3987
|
let dataCounter = 8;
|
|
@@ -3905,7 +4000,7 @@ class ActionPlayer {
|
|
|
3905
4000
|
}
|
|
3906
4001
|
}
|
|
3907
4002
|
|
|
3908
|
-
const VERSION = "1.0.
|
|
4003
|
+
const VERSION = "1.0.2";
|
|
3909
4004
|
|
|
3910
4005
|
/**
|
|
3911
4006
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -3924,75 +4019,6 @@ class XRReferenceSpaceEvent extends Event {
|
|
|
3924
4019
|
}
|
|
3925
4020
|
}
|
|
3926
4021
|
|
|
3927
|
-
/**
|
|
3928
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3929
|
-
*
|
|
3930
|
-
* This source code is licensed under the MIT license found in the
|
|
3931
|
-
* LICENSE file in the root directory of this source tree.
|
|
3932
|
-
*/
|
|
3933
|
-
const PRIVATE$3 = Symbol('@immersive-web-emulation-runtime/xr-system');
|
|
3934
|
-
class XRSystem extends EventTarget {
|
|
3935
|
-
constructor(device) {
|
|
3936
|
-
super();
|
|
3937
|
-
this[PRIVATE$3] = { device };
|
|
3938
|
-
// Initialize device change monitoring here if applicable
|
|
3939
|
-
}
|
|
3940
|
-
isSessionSupported(mode) {
|
|
3941
|
-
return new Promise((resolve, _reject) => {
|
|
3942
|
-
if (mode === XRSessionMode.Inline) {
|
|
3943
|
-
resolve(true);
|
|
3944
|
-
}
|
|
3945
|
-
else {
|
|
3946
|
-
// Check for spatial tracking permission if necessary
|
|
3947
|
-
resolve(this[PRIVATE$3].device.supportedSessionModes.includes(mode));
|
|
3948
|
-
}
|
|
3949
|
-
});
|
|
3950
|
-
}
|
|
3951
|
-
requestSession(mode, options = {}) {
|
|
3952
|
-
return new Promise((resolve, reject) => {
|
|
3953
|
-
this.isSessionSupported(mode)
|
|
3954
|
-
.then((isSupported) => {
|
|
3955
|
-
if (!isSupported) {
|
|
3956
|
-
reject(new DOMException('The requested XRSession mode is not supported.', 'NotSupportedError'));
|
|
3957
|
-
return;
|
|
3958
|
-
}
|
|
3959
|
-
// Check for active sessions and other constraints here
|
|
3960
|
-
if (this[PRIVATE$3].activeSession) {
|
|
3961
|
-
reject(new DOMException('An active XRSession already exists.', 'InvalidStateError'));
|
|
3962
|
-
return;
|
|
3963
|
-
}
|
|
3964
|
-
// Handle required and optional features
|
|
3965
|
-
const { requiredFeatures = [], optionalFeatures = [] } = options;
|
|
3966
|
-
const { supportedFeatures } = this[PRIVATE$3].device;
|
|
3967
|
-
// Check if all required features are supported
|
|
3968
|
-
const allRequiredSupported = requiredFeatures.every((feature) => supportedFeatures.includes(feature));
|
|
3969
|
-
if (!allRequiredSupported) {
|
|
3970
|
-
reject(new Error('One or more required features are not supported by the device.'));
|
|
3971
|
-
return;
|
|
3972
|
-
}
|
|
3973
|
-
// Filter out unsupported optional features
|
|
3974
|
-
const supportedOptionalFeatures = optionalFeatures.filter((feature) => supportedFeatures.includes(feature));
|
|
3975
|
-
// Combine required and supported optional features into enabled features
|
|
3976
|
-
const enabledFeatures = Array.from(new Set([
|
|
3977
|
-
...requiredFeatures,
|
|
3978
|
-
...supportedOptionalFeatures,
|
|
3979
|
-
WebXRFeatures.Viewer,
|
|
3980
|
-
WebXRFeatures.Local,
|
|
3981
|
-
]));
|
|
3982
|
-
// Proceed with session creation
|
|
3983
|
-
const session = new XRSession(this[PRIVATE$3].device, mode, enabledFeatures);
|
|
3984
|
-
this[PRIVATE$3].activeSession = session;
|
|
3985
|
-
// Listen for session end to clear the active session
|
|
3986
|
-
session.addEventListener('end', () => {
|
|
3987
|
-
this[PRIVATE$3].activeSession = undefined;
|
|
3988
|
-
});
|
|
3989
|
-
resolve(session);
|
|
3990
|
-
})
|
|
3991
|
-
.catch(reject);
|
|
3992
|
-
});
|
|
3993
|
-
}
|
|
3994
|
-
}
|
|
3995
|
-
|
|
3996
4022
|
/**
|
|
3997
4023
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3998
4024
|
*
|
|
@@ -4093,6 +4119,7 @@ class XRDevice {
|
|
|
4093
4119
|
supportedFrameRates: deviceConfig.supportedFrameRates,
|
|
4094
4120
|
isSystemKeyboardSupported: deviceConfig.isSystemKeyboardSupported,
|
|
4095
4121
|
internalNominalFrameRate: deviceConfig.internalNominalFrameRate,
|
|
4122
|
+
userAgent: deviceConfig.userAgent,
|
|
4096
4123
|
position: (_b = deviceOptions.headsetPosition) !== null && _b !== void 0 ? _b : DEFAULTS.headsetPosition.clone(),
|
|
4097
4124
|
quaternion: (_c = deviceOptions.headsetQuaternion) !== null && _c !== void 0 ? _c : DEFAULTS.headsetQuaternion.clone(),
|
|
4098
4125
|
stereoEnabled: (_d = deviceOptions.stereoEnabled) !== null && _d !== void 0 ? _d : DEFAULTS.stereoEnabled,
|
|
@@ -4104,6 +4131,7 @@ class XRDevice {
|
|
|
4104
4131
|
pendingReferenceSpaceReset: false,
|
|
4105
4132
|
visibilityState: XRVisibilityState.Visible,
|
|
4106
4133
|
pendingVisibilityState: null,
|
|
4134
|
+
xrSystem: null,
|
|
4107
4135
|
matrix: create$3(),
|
|
4108
4136
|
globalSpace,
|
|
4109
4137
|
viewerSpace,
|
|
@@ -4124,10 +4152,10 @@ class XRDevice {
|
|
|
4124
4152
|
updateViews: () => {
|
|
4125
4153
|
// update viewerSpace
|
|
4126
4154
|
const viewerSpace = this[PRIVATE$1].viewerSpace;
|
|
4127
|
-
fromRotationTranslation(viewerSpace[PRIVATE$
|
|
4155
|
+
fromRotationTranslation(viewerSpace[PRIVATE$l].offsetMatrix, this[PRIVATE$1].quaternion.quat, this[PRIVATE$1].position.vec3);
|
|
4128
4156
|
// update viewSpaces
|
|
4129
|
-
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Left][PRIVATE$
|
|
4130
|
-
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Right][PRIVATE$
|
|
4157
|
+
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Left][PRIVATE$l].offsetMatrix, fromValues$2(-this[PRIVATE$1].ipd / 2, 0, 0));
|
|
4158
|
+
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Right][PRIVATE$l].offsetMatrix, fromValues$2(this[PRIVATE$1].ipd / 2, 0, 0));
|
|
4131
4159
|
},
|
|
4132
4160
|
onBaseLayerSet: (baseLayer) => {
|
|
4133
4161
|
if (!baseLayer)
|
|
@@ -4209,10 +4237,17 @@ class XRDevice {
|
|
|
4209
4237
|
},
|
|
4210
4238
|
configurable: true,
|
|
4211
4239
|
});
|
|
4240
|
+
this[PRIVATE$1].xrSystem = new XRSystem(this);
|
|
4212
4241
|
Object.defineProperty(globalThis.navigator, 'xr', {
|
|
4213
|
-
value:
|
|
4242
|
+
value: this[PRIVATE$1].xrSystem,
|
|
4214
4243
|
configurable: true,
|
|
4215
4244
|
});
|
|
4245
|
+
Object.defineProperty(navigator, 'userAgent', {
|
|
4246
|
+
value: this[PRIVATE$1].userAgent,
|
|
4247
|
+
writable: false,
|
|
4248
|
+
configurable: false,
|
|
4249
|
+
enumerable: true,
|
|
4250
|
+
});
|
|
4216
4251
|
globalObject['XRSystem'] = XRSystem;
|
|
4217
4252
|
globalObject['XRSession'] = XRSession;
|
|
4218
4253
|
globalObject['XRRenderState'] = XRRenderState;
|
|
@@ -4330,6 +4365,10 @@ class XRDevice {
|
|
|
4330
4365
|
get canvasContainer() {
|
|
4331
4366
|
return this[PRIVATE$1].canvasContainer;
|
|
4332
4367
|
}
|
|
4368
|
+
get activeSession() {
|
|
4369
|
+
var _a;
|
|
4370
|
+
return (_a = this[PRIVATE$1].xrSystem) === null || _a === void 0 ? void 0 : _a[PRIVATE$4].activeSession;
|
|
4371
|
+
}
|
|
4333
4372
|
recenter() {
|
|
4334
4373
|
const deltaVec = new Vector3(-this.position.x, 0, -this.position.z);
|
|
4335
4374
|
const forward = new Vector3(0, 0, -1).applyQuaternion(this.quaternion);
|
|
@@ -4549,6 +4588,7 @@ const oculusQuest1 = {
|
|
|
4549
4588
|
supportedFrameRates: [72, 80, 90],
|
|
4550
4589
|
isSystemKeyboardSupported: true,
|
|
4551
4590
|
internalNominalFrameRate: 72,
|
|
4591
|
+
userAgent: 'Mozilla/5.0 (X11; Linux x86_64; Quest 1) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36',
|
|
4552
4592
|
};
|
|
4553
4593
|
const metaQuest2 = {
|
|
4554
4594
|
name: 'Meta Quest 2',
|
|
@@ -4573,6 +4613,7 @@ const metaQuest2 = {
|
|
|
4573
4613
|
supportedFrameRates: [72, 80, 90, 120],
|
|
4574
4614
|
isSystemKeyboardSupported: true,
|
|
4575
4615
|
internalNominalFrameRate: 72,
|
|
4616
|
+
userAgent: 'Mozilla/5.0 (X11; Linux x86_64; Quest 2) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36',
|
|
4576
4617
|
};
|
|
4577
4618
|
const metaQuestPro = {
|
|
4578
4619
|
name: 'Meta Quest Pro',
|
|
@@ -4597,6 +4638,7 @@ const metaQuestPro = {
|
|
|
4597
4638
|
supportedFrameRates: [72, 80, 90, 120],
|
|
4598
4639
|
isSystemKeyboardSupported: true,
|
|
4599
4640
|
internalNominalFrameRate: 90,
|
|
4641
|
+
userAgent: 'Mozilla/5.0 (X11; Linux x86_64; Quest Pro) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36',
|
|
4600
4642
|
};
|
|
4601
4643
|
const metaQuest3 = {
|
|
4602
4644
|
name: 'Meta Quest 3',
|
|
@@ -4622,6 +4664,7 @@ const metaQuest3 = {
|
|
|
4622
4664
|
supportedFrameRates: [72, 80, 90, 120],
|
|
4623
4665
|
isSystemKeyboardSupported: true,
|
|
4624
4666
|
internalNominalFrameRate: 90,
|
|
4667
|
+
userAgent: 'Mozilla/5.0 (X11; Linux x86_64; Quest 3) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/33.0.0.x.x.x Chrome/126.0.6478.122 VR Safari/537.36',
|
|
4625
4668
|
};
|
|
4626
4669
|
|
|
4627
4670
|
/**
|