/
websg.d.ts
2843 lines (2541 loc) · 78.5 KB
/
websg.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare namespace WebSG {
/**
* @typedef AccessorType
* @type {("SCALAR"|"VEC2"|"VEC3"|"VEC4"|"MAT2"|"MAT3"|"MAT4")}
* @description The type of an accessor, describing the shape of the data it represents.
*/
type AccessorType = "SCALAR" | "VEC2" | "VEC3" | "VEC4" | "MAT2" | "MAT3" | "MAT4";
const AccessorType: { [Type in AccessorType]: Type };
/**
* @typedef AccessorComponentType
* @type {(5120|5121|5122|5123|5125|5126)}
* @description The component type of an accessor, describing the data type of individual components in the data.
*/
type AccessorComponentType = 5120 | 5121 | 5122 | 5123 | 5125 | 5126;
/**
* @constant AccessorComponentType
* @type {{
* Int8: 5120;
* Uint8: 5121;
* Int16: 5122;
* Uint16: 5123;
* Uint32: 5125;
* Float32: 5126;
* }}
* @description A mapping of AccessorComponentType values to their respective numeric codes.
*/
const AccessorComponentType: {
Int8: 5120;
Uint8: 5121;
Int16: 5122;
Uint16: 5123;
Uint32: 5125;
Float32: 5126;
};
/**
* Interface describing the properties of an Accessor created from an ArrayBuffer.
*/
interface AccessorFromProps {
/**
* The shape of the data the accessor represents.
*/
type: AccessorType;
/**
* The data type of individual components in the data.
*/
componentType: AccessorComponentType;
/**
* The number of elements in the accessor.
*/
count: number;
/**
* Whether the data should be normalized when accessed (default is `false`).
*/
normalized?: boolean;
/**
* Whether the accessor's data is dynamic and can change over time (default is `false`).
*/
dynamic?: boolean;
/**
* The minimum values of the accessor's components (optional).
*/
min?: number[];
/**
* The maximum values of the accessor's components (optional).
*/
max?: number[];
}
/**
* The Accessor class provides a way to update a given ArrayBuffer
* with new data.
*/
class Accessor {
/**
* Updates the existing ArrayBuffer with new data.
*
* @param data The new data to update the ArrayBuffer.
*
* @example
* // Create an instance of Accessor
* const accessor = world.createAccessorFrom(buffer, {
* componentType: WebSG.AccessorComponentType.Uint16,
* count: indicesCount,
* type: WebSG.AccessorType.SCALAR,
* });
*
* // Update the ArrayBuffer with new data
* accessor.updateWith(newData);
*/
updateWith(data: ArrayBuffer): this;
}
/**
* A type representing the possible collider types in the physics system.
* @typedef {("box" | "sphere" | "capsule" | "cylinder" | "hull" | "trimesh")} ColliderType
*/
type ColliderType = "box" | "sphere" | "capsule" | "cylinder" | "hull" | "trimesh";
/**
* A constant object containing the possible collider types as keys and their corresponding string values.
* @type {{Box: "box", Sphere: "sphere", Capsule: "capsule", Cylinder: "cylinder", Hull: "hull", Trimesh: "trimesh"}}
*/
const ColliderType: {
Box: "box";
Sphere: "sphere";
Capsule: "capsule";
Cylinder: "cylinder";
Hull: "hull";
Trimesh: "trimesh";
};
/**
* Collider properties interface.
*/
interface ColliderProps {
/**
* The type of the Collider.
*/
type: ColliderType;
/**
* Determines if the Collider acts as a trigger.
*/
isTrigger?: boolean;
/**
* The size of the Collider (required for box type).
*/
size?: ArrayLike<number>;
/**
* The radius of the Collider (required for sphere, capsule, and cylinder types).
*/
radius?: number;
/**
* The height of the Collider (required for capsule and cylinder types).
*/
height?: number;
/**
* The mesh representing the shape of the Collider (required for hull and trimesh types).
*/
mesh?: Mesh;
}
/**
* The Collider class represents a shape that can be used for
* collision detection in a physics simulation.
*/
class Collider {
/**
* Creates a new Collider instance with the specified properties.
*
* @param props The properties of the Collider.
*
* @example
* // Create a new box Collider
* const collider = world.createCollider({
* type: ColliderType.Box,
* size: [1, 1, 1],
* });
*/
constructor(props: ColliderProps);
}
type InteractableType = 1 | 2;
const InteractableType: {
Interactable: 1;
Grabbable: 2;
};
type InteractableProps = {
type: InteractableType;
};
/**
* The Interactable class represents an object that can be interacted
* with, providing information about its current interaction state.
*/
class Interactable {
/**
* Returns the pressed state of the Interactable object.
*
* @example
* node.addInteractable();
* console.log(node.interactable.pressed); // false
*/
get pressed(): boolean;
/**
* Returns the held state of the Interactable object.
*
* @example
* node.addInteractable();
* console.log(node.interactable.held); // false
*/
get held(): boolean;
/**
* Returns the released state of the Interactable object.
*
* @example
* node.addInteractable();
* console.log(node.interactable.released); // false
*/
get released(): boolean;
}
/**
* LightType is a union type representing the available types of lights.
* @typedef {"directional" | "point" | "spot"} LightType
*/
/**
* LightType is an object containing the string constants for the available types of lights.
* @type {Object} LightType
* @property {string} Directional - Represents a directional light.
* @property {string} Point - Represents a point light.
* @property {string} Spot - Represents a spot light.
*/
type LightType = {
Directional: "directional";
Point: "point";
Spot: "spot";
};
/**
* LightProps is an interface that defines the properties for creating a Light instance.
*/
interface LightProps {
/**
* The type of the light.
*/
type: LightType;
/**
* The optional name of the light.
*/
name?: string;
/**
* The optional intensity of the light. Default is 1.
*/
intensity?: number;
/**
* The optional RGB color of the light. Default is white.
*/
color?: ArrayLike<number>;
/**
* The optional range of the light, for point and spot lights.
*/
range?: number;
/**
* The optional inner cone angle of the light, for spot lights.
*/
innerConeAngle?: number;
/**
* The optional outer cone angle of the light, for spot lights.
*/
outerConeAngle?: number;
}
/**
* The Light class represents a light source in a scene.
*/
class Light {
/**
* Creates a new Light instance.
* @param props The properties to create the light with.
*/
constructor(props: LightProps);
/**
* Returns the intensity of the Light object.
*
* @example
* const light = world.createLight({ type: LightType.Point });
* console.log(light.intensity); // 1
*/
get intensity(): number;
/**
* Sets the intensity of the Light object.
* @param value - The new intensity value for the Light object.
*
* @example
* const light = world.createLight({ type: LightType.Point });
* light.intensity = 2;
* console.log(light.intensity); // 2
*/
set intensity(value: number);
/**
* Returns the color of the Light object as an RGB instance.
*
* @example
* const light = world.createLight({ type: LightType.Point, color: [1, 0, 0] });
* console.log(light.color); // RGB { r: 1, g: 0, b: 0 }
*/
get color(): RGB;
}
/**
* AlphaMode is a union type representing the available alpha modes.
*/
type AlphaMode = "OPAQUE" | "BLEND" | "MASK";
/**
* AlphaMode is an object containing the string constants for the available alpha modes.
*/
const AlphaMode: { [Mode in AlphaMode]: Mode };
/**
* UnlitMaterialProps is an interface that defines the properties for creating an unlit Material instance.
*/
interface UnlitMaterialProps {
/**
* The name of the material.
*/
name?: string;
/**
* The RGBA base color factor.
*/
baseColorFactor?: ArrayLike<number>;
/**
* The base color texture.
*/
baseColorTexture?: Texture;
/**
* Whether the material is visible from both sides. Default is false.
*/
doubleSided?: boolean;
/**
* The alpha cutoff value for the material. Default is 0.5.
*/
alphaCutoff?: number;
/**
* The alpha mode for the material. Default is 'OPAQUE'.
*/
alphaMode?: AlphaMode;
}
/**
* MaterialProps is an interface that defines the properties for creating a Material instance.
*/
interface MaterialProps {
/**
* The name of the material.
*/
name?: string;
/**
* Whether the material is visible from both sides. Default is false.
*/
doubleSided?: boolean;
/**
* The alpha cutoff value for the material. Default is 0.5.
*/
alphaCutoff?: number;
/**
* The alpha mode for the material. Default is 'OPAQUE'.
*/
alphaMode?: AlphaMode;
/**
* The RGBA base color factor.
*/
baseColorFactor?: ArrayLike<number>;
/**
* The base color texture.
*/
baseColorTexture?: Texture;
/**
* The metallic factor. Default is 1.
*/
metallicFactor?: number;
/**
* The roughness factor. Default is 1.
*/
roughnessFactor?: number;
/**
* The metallic-roughness texture.
*/
metallicRoughnessTexture?: Texture;
/**
* The normal texture.
*/
normalTexture?: Texture;
/**
* The scale for the normal texture. Default is 1.
*/
normalScale?: number;
/**
* The occlusion texture.
*/
occlusionTexture?: Texture;
/**
* The occlusion strength. Default is 1.
*/
occlusionStrength?: number;
/**
* The RGB emissive factor.
*/
emissiveFactor?: ArrayLike<number>;
/**
* The emissive texture.
*/
emissiveTexture?: Texture;
}
/**
* The Material class represents a material in a scene.
*/
class Material {
/**
* Creates a new Material instance.
* @param props The properties to create the material with.
*/
constructor(props: MaterialProps);
/**
* Returns the base color factor of the Material object as an RGBA instance.
*/
get baseColorFactor(): RGBA;
/**
* Gets the base color texture of the Material object.
*/
get baseColorTexture(): Texture | undefined;
/**
* Sets the base color texture of the Material object.
* @param texture The new base color texture.
*/
set baseColorTexture(texture: Texture | undefined);
/**
* Gets the metallic factor of the Material object.
*/
get metallicFactor(): number;
/**
* Sets the metallic factor of the Material object.
* @param value The new metallic factor value.
*/
set metallicFactor(value: number);
/**
* Gets the roughness factor of the Material object.
*/
get roughnessFactor(): number;
/**
* Sets the roughness factor of the Material object.
* @param value The new roughness factor value.
*/
set roughnessFactor(value: number);
/**
* Returns the emissive factor of the Material object as an RGB instance.
*/
get emissiveFactor(): RGB;
}
/**
* The Matrix4 class represents a 4x4 matrix of numbers.
*/
class Matrix4 {
[n: number]: number;
/**
* Sets the elements of the Matrix.
* @param {ArrayLike<number>} value - The new values for the Matrix4 instance.
*/
set(value: ArrayLike<number>): this;
/**
* Returns the number of elements of the Matrix.
*/
readonly length: number;
}
/**
* The ReadonlyMatrix4 class represents a readonly 4x4 matrix of numbers.
*/
class ReadonlyMatrix4 {
/**
* Gets the readonly value at a specific index.
*/
readonly [n: number]: number;
/**
* Returns the length of the ReadonlyMatrix4 instance.
*/
readonly length: number;
}
/**
* Enumeration of possible mesh primitive attributes.
*/
type MeshPrimitiveAttribute =
| "POSITION"
| "NORMAL"
| "TANGENT"
| "TEXCOORD_0"
| "TEXCOORD_1"
| "COLOR_0"
| "JOINTS_0"
| "WEIGHTS_0";
const MeshPrimitiveAttribute: { [Attribute in MeshPrimitiveAttribute]: Attribute };
/**
* Enumeration of possible mesh primitive rendering modes.
*/
type MeshPrimitiveMode = 0 | 1 | 2 | 3 | 4 | 5 | 6;
const MeshPrimitiveMode: {
POINTS: 0;
LINES: 1;
LINE_LOOP: 2;
LINE_STRIP: 3;
TRIANGLES: 4;
TRIANGLE_STRIP: 5;
TRIANGLE_FAN: 6;
};
/**
* MeshPrimitiveProps is an interface for defining properties of a mesh primitive.
*/
interface MeshPrimitiveProps {
mode?: MeshPrimitiveMode;
indices?: Accessor;
material?: Material;
attributes: { [name in MeshPrimitiveAttribute]?: Accessor };
}
/**
* The MeshPrimitive class represents a single primitive of a mesh.
*/
class MeshPrimitive {
/**
* Returns the current rendering mode of the mesh primitive.
*/
get mode(): MeshPrimitiveMode;
/**
* Returns the Accessor for the indices of the mesh primitive.
*/
get indices(): Accessor | undefined;
/**
* Returns the Accessor for the specified attribute name.
* @param name The attribute name.
* @returns The Accessor for the attribute or undefined if not found.
*/
getAttribute(name: MeshPrimitiveAttribute): Accessor | undefined;
/**
* Returns the Material of the mesh primitive.
*/
get material(): Material | undefined;
/**
* Sets the Material for the mesh primitive.
* @param material The Material to set.
*/
set material(material: Material | undefined);
/**
* Sets the draw range for the mesh primitive.
* @param start The starting index for the draw range.
* @param count The number of indices in the draw range.
*/
setDrawRange(start: number, count: number): this;
/**
* Enables or disables the hologram material for the mesh primitive.
* @param enabled Whether to enable or disable the hologram material.
* @experimental This API is experimental and may change or be removed in future releases.
*/
thirdroomSetHologramMaterialEnabled(enabled: boolean): this;
}
/**
* MeshProps is an interface for defining properties of a mesh.
*/
interface MeshProps {
/**
* The name of the mesh.
*/
name?: string;
/**
* An array of MeshPrimitiveProps that define the geometry and materials of the mesh.
*/
primitives: MeshPrimitiveProps[];
}
/**
* BoxMeshProps is an interface for defining properties of a box mesh.
*/
interface BoxMeshProps {
/**
* The size of the mesh in meters in the x,y,z directions.
*/
size?: ArrayLike<number>;
/**
* The number of segments to use in the x,y,z directions.
*/
segments?: ArrayLike<number>;
/**
* The material to use for the mesh.
*/
material?: Material;
}
/**
* The Mesh class represents a 3D object with one or more mesh primitives.
*/
class Mesh {
/**
* An array of MeshPrimitive instances that define the geometry of the mesh.
*/
readonly primitives: MeshPrimitive[];
}
/**
* An iterator for node objects.
*/
class NodeIterator {
/**
* Returns the next node in the iterator.
*/
next(): { value: Node; done: boolean };
[Symbol.iterator](): NodeIterator;
}
/**
* Interface representing the properties you can create a Node object with.
*/
interface NodeProps {
/**
* The initial name of the node.
*/
name?: string;
/**
* The initial mesh associated with the node.
*/
mesh?: Mesh;
/**
* The initial UI canvas associated with the node.
*/
uiCanvas?: UICanvas;
/**
* The initial translation of the node.
*/
translation?: Vector3;
/**
* The initial rotation of the node.
*/
rotation?: Quaternion;
/**
* The initial scale of the node.
*/
scale?: Vector3;
}
/**
* Interface representing the options for configuring an orbiting camera control mode.
*/
interface OrbitOptions {
/**
* The pitch angle in degrees, which is the rotation around the X-axis.
* Positive values tilt the camera upwards, while negative values tilt it downwards.
*/
pitch?: number;
/**
* The yaw angle in degrees, which is the rotation around the Y-axis.
* Positive values rotate the camera to the right, while negative values rotate it to the left.
*/
yaw?: number;
/**
* The zoom value, which is a scalar factor for the distance from the object.
* Positive values move the camera closer to the object, while negative values move it further away.
*/
zoom?: number;
}
/**
* Class representing a node in a scene graph.
*/
class Node {
/**
* The node's translation as a Vector3.
*/
readonly translation: Vector3;
/**
* The node's rotation as a Quaternion.
*/
readonly rotation: Quaternion;
/**
* The node's scale as a Vector3.
*/
readonly scale: Vector3;
/**
* The node's local transformation matrix as a Matrix4.
*/
readonly matrix: Matrix4;
/**
* The node's world transformation matrix as a ReadonlyMatrix4.
*/
readonly worldMatrix: ReadonlyMatrix4;
/**
* Adds a child node to this node.
* @param node The node to add as a child.
*/
addChild(node: Node): this;
/**
* Removes a child node from this node.
* @param node The node to remove.
*/
removeChild(node: Node): this;
/**
* Gets the child node at the specified index or undefined if the index is out of range.
* @param index The index of the child node.
*/
getChild(index: number): Node | undefined;
/**
* Returns an iterator for the children of this node.
*/
children(): NodeIterator;
/**
* Gets the parent node of this node or undefined if this node has no parent.
*/
get parent(): Node | undefined;
/**
* Gets or sets whether this node is static.
*/
get isStatic(): boolean;
/**
* Sets whether this node is static and can be optimized by the engine.
* Optimizations include world matrix calculations. When a node is static,
* you may not modify its transform properties (translation, rotation, scale).
* @param value Whether this node is static.
*/
set isStatic(value: boolean);
/**
* Returns whether or not this node is visible
*/
get visible(): boolean;
/**
* Sets whether or not this node is visible
* @param value Whether or not this node is visible
*/
set visible(value: boolean);
/**
* Get the mesh associated with this node.
*/
get mesh(): Mesh | undefined;
/**
* Set the mesh associated with this node.
* @param mesh The mesh to associate with this node or undefined to unset.
*/
set mesh(mesh: Mesh | undefined);
/**
* Get the light associated with this node.
*/
get light(): Light | undefined;
/**
* Set the light associated with this node.
* @param light The light to associate with this node or undefined to unset.
*/
set light(light: Light | undefined);
/**
* Get the collider associated with this node.
*/
get collider(): Collider | undefined;
/**
* Set the collider associated with this node.
* @param collider The collider to associate with this node or undefined to unset.
*/
set collider(collider: Collider | undefined);
/**
* Get the UI canvas associated with this node.
*/
get uiCanvas(): UICanvas | undefined;
/**
* Set the UI canvas associated with this node.
* @param uiCanvas The UI canvas to associate with this node or undefined to unset.
*/
set uiCanvas(uiCanvas: UICanvas | undefined);
/**
* Gets the interactable behavior associated with this node.
*/
get interactable(): Interactable | undefined;
/**
* Adds an interactable behavior to this node.
* @param {InteractableProps | undefined} props Optional interactable properties.
*/
addInteractable(props?: InteractableProps): Interactable;
/**
* Removes the interactable property from this node.
*/
removeInteractable(): undefined;
/**
* Gets the physics body behavior associated with this node.
*/
get physicsBody(): PhysicsBody | undefined;
/**
* Adds a physics body behavior to this node.
* @param {PhysicsBodyProps | undefined} props Optional physics body properties.
*/
addPhysicsBody(props?: PhysicsBodyProps): PhysicsBody;
/**
* Removes the physics body behavior from this node.
*/
removePhysicsBody(): undefined;
/**
* Enables orbit camera control mode for this node.
* @param options Optional orbit options.
*/
startOrbit(options?: OrbitOptions): undefined;
/**
* Adds a component to this node.
* @param component the component type to add.
*/
addComponent(component: ComponentStore): undefined;
/**
* Removes a component from this node.
* @param component the component type to remove.
*/
removeComponent(component: ComponentStore): undefined;
/**
* Checks if this node has a component.
* @param component the component type to check for.
*/
hasComponent(component: ComponentStore): boolean;
/**
* Gets an instance of a component of the specified type on this node.
* If the component does not exist on this node, it will return undefined.
* @param component the component type to get.
*/
getComponent(component: ComponentStore): Component | undefined;
}
/**
* Type representing the various physics body types.
*/
type PhysicsBodyType = "kinematic" | "rigid" | "static";
/**
* Physics body type constants.
*/
const PhysicsBodyType: {
Kinematic: "kinematic";
Rigid: "rigid";
Static: "static";
};
/**
* Interface representing the properties for creating a PhysicsBody.
*/
interface PhysicsBodyProps {
/**
* The type of the physics body.
*/
type: PhysicsBodyType;
/**
* The mass of the physics body in kilograms.
*/
mass?: number;
/**
* The linear velocity of the physics body as an array of three numbers [x, y, z].
*/
linearVelocity?: ArrayLike<number>;
/**
* The angular velocity of the physics body as an array of three numbers [x, y, z].
*/
angularVelocity?: ArrayLike<number>;
/**
* The inertia tensor of the physics body as an array of nine numbers representing a 3x3 matrix.
* @experimental This property is experimental and may be changed in a future release.
*/
inertiaTensor?: ArrayLike<number>;
}
/**
* A PhysicsBody is a behavior that can be added to a node to give it a
* physical presence in the world and interact with other physics bodies.
*/
class PhysicsBody {
/**
* Applies an impulse at the center of mass of this physics body.
* @param impulse The impulse to apply.
*/
applyImpulse(impulse: ArrayLike<number>): undefined;
}
class Collision {
/**
* The first node involved in the collision.
*/
nodeA: Node;
/**
* The second node involved in the collision.
*/
nodeB: Node;
/**
* Whether the collision started or ended this frame.
*/
started: boolean;
}
/**
* An iterator for collisions.
*/
class CollisionIterator {
/**
* Returns the next collision in the iterator.
*/
next(): { value: Collision; done: boolean };
[Symbol.iterator](): CollisionIterator;
}
/**
* A Collision Listener provides an interface for listening to collisions events between nodes with colliders.
* Collision events are recorded for both the start and end of a collision.
* {@link WebSG.CollisionListener.collisions | .collisions()} should be called each frame to iterate through
* the collisions that occurred since the last call to .collisions(). Failing to regularly call .collisions()
* will result in a memory leak. If you are done listening to collisions, you should call .dispose() to free
* up the memory used by the collision listener and stop listening to collisions.
*/
class CollisionListener {
/**
* Returns an iterator for the collisions that occurred since the last call to .collisions().
*/
collisions(): CollisionIterator;
/**
* Disposes of the collision listener and stops listening to collisions.
*/
dispose(): void;
}
/**
* A Quaternion class with x, y, z, and w components. The class provides methods to set the components of the quaternion using an array-like syntax.
*/
class Quaternion {
/**
* The quaternion components.
*/
[n: number]: number;
/**
* The x-component of the quaternion.
*/
x: number;
/**
* The y-component of the quaternion.
*/
y: number;
/**
* The z-component of the quaternion.
*/
z: number;
/**