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.js
CHANGED
|
@@ -1287,11 +1287,11 @@
|
|
|
1287
1287
|
* This source code is licensed under the MIT license found in the
|
|
1288
1288
|
* LICENSE file in the root directory of this source tree.
|
|
1289
1289
|
*/
|
|
1290
|
-
const PRIVATE$
|
|
1290
|
+
const PRIVATE$l = Symbol('@immersive-web-emulation-runtime/xr-space');
|
|
1291
1291
|
class XRSpace extends EventTarget {
|
|
1292
1292
|
constructor(parentSpace, offsetMatrix) {
|
|
1293
1293
|
super();
|
|
1294
|
-
this[PRIVATE$
|
|
1294
|
+
this[PRIVATE$l] = {
|
|
1295
1295
|
parentSpace,
|
|
1296
1296
|
offsetMatrix: offsetMatrix ? clone(offsetMatrix) : create$3(),
|
|
1297
1297
|
emulated: true,
|
|
@@ -1306,27 +1306,27 @@
|
|
|
1306
1306
|
class XRSpaceUtils {
|
|
1307
1307
|
// Update the position component of the offsetMatrix of a given XRSpace
|
|
1308
1308
|
static updateOffsetPosition(space, position) {
|
|
1309
|
-
const offsetMatrix = space[PRIVATE$
|
|
1309
|
+
const offsetMatrix = space[PRIVATE$l].offsetMatrix;
|
|
1310
1310
|
fromTranslation(offsetMatrix, position);
|
|
1311
1311
|
}
|
|
1312
1312
|
// Update the rotation component of the offsetMatrix of a given XRSpace using a quaternion
|
|
1313
1313
|
static updateOffsetQuaternion(space, quaternion) {
|
|
1314
|
-
const offsetMatrix = space[PRIVATE$
|
|
1314
|
+
const offsetMatrix = space[PRIVATE$l].offsetMatrix;
|
|
1315
1315
|
const translation = create$2();
|
|
1316
1316
|
getTranslation(translation, offsetMatrix);
|
|
1317
1317
|
fromRotationTranslation(offsetMatrix, quaternion, translation);
|
|
1318
1318
|
}
|
|
1319
1319
|
// Update the offsetMatrix of a given XRSpace directly
|
|
1320
1320
|
static updateOffsetMatrix(space, matrix) {
|
|
1321
|
-
const offsetMatrix = space[PRIVATE$
|
|
1321
|
+
const offsetMatrix = space[PRIVATE$l].offsetMatrix;
|
|
1322
1322
|
copy$3(offsetMatrix, matrix);
|
|
1323
1323
|
}
|
|
1324
1324
|
// Calculate the global offset matrix for a given XRSpace
|
|
1325
1325
|
static calculateGlobalOffsetMatrix(space, globalOffset = create$3()) {
|
|
1326
|
-
const parentOffset = space[PRIVATE$
|
|
1327
|
-
? XRSpaceUtils.calculateGlobalOffsetMatrix(space[PRIVATE$
|
|
1326
|
+
const parentOffset = space[PRIVATE$l].parentSpace
|
|
1327
|
+
? XRSpaceUtils.calculateGlobalOffsetMatrix(space[PRIVATE$l].parentSpace)
|
|
1328
1328
|
: create$3(); // Identity matrix for GlobalSpace
|
|
1329
|
-
multiply$1(globalOffset, parentOffset, space[PRIVATE$
|
|
1329
|
+
multiply$1(globalOffset, parentOffset, space[PRIVATE$l].offsetMatrix);
|
|
1330
1330
|
return globalOffset;
|
|
1331
1331
|
}
|
|
1332
1332
|
}
|
|
@@ -1470,7 +1470,7 @@
|
|
|
1470
1470
|
* This source code is licensed under the MIT license found in the
|
|
1471
1471
|
* LICENSE file in the root directory of this source tree.
|
|
1472
1472
|
*/
|
|
1473
|
-
const PRIVATE$
|
|
1473
|
+
const PRIVATE$k = Symbol('@immersive-web-emulation-runtime/gamepad');
|
|
1474
1474
|
var GamepadMappingType;
|
|
1475
1475
|
(function (GamepadMappingType) {
|
|
1476
1476
|
GamepadMappingType["None"] = "";
|
|
@@ -1479,7 +1479,7 @@
|
|
|
1479
1479
|
})(GamepadMappingType || (GamepadMappingType = {}));
|
|
1480
1480
|
class GamepadButton {
|
|
1481
1481
|
constructor(type, eventTrigger) {
|
|
1482
|
-
this[PRIVATE$
|
|
1482
|
+
this[PRIVATE$k] = {
|
|
1483
1483
|
type,
|
|
1484
1484
|
eventTrigger,
|
|
1485
1485
|
pressed: false,
|
|
@@ -1490,23 +1490,23 @@
|
|
|
1490
1490
|
};
|
|
1491
1491
|
}
|
|
1492
1492
|
get pressed() {
|
|
1493
|
-
if (this[PRIVATE$
|
|
1494
|
-
return this[PRIVATE$
|
|
1493
|
+
if (this[PRIVATE$k].type === 'manual') {
|
|
1494
|
+
return this[PRIVATE$k].pressed;
|
|
1495
1495
|
}
|
|
1496
1496
|
else {
|
|
1497
|
-
return this[PRIVATE$
|
|
1497
|
+
return this[PRIVATE$k].value > 0;
|
|
1498
1498
|
}
|
|
1499
1499
|
}
|
|
1500
1500
|
get touched() {
|
|
1501
|
-
if (this[PRIVATE$
|
|
1502
|
-
return this[PRIVATE$
|
|
1501
|
+
if (this[PRIVATE$k].type === 'manual') {
|
|
1502
|
+
return this[PRIVATE$k].touched;
|
|
1503
1503
|
}
|
|
1504
1504
|
else {
|
|
1505
|
-
return this[PRIVATE$
|
|
1505
|
+
return this[PRIVATE$k].touched || this.pressed;
|
|
1506
1506
|
}
|
|
1507
1507
|
}
|
|
1508
1508
|
get value() {
|
|
1509
|
-
return this[PRIVATE$
|
|
1509
|
+
return this[PRIVATE$k].value;
|
|
1510
1510
|
}
|
|
1511
1511
|
}
|
|
1512
1512
|
class EmptyGamepadButton {
|
|
@@ -1518,7 +1518,7 @@
|
|
|
1518
1518
|
}
|
|
1519
1519
|
class Gamepad {
|
|
1520
1520
|
constructor(gamepadConfig, id = '', index = -1) {
|
|
1521
|
-
this[PRIVATE$
|
|
1521
|
+
this[PRIVATE$k] = {
|
|
1522
1522
|
id,
|
|
1523
1523
|
index,
|
|
1524
1524
|
connected: false,
|
|
@@ -1533,43 +1533,43 @@
|
|
|
1533
1533
|
gamepadConfig.buttons.forEach((buttonConfig) => {
|
|
1534
1534
|
var _a;
|
|
1535
1535
|
if (buttonConfig === null) {
|
|
1536
|
-
this[PRIVATE$
|
|
1536
|
+
this[PRIVATE$k].buttonsSequence.push(null);
|
|
1537
1537
|
}
|
|
1538
1538
|
else {
|
|
1539
|
-
this[PRIVATE$
|
|
1540
|
-
this[PRIVATE$
|
|
1539
|
+
this[PRIVATE$k].buttonsSequence.push(buttonConfig.id);
|
|
1540
|
+
this[PRIVATE$k].buttonsMap[buttonConfig.id] = new GamepadButton(buttonConfig.type, (_a = buttonConfig.eventTrigger) !== null && _a !== void 0 ? _a : null);
|
|
1541
1541
|
}
|
|
1542
1542
|
});
|
|
1543
1543
|
gamepadConfig.axes.forEach((axisConfig) => {
|
|
1544
1544
|
if (axisConfig === null) {
|
|
1545
|
-
this[PRIVATE$
|
|
1545
|
+
this[PRIVATE$k].axesSequence.push(null);
|
|
1546
1546
|
}
|
|
1547
1547
|
else {
|
|
1548
|
-
this[PRIVATE$
|
|
1549
|
-
if (!this[PRIVATE$
|
|
1550
|
-
this[PRIVATE$
|
|
1548
|
+
this[PRIVATE$k].axesSequence.push(axisConfig.id + axisConfig.type);
|
|
1549
|
+
if (!this[PRIVATE$k].axesMap[axisConfig.id]) {
|
|
1550
|
+
this[PRIVATE$k].axesMap[axisConfig.id] = { x: 0, y: 0 };
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
1553
|
});
|
|
1554
1554
|
}
|
|
1555
1555
|
get id() {
|
|
1556
|
-
return this[PRIVATE$
|
|
1556
|
+
return this[PRIVATE$k].id;
|
|
1557
1557
|
}
|
|
1558
1558
|
get index() {
|
|
1559
|
-
return this[PRIVATE$
|
|
1559
|
+
return this[PRIVATE$k].index;
|
|
1560
1560
|
}
|
|
1561
1561
|
get connected() {
|
|
1562
|
-
return this[PRIVATE$
|
|
1562
|
+
return this[PRIVATE$k].connected;
|
|
1563
1563
|
}
|
|
1564
1564
|
get timestamp() {
|
|
1565
|
-
return this[PRIVATE$
|
|
1565
|
+
return this[PRIVATE$k].timestamp;
|
|
1566
1566
|
}
|
|
1567
1567
|
get mapping() {
|
|
1568
|
-
return this[PRIVATE$
|
|
1568
|
+
return this[PRIVATE$k].mapping;
|
|
1569
1569
|
}
|
|
1570
1570
|
get axes() {
|
|
1571
1571
|
const axes = [];
|
|
1572
|
-
this[PRIVATE$
|
|
1572
|
+
this[PRIVATE$k].axesSequence.forEach((id) => {
|
|
1573
1573
|
if (id === null) {
|
|
1574
1574
|
axes.push(null);
|
|
1575
1575
|
}
|
|
@@ -1579,17 +1579,17 @@
|
|
|
1579
1579
|
axes.push(
|
|
1580
1580
|
// if axis type is manual, then return the x value
|
|
1581
1581
|
axisType === 'y-axis'
|
|
1582
|
-
? this[PRIVATE$
|
|
1583
|
-
: this[PRIVATE$
|
|
1582
|
+
? this[PRIVATE$k].axesMap[axisId].y
|
|
1583
|
+
: this[PRIVATE$k].axesMap[axisId].x);
|
|
1584
1584
|
}
|
|
1585
1585
|
});
|
|
1586
1586
|
return axes;
|
|
1587
1587
|
}
|
|
1588
1588
|
get buttons() {
|
|
1589
|
-
return this[PRIVATE$
|
|
1589
|
+
return this[PRIVATE$k].buttonsSequence.map((id) => id === null ? new EmptyGamepadButton() : this[PRIVATE$k].buttonsMap[id]);
|
|
1590
1590
|
}
|
|
1591
1591
|
get hapticActuators() {
|
|
1592
|
-
return this[PRIVATE$
|
|
1592
|
+
return this[PRIVATE$k].hapticActuators;
|
|
1593
1593
|
}
|
|
1594
1594
|
get vibrationActuator() {
|
|
1595
1595
|
return null;
|
|
@@ -1617,10 +1617,10 @@
|
|
|
1617
1617
|
})(XRTargetRayMode || (XRTargetRayMode = {}));
|
|
1618
1618
|
class XRInputSourceArray extends Array {
|
|
1619
1619
|
}
|
|
1620
|
-
const PRIVATE$
|
|
1620
|
+
const PRIVATE$j = Symbol('@immersive-web-emulation-runtime/xr-input-source');
|
|
1621
1621
|
class XRInputSource {
|
|
1622
1622
|
constructor(handedness, targetRayMode, profiles, targetRaySpace, gamepad, gripSpace, hand) {
|
|
1623
|
-
this[PRIVATE$
|
|
1623
|
+
this[PRIVATE$j] = {
|
|
1624
1624
|
handedness,
|
|
1625
1625
|
targetRayMode,
|
|
1626
1626
|
targetRaySpace,
|
|
@@ -1631,25 +1631,25 @@
|
|
|
1631
1631
|
};
|
|
1632
1632
|
}
|
|
1633
1633
|
get handedness() {
|
|
1634
|
-
return this[PRIVATE$
|
|
1634
|
+
return this[PRIVATE$j].handedness;
|
|
1635
1635
|
}
|
|
1636
1636
|
get targetRayMode() {
|
|
1637
|
-
return this[PRIVATE$
|
|
1637
|
+
return this[PRIVATE$j].targetRayMode;
|
|
1638
1638
|
}
|
|
1639
1639
|
get targetRaySpace() {
|
|
1640
|
-
return this[PRIVATE$
|
|
1640
|
+
return this[PRIVATE$j].targetRaySpace;
|
|
1641
1641
|
}
|
|
1642
1642
|
get gripSpace() {
|
|
1643
|
-
return this[PRIVATE$
|
|
1643
|
+
return this[PRIVATE$j].gripSpace;
|
|
1644
1644
|
}
|
|
1645
1645
|
get profiles() {
|
|
1646
|
-
return this[PRIVATE$
|
|
1646
|
+
return this[PRIVATE$j].profiles;
|
|
1647
1647
|
}
|
|
1648
1648
|
get gamepad() {
|
|
1649
|
-
return this[PRIVATE$
|
|
1649
|
+
return this[PRIVATE$j].gamepad;
|
|
1650
1650
|
}
|
|
1651
1651
|
get hand() {
|
|
1652
|
-
return this[PRIVATE$
|
|
1652
|
+
return this[PRIVATE$j].hand;
|
|
1653
1653
|
}
|
|
1654
1654
|
}
|
|
1655
1655
|
|
|
@@ -1679,7 +1679,7 @@
|
|
|
1679
1679
|
* This source code is licensed under the MIT license found in the
|
|
1680
1680
|
* LICENSE file in the root directory of this source tree.
|
|
1681
1681
|
*/
|
|
1682
|
-
const PRIVATE$
|
|
1682
|
+
const PRIVATE$i = Symbol('@immersive-web-emulation-runtime/xr-tracked-input');
|
|
1683
1683
|
const DEFAULT_TRANSFORM = {
|
|
1684
1684
|
[XRHandedness.Left]: {
|
|
1685
1685
|
position: new Vector3(-0.25, 1.5, -0.4),
|
|
@@ -1696,7 +1696,7 @@
|
|
|
1696
1696
|
};
|
|
1697
1697
|
class XRTrackedInput {
|
|
1698
1698
|
constructor(inputSource) {
|
|
1699
|
-
this[PRIVATE$
|
|
1699
|
+
this[PRIVATE$i] = {
|
|
1700
1700
|
inputSource,
|
|
1701
1701
|
position: DEFAULT_TRANSFORM[inputSource.handedness].position.clone(),
|
|
1702
1702
|
quaternion: DEFAULT_TRANSFORM[inputSource.handedness].quaternion.clone(),
|
|
@@ -1706,59 +1706,59 @@
|
|
|
1706
1706
|
};
|
|
1707
1707
|
}
|
|
1708
1708
|
get position() {
|
|
1709
|
-
return this[PRIVATE$
|
|
1709
|
+
return this[PRIVATE$i].position;
|
|
1710
1710
|
}
|
|
1711
1711
|
get quaternion() {
|
|
1712
|
-
return this[PRIVATE$
|
|
1712
|
+
return this[PRIVATE$i].quaternion;
|
|
1713
1713
|
}
|
|
1714
1714
|
get inputSource() {
|
|
1715
|
-
return this[PRIVATE$
|
|
1715
|
+
return this[PRIVATE$i].inputSource;
|
|
1716
1716
|
}
|
|
1717
1717
|
get connected() {
|
|
1718
|
-
return this[PRIVATE$
|
|
1718
|
+
return this[PRIVATE$i].connected;
|
|
1719
1719
|
}
|
|
1720
1720
|
set connected(value) {
|
|
1721
|
-
this[PRIVATE$
|
|
1722
|
-
this[PRIVATE$
|
|
1721
|
+
this[PRIVATE$i].connected = value;
|
|
1722
|
+
this[PRIVATE$i].inputSource.gamepad[PRIVATE$k].connected = value;
|
|
1723
1723
|
}
|
|
1724
1724
|
onFrameStart(frame) {
|
|
1725
|
-
const targetRaySpace = this[PRIVATE$
|
|
1726
|
-
fromRotationTranslation(targetRaySpace[PRIVATE$
|
|
1725
|
+
const targetRaySpace = this[PRIVATE$i].inputSource.targetRaySpace;
|
|
1726
|
+
fromRotationTranslation(targetRaySpace[PRIVATE$l].offsetMatrix, this[PRIVATE$i].quaternion.quat, this[PRIVATE$i].position.vec3);
|
|
1727
1727
|
const session = frame.session;
|
|
1728
|
-
this[PRIVATE$
|
|
1728
|
+
this[PRIVATE$i].inputSource.gamepad.buttons.forEach((button) => {
|
|
1729
1729
|
if (button instanceof GamepadButton) {
|
|
1730
1730
|
// apply pending values and record last frame values
|
|
1731
|
-
button[PRIVATE$
|
|
1732
|
-
if (button[PRIVATE$
|
|
1733
|
-
button[PRIVATE$
|
|
1734
|
-
button[PRIVATE$
|
|
1731
|
+
button[PRIVATE$k].lastFrameValue = button[PRIVATE$k].value;
|
|
1732
|
+
if (button[PRIVATE$k].pendingValue != null) {
|
|
1733
|
+
button[PRIVATE$k].value = button[PRIVATE$k].pendingValue;
|
|
1734
|
+
button[PRIVATE$k].pendingValue = null;
|
|
1735
1735
|
}
|
|
1736
1736
|
// trigger input source events
|
|
1737
|
-
if (button[PRIVATE$
|
|
1738
|
-
if (button[PRIVATE$
|
|
1739
|
-
button[PRIVATE$
|
|
1740
|
-
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$
|
|
1737
|
+
if (button[PRIVATE$k].eventTrigger != null) {
|
|
1738
|
+
if (button[PRIVATE$k].lastFrameValue === 0 &&
|
|
1739
|
+
button[PRIVATE$k].value > 0) {
|
|
1740
|
+
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$k].eventTrigger, {
|
|
1741
1741
|
frame,
|
|
1742
|
-
inputSource: this[PRIVATE$
|
|
1742
|
+
inputSource: this[PRIVATE$i].inputSource,
|
|
1743
1743
|
}));
|
|
1744
|
-
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$
|
|
1744
|
+
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$k].eventTrigger + 'start', {
|
|
1745
1745
|
frame,
|
|
1746
|
-
inputSource: this[PRIVATE$
|
|
1746
|
+
inputSource: this[PRIVATE$i].inputSource,
|
|
1747
1747
|
}));
|
|
1748
1748
|
}
|
|
1749
|
-
else if (button[PRIVATE$
|
|
1750
|
-
button[PRIVATE$
|
|
1751
|
-
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$
|
|
1749
|
+
else if (button[PRIVATE$k].lastFrameValue > 0 &&
|
|
1750
|
+
button[PRIVATE$k].value === 0) {
|
|
1751
|
+
session.dispatchEvent(new XRInputSourceEvent(button[PRIVATE$k].eventTrigger + 'end', {
|
|
1752
1752
|
frame,
|
|
1753
|
-
inputSource: this[PRIVATE$
|
|
1753
|
+
inputSource: this[PRIVATE$i].inputSource,
|
|
1754
1754
|
}));
|
|
1755
1755
|
}
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
1758
|
});
|
|
1759
|
-
this[PRIVATE$
|
|
1760
|
-
this.connected !== this[PRIVATE$
|
|
1761
|
-
this[PRIVATE$
|
|
1759
|
+
this[PRIVATE$i].inputSourceChanged =
|
|
1760
|
+
this.connected !== this[PRIVATE$i].lastFrameConnected;
|
|
1761
|
+
this[PRIVATE$i].lastFrameConnected = this.connected;
|
|
1762
1762
|
}
|
|
1763
1763
|
}
|
|
1764
1764
|
|
|
@@ -1768,6 +1768,7 @@
|
|
|
1768
1768
|
* This source code is licensed under the MIT license found in the
|
|
1769
1769
|
* LICENSE file in the root directory of this source tree.
|
|
1770
1770
|
*/
|
|
1771
|
+
const PRIVATE$h = Symbol('@immersive-web-emulation-runtime/xr-controller');
|
|
1771
1772
|
class XRController extends XRTrackedInput {
|
|
1772
1773
|
constructor(controllerConfig, handedness, globalSpace) {
|
|
1773
1774
|
if (!controllerConfig.layout[handedness]) {
|
|
@@ -1783,30 +1784,38 @@
|
|
|
1783
1784
|
];
|
|
1784
1785
|
const inputSource = new XRInputSource(handedness, XRTargetRayMode.TrackedPointer, profiles, targetRaySpace, new Gamepad(controllerConfig.layout[handedness].gamepad), gripSpace);
|
|
1785
1786
|
super(inputSource);
|
|
1787
|
+
this[PRIVATE$h] = {
|
|
1788
|
+
gamepadConfig: controllerConfig.layout[handedness].gamepad,
|
|
1789
|
+
};
|
|
1790
|
+
}
|
|
1791
|
+
get gamepadConfig() {
|
|
1792
|
+
return this[PRIVATE$h].gamepadConfig;
|
|
1786
1793
|
}
|
|
1787
1794
|
updateButtonValue(id, value) {
|
|
1788
1795
|
if (value > 1 || value < 0) {
|
|
1789
1796
|
console.warn(`Out-of-range value ${value} provided for button ${id}.`);
|
|
1790
1797
|
return;
|
|
1791
1798
|
}
|
|
1792
|
-
const gamepadButton = this[PRIVATE$
|
|
1799
|
+
const gamepadButton = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1800
|
+
.buttonsMap[id];
|
|
1793
1801
|
if (gamepadButton) {
|
|
1794
|
-
if (gamepadButton[PRIVATE$
|
|
1802
|
+
if (gamepadButton[PRIVATE$k].type === 'binary' &&
|
|
1795
1803
|
value != 1 &&
|
|
1796
1804
|
value != 0) {
|
|
1797
1805
|
console.warn(`Non-binary value ${value} provided for binary button ${id}.`);
|
|
1798
1806
|
return;
|
|
1799
1807
|
}
|
|
1800
|
-
gamepadButton[PRIVATE$
|
|
1808
|
+
gamepadButton[PRIVATE$k].pendingValue = value;
|
|
1801
1809
|
}
|
|
1802
1810
|
else {
|
|
1803
1811
|
console.warn(`Current controller does not have button ${id}.`);
|
|
1804
1812
|
}
|
|
1805
1813
|
}
|
|
1806
1814
|
updateButtonTouch(id, touched) {
|
|
1807
|
-
const gamepadButton = this[PRIVATE$
|
|
1815
|
+
const gamepadButton = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1816
|
+
.buttonsMap[id];
|
|
1808
1817
|
if (gamepadButton) {
|
|
1809
|
-
gamepadButton[PRIVATE$
|
|
1818
|
+
gamepadButton[PRIVATE$k].touched = touched;
|
|
1810
1819
|
}
|
|
1811
1820
|
else {
|
|
1812
1821
|
console.warn(`Current controller does not have button ${id}.`);
|
|
@@ -1817,7 +1826,8 @@
|
|
|
1817
1826
|
console.warn(`Out-of-range value ${value} provided for ${id} axes.`);
|
|
1818
1827
|
return;
|
|
1819
1828
|
}
|
|
1820
|
-
const axesById = this[PRIVATE$
|
|
1829
|
+
const axesById = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1830
|
+
.axesMap[id];
|
|
1821
1831
|
if (axesById) {
|
|
1822
1832
|
if (type === 'x-axis') {
|
|
1823
1833
|
axesById.x = value;
|
|
@@ -1835,7 +1845,8 @@
|
|
|
1835
1845
|
console.warn(`Out-of-range value x:${x}, y:${y} provided for ${id} axes.`);
|
|
1836
1846
|
return;
|
|
1837
1847
|
}
|
|
1838
|
-
const axesById = this[PRIVATE$
|
|
1848
|
+
const axesById = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
1849
|
+
.axesMap[id];
|
|
1839
1850
|
if (axesById) {
|
|
1840
1851
|
axesById.x = x;
|
|
1841
1852
|
axesById.y = y;
|
|
@@ -2770,20 +2781,20 @@
|
|
|
2770
2781
|
const targetJointMatrix = targetPose.jointTransforms[jointName].offsetMatrix;
|
|
2771
2782
|
const pinchJointMatrix = pinchPose.jointTransforms[jointName].offsetMatrix;
|
|
2772
2783
|
const jointSpace = this.inputSource.hand.get(jointName);
|
|
2773
|
-
interpolateMatrix(jointSpace[PRIVATE$
|
|
2784
|
+
interpolateMatrix(jointSpace[PRIVATE$l].offsetMatrix, targetJointMatrix, pinchJointMatrix, this.pinchValue);
|
|
2774
2785
|
if (this.inputSource.handedness === XRHandedness.Right) {
|
|
2775
|
-
mirrorMatrixToRight(jointSpace[PRIVATE$
|
|
2786
|
+
mirrorMatrixToRight(jointSpace[PRIVATE$l].offsetMatrix);
|
|
2776
2787
|
}
|
|
2777
2788
|
jointSpace[PRIVATE$f].radius =
|
|
2778
2789
|
(1 - this.pinchValue) * targetPose.jointTransforms[jointName].radius +
|
|
2779
2790
|
this.pinchValue * pinchPose.jointTransforms[jointName].radius;
|
|
2780
2791
|
});
|
|
2781
2792
|
if (targetPose.gripOffsetMatrix && pinchPose.gripOffsetMatrix) {
|
|
2782
|
-
interpolateMatrix(this.inputSource.gripSpace[PRIVATE$
|
|
2793
|
+
interpolateMatrix(this.inputSource.gripSpace[PRIVATE$l].offsetMatrix, targetPose.gripOffsetMatrix, pinchPose.gripOffsetMatrix, this.pinchValue);
|
|
2783
2794
|
}
|
|
2784
2795
|
}
|
|
2785
2796
|
get pinchValue() {
|
|
2786
|
-
return this[PRIVATE$
|
|
2797
|
+
return this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
2787
2798
|
.buttonsMap['pinch'].value;
|
|
2788
2799
|
}
|
|
2789
2800
|
updatePinchValue(value) {
|
|
@@ -2791,9 +2802,9 @@
|
|
|
2791
2802
|
console.warn(`Out-of-range value ${value} provided for pinch`);
|
|
2792
2803
|
return;
|
|
2793
2804
|
}
|
|
2794
|
-
const gamepadButton = this[PRIVATE$
|
|
2805
|
+
const gamepadButton = this[PRIVATE$i].inputSource.gamepad[PRIVATE$k]
|
|
2795
2806
|
.buttonsMap['pinch'];
|
|
2796
|
-
gamepadButton[PRIVATE$
|
|
2807
|
+
gamepadButton[PRIVATE$k].pendingValue = value;
|
|
2797
2808
|
}
|
|
2798
2809
|
onFrameStart(frame) {
|
|
2799
2810
|
super.onFrameStart(frame);
|
|
@@ -3004,7 +3015,7 @@
|
|
|
3004
3015
|
y: orientation[1],
|
|
3005
3016
|
z: orientation[2],
|
|
3006
3017
|
w: orientation[3],
|
|
3007
|
-
}), space[PRIVATE$
|
|
3018
|
+
}), space[PRIVATE$l].emulated);
|
|
3008
3019
|
}
|
|
3009
3020
|
getViewerPose(referenceSpace) {
|
|
3010
3021
|
if (!this[PRIVATE$9].animationFrame) {
|
|
@@ -3405,6 +3416,7 @@
|
|
|
3405
3416
|
return this[PRIVATE$6].isSystemKeyboardSupported;
|
|
3406
3417
|
}
|
|
3407
3418
|
updateRenderState(state = {}) {
|
|
3419
|
+
var _a, _b, _c, _d;
|
|
3408
3420
|
if (this[PRIVATE$6].ended) {
|
|
3409
3421
|
throw new DOMException('XRSession has already ended.', 'InvalidStateError');
|
|
3410
3422
|
}
|
|
@@ -3416,7 +3428,21 @@
|
|
|
3416
3428
|
this[PRIVATE$6].mode !== XRSessionMode.Inline) {
|
|
3417
3429
|
throw new DOMException('InlineVerticalFieldOfView must not be set for an immersive session', 'InvalidStateError');
|
|
3418
3430
|
}
|
|
3419
|
-
|
|
3431
|
+
const compoundStateInit = {
|
|
3432
|
+
baseLayer: state.baseLayer ||
|
|
3433
|
+
((_a = this[PRIVATE$6].pendingRenderState) === null || _a === void 0 ? void 0 : _a.baseLayer) ||
|
|
3434
|
+
undefined,
|
|
3435
|
+
depthFar: state.depthFar ||
|
|
3436
|
+
((_b = this[PRIVATE$6].pendingRenderState) === null || _b === void 0 ? void 0 : _b.depthFar) ||
|
|
3437
|
+
undefined,
|
|
3438
|
+
depthNear: state.depthNear ||
|
|
3439
|
+
((_c = this[PRIVATE$6].pendingRenderState) === null || _c === void 0 ? void 0 : _c.depthNear) ||
|
|
3440
|
+
undefined,
|
|
3441
|
+
inlineVerticalFieldOfView: state.inlineVerticalFieldOfView ||
|
|
3442
|
+
((_d = this[PRIVATE$6].pendingRenderState) === null || _d === void 0 ? void 0 : _d.inlineVerticalFieldOfView) ||
|
|
3443
|
+
undefined,
|
|
3444
|
+
};
|
|
3445
|
+
this[PRIVATE$6].pendingRenderState = new XRRenderState(compoundStateInit, this[PRIVATE$6].renderState);
|
|
3420
3446
|
}
|
|
3421
3447
|
// the nominal frame rate updates are emulated, no actual update to the
|
|
3422
3448
|
// display frame rate of the device will be executed
|
|
@@ -3455,7 +3481,7 @@
|
|
|
3455
3481
|
break;
|
|
3456
3482
|
case XRReferenceSpaceType.Local:
|
|
3457
3483
|
// creating an XRReferenceSpace with the current headset transform in global space
|
|
3458
|
-
referenceSpace = new XRReferenceSpace(type, this[PRIVATE$6].device[PRIVATE$1].globalSpace, this[PRIVATE$6].device.viewerSpace[PRIVATE$
|
|
3484
|
+
referenceSpace = new XRReferenceSpace(type, this[PRIVATE$6].device[PRIVATE$1].globalSpace, this[PRIVATE$6].device.viewerSpace[PRIVATE$l].offsetMatrix);
|
|
3459
3485
|
break;
|
|
3460
3486
|
case XRReferenceSpaceType.LocalFloor:
|
|
3461
3487
|
case XRReferenceSpaceType.BoundedFloor:
|
|
@@ -3721,7 +3747,76 @@
|
|
|
3721
3747
|
* This source code is licensed under the MIT license found in the
|
|
3722
3748
|
* LICENSE file in the root directory of this source tree.
|
|
3723
3749
|
*/
|
|
3724
|
-
const PRIVATE$4 = Symbol('@immersive-web-emulation-runtime/
|
|
3750
|
+
const PRIVATE$4 = Symbol('@immersive-web-emulation-runtime/xr-system');
|
|
3751
|
+
class XRSystem extends EventTarget {
|
|
3752
|
+
constructor(device) {
|
|
3753
|
+
super();
|
|
3754
|
+
this[PRIVATE$4] = { device };
|
|
3755
|
+
// Initialize device change monitoring here if applicable
|
|
3756
|
+
}
|
|
3757
|
+
isSessionSupported(mode) {
|
|
3758
|
+
return new Promise((resolve, _reject) => {
|
|
3759
|
+
if (mode === XRSessionMode.Inline) {
|
|
3760
|
+
resolve(true);
|
|
3761
|
+
}
|
|
3762
|
+
else {
|
|
3763
|
+
// Check for spatial tracking permission if necessary
|
|
3764
|
+
resolve(this[PRIVATE$4].device.supportedSessionModes.includes(mode));
|
|
3765
|
+
}
|
|
3766
|
+
});
|
|
3767
|
+
}
|
|
3768
|
+
requestSession(mode, options = {}) {
|
|
3769
|
+
return new Promise((resolve, reject) => {
|
|
3770
|
+
this.isSessionSupported(mode)
|
|
3771
|
+
.then((isSupported) => {
|
|
3772
|
+
if (!isSupported) {
|
|
3773
|
+
reject(new DOMException('The requested XRSession mode is not supported.', 'NotSupportedError'));
|
|
3774
|
+
return;
|
|
3775
|
+
}
|
|
3776
|
+
// Check for active sessions and other constraints here
|
|
3777
|
+
if (this[PRIVATE$4].activeSession) {
|
|
3778
|
+
reject(new DOMException('An active XRSession already exists.', 'InvalidStateError'));
|
|
3779
|
+
return;
|
|
3780
|
+
}
|
|
3781
|
+
// Handle required and optional features
|
|
3782
|
+
const { requiredFeatures = [], optionalFeatures = [] } = options;
|
|
3783
|
+
const { supportedFeatures } = this[PRIVATE$4].device;
|
|
3784
|
+
// Check if all required features are supported
|
|
3785
|
+
const allRequiredSupported = requiredFeatures.every((feature) => supportedFeatures.includes(feature));
|
|
3786
|
+
if (!allRequiredSupported) {
|
|
3787
|
+
reject(new Error('One or more required features are not supported by the device.'));
|
|
3788
|
+
return;
|
|
3789
|
+
}
|
|
3790
|
+
// Filter out unsupported optional features
|
|
3791
|
+
const supportedOptionalFeatures = optionalFeatures.filter((feature) => supportedFeatures.includes(feature));
|
|
3792
|
+
// Combine required and supported optional features into enabled features
|
|
3793
|
+
const enabledFeatures = Array.from(new Set([
|
|
3794
|
+
...requiredFeatures,
|
|
3795
|
+
...supportedOptionalFeatures,
|
|
3796
|
+
WebXRFeatures.Viewer,
|
|
3797
|
+
WebXRFeatures.Local,
|
|
3798
|
+
]));
|
|
3799
|
+
// Proceed with session creation
|
|
3800
|
+
const session = new XRSession(this[PRIVATE$4].device, mode, enabledFeatures);
|
|
3801
|
+
this[PRIVATE$4].activeSession = session;
|
|
3802
|
+
// Listen for session end to clear the active session
|
|
3803
|
+
session.addEventListener('end', () => {
|
|
3804
|
+
this[PRIVATE$4].activeSession = undefined;
|
|
3805
|
+
});
|
|
3806
|
+
resolve(session);
|
|
3807
|
+
})
|
|
3808
|
+
.catch(reject);
|
|
3809
|
+
});
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
/**
|
|
3814
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3815
|
+
*
|
|
3816
|
+
* This source code is licensed under the MIT license found in the
|
|
3817
|
+
* LICENSE file in the root directory of this source tree.
|
|
3818
|
+
*/
|
|
3819
|
+
const PRIVATE$3 = Symbol('@immersive-web-emulation-runtime/action-player');
|
|
3725
3820
|
class ActionPlayer {
|
|
3726
3821
|
constructor(refSpace, recording, ipd) {
|
|
3727
3822
|
const { schema, frames } = recording;
|
|
@@ -3734,7 +3829,7 @@
|
|
|
3734
3829
|
[XREye.Right]: new XRSpace(viewerSpace),
|
|
3735
3830
|
[XREye.None]: new XRSpace(viewerSpace),
|
|
3736
3831
|
};
|
|
3737
|
-
this[PRIVATE$
|
|
3832
|
+
this[PRIVATE$3] = {
|
|
3738
3833
|
refSpace,
|
|
3739
3834
|
inputSources: new Map(),
|
|
3740
3835
|
inputSchemas: new Map(),
|
|
@@ -3749,8 +3844,8 @@
|
|
|
3749
3844
|
vec3: create$2(),
|
|
3750
3845
|
quat: create(),
|
|
3751
3846
|
};
|
|
3752
|
-
fromTranslation(this[PRIVATE$
|
|
3753
|
-
fromTranslation(this[PRIVATE$
|
|
3847
|
+
fromTranslation(this[PRIVATE$3].viewSpaces[XREye.Left][PRIVATE$l].offsetMatrix, fromValues$2(-ipd / 2, 0, 0));
|
|
3848
|
+
fromTranslation(this[PRIVATE$3].viewSpaces[XREye.Right][PRIVATE$l].offsetMatrix, fromValues$2(ipd / 2, 0, 0));
|
|
3754
3849
|
schema.forEach((schemaEntry) => {
|
|
3755
3850
|
const index = schemaEntry[0];
|
|
3756
3851
|
const schema = schemaEntry[1];
|
|
@@ -3779,53 +3874,53 @@
|
|
|
3779
3874
|
});
|
|
3780
3875
|
}
|
|
3781
3876
|
const inputSource = new XRInputSource(schema.handedness, schema.targetRayMode, schema.profiles, targetRaySpace, gamepad, schema.hasGrip ? new XRSpace(refSpace) : undefined, schema.hasHand ? hand : undefined);
|
|
3782
|
-
this[PRIVATE$
|
|
3877
|
+
this[PRIVATE$3].inputSources.set(index, {
|
|
3783
3878
|
active: false,
|
|
3784
3879
|
source: inputSource,
|
|
3785
3880
|
});
|
|
3786
|
-
this[PRIVATE$
|
|
3881
|
+
this[PRIVATE$3].inputSchemas.set(index, schema);
|
|
3787
3882
|
});
|
|
3788
3883
|
}
|
|
3789
3884
|
play() {
|
|
3790
|
-
this[PRIVATE$
|
|
3791
|
-
this[PRIVATE$
|
|
3792
|
-
this[PRIVATE$
|
|
3793
|
-
this[PRIVATE$
|
|
3885
|
+
this[PRIVATE$3].recordedFramePointer = 0;
|
|
3886
|
+
this[PRIVATE$3].playbackTime = this[PRIVATE$3].startingTimeStamp;
|
|
3887
|
+
this[PRIVATE$3].playing = true;
|
|
3888
|
+
this[PRIVATE$3].actualTimeStamp = performance.now();
|
|
3794
3889
|
}
|
|
3795
3890
|
stop() {
|
|
3796
|
-
this[PRIVATE$
|
|
3891
|
+
this[PRIVATE$3].playing = false;
|
|
3797
3892
|
}
|
|
3798
3893
|
get playing() {
|
|
3799
|
-
return this[PRIVATE$
|
|
3894
|
+
return this[PRIVATE$3].playing;
|
|
3800
3895
|
}
|
|
3801
3896
|
get viewerSpace() {
|
|
3802
|
-
return this[PRIVATE$
|
|
3897
|
+
return this[PRIVATE$3].viewerSpace;
|
|
3803
3898
|
}
|
|
3804
3899
|
get viewSpaces() {
|
|
3805
|
-
return this[PRIVATE$
|
|
3900
|
+
return this[PRIVATE$3].viewSpaces;
|
|
3806
3901
|
}
|
|
3807
3902
|
get inputSources() {
|
|
3808
|
-
return Array.from(this[PRIVATE$
|
|
3903
|
+
return Array.from(this[PRIVATE$3].inputSources.values())
|
|
3809
3904
|
.filter((wrapper) => wrapper.active)
|
|
3810
3905
|
.map((wrapper) => wrapper.source);
|
|
3811
3906
|
}
|
|
3812
3907
|
playFrame() {
|
|
3813
3908
|
const now = performance.now();
|
|
3814
|
-
const delta = now - this[PRIVATE$
|
|
3815
|
-
this[PRIVATE$
|
|
3816
|
-
this[PRIVATE$
|
|
3817
|
-
if (this[PRIVATE$
|
|
3909
|
+
const delta = now - this[PRIVATE$3].actualTimeStamp;
|
|
3910
|
+
this[PRIVATE$3].actualTimeStamp = now;
|
|
3911
|
+
this[PRIVATE$3].playbackTime += delta;
|
|
3912
|
+
if (this[PRIVATE$3].playbackTime > this[PRIVATE$3].endingTimeStamp) {
|
|
3818
3913
|
this.stop();
|
|
3819
3914
|
return;
|
|
3820
3915
|
}
|
|
3821
|
-
while (this[PRIVATE$
|
|
3822
|
-
this[PRIVATE$
|
|
3916
|
+
while (this[PRIVATE$3].frames[this[PRIVATE$3].recordedFramePointer + 1][0] < this[PRIVATE$3].playbackTime) {
|
|
3917
|
+
this[PRIVATE$3].recordedFramePointer++;
|
|
3823
3918
|
}
|
|
3824
|
-
const lastFrameData = this[PRIVATE$
|
|
3825
|
-
const nextFrameData = this[PRIVATE$
|
|
3826
|
-
const alpha = (this[PRIVATE$
|
|
3919
|
+
const lastFrameData = this[PRIVATE$3].frames[this[PRIVATE$3].recordedFramePointer];
|
|
3920
|
+
const nextFrameData = this[PRIVATE$3].frames[this[PRIVATE$3].recordedFramePointer + 1];
|
|
3921
|
+
const alpha = (this[PRIVATE$3].playbackTime - lastFrameData[0]) /
|
|
3827
3922
|
(nextFrameData[0] - lastFrameData[0]);
|
|
3828
|
-
this.updateXRSpaceFromMergedFrames(this[PRIVATE$
|
|
3923
|
+
this.updateXRSpaceFromMergedFrames(this[PRIVATE$3].viewerSpace, lastFrameData.slice(1, 8), nextFrameData.slice(1, 8), alpha);
|
|
3829
3924
|
const lastFrameInputs = new Map();
|
|
3830
3925
|
for (let i = 8; i < lastFrameData.length; i++) {
|
|
3831
3926
|
const { index, inputData } = this.processRawInputData(lastFrameData[i]);
|
|
@@ -3836,13 +3931,13 @@
|
|
|
3836
3931
|
const { index, inputData } = this.processRawInputData(nextFrameData[i]);
|
|
3837
3932
|
nextFrameInputs.set(index, inputData);
|
|
3838
3933
|
}
|
|
3839
|
-
this[PRIVATE$
|
|
3934
|
+
this[PRIVATE$3].inputSources.forEach((sourceWrapper) => {
|
|
3840
3935
|
sourceWrapper.active = false;
|
|
3841
3936
|
});
|
|
3842
3937
|
nextFrameInputs.forEach((inputData, index) => {
|
|
3843
|
-
this[PRIVATE$
|
|
3844
|
-
const inputSource = this[PRIVATE$
|
|
3845
|
-
const schema = this[PRIVATE$
|
|
3938
|
+
this[PRIVATE$3].inputSources.get(index).active = true;
|
|
3939
|
+
const inputSource = this[PRIVATE$3].inputSources.get(index).source;
|
|
3940
|
+
const schema = this[PRIVATE$3].inputSchemas.get(index);
|
|
3846
3941
|
this.updateInputSource(inputSource, schema, lastFrameInputs.has(index) ? lastFrameInputs.get(index) : inputData, inputData, alpha);
|
|
3847
3942
|
});
|
|
3848
3943
|
}
|
|
@@ -3867,16 +3962,16 @@
|
|
|
3867
3962
|
const gamepad = inputSource.gamepad;
|
|
3868
3963
|
nextInputData.buttons.forEach((states, index) => {
|
|
3869
3964
|
const gamepadButton = gamepad.buttons[index];
|
|
3870
|
-
gamepadButton[PRIVATE$
|
|
3871
|
-
gamepadButton[PRIVATE$
|
|
3965
|
+
gamepadButton[PRIVATE$k].pressed = states[0] === 1 ? true : false;
|
|
3966
|
+
gamepadButton[PRIVATE$k].touched = states[1] === 1 ? true : false;
|
|
3872
3967
|
const lastValue = lastInputData.buttons[index][2];
|
|
3873
3968
|
const nextValue = states[2];
|
|
3874
|
-
gamepadButton[PRIVATE$
|
|
3969
|
+
gamepadButton[PRIVATE$k].value =
|
|
3875
3970
|
(nextValue - lastValue) * alpha + lastValue;
|
|
3876
3971
|
});
|
|
3877
3972
|
nextInputData.axes.forEach((nextValue, index) => {
|
|
3878
3973
|
const lastValue = lastInputData.axes[index];
|
|
3879
|
-
gamepad[PRIVATE$
|
|
3974
|
+
gamepad[PRIVATE$k].axesMap[index.toString()].x =
|
|
3880
3975
|
(nextValue - lastValue) * alpha + lastValue;
|
|
3881
3976
|
});
|
|
3882
3977
|
}
|
|
@@ -3886,13 +3981,13 @@
|
|
|
3886
3981
|
const f1q = fromValues(lastTransform[3], lastTransform[4], lastTransform[5], lastTransform[6]);
|
|
3887
3982
|
const f2p = fromValues$2(nextTransform[0], nextTransform[1], nextTransform[2]);
|
|
3888
3983
|
const f2q = fromValues(nextTransform[3], nextTransform[4], nextTransform[5], nextTransform[6]);
|
|
3889
|
-
lerp(this[PRIVATE$
|
|
3890
|
-
slerp(this[PRIVATE$
|
|
3891
|
-
fromRotationTranslation(space[PRIVATE$
|
|
3984
|
+
lerp(this[PRIVATE$3].vec3, f1p, f2p, alpha);
|
|
3985
|
+
slerp(this[PRIVATE$3].quat, f1q, f2q, alpha);
|
|
3986
|
+
fromRotationTranslation(space[PRIVATE$l].offsetMatrix, this[PRIVATE$3].quat, this[PRIVATE$3].vec3);
|
|
3892
3987
|
}
|
|
3893
3988
|
processRawInputData(inputDataRaw) {
|
|
3894
3989
|
const index = inputDataRaw[0];
|
|
3895
|
-
const schema = this[PRIVATE$
|
|
3990
|
+
const schema = this[PRIVATE$3].inputSchemas.get(index);
|
|
3896
3991
|
const targetRayTransform = inputDataRaw.slice(1, 8);
|
|
3897
3992
|
const inputData = { targetRayTransform };
|
|
3898
3993
|
let dataCounter = 8;
|
|
@@ -3911,7 +4006,7 @@
|
|
|
3911
4006
|
}
|
|
3912
4007
|
}
|
|
3913
4008
|
|
|
3914
|
-
const VERSION = "1.0.
|
|
4009
|
+
const VERSION = "1.0.2";
|
|
3915
4010
|
|
|
3916
4011
|
/**
|
|
3917
4012
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
@@ -3930,75 +4025,6 @@
|
|
|
3930
4025
|
}
|
|
3931
4026
|
}
|
|
3932
4027
|
|
|
3933
|
-
/**
|
|
3934
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3935
|
-
*
|
|
3936
|
-
* This source code is licensed under the MIT license found in the
|
|
3937
|
-
* LICENSE file in the root directory of this source tree.
|
|
3938
|
-
*/
|
|
3939
|
-
const PRIVATE$3 = Symbol('@immersive-web-emulation-runtime/xr-system');
|
|
3940
|
-
class XRSystem extends EventTarget {
|
|
3941
|
-
constructor(device) {
|
|
3942
|
-
super();
|
|
3943
|
-
this[PRIVATE$3] = { device };
|
|
3944
|
-
// Initialize device change monitoring here if applicable
|
|
3945
|
-
}
|
|
3946
|
-
isSessionSupported(mode) {
|
|
3947
|
-
return new Promise((resolve, _reject) => {
|
|
3948
|
-
if (mode === XRSessionMode.Inline) {
|
|
3949
|
-
resolve(true);
|
|
3950
|
-
}
|
|
3951
|
-
else {
|
|
3952
|
-
// Check for spatial tracking permission if necessary
|
|
3953
|
-
resolve(this[PRIVATE$3].device.supportedSessionModes.includes(mode));
|
|
3954
|
-
}
|
|
3955
|
-
});
|
|
3956
|
-
}
|
|
3957
|
-
requestSession(mode, options = {}) {
|
|
3958
|
-
return new Promise((resolve, reject) => {
|
|
3959
|
-
this.isSessionSupported(mode)
|
|
3960
|
-
.then((isSupported) => {
|
|
3961
|
-
if (!isSupported) {
|
|
3962
|
-
reject(new DOMException('The requested XRSession mode is not supported.', 'NotSupportedError'));
|
|
3963
|
-
return;
|
|
3964
|
-
}
|
|
3965
|
-
// Check for active sessions and other constraints here
|
|
3966
|
-
if (this[PRIVATE$3].activeSession) {
|
|
3967
|
-
reject(new DOMException('An active XRSession already exists.', 'InvalidStateError'));
|
|
3968
|
-
return;
|
|
3969
|
-
}
|
|
3970
|
-
// Handle required and optional features
|
|
3971
|
-
const { requiredFeatures = [], optionalFeatures = [] } = options;
|
|
3972
|
-
const { supportedFeatures } = this[PRIVATE$3].device;
|
|
3973
|
-
// Check if all required features are supported
|
|
3974
|
-
const allRequiredSupported = requiredFeatures.every((feature) => supportedFeatures.includes(feature));
|
|
3975
|
-
if (!allRequiredSupported) {
|
|
3976
|
-
reject(new Error('One or more required features are not supported by the device.'));
|
|
3977
|
-
return;
|
|
3978
|
-
}
|
|
3979
|
-
// Filter out unsupported optional features
|
|
3980
|
-
const supportedOptionalFeatures = optionalFeatures.filter((feature) => supportedFeatures.includes(feature));
|
|
3981
|
-
// Combine required and supported optional features into enabled features
|
|
3982
|
-
const enabledFeatures = Array.from(new Set([
|
|
3983
|
-
...requiredFeatures,
|
|
3984
|
-
...supportedOptionalFeatures,
|
|
3985
|
-
WebXRFeatures.Viewer,
|
|
3986
|
-
WebXRFeatures.Local,
|
|
3987
|
-
]));
|
|
3988
|
-
// Proceed with session creation
|
|
3989
|
-
const session = new XRSession(this[PRIVATE$3].device, mode, enabledFeatures);
|
|
3990
|
-
this[PRIVATE$3].activeSession = session;
|
|
3991
|
-
// Listen for session end to clear the active session
|
|
3992
|
-
session.addEventListener('end', () => {
|
|
3993
|
-
this[PRIVATE$3].activeSession = undefined;
|
|
3994
|
-
});
|
|
3995
|
-
resolve(session);
|
|
3996
|
-
})
|
|
3997
|
-
.catch(reject);
|
|
3998
|
-
});
|
|
3999
|
-
}
|
|
4000
|
-
}
|
|
4001
|
-
|
|
4002
4028
|
/**
|
|
4003
4029
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4004
4030
|
*
|
|
@@ -4099,6 +4125,7 @@
|
|
|
4099
4125
|
supportedFrameRates: deviceConfig.supportedFrameRates,
|
|
4100
4126
|
isSystemKeyboardSupported: deviceConfig.isSystemKeyboardSupported,
|
|
4101
4127
|
internalNominalFrameRate: deviceConfig.internalNominalFrameRate,
|
|
4128
|
+
userAgent: deviceConfig.userAgent,
|
|
4102
4129
|
position: (_b = deviceOptions.headsetPosition) !== null && _b !== void 0 ? _b : DEFAULTS.headsetPosition.clone(),
|
|
4103
4130
|
quaternion: (_c = deviceOptions.headsetQuaternion) !== null && _c !== void 0 ? _c : DEFAULTS.headsetQuaternion.clone(),
|
|
4104
4131
|
stereoEnabled: (_d = deviceOptions.stereoEnabled) !== null && _d !== void 0 ? _d : DEFAULTS.stereoEnabled,
|
|
@@ -4110,6 +4137,7 @@
|
|
|
4110
4137
|
pendingReferenceSpaceReset: false,
|
|
4111
4138
|
visibilityState: XRVisibilityState.Visible,
|
|
4112
4139
|
pendingVisibilityState: null,
|
|
4140
|
+
xrSystem: null,
|
|
4113
4141
|
matrix: create$3(),
|
|
4114
4142
|
globalSpace,
|
|
4115
4143
|
viewerSpace,
|
|
@@ -4130,10 +4158,10 @@
|
|
|
4130
4158
|
updateViews: () => {
|
|
4131
4159
|
// update viewerSpace
|
|
4132
4160
|
const viewerSpace = this[PRIVATE$1].viewerSpace;
|
|
4133
|
-
fromRotationTranslation(viewerSpace[PRIVATE$
|
|
4161
|
+
fromRotationTranslation(viewerSpace[PRIVATE$l].offsetMatrix, this[PRIVATE$1].quaternion.quat, this[PRIVATE$1].position.vec3);
|
|
4134
4162
|
// update viewSpaces
|
|
4135
|
-
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Left][PRIVATE$
|
|
4136
|
-
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Right][PRIVATE$
|
|
4163
|
+
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Left][PRIVATE$l].offsetMatrix, fromValues$2(-this[PRIVATE$1].ipd / 2, 0, 0));
|
|
4164
|
+
fromTranslation(this[PRIVATE$1].viewSpaces[XREye.Right][PRIVATE$l].offsetMatrix, fromValues$2(this[PRIVATE$1].ipd / 2, 0, 0));
|
|
4137
4165
|
},
|
|
4138
4166
|
onBaseLayerSet: (baseLayer) => {
|
|
4139
4167
|
if (!baseLayer)
|
|
@@ -4215,10 +4243,17 @@
|
|
|
4215
4243
|
},
|
|
4216
4244
|
configurable: true,
|
|
4217
4245
|
});
|
|
4246
|
+
this[PRIVATE$1].xrSystem = new XRSystem(this);
|
|
4218
4247
|
Object.defineProperty(globalThis.navigator, 'xr', {
|
|
4219
|
-
value:
|
|
4248
|
+
value: this[PRIVATE$1].xrSystem,
|
|
4220
4249
|
configurable: true,
|
|
4221
4250
|
});
|
|
4251
|
+
Object.defineProperty(navigator, 'userAgent', {
|
|
4252
|
+
value: this[PRIVATE$1].userAgent,
|
|
4253
|
+
writable: false,
|
|
4254
|
+
configurable: false,
|
|
4255
|
+
enumerable: true,
|
|
4256
|
+
});
|
|
4222
4257
|
globalObject['XRSystem'] = XRSystem;
|
|
4223
4258
|
globalObject['XRSession'] = XRSession;
|
|
4224
4259
|
globalObject['XRRenderState'] = XRRenderState;
|
|
@@ -4336,6 +4371,10 @@
|
|
|
4336
4371
|
get canvasContainer() {
|
|
4337
4372
|
return this[PRIVATE$1].canvasContainer;
|
|
4338
4373
|
}
|
|
4374
|
+
get activeSession() {
|
|
4375
|
+
var _a;
|
|
4376
|
+
return (_a = this[PRIVATE$1].xrSystem) === null || _a === void 0 ? void 0 : _a[PRIVATE$4].activeSession;
|
|
4377
|
+
}
|
|
4339
4378
|
recenter() {
|
|
4340
4379
|
const deltaVec = new Vector3(-this.position.x, 0, -this.position.z);
|
|
4341
4380
|
const forward = new Vector3(0, 0, -1).applyQuaternion(this.quaternion);
|
|
@@ -4555,6 +4594,7 @@
|
|
|
4555
4594
|
supportedFrameRates: [72, 80, 90],
|
|
4556
4595
|
isSystemKeyboardSupported: true,
|
|
4557
4596
|
internalNominalFrameRate: 72,
|
|
4597
|
+
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',
|
|
4558
4598
|
};
|
|
4559
4599
|
const metaQuest2 = {
|
|
4560
4600
|
name: 'Meta Quest 2',
|
|
@@ -4579,6 +4619,7 @@
|
|
|
4579
4619
|
supportedFrameRates: [72, 80, 90, 120],
|
|
4580
4620
|
isSystemKeyboardSupported: true,
|
|
4581
4621
|
internalNominalFrameRate: 72,
|
|
4622
|
+
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',
|
|
4582
4623
|
};
|
|
4583
4624
|
const metaQuestPro = {
|
|
4584
4625
|
name: 'Meta Quest Pro',
|
|
@@ -4603,6 +4644,7 @@
|
|
|
4603
4644
|
supportedFrameRates: [72, 80, 90, 120],
|
|
4604
4645
|
isSystemKeyboardSupported: true,
|
|
4605
4646
|
internalNominalFrameRate: 90,
|
|
4647
|
+
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',
|
|
4606
4648
|
};
|
|
4607
4649
|
const metaQuest3 = {
|
|
4608
4650
|
name: 'Meta Quest 3',
|
|
@@ -4628,6 +4670,7 @@
|
|
|
4628
4670
|
supportedFrameRates: [72, 80, 90, 120],
|
|
4629
4671
|
isSystemKeyboardSupported: true,
|
|
4630
4672
|
internalNominalFrameRate: 90,
|
|
4673
|
+
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',
|
|
4631
4674
|
};
|
|
4632
4675
|
|
|
4633
4676
|
/**
|