quake2ts 0.0.574 → 0.0.577
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/package.json +5 -4
- package/packages/test-utils/dist/index.cjs +672 -87
- package/packages/test-utils/dist/index.cjs.map +1 -1
- package/packages/test-utils/dist/index.d.cts +139 -17
- package/packages/test-utils/dist/index.d.ts +139 -17
- package/packages/test-utils/dist/index.js +667 -87
- package/packages/test-utils/dist/index.js.map +1 -1
|
@@ -50,13 +50,16 @@ __export(index_exports, {
|
|
|
50
50
|
createEntityFactory: () => createEntityFactory,
|
|
51
51
|
createEntityStateFactory: () => createEntityStateFactory,
|
|
52
52
|
createGameStateSnapshotFactory: () => createGameStateSnapshotFactory,
|
|
53
|
+
createInputInjector: () => createInputInjector,
|
|
53
54
|
createItemEntityFactory: () => createItemEntityFactory,
|
|
54
55
|
createMockAI: () => createMockAI,
|
|
55
56
|
createMockAmmoItem: () => createMockAmmoItem,
|
|
56
57
|
createMockArmorItem: () => createMockArmorItem,
|
|
57
58
|
createMockAudioContext: () => createMockAudioContext,
|
|
59
|
+
createMockCamera: () => createMockCamera,
|
|
58
60
|
createMockCanvas: () => createMockCanvas,
|
|
59
61
|
createMockCanvasContext2D: () => createMockCanvasContext2D,
|
|
62
|
+
createMockCollisionEntityIndex: () => createMockCollisionEntityIndex,
|
|
60
63
|
createMockConnection: () => createMockConnection,
|
|
61
64
|
createMockDamageInfo: () => createMockDamageInfo,
|
|
62
65
|
createMockEngine: () => createMockEngine,
|
|
@@ -73,17 +76,21 @@ __export(index_exports, {
|
|
|
73
76
|
createMockIndexedDB: () => createMockIndexedDB,
|
|
74
77
|
createMockInventory: () => createMockInventory,
|
|
75
78
|
createMockItem: () => createMockItem,
|
|
79
|
+
createMockKeyboardEvent: () => createMockKeyboardEvent,
|
|
76
80
|
createMockLocalStorage: () => createMockLocalStorage,
|
|
77
81
|
createMockMasterServer: () => createMockMasterServer,
|
|
78
82
|
createMockMonsterAI: () => createMockMonsterAI,
|
|
79
83
|
createMockMonsterMove: () => createMockMonsterMove,
|
|
84
|
+
createMockMouseEvent: () => createMockMouseEvent,
|
|
80
85
|
createMockNetDriver: () => createMockNetDriver,
|
|
81
86
|
createMockNetworkAddress: () => createMockNetworkAddress,
|
|
82
87
|
createMockPerformance: () => createMockPerformance,
|
|
88
|
+
createMockPointerLock: () => createMockPointerLock,
|
|
83
89
|
createMockPowerupItem: () => createMockPowerupItem,
|
|
84
90
|
createMockRAF: () => createMockRAF,
|
|
85
91
|
createMockRConClient: () => createMockRConClient,
|
|
86
92
|
createMockRateLimiter: () => createMockRateLimiter,
|
|
93
|
+
createMockRefDef: () => createMockRefDef,
|
|
87
94
|
createMockServer: () => createMockServer,
|
|
88
95
|
createMockServerClient: () => createMockServerClient,
|
|
89
96
|
createMockServerConsole: () => createMockServerConsole,
|
|
@@ -94,9 +101,11 @@ __export(index_exports, {
|
|
|
94
101
|
createMockTransport: () => createMockTransport,
|
|
95
102
|
createMockUDPSocket: () => createMockUDPSocket,
|
|
96
103
|
createMockUserInfo: () => createMockUserInfo,
|
|
104
|
+
createMockViewState: () => createMockViewState,
|
|
97
105
|
createMockWeapon: () => createMockWeapon,
|
|
98
106
|
createMockWeaponItem: () => createMockWeaponItem,
|
|
99
107
|
createMockWebGL2Context: () => createMockWebGL2Context,
|
|
108
|
+
createMockWheelEvent: () => createMockWheelEvent,
|
|
100
109
|
createMonsterEntityFactory: () => createMonsterEntityFactory,
|
|
101
110
|
createMultiplayerTestScenario: () => createMultiplayerTestScenario,
|
|
102
111
|
createNetChanMock: () => createNetChanMock,
|
|
@@ -110,6 +119,7 @@ __export(index_exports, {
|
|
|
110
119
|
createStorageTestScenario: () => createStorageTestScenario,
|
|
111
120
|
createTestContext: () => createTestContext,
|
|
112
121
|
createTriggerEntityFactory: () => createTriggerEntityFactory,
|
|
122
|
+
createViewTestScenario: () => createViewTestScenario,
|
|
113
123
|
createVisualTestScenario: () => createVisualTestScenario,
|
|
114
124
|
intersects: () => import_shared3.intersects,
|
|
115
125
|
ladderTrace: () => import_shared3.ladderTrace,
|
|
@@ -128,6 +138,7 @@ __export(index_exports, {
|
|
|
128
138
|
setupNodeEnvironment: () => setupNodeEnvironment,
|
|
129
139
|
setupWebGPUMocks: () => setupWebGPUMocks,
|
|
130
140
|
simulateBandwidthLimit: () => simulateBandwidthLimit,
|
|
141
|
+
simulateCameraMovement: () => simulateCameraMovement,
|
|
131
142
|
simulateFrames: () => simulateFrames,
|
|
132
143
|
simulateFramesWithMock: () => simulateFramesWithMock,
|
|
133
144
|
simulateHandshake: () => simulateHandshake,
|
|
@@ -224,17 +235,17 @@ var createBinaryStreamMock = () => ({
|
|
|
224
235
|
readCoord: import_vitest.vi.fn(() => 0),
|
|
225
236
|
readAngle: import_vitest.vi.fn(() => 0),
|
|
226
237
|
readAngle16: import_vitest.vi.fn(() => 0),
|
|
227
|
-
readData: import_vitest.vi.fn((
|
|
238
|
+
readData: import_vitest.vi.fn((length2) => new Uint8Array(length2)),
|
|
228
239
|
readPos: import_vitest.vi.fn(),
|
|
229
240
|
readDir: import_vitest.vi.fn()
|
|
230
241
|
});
|
|
231
242
|
|
|
232
243
|
// src/shared/bsp.ts
|
|
233
244
|
var import_shared = require("@quake2ts/shared");
|
|
234
|
-
function makePlane(normal,
|
|
245
|
+
function makePlane(normal, dist2) {
|
|
235
246
|
return {
|
|
236
247
|
normal,
|
|
237
|
-
dist,
|
|
248
|
+
dist: dist2,
|
|
238
249
|
type: Math.abs(normal.x) === 1 ? 0 : Math.abs(normal.y) === 1 ? 1 : Math.abs(normal.z) === 1 ? 2 : 3,
|
|
239
250
|
signbits: (0, import_shared.computePlaneSignBits)(normal)
|
|
240
251
|
};
|
|
@@ -1253,6 +1264,24 @@ async function simulateServerRegistration(server, master) {
|
|
|
1253
1264
|
return master.registerServer(info);
|
|
1254
1265
|
}
|
|
1255
1266
|
|
|
1267
|
+
// src/server/mocks/physics.ts
|
|
1268
|
+
var import_vitest9 = require("vitest");
|
|
1269
|
+
function createMockCollisionEntityIndex(overrides) {
|
|
1270
|
+
return {
|
|
1271
|
+
trace: import_vitest9.vi.fn().mockReturnValue({
|
|
1272
|
+
fraction: 1,
|
|
1273
|
+
allsolid: false,
|
|
1274
|
+
startsolid: false,
|
|
1275
|
+
endpos: { x: 0, y: 0, z: 0 },
|
|
1276
|
+
entityId: null
|
|
1277
|
+
}),
|
|
1278
|
+
link: import_vitest9.vi.fn(),
|
|
1279
|
+
unlink: import_vitest9.vi.fn(),
|
|
1280
|
+
gatherTriggerTouches: import_vitest9.vi.fn().mockReturnValue([]),
|
|
1281
|
+
...overrides
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1256
1285
|
// src/server/helpers/multiplayer.ts
|
|
1257
1286
|
var import_server3 = require("@quake2ts/server");
|
|
1258
1287
|
function createMultiplayerTestScenario(numPlayers = 2) {
|
|
@@ -1475,10 +1504,54 @@ var import_jsdom = require("jsdom");
|
|
|
1475
1504
|
var import_canvas = require("@napi-rs/canvas");
|
|
1476
1505
|
var import_auto = require("fake-indexeddb/auto");
|
|
1477
1506
|
|
|
1478
|
-
// src/
|
|
1507
|
+
// src/client/mocks/input.ts
|
|
1508
|
+
function createMockKeyboardEvent(key, type = "keydown", modifiers = {}) {
|
|
1509
|
+
return new KeyboardEvent(type, {
|
|
1510
|
+
key,
|
|
1511
|
+
code: key,
|
|
1512
|
+
// Default code to key if not specified (caller can override property if needed)
|
|
1513
|
+
ctrlKey: modifiers.ctrl,
|
|
1514
|
+
altKey: modifiers.alt,
|
|
1515
|
+
shiftKey: modifiers.shift,
|
|
1516
|
+
metaKey: modifiers.meta,
|
|
1517
|
+
bubbles: true,
|
|
1518
|
+
cancelable: true,
|
|
1519
|
+
view: window
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
function createMockMouseEvent(type, options = {}) {
|
|
1523
|
+
const event = new MouseEvent(type, {
|
|
1524
|
+
bubbles: true,
|
|
1525
|
+
cancelable: true,
|
|
1526
|
+
view: window,
|
|
1527
|
+
...options
|
|
1528
|
+
});
|
|
1529
|
+
if (options.movementX !== void 0) {
|
|
1530
|
+
Object.defineProperty(event, "movementX", { value: options.movementX });
|
|
1531
|
+
}
|
|
1532
|
+
if (options.movementY !== void 0) {
|
|
1533
|
+
Object.defineProperty(event, "movementY", { value: options.movementY });
|
|
1534
|
+
}
|
|
1535
|
+
return event;
|
|
1536
|
+
}
|
|
1537
|
+
function createMockWheelEvent(deltaX = 0, deltaY = 0) {
|
|
1538
|
+
return new WheelEvent("wheel", {
|
|
1539
|
+
deltaX,
|
|
1540
|
+
deltaY,
|
|
1541
|
+
bubbles: true,
|
|
1542
|
+
cancelable: true,
|
|
1543
|
+
view: window
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1479
1546
|
var MockPointerLock = class {
|
|
1480
|
-
|
|
1547
|
+
constructor(doc = document) {
|
|
1548
|
+
this._doc = doc;
|
|
1549
|
+
this.setup();
|
|
1550
|
+
}
|
|
1551
|
+
setup() {
|
|
1552
|
+
if (this._doc.__mockPointerLockInstalled) return;
|
|
1481
1553
|
let _pointerLockElement = null;
|
|
1554
|
+
const doc = this._doc;
|
|
1482
1555
|
Object.defineProperty(doc, "pointerLockElement", {
|
|
1483
1556
|
get: () => _pointerLockElement,
|
|
1484
1557
|
configurable: true
|
|
@@ -1489,84 +1562,99 @@ var MockPointerLock = class {
|
|
|
1489
1562
|
doc.dispatchEvent(new Event("pointerlockchange"));
|
|
1490
1563
|
}
|
|
1491
1564
|
};
|
|
1565
|
+
if (!global.HTMLElement.prototype.__originalRequestPointerLock) {
|
|
1566
|
+
global.HTMLElement.prototype.__originalRequestPointerLock = global.HTMLElement.prototype.requestPointerLock;
|
|
1567
|
+
}
|
|
1492
1568
|
global.HTMLElement.prototype.requestPointerLock = function() {
|
|
1493
1569
|
_pointerLockElement = this;
|
|
1494
1570
|
doc.dispatchEvent(new Event("pointerlockchange"));
|
|
1495
1571
|
};
|
|
1572
|
+
doc.__mockPointerLockInstalled = true;
|
|
1573
|
+
}
|
|
1574
|
+
get element() {
|
|
1575
|
+
return this._doc.pointerLockElement;
|
|
1576
|
+
}
|
|
1577
|
+
get locked() {
|
|
1578
|
+
return !!this.element;
|
|
1579
|
+
}
|
|
1580
|
+
request(element) {
|
|
1581
|
+
element.requestPointerLock();
|
|
1582
|
+
}
|
|
1583
|
+
exit() {
|
|
1584
|
+
this._doc.exitPointerLock();
|
|
1585
|
+
}
|
|
1586
|
+
isLocked() {
|
|
1587
|
+
return this.locked;
|
|
1496
1588
|
}
|
|
1497
1589
|
};
|
|
1498
1590
|
var InputInjector = class {
|
|
1499
|
-
constructor(doc, win) {
|
|
1591
|
+
constructor(doc = document, win = window) {
|
|
1500
1592
|
this.doc = doc;
|
|
1501
1593
|
this.win = win;
|
|
1502
1594
|
}
|
|
1503
|
-
keyDown(key, code) {
|
|
1504
|
-
const event =
|
|
1505
|
-
|
|
1506
|
-
code: code
|
|
1507
|
-
|
|
1508
|
-
cancelable: true,
|
|
1509
|
-
view: this.win
|
|
1510
|
-
});
|
|
1595
|
+
keyDown(key, code, modifiers) {
|
|
1596
|
+
const event = createMockKeyboardEvent(key, "keydown", modifiers);
|
|
1597
|
+
if (code) {
|
|
1598
|
+
Object.defineProperty(event, "code", { value: code });
|
|
1599
|
+
}
|
|
1511
1600
|
this.doc.dispatchEvent(event);
|
|
1512
1601
|
}
|
|
1513
|
-
keyUp(key, code) {
|
|
1514
|
-
const event =
|
|
1515
|
-
|
|
1516
|
-
code: code
|
|
1517
|
-
|
|
1518
|
-
cancelable: true,
|
|
1519
|
-
view: this.win
|
|
1520
|
-
});
|
|
1602
|
+
keyUp(key, code, modifiers) {
|
|
1603
|
+
const event = createMockKeyboardEvent(key, "keyup", modifiers);
|
|
1604
|
+
if (code) {
|
|
1605
|
+
Object.defineProperty(event, "code", { value: code });
|
|
1606
|
+
}
|
|
1521
1607
|
this.doc.dispatchEvent(event);
|
|
1522
1608
|
}
|
|
1523
1609
|
mouseMove(movementX, movementY, clientX = 0, clientY = 0) {
|
|
1524
|
-
const event =
|
|
1525
|
-
bubbles: true,
|
|
1526
|
-
cancelable: true,
|
|
1527
|
-
view: this.win,
|
|
1610
|
+
const event = createMockMouseEvent("mousemove", {
|
|
1528
1611
|
clientX,
|
|
1529
1612
|
clientY,
|
|
1530
1613
|
movementX,
|
|
1531
|
-
// Note: JSDOM might not support this standard property fully on event init
|
|
1532
1614
|
movementY
|
|
1533
1615
|
});
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1616
|
+
this.dispatchToTarget(event);
|
|
1617
|
+
}
|
|
1618
|
+
mouseButton(button, state = "down") {
|
|
1619
|
+
if (state === "down") {
|
|
1620
|
+
this.mouseDown(button);
|
|
1621
|
+
} else {
|
|
1622
|
+
this.mouseUp(button);
|
|
1623
|
+
}
|
|
1538
1624
|
}
|
|
1539
1625
|
mouseDown(button = 0) {
|
|
1540
|
-
const event =
|
|
1541
|
-
|
|
1542
|
-
bubbles: true,
|
|
1543
|
-
cancelable: true,
|
|
1544
|
-
view: this.win
|
|
1545
|
-
});
|
|
1546
|
-
const target = this.doc.pointerLockElement || this.doc;
|
|
1547
|
-
target.dispatchEvent(event);
|
|
1626
|
+
const event = createMockMouseEvent("mousedown", { button });
|
|
1627
|
+
this.dispatchToTarget(event);
|
|
1548
1628
|
}
|
|
1549
1629
|
mouseUp(button = 0) {
|
|
1550
|
-
const event =
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
const target = this.doc.pointerLockElement || this.doc;
|
|
1557
|
-
target.dispatchEvent(event);
|
|
1630
|
+
const event = createMockMouseEvent("mouseup", { button });
|
|
1631
|
+
this.dispatchToTarget(event);
|
|
1632
|
+
}
|
|
1633
|
+
mouseWheel(deltaY) {
|
|
1634
|
+
const event = createMockWheelEvent(0, deltaY);
|
|
1635
|
+
this.dispatchToTarget(event);
|
|
1558
1636
|
}
|
|
1637
|
+
// Alias for backward compatibility/ease of use
|
|
1559
1638
|
wheel(deltaY) {
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
cancelable: true,
|
|
1564
|
-
view: this.win
|
|
1565
|
-
});
|
|
1639
|
+
this.mouseWheel(deltaY);
|
|
1640
|
+
}
|
|
1641
|
+
dispatchToTarget(event) {
|
|
1566
1642
|
const target = this.doc.pointerLockElement || this.doc;
|
|
1567
1643
|
target.dispatchEvent(event);
|
|
1568
1644
|
}
|
|
1569
1645
|
};
|
|
1646
|
+
function createMockPointerLock(element) {
|
|
1647
|
+
const mock = new MockPointerLock();
|
|
1648
|
+
if (element) {
|
|
1649
|
+
mock.request(element);
|
|
1650
|
+
}
|
|
1651
|
+
return mock;
|
|
1652
|
+
}
|
|
1653
|
+
function createInputInjector(target) {
|
|
1654
|
+
const doc = target instanceof Document ? target : document;
|
|
1655
|
+
const win = doc.defaultView ? doc.defaultView : window;
|
|
1656
|
+
return new InputInjector(doc, win);
|
|
1657
|
+
}
|
|
1570
1658
|
|
|
1571
1659
|
// src/setup/webgl.ts
|
|
1572
1660
|
function createMockWebGL2Context(canvas) {
|
|
@@ -1815,17 +1903,17 @@ function setupBrowserEnvironment(options = {}) {
|
|
|
1815
1903
|
};
|
|
1816
1904
|
}
|
|
1817
1905
|
if (typeof global.btoa === "undefined") {
|
|
1818
|
-
global.btoa = function(
|
|
1819
|
-
return Buffer.from(
|
|
1906
|
+
global.btoa = function(str2) {
|
|
1907
|
+
return Buffer.from(str2, "binary").toString("base64");
|
|
1820
1908
|
};
|
|
1821
1909
|
}
|
|
1822
1910
|
if (typeof global.atob === "undefined") {
|
|
1823
|
-
global.atob = function(
|
|
1824
|
-
return Buffer.from(
|
|
1911
|
+
global.atob = function(str2) {
|
|
1912
|
+
return Buffer.from(str2, "base64").toString("binary");
|
|
1825
1913
|
};
|
|
1826
1914
|
}
|
|
1827
1915
|
if (enablePointerLock) {
|
|
1828
|
-
MockPointerLock
|
|
1916
|
+
new MockPointerLock(global.document);
|
|
1829
1917
|
}
|
|
1830
1918
|
if (typeof global.requestAnimationFrame === "undefined") {
|
|
1831
1919
|
let lastTime = 0;
|
|
@@ -1947,10 +2035,10 @@ function createMockImage(width, height, src) {
|
|
|
1947
2035
|
}
|
|
1948
2036
|
|
|
1949
2037
|
// src/engine/mocks/webgpu.ts
|
|
1950
|
-
var
|
|
2038
|
+
var import_vitest10 = require("vitest");
|
|
1951
2039
|
function createMockGPUAdapter() {
|
|
1952
2040
|
return {
|
|
1953
|
-
requestDevice:
|
|
2041
|
+
requestDevice: import_vitest10.vi.fn().mockResolvedValue(createMockGPUDevice()),
|
|
1954
2042
|
features: /* @__PURE__ */ new Set(),
|
|
1955
2043
|
limits: {}
|
|
1956
2044
|
};
|
|
@@ -1960,40 +2048,40 @@ function createMockGPUDevice() {
|
|
|
1960
2048
|
features: /* @__PURE__ */ new Set(),
|
|
1961
2049
|
limits: {},
|
|
1962
2050
|
queue: {
|
|
1963
|
-
submit:
|
|
1964
|
-
writeBuffer:
|
|
1965
|
-
writeTexture:
|
|
1966
|
-
copyExternalImageToTexture:
|
|
1967
|
-
},
|
|
1968
|
-
createCommandEncoder:
|
|
1969
|
-
beginRenderPass:
|
|
1970
|
-
setPipeline:
|
|
1971
|
-
draw:
|
|
1972
|
-
end:
|
|
2051
|
+
submit: import_vitest10.vi.fn(),
|
|
2052
|
+
writeBuffer: import_vitest10.vi.fn(),
|
|
2053
|
+
writeTexture: import_vitest10.vi.fn(),
|
|
2054
|
+
copyExternalImageToTexture: import_vitest10.vi.fn()
|
|
2055
|
+
},
|
|
2056
|
+
createCommandEncoder: import_vitest10.vi.fn().mockReturnValue({
|
|
2057
|
+
beginRenderPass: import_vitest10.vi.fn().mockReturnValue({
|
|
2058
|
+
setPipeline: import_vitest10.vi.fn(),
|
|
2059
|
+
draw: import_vitest10.vi.fn(),
|
|
2060
|
+
end: import_vitest10.vi.fn()
|
|
1973
2061
|
}),
|
|
1974
|
-
finish:
|
|
2062
|
+
finish: import_vitest10.vi.fn()
|
|
1975
2063
|
}),
|
|
1976
|
-
createRenderPipeline:
|
|
1977
|
-
createShaderModule:
|
|
1978
|
-
createBindGroup:
|
|
1979
|
-
createBindGroupLayout:
|
|
1980
|
-
createBuffer:
|
|
1981
|
-
createTexture:
|
|
1982
|
-
createSampler:
|
|
2064
|
+
createRenderPipeline: import_vitest10.vi.fn(),
|
|
2065
|
+
createShaderModule: import_vitest10.vi.fn(),
|
|
2066
|
+
createBindGroup: import_vitest10.vi.fn(),
|
|
2067
|
+
createBindGroupLayout: import_vitest10.vi.fn(),
|
|
2068
|
+
createBuffer: import_vitest10.vi.fn(),
|
|
2069
|
+
createTexture: import_vitest10.vi.fn(),
|
|
2070
|
+
createSampler: import_vitest10.vi.fn()
|
|
1983
2071
|
};
|
|
1984
2072
|
}
|
|
1985
2073
|
function createMockGPUCanvasContext() {
|
|
1986
2074
|
return {
|
|
1987
|
-
configure:
|
|
1988
|
-
unconfigure:
|
|
1989
|
-
getCurrentTexture:
|
|
2075
|
+
configure: import_vitest10.vi.fn(),
|
|
2076
|
+
unconfigure: import_vitest10.vi.fn(),
|
|
2077
|
+
getCurrentTexture: import_vitest10.vi.fn()
|
|
1990
2078
|
};
|
|
1991
2079
|
}
|
|
1992
2080
|
function setupWebGPUMocks() {
|
|
1993
2081
|
const mockAdapter = createMockGPUAdapter();
|
|
1994
2082
|
const mockGpu = {
|
|
1995
|
-
requestAdapter:
|
|
1996
|
-
getPreferredCanvasFormat:
|
|
2083
|
+
requestAdapter: import_vitest10.vi.fn().mockResolvedValue(mockAdapter),
|
|
2084
|
+
getPreferredCanvasFormat: import_vitest10.vi.fn().mockReturnValue("bgra8unorm")
|
|
1997
2085
|
};
|
|
1998
2086
|
Object.defineProperty(global.navigator, "gpu", {
|
|
1999
2087
|
value: mockGpu,
|
|
@@ -2336,12 +2424,12 @@ function createMockAudioContext() {
|
|
|
2336
2424
|
numberOfChannels: 2,
|
|
2337
2425
|
getChannelData: () => new Float32Array(44100)
|
|
2338
2426
|
}),
|
|
2339
|
-
createBuffer: (channels,
|
|
2340
|
-
duration:
|
|
2341
|
-
length,
|
|
2427
|
+
createBuffer: (channels, length2, sampleRate) => ({
|
|
2428
|
+
duration: length2 / sampleRate,
|
|
2429
|
+
length: length2,
|
|
2342
2430
|
sampleRate,
|
|
2343
2431
|
numberOfChannels: channels,
|
|
2344
|
-
getChannelData: () => new Float32Array(
|
|
2432
|
+
getChannelData: () => new Float32Array(length2)
|
|
2345
2433
|
}),
|
|
2346
2434
|
// Helper to track events if needed
|
|
2347
2435
|
_events: []
|
|
@@ -2382,6 +2470,492 @@ function captureAudioEvents(context) {
|
|
|
2382
2470
|
return context._events || [];
|
|
2383
2471
|
}
|
|
2384
2472
|
|
|
2473
|
+
// ../../node_modules/.pnpm/gl-matrix@3.4.4/node_modules/gl-matrix/esm/common.js
|
|
2474
|
+
var EPSILON = 1e-6;
|
|
2475
|
+
var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
|
|
2476
|
+
var RANDOM = Math.random;
|
|
2477
|
+
function round(a) {
|
|
2478
|
+
if (a >= 0) return Math.round(a);
|
|
2479
|
+
return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
|
|
2480
|
+
}
|
|
2481
|
+
var degree = Math.PI / 180;
|
|
2482
|
+
var radian = 180 / Math.PI;
|
|
2483
|
+
|
|
2484
|
+
// ../../node_modules/.pnpm/gl-matrix@3.4.4/node_modules/gl-matrix/esm/vec3.js
|
|
2485
|
+
var vec3_exports = {};
|
|
2486
|
+
__export(vec3_exports, {
|
|
2487
|
+
add: () => add,
|
|
2488
|
+
angle: () => angle,
|
|
2489
|
+
bezier: () => bezier,
|
|
2490
|
+
ceil: () => ceil,
|
|
2491
|
+
clone: () => clone,
|
|
2492
|
+
copy: () => copy,
|
|
2493
|
+
create: () => create,
|
|
2494
|
+
cross: () => cross,
|
|
2495
|
+
dist: () => dist,
|
|
2496
|
+
distance: () => distance,
|
|
2497
|
+
div: () => div,
|
|
2498
|
+
divide: () => divide,
|
|
2499
|
+
dot: () => dot,
|
|
2500
|
+
equals: () => equals,
|
|
2501
|
+
exactEquals: () => exactEquals,
|
|
2502
|
+
floor: () => floor,
|
|
2503
|
+
forEach: () => forEach,
|
|
2504
|
+
fromValues: () => fromValues,
|
|
2505
|
+
hermite: () => hermite,
|
|
2506
|
+
inverse: () => inverse,
|
|
2507
|
+
len: () => len,
|
|
2508
|
+
length: () => length,
|
|
2509
|
+
lerp: () => lerp,
|
|
2510
|
+
max: () => max,
|
|
2511
|
+
min: () => min,
|
|
2512
|
+
mul: () => mul,
|
|
2513
|
+
multiply: () => multiply,
|
|
2514
|
+
negate: () => negate,
|
|
2515
|
+
normalize: () => normalize,
|
|
2516
|
+
random: () => random,
|
|
2517
|
+
rotateX: () => rotateX,
|
|
2518
|
+
rotateY: () => rotateY,
|
|
2519
|
+
rotateZ: () => rotateZ,
|
|
2520
|
+
round: () => round2,
|
|
2521
|
+
scale: () => scale,
|
|
2522
|
+
scaleAndAdd: () => scaleAndAdd,
|
|
2523
|
+
set: () => set,
|
|
2524
|
+
slerp: () => slerp,
|
|
2525
|
+
sqrDist: () => sqrDist,
|
|
2526
|
+
sqrLen: () => sqrLen,
|
|
2527
|
+
squaredDistance: () => squaredDistance,
|
|
2528
|
+
squaredLength: () => squaredLength,
|
|
2529
|
+
str: () => str,
|
|
2530
|
+
sub: () => sub,
|
|
2531
|
+
subtract: () => subtract,
|
|
2532
|
+
transformMat3: () => transformMat3,
|
|
2533
|
+
transformMat4: () => transformMat4,
|
|
2534
|
+
transformQuat: () => transformQuat,
|
|
2535
|
+
zero: () => zero
|
|
2536
|
+
});
|
|
2537
|
+
function create() {
|
|
2538
|
+
var out = new ARRAY_TYPE(3);
|
|
2539
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
2540
|
+
out[0] = 0;
|
|
2541
|
+
out[1] = 0;
|
|
2542
|
+
out[2] = 0;
|
|
2543
|
+
}
|
|
2544
|
+
return out;
|
|
2545
|
+
}
|
|
2546
|
+
function clone(a) {
|
|
2547
|
+
var out = new ARRAY_TYPE(3);
|
|
2548
|
+
out[0] = a[0];
|
|
2549
|
+
out[1] = a[1];
|
|
2550
|
+
out[2] = a[2];
|
|
2551
|
+
return out;
|
|
2552
|
+
}
|
|
2553
|
+
function length(a) {
|
|
2554
|
+
var x = a[0];
|
|
2555
|
+
var y = a[1];
|
|
2556
|
+
var z = a[2];
|
|
2557
|
+
return Math.sqrt(x * x + y * y + z * z);
|
|
2558
|
+
}
|
|
2559
|
+
function fromValues(x, y, z) {
|
|
2560
|
+
var out = new ARRAY_TYPE(3);
|
|
2561
|
+
out[0] = x;
|
|
2562
|
+
out[1] = y;
|
|
2563
|
+
out[2] = z;
|
|
2564
|
+
return out;
|
|
2565
|
+
}
|
|
2566
|
+
function copy(out, a) {
|
|
2567
|
+
out[0] = a[0];
|
|
2568
|
+
out[1] = a[1];
|
|
2569
|
+
out[2] = a[2];
|
|
2570
|
+
return out;
|
|
2571
|
+
}
|
|
2572
|
+
function set(out, x, y, z) {
|
|
2573
|
+
out[0] = x;
|
|
2574
|
+
out[1] = y;
|
|
2575
|
+
out[2] = z;
|
|
2576
|
+
return out;
|
|
2577
|
+
}
|
|
2578
|
+
function add(out, a, b) {
|
|
2579
|
+
out[0] = a[0] + b[0];
|
|
2580
|
+
out[1] = a[1] + b[1];
|
|
2581
|
+
out[2] = a[2] + b[2];
|
|
2582
|
+
return out;
|
|
2583
|
+
}
|
|
2584
|
+
function subtract(out, a, b) {
|
|
2585
|
+
out[0] = a[0] - b[0];
|
|
2586
|
+
out[1] = a[1] - b[1];
|
|
2587
|
+
out[2] = a[2] - b[2];
|
|
2588
|
+
return out;
|
|
2589
|
+
}
|
|
2590
|
+
function multiply(out, a, b) {
|
|
2591
|
+
out[0] = a[0] * b[0];
|
|
2592
|
+
out[1] = a[1] * b[1];
|
|
2593
|
+
out[2] = a[2] * b[2];
|
|
2594
|
+
return out;
|
|
2595
|
+
}
|
|
2596
|
+
function divide(out, a, b) {
|
|
2597
|
+
out[0] = a[0] / b[0];
|
|
2598
|
+
out[1] = a[1] / b[1];
|
|
2599
|
+
out[2] = a[2] / b[2];
|
|
2600
|
+
return out;
|
|
2601
|
+
}
|
|
2602
|
+
function ceil(out, a) {
|
|
2603
|
+
out[0] = Math.ceil(a[0]);
|
|
2604
|
+
out[1] = Math.ceil(a[1]);
|
|
2605
|
+
out[2] = Math.ceil(a[2]);
|
|
2606
|
+
return out;
|
|
2607
|
+
}
|
|
2608
|
+
function floor(out, a) {
|
|
2609
|
+
out[0] = Math.floor(a[0]);
|
|
2610
|
+
out[1] = Math.floor(a[1]);
|
|
2611
|
+
out[2] = Math.floor(a[2]);
|
|
2612
|
+
return out;
|
|
2613
|
+
}
|
|
2614
|
+
function min(out, a, b) {
|
|
2615
|
+
out[0] = Math.min(a[0], b[0]);
|
|
2616
|
+
out[1] = Math.min(a[1], b[1]);
|
|
2617
|
+
out[2] = Math.min(a[2], b[2]);
|
|
2618
|
+
return out;
|
|
2619
|
+
}
|
|
2620
|
+
function max(out, a, b) {
|
|
2621
|
+
out[0] = Math.max(a[0], b[0]);
|
|
2622
|
+
out[1] = Math.max(a[1], b[1]);
|
|
2623
|
+
out[2] = Math.max(a[2], b[2]);
|
|
2624
|
+
return out;
|
|
2625
|
+
}
|
|
2626
|
+
function round2(out, a) {
|
|
2627
|
+
out[0] = round(a[0]);
|
|
2628
|
+
out[1] = round(a[1]);
|
|
2629
|
+
out[2] = round(a[2]);
|
|
2630
|
+
return out;
|
|
2631
|
+
}
|
|
2632
|
+
function scale(out, a, b) {
|
|
2633
|
+
out[0] = a[0] * b;
|
|
2634
|
+
out[1] = a[1] * b;
|
|
2635
|
+
out[2] = a[2] * b;
|
|
2636
|
+
return out;
|
|
2637
|
+
}
|
|
2638
|
+
function scaleAndAdd(out, a, b, scale2) {
|
|
2639
|
+
out[0] = a[0] + b[0] * scale2;
|
|
2640
|
+
out[1] = a[1] + b[1] * scale2;
|
|
2641
|
+
out[2] = a[2] + b[2] * scale2;
|
|
2642
|
+
return out;
|
|
2643
|
+
}
|
|
2644
|
+
function distance(a, b) {
|
|
2645
|
+
var x = b[0] - a[0];
|
|
2646
|
+
var y = b[1] - a[1];
|
|
2647
|
+
var z = b[2] - a[2];
|
|
2648
|
+
return Math.sqrt(x * x + y * y + z * z);
|
|
2649
|
+
}
|
|
2650
|
+
function squaredDistance(a, b) {
|
|
2651
|
+
var x = b[0] - a[0];
|
|
2652
|
+
var y = b[1] - a[1];
|
|
2653
|
+
var z = b[2] - a[2];
|
|
2654
|
+
return x * x + y * y + z * z;
|
|
2655
|
+
}
|
|
2656
|
+
function squaredLength(a) {
|
|
2657
|
+
var x = a[0];
|
|
2658
|
+
var y = a[1];
|
|
2659
|
+
var z = a[2];
|
|
2660
|
+
return x * x + y * y + z * z;
|
|
2661
|
+
}
|
|
2662
|
+
function negate(out, a) {
|
|
2663
|
+
out[0] = -a[0];
|
|
2664
|
+
out[1] = -a[1];
|
|
2665
|
+
out[2] = -a[2];
|
|
2666
|
+
return out;
|
|
2667
|
+
}
|
|
2668
|
+
function inverse(out, a) {
|
|
2669
|
+
out[0] = 1 / a[0];
|
|
2670
|
+
out[1] = 1 / a[1];
|
|
2671
|
+
out[2] = 1 / a[2];
|
|
2672
|
+
return out;
|
|
2673
|
+
}
|
|
2674
|
+
function normalize(out, a) {
|
|
2675
|
+
var x = a[0];
|
|
2676
|
+
var y = a[1];
|
|
2677
|
+
var z = a[2];
|
|
2678
|
+
var len2 = x * x + y * y + z * z;
|
|
2679
|
+
if (len2 > 0) {
|
|
2680
|
+
len2 = 1 / Math.sqrt(len2);
|
|
2681
|
+
}
|
|
2682
|
+
out[0] = a[0] * len2;
|
|
2683
|
+
out[1] = a[1] * len2;
|
|
2684
|
+
out[2] = a[2] * len2;
|
|
2685
|
+
return out;
|
|
2686
|
+
}
|
|
2687
|
+
function dot(a, b) {
|
|
2688
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
2689
|
+
}
|
|
2690
|
+
function cross(out, a, b) {
|
|
2691
|
+
var ax = a[0], ay = a[1], az = a[2];
|
|
2692
|
+
var bx = b[0], by = b[1], bz = b[2];
|
|
2693
|
+
out[0] = ay * bz - az * by;
|
|
2694
|
+
out[1] = az * bx - ax * bz;
|
|
2695
|
+
out[2] = ax * by - ay * bx;
|
|
2696
|
+
return out;
|
|
2697
|
+
}
|
|
2698
|
+
function lerp(out, a, b, t) {
|
|
2699
|
+
var ax = a[0];
|
|
2700
|
+
var ay = a[1];
|
|
2701
|
+
var az = a[2];
|
|
2702
|
+
out[0] = ax + t * (b[0] - ax);
|
|
2703
|
+
out[1] = ay + t * (b[1] - ay);
|
|
2704
|
+
out[2] = az + t * (b[2] - az);
|
|
2705
|
+
return out;
|
|
2706
|
+
}
|
|
2707
|
+
function slerp(out, a, b, t) {
|
|
2708
|
+
var angle2 = Math.acos(Math.min(Math.max(dot(a, b), -1), 1));
|
|
2709
|
+
var sinTotal = Math.sin(angle2);
|
|
2710
|
+
var ratioA = Math.sin((1 - t) * angle2) / sinTotal;
|
|
2711
|
+
var ratioB = Math.sin(t * angle2) / sinTotal;
|
|
2712
|
+
out[0] = ratioA * a[0] + ratioB * b[0];
|
|
2713
|
+
out[1] = ratioA * a[1] + ratioB * b[1];
|
|
2714
|
+
out[2] = ratioA * a[2] + ratioB * b[2];
|
|
2715
|
+
return out;
|
|
2716
|
+
}
|
|
2717
|
+
function hermite(out, a, b, c, d, t) {
|
|
2718
|
+
var factorTimes2 = t * t;
|
|
2719
|
+
var factor1 = factorTimes2 * (2 * t - 3) + 1;
|
|
2720
|
+
var factor2 = factorTimes2 * (t - 2) + t;
|
|
2721
|
+
var factor3 = factorTimes2 * (t - 1);
|
|
2722
|
+
var factor4 = factorTimes2 * (3 - 2 * t);
|
|
2723
|
+
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
|
|
2724
|
+
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
|
|
2725
|
+
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
|
|
2726
|
+
return out;
|
|
2727
|
+
}
|
|
2728
|
+
function bezier(out, a, b, c, d, t) {
|
|
2729
|
+
var inverseFactor = 1 - t;
|
|
2730
|
+
var inverseFactorTimesTwo = inverseFactor * inverseFactor;
|
|
2731
|
+
var factorTimes2 = t * t;
|
|
2732
|
+
var factor1 = inverseFactorTimesTwo * inverseFactor;
|
|
2733
|
+
var factor2 = 3 * t * inverseFactorTimesTwo;
|
|
2734
|
+
var factor3 = 3 * factorTimes2 * inverseFactor;
|
|
2735
|
+
var factor4 = factorTimes2 * t;
|
|
2736
|
+
out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
|
|
2737
|
+
out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
|
|
2738
|
+
out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
|
|
2739
|
+
return out;
|
|
2740
|
+
}
|
|
2741
|
+
function random(out, scale2) {
|
|
2742
|
+
scale2 = scale2 === void 0 ? 1 : scale2;
|
|
2743
|
+
var r = RANDOM() * 2 * Math.PI;
|
|
2744
|
+
var z = RANDOM() * 2 - 1;
|
|
2745
|
+
var zScale = Math.sqrt(1 - z * z) * scale2;
|
|
2746
|
+
out[0] = Math.cos(r) * zScale;
|
|
2747
|
+
out[1] = Math.sin(r) * zScale;
|
|
2748
|
+
out[2] = z * scale2;
|
|
2749
|
+
return out;
|
|
2750
|
+
}
|
|
2751
|
+
function transformMat4(out, a, m) {
|
|
2752
|
+
var x = a[0], y = a[1], z = a[2];
|
|
2753
|
+
var w = m[3] * x + m[7] * y + m[11] * z + m[15];
|
|
2754
|
+
w = w || 1;
|
|
2755
|
+
out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
|
|
2756
|
+
out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
|
|
2757
|
+
out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
|
|
2758
|
+
return out;
|
|
2759
|
+
}
|
|
2760
|
+
function transformMat3(out, a, m) {
|
|
2761
|
+
var x = a[0], y = a[1], z = a[2];
|
|
2762
|
+
out[0] = x * m[0] + y * m[3] + z * m[6];
|
|
2763
|
+
out[1] = x * m[1] + y * m[4] + z * m[7];
|
|
2764
|
+
out[2] = x * m[2] + y * m[5] + z * m[8];
|
|
2765
|
+
return out;
|
|
2766
|
+
}
|
|
2767
|
+
function transformQuat(out, a, q) {
|
|
2768
|
+
var qx = q[0], qy = q[1], qz = q[2], qw = q[3];
|
|
2769
|
+
var vx = a[0], vy = a[1], vz = a[2];
|
|
2770
|
+
var tx = qy * vz - qz * vy;
|
|
2771
|
+
var ty = qz * vx - qx * vz;
|
|
2772
|
+
var tz = qx * vy - qy * vx;
|
|
2773
|
+
tx = tx + tx;
|
|
2774
|
+
ty = ty + ty;
|
|
2775
|
+
tz = tz + tz;
|
|
2776
|
+
out[0] = vx + qw * tx + qy * tz - qz * ty;
|
|
2777
|
+
out[1] = vy + qw * ty + qz * tx - qx * tz;
|
|
2778
|
+
out[2] = vz + qw * tz + qx * ty - qy * tx;
|
|
2779
|
+
return out;
|
|
2780
|
+
}
|
|
2781
|
+
function rotateX(out, a, b, rad) {
|
|
2782
|
+
var p = [], r = [];
|
|
2783
|
+
p[0] = a[0] - b[0];
|
|
2784
|
+
p[1] = a[1] - b[1];
|
|
2785
|
+
p[2] = a[2] - b[2];
|
|
2786
|
+
r[0] = p[0];
|
|
2787
|
+
r[1] = p[1] * Math.cos(rad) - p[2] * Math.sin(rad);
|
|
2788
|
+
r[2] = p[1] * Math.sin(rad) + p[2] * Math.cos(rad);
|
|
2789
|
+
out[0] = r[0] + b[0];
|
|
2790
|
+
out[1] = r[1] + b[1];
|
|
2791
|
+
out[2] = r[2] + b[2];
|
|
2792
|
+
return out;
|
|
2793
|
+
}
|
|
2794
|
+
function rotateY(out, a, b, rad) {
|
|
2795
|
+
var p = [], r = [];
|
|
2796
|
+
p[0] = a[0] - b[0];
|
|
2797
|
+
p[1] = a[1] - b[1];
|
|
2798
|
+
p[2] = a[2] - b[2];
|
|
2799
|
+
r[0] = p[2] * Math.sin(rad) + p[0] * Math.cos(rad);
|
|
2800
|
+
r[1] = p[1];
|
|
2801
|
+
r[2] = p[2] * Math.cos(rad) - p[0] * Math.sin(rad);
|
|
2802
|
+
out[0] = r[0] + b[0];
|
|
2803
|
+
out[1] = r[1] + b[1];
|
|
2804
|
+
out[2] = r[2] + b[2];
|
|
2805
|
+
return out;
|
|
2806
|
+
}
|
|
2807
|
+
function rotateZ(out, a, b, rad) {
|
|
2808
|
+
var p = [], r = [];
|
|
2809
|
+
p[0] = a[0] - b[0];
|
|
2810
|
+
p[1] = a[1] - b[1];
|
|
2811
|
+
p[2] = a[2] - b[2];
|
|
2812
|
+
r[0] = p[0] * Math.cos(rad) - p[1] * Math.sin(rad);
|
|
2813
|
+
r[1] = p[0] * Math.sin(rad) + p[1] * Math.cos(rad);
|
|
2814
|
+
r[2] = p[2];
|
|
2815
|
+
out[0] = r[0] + b[0];
|
|
2816
|
+
out[1] = r[1] + b[1];
|
|
2817
|
+
out[2] = r[2] + b[2];
|
|
2818
|
+
return out;
|
|
2819
|
+
}
|
|
2820
|
+
function angle(a, b) {
|
|
2821
|
+
var ax = a[0], ay = a[1], az = a[2], bx = b[0], by = b[1], bz = b[2], mag = Math.sqrt((ax * ax + ay * ay + az * az) * (bx * bx + by * by + bz * bz)), cosine = mag && dot(a, b) / mag;
|
|
2822
|
+
return Math.acos(Math.min(Math.max(cosine, -1), 1));
|
|
2823
|
+
}
|
|
2824
|
+
function zero(out) {
|
|
2825
|
+
out[0] = 0;
|
|
2826
|
+
out[1] = 0;
|
|
2827
|
+
out[2] = 0;
|
|
2828
|
+
return out;
|
|
2829
|
+
}
|
|
2830
|
+
function str(a) {
|
|
2831
|
+
return "vec3(" + a[0] + ", " + a[1] + ", " + a[2] + ")";
|
|
2832
|
+
}
|
|
2833
|
+
function exactEquals(a, b) {
|
|
2834
|
+
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
|
|
2835
|
+
}
|
|
2836
|
+
function equals(a, b) {
|
|
2837
|
+
var a0 = a[0], a1 = a[1], a2 = a[2];
|
|
2838
|
+
var b0 = b[0], b1 = b[1], b2 = b[2];
|
|
2839
|
+
return Math.abs(a0 - b0) <= EPSILON * Math.max(1, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= EPSILON * Math.max(1, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= EPSILON * Math.max(1, Math.abs(a2), Math.abs(b2));
|
|
2840
|
+
}
|
|
2841
|
+
var sub = subtract;
|
|
2842
|
+
var mul = multiply;
|
|
2843
|
+
var div = divide;
|
|
2844
|
+
var dist = distance;
|
|
2845
|
+
var sqrDist = squaredDistance;
|
|
2846
|
+
var len = length;
|
|
2847
|
+
var sqrLen = squaredLength;
|
|
2848
|
+
var forEach = (function() {
|
|
2849
|
+
var vec = create();
|
|
2850
|
+
return function(a, stride, offset, count, fn, arg) {
|
|
2851
|
+
var i, l;
|
|
2852
|
+
if (!stride) {
|
|
2853
|
+
stride = 3;
|
|
2854
|
+
}
|
|
2855
|
+
if (!offset) {
|
|
2856
|
+
offset = 0;
|
|
2857
|
+
}
|
|
2858
|
+
if (count) {
|
|
2859
|
+
l = Math.min(count * stride + offset, a.length);
|
|
2860
|
+
} else {
|
|
2861
|
+
l = a.length;
|
|
2862
|
+
}
|
|
2863
|
+
for (i = offset; i < l; i += stride) {
|
|
2864
|
+
vec[0] = a[i];
|
|
2865
|
+
vec[1] = a[i + 1];
|
|
2866
|
+
vec[2] = a[i + 2];
|
|
2867
|
+
fn(vec, vec, arg);
|
|
2868
|
+
a[i] = vec[0];
|
|
2869
|
+
a[i + 1] = vec[1];
|
|
2870
|
+
a[i + 2] = vec[2];
|
|
2871
|
+
}
|
|
2872
|
+
return a;
|
|
2873
|
+
};
|
|
2874
|
+
})();
|
|
2875
|
+
|
|
2876
|
+
// src/client/helpers/view.ts
|
|
2877
|
+
var import_engine = require("@quake2ts/engine");
|
|
2878
|
+
function createMockCamera(overrides = {}) {
|
|
2879
|
+
const camera = new import_engine.Camera();
|
|
2880
|
+
if (overrides.position) {
|
|
2881
|
+
camera.position = overrides.position;
|
|
2882
|
+
}
|
|
2883
|
+
if (overrides.angles) {
|
|
2884
|
+
camera.angles = overrides.angles;
|
|
2885
|
+
}
|
|
2886
|
+
if (overrides.fov !== void 0) {
|
|
2887
|
+
camera.fov = overrides.fov;
|
|
2888
|
+
}
|
|
2889
|
+
return camera;
|
|
2890
|
+
}
|
|
2891
|
+
function createMockRefDef(overrides = {}) {
|
|
2892
|
+
return {
|
|
2893
|
+
x: 0,
|
|
2894
|
+
y: 0,
|
|
2895
|
+
width: 320,
|
|
2896
|
+
height: 240,
|
|
2897
|
+
fov_x: 90,
|
|
2898
|
+
fov_y: 90,
|
|
2899
|
+
vieworg: vec3_exports.create(),
|
|
2900
|
+
viewangles: vec3_exports.create(),
|
|
2901
|
+
time: 0,
|
|
2902
|
+
rdflags: 0,
|
|
2903
|
+
...overrides
|
|
2904
|
+
};
|
|
2905
|
+
}
|
|
2906
|
+
function createMockViewState(overrides = {}) {
|
|
2907
|
+
return {
|
|
2908
|
+
camera: overrides.camera || createMockCamera(),
|
|
2909
|
+
viewport: overrides.viewport || { x: 0, y: 0, width: 800, height: 600 },
|
|
2910
|
+
refdef: overrides.refdef || createMockRefDef(),
|
|
2911
|
+
...overrides
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
function createViewTestScenario(scenarioType) {
|
|
2915
|
+
const camera = createMockCamera();
|
|
2916
|
+
const refdef = createMockRefDef();
|
|
2917
|
+
switch (scenarioType) {
|
|
2918
|
+
case "firstPerson":
|
|
2919
|
+
camera.position = vec3_exports.fromValues(100, 100, 50);
|
|
2920
|
+
camera.angles = vec3_exports.fromValues(0, 45, 0);
|
|
2921
|
+
vec3_exports.copy(refdef.vieworg, camera.position);
|
|
2922
|
+
vec3_exports.copy(refdef.viewangles, camera.angles);
|
|
2923
|
+
break;
|
|
2924
|
+
case "thirdPerson":
|
|
2925
|
+
camera.position = vec3_exports.fromValues(100, 100, 100);
|
|
2926
|
+
camera.angles = vec3_exports.fromValues(30, 45, 0);
|
|
2927
|
+
vec3_exports.set(refdef.vieworg, 100, 100, 50);
|
|
2928
|
+
break;
|
|
2929
|
+
case "spectator":
|
|
2930
|
+
camera.position = vec3_exports.fromValues(0, 0, 100);
|
|
2931
|
+
camera.angles = vec3_exports.fromValues(90, 0, 0);
|
|
2932
|
+
break;
|
|
2933
|
+
}
|
|
2934
|
+
return {
|
|
2935
|
+
viewState: {
|
|
2936
|
+
camera,
|
|
2937
|
+
viewport: { x: 0, y: 0, width: 800, height: 600 },
|
|
2938
|
+
refdef
|
|
2939
|
+
},
|
|
2940
|
+
cleanup: () => {
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
}
|
|
2944
|
+
function simulateCameraMovement(camera, input, deltaTime) {
|
|
2945
|
+
const speed = 100;
|
|
2946
|
+
if (input.pitchDelta) camera.angles[0] += input.pitchDelta;
|
|
2947
|
+
if (input.yawDelta) camera.angles[1] += input.yawDelta;
|
|
2948
|
+
if (input.rollDelta) camera.angles[2] += input.rollDelta;
|
|
2949
|
+
camera.angles = camera.angles;
|
|
2950
|
+
if (input.forward || input.right || input.up) {
|
|
2951
|
+
camera.position[0] += (input.forward || 0) * deltaTime;
|
|
2952
|
+
camera.position[1] += (input.right || 0) * deltaTime;
|
|
2953
|
+
camera.position[2] += (input.up || 0) * deltaTime;
|
|
2954
|
+
camera.position = camera.position;
|
|
2955
|
+
}
|
|
2956
|
+
return camera;
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2385
2959
|
// src/e2e/playwright.ts
|
|
2386
2960
|
var import_playwright = require("playwright");
|
|
2387
2961
|
var import_http = require("http");
|
|
@@ -2619,13 +3193,16 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2619
3193
|
createEntityFactory,
|
|
2620
3194
|
createEntityStateFactory,
|
|
2621
3195
|
createGameStateSnapshotFactory,
|
|
3196
|
+
createInputInjector,
|
|
2622
3197
|
createItemEntityFactory,
|
|
2623
3198
|
createMockAI,
|
|
2624
3199
|
createMockAmmoItem,
|
|
2625
3200
|
createMockArmorItem,
|
|
2626
3201
|
createMockAudioContext,
|
|
3202
|
+
createMockCamera,
|
|
2627
3203
|
createMockCanvas,
|
|
2628
3204
|
createMockCanvasContext2D,
|
|
3205
|
+
createMockCollisionEntityIndex,
|
|
2629
3206
|
createMockConnection,
|
|
2630
3207
|
createMockDamageInfo,
|
|
2631
3208
|
createMockEngine,
|
|
@@ -2642,17 +3219,21 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2642
3219
|
createMockIndexedDB,
|
|
2643
3220
|
createMockInventory,
|
|
2644
3221
|
createMockItem,
|
|
3222
|
+
createMockKeyboardEvent,
|
|
2645
3223
|
createMockLocalStorage,
|
|
2646
3224
|
createMockMasterServer,
|
|
2647
3225
|
createMockMonsterAI,
|
|
2648
3226
|
createMockMonsterMove,
|
|
3227
|
+
createMockMouseEvent,
|
|
2649
3228
|
createMockNetDriver,
|
|
2650
3229
|
createMockNetworkAddress,
|
|
2651
3230
|
createMockPerformance,
|
|
3231
|
+
createMockPointerLock,
|
|
2652
3232
|
createMockPowerupItem,
|
|
2653
3233
|
createMockRAF,
|
|
2654
3234
|
createMockRConClient,
|
|
2655
3235
|
createMockRateLimiter,
|
|
3236
|
+
createMockRefDef,
|
|
2656
3237
|
createMockServer,
|
|
2657
3238
|
createMockServerClient,
|
|
2658
3239
|
createMockServerConsole,
|
|
@@ -2663,9 +3244,11 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2663
3244
|
createMockTransport,
|
|
2664
3245
|
createMockUDPSocket,
|
|
2665
3246
|
createMockUserInfo,
|
|
3247
|
+
createMockViewState,
|
|
2666
3248
|
createMockWeapon,
|
|
2667
3249
|
createMockWeaponItem,
|
|
2668
3250
|
createMockWebGL2Context,
|
|
3251
|
+
createMockWheelEvent,
|
|
2669
3252
|
createMonsterEntityFactory,
|
|
2670
3253
|
createMultiplayerTestScenario,
|
|
2671
3254
|
createNetChanMock,
|
|
@@ -2679,6 +3262,7 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2679
3262
|
createStorageTestScenario,
|
|
2680
3263
|
createTestContext,
|
|
2681
3264
|
createTriggerEntityFactory,
|
|
3265
|
+
createViewTestScenario,
|
|
2682
3266
|
createVisualTestScenario,
|
|
2683
3267
|
intersects,
|
|
2684
3268
|
ladderTrace,
|
|
@@ -2697,6 +3281,7 @@ function createVisualTestScenario(page, sceneName) {
|
|
|
2697
3281
|
setupNodeEnvironment,
|
|
2698
3282
|
setupWebGPUMocks,
|
|
2699
3283
|
simulateBandwidthLimit,
|
|
3284
|
+
simulateCameraMovement,
|
|
2700
3285
|
simulateFrames,
|
|
2701
3286
|
simulateFramesWithMock,
|
|
2702
3287
|
simulateHandshake,
|