@jack120/test 0.2.1 → 0.2.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/dist/index.js +1 -2415
- package/package.json +5 -3
- package/types/index.d.ts +67 -0
- package/dist/native-bindings-osx.node +0 -0
- package/dist/native-bindings-win.node +0 -0
package/dist/index.js
CHANGED
|
@@ -1,2415 +1 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// library/rpc.ts
|
|
9
|
-
import { platform } from "node:os";
|
|
10
|
-
var addon = platform() === "darwin" ? __require("./native-bindings-osx.node") : __require("./native-bindings-win.node");
|
|
11
|
-
var RpcClient = class _RpcClient {
|
|
12
|
-
static Init() {
|
|
13
|
-
addon.Rpc_RegisterCbHandler((callbackId, argsJson) => {
|
|
14
|
-
let kvJson = JSON.parse(argsJson);
|
|
15
|
-
let objJson = _RpcClient.keyValueToObject(
|
|
16
|
-
kvJson["keys"],
|
|
17
|
-
kvJson["values"]
|
|
18
|
-
);
|
|
19
|
-
try {
|
|
20
|
-
_RpcClient.callbackRegistry[callbackId](objJson);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error(`${error}`);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
static RegisterCallback(callback) {
|
|
27
|
-
let callbackId = Number(
|
|
28
|
-
_RpcClient.Call("_RPC::AllocateCallback", {
|
|
29
|
-
clientId: _RpcClient.GetClientId()
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
_RpcClient.callbackRegistry[callbackId] = callback;
|
|
33
|
-
return callbackId;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @param funcName RPC function name to call
|
|
38
|
-
* @param args Arguments of RPC in the format: `{parameter0: value0, parameter1: value1}`
|
|
39
|
-
* @returns The value returned from RPC function in string type
|
|
40
|
-
*/
|
|
41
|
-
static Call(funcName, args) {
|
|
42
|
-
if (!this.initialized) {
|
|
43
|
-
this.initialized = true;
|
|
44
|
-
_RpcClient.Init();
|
|
45
|
-
}
|
|
46
|
-
const processedArgs = {};
|
|
47
|
-
for (const [key, value] of Object.entries(args)) {
|
|
48
|
-
if (typeof value === "function") {
|
|
49
|
-
processedArgs[key] = _RpcClient.RegisterCallback(value);
|
|
50
|
-
} else {
|
|
51
|
-
processedArgs[key] = value;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return JSON.parse(
|
|
55
|
-
addon.Rpc_Call(
|
|
56
|
-
funcName,
|
|
57
|
-
JSON.stringify(this.objectToKeyValue(processedArgs))
|
|
58
|
-
)
|
|
59
|
-
).result;
|
|
60
|
-
}
|
|
61
|
-
static GetClientId() {
|
|
62
|
-
return Number(addon.Rpc_GetClientId());
|
|
63
|
-
}
|
|
64
|
-
static objectToKeyValue(obj) {
|
|
65
|
-
const keys = Object.keys(obj);
|
|
66
|
-
const values = keys.map((key) => obj[key]);
|
|
67
|
-
return { keys, values };
|
|
68
|
-
}
|
|
69
|
-
static keyValueToObject(keys, values) {
|
|
70
|
-
const obj = {};
|
|
71
|
-
keys.forEach((key, index) => {
|
|
72
|
-
obj[key] = values[index];
|
|
73
|
-
});
|
|
74
|
-
return obj;
|
|
75
|
-
}
|
|
76
|
-
static {
|
|
77
|
-
this.callbackRegistry = {};
|
|
78
|
-
}
|
|
79
|
-
static {
|
|
80
|
-
this.initialized = false;
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// library/debug.ts
|
|
85
|
-
var Debug = class {
|
|
86
|
-
static OnCmdCallback(fn) {
|
|
87
|
-
return RpcClient.Call("DebugWindow::GetCommand", { callback: fn });
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// library/device.ts
|
|
92
|
-
var Device = class {
|
|
93
|
-
// Local positions (relative to XR Origin)
|
|
94
|
-
static GetLeftPosition() {
|
|
95
|
-
return JSON.parse(RpcClient.Call("XRI Left/Position", {}));
|
|
96
|
-
}
|
|
97
|
-
static GetLeftRotation() {
|
|
98
|
-
return JSON.parse(RpcClient.Call("XRI Left/Rotation", {}));
|
|
99
|
-
}
|
|
100
|
-
static GetLeftThumbstick() {
|
|
101
|
-
return JSON.parse(RpcClient.Call("XRI Left/Thumbstick", {}));
|
|
102
|
-
}
|
|
103
|
-
static GetLeftSelect() {
|
|
104
|
-
return JSON.parse(RpcClient.Call("XRI Left Interaction/Select Value", {}));
|
|
105
|
-
}
|
|
106
|
-
static GetLeftActivate() {
|
|
107
|
-
return JSON.parse(
|
|
108
|
-
RpcClient.Call("XRI Left Interaction/Activate Value", {})
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
static GetLeftTurn() {
|
|
112
|
-
return JSON.parse(RpcClient.Call("XRI Left Locomotion/Turn", {}));
|
|
113
|
-
}
|
|
114
|
-
static GetLeftSnapTurn() {
|
|
115
|
-
return JSON.parse(RpcClient.Call("XRI Left Locomotion/Snap Turn", {}));
|
|
116
|
-
}
|
|
117
|
-
static GetLeftMove() {
|
|
118
|
-
return JSON.parse(RpcClient.Call("XRI Left Locomotion/Move", {}));
|
|
119
|
-
}
|
|
120
|
-
static GetLeftGrabMove() {
|
|
121
|
-
return JSON.parse(RpcClient.Call("XRI Left Locomotion/Grab Move", {}));
|
|
122
|
-
}
|
|
123
|
-
static GetRightPosition() {
|
|
124
|
-
return JSON.parse(RpcClient.Call("XRI Right/Position", {}));
|
|
125
|
-
}
|
|
126
|
-
static GetRightRotation() {
|
|
127
|
-
return JSON.parse(RpcClient.Call("XRI Right/Rotation", {}));
|
|
128
|
-
}
|
|
129
|
-
static GetRightThumbstick() {
|
|
130
|
-
return JSON.parse(RpcClient.Call("XRI Right/Thumbstick", {}));
|
|
131
|
-
}
|
|
132
|
-
static GetRightSelect() {
|
|
133
|
-
return JSON.parse(RpcClient.Call("XRI Right Interaction/Select Value", {}));
|
|
134
|
-
}
|
|
135
|
-
static GetRightActivate() {
|
|
136
|
-
return JSON.parse(
|
|
137
|
-
RpcClient.Call("XRI Right Interaction/Activate Value", {})
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
static GetRightTurn() {
|
|
141
|
-
return JSON.parse(RpcClient.Call("XRI Right Locomotion/Turn", {}));
|
|
142
|
-
}
|
|
143
|
-
static GetRightSnapTurn() {
|
|
144
|
-
return JSON.parse(RpcClient.Call("XRI Right Locomotion/Snap Turn", {}));
|
|
145
|
-
}
|
|
146
|
-
static GetRightMove() {
|
|
147
|
-
return JSON.parse(RpcClient.Call("XRI Right Locomotion/Move", {}));
|
|
148
|
-
}
|
|
149
|
-
static GetRightGrabMove() {
|
|
150
|
-
return JSON.parse(RpcClient.Call("XRI Right Locomotion/Grab Move", {}));
|
|
151
|
-
}
|
|
152
|
-
static GetHeadPosition() {
|
|
153
|
-
return JSON.parse(RpcClient.Call("XRI Head/Position", {}));
|
|
154
|
-
}
|
|
155
|
-
static GetHeadRotation() {
|
|
156
|
-
return JSON.parse(RpcClient.Call("XRI Head/Rotation", {}));
|
|
157
|
-
}
|
|
158
|
-
// World positions (absolute positions in world space)
|
|
159
|
-
static GetLeftWorldPosition() {
|
|
160
|
-
return JSON.parse(RpcClient.Call("XRI Left/WorldPosition", {}));
|
|
161
|
-
}
|
|
162
|
-
static GetLeftWorldRotation() {
|
|
163
|
-
return JSON.parse(RpcClient.Call("XRI Left/WorldRotation", {}));
|
|
164
|
-
}
|
|
165
|
-
static GetRightWorldPosition() {
|
|
166
|
-
return JSON.parse(RpcClient.Call("XRI Right/WorldPosition", {}));
|
|
167
|
-
}
|
|
168
|
-
static GetRightWorldRotation() {
|
|
169
|
-
return JSON.parse(RpcClient.Call("XRI Right/WorldRotation", {}));
|
|
170
|
-
}
|
|
171
|
-
static GetHeadWorldPosition() {
|
|
172
|
-
return JSON.parse(RpcClient.Call("XRI Head/WorldPosition", {}));
|
|
173
|
-
}
|
|
174
|
-
static GetHeadWorldRotation() {
|
|
175
|
-
return JSON.parse(RpcClient.Call("XRI Head/WorldRotation", {}));
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var XRSystem = class {
|
|
179
|
-
static {
|
|
180
|
-
this.KEYCODE = Object.freeze({
|
|
181
|
-
/* pose type */
|
|
182
|
-
LEFT_EYE: "Left Eye",
|
|
183
|
-
RIGHT_EYE: "Right Eye",
|
|
184
|
-
LEFT_AIM: "Left Aim",
|
|
185
|
-
RIGHT_AIM: "Right Aim",
|
|
186
|
-
LEFT_GRIP: "Left Grip",
|
|
187
|
-
RIGHT_GRIP: "Right Grip",
|
|
188
|
-
/* number type */
|
|
189
|
-
LEFT_SQUEEZE: "Left Squeeze",
|
|
190
|
-
RIGHT_SQUEEZE: "Right Squeeze",
|
|
191
|
-
LEFT_TRIGGER: "Left Trigger",
|
|
192
|
-
RIGHT_TRIGGER: "Right Trigger",
|
|
193
|
-
LEFT_THUMBSTICK_X: "Left Thumbstick X",
|
|
194
|
-
RIGHT_THUMBSTICK_X: "Right Thumbstick X",
|
|
195
|
-
LEFT_THUMBSTICK_Y: "Left Thumbstick Y",
|
|
196
|
-
RIGHT_THUMBSTICK_Y: "Right Thumbstick Y",
|
|
197
|
-
/* boolean type */
|
|
198
|
-
LEFT_TRIGGER_TOUCH: "Left Trigger Touch",
|
|
199
|
-
RIGHT_TRIGGER_TOUCH: "Right Trigger Touch",
|
|
200
|
-
LEFT_THUMBSTICK_CLICK: "Left Thumbstick Click",
|
|
201
|
-
RIGHT_THUMBSTICK_CLICK: "Right Thumbstick Click",
|
|
202
|
-
LEFT_THUMBSTICK_TOUCH: "Left Thumbstick Touch",
|
|
203
|
-
RIGHT_THUMBSTICK_TOUCH: "Right Thumbstick Touch",
|
|
204
|
-
LEFT_X_CLICK: "Left X Click",
|
|
205
|
-
LEFT_X_TOUCH: "Left X Touch",
|
|
206
|
-
LEFT_Y_CLICK: "Left Y Click",
|
|
207
|
-
LEFT_Y_TOUCH: "Left Y Touch",
|
|
208
|
-
LEFT_MENU_CLICK: "Left Menu Click",
|
|
209
|
-
RIGHT_A_CLICK: "Right A Click",
|
|
210
|
-
RIGHT_A_TOUCH: "Right A Touch",
|
|
211
|
-
RIGHT_B_CLIKC: "Right B Click",
|
|
212
|
-
RIGHT_B_TOUCH: "Right B Touch",
|
|
213
|
-
RIGHT_SYSTEM_CLICK: "Right System Click"
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
var Keyboard = class {
|
|
218
|
-
static {
|
|
219
|
-
this.MOUSE = Object.freeze({
|
|
220
|
-
BUTTON_LEFT: 0,
|
|
221
|
-
BUTTON_RIGHT: 1,
|
|
222
|
-
BUTTON_MIDDLE: 2
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
static {
|
|
226
|
-
this.KEYCODE = Object.freeze({
|
|
227
|
-
SPACE: 32,
|
|
228
|
-
APOSTROPHE: 39,
|
|
229
|
-
COMMA: 44,
|
|
230
|
-
MINUS: 45,
|
|
231
|
-
PERIOD: 46,
|
|
232
|
-
SLASH: 47,
|
|
233
|
-
NUM_0: 48,
|
|
234
|
-
NUM_1: 49,
|
|
235
|
-
NUM_2: 50,
|
|
236
|
-
NUM_3: 51,
|
|
237
|
-
NUM_4: 52,
|
|
238
|
-
NUM_5: 53,
|
|
239
|
-
NUM_6: 54,
|
|
240
|
-
NUM_7: 55,
|
|
241
|
-
NUM_8: 56,
|
|
242
|
-
NUM_9: 57,
|
|
243
|
-
SEMICOLON: 59,
|
|
244
|
-
EQUAL: 61,
|
|
245
|
-
A: 65,
|
|
246
|
-
B: 66,
|
|
247
|
-
C: 67,
|
|
248
|
-
D: 68,
|
|
249
|
-
E: 69,
|
|
250
|
-
F: 70,
|
|
251
|
-
G: 71,
|
|
252
|
-
H: 72,
|
|
253
|
-
I: 73,
|
|
254
|
-
J: 74,
|
|
255
|
-
K: 75,
|
|
256
|
-
L: 76,
|
|
257
|
-
M: 77,
|
|
258
|
-
N: 78,
|
|
259
|
-
O: 79,
|
|
260
|
-
P: 80,
|
|
261
|
-
Q: 81,
|
|
262
|
-
R: 82,
|
|
263
|
-
S: 83,
|
|
264
|
-
T: 84,
|
|
265
|
-
U: 85,
|
|
266
|
-
V: 86,
|
|
267
|
-
W: 87,
|
|
268
|
-
X: 88,
|
|
269
|
-
Y: 89,
|
|
270
|
-
Z: 90,
|
|
271
|
-
LEFT_BRACKET: 91,
|
|
272
|
-
BACKSLASH: 92,
|
|
273
|
-
RIGHT_BRACKET: 93,
|
|
274
|
-
GRAVE_ACCENT: 96,
|
|
275
|
-
WORLD_1: 161,
|
|
276
|
-
WORLD_2: 162,
|
|
277
|
-
ESCAPE: 256,
|
|
278
|
-
ENTER: 257,
|
|
279
|
-
TAB: 258,
|
|
280
|
-
BACKSPACE: 259,
|
|
281
|
-
INSERT: 260,
|
|
282
|
-
DELETE: 261,
|
|
283
|
-
RIGHT: 262,
|
|
284
|
-
LEFT: 263,
|
|
285
|
-
DOWN: 264,
|
|
286
|
-
UP: 265,
|
|
287
|
-
PAGE_UP: 266,
|
|
288
|
-
PAGE_DOWN: 267,
|
|
289
|
-
HOME: 268,
|
|
290
|
-
END: 269,
|
|
291
|
-
CAPS_LOCK: 280,
|
|
292
|
-
SCROLL_LOCK: 281,
|
|
293
|
-
NUM_LOCK: 282,
|
|
294
|
-
PRINT_SCREEN: 283,
|
|
295
|
-
PAUSE: 284,
|
|
296
|
-
F1: 290,
|
|
297
|
-
F2: 291,
|
|
298
|
-
F3: 292,
|
|
299
|
-
F4: 293,
|
|
300
|
-
F5: 294,
|
|
301
|
-
F6: 295,
|
|
302
|
-
F7: 296,
|
|
303
|
-
F8: 297,
|
|
304
|
-
F9: 298,
|
|
305
|
-
F10: 299,
|
|
306
|
-
F11: 300,
|
|
307
|
-
F12: 301,
|
|
308
|
-
F13: 302,
|
|
309
|
-
F14: 303,
|
|
310
|
-
F15: 304,
|
|
311
|
-
F16: 305,
|
|
312
|
-
F17: 306,
|
|
313
|
-
F18: 307,
|
|
314
|
-
F19: 308,
|
|
315
|
-
F20: 309,
|
|
316
|
-
F21: 310,
|
|
317
|
-
F22: 311,
|
|
318
|
-
F23: 312,
|
|
319
|
-
F24: 313,
|
|
320
|
-
F25: 314,
|
|
321
|
-
KP_0: 320,
|
|
322
|
-
KP_1: 321,
|
|
323
|
-
KP_2: 322,
|
|
324
|
-
KP_3: 323,
|
|
325
|
-
KP_4: 324,
|
|
326
|
-
KP_5: 325,
|
|
327
|
-
KP_6: 326,
|
|
328
|
-
KP_7: 327,
|
|
329
|
-
KP_8: 328,
|
|
330
|
-
KP_9: 329,
|
|
331
|
-
KP_DECIMAL: 330,
|
|
332
|
-
KP_DIVIDE: 331,
|
|
333
|
-
KP_MULTIPLY: 332,
|
|
334
|
-
KP_SUBTRACT: 333,
|
|
335
|
-
KP_ADD: 334,
|
|
336
|
-
KP_ENTER: 335,
|
|
337
|
-
KP_EQUAL: 336,
|
|
338
|
-
LEFT_SHIFT: 340,
|
|
339
|
-
LEFT_CONTROL: 341,
|
|
340
|
-
LEFT_ALT: 342,
|
|
341
|
-
LEFT_SUPER: 343,
|
|
342
|
-
RIGHT_SHIFT: 344,
|
|
343
|
-
RIGHT_CONTROL: 345,
|
|
344
|
-
RIGHT_ALT: 346,
|
|
345
|
-
RIGHT_SUPER: 347,
|
|
346
|
-
MENU: 348
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
static {
|
|
350
|
-
this.ACTION = Object.freeze({
|
|
351
|
-
RELEASE: 0,
|
|
352
|
-
PRESS: 1,
|
|
353
|
-
REPEAT: 2
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
static {
|
|
357
|
-
this.MODIFIER = Object.freeze({
|
|
358
|
-
SHIFT: 1,
|
|
359
|
-
CONTROL: 2,
|
|
360
|
-
ALT: 4,
|
|
361
|
-
SUPER: 8,
|
|
362
|
-
CAPS_LOCK: 16,
|
|
363
|
-
NUM_LOCK: 32
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
// library/entity.ts
|
|
369
|
-
var EntityManager = class {
|
|
370
|
-
/**
|
|
371
|
-
* Create a new Entity
|
|
372
|
-
* @returns {Entity}
|
|
373
|
-
*/
|
|
374
|
-
static Create(name) {
|
|
375
|
-
return Number(
|
|
376
|
-
RpcClient.Call("Entity_Create", {
|
|
377
|
-
name,
|
|
378
|
-
clientId: RpcClient.GetClientId()
|
|
379
|
-
})
|
|
380
|
-
);
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Destroys an Entity.
|
|
384
|
-
* @param {Entity} entity
|
|
385
|
-
* @returns {Boolean} If entity is destroyed successfully
|
|
386
|
-
*/
|
|
387
|
-
static Destroy(entityHandle) {
|
|
388
|
-
return Boolean(RpcClient.Call("Entity_Destroy", { entityHandle }));
|
|
389
|
-
}
|
|
390
|
-
static SetName(entityHandle, name) {
|
|
391
|
-
return Boolean(RpcClient.Call("Entity_SetName", { entityHandle, name }));
|
|
392
|
-
}
|
|
393
|
-
static GetName(entityHandle) {
|
|
394
|
-
return RpcClient.Call("Entity_GetName", { entityHandle });
|
|
395
|
-
}
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
// library/interaction/interaction.ts
|
|
399
|
-
var GrabInteractableManager = class {
|
|
400
|
-
/**
|
|
401
|
-
* Creates a grab interactable component for the specified entity.
|
|
402
|
-
* All colliders added before this component is add are used to detect grabbing
|
|
403
|
-
* @param entityHandle The entity to attach the grab interactable to.
|
|
404
|
-
* @returns A handle representing the newly created grab interactable.
|
|
405
|
-
*/
|
|
406
|
-
static Create(entityHandle) {
|
|
407
|
-
return Boolean(
|
|
408
|
-
RpcClient.Call("GrabInteractableAPI_Create", {
|
|
409
|
-
entityHandle
|
|
410
|
-
})
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Destroys the grab interactable component on the given entity.
|
|
415
|
-
* @param entityHandle The entity whose grab interactable should be destroyed.
|
|
416
|
-
* @returns True if the component was successfully destroyed.
|
|
417
|
-
*/
|
|
418
|
-
static Destroy(entityHandle) {
|
|
419
|
-
return Boolean(
|
|
420
|
-
RpcClient.Call("GrabInteractableAPI_Destroy", {
|
|
421
|
-
entityHandle
|
|
422
|
-
})
|
|
423
|
-
);
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Checks if the specified entity has a grab interactable component.
|
|
427
|
-
* @param entityHandle The entity to check.
|
|
428
|
-
* @returns True if the component exists.
|
|
429
|
-
*/
|
|
430
|
-
static HasComponent(entityHandle) {
|
|
431
|
-
return Boolean(
|
|
432
|
-
RpcClient.Call("GrabInteractableAPI_HasComponent", {
|
|
433
|
-
entityHandle
|
|
434
|
-
})
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
/**
|
|
438
|
-
* Gets whether the grab interactable tracks position.
|
|
439
|
-
* @param entityHandle The target entity.
|
|
440
|
-
* @returns True if position tracking is enabled.
|
|
441
|
-
*/
|
|
442
|
-
static GetTrackPosition(entityHandle) {
|
|
443
|
-
return Boolean(
|
|
444
|
-
RpcClient.Call("GrabInteractableAPI_GetTrackPosition", {
|
|
445
|
-
entityHandle
|
|
446
|
-
})
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Enables or disables position tracking on the grab interactable.
|
|
451
|
-
* @param entityHandle The target entity.
|
|
452
|
-
* @param isTracking Whether to enable position tracking.
|
|
453
|
-
* @returns True if the change was applied.
|
|
454
|
-
*/
|
|
455
|
-
static SetTrackPosition(entityHandle, isTracking) {
|
|
456
|
-
return Boolean(
|
|
457
|
-
RpcClient.Call("GrabInteractableAPI_SetTrackPosition", {
|
|
458
|
-
entityHandle,
|
|
459
|
-
isTracking
|
|
460
|
-
})
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Gets whether the grab interactable tracks rotation.
|
|
465
|
-
* @param entityHandle The target entity.
|
|
466
|
-
* @returns True if rotation tracking is enabled.
|
|
467
|
-
*/
|
|
468
|
-
static GetTrackRotation(entityHandle) {
|
|
469
|
-
return JSON.parse(
|
|
470
|
-
RpcClient.Call("GrabInteractableAPI_GetTrackRotation", {
|
|
471
|
-
entityHandle
|
|
472
|
-
})
|
|
473
|
-
);
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Enables or disables rotation tracking on the grab interactable.
|
|
477
|
-
* @param entityHandle The target entity.
|
|
478
|
-
* @param isTracking Whether to enable rotation tracking.
|
|
479
|
-
* @returns True if the change was applied.
|
|
480
|
-
*/
|
|
481
|
-
static SetTrackRotation(entityHandle, isTracking) {
|
|
482
|
-
return JSON.parse(
|
|
483
|
-
RpcClient.Call("GrabInteractableAPI_SetTrackRotation", {
|
|
484
|
-
entityHandle,
|
|
485
|
-
isTracking
|
|
486
|
-
})
|
|
487
|
-
);
|
|
488
|
-
}
|
|
489
|
-
/**
|
|
490
|
-
* Gets whether the grab interactable tracks scale.
|
|
491
|
-
* @param entityHandle The target entity.
|
|
492
|
-
* @returns True if scale tracking is enabled.
|
|
493
|
-
*/
|
|
494
|
-
static GetTrackScale(entityHandle) {
|
|
495
|
-
return Boolean(
|
|
496
|
-
RpcClient.Call("GrabInteractableAPI_GetTrackScale", {
|
|
497
|
-
entityHandle
|
|
498
|
-
})
|
|
499
|
-
);
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* Enables or disables scale tracking on the grab interactable.
|
|
503
|
-
* @param entityHandle The target entity.
|
|
504
|
-
* @param isTracking Whether to enable scale tracking.
|
|
505
|
-
* @returns True if the change was applied.
|
|
506
|
-
*/
|
|
507
|
-
static SetTrackScale(entityHandle, isTracking) {
|
|
508
|
-
return Boolean(
|
|
509
|
-
RpcClient.Call("GrabInteractableAPI_SetTrackScale", {
|
|
510
|
-
entityHandle,
|
|
511
|
-
isTracking
|
|
512
|
-
})
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Gets whether the object should apply physics-based throw on detach.
|
|
517
|
-
* @param entityHandle The target entity.
|
|
518
|
-
* @returns True if throw-on-detach is enabled.
|
|
519
|
-
*/
|
|
520
|
-
static GetThrowOnDetach(entityHandle) {
|
|
521
|
-
return Boolean(
|
|
522
|
-
RpcClient.Call("GrabInteractableAPI_GetThrowOnDetach", {
|
|
523
|
-
entityHandle
|
|
524
|
-
})
|
|
525
|
-
);
|
|
526
|
-
}
|
|
527
|
-
/**
|
|
528
|
-
* Enables or disables physics-based throwing on detach.
|
|
529
|
-
* @param entityHandle The target entity.
|
|
530
|
-
* @param enable Whether to enable throw-on-detach.
|
|
531
|
-
* @returns True if the setting was successfully changed.
|
|
532
|
-
*/
|
|
533
|
-
static SetThrowOnDetach(entityHandle, enable) {
|
|
534
|
-
return Boolean(
|
|
535
|
-
RpcClient.Call("GrabInteractableAPI_SetThrowOnDetach", {
|
|
536
|
-
entityHandle,
|
|
537
|
-
enable
|
|
538
|
-
})
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Gets the currently attached entity handle, if any.
|
|
543
|
-
* @param entityHandle The entity whose attachment is being queried.
|
|
544
|
-
* @returns True if the query was successful. The actual value is assumed returned via RPC side effect or callback.
|
|
545
|
-
*/
|
|
546
|
-
static GetAttachEntity(entityHandle) {
|
|
547
|
-
return Boolean(
|
|
548
|
-
RpcClient.Call("GrabInteractableAPI_GetAttachEntity", {
|
|
549
|
-
entityHandle
|
|
550
|
-
})
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* Sets the entity that should be used as the attachment target for this grab interactable.
|
|
555
|
-
* @param entityHandle The source grab interactable entity.
|
|
556
|
-
* @param attachEntityHandle The target entity to attach to.
|
|
557
|
-
* @returns True if the attachment was successfully updated.
|
|
558
|
-
*/
|
|
559
|
-
static SetAttachEntity(entityHandle, attachEntityHandle) {
|
|
560
|
-
return Boolean(
|
|
561
|
-
RpcClient.Call("GrabInteractableAPI_SetAttachEntity", {
|
|
562
|
-
entityHandle,
|
|
563
|
-
attachEntityHandle
|
|
564
|
-
})
|
|
565
|
-
);
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Registers a callback to be invoked when the object is selected (grabbed).
|
|
569
|
-
* @param entityHandle The entity to observe.
|
|
570
|
-
* @param onSelectEntered Callback function to invoke on select enter.
|
|
571
|
-
* @returns True if the callback was registered successfully.
|
|
572
|
-
*/
|
|
573
|
-
static AddSelectEnteredCallback(entityHandle, onSelectEntered) {
|
|
574
|
-
return Boolean(
|
|
575
|
-
RpcClient.Call("GrabInteractableAPI_AddSelectEnteredCallback", {
|
|
576
|
-
entityHandle,
|
|
577
|
-
onSelectEntered: (args) => {
|
|
578
|
-
onSelectEntered(args.interactableEntity, args.interactorEntity);
|
|
579
|
-
}
|
|
580
|
-
})
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Registers a callback to be invoked when the object is released (deselected).
|
|
585
|
-
* @param entityHandle The entity to observe.
|
|
586
|
-
* @param onSelectExited Callback function to invoke on select exit.
|
|
587
|
-
* @returns True if the callback was registered successfully.
|
|
588
|
-
*/
|
|
589
|
-
static AddSelectExitedCallback(entityHandle, onSelectExited) {
|
|
590
|
-
return Boolean(
|
|
591
|
-
RpcClient.Call("GrabInteractableAPI_AddSelectExitedCallback", {
|
|
592
|
-
entityHandle,
|
|
593
|
-
onSelectExited: (args) => {
|
|
594
|
-
onSelectExited(args.interactableEntity, args.interactorEntity);
|
|
595
|
-
}
|
|
596
|
-
})
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Registers a callback to be invoked when the object is activated (e.g. trigger pressed).
|
|
601
|
-
* @param entityHandle The entity to observe.
|
|
602
|
-
* @param onActivated Callback function to invoke on activation.
|
|
603
|
-
* @returns True if the callback was registered successfully.
|
|
604
|
-
*/
|
|
605
|
-
static AddActivatedCallback(entityHandle, onActivated) {
|
|
606
|
-
return Boolean(
|
|
607
|
-
RpcClient.Call("GrabInteractableAPI_AddActivatedCallback", {
|
|
608
|
-
entityHandle,
|
|
609
|
-
onActivated: (args) => {
|
|
610
|
-
onActivated(args.interactableEntity, args.interactorEntity);
|
|
611
|
-
}
|
|
612
|
-
})
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Registers a callback to be invoked when the object is deactivated (e.g. trigger released).
|
|
617
|
-
* @param entityHandle The entity to observe.
|
|
618
|
-
* @param onDeactivated Callback function to invoke on deactivation.
|
|
619
|
-
* @returns True if the callback was registered successfully.
|
|
620
|
-
*/
|
|
621
|
-
static AddDeactivatedCallback(entityHandle, onDeactivated) {
|
|
622
|
-
return Boolean(
|
|
623
|
-
RpcClient.Call("GrabInteractableAPI_AddDeactivatedCallback", {
|
|
624
|
-
entityHandle,
|
|
625
|
-
onDeactivated: (args) => {
|
|
626
|
-
onDeactivated(args.interactableEntity, args.interactorEntity);
|
|
627
|
-
}
|
|
628
|
-
})
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
// library/networking/state-sync.ts
|
|
634
|
-
var StateSync = class _StateSync {
|
|
635
|
-
static {
|
|
636
|
-
this.stateMap = /* @__PURE__ */ new Map();
|
|
637
|
-
}
|
|
638
|
-
// holds all proxies by key
|
|
639
|
-
static GetNetworkID() {
|
|
640
|
-
return RpcClient.Call("_Main::GetNetworkPrefabIdByPid", {
|
|
641
|
-
pid: process.pid
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
static CreateNetworkState(key, initial, onStateChange = () => {
|
|
645
|
-
}) {
|
|
646
|
-
const internalState = structuredClone(initial);
|
|
647
|
-
_StateSync.stateMap.set(key, internalState);
|
|
648
|
-
const proxy = new Proxy(internalState, {
|
|
649
|
-
get(target, prop) {
|
|
650
|
-
return Reflect.get(target, prop);
|
|
651
|
-
},
|
|
652
|
-
set(target, prop, value) {
|
|
653
|
-
Reflect.set(target, prop, value);
|
|
654
|
-
RpcClient.Call("_RPC::BroadcastState", {
|
|
655
|
-
networkId: _StateSync.GetNetworkID(),
|
|
656
|
-
key,
|
|
657
|
-
payload: JSON.stringify({ prop, value })
|
|
658
|
-
});
|
|
659
|
-
return true;
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
RpcClient.Call("_RPC::AddNewState", {
|
|
663
|
-
networkId: _StateSync.GetNetworkID(),
|
|
664
|
-
key,
|
|
665
|
-
onReceived: (jsonObject) => {
|
|
666
|
-
console.log("onReceived: " + jsonObject.data);
|
|
667
|
-
const internalState2 = _StateSync.stateMap.get(key);
|
|
668
|
-
if (!internalState2) return;
|
|
669
|
-
const { prop, value } = JSON.parse(jsonObject.data);
|
|
670
|
-
internalState2[prop] = value;
|
|
671
|
-
onStateChange(prop, value);
|
|
672
|
-
}
|
|
673
|
-
});
|
|
674
|
-
return proxy;
|
|
675
|
-
}
|
|
676
|
-
static IsStateAuthority() {
|
|
677
|
-
return RpcClient.Call("_RPC:IsStateAuthority", {
|
|
678
|
-
networkId: _StateSync.GetNetworkID()
|
|
679
|
-
});
|
|
680
|
-
}
|
|
681
|
-
static GetPlayerId() {
|
|
682
|
-
return RpcClient.Call("Multiplayer_GetPlayerId", {});
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
|
-
|
|
686
|
-
// library/physics/collider.ts
|
|
687
|
-
import { vec3 } from "gl-matrix";
|
|
688
|
-
var ColliderManager = class {
|
|
689
|
-
static CreateBox(entityHandle) {
|
|
690
|
-
return Number(
|
|
691
|
-
RpcClient.Call("ColliderAPI_CreateBox", {
|
|
692
|
-
entityHandle
|
|
693
|
-
})
|
|
694
|
-
);
|
|
695
|
-
}
|
|
696
|
-
static CreateSphere(entityHandle) {
|
|
697
|
-
return Number(
|
|
698
|
-
RpcClient.Call("ColliderAPI_CreateSphere", {
|
|
699
|
-
entityHandle
|
|
700
|
-
})
|
|
701
|
-
);
|
|
702
|
-
}
|
|
703
|
-
static CreateCapsule(entityHandle) {
|
|
704
|
-
return Number(
|
|
705
|
-
RpcClient.Call("ColliderAPI_CreateCapsule", {
|
|
706
|
-
entityHandle
|
|
707
|
-
})
|
|
708
|
-
);
|
|
709
|
-
}
|
|
710
|
-
static Destroy(entityHandle, colliderHandle) {
|
|
711
|
-
return Boolean(
|
|
712
|
-
RpcClient.Call("ColliderAPI_Destroy", {
|
|
713
|
-
entityHandle,
|
|
714
|
-
colliderHandle
|
|
715
|
-
})
|
|
716
|
-
);
|
|
717
|
-
}
|
|
718
|
-
static HasComponent(entityHandle, colliderHandle) {
|
|
719
|
-
return Boolean(
|
|
720
|
-
RpcClient.Call("ColliderAPI_HasComponent", {
|
|
721
|
-
entityHandle,
|
|
722
|
-
colliderHandle
|
|
723
|
-
})
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
static GetGameObject(entityHandle) {
|
|
727
|
-
return Number(
|
|
728
|
-
RpcClient.Call("ColliderAPI_GetGameObject", {
|
|
729
|
-
entityHandle
|
|
730
|
-
})
|
|
731
|
-
);
|
|
732
|
-
}
|
|
733
|
-
static GetBoxColliderCenter(colliderHandle) {
|
|
734
|
-
const center = JSON.parse(
|
|
735
|
-
RpcClient.Call("ColliderAPI_GetBoxColliderCenter", {
|
|
736
|
-
colliderHandle
|
|
737
|
-
})
|
|
738
|
-
);
|
|
739
|
-
return vec3.fromValues(center[0], center[1], center[2]);
|
|
740
|
-
}
|
|
741
|
-
static SetBoxColliderCenter(colliderHandle, center) {
|
|
742
|
-
return RpcClient.Call("ColliderAPI_SetBoxColliderCenter", {
|
|
743
|
-
colliderHandle,
|
|
744
|
-
v0: center[0],
|
|
745
|
-
v1: center[1],
|
|
746
|
-
v2: center[2]
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
static GetBoxColliderSize(colliderHandle) {
|
|
750
|
-
const center = JSON.parse(
|
|
751
|
-
RpcClient.Call("ColliderAPI_GetBoxColliderSize", {
|
|
752
|
-
colliderHandle
|
|
753
|
-
})
|
|
754
|
-
);
|
|
755
|
-
return vec3.fromValues(center[0], center[1], center[2]);
|
|
756
|
-
}
|
|
757
|
-
static SetBoxColliderSize(colliderHandle, size) {
|
|
758
|
-
return RpcClient.Call("ColliderAPI_SetBoxColliderSize", {
|
|
759
|
-
colliderHandle,
|
|
760
|
-
v0: size[0],
|
|
761
|
-
v1: size[1],
|
|
762
|
-
v2: size[2]
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
static GetSphereColliderCenter(colliderHandle) {
|
|
766
|
-
const center = JSON.parse(
|
|
767
|
-
RpcClient.Call("ColliderAPI_GetSphereColliderCenter", {
|
|
768
|
-
colliderHandle
|
|
769
|
-
})
|
|
770
|
-
);
|
|
771
|
-
return vec3.fromValues(center[0], center[1], center[2]);
|
|
772
|
-
}
|
|
773
|
-
static SetSphereColliderCenter(colliderHandle, center) {
|
|
774
|
-
return RpcClient.Call("ColliderAPI_SetSphereColliderCenter", {
|
|
775
|
-
colliderHandle,
|
|
776
|
-
v0: center[0],
|
|
777
|
-
v1: center[1],
|
|
778
|
-
v2: center[2]
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
static GetSphereColliderRadius(colliderHandle) {
|
|
782
|
-
return RpcClient.Call("ColliderAPI_GetSphereColliderRadius", {
|
|
783
|
-
colliderHandle
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
static SetSphereColliderRadius(colliderHandle, radius) {
|
|
787
|
-
return RpcClient.Call("ColliderAPI_SetSphereColliderRadius", {
|
|
788
|
-
colliderHandle,
|
|
789
|
-
radius
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
static GetCapsuleColliderCenter(colliderHandle) {
|
|
793
|
-
const center = JSON.parse(
|
|
794
|
-
RpcClient.Call("ColliderAPI_GetCapsuleColliderCenter", {
|
|
795
|
-
colliderHandle
|
|
796
|
-
})
|
|
797
|
-
);
|
|
798
|
-
return vec3.fromValues(center[0], center[1], center[2]);
|
|
799
|
-
}
|
|
800
|
-
static SetCapsuleColliderCenter(colliderHandle, center) {
|
|
801
|
-
return RpcClient.Call("ColliderAPI_SetCapsuleColliderCenter", {
|
|
802
|
-
colliderHandle,
|
|
803
|
-
v0: center[0],
|
|
804
|
-
v1: center[1],
|
|
805
|
-
v2: center[2]
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
static GetCapsuleColliderRadius(colliderHandle) {
|
|
809
|
-
return RpcClient.Call("ColliderAPI_GetCapsuleColliderRadius", {
|
|
810
|
-
colliderHandle
|
|
811
|
-
});
|
|
812
|
-
}
|
|
813
|
-
static SetCapsuleColliderRadius(colliderHandle, radius) {
|
|
814
|
-
return RpcClient.Call("ColliderAPI_SetCapsuleColliderRadius", {
|
|
815
|
-
colliderHandle,
|
|
816
|
-
radius
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
static GetCapsuleColliderHeight(colliderHandle) {
|
|
820
|
-
return RpcClient.Call("ColliderAPI_GetCapsuleColliderHeight", {
|
|
821
|
-
colliderHandle
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
static SetCapsuleColliderHeight(colliderHandle, height) {
|
|
825
|
-
return RpcClient.Call("ColliderAPI_SetCapsuleColliderHeight", {
|
|
826
|
-
colliderHandle,
|
|
827
|
-
height
|
|
828
|
-
});
|
|
829
|
-
}
|
|
830
|
-
static GetIsTrigger(entityHandle) {
|
|
831
|
-
return Boolean(
|
|
832
|
-
RpcClient.Call("ColliderAPI_GetIsTrigger", {
|
|
833
|
-
entityHandle
|
|
834
|
-
})
|
|
835
|
-
);
|
|
836
|
-
}
|
|
837
|
-
static SetIsTrigger(colliderHandle, isTrigger) {
|
|
838
|
-
return Boolean(
|
|
839
|
-
RpcClient.Call("ColliderAPI_SetIsTrigger", {
|
|
840
|
-
colliderHandle,
|
|
841
|
-
isTrigger
|
|
842
|
-
})
|
|
843
|
-
);
|
|
844
|
-
}
|
|
845
|
-
static AddTriggerEnterCallback(entityHandle, onTriggerEnter) {
|
|
846
|
-
return Boolean(
|
|
847
|
-
RpcClient.Call("ColliderAPI_AddTriggerEnterCallback", {
|
|
848
|
-
entityHandle,
|
|
849
|
-
onTriggerEnter
|
|
850
|
-
})
|
|
851
|
-
);
|
|
852
|
-
}
|
|
853
|
-
static AddTriggerExitCallback(entityHandle, onTriggerExit) {
|
|
854
|
-
return Boolean(
|
|
855
|
-
RpcClient.Call("ColliderAPI_AddTriggerExitCallback", {
|
|
856
|
-
entityHandle,
|
|
857
|
-
onTriggerExit
|
|
858
|
-
})
|
|
859
|
-
);
|
|
860
|
-
}
|
|
861
|
-
static AddTriggerStayCallback(entityHandle, onTriggerStay) {
|
|
862
|
-
return Boolean(
|
|
863
|
-
RpcClient.Call("ColliderAPI_AddTriggerStayCallback", {
|
|
864
|
-
entityHandle,
|
|
865
|
-
onTriggerStay
|
|
866
|
-
})
|
|
867
|
-
);
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
|
|
871
|
-
// library/physics/rigidbody.ts
|
|
872
|
-
var RigidbodyManager = class {
|
|
873
|
-
static Create(entityHandle) {
|
|
874
|
-
return Boolean(
|
|
875
|
-
RpcClient.Call("RidigbodyAPI_Create", {
|
|
876
|
-
entityHandle
|
|
877
|
-
})
|
|
878
|
-
);
|
|
879
|
-
}
|
|
880
|
-
static Destroy(entityHandle) {
|
|
881
|
-
return Boolean(
|
|
882
|
-
RpcClient.Call("RidigbodyAPI_Destroy", {
|
|
883
|
-
entityHandle
|
|
884
|
-
})
|
|
885
|
-
);
|
|
886
|
-
}
|
|
887
|
-
static HasComponent(entityHandle) {
|
|
888
|
-
return Boolean(
|
|
889
|
-
RpcClient.Call("RidigbodyAPI_HasComponent", {
|
|
890
|
-
entityHandle
|
|
891
|
-
})
|
|
892
|
-
);
|
|
893
|
-
}
|
|
894
|
-
static GetIsKinematic(entityHandle) {
|
|
895
|
-
return Boolean(
|
|
896
|
-
RpcClient.Call("RidigbodyAPI_GetIsKinematic", {
|
|
897
|
-
entityHandle
|
|
898
|
-
})
|
|
899
|
-
);
|
|
900
|
-
}
|
|
901
|
-
static SetIsKinematic(entityHandle, isKinematic) {
|
|
902
|
-
return Boolean(
|
|
903
|
-
RpcClient.Call("RidigbodyAPI_SetIsKinematic", {
|
|
904
|
-
entityHandle,
|
|
905
|
-
isKinematic
|
|
906
|
-
})
|
|
907
|
-
);
|
|
908
|
-
}
|
|
909
|
-
static GetUseGravity(entityHandle) {
|
|
910
|
-
return Boolean(
|
|
911
|
-
RpcClient.Call("RidigbodyAPI_GetUseGravity", {
|
|
912
|
-
entityHandle
|
|
913
|
-
})
|
|
914
|
-
);
|
|
915
|
-
}
|
|
916
|
-
static SetUseGravity(entityHandle, useGravity) {
|
|
917
|
-
return Boolean(
|
|
918
|
-
RpcClient.Call("RidigbodyAPI_SetUseGravity", {
|
|
919
|
-
entityHandle,
|
|
920
|
-
useGravity
|
|
921
|
-
})
|
|
922
|
-
);
|
|
923
|
-
}
|
|
924
|
-
static GetMass(entityHandle) {
|
|
925
|
-
return Number(
|
|
926
|
-
RpcClient.Call("RidigbodyAPI_GetMass", {
|
|
927
|
-
entityHandle
|
|
928
|
-
})
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
static SetMass(entityHandle, mass) {
|
|
932
|
-
return Boolean(
|
|
933
|
-
RpcClient.Call("RidigbodyAPI_SetMass", {
|
|
934
|
-
entityHandle,
|
|
935
|
-
mass
|
|
936
|
-
})
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
|
-
static GetLinearDamping(entityHandle) {
|
|
940
|
-
return Number(
|
|
941
|
-
RpcClient.Call("RidigbodyAPI_GetLinearDamping", {
|
|
942
|
-
entityHandle
|
|
943
|
-
})
|
|
944
|
-
);
|
|
945
|
-
}
|
|
946
|
-
static SetLinearDamping(entityHandle, linearDamping) {
|
|
947
|
-
return Boolean(
|
|
948
|
-
RpcClient.Call("RidigbodyAPI_SetLinearDamping", {
|
|
949
|
-
entityHandle,
|
|
950
|
-
linearDamping
|
|
951
|
-
})
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
static GetAngularDamping(entityHandle) {
|
|
955
|
-
return Number(
|
|
956
|
-
RpcClient.Call("RidigbodyAPI_GetAngularDamping", {
|
|
957
|
-
entityHandle
|
|
958
|
-
})
|
|
959
|
-
);
|
|
960
|
-
}
|
|
961
|
-
static SetAngularDamping(entityHandle, angularDamping) {
|
|
962
|
-
return Boolean(
|
|
963
|
-
RpcClient.Call("RidigbodyAPI_SetAngularDamping", {
|
|
964
|
-
entityHandle,
|
|
965
|
-
angularDamping
|
|
966
|
-
})
|
|
967
|
-
);
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
|
|
971
|
-
// library/render/camera.ts
|
|
972
|
-
var CameraManager = class {
|
|
973
|
-
/**
|
|
974
|
-
* Create a Camera component and attach it to the specified entity
|
|
975
|
-
* @param entity The entity to attach the camera to
|
|
976
|
-
* @returns boolean indicating success
|
|
977
|
-
*/
|
|
978
|
-
static Create(entity) {
|
|
979
|
-
return Boolean(RpcClient.Call("Camera_Create", { entityHandle: entity }));
|
|
980
|
-
}
|
|
981
|
-
/**
|
|
982
|
-
* Destroy the Camera component from the specified entity
|
|
983
|
-
* @param entity The entity to remove the camera from
|
|
984
|
-
* @returns boolean indicating success
|
|
985
|
-
*/
|
|
986
|
-
static Destroy(entity) {
|
|
987
|
-
return Boolean(RpcClient.Call("Camera_Destroy", { entityHandle: entity }));
|
|
988
|
-
}
|
|
989
|
-
/**
|
|
990
|
-
* Check if the entity has a Camera component
|
|
991
|
-
* @param entity The entity to check
|
|
992
|
-
* @returns boolean indicating if camera component exists
|
|
993
|
-
*/
|
|
994
|
-
static HasComponent(entity) {
|
|
995
|
-
return Boolean(
|
|
996
|
-
RpcClient.Call("Camera_HasComponent", { entityHandle: entity })
|
|
997
|
-
);
|
|
998
|
-
}
|
|
999
|
-
/**
|
|
1000
|
-
* Set the projection parameters for the camera
|
|
1001
|
-
* @param entity The entity with the camera component
|
|
1002
|
-
* @param projectionType Type of projection
|
|
1003
|
-
* @param fov Field of view
|
|
1004
|
-
* @param aspect Aspect ratio
|
|
1005
|
-
* @param near Near plane
|
|
1006
|
-
* @param far Far plane
|
|
1007
|
-
* @returns boolean indicating success
|
|
1008
|
-
*/
|
|
1009
|
-
static SetProjection(entity, projectionType, fov, aspect, near, far) {
|
|
1010
|
-
return Boolean(
|
|
1011
|
-
RpcClient.Call("Camera_SetProjection", {
|
|
1012
|
-
entityHandle: entity,
|
|
1013
|
-
projectionType,
|
|
1014
|
-
fov,
|
|
1015
|
-
aspect,
|
|
1016
|
-
near,
|
|
1017
|
-
far
|
|
1018
|
-
})
|
|
1019
|
-
);
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Set orthographic projection parameters
|
|
1023
|
-
* @param entity The entity with the camera component
|
|
1024
|
-
* @param left Left plane
|
|
1025
|
-
* @param right Right plane
|
|
1026
|
-
* @param bottom Bottom plane
|
|
1027
|
-
* @param top Top plane
|
|
1028
|
-
* @param near Near plane
|
|
1029
|
-
* @param far Far plane
|
|
1030
|
-
* @returns boolean indicating success
|
|
1031
|
-
*/
|
|
1032
|
-
static SetOrthographic(entity, left, right, bottom, top, near, far) {
|
|
1033
|
-
return Boolean(
|
|
1034
|
-
RpcClient.Call("Camera_SetOrthographic", {
|
|
1035
|
-
entityHandle: entity,
|
|
1036
|
-
left,
|
|
1037
|
-
right,
|
|
1038
|
-
bottom,
|
|
1039
|
-
top,
|
|
1040
|
-
near,
|
|
1041
|
-
far
|
|
1042
|
-
})
|
|
1043
|
-
);
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Make the camera look at a target point
|
|
1047
|
-
* @param entity The entity with the camera component
|
|
1048
|
-
* @param targetX Target X coordinate
|
|
1049
|
-
* @param targetY Target Y coordinate
|
|
1050
|
-
* @param targetZ Target Z coordinate
|
|
1051
|
-
* @param upX Up vector X
|
|
1052
|
-
* @param upY Up vector Y
|
|
1053
|
-
* @param upZ Up vector Z
|
|
1054
|
-
* @param worldUpX World up X
|
|
1055
|
-
* @param worldUpY World up Y
|
|
1056
|
-
* @param worldUpZ World up Z
|
|
1057
|
-
* @returns boolean indicating success
|
|
1058
|
-
*/
|
|
1059
|
-
static LookAt(entity, targetX, targetY, targetZ, upX, upY, upZ, worldUpX, worldUpY, worldUpZ) {
|
|
1060
|
-
return Boolean(
|
|
1061
|
-
RpcClient.Call("Camera_LookAt", {
|
|
1062
|
-
entityHandle: entity,
|
|
1063
|
-
targetX,
|
|
1064
|
-
targetY,
|
|
1065
|
-
targetZ,
|
|
1066
|
-
upX,
|
|
1067
|
-
upY,
|
|
1068
|
-
upZ,
|
|
1069
|
-
worldUpX,
|
|
1070
|
-
worldUpY,
|
|
1071
|
-
worldUpZ
|
|
1072
|
-
})
|
|
1073
|
-
);
|
|
1074
|
-
}
|
|
1075
|
-
/**
|
|
1076
|
-
* Set the culling mask for the camera
|
|
1077
|
-
* @param entity The entity with the camera component
|
|
1078
|
-
* @param mask The culling mask
|
|
1079
|
-
* @returns boolean indicating success
|
|
1080
|
-
*/
|
|
1081
|
-
static SetCullingMask(entity, mask) {
|
|
1082
|
-
return Boolean(
|
|
1083
|
-
RpcClient.Call("Camera_SetCullingMask", {
|
|
1084
|
-
entityHandle: entity,
|
|
1085
|
-
mask
|
|
1086
|
-
})
|
|
1087
|
-
);
|
|
1088
|
-
}
|
|
1089
|
-
/**
|
|
1090
|
-
* Set the render texture for the camera
|
|
1091
|
-
* @param entity The entity with the camera component
|
|
1092
|
-
* @param textureHandle The render texture handle
|
|
1093
|
-
* @returns boolean indicating success
|
|
1094
|
-
*/
|
|
1095
|
-
static SetRenderTexture(entity, textureHandle) {
|
|
1096
|
-
return Boolean(
|
|
1097
|
-
RpcClient.Call("Camera_SetRenderTexture", {
|
|
1098
|
-
entityHandle: entity,
|
|
1099
|
-
renderTextureHandle: textureHandle
|
|
1100
|
-
})
|
|
1101
|
-
);
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
// library/render/light.ts
|
|
1106
|
-
var LightManager = class {
|
|
1107
|
-
/**
|
|
1108
|
-
* Create a Light component and attach it to the specified entity
|
|
1109
|
-
* @param entity The entity to attach the light to
|
|
1110
|
-
* @param type The type of light to create
|
|
1111
|
-
* @returns boolean indicating success
|
|
1112
|
-
*/
|
|
1113
|
-
static Create(entity, type) {
|
|
1114
|
-
return Boolean(
|
|
1115
|
-
RpcClient.Call("Light_Create", {
|
|
1116
|
-
entityHandle: entity,
|
|
1117
|
-
lightType: type
|
|
1118
|
-
// 0=Spot,1=Directional,2=Point,3=Area
|
|
1119
|
-
})
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
|
-
/**
|
|
1123
|
-
* Destroy the Light component from the specified entity
|
|
1124
|
-
* @param entity The entity to remove the light from
|
|
1125
|
-
* @returns boolean indicating success
|
|
1126
|
-
*/
|
|
1127
|
-
static Destroy(entity) {
|
|
1128
|
-
return Boolean(RpcClient.Call("Light_Destroy", { entityHandle: entity }));
|
|
1129
|
-
}
|
|
1130
|
-
/**
|
|
1131
|
-
* Check if the entity has a Light component
|
|
1132
|
-
* @param entity The entity to check
|
|
1133
|
-
* @returns boolean indicating if light component exists
|
|
1134
|
-
*/
|
|
1135
|
-
static HasComponent(entity) {
|
|
1136
|
-
return Boolean(
|
|
1137
|
-
RpcClient.Call("Light_HasComponent", { entityHandle: entity })
|
|
1138
|
-
);
|
|
1139
|
-
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Set the type of light
|
|
1142
|
-
* @param entity The entity with the light component
|
|
1143
|
-
* @param type The light type
|
|
1144
|
-
* @returns boolean indicating success
|
|
1145
|
-
*/
|
|
1146
|
-
static SetType(entity, type) {
|
|
1147
|
-
return Boolean(
|
|
1148
|
-
RpcClient.Call("Light_SetType", {
|
|
1149
|
-
entityHandle: entity,
|
|
1150
|
-
lightType: type
|
|
1151
|
-
// 0=Spot,1=Directional,2=Point,3=Area
|
|
1152
|
-
})
|
|
1153
|
-
);
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Set the color of the light
|
|
1157
|
-
* @param entity The entity with the light component
|
|
1158
|
-
* @param r Red component (0-1)
|
|
1159
|
-
* @param g Green component (0-1)
|
|
1160
|
-
* @param b Blue component (0-1)
|
|
1161
|
-
* @returns boolean indicating success
|
|
1162
|
-
*/
|
|
1163
|
-
static SetColor(entity, rgb) {
|
|
1164
|
-
return Boolean(
|
|
1165
|
-
RpcClient.Call("Light_SetColor", {
|
|
1166
|
-
entityHandle: entity,
|
|
1167
|
-
r: rgb[0],
|
|
1168
|
-
g: rgb[1],
|
|
1169
|
-
b: rgb[2]
|
|
1170
|
-
})
|
|
1171
|
-
);
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Set the intensity of the light
|
|
1175
|
-
* @param entity The entity with the light component
|
|
1176
|
-
* @param intensity The light intensity
|
|
1177
|
-
* @returns boolean indicating success
|
|
1178
|
-
*/
|
|
1179
|
-
static SetIntensity(entity, intensity) {
|
|
1180
|
-
return Boolean(
|
|
1181
|
-
RpcClient.Call("Light_SetIntensity", {
|
|
1182
|
-
entityHandle: entity,
|
|
1183
|
-
intensity
|
|
1184
|
-
})
|
|
1185
|
-
);
|
|
1186
|
-
}
|
|
1187
|
-
/**
|
|
1188
|
-
* Set the range of the light
|
|
1189
|
-
* @param entity The entity with the light component
|
|
1190
|
-
* @param range The light range
|
|
1191
|
-
* @returns boolean indicating success
|
|
1192
|
-
*/
|
|
1193
|
-
static SetRange(entity, range) {
|
|
1194
|
-
return Boolean(
|
|
1195
|
-
RpcClient.Call("Light_SetRange", {
|
|
1196
|
-
entityHandle: entity,
|
|
1197
|
-
range
|
|
1198
|
-
})
|
|
1199
|
-
);
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* Set the spot angle for spot lights
|
|
1203
|
-
* @param entity The entity with the light component
|
|
1204
|
-
* @param angle The spot angle
|
|
1205
|
-
* @param asDegrees Whether the angle is in degrees (default: true)
|
|
1206
|
-
* @returns boolean indicating success
|
|
1207
|
-
*/
|
|
1208
|
-
static SetSpotAngle(entity, angle, asDegrees = true) {
|
|
1209
|
-
return Boolean(
|
|
1210
|
-
RpcClient.Call("Light_SetSpotAngle", {
|
|
1211
|
-
entityHandle: entity,
|
|
1212
|
-
angle,
|
|
1213
|
-
// third param "bool" unused in bridge—always true
|
|
1214
|
-
value: asDegrees
|
|
1215
|
-
})
|
|
1216
|
-
);
|
|
1217
|
-
}
|
|
1218
|
-
/**
|
|
1219
|
-
* Set the shadow mode for the light
|
|
1220
|
-
* @param entity The entity with the light component
|
|
1221
|
-
* @param mode The shadow mode
|
|
1222
|
-
* @returns boolean indicating success
|
|
1223
|
-
*/
|
|
1224
|
-
static SetShadows(entity, mode) {
|
|
1225
|
-
return Boolean(
|
|
1226
|
-
RpcClient.Call("Light_SetShadows", {
|
|
1227
|
-
entityHandle: entity,
|
|
1228
|
-
shadowType: mode
|
|
1229
|
-
// 0=NoShadows,1=Hard,2=Soft
|
|
1230
|
-
})
|
|
1231
|
-
);
|
|
1232
|
-
}
|
|
1233
|
-
/**
|
|
1234
|
-
* Set the culling mask for the light
|
|
1235
|
-
* @param entity The entity with the light component
|
|
1236
|
-
* @param mask The culling mask
|
|
1237
|
-
* @returns boolean indicating success
|
|
1238
|
-
*/
|
|
1239
|
-
static SetCullingMask(entity, mask) {
|
|
1240
|
-
return Boolean(
|
|
1241
|
-
RpcClient.Call("Light_SetCullingMask", {
|
|
1242
|
-
entityHandle: entity,
|
|
1243
|
-
mask
|
|
1244
|
-
})
|
|
1245
|
-
);
|
|
1246
|
-
}
|
|
1247
|
-
};
|
|
1248
|
-
var LightShadowMode = /* @__PURE__ */ ((LightShadowMode2) => {
|
|
1249
|
-
LightShadowMode2[LightShadowMode2["NoShadows"] = 0] = "NoShadows";
|
|
1250
|
-
LightShadowMode2[LightShadowMode2["Hard"] = 1] = "Hard";
|
|
1251
|
-
LightShadowMode2[LightShadowMode2["Soft"] = 2] = "Soft";
|
|
1252
|
-
return LightShadowMode2;
|
|
1253
|
-
})(LightShadowMode || {});
|
|
1254
|
-
var LightType = /* @__PURE__ */ ((LightType2) => {
|
|
1255
|
-
LightType2[LightType2["Spot"] = 0] = "Spot";
|
|
1256
|
-
LightType2[LightType2["Directional"] = 1] = "Directional";
|
|
1257
|
-
LightType2[LightType2["Point"] = 2] = "Point";
|
|
1258
|
-
LightType2[LightType2["Area"] = 3] = "Area";
|
|
1259
|
-
return LightType2;
|
|
1260
|
-
})(LightType || {});
|
|
1261
|
-
|
|
1262
|
-
// library/render/material.ts
|
|
1263
|
-
var ShaderType = /* @__PURE__ */ ((ShaderType2) => {
|
|
1264
|
-
ShaderType2["URP_LIT"] = "Universal Render Pipeline/Lit";
|
|
1265
|
-
return ShaderType2;
|
|
1266
|
-
})(ShaderType || {});
|
|
1267
|
-
var ShaderProperties = /* @__PURE__ */ ((ShaderProperties2) => {
|
|
1268
|
-
ShaderProperties2["BaseMap"] = "_BaseMap";
|
|
1269
|
-
ShaderProperties2["BaseColor"] = "_BaseColor";
|
|
1270
|
-
ShaderProperties2["Cutoff"] = "_Cutoff";
|
|
1271
|
-
ShaderProperties2["Smoothness"] = "_Smoothness";
|
|
1272
|
-
ShaderProperties2["SmoothnessTextureChannel"] = "_SmoothnessTextureChannel";
|
|
1273
|
-
ShaderProperties2["Metallic"] = "_Metallic";
|
|
1274
|
-
ShaderProperties2["MetallicGlossMap"] = "_MetallicGlossMap";
|
|
1275
|
-
ShaderProperties2["SpecColor"] = "_SpecColor";
|
|
1276
|
-
ShaderProperties2["SpecGlossMap"] = "_SpecGlossMap";
|
|
1277
|
-
ShaderProperties2["SpecularHighlights"] = "_SpecularHighlights";
|
|
1278
|
-
ShaderProperties2["EnvironmentReflections"] = "_EnvironmentReflections";
|
|
1279
|
-
ShaderProperties2["BumpScale"] = "_BumpScale";
|
|
1280
|
-
ShaderProperties2["BumpMap"] = "_BumpMap";
|
|
1281
|
-
ShaderProperties2["Parallax"] = "_Parallax";
|
|
1282
|
-
ShaderProperties2["ParallaxMap"] = "_ParallaxMap";
|
|
1283
|
-
ShaderProperties2["OcclusionStrength"] = "_OcclusionStrength";
|
|
1284
|
-
ShaderProperties2["OcclusionMap"] = "_OcclusionMap";
|
|
1285
|
-
ShaderProperties2["EmissionColor"] = "_EmissionColor";
|
|
1286
|
-
ShaderProperties2["EmissionMap"] = "_EmissionMap";
|
|
1287
|
-
ShaderProperties2["DetailMask"] = "_DetailMask";
|
|
1288
|
-
ShaderProperties2["DetailAlbedoMapScale"] = "_DetailAlbedoMapScale";
|
|
1289
|
-
ShaderProperties2["DetailAlbedoMap"] = "_DetailAlbedoMap";
|
|
1290
|
-
ShaderProperties2["DetailNormalMapScale"] = "_DetailNormalMapScale";
|
|
1291
|
-
ShaderProperties2["DetailNormalMap"] = "_DetailNormalMap";
|
|
1292
|
-
return ShaderProperties2;
|
|
1293
|
-
})(ShaderProperties || {});
|
|
1294
|
-
var MaterialManager = class {
|
|
1295
|
-
static Create(shader = "Universal Render Pipeline/Lit" /* URP_LIT */, entity, submeshIndex = 0) {
|
|
1296
|
-
const matHandle = Number(
|
|
1297
|
-
RpcClient.Call("Material_Create", {
|
|
1298
|
-
shaderName: shader,
|
|
1299
|
-
clientId: RpcClient.GetClientId()
|
|
1300
|
-
})
|
|
1301
|
-
);
|
|
1302
|
-
if (entity !== void 0) {
|
|
1303
|
-
RpcClient.Call("Renderable_SetMaterial", {
|
|
1304
|
-
entityHandle: entity,
|
|
1305
|
-
materialHandle: matHandle,
|
|
1306
|
-
index: submeshIndex
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
return matHandle;
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Destroy a material
|
|
1313
|
-
* @param handle The material handle to destroy
|
|
1314
|
-
* @returns boolean indicating success
|
|
1315
|
-
*/
|
|
1316
|
-
static Destroy(handle) {
|
|
1317
|
-
return Boolean(
|
|
1318
|
-
RpcClient.Call("Material_Destroy", { materialHandle: handle })
|
|
1319
|
-
);
|
|
1320
|
-
}
|
|
1321
|
-
/**
|
|
1322
|
-
* Create a material instance
|
|
1323
|
-
* @param handle The material handle to create an instance from
|
|
1324
|
-
* @returns The material instance handle
|
|
1325
|
-
*/
|
|
1326
|
-
static CreateInstance(handle) {
|
|
1327
|
-
return Number(
|
|
1328
|
-
RpcClient.Call("Material_CreateInstance", {
|
|
1329
|
-
materialHandle: handle,
|
|
1330
|
-
clientId: RpcClient.GetClientId()
|
|
1331
|
-
})
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
|
-
/**
|
|
1335
|
-
* Set a float property on the material
|
|
1336
|
-
* @param handle The material handle
|
|
1337
|
-
* @param prop The property name
|
|
1338
|
-
* @param value The float value
|
|
1339
|
-
* @returns boolean indicating success
|
|
1340
|
-
*/
|
|
1341
|
-
static SetFloat(handle, prop, value) {
|
|
1342
|
-
return Boolean(
|
|
1343
|
-
RpcClient.Call("Material_SetFloat", {
|
|
1344
|
-
materialHandle: handle,
|
|
1345
|
-
propertyName: prop,
|
|
1346
|
-
value
|
|
1347
|
-
})
|
|
1348
|
-
);
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Set a vector property on the material
|
|
1352
|
-
* @param handle The material handle
|
|
1353
|
-
* @param prop The property name
|
|
1354
|
-
* @param value vec4 value
|
|
1355
|
-
* @returns boolean indicating success
|
|
1356
|
-
*/
|
|
1357
|
-
static SetVector(handle, prop, value) {
|
|
1358
|
-
return Boolean(
|
|
1359
|
-
RpcClient.Call("Material_SetVector", {
|
|
1360
|
-
materialHandle: handle,
|
|
1361
|
-
propertyName: prop,
|
|
1362
|
-
x: value[0],
|
|
1363
|
-
y: value[1],
|
|
1364
|
-
z: value[2],
|
|
1365
|
-
w: value[3]
|
|
1366
|
-
})
|
|
1367
|
-
);
|
|
1368
|
-
}
|
|
1369
|
-
/**
|
|
1370
|
-
* Set a color property on the material
|
|
1371
|
-
* @param handle The material handle
|
|
1372
|
-
* @param prop The property name
|
|
1373
|
-
* @param rgba vec4 color [0.0, 1.0]
|
|
1374
|
-
* @returns boolean indicating success
|
|
1375
|
-
*/
|
|
1376
|
-
static SetColor(handle, prop, rgba) {
|
|
1377
|
-
return Boolean(
|
|
1378
|
-
RpcClient.Call("Material_SetColor", {
|
|
1379
|
-
materialHandle: handle,
|
|
1380
|
-
propertyName: prop,
|
|
1381
|
-
r: rgba[0],
|
|
1382
|
-
g: rgba[1],
|
|
1383
|
-
b: rgba[2],
|
|
1384
|
-
a: rgba[3]
|
|
1385
|
-
})
|
|
1386
|
-
);
|
|
1387
|
-
}
|
|
1388
|
-
/**
|
|
1389
|
-
* Set a texture property on the material
|
|
1390
|
-
* @param handle The material handle
|
|
1391
|
-
* @param prop The property name
|
|
1392
|
-
* @param tex The texture handle
|
|
1393
|
-
* @returns boolean indicating success
|
|
1394
|
-
*/
|
|
1395
|
-
static SetTexture(handle, prop, tex) {
|
|
1396
|
-
return Boolean(
|
|
1397
|
-
RpcClient.Call("Material_SetTexture", {
|
|
1398
|
-
materialHandle: handle,
|
|
1399
|
-
propertyName: prop,
|
|
1400
|
-
textureHandle: tex
|
|
1401
|
-
})
|
|
1402
|
-
);
|
|
1403
|
-
}
|
|
1404
|
-
/**
|
|
1405
|
-
* Get a float property from the material
|
|
1406
|
-
* @param handle The material handle
|
|
1407
|
-
* @param prop The property name
|
|
1408
|
-
* @returns The float value
|
|
1409
|
-
*/
|
|
1410
|
-
static GetFloat(handle, prop) {
|
|
1411
|
-
return Number(
|
|
1412
|
-
RpcClient.Call("Material_GetFloat", {
|
|
1413
|
-
materialHandle: handle,
|
|
1414
|
-
propertyName: prop
|
|
1415
|
-
})
|
|
1416
|
-
);
|
|
1417
|
-
}
|
|
1418
|
-
/**
|
|
1419
|
-
* Get a color property from the material
|
|
1420
|
-
* @param handle The material handle
|
|
1421
|
-
* @param prop The property name
|
|
1422
|
-
* @returns The color as a string
|
|
1423
|
-
*/
|
|
1424
|
-
static GetColor(handle, prop) {
|
|
1425
|
-
return RpcClient.Call("Material_GetColor", {
|
|
1426
|
-
materialHandle: handle,
|
|
1427
|
-
propertyName: prop
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
};
|
|
1431
|
-
|
|
1432
|
-
// library/utilities/base64.ts
|
|
1433
|
-
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1434
|
-
var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
|
|
1435
|
-
for (let i = 0; i < chars.length; i++) {
|
|
1436
|
-
lookup[chars.charCodeAt(i)] = i;
|
|
1437
|
-
}
|
|
1438
|
-
var base64Encode = (arraybuffer) => {
|
|
1439
|
-
let bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
|
|
1440
|
-
for (i = 0; i < len; i += 3) {
|
|
1441
|
-
base64 += chars[bytes[i] >> 2];
|
|
1442
|
-
base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
|
|
1443
|
-
base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
|
|
1444
|
-
base64 += chars[bytes[i + 2] & 63];
|
|
1445
|
-
}
|
|
1446
|
-
if (len % 3 === 2) {
|
|
1447
|
-
base64 = base64.substring(0, base64.length - 1) + "=";
|
|
1448
|
-
} else if (len % 3 === 1) {
|
|
1449
|
-
base64 = base64.substring(0, base64.length - 2) + "==";
|
|
1450
|
-
}
|
|
1451
|
-
return base64;
|
|
1452
|
-
};
|
|
1453
|
-
var base64Decode = (base64) => {
|
|
1454
|
-
let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
|
|
1455
|
-
if (base64[base64.length - 1] === "=") {
|
|
1456
|
-
bufferLength--;
|
|
1457
|
-
if (base64[base64.length - 2] === "=") {
|
|
1458
|
-
bufferLength--;
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
|
|
1462
|
-
for (i = 0; i < len; i += 4) {
|
|
1463
|
-
encoded1 = lookup[base64.charCodeAt(i)];
|
|
1464
|
-
encoded2 = lookup[base64.charCodeAt(i + 1)];
|
|
1465
|
-
encoded3 = lookup[base64.charCodeAt(i + 2)];
|
|
1466
|
-
encoded4 = lookup[base64.charCodeAt(i + 3)];
|
|
1467
|
-
bytes[p++] = encoded1 << 2 | encoded2 >> 4;
|
|
1468
|
-
bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
|
1469
|
-
bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
|
1470
|
-
}
|
|
1471
|
-
return arraybuffer;
|
|
1472
|
-
};
|
|
1473
|
-
|
|
1474
|
-
// library/render/mesh.ts
|
|
1475
|
-
var MeshManager = class {
|
|
1476
|
-
static Create(entity) {
|
|
1477
|
-
const meshHandle = Number(
|
|
1478
|
-
RpcClient.Call("Mesh_Create", {
|
|
1479
|
-
clientId: RpcClient.GetClientId()
|
|
1480
|
-
})
|
|
1481
|
-
);
|
|
1482
|
-
if (entity !== void 0) {
|
|
1483
|
-
RpcClient.Call("Renderable_SetMesh", {
|
|
1484
|
-
entityHandle: entity,
|
|
1485
|
-
meshHandle
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
return meshHandle;
|
|
1489
|
-
}
|
|
1490
|
-
/**
|
|
1491
|
-
* Destroy a mesh
|
|
1492
|
-
* @param handle The mesh handle to destroy
|
|
1493
|
-
* @returns boolean indicating success
|
|
1494
|
-
*/
|
|
1495
|
-
static Destroy(handle) {
|
|
1496
|
-
return Boolean(RpcClient.Call("Mesh_Destroy", { meshHandle: handle }));
|
|
1497
|
-
}
|
|
1498
|
-
static SetVertices(handle, verticesOrBase64) {
|
|
1499
|
-
let base64Vertices;
|
|
1500
|
-
if (typeof verticesOrBase64 === "string") {
|
|
1501
|
-
base64Vertices = verticesOrBase64;
|
|
1502
|
-
} else {
|
|
1503
|
-
const buffer = new Float32Array(verticesOrBase64.length * 3);
|
|
1504
|
-
for (let i = 0; i < verticesOrBase64.length; i++) {
|
|
1505
|
-
const n = verticesOrBase64[i];
|
|
1506
|
-
buffer[i * 3] = n[0];
|
|
1507
|
-
buffer[i * 3 + 1] = n[1];
|
|
1508
|
-
buffer[i * 3 + 2] = n[2];
|
|
1509
|
-
}
|
|
1510
|
-
base64Vertices = base64Encode(buffer.buffer);
|
|
1511
|
-
}
|
|
1512
|
-
return Boolean(
|
|
1513
|
-
RpcClient.Call("Mesh_SetVertices", {
|
|
1514
|
-
meshHandle: handle,
|
|
1515
|
-
base64Vertices
|
|
1516
|
-
})
|
|
1517
|
-
);
|
|
1518
|
-
}
|
|
1519
|
-
static SetTriangles(handle, indicesOrBase64) {
|
|
1520
|
-
let base64Triangles;
|
|
1521
|
-
if (typeof indicesOrBase64 === "string") {
|
|
1522
|
-
base64Triangles = indicesOrBase64;
|
|
1523
|
-
} else {
|
|
1524
|
-
const buffer = new Float32Array(indicesOrBase64.length * 3);
|
|
1525
|
-
for (let i = 0; i < indicesOrBase64.length; i++) {
|
|
1526
|
-
const n = indicesOrBase64[i];
|
|
1527
|
-
buffer[i * 3] = n[0];
|
|
1528
|
-
buffer[i * 3 + 1] = n[1];
|
|
1529
|
-
buffer[i * 3 + 2] = n[2];
|
|
1530
|
-
}
|
|
1531
|
-
base64Triangles = base64Encode(buffer.buffer);
|
|
1532
|
-
}
|
|
1533
|
-
return Boolean(
|
|
1534
|
-
RpcClient.Call("Mesh_SetTriangles", {
|
|
1535
|
-
meshHandle: handle,
|
|
1536
|
-
base64Triangles
|
|
1537
|
-
})
|
|
1538
|
-
);
|
|
1539
|
-
}
|
|
1540
|
-
static SetUVs(handle, uvsOrBase64) {
|
|
1541
|
-
let base64Uvs;
|
|
1542
|
-
if (typeof uvsOrBase64 === "string") {
|
|
1543
|
-
base64Uvs = uvsOrBase64;
|
|
1544
|
-
} else {
|
|
1545
|
-
const buffer = new Float32Array(uvsOrBase64.length * 2);
|
|
1546
|
-
for (let i = 0; i < uvsOrBase64.length; i++) {
|
|
1547
|
-
const n = uvsOrBase64[i];
|
|
1548
|
-
buffer[i * 2] = n[0];
|
|
1549
|
-
buffer[i * 2 + 1] = n[1];
|
|
1550
|
-
}
|
|
1551
|
-
base64Uvs = base64Encode(buffer.buffer);
|
|
1552
|
-
}
|
|
1553
|
-
return Boolean(
|
|
1554
|
-
RpcClient.Call("Mesh_SetUVs", {
|
|
1555
|
-
meshHandle: handle,
|
|
1556
|
-
base64Uvs
|
|
1557
|
-
})
|
|
1558
|
-
);
|
|
1559
|
-
}
|
|
1560
|
-
static SetNormals(handle, normalsOrBase64) {
|
|
1561
|
-
let base64Normals;
|
|
1562
|
-
if (typeof normalsOrBase64 === "string") {
|
|
1563
|
-
base64Normals = normalsOrBase64;
|
|
1564
|
-
} else {
|
|
1565
|
-
const buffer = new Float32Array(normalsOrBase64.length * 3);
|
|
1566
|
-
for (let i = 0; i < normalsOrBase64.length; i++) {
|
|
1567
|
-
const n = normalsOrBase64[i];
|
|
1568
|
-
buffer[i * 3] = n[0];
|
|
1569
|
-
buffer[i * 3 + 1] = n[1];
|
|
1570
|
-
buffer[i * 3 + 2] = n[2];
|
|
1571
|
-
}
|
|
1572
|
-
base64Normals = base64Encode(buffer.buffer);
|
|
1573
|
-
}
|
|
1574
|
-
return Boolean(
|
|
1575
|
-
RpcClient.Call("Mesh_SetNormals", {
|
|
1576
|
-
meshHandle: handle,
|
|
1577
|
-
base64Normals
|
|
1578
|
-
})
|
|
1579
|
-
);
|
|
1580
|
-
}
|
|
1581
|
-
/**
|
|
1582
|
-
* Recalculate normals for the mesh
|
|
1583
|
-
* @param handle The mesh handle
|
|
1584
|
-
* @returns boolean indicating success
|
|
1585
|
-
*/
|
|
1586
|
-
static RecalcNormals(handle) {
|
|
1587
|
-
return Boolean(
|
|
1588
|
-
RpcClient.Call("Mesh_RecalculateNormals", { meshHandle: handle })
|
|
1589
|
-
);
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Recalculate bounds for the mesh
|
|
1593
|
-
* @param handle The mesh handle
|
|
1594
|
-
* @returns boolean indicating success
|
|
1595
|
-
*/
|
|
1596
|
-
static RecalcBounds(handle) {
|
|
1597
|
-
return Boolean(
|
|
1598
|
-
RpcClient.Call("Mesh_RecalculateBounds", { meshHandle: handle })
|
|
1599
|
-
);
|
|
1600
|
-
}
|
|
1601
|
-
};
|
|
1602
|
-
|
|
1603
|
-
// library/render/primitives.ts
|
|
1604
|
-
function NewCubeMesh() {
|
|
1605
|
-
const cubeVertices = [
|
|
1606
|
-
[-0.5, -0.5, -0.5],
|
|
1607
|
-
// 0: left-bottom-back
|
|
1608
|
-
[0.5, -0.5, -0.5],
|
|
1609
|
-
// 1: right-bottom-back
|
|
1610
|
-
[0.5, 0.5, -0.5],
|
|
1611
|
-
// 2: right-top-back
|
|
1612
|
-
[-0.5, 0.5, -0.5],
|
|
1613
|
-
// 3: left-top-back
|
|
1614
|
-
[-0.5, -0.5, 0.5],
|
|
1615
|
-
// 4: left-bottom-front
|
|
1616
|
-
[0.5, -0.5, 0.5],
|
|
1617
|
-
// 5: right-bottom-front
|
|
1618
|
-
[0.5, 0.5, 0.5],
|
|
1619
|
-
// 6: right-top-front
|
|
1620
|
-
[-0.5, 0.5, 0.5]
|
|
1621
|
-
// 7: left-top-front
|
|
1622
|
-
];
|
|
1623
|
-
const cubeIndices = [
|
|
1624
|
-
// back face
|
|
1625
|
-
[0, 2, 1],
|
|
1626
|
-
[0, 3, 2],
|
|
1627
|
-
// front face
|
|
1628
|
-
[4, 5, 6],
|
|
1629
|
-
[4, 6, 7],
|
|
1630
|
-
// bottom face
|
|
1631
|
-
[0, 1, 5],
|
|
1632
|
-
[0, 5, 4],
|
|
1633
|
-
// top face
|
|
1634
|
-
[3, 7, 6],
|
|
1635
|
-
[3, 6, 2],
|
|
1636
|
-
// left face
|
|
1637
|
-
[0, 4, 7],
|
|
1638
|
-
[0, 7, 3],
|
|
1639
|
-
// right face
|
|
1640
|
-
[1, 2, 6],
|
|
1641
|
-
[1, 6, 5]
|
|
1642
|
-
];
|
|
1643
|
-
const meshHandle = MeshManager.Create();
|
|
1644
|
-
MeshManager.SetVertices(meshHandle, cubeVertices);
|
|
1645
|
-
MeshManager.SetTriangles(meshHandle, cubeIndices);
|
|
1646
|
-
MeshManager.RecalcNormals(meshHandle);
|
|
1647
|
-
MeshManager.RecalcBounds(meshHandle);
|
|
1648
|
-
return meshHandle;
|
|
1649
|
-
}
|
|
1650
|
-
function NewQuadMesh() {
|
|
1651
|
-
const quadVertices = [
|
|
1652
|
-
[-0.5, -0.5, 0],
|
|
1653
|
-
// 0: bottom-left
|
|
1654
|
-
[0.5, -0.5, 0],
|
|
1655
|
-
// 1: bottom-right
|
|
1656
|
-
[0.5, 0.5, 0],
|
|
1657
|
-
// 2: top-right
|
|
1658
|
-
[-0.5, 0.5, 0]
|
|
1659
|
-
// 3: top-left
|
|
1660
|
-
];
|
|
1661
|
-
const quadUVs = [
|
|
1662
|
-
[0, 1],
|
|
1663
|
-
// 0: bottom-left
|
|
1664
|
-
[1, 1],
|
|
1665
|
-
// 1: bottom-right
|
|
1666
|
-
[1, 0],
|
|
1667
|
-
// 2: top-right
|
|
1668
|
-
[0, 0]
|
|
1669
|
-
// 3: top-left
|
|
1670
|
-
];
|
|
1671
|
-
const quadIndices = [
|
|
1672
|
-
[0, 2, 1],
|
|
1673
|
-
[0, 3, 2]
|
|
1674
|
-
];
|
|
1675
|
-
const meshHandle = MeshManager.Create();
|
|
1676
|
-
MeshManager.SetVertices(meshHandle, quadVertices);
|
|
1677
|
-
MeshManager.SetUVs(meshHandle, quadUVs);
|
|
1678
|
-
MeshManager.SetTriangles(meshHandle, quadIndices);
|
|
1679
|
-
MeshManager.RecalcNormals(meshHandle);
|
|
1680
|
-
MeshManager.RecalcBounds(meshHandle);
|
|
1681
|
-
return meshHandle;
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
// library/render/renderable.ts
|
|
1685
|
-
var RenderableManager = class _RenderableManager {
|
|
1686
|
-
/**
|
|
1687
|
-
* Create a renderable component and attach it to the specified entity
|
|
1688
|
-
* @param entity The entity to attach the renderable component to
|
|
1689
|
-
* @returns boolean indicating success
|
|
1690
|
-
*/
|
|
1691
|
-
static Create(entity) {
|
|
1692
|
-
return Boolean(
|
|
1693
|
-
RpcClient.Call("Renderable_Create", { entityHandle: entity })
|
|
1694
|
-
);
|
|
1695
|
-
}
|
|
1696
|
-
/**
|
|
1697
|
-
* Destroy the Renderable component on this entity.
|
|
1698
|
-
* @param entityHandle The entity to remove the renderable component from
|
|
1699
|
-
* @returns boolean indicating success
|
|
1700
|
-
*/
|
|
1701
|
-
static Destroy(entityHandle) {
|
|
1702
|
-
return Boolean(RpcClient.Call("Renderable_Destroy", { entityHandle }));
|
|
1703
|
-
}
|
|
1704
|
-
/**
|
|
1705
|
-
* Returns whether this entity currently has a Renderable.
|
|
1706
|
-
* @param entityHandle The entity to check
|
|
1707
|
-
* @returns boolean indicating if renderable component exists
|
|
1708
|
-
*/
|
|
1709
|
-
static HasComponent(entityHandle) {
|
|
1710
|
-
return Boolean(RpcClient.Call("Renderable_HasComponent", { entityHandle }));
|
|
1711
|
-
}
|
|
1712
|
-
/**
|
|
1713
|
-
* Set the mesh for the renderable component
|
|
1714
|
-
* @param entityHandle The entity with the renderable component
|
|
1715
|
-
* @param meshHandle The mesh handle to attach
|
|
1716
|
-
* @returns boolean indicating success
|
|
1717
|
-
*/
|
|
1718
|
-
static SetMesh(entityHandle, meshHandle) {
|
|
1719
|
-
if (_RenderableManager.HasComponent(entityHandle)) {
|
|
1720
|
-
return Boolean(
|
|
1721
|
-
RpcClient.Call("Renderable_SetMesh", {
|
|
1722
|
-
entityHandle,
|
|
1723
|
-
meshHandle
|
|
1724
|
-
})
|
|
1725
|
-
);
|
|
1726
|
-
} else return false;
|
|
1727
|
-
}
|
|
1728
|
-
/**
|
|
1729
|
-
* Set the material for the renderable component
|
|
1730
|
-
* @param entityHandle The entity with the renderable component
|
|
1731
|
-
* @param materialHandle The material handle to attach
|
|
1732
|
-
* @param index The submesh index (default: 0)
|
|
1733
|
-
* @returns boolean indicating success
|
|
1734
|
-
*/
|
|
1735
|
-
static SetMaterial(entityHandle, materialHandle, index = 0) {
|
|
1736
|
-
return Boolean(
|
|
1737
|
-
RpcClient.Call("Renderable_SetMaterial", {
|
|
1738
|
-
entityHandle,
|
|
1739
|
-
materialHandle,
|
|
1740
|
-
index
|
|
1741
|
-
})
|
|
1742
|
-
);
|
|
1743
|
-
}
|
|
1744
|
-
/**
|
|
1745
|
-
* Set the layer mask on this Renderable (bitmask of visible layers).
|
|
1746
|
-
* @param entityHandle The entity with the renderable component
|
|
1747
|
-
* @param layerMask The layer mask
|
|
1748
|
-
* @returns boolean indicating success
|
|
1749
|
-
*/
|
|
1750
|
-
static SetLayerMask(entityHandle, layerMask) {
|
|
1751
|
-
return Boolean(
|
|
1752
|
-
RpcClient.Call("Renderable_SetLayerMask", {
|
|
1753
|
-
entityHandle,
|
|
1754
|
-
layerMask
|
|
1755
|
-
})
|
|
1756
|
-
);
|
|
1757
|
-
}
|
|
1758
|
-
/**
|
|
1759
|
-
* Enable or disable receiving shadows on this Renderable.
|
|
1760
|
-
* @param entityHandle The entity with the renderable component
|
|
1761
|
-
* @param receive Whether to receive shadows
|
|
1762
|
-
* @returns boolean indicating success
|
|
1763
|
-
*/
|
|
1764
|
-
static SetReceiveShadows(entityHandle, receive) {
|
|
1765
|
-
return Boolean(
|
|
1766
|
-
RpcClient.Call("Renderable_SetReceiveShadows", {
|
|
1767
|
-
entityHandle,
|
|
1768
|
-
receive
|
|
1769
|
-
})
|
|
1770
|
-
);
|
|
1771
|
-
}
|
|
1772
|
-
/**
|
|
1773
|
-
* Control shadow‐casting mode.
|
|
1774
|
-
* 0 = Off, 1 = On, 2 = TwoSided, 3 = ShadowsOnly
|
|
1775
|
-
* @param entityHandle The entity with the renderable component
|
|
1776
|
-
* @param shadowMode The shadow casting mode
|
|
1777
|
-
* @returns boolean indicating success
|
|
1778
|
-
*/
|
|
1779
|
-
static SetCastShadows(entityHandle, shadowMode) {
|
|
1780
|
-
return Boolean(
|
|
1781
|
-
RpcClient.Call("Renderable_SetCastShadows", {
|
|
1782
|
-
entityHandle,
|
|
1783
|
-
shadowMode
|
|
1784
|
-
})
|
|
1785
|
-
);
|
|
1786
|
-
}
|
|
1787
|
-
/**
|
|
1788
|
-
* Enable or disable frustum‐culling on this Renderable.
|
|
1789
|
-
* @param entityHandle The entity with the renderable component
|
|
1790
|
-
* @param enabled Whether to enable culling
|
|
1791
|
-
* @returns boolean indicating success
|
|
1792
|
-
*/
|
|
1793
|
-
static SetCulling(entityHandle, enabled) {
|
|
1794
|
-
return Boolean(
|
|
1795
|
-
RpcClient.Call("Renderable_SetCulling", {
|
|
1796
|
-
entityHandle,
|
|
1797
|
-
enabled
|
|
1798
|
-
})
|
|
1799
|
-
);
|
|
1800
|
-
}
|
|
1801
|
-
};
|
|
1802
|
-
|
|
1803
|
-
// library/render/texture.ts
|
|
1804
|
-
var TextureFormat = /* @__PURE__ */ ((TextureFormat2) => {
|
|
1805
|
-
TextureFormat2[TextureFormat2["Alpha8"] = 1] = "Alpha8";
|
|
1806
|
-
TextureFormat2[TextureFormat2["ARGB4444"] = 2] = "ARGB4444";
|
|
1807
|
-
TextureFormat2[TextureFormat2["RGB24"] = 3] = "RGB24";
|
|
1808
|
-
TextureFormat2[TextureFormat2["RGBA32"] = 4] = "RGBA32";
|
|
1809
|
-
TextureFormat2[TextureFormat2["ARGB32"] = 5] = "ARGB32";
|
|
1810
|
-
TextureFormat2[TextureFormat2["RGB565"] = 7] = "RGB565";
|
|
1811
|
-
TextureFormat2[TextureFormat2["R16"] = 9] = "R16";
|
|
1812
|
-
TextureFormat2[TextureFormat2["DXT1"] = 10] = "DXT1";
|
|
1813
|
-
TextureFormat2[TextureFormat2["DXT5"] = 12] = "DXT5";
|
|
1814
|
-
return TextureFormat2;
|
|
1815
|
-
})(TextureFormat || {});
|
|
1816
|
-
var TextureManager = class {
|
|
1817
|
-
/**
|
|
1818
|
-
* Create a 2D texture
|
|
1819
|
-
* @param width The texture width
|
|
1820
|
-
* @param height The texture height
|
|
1821
|
-
* @param format The texture format
|
|
1822
|
-
* @returns The texture handle
|
|
1823
|
-
*/
|
|
1824
|
-
static Create2D(width, height, format) {
|
|
1825
|
-
return Number(
|
|
1826
|
-
RpcClient.Call("Texture_Create2D", {
|
|
1827
|
-
width,
|
|
1828
|
-
height,
|
|
1829
|
-
format,
|
|
1830
|
-
clientId: RpcClient.GetClientId()
|
|
1831
|
-
})
|
|
1832
|
-
);
|
|
1833
|
-
}
|
|
1834
|
-
/**
|
|
1835
|
-
* Create a 2D texture and attach it to a material
|
|
1836
|
-
* @param width The texture width
|
|
1837
|
-
* @param height The texture height
|
|
1838
|
-
* @param format The texture format
|
|
1839
|
-
* @param materialHandle The material handle to attach to
|
|
1840
|
-
* @param propertyName The material property name
|
|
1841
|
-
* @returns The texture handle
|
|
1842
|
-
*/
|
|
1843
|
-
static Create2DForMaterial(width, height, format, materialHandle, propertyName) {
|
|
1844
|
-
const textureHandle = Number(
|
|
1845
|
-
RpcClient.Call("Texture_Create2D", {
|
|
1846
|
-
width,
|
|
1847
|
-
height,
|
|
1848
|
-
format,
|
|
1849
|
-
clientId: RpcClient.GetClientId()
|
|
1850
|
-
})
|
|
1851
|
-
);
|
|
1852
|
-
RpcClient.Call("Material_SetTexture", {
|
|
1853
|
-
materialHandle,
|
|
1854
|
-
propertyName,
|
|
1855
|
-
textureHandle
|
|
1856
|
-
});
|
|
1857
|
-
return textureHandle;
|
|
1858
|
-
}
|
|
1859
|
-
/**
|
|
1860
|
-
* Create a render texture
|
|
1861
|
-
* @param width The texture width
|
|
1862
|
-
* @param height The texture height
|
|
1863
|
-
* @param depth The texture depth
|
|
1864
|
-
* @param format The texture format
|
|
1865
|
-
* @returns The texture handle
|
|
1866
|
-
*/
|
|
1867
|
-
static CreateRenderTexture(width, height, depth, format) {
|
|
1868
|
-
return Number(
|
|
1869
|
-
RpcClient.Call("Texture_CreateRenderTexture", {
|
|
1870
|
-
width,
|
|
1871
|
-
height,
|
|
1872
|
-
depth,
|
|
1873
|
-
format,
|
|
1874
|
-
clientId: RpcClient.GetClientId()
|
|
1875
|
-
})
|
|
1876
|
-
);
|
|
1877
|
-
}
|
|
1878
|
-
/**
|
|
1879
|
-
* Destroy a texture
|
|
1880
|
-
* @param handle The texture handle to destroy
|
|
1881
|
-
* @returns boolean indicating success
|
|
1882
|
-
*/
|
|
1883
|
-
static Destroy(handle) {
|
|
1884
|
-
return Boolean(
|
|
1885
|
-
RpcClient.Call("Texture_Destroy", { textureHandle: handle })
|
|
1886
|
-
);
|
|
1887
|
-
}
|
|
1888
|
-
/**
|
|
1889
|
-
* Set raw RGBA iamge for the texture
|
|
1890
|
-
* @param handle The texture handle
|
|
1891
|
-
* @param rgbaDataJson RGBA values
|
|
1892
|
-
* @param width The texture width
|
|
1893
|
-
* @param height The texture height
|
|
1894
|
-
* @returns boolean indicating success
|
|
1895
|
-
*/
|
|
1896
|
-
static LoadRawTextureData(handle, base64Rgba, width, height) {
|
|
1897
|
-
const base64String = base64Encode(base64Rgba);
|
|
1898
|
-
return Boolean(
|
|
1899
|
-
RpcClient.Call("Texture_LoadRawTextureData", {
|
|
1900
|
-
textureHandle: handle,
|
|
1901
|
-
base64Rgba: base64String,
|
|
1902
|
-
width,
|
|
1903
|
-
height
|
|
1904
|
-
})
|
|
1905
|
-
);
|
|
1906
|
-
}
|
|
1907
|
-
/**
|
|
1908
|
-
* Loads PNG/JPG image byte array into a texture.
|
|
1909
|
-
* @param handle The texture handle
|
|
1910
|
-
* @param imageDataJson JSON string with comma-separated RGBA values
|
|
1911
|
-
* @returns boolean indicating success
|
|
1912
|
-
*/
|
|
1913
|
-
static LoadImage(handle, image) {
|
|
1914
|
-
const base64Image = base64Encode(image);
|
|
1915
|
-
return Boolean(
|
|
1916
|
-
RpcClient.Call("Texture_LoadImage", {
|
|
1917
|
-
textureHandle: handle,
|
|
1918
|
-
base64Image
|
|
1919
|
-
})
|
|
1920
|
-
);
|
|
1921
|
-
}
|
|
1922
|
-
/**
|
|
1923
|
-
* Loads PNG/JPG image byte array into a texture.
|
|
1924
|
-
* @param handle The texture handle
|
|
1925
|
-
* @param imageDataJson JSON string with comma-separated RGBA values
|
|
1926
|
-
* @returns boolean indicating success
|
|
1927
|
-
*/
|
|
1928
|
-
static LoadImageBase64(handle, base64Image) {
|
|
1929
|
-
return Boolean(
|
|
1930
|
-
RpcClient.Call("Texture_LoadImage", {
|
|
1931
|
-
textureHandle: handle,
|
|
1932
|
-
base64Image
|
|
1933
|
-
})
|
|
1934
|
-
);
|
|
1935
|
-
}
|
|
1936
|
-
/**
|
|
1937
|
-
* Set the filter mode for the texture
|
|
1938
|
-
* @param handle The texture handle
|
|
1939
|
-
* @param mode The filter mode
|
|
1940
|
-
* @returns boolean indicating success
|
|
1941
|
-
*/
|
|
1942
|
-
static SetFilterMode(handle, mode) {
|
|
1943
|
-
return Boolean(
|
|
1944
|
-
RpcClient.Call("Texture_SetFilterMode", {
|
|
1945
|
-
textureHandle: handle,
|
|
1946
|
-
filterMode: mode
|
|
1947
|
-
})
|
|
1948
|
-
);
|
|
1949
|
-
}
|
|
1950
|
-
/**
|
|
1951
|
-
* Set the wrap mode for the texture
|
|
1952
|
-
* @param handle The texture handle
|
|
1953
|
-
* @param wrapMode The wrap mode
|
|
1954
|
-
* @returns boolean indicating success
|
|
1955
|
-
*/
|
|
1956
|
-
static SetWrapMode(handle, wrapMode) {
|
|
1957
|
-
return Boolean(
|
|
1958
|
-
RpcClient.Call("Texture_SetWrapMode", {
|
|
1959
|
-
textureHandle: handle,
|
|
1960
|
-
wrapMode
|
|
1961
|
-
})
|
|
1962
|
-
);
|
|
1963
|
-
}
|
|
1964
|
-
};
|
|
1965
|
-
var TextureFilterMode = /* @__PURE__ */ ((TextureFilterMode2) => {
|
|
1966
|
-
TextureFilterMode2[TextureFilterMode2["NEAREST"] = 0] = "NEAREST";
|
|
1967
|
-
TextureFilterMode2[TextureFilterMode2["LINEAR"] = 1] = "LINEAR";
|
|
1968
|
-
TextureFilterMode2[TextureFilterMode2["NEAREST_MIPMAP_NEAREST"] = 2] = "NEAREST_MIPMAP_NEAREST";
|
|
1969
|
-
TextureFilterMode2[TextureFilterMode2["LINEAR_MIPMAP_NEAREST"] = 3] = "LINEAR_MIPMAP_NEAREST";
|
|
1970
|
-
TextureFilterMode2[TextureFilterMode2["NEAREST_MIPMAP_LINEAR"] = 4] = "NEAREST_MIPMAP_LINEAR";
|
|
1971
|
-
TextureFilterMode2[TextureFilterMode2["LINEAR_MIPMAP_LINEAR"] = 5] = "LINEAR_MIPMAP_LINEAR";
|
|
1972
|
-
return TextureFilterMode2;
|
|
1973
|
-
})(TextureFilterMode || {});
|
|
1974
|
-
var TextureWrapMode = /* @__PURE__ */ ((TextureWrapMode2) => {
|
|
1975
|
-
TextureWrapMode2[TextureWrapMode2["CLAMP_TO_EDGE"] = 0] = "CLAMP_TO_EDGE";
|
|
1976
|
-
TextureWrapMode2[TextureWrapMode2["REPEAT"] = 1] = "REPEAT";
|
|
1977
|
-
TextureWrapMode2[TextureWrapMode2["MIRRORED_REPEAT"] = 2] = "MIRRORED_REPEAT";
|
|
1978
|
-
return TextureWrapMode2;
|
|
1979
|
-
})(TextureWrapMode || {});
|
|
1980
|
-
|
|
1981
|
-
// library/render/scene.ts
|
|
1982
|
-
var SceneManager = class {
|
|
1983
|
-
/**
|
|
1984
|
-
* Get the default scene handle
|
|
1985
|
-
* @returns The default scene handle
|
|
1986
|
-
*/
|
|
1987
|
-
static GetDefault() {
|
|
1988
|
-
return Number(RpcClient.Call("Scene_GetDefault", {}));
|
|
1989
|
-
}
|
|
1990
|
-
/**
|
|
1991
|
-
* Set the skybox for the scene
|
|
1992
|
-
* @param sceneHandle The scene handle
|
|
1993
|
-
* @param skyboxHandle The skybox material handle
|
|
1994
|
-
* @returns boolean indicating success
|
|
1995
|
-
*/
|
|
1996
|
-
static SetSkybox(sceneHandle, skyboxHandle) {
|
|
1997
|
-
return Boolean(
|
|
1998
|
-
RpcClient.Call("Scene_SetSkybox", {
|
|
1999
|
-
sceneHandle,
|
|
2000
|
-
skyboxHandle
|
|
2001
|
-
})
|
|
2002
|
-
);
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* Set the ambient light for the scene
|
|
2006
|
-
* @param sceneHandle The scene handle
|
|
2007
|
-
* @param r Red component (0-1)
|
|
2008
|
-
* @param g Green component (0-1)
|
|
2009
|
-
* @param b Blue component (0-1)
|
|
2010
|
-
* @param intensity The ambient light intensity
|
|
2011
|
-
* @returns boolean indicating success
|
|
2012
|
-
*/
|
|
2013
|
-
static SetAmbientLight(sceneHandle, r, g, b, intensity) {
|
|
2014
|
-
return Boolean(
|
|
2015
|
-
RpcClient.Call("Scene_SetAmbientLight", {
|
|
2016
|
-
sceneHandle,
|
|
2017
|
-
r,
|
|
2018
|
-
g,
|
|
2019
|
-
b,
|
|
2020
|
-
intensity
|
|
2021
|
-
})
|
|
2022
|
-
);
|
|
2023
|
-
}
|
|
2024
|
-
/**
|
|
2025
|
-
* Set the fog parameters for the scene
|
|
2026
|
-
* @param sceneHandle The scene handle
|
|
2027
|
-
* @param enabled Whether fog is enabled
|
|
2028
|
-
* @param mode The fog mode
|
|
2029
|
-
* @param density The fog density
|
|
2030
|
-
* @param start The fog start distance
|
|
2031
|
-
* @param end The fog end distance
|
|
2032
|
-
* @returns boolean indicating success
|
|
2033
|
-
*/
|
|
2034
|
-
static SetFog(sceneHandle, enabled, mode, density, start, end) {
|
|
2035
|
-
return Boolean(
|
|
2036
|
-
RpcClient.Call("Scene_SetFog", {
|
|
2037
|
-
sceneHandle,
|
|
2038
|
-
enabled,
|
|
2039
|
-
mode,
|
|
2040
|
-
density,
|
|
2041
|
-
start,
|
|
2042
|
-
end
|
|
2043
|
-
})
|
|
2044
|
-
);
|
|
2045
|
-
}
|
|
2046
|
-
};
|
|
2047
|
-
|
|
2048
|
-
// library/render/renderer.ts
|
|
2049
|
-
var RendererManager = class {
|
|
2050
|
-
// ------------------------------------------------------------
|
|
2051
|
-
// Camera / XR
|
|
2052
|
-
// ------------------------------------------------------------
|
|
2053
|
-
/**
|
|
2054
|
-
* Filament: Renderer::getDefaultCameraEntity()
|
|
2055
|
-
* Unity RPC not yet implemented; please register a CameraManager method.
|
|
2056
|
-
* @returns The default camera entity handle
|
|
2057
|
-
*/
|
|
2058
|
-
static GetDefaultCameraEntity() {
|
|
2059
|
-
console.warn("GetDefaultCameraEntity(): Unity RPC not available");
|
|
2060
|
-
return -1;
|
|
2061
|
-
}
|
|
2062
|
-
/**
|
|
2063
|
-
* Filament: Renderer::getXRCameras()
|
|
2064
|
-
* Unity RPC not yet implemented.
|
|
2065
|
-
* @returns Array of XR camera entity handles
|
|
2066
|
-
*/
|
|
2067
|
-
static GetXRCameras() {
|
|
2068
|
-
console.warn("GetXRCameras(): Unity RPC not available");
|
|
2069
|
-
return [];
|
|
2070
|
-
}
|
|
2071
|
-
// ------------------------------------------------------------
|
|
2072
|
-
// Material / Skybox / Indirect Light
|
|
2073
|
-
// ------------------------------------------------------------
|
|
2074
|
-
/**
|
|
2075
|
-
* Destroy a material instance (mimics Filament::Renderer::destroyMaterialInstance)
|
|
2076
|
-
* @param instanceHandle The material instance handle to destroy
|
|
2077
|
-
* @returns boolean indicating success
|
|
2078
|
-
*/
|
|
2079
|
-
static DestroyMaterialInstance(instanceHandle) {
|
|
2080
|
-
return MaterialManager.Destroy(instanceHandle);
|
|
2081
|
-
}
|
|
2082
|
-
/**
|
|
2083
|
-
* Destroy a render-target (in Unity, render textures)
|
|
2084
|
-
* @param rtHandle The render target handle to destroy
|
|
2085
|
-
* @returns boolean indicating success
|
|
2086
|
-
*/
|
|
2087
|
-
static DestroyRenderTarget(rtHandle) {
|
|
2088
|
-
return TextureManager.Destroy(rtHandle);
|
|
2089
|
-
}
|
|
2090
|
-
/**
|
|
2091
|
-
* Destroy a skybox (in Unity, just a material)
|
|
2092
|
-
* @param skyboxMatHandle The skybox material handle to destroy
|
|
2093
|
-
* @returns boolean indicating success
|
|
2094
|
-
*/
|
|
2095
|
-
static DestroySkybox(skyboxMatHandle) {
|
|
2096
|
-
return MaterialManager.Destroy(skyboxMatHandle);
|
|
2097
|
-
}
|
|
2098
|
-
/**
|
|
2099
|
-
* Destroy an indirect light (no direct Unity equivalent)
|
|
2100
|
-
* @param ilHandle The indirect light handle to destroy
|
|
2101
|
-
* @returns boolean indicating success
|
|
2102
|
-
*/
|
|
2103
|
-
static DestroyIndirectLight(ilHandle) {
|
|
2104
|
-
console.warn("DestroyIndirectLight(): no Unity RPC equivalent");
|
|
2105
|
-
return false;
|
|
2106
|
-
}
|
|
2107
|
-
// ------------------------------------------------------------
|
|
2108
|
-
// Scene-level convenience
|
|
2109
|
-
// ------------------------------------------------------------
|
|
2110
|
-
/**
|
|
2111
|
-
* Wraps Scene_SetSkybox
|
|
2112
|
-
* @param sceneHandle The scene handle
|
|
2113
|
-
* @param skyboxMatHandle The skybox material handle
|
|
2114
|
-
* @returns boolean indicating success
|
|
2115
|
-
*/
|
|
2116
|
-
static SetSkybox(sceneHandle, skyboxMatHandle) {
|
|
2117
|
-
return SceneManager.SetSkybox(sceneHandle, skyboxMatHandle);
|
|
2118
|
-
}
|
|
2119
|
-
/**
|
|
2120
|
-
* Wraps Scene_SetAmbientLight
|
|
2121
|
-
* @param sceneHandle The scene handle
|
|
2122
|
-
* @param r Red component (0-1)
|
|
2123
|
-
* @param g Green component (0-1)
|
|
2124
|
-
* @param b Blue component (0-1)
|
|
2125
|
-
* @param intensity The ambient light intensity
|
|
2126
|
-
* @returns boolean indicating success
|
|
2127
|
-
*/
|
|
2128
|
-
static SetAmbientLight(sceneHandle, r, g, b, intensity) {
|
|
2129
|
-
return SceneManager.SetAmbientLight(sceneHandle, r, g, b, intensity);
|
|
2130
|
-
}
|
|
2131
|
-
/**
|
|
2132
|
-
* Wraps Scene_SetFog
|
|
2133
|
-
* @param sceneHandle The scene handle
|
|
2134
|
-
* @param enabled Whether fog is enabled
|
|
2135
|
-
* @param mode The fog mode
|
|
2136
|
-
* @param density The fog density
|
|
2137
|
-
* @param start The fog start distance
|
|
2138
|
-
* @param end The fog end distance
|
|
2139
|
-
* @returns boolean indicating success
|
|
2140
|
-
*/
|
|
2141
|
-
static SetFog(sceneHandle, enabled, mode, density, start, end) {
|
|
2142
|
-
return SceneManager.SetFog(sceneHandle, enabled, mode, density, start, end);
|
|
2143
|
-
}
|
|
2144
|
-
};
|
|
2145
|
-
|
|
2146
|
-
// library/render/transform.ts
|
|
2147
|
-
import { mat4, quat, vec3 as vec32 } from "gl-matrix";
|
|
2148
|
-
var TransformManager = class {
|
|
2149
|
-
/**
|
|
2150
|
-
* Checks if the entity has a Transform component.
|
|
2151
|
-
* @param entity The entity to check
|
|
2152
|
-
* @returns boolean indicating if transform component exists
|
|
2153
|
-
*/
|
|
2154
|
-
static HasComponent(entity) {
|
|
2155
|
-
return Boolean(
|
|
2156
|
-
RpcClient.Call("Transform_HasComponent", { entityHandle: entity })
|
|
2157
|
-
);
|
|
2158
|
-
}
|
|
2159
|
-
/**
|
|
2160
|
-
* Sets the world transform given a 16-element row-major matrix.
|
|
2161
|
-
* Transposes to column-major and flips Z-axis for Unity.
|
|
2162
|
-
* TODO: double check if this is correct, what are we using internally?
|
|
2163
|
-
* Use the coords provided by gl matrix or unity.
|
|
2164
|
-
* @param entity The entity with the transform component
|
|
2165
|
-
* @param srcMatrix The source transformation matrix
|
|
2166
|
-
* @returns boolean indicating success
|
|
2167
|
-
*/
|
|
2168
|
-
static SetTransform(entity, srcMatrix) {
|
|
2169
|
-
const colMaj = new Array(16);
|
|
2170
|
-
for (let row = 0; row < 4; row++) {
|
|
2171
|
-
for (let col = 0; col < 4; col++) {
|
|
2172
|
-
let val = srcMatrix[row * 4 + col];
|
|
2173
|
-
if (col === 2) val = -val;
|
|
2174
|
-
colMaj[col * 4 + row] = val;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
const matrixJson = colMaj.join(",");
|
|
2178
|
-
return Boolean(
|
|
2179
|
-
RpcClient.Call("Transform_SetTransform", {
|
|
2180
|
-
entityHandle: entity,
|
|
2181
|
-
matrixJson
|
|
2182
|
-
})
|
|
2183
|
-
);
|
|
2184
|
-
}
|
|
2185
|
-
/**
|
|
2186
|
-
* Retrieves the world transform matrix (column-major).
|
|
2187
|
-
* @param entity The entity with the transform component
|
|
2188
|
-
* @returns The transformation matrix
|
|
2189
|
-
*/
|
|
2190
|
-
static GetTransform(entity) {
|
|
2191
|
-
const result = RpcClient.Call("Transform_GetTransform", {
|
|
2192
|
-
entityHandle: entity
|
|
2193
|
-
});
|
|
2194
|
-
const nums = result.split(",").map((j) => parseFloat(j));
|
|
2195
|
-
if (nums.length !== 16) {
|
|
2196
|
-
throw new Error(`Invalid transform data (${nums.length} elements)`);
|
|
2197
|
-
}
|
|
2198
|
-
return mat4.fromValues(
|
|
2199
|
-
nums[0],
|
|
2200
|
-
nums[1],
|
|
2201
|
-
nums[2],
|
|
2202
|
-
nums[3],
|
|
2203
|
-
nums[4],
|
|
2204
|
-
nums[5],
|
|
2205
|
-
nums[6],
|
|
2206
|
-
nums[7],
|
|
2207
|
-
nums[8],
|
|
2208
|
-
nums[9],
|
|
2209
|
-
nums[10],
|
|
2210
|
-
nums[11],
|
|
2211
|
-
nums[12],
|
|
2212
|
-
nums[13],
|
|
2213
|
-
nums[14],
|
|
2214
|
-
nums[15]
|
|
2215
|
-
);
|
|
2216
|
-
}
|
|
2217
|
-
/**
|
|
2218
|
-
* Sets this entity's parent transform.
|
|
2219
|
-
* @param entity The entity with the transform component
|
|
2220
|
-
* @param parent The parent entity
|
|
2221
|
-
* @returns boolean indicating success
|
|
2222
|
-
*/
|
|
2223
|
-
static SetParent(entity, parent) {
|
|
2224
|
-
return Boolean(
|
|
2225
|
-
RpcClient.Call("Transform_SetParent", {
|
|
2226
|
-
entityHandle: entity,
|
|
2227
|
-
parentHandle: parent
|
|
2228
|
-
})
|
|
2229
|
-
);
|
|
2230
|
-
}
|
|
2231
|
-
/**
|
|
2232
|
-
* Gets the parent entity handle, or -1 if none.
|
|
2233
|
-
* @param entity The entity with the transform component
|
|
2234
|
-
* @returns The parent entity handle
|
|
2235
|
-
*/
|
|
2236
|
-
static GetParent(entity) {
|
|
2237
|
-
return Number(
|
|
2238
|
-
RpcClient.Call("Transform_GetParent", { entityHandle: entity })
|
|
2239
|
-
);
|
|
2240
|
-
}
|
|
2241
|
-
/**
|
|
2242
|
-
* Sets world position vector.
|
|
2243
|
-
* @param entity The entity with the transform component
|
|
2244
|
-
* @param pos The position vector
|
|
2245
|
-
* @returns boolean indicating success
|
|
2246
|
-
*/
|
|
2247
|
-
static SetWorldPosition(entity, pos) {
|
|
2248
|
-
return Boolean(
|
|
2249
|
-
RpcClient.Call("Transform_SetWorldPosition", {
|
|
2250
|
-
entityHandle: entity,
|
|
2251
|
-
x: pos[0],
|
|
2252
|
-
y: pos[1],
|
|
2253
|
-
z: pos[2]
|
|
2254
|
-
})
|
|
2255
|
-
);
|
|
2256
|
-
}
|
|
2257
|
-
/**
|
|
2258
|
-
* Sets local position vector.
|
|
2259
|
-
* @param entity The entity with the transform component
|
|
2260
|
-
* @param pos The position vector
|
|
2261
|
-
* @returns boolean indicating success
|
|
2262
|
-
*/
|
|
2263
|
-
static SetLocalPosition(entity, pos) {
|
|
2264
|
-
return Boolean(
|
|
2265
|
-
RpcClient.Call("Transform_SetLocalPosition", {
|
|
2266
|
-
entityHandle: entity,
|
|
2267
|
-
x: pos[0],
|
|
2268
|
-
y: pos[1],
|
|
2269
|
-
z: pos[2]
|
|
2270
|
-
})
|
|
2271
|
-
);
|
|
2272
|
-
}
|
|
2273
|
-
/**
|
|
2274
|
-
* Gets world position vector.
|
|
2275
|
-
* @param entity The entity with the transform component
|
|
2276
|
-
* @returns The position vector
|
|
2277
|
-
*/
|
|
2278
|
-
static GetWorldPosition(entity) {
|
|
2279
|
-
const data = RpcClient.Call("Transform_GetWorldPosition", {
|
|
2280
|
-
entityHandle: entity
|
|
2281
|
-
});
|
|
2282
|
-
const [x, y, z] = data.split(",").map((j) => parseFloat(j));
|
|
2283
|
-
return vec32.fromValues(x, y, z);
|
|
2284
|
-
}
|
|
2285
|
-
/**
|
|
2286
|
-
* Gets local position vector.
|
|
2287
|
-
* @param entity The entity with the transform component
|
|
2288
|
-
* @returns The position vector
|
|
2289
|
-
*/
|
|
2290
|
-
static GetLocalPosition(entity) {
|
|
2291
|
-
const data = RpcClient.Call("Transform_GetLocalPosition", {
|
|
2292
|
-
entityHandle: entity
|
|
2293
|
-
});
|
|
2294
|
-
const [x, y, z] = data.split(",").map((j) => parseFloat(j));
|
|
2295
|
-
return vec32.fromValues(x, y, z);
|
|
2296
|
-
}
|
|
2297
|
-
/**
|
|
2298
|
-
* Sets world rotation quaternion.
|
|
2299
|
-
* @param entity The entity with the transform component
|
|
2300
|
-
* @param quat The rotation quaternion [x, y, z, w]
|
|
2301
|
-
* @returns boolean indicating success
|
|
2302
|
-
*/
|
|
2303
|
-
static SetWorldRotation(entity, quat2) {
|
|
2304
|
-
return Boolean(
|
|
2305
|
-
RpcClient.Call("Transform_SetWorldRotation", {
|
|
2306
|
-
entityHandle: entity,
|
|
2307
|
-
x: quat2[0],
|
|
2308
|
-
y: quat2[1],
|
|
2309
|
-
z: quat2[2],
|
|
2310
|
-
w: quat2[3]
|
|
2311
|
-
})
|
|
2312
|
-
);
|
|
2313
|
-
}
|
|
2314
|
-
/**
|
|
2315
|
-
* Sets local rotation quaternion.
|
|
2316
|
-
* @param entity The entity with the transform component
|
|
2317
|
-
* @param quat The rotation quaternion [x, y, z, w]
|
|
2318
|
-
* @returns boolean indicating success
|
|
2319
|
-
*/
|
|
2320
|
-
static SetLocalRotation(entity, quat2) {
|
|
2321
|
-
return Boolean(
|
|
2322
|
-
RpcClient.Call("Transform_SetLocalRotation", {
|
|
2323
|
-
entityHandle: entity,
|
|
2324
|
-
x: quat2[0],
|
|
2325
|
-
y: quat2[1],
|
|
2326
|
-
z: quat2[2],
|
|
2327
|
-
w: quat2[3]
|
|
2328
|
-
})
|
|
2329
|
-
);
|
|
2330
|
-
}
|
|
2331
|
-
/**
|
|
2332
|
-
* Gets local rotation quaternion.
|
|
2333
|
-
* @param entity The entity with the transform component
|
|
2334
|
-
* @returns The rotation quaternion
|
|
2335
|
-
*/
|
|
2336
|
-
static GetWorldRotation(entity) {
|
|
2337
|
-
const data = RpcClient.Call("Transform_GetWorldRotation", {
|
|
2338
|
-
entityHandle: entity
|
|
2339
|
-
});
|
|
2340
|
-
const [x, y, z, w] = data.split(",").map((j) => parseFloat(j));
|
|
2341
|
-
return quat.fromValues(x, y, z, w);
|
|
2342
|
-
}
|
|
2343
|
-
/**
|
|
2344
|
-
* Gets local rotation quaternion.
|
|
2345
|
-
* @param entity The entity with the transform component
|
|
2346
|
-
* @returns The rotation quaternion
|
|
2347
|
-
*/
|
|
2348
|
-
static GetLocalRotation(entity) {
|
|
2349
|
-
const data = RpcClient.Call("Transform_GetLocalRotation", {
|
|
2350
|
-
entityHandle: entity
|
|
2351
|
-
});
|
|
2352
|
-
const [x, y, z, w] = data.split(",").map((j) => parseFloat(j));
|
|
2353
|
-
return quat.fromValues(x, y, z, w);
|
|
2354
|
-
}
|
|
2355
|
-
/**
|
|
2356
|
-
* Sets local scale vector.
|
|
2357
|
-
* @param entity The entity with the transform component
|
|
2358
|
-
* @param scale The scale vector
|
|
2359
|
-
* @returns boolean indicating success
|
|
2360
|
-
*/
|
|
2361
|
-
static SetLocalScale(entity, scale) {
|
|
2362
|
-
return Boolean(
|
|
2363
|
-
RpcClient.Call("Transform_SetLocalScale", {
|
|
2364
|
-
entityHandle: entity,
|
|
2365
|
-
x: scale[0],
|
|
2366
|
-
y: scale[1],
|
|
2367
|
-
z: scale[2]
|
|
2368
|
-
})
|
|
2369
|
-
);
|
|
2370
|
-
}
|
|
2371
|
-
/**
|
|
2372
|
-
* Gets local scale vector.
|
|
2373
|
-
* @param entity The entity with the transform component
|
|
2374
|
-
* @returns The position vector
|
|
2375
|
-
*/
|
|
2376
|
-
static GetLocalScale(entity) {
|
|
2377
|
-
const data = RpcClient.Call("Transform_GetLocalScale", {
|
|
2378
|
-
entityHandle: entity
|
|
2379
|
-
});
|
|
2380
|
-
const [x, y, z] = data.split(",").map((j) => parseFloat(j));
|
|
2381
|
-
return vec32.fromValues(x, y, z);
|
|
2382
|
-
}
|
|
2383
|
-
};
|
|
2384
|
-
export {
|
|
2385
|
-
CameraManager,
|
|
2386
|
-
ColliderManager,
|
|
2387
|
-
Debug,
|
|
2388
|
-
Device,
|
|
2389
|
-
EntityManager,
|
|
2390
|
-
GrabInteractableManager,
|
|
2391
|
-
Keyboard,
|
|
2392
|
-
LightManager,
|
|
2393
|
-
LightShadowMode,
|
|
2394
|
-
LightType,
|
|
2395
|
-
MaterialManager,
|
|
2396
|
-
MeshManager,
|
|
2397
|
-
NewCubeMesh,
|
|
2398
|
-
NewQuadMesh,
|
|
2399
|
-
RenderableManager,
|
|
2400
|
-
RendererManager,
|
|
2401
|
-
RigidbodyManager,
|
|
2402
|
-
RpcClient,
|
|
2403
|
-
SceneManager,
|
|
2404
|
-
ShaderProperties,
|
|
2405
|
-
ShaderType,
|
|
2406
|
-
StateSync,
|
|
2407
|
-
TextureFilterMode,
|
|
2408
|
-
TextureFormat,
|
|
2409
|
-
TextureManager,
|
|
2410
|
-
TextureWrapMode,
|
|
2411
|
-
TransformManager,
|
|
2412
|
-
XRSystem,
|
|
2413
|
-
base64Decode,
|
|
2414
|
-
base64Encode
|
|
2415
|
-
};
|
|
1
|
+
var H=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import{platform as U}from"node:os";var I=U()==="darwin"?H("./native-bindings-osx.node"):H("./native-bindings-win.node"),a=class i{static Init(){I.Rpc_RegisterCbHandler((t,e)=>{let n=JSON.parse(e),l=i.keyValueToObject(n.keys,n.values);try{i.callbackRegistry[t](l)}catch(r){console.error(`${r}`)}})}static RegisterCallback(t){let e=Number(i.Call("_RPC::AllocateCallback",{clientId:i.GetClientId()}));return i.callbackRegistry[e]=t,e}static Call(t,e){this.initialized||(this.initialized=!0,i.Init());let n={};for(let[l,r]of Object.entries(e))typeof r=="function"?n[l]=i.RegisterCallback(r):n[l]=r;return JSON.parse(I.Rpc_Call(t,JSON.stringify(this.objectToKeyValue(n)))).result}static GetClientId(){return Number(I.Rpc_GetClientId())}static objectToKeyValue(t){let e=Object.keys(t),n=e.map(l=>t[l]);return{keys:e,values:n}}static keyValueToObject(t,e){let n={};return t.forEach((l,r)=>{n[l]=e[r]}),n}static{this.callbackRegistry={}}static{this.initialized=!1}};var T=class{static OnCmdCallback(t){return a.Call("DebugWindow::GetCommand",{callback:t})}};var g=class{static GetLeftPosition(){return JSON.parse(a.Call("XRI Left/Position",{}))}static GetLeftRotation(){return JSON.parse(a.Call("XRI Left/Rotation",{}))}static GetLeftThumbstick(){return JSON.parse(a.Call("XRI Left/Thumbstick",{}))}static GetLeftSelect(){return JSON.parse(a.Call("XRI Left Interaction/Select Value",{}))}static GetLeftActivate(){return JSON.parse(a.Call("XRI Left Interaction/Activate Value",{}))}static GetLeftTurn(){return JSON.parse(a.Call("XRI Left Locomotion/Turn",{}))}static GetLeftSnapTurn(){return JSON.parse(a.Call("XRI Left Locomotion/Snap Turn",{}))}static GetLeftMove(){return JSON.parse(a.Call("XRI Left Locomotion/Move",{}))}static GetLeftGrabMove(){return JSON.parse(a.Call("XRI Left Locomotion/Grab Move",{}))}static GetRightPosition(){return JSON.parse(a.Call("XRI Right/Position",{}))}static GetRightRotation(){return JSON.parse(a.Call("XRI Right/Rotation",{}))}static GetRightThumbstick(){return JSON.parse(a.Call("XRI Right/Thumbstick",{}))}static GetRightSelect(){return JSON.parse(a.Call("XRI Right Interaction/Select Value",{}))}static GetRightActivate(){return JSON.parse(a.Call("XRI Right Interaction/Activate Value",{}))}static GetRightTurn(){return JSON.parse(a.Call("XRI Right Locomotion/Turn",{}))}static GetRightSnapTurn(){return JSON.parse(a.Call("XRI Right Locomotion/Snap Turn",{}))}static GetRightMove(){return JSON.parse(a.Call("XRI Right Locomotion/Move",{}))}static GetRightGrabMove(){return JSON.parse(a.Call("XRI Right Locomotion/Grab Move",{}))}static GetHeadPosition(){return JSON.parse(a.Call("XRI Head/Position",{}))}static GetHeadRotation(){return JSON.parse(a.Call("XRI Head/Rotation",{}))}static GetLeftWorldPosition(){return JSON.parse(a.Call("XRI Left/WorldPosition",{}))}static GetLeftWorldRotation(){return JSON.parse(a.Call("XRI Left/WorldRotation",{}))}static GetRightWorldPosition(){return JSON.parse(a.Call("XRI Right/WorldPosition",{}))}static GetRightWorldRotation(){return JSON.parse(a.Call("XRI Right/WorldRotation",{}))}static GetHeadWorldPosition(){return JSON.parse(a.Call("XRI Head/WorldPosition",{}))}static GetHeadWorldRotation(){return JSON.parse(a.Call("XRI Head/WorldRotation",{}))}},h=class{static{this.KEYCODE=Object.freeze({LEFT_EYE:"Left Eye",RIGHT_EYE:"Right Eye",LEFT_AIM:"Left Aim",RIGHT_AIM:"Right Aim",LEFT_GRIP:"Left Grip",RIGHT_GRIP:"Right Grip",LEFT_SQUEEZE:"Left Squeeze",RIGHT_SQUEEZE:"Right Squeeze",LEFT_TRIGGER:"Left Trigger",RIGHT_TRIGGER:"Right Trigger",LEFT_THUMBSTICK_X:"Left Thumbstick X",RIGHT_THUMBSTICK_X:"Right Thumbstick X",LEFT_THUMBSTICK_Y:"Left Thumbstick Y",RIGHT_THUMBSTICK_Y:"Right Thumbstick Y",LEFT_TRIGGER_TOUCH:"Left Trigger Touch",RIGHT_TRIGGER_TOUCH:"Right Trigger Touch",LEFT_THUMBSTICK_CLICK:"Left Thumbstick Click",RIGHT_THUMBSTICK_CLICK:"Right Thumbstick Click",LEFT_THUMBSTICK_TOUCH:"Left Thumbstick Touch",RIGHT_THUMBSTICK_TOUCH:"Right Thumbstick Touch",LEFT_X_CLICK:"Left X Click",LEFT_X_TOUCH:"Left X Touch",LEFT_Y_CLICK:"Left Y Click",LEFT_Y_TOUCH:"Left Y Touch",LEFT_MENU_CLICK:"Left Menu Click",RIGHT_A_CLICK:"Right A Click",RIGHT_A_TOUCH:"Right A Touch",RIGHT_B_CLIKC:"Right B Click",RIGHT_B_TOUCH:"Right B Touch",RIGHT_SYSTEM_CLICK:"Right System Click"})}},G=class{static{this.MOUSE=Object.freeze({BUTTON_LEFT:0,BUTTON_RIGHT:1,BUTTON_MIDDLE:2})}static{this.KEYCODE=Object.freeze({SPACE:32,APOSTROPHE:39,COMMA:44,MINUS:45,PERIOD:46,SLASH:47,NUM_0:48,NUM_1:49,NUM_2:50,NUM_3:51,NUM_4:52,NUM_5:53,NUM_6:54,NUM_7:55,NUM_8:56,NUM_9:57,SEMICOLON:59,EQUAL:61,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LEFT_BRACKET:91,BACKSLASH:92,RIGHT_BRACKET:93,GRAVE_ACCENT:96,WORLD_1:161,WORLD_2:162,ESCAPE:256,ENTER:257,TAB:258,BACKSPACE:259,INSERT:260,DELETE:261,RIGHT:262,LEFT:263,DOWN:264,UP:265,PAGE_UP:266,PAGE_DOWN:267,HOME:268,END:269,CAPS_LOCK:280,SCROLL_LOCK:281,NUM_LOCK:282,PRINT_SCREEN:283,PAUSE:284,F1:290,F2:291,F3:292,F4:293,F5:294,F6:295,F7:296,F8:297,F9:298,F10:299,F11:300,F12:301,F13:302,F14:303,F15:304,F16:305,F17:306,F18:307,F19:308,F20:309,F21:310,F22:311,F23:312,F24:313,F25:314,KP_0:320,KP_1:321,KP_2:322,KP_3:323,KP_4:324,KP_5:325,KP_6:326,KP_7:327,KP_8:328,KP_9:329,KP_DECIMAL:330,KP_DIVIDE:331,KP_MULTIPLY:332,KP_SUBTRACT:333,KP_ADD:334,KP_ENTER:335,KP_EQUAL:336,LEFT_SHIFT:340,LEFT_CONTROL:341,LEFT_ALT:342,LEFT_SUPER:343,RIGHT_SHIFT:344,RIGHT_CONTROL:345,RIGHT_ALT:346,RIGHT_SUPER:347,MENU:348})}static{this.ACTION=Object.freeze({RELEASE:0,PRESS:1,REPEAT:2})}static{this.MODIFIER=Object.freeze({SHIFT:1,CONTROL:2,ALT:4,SUPER:8,CAPS_LOCK:16,NUM_LOCK:32})}};var A=class{static Create(t){return Number(a.Call("Entity_Create",{name:t,clientId:a.GetClientId()}))}static Destroy(t){return!!a.Call("Entity_Destroy",{entityHandle:t})}static SetName(t,e){return!!a.Call("Entity_SetName",{entityHandle:t,name:e})}static GetName(t){return a.Call("Entity_GetName",{entityHandle:t})}};var L=class{static Create(t){return!!a.Call("GrabInteractableAPI_Create",{entityHandle:t})}static Destroy(t){return!!a.Call("GrabInteractableAPI_Destroy",{entityHandle:t})}static HasComponent(t){return!!a.Call("GrabInteractableAPI_HasComponent",{entityHandle:t})}static GetTrackPosition(t){return!!a.Call("GrabInteractableAPI_GetTrackPosition",{entityHandle:t})}static SetTrackPosition(t,e){return!!a.Call("GrabInteractableAPI_SetTrackPosition",{entityHandle:t,isTracking:e})}static GetTrackRotation(t){return JSON.parse(a.Call("GrabInteractableAPI_GetTrackRotation",{entityHandle:t}))}static SetTrackRotation(t,e){return JSON.parse(a.Call("GrabInteractableAPI_SetTrackRotation",{entityHandle:t,isTracking:e}))}static GetTrackScale(t){return!!a.Call("GrabInteractableAPI_GetTrackScale",{entityHandle:t})}static SetTrackScale(t,e){return!!a.Call("GrabInteractableAPI_SetTrackScale",{entityHandle:t,isTracking:e})}static GetThrowOnDetach(t){return!!a.Call("GrabInteractableAPI_GetThrowOnDetach",{entityHandle:t})}static SetThrowOnDetach(t,e){return!!a.Call("GrabInteractableAPI_SetThrowOnDetach",{entityHandle:t,enable:e})}static GetAttachEntity(t){return!!a.Call("GrabInteractableAPI_GetAttachEntity",{entityHandle:t})}static SetAttachEntity(t,e){return!!a.Call("GrabInteractableAPI_SetAttachEntity",{entityHandle:t,attachEntityHandle:e})}static AddSelectEnteredCallback(t,e){return!!a.Call("GrabInteractableAPI_AddSelectEnteredCallback",{entityHandle:t,onSelectEntered:n=>{e(n.interactableEntity,n.interactorEntity)}})}static AddSelectExitedCallback(t,e){return!!a.Call("GrabInteractableAPI_AddSelectExitedCallback",{entityHandle:t,onSelectExited:n=>{e(n.interactableEntity,n.interactorEntity)}})}static AddActivatedCallback(t,e){return!!a.Call("GrabInteractableAPI_AddActivatedCallback",{entityHandle:t,onActivated:n=>{e(n.interactableEntity,n.interactorEntity)}})}static AddDeactivatedCallback(t,e){return!!a.Call("GrabInteractableAPI_AddDeactivatedCallback",{entityHandle:t,onDeactivated:n=>{e(n.interactableEntity,n.interactorEntity)}})}};var P=class i{static{this.stateMap=new Map}static GetNetworkID(){return a.Call("_Main::GetNetworkPrefabIdByPid",{pid:process.pid})}static CreateNetworkState(t,e,n=()=>{}){let l=structuredClone(e);i.stateMap.set(t,l);let r=new Proxy(l,{get(o,C){return Reflect.get(o,C)},set(o,C,d){return Reflect.set(o,C,d),a.Call("_RPC::BroadcastState",{networkId:i.GetNetworkID(),key:t,payload:JSON.stringify({prop:C,value:d})}),!0}});return a.Call("_RPC::AddNewState",{networkId:i.GetNetworkID(),key:t,onReceived:o=>{console.log("onReceived: "+o.data);let C=i.stateMap.get(t);if(!C)return;let{prop:d,value:s}=JSON.parse(o.data);C[d]=s,n(d,s)}}),r}static IsStateAuthority(){return a.Call("_RPC:IsStateAuthority",{networkId:i.GetNetworkID()})}static GetPlayerId(){return a.Call("Multiplayer_GetPlayerId",{})}};import{vec3 as _}from"gl-matrix";var M=class{static CreateBox(t){return Number(a.Call("ColliderAPI_CreateBox",{entityHandle:t}))}static CreateSphere(t){return Number(a.Call("ColliderAPI_CreateSphere",{entityHandle:t}))}static CreateCapsule(t){return Number(a.Call("ColliderAPI_CreateCapsule",{entityHandle:t}))}static Destroy(t,e){return!!a.Call("ColliderAPI_Destroy",{entityHandle:t,colliderHandle:e})}static HasComponent(t,e){return!!a.Call("ColliderAPI_HasComponent",{entityHandle:t,colliderHandle:e})}static GetGameObject(t){return Number(a.Call("ColliderAPI_GetGameObject",{entityHandle:t}))}static GetBoxColliderCenter(t){let e=JSON.parse(a.Call("ColliderAPI_GetBoxColliderCenter",{colliderHandle:t}));return _.fromValues(e[0],e[1],e[2])}static SetBoxColliderCenter(t,e){return a.Call("ColliderAPI_SetBoxColliderCenter",{colliderHandle:t,v0:e[0],v1:e[1],v2:e[2]})}static GetBoxColliderSize(t){let e=JSON.parse(a.Call("ColliderAPI_GetBoxColliderSize",{colliderHandle:t}));return _.fromValues(e[0],e[1],e[2])}static SetBoxColliderSize(t,e){return a.Call("ColliderAPI_SetBoxColliderSize",{colliderHandle:t,v0:e[0],v1:e[1],v2:e[2]})}static GetSphereColliderCenter(t){let e=JSON.parse(a.Call("ColliderAPI_GetSphereColliderCenter",{colliderHandle:t}));return _.fromValues(e[0],e[1],e[2])}static SetSphereColliderCenter(t,e){return a.Call("ColliderAPI_SetSphereColliderCenter",{colliderHandle:t,v0:e[0],v1:e[1],v2:e[2]})}static GetSphereColliderRadius(t){return a.Call("ColliderAPI_GetSphereColliderRadius",{colliderHandle:t})}static SetSphereColliderRadius(t,e){return a.Call("ColliderAPI_SetSphereColliderRadius",{colliderHandle:t,radius:e})}static GetCapsuleColliderCenter(t){let e=JSON.parse(a.Call("ColliderAPI_GetCapsuleColliderCenter",{colliderHandle:t}));return _.fromValues(e[0],e[1],e[2])}static SetCapsuleColliderCenter(t,e){return a.Call("ColliderAPI_SetCapsuleColliderCenter",{colliderHandle:t,v0:e[0],v1:e[1],v2:e[2]})}static GetCapsuleColliderRadius(t){return a.Call("ColliderAPI_GetCapsuleColliderRadius",{colliderHandle:t})}static SetCapsuleColliderRadius(t,e){return a.Call("ColliderAPI_SetCapsuleColliderRadius",{colliderHandle:t,radius:e})}static GetCapsuleColliderHeight(t){return a.Call("ColliderAPI_GetCapsuleColliderHeight",{colliderHandle:t})}static SetCapsuleColliderHeight(t,e){return a.Call("ColliderAPI_SetCapsuleColliderHeight",{colliderHandle:t,height:e})}static GetIsTrigger(t){return!!a.Call("ColliderAPI_GetIsTrigger",{entityHandle:t})}static SetIsTrigger(t,e){return!!a.Call("ColliderAPI_SetIsTrigger",{colliderHandle:t,isTrigger:e})}static AddTriggerEnterCallback(t,e){return!!a.Call("ColliderAPI_AddTriggerEnterCallback",{entityHandle:t,onTriggerEnter:e})}static AddTriggerExitCallback(t,e){return!!a.Call("ColliderAPI_AddTriggerExitCallback",{entityHandle:t,onTriggerExit:e})}static AddTriggerStayCallback(t,e){return!!a.Call("ColliderAPI_AddTriggerStayCallback",{entityHandle:t,onTriggerStay:e})}};var N=class{static Create(t){return!!a.Call("RidigbodyAPI_Create",{entityHandle:t})}static Destroy(t){return!!a.Call("RidigbodyAPI_Destroy",{entityHandle:t})}static HasComponent(t){return!!a.Call("RidigbodyAPI_HasComponent",{entityHandle:t})}static GetIsKinematic(t){return!!a.Call("RidigbodyAPI_GetIsKinematic",{entityHandle:t})}static SetIsKinematic(t,e){return!!a.Call("RidigbodyAPI_SetIsKinematic",{entityHandle:t,isKinematic:e})}static GetUseGravity(t){return!!a.Call("RidigbodyAPI_GetUseGravity",{entityHandle:t})}static SetUseGravity(t,e){return!!a.Call("RidigbodyAPI_SetUseGravity",{entityHandle:t,useGravity:e})}static GetMass(t){return Number(a.Call("RidigbodyAPI_GetMass",{entityHandle:t}))}static SetMass(t,e){return!!a.Call("RidigbodyAPI_SetMass",{entityHandle:t,mass:e})}static GetLinearDamping(t){return Number(a.Call("RidigbodyAPI_GetLinearDamping",{entityHandle:t}))}static SetLinearDamping(t,e){return!!a.Call("RidigbodyAPI_SetLinearDamping",{entityHandle:t,linearDamping:e})}static GetAngularDamping(t){return Number(a.Call("RidigbodyAPI_GetAngularDamping",{entityHandle:t}))}static SetAngularDamping(t,e){return!!a.Call("RidigbodyAPI_SetAngularDamping",{entityHandle:t,angularDamping:e})}};var B=class{static Create(t){return!!a.Call("Camera_Create",{entityHandle:t})}static Destroy(t){return!!a.Call("Camera_Destroy",{entityHandle:t})}static HasComponent(t){return!!a.Call("Camera_HasComponent",{entityHandle:t})}static SetProjection(t,e,n,l,r,o){return!!a.Call("Camera_SetProjection",{entityHandle:t,projectionType:e,fov:n,aspect:l,near:r,far:o})}static SetOrthographic(t,e,n,l,r,o,C){return!!a.Call("Camera_SetOrthographic",{entityHandle:t,left:e,right:n,bottom:l,top:r,near:o,far:C})}static LookAt(t,e,n,l,r,o,C,d,s,S){return!!a.Call("Camera_LookAt",{entityHandle:t,targetX:e,targetY:n,targetZ:l,upX:r,upY:o,upZ:C,worldUpX:d,worldUpY:s,worldUpZ:S})}static SetCullingMask(t,e){return!!a.Call("Camera_SetCullingMask",{entityHandle:t,mask:e})}static SetRenderTexture(t,e){return!!a.Call("Camera_SetRenderTexture",{entityHandle:t,renderTextureHandle:e})}};var x=class{static Create(t,e){return!!a.Call("Light_Create",{entityHandle:t,lightType:e})}static Destroy(t){return!!a.Call("Light_Destroy",{entityHandle:t})}static HasComponent(t){return!!a.Call("Light_HasComponent",{entityHandle:t})}static SetType(t,e){return!!a.Call("Light_SetType",{entityHandle:t,lightType:e})}static SetColor(t,e){return!!a.Call("Light_SetColor",{entityHandle:t,r:e[0],g:e[1],b:e[2]})}static SetIntensity(t,e){return!!a.Call("Light_SetIntensity",{entityHandle:t,intensity:e})}static SetRange(t,e){return!!a.Call("Light_SetRange",{entityHandle:t,range:e})}static SetSpotAngle(t,e,n=!0){return!!a.Call("Light_SetSpotAngle",{entityHandle:t,angle:e,value:n})}static SetShadows(t,e){return!!a.Call("Light_SetShadows",{entityHandle:t,shadowType:e})}static SetCullingMask(t,e){return!!a.Call("Light_SetCullingMask",{entityHandle:t,mask:e})}},K=(n=>(n[n.NoShadows=0]="NoShadows",n[n.Hard=1]="Hard",n[n.Soft=2]="Soft",n))(K||{}),F=(l=>(l[l.Spot=0]="Spot",l[l.Directional=1]="Directional",l[l.Point=2]="Point",l[l.Area=3]="Area",l))(F||{});var w=(t=>(t.URP_LIT="Universal Render Pipeline/Lit",t))(w||{}),J=(c=>(c.BaseMap="_BaseMap",c.BaseColor="_BaseColor",c.Cutoff="_Cutoff",c.Smoothness="_Smoothness",c.SmoothnessTextureChannel="_SmoothnessTextureChannel",c.Metallic="_Metallic",c.MetallicGlossMap="_MetallicGlossMap",c.SpecColor="_SpecColor",c.SpecGlossMap="_SpecGlossMap",c.SpecularHighlights="_SpecularHighlights",c.EnvironmentReflections="_EnvironmentReflections",c.BumpScale="_BumpScale",c.BumpMap="_BumpMap",c.Parallax="_Parallax",c.ParallaxMap="_ParallaxMap",c.OcclusionStrength="_OcclusionStrength",c.OcclusionMap="_OcclusionMap",c.EmissionColor="_EmissionColor",c.EmissionMap="_EmissionMap",c.DetailMask="_DetailMask",c.DetailAlbedoMapScale="_DetailAlbedoMapScale",c.DetailAlbedoMap="_DetailAlbedoMap",c.DetailNormalMapScale="_DetailNormalMapScale",c.DetailNormalMap="_DetailNormalMap",c))(J||{}),p=class{static Create(t="Universal Render Pipeline/Lit",e,n=0){let l=Number(a.Call("Material_Create",{shaderName:t,clientId:a.GetClientId()}));return e!==void 0&&a.Call("Renderable_SetMaterial",{entityHandle:e,materialHandle:l,index:n}),l}static Destroy(t){return!!a.Call("Material_Destroy",{materialHandle:t})}static CreateInstance(t){return Number(a.Call("Material_CreateInstance",{materialHandle:t,clientId:a.GetClientId()}))}static SetFloat(t,e,n){return!!a.Call("Material_SetFloat",{materialHandle:t,propertyName:e,value:n})}static SetVector(t,e,n){return!!a.Call("Material_SetVector",{materialHandle:t,propertyName:e,x:n[0],y:n[1],z:n[2],w:n[3]})}static SetColor(t,e,n){return!!a.Call("Material_SetColor",{materialHandle:t,propertyName:e,r:n[0],g:n[1],b:n[2],a:n[3]})}static SetTexture(t,e,n){return!!a.Call("Material_SetTexture",{materialHandle:t,propertyName:e,textureHandle:n})}static GetFloat(t,e){return Number(a.Call("Material_GetFloat",{materialHandle:t,propertyName:e}))}static GetColor(t,e){return a.Call("Material_GetColor",{materialHandle:t,propertyName:e})}};var m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",E=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i<m.length;i++)E[m.charCodeAt(i)]=i;var b=i=>{let t=new Uint8Array(i),e,n=t.length,l="";for(e=0;e<n;e+=3)l+=m[t[e]>>2],l+=m[(t[e]&3)<<4|t[e+1]>>4],l+=m[(t[e+1]&15)<<2|t[e+2]>>6],l+=m[t[e+2]&63];return n%3===2?l=l.substring(0,l.length-1)+"=":n%3===1&&(l=l.substring(0,l.length-2)+"=="),l},Et=i=>{let t=i.length*.75,e=i.length,n,l=0,r,o,C,d;i[i.length-1]==="="&&(t--,i[i.length-2]==="="&&t--);let s=new ArrayBuffer(t),S=new Uint8Array(s);for(n=0;n<e;n+=4)r=E[i.charCodeAt(n)],o=E[i.charCodeAt(n+1)],C=E[i.charCodeAt(n+2)],d=E[i.charCodeAt(n+3)],S[l++]=r<<2|o>>4,S[l++]=(o&15)<<4|C>>2,S[l++]=(C&3)<<6|d&63;return s};var u=class{static Create(t){let e=Number(a.Call("Mesh_Create",{clientId:a.GetClientId()}));return t!==void 0&&a.Call("Renderable_SetMesh",{entityHandle:t,meshHandle:e}),e}static Destroy(t){return!!a.Call("Mesh_Destroy",{meshHandle:t})}static SetVertices(t,e){let n;if(typeof e=="string")n=e;else{let l=new Float32Array(e.length*3);for(let r=0;r<e.length;r++){let o=e[r];l[r*3]=o[0],l[r*3+1]=o[1],l[r*3+2]=o[2]}n=b(l.buffer)}return!!a.Call("Mesh_SetVertices",{meshHandle:t,base64Vertices:n})}static SetTriangles(t,e){let n;if(typeof e=="string")n=e;else{let l=new Float32Array(e.length*3);for(let r=0;r<e.length;r++){let o=e[r];l[r*3]=o[0],l[r*3+1]=o[1],l[r*3+2]=o[2]}n=b(l.buffer)}return!!a.Call("Mesh_SetTriangles",{meshHandle:t,base64Triangles:n})}static SetUVs(t,e){let n;if(typeof e=="string")n=e;else{let l=new Float32Array(e.length*2);for(let r=0;r<e.length;r++){let o=e[r];l[r*2]=o[0],l[r*2+1]=o[1]}n=b(l.buffer)}return!!a.Call("Mesh_SetUVs",{meshHandle:t,base64Uvs:n})}static SetNormals(t,e){let n;if(typeof e=="string")n=e;else{let l=new Float32Array(e.length*3);for(let r=0;r<e.length;r++){let o=e[r];l[r*3]=o[0],l[r*3+1]=o[1],l[r*3+2]=o[2]}n=b(l.buffer)}return!!a.Call("Mesh_SetNormals",{meshHandle:t,base64Normals:n})}static RecalcNormals(t){return!!a.Call("Mesh_RecalculateNormals",{meshHandle:t})}static RecalcBounds(t){return!!a.Call("Mesh_RecalculateBounds",{meshHandle:t})}};function Tt(){let i=[[-.5,-.5,-.5],[.5,-.5,-.5],[.5,.5,-.5],[-.5,.5,-.5],[-.5,-.5,.5],[.5,-.5,.5],[.5,.5,.5],[-.5,.5,.5]],t=[[0,2,1],[0,3,2],[4,5,6],[4,6,7],[0,1,5],[0,5,4],[3,7,6],[3,6,2],[0,4,7],[0,7,3],[1,2,6],[1,6,5]],e=u.Create();return u.SetVertices(e,i),u.SetTriangles(e,t),u.RecalcNormals(e),u.RecalcBounds(e),e}function gt(){let i=[[-.5,-.5,0],[.5,-.5,0],[.5,.5,0],[-.5,.5,0]],t=[[0,1],[1,1],[1,0],[0,0]],e=[[0,2,1],[0,3,2]],n=u.Create();return u.SetVertices(n,i),u.SetUVs(n,t),u.SetTriangles(n,e),u.RecalcNormals(n),u.RecalcBounds(n),n}var k=class i{static Create(t){return!!a.Call("Renderable_Create",{entityHandle:t})}static Destroy(t){return!!a.Call("Renderable_Destroy",{entityHandle:t})}static HasComponent(t){return!!a.Call("Renderable_HasComponent",{entityHandle:t})}static SetMesh(t,e){return i.HasComponent(t)?!!a.Call("Renderable_SetMesh",{entityHandle:t,meshHandle:e}):!1}static SetMaterial(t,e,n=0){return!!a.Call("Renderable_SetMaterial",{entityHandle:t,materialHandle:e,index:n})}static SetLayerMask(t,e){return!!a.Call("Renderable_SetLayerMask",{entityHandle:t,layerMask:e})}static SetReceiveShadows(t,e){return!!a.Call("Renderable_SetReceiveShadows",{entityHandle:t,receive:e})}static SetCastShadows(t,e){return!!a.Call("Renderable_SetCastShadows",{entityHandle:t,shadowMode:e})}static SetCulling(t,e){return!!a.Call("Renderable_SetCulling",{entityHandle:t,enabled:e})}};var V=(s=>(s[s.Alpha8=1]="Alpha8",s[s.ARGB4444=2]="ARGB4444",s[s.RGB24=3]="RGB24",s[s.RGBA32=4]="RGBA32",s[s.ARGB32=5]="ARGB32",s[s.RGB565=7]="RGB565",s[s.R16=9]="R16",s[s.DXT1=10]="DXT1",s[s.DXT5=12]="DXT5",s))(V||{}),R=class{static Create2D(t,e,n){return Number(a.Call("Texture_Create2D",{width:t,height:e,format:n,clientId:a.GetClientId()}))}static Create2DForMaterial(t,e,n,l,r){let o=Number(a.Call("Texture_Create2D",{width:t,height:e,format:n,clientId:a.GetClientId()}));return a.Call("Material_SetTexture",{materialHandle:l,propertyName:r,textureHandle:o}),o}static CreateRenderTexture(t,e,n,l){return Number(a.Call("Texture_CreateRenderTexture",{width:t,height:e,depth:n,format:l,clientId:a.GetClientId()}))}static Destroy(t){return!!a.Call("Texture_Destroy",{textureHandle:t})}static LoadRawTextureData(t,e,n,l){let r=b(e);return!!a.Call("Texture_LoadRawTextureData",{textureHandle:t,base64Rgba:r,width:n,height:l})}static LoadImage(t,e){let n=b(e);return!!a.Call("Texture_LoadImage",{textureHandle:t,base64Image:n})}static LoadImageBase64(t,e){return!!a.Call("Texture_LoadImage",{textureHandle:t,base64Image:e})}static SetFilterMode(t,e){return!!a.Call("Texture_SetFilterMode",{textureHandle:t,filterMode:e})}static SetWrapMode(t,e){return!!a.Call("Texture_SetWrapMode",{textureHandle:t,wrapMode:e})}},X=(o=>(o[o.NEAREST=0]="NEAREST",o[o.LINEAR=1]="LINEAR",o[o.NEAREST_MIPMAP_NEAREST=2]="NEAREST_MIPMAP_NEAREST",o[o.LINEAR_MIPMAP_NEAREST=3]="LINEAR_MIPMAP_NEAREST",o[o.NEAREST_MIPMAP_LINEAR=4]="NEAREST_MIPMAP_LINEAR",o[o.LINEAR_MIPMAP_LINEAR=5]="LINEAR_MIPMAP_LINEAR",o))(X||{}),z=(n=>(n[n.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",n[n.REPEAT=1]="REPEAT",n[n.MIRRORED_REPEAT=2]="MIRRORED_REPEAT",n))(z||{});var y=class{static GetDefault(){return Number(a.Call("Scene_GetDefault",{}))}static SetSkybox(t,e){return!!a.Call("Scene_SetSkybox",{sceneHandle:t,skyboxHandle:e})}static SetAmbientLight(t,e,n,l,r){return!!a.Call("Scene_SetAmbientLight",{sceneHandle:t,r:e,g:n,b:l,intensity:r})}static SetFog(t,e,n,l,r,o){return!!a.Call("Scene_SetFog",{sceneHandle:t,enabled:e,mode:n,density:l,start:r,end:o})}};var D=class{static GetDefaultCameraEntity(){return console.warn("GetDefaultCameraEntity(): Unity RPC not available"),-1}static GetXRCameras(){return console.warn("GetXRCameras(): Unity RPC not available"),[]}static DestroyMaterialInstance(t){return p.Destroy(t)}static DestroyRenderTarget(t){return R.Destroy(t)}static DestroySkybox(t){return p.Destroy(t)}static DestroyIndirectLight(t){return console.warn("DestroyIndirectLight(): no Unity RPC equivalent"),!1}static SetSkybox(t,e){return y.SetSkybox(t,e)}static SetAmbientLight(t,e,n,l,r){return y.SetAmbientLight(t,e,n,l,r)}static SetFog(t,e,n,l,r,o){return y.SetFog(t,e,n,l,r,o)}};import{mat4 as W,quat as O,vec3 as f}from"gl-matrix";var v=class{static HasComponent(t){return!!a.Call("Transform_HasComponent",{entityHandle:t})}static SetTransform(t,e){let n=new Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++){let C=e[r*4+o];o===2&&(C=-C),n[o*4+r]=C}let l=n.join(",");return!!a.Call("Transform_SetTransform",{entityHandle:t,matrixJson:l})}static GetTransform(t){let n=a.Call("Transform_GetTransform",{entityHandle:t}).split(",").map(l=>parseFloat(l));if(n.length!==16)throw new Error(`Invalid transform data (${n.length} elements)`);return W.fromValues(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15])}static SetParent(t,e){return!!a.Call("Transform_SetParent",{entityHandle:t,parentHandle:e})}static GetParent(t){return Number(a.Call("Transform_GetParent",{entityHandle:t}))}static SetWorldPosition(t,e){return!!a.Call("Transform_SetWorldPosition",{entityHandle:t,x:e[0],y:e[1],z:e[2]})}static SetLocalPosition(t,e){return!!a.Call("Transform_SetLocalPosition",{entityHandle:t,x:e[0],y:e[1],z:e[2]})}static GetWorldPosition(t){let e=a.Call("Transform_GetWorldPosition",{entityHandle:t}),[n,l,r]=e.split(",").map(o=>parseFloat(o));return f.fromValues(n,l,r)}static GetLocalPosition(t){let e=a.Call("Transform_GetLocalPosition",{entityHandle:t}),[n,l,r]=e.split(",").map(o=>parseFloat(o));return f.fromValues(n,l,r)}static SetWorldRotation(t,e){return!!a.Call("Transform_SetWorldRotation",{entityHandle:t,x:e[0],y:e[1],z:e[2],w:e[3]})}static SetLocalRotation(t,e){return!!a.Call("Transform_SetLocalRotation",{entityHandle:t,x:e[0],y:e[1],z:e[2],w:e[3]})}static GetWorldRotation(t){let e=a.Call("Transform_GetWorldRotation",{entityHandle:t}),[n,l,r,o]=e.split(",").map(C=>parseFloat(C));return O.fromValues(n,l,r,o)}static GetLocalRotation(t){let e=a.Call("Transform_GetLocalRotation",{entityHandle:t}),[n,l,r,o]=e.split(",").map(C=>parseFloat(C));return O.fromValues(n,l,r,o)}static SetLocalScale(t,e){return!!a.Call("Transform_SetLocalScale",{entityHandle:t,x:e[0],y:e[1],z:e[2]})}static GetLocalScale(t){let e=a.Call("Transform_GetLocalScale",{entityHandle:t}),[n,l,r]=e.split(",").map(o=>parseFloat(o));return f.fromValues(n,l,r)}};export{B as CameraManager,M as ColliderManager,T as Debug,g as Device,A as EntityManager,L as GrabInteractableManager,G as Keyboard,x as LightManager,K as LightShadowMode,F as LightType,p as MaterialManager,u as MeshManager,Tt as NewCubeMesh,gt as NewQuadMesh,k as RenderableManager,D as RendererManager,N as RigidbodyManager,a as RpcClient,y as SceneManager,J as ShaderProperties,w as ShaderType,P as StateSync,X as TextureFilterMode,V as TextureFormat,R as TextureManager,z as TextureWrapMode,v as TransformManager,h as XRSystem,Et as base64Decode,b as base64Encode};
|