forked from cocos-creator/cocos-cannon.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCANNON.d.ts
1363 lines (1066 loc) · 40.7 KB
/
CANNON.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
// tslint:disable:max-line-length
// tslint:disable-next-line:no-namespace
declare namespace CANNON {
interface IAABBOptions {
upperBound?: Vec3;
lowerBound?: Vec3;
}
class AABB {
public lowerBound: Vec3;
public upperBound: Vec3;
constructor (options?: IAABBOptions);
public clone (): AABB;
public copy (aabb: AABB): void;
public extend (aabb: AABB): void;
public getCorners (a: Vec3, b: Vec3, c: Vec3, d: Vec3, e: Vec3, f: Vec3, g: Vec3, h: Vec3): void;
public overlaps (aabb: AABB): boolean;
public setFromPoints (points: Vec3[], position?: Vec3, quaternion?: Quaternion, skinSize?: number): AABB;
public toLocalFrame (frame: Transform, target: AABB): AABB;
public toWorldFrame (frame: Transform, target: AABB): AABB;
}
/**
* @class OctreeNode
* @param {object} [options]
* @param {Octree} [options.root]
* @param {AABB} [options.aabb]
*/
class OctreeNode {
/**
* The root node
* @property {OctreeNode} root
*/
root: OctreeNode | null;
/**
* Boundary of this node
* @property {AABB} aabb
*/
aabb: AABB;
/**
* Contained data at the current node level.
* @property {Array} data
*/
data: number[];
/**
* Children to this node
* @property {Array} children
*/
children: OctreeNode[];
/**
* Insert data into this node
* @method insert
* @param {AABB} aabb
* @param {object} elementData
* @return {boolean} True if successful, otherwise false
*/
insert (aabb: AABB, elementData: any, level?: number | 0): boolean
reset (): void;
/**
* Create 8 equally sized children nodes and put them in the .children array.
* @method subdivide
*/
subdivide (): void;
/**
* Get all data, potentially within an AABB
* @method aabbQuery
* @param {AABB} aabb
* @param {array} result
* @return {array} The "result" object
*/
aabbQuery (aabb: AABB, resul: any[]): any[]
/**
* Get all data, potentially intersected by a ray.
* @method rayQuery
* @param {Ray} ray
* @param {Transform} treeTransform
* @param {array} result
* @return {array} The "result" object
*/
rayQuery (ray: Ray, treeTransform: Transform, result: any[]): any[];
/**
* @method removeEmptyNodes
*/
removeEmptyNodes (): void;
}
/**
* @class Octree
* @param {AABB} aabb The total AABB of the tree
* @param {object} [options]
* @param {number} [options.maxDepth=8]
* @extends OctreeNode
*/
class Octree extends OctreeNode {
maxDepth: number | 8;
constructor (aabb?: AABB, opt?: any);
}
class ArrayCollisionMatrix {
public matrix: Mat3[];
public get (i: number, j: number): number;
public set (i: number, j: number, value: number): void;
public reset (): void;
public setNumObjects (n: number): void;
}
class BroadPhase {
public world: World;
public useBoundingBoxes: boolean;
public dirty: boolean;
public collisionPairs (world: World, p1: Body[], p2: Body[]): void;
public needBroadphaseCollision (bodyA: Body, bodyB: Body): boolean;
public intersectionTest (bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void;
public doBoundingSphereBroadphase (bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void;
public doBoundingBoxBroadphase (bodyA: Body, bodyB: Body, pairs1: Body[], pairs2: Body[]): void;
public makePairsUnique (pairs1: Body[], pairs2: Body[]): void;
public setWorld (world: World): void;
public boundingSphereCheck (bodyA: Body, bodyB: Body): boolean;
public aabbQuery (world: World, aabb: AABB, result: Body[]): Body[];
}
class GridBroadphase extends BroadPhase {
public nx: number;
public ny: number;
public nz: number;
public aabbMin: Vec3;
public aabbMax: Vec3;
public bins: any[];
constructor (aabbMin?: Vec3, aabbMax?: Vec3, nx?: number, ny?: number, nz?: number);
}
class NaiveBroadphase extends BroadPhase {
}
class ObjectCollisionMatrix {
public matrix: number[];
public get (i: number, j: number): number;
public set (i: number, j: number, value: number): void;
public reset (): void;
public setNumObjects (n: number): void;
}
class Ray {
public from: Vec3;
public to: Vec3;
public precision: number;
public checkCollisionResponse: boolean;
constructor (from?: Vec3, to?: Vec3);
public getAABB (result: RaycastResult): void;
}
class RaycastResult {
public rayFromWorld: Vec3;
public rayToWorld: Vec3;
public hitNormalWorld: Vec3;
public hitPointWorld: Vec3;
public hasHit: boolean;
public shape: Shape;
public body: Body;
public distance: number;
public reset (): void;
public set (rayFromWorld: Vec3, rayToWorld: Vec3, hitNormalWorld: Vec3, hitPointWorld: Vec3, shape: Shape, body: Body, distance: number): void;
}
class SAPBroadphase extends BroadPhase {
public static insertionSortX (a: any[]): any[];
public static insertionSortY (a: any[]): any[];
public static insertionSortZ (a: any[]): any[];
public static checkBounds (bi: Body, bj: Body, axisIndex?: number): boolean;
public axisList: any[];
public world: World;
public axisIndex: number;
constructor (world?: World);
public autoDetectAxis (): void;
public aabbQuery (world: World, aabb: AABB, result?: Body[]): Body[];
}
interface IConstraintOptions {
collideConnected?: boolean;
wakeUpBodies?: boolean;
}
class Constraint {
public equations: any[];
public bodyA: Body;
public bodyB: Body;
public id: number;
public collideConnected: boolean;
constructor (bodyA: Body, bodyB: Body, options?: IConstraintOptions);
public update (): void;
public disable (): void;
public enable (): void;
}
class DistanceConstraint extends Constraint {
constructor (bodyA: Body, bodyB: Body, distance: number, maxForce?: number);
}
interface IHingeConstraintOptions {
pivotA?: Vec3;
axisA?: Vec3;
pivotB?: Vec3;
axisB?: Vec3;
maxForce?: number;
}
class HingeConstraint extends Constraint {
public motorEnabled: boolean;
public motorTargetVelocity: number;
public motorMinForce: number;
public motorMaxForce: number;
public motorEquation: RotationalMotorEquation;
constructor (bodyA: Body, bodyB: Body, options?: IHingeConstraintOptions);
public enableMotor (): void;
public disableMotor (): void;
}
class PointToPointConstraint extends Constraint {
constructor (bodyA: Body, pivotA: Vec3, bodyB: Body, pivotB: Vec3, maxForce?: number);
}
interface ILockConstraintOptions {
maxForce?: number;
}
class LockConstraint extends Constraint {
constructor (bodyA: Body, bodyB: Body, options?: ILockConstraintOptions);
}
interface IConeTwistConstraintOptions {
pivotA?: Vec3;
pivotB?: Vec3;
axisA?: Vec3;
axisB?: Vec3;
maxForce?: number;
}
class ConeTwistConstraint extends Constraint {
constructor (bodyA: Body, bodyB: Body, options?: IConeTwistConstraintOptions);
}
class Equation {
public readonly id: number;
public minForce: number;
public maxForce: number;
public bi: Body;
public bj: Body;
public a: number;
public b: number;
public eps: number;
public jacobianElementA: JacobianElement;
public jacobianElementB: JacobianElement;
public enabled: boolean;
public multiplier: number;
constructor (bi: Body, bj: Body, minForce?: number, maxForce?: number);
public setSpookParams (stiffness: number, relaxation: number, timeStep: number): void;
public computeB (a: number, b: number, h: number): number;
public computeGq (): number;
public computeGW (): number;
public computeGWlamda (): number;
public computeGiMf (): number;
public computeGiMGt (): number;
public addToWlamda (deltalambda: number): number;
public computeC (): number;
}
class FrictionEquation extends Equation {
constructor (bi: Body, bj: Body, slipForce: number);
}
class RotationalEquation extends Equation {
public ni: Vec3;
public nj: Vec3;
public nixnj: Vec3;
public njxni: Vec3;
public invIi: Mat3;
public invIj: Mat3;
public relVel: Vec3;
public relForce: Vec3;
constructor (bodyA: Body, bodyB: Body);
}
class RotationalMotorEquation extends Equation {
public axisA: Vec3;
public axisB: Vec3;
public invLi: Mat3;
public invIj: Mat3;
public targetVelocity: number;
constructor (bodyA: Body, bodyB: Body, maxForce?: number);
}
class ContactEquation extends Equation {
public si: Shape;
public sj: Shape;
public restitution: number;
public ri: Vec3;
public rj: Vec3;
// public penetrationVec: Vec3;
public ni: Vec3;
// public rixn: Vec3;
// public rjxn: Vec3;
// public invIi: Mat3;
// public invIj: Mat3;
// public biInvInertiaTimesRixn: Vec3;
// public bjInvInertiaTimesRjxn: Vec3;
constructor (bi: Body, bj: Body);
}
interface IContactMaterialOptions {
friction?: number;
restitution?: number;
contactEquationStiffness?: number;
contactEquationRelaxation?: number;
frictionEquationStiffness?: number;
frictionEquationRelaxation?: number;
}
class ContactMaterial {
public id: number;
public materials: Material[];
public friction: number;
public restitution: number;
public contactEquationStiffness: number;
public contactEquationRelaxation: number;
public frictionEquationStiffness: number;
public frictionEquationRelaxation: number;
constructor (m1: Material, m2: Material, options?: IContactMaterialOptions);
}
class Material {
public name: string;
public id: number;
public friction: number;
public restitution: number;
constructor (name: string);
}
class JacobianElement {
public spatial: Vec3;
public rotational: Vec3;
public multiplyElement (element: JacobianElement): number;
public multiplyVectors (spacial: Vec3, rotational: Vec3): number;
}
class Mat3 {
constructor (elements?: number[]);
public identity (): void;
public setZero (): void;
public setTrace (vec3: Vec3): void;
public getTrace (target: Vec3): void;
public vmult (v: Vec3, target?: Vec3): Vec3;
public smult (s: number): void;
public mmult (m: Mat3): Mat3;
public scale (v: Vec3, target?: Mat3): Mat3;
public solve (b: Vec3, target?: Vec3): Vec3;
public e (row: number, column: number, value?: number): number;
public copy (source: Mat3): Mat3;
public toString (): string;
public reverse (target?: Mat3): Mat3;
public setRotationFromQuaternion (q: Quaternion): Mat3;
public transpose (target?: Mat3): Mat3;
}
class Quaternion {
public x: number;
public y: number;
public z: number;
public w: number;
constructor (x?: number, y?: number, z?: number, w?: number);
public set (x: number, y: number, z: number, w: number): void;
public toString (): string;
public toArray (): number[];
public setFromAxisAngle (axis: Vec3, angle: number): void;
public toAxisAngle (targetAxis?: Vec3): any[];
public setFromVectors (u: Vec3, v: Vec3): void;
public mult (q: Quaternion, target?: Quaternion): Quaternion;
public inverse (target?: Quaternion): Quaternion;
public conjugate (target?: Quaternion): Quaternion;
public normalize (): void;
public normalizeFast (): void;
public vmult (v: Vec3, target?: Vec3): Vec3;
public copy (source: Quaternion): Quaternion;
public toEuler (target: Vec3, order?: string): void;
public setFromEuler (x: number, y: number, z: number, order?: string): Quaternion;
public clone (): Quaternion;
}
class Transform {
public static pointToLocalFrame (position: Vec3, quaternion: Quaternion, worldPoint: Vec3, result?: Vec3): Vec3;
public static pointToWorldFrame (position: Vec3, quaternion: Quaternion, localPoint: Vec3, result?: Vec3): Vec3;
public position: Vec3;
public quaternion: Quaternion;
public vectorToWorldFrame (localVector: Vec3, result?: Vec3): Vec3;
public vectorToLocalFrame (position: Vec3, quaternion: Quaternion, worldVector: Vec3, result?: Vec3): Vec3;
}
class Vec3 {
public static ZERO: Vec3;
public x: number;
public y: number;
public z: number;
constructor (x?: number, y?: number, z?: number);
public cross (v: Vec3, target?: Vec3): Vec3;
public set (x: number, y: number, z: number): Vec3;
public setZero (): void;
public vadd (v: Vec3, target?: Vec3): Vec3;
public vsub (v: Vec3, target?: Vec3): Vec3;
public crossmat (): Mat3;
public normalize (): number;
public unit (target?: Vec3): Vec3;
public norm (): number;
public norm2 (): number;
public distanceTo (p: Vec3): number;
public mult (scalar: number, target?: Vec3): Vec3;
public scale (scalar: number, target?: Vec3): Vec3;
public dot (v: Vec3): number;
public isZero (): boolean;
public negate (target?: Vec3): Vec3;
public tangents (t1: Vec3, t2: Vec3): void;
public toString (): string;
public toArray (): number[];
public copy (source: Vec3): Vec3;
public lerp (v: Vec3, t: number, target?: Vec3): void;
public almostEquals (v: Vec3, precision?: number): boolean;
public almostZero (precision?: number): boolean;
public isAntiparallelTo (v: Vec3, prescision?: number): boolean;
public clone (): Vec3;
}
interface IBodyOptions {
position?: Vec3;
velocity?: Vec3;
angularVelocity?: Vec3;
quaternion?: Quaternion;
mass?: number;
material?: Material;
type?: number;
linearDamping?: number;
angularDamping?: number;
allowSleep?: boolean;
sleepSpeedLimit?: number;
sleepTimeLimit?: number;
collisionFilterGroup?: number;
collisionFilterMask?: number;
fixedRotation?: boolean;
useGravity?: boolean;
shape?: Shape;
}
class Body extends EventTarget {
public static DYNAMIC: number;
public static STATIC: number;
public static KINEMATIC: number;
public static AWAKE: number;
public static SLEEPY: number;
public static SLEEPING: number;
public static sleepyEvent: IEvent;
public static sleepEvent: IEvent;
public readonly id: number;
public world: World;
public preStep: Function;
public postStep: Function;
public vlambda: Vec3;
public collisionFilterGroup: number;
public collisionFilterMask: number;
public collisionResponse: boolean;
public position: Vec3;
public previousPosition: Vec3;
public initPosition: Vec3;
public interpolatedPosition: Vec3;
public velocity: Vec3;
public initVelocity: Vec3;
public angularVelocity: Vec3;
public initAngularVelocity: Vec3;
public force: Vec3;
public torque: Vec3;
public mass: number;
public invMass: number;
public material: Material;
public linearDamping: number;
public type: number;
public allowSleep: boolean;
public sleepState: number;
public sleepSpeedLimit: number;
public sleepTimeLimit: number;
public timeLastSleepy: number;
public quaternion: Quaternion;
public previousQuaternion: Quaternion;
public initQuaternion: Quaternion;
public interpolatedQuaternion: Quaternion;
public shapes: Shape[];
public shapeOffsets: any[];
public shapeOrientations: any[];
public inertia: Vec3;
public invInertia: Vec3;
public invInertiaWorld: Mat3;
public invMassSolve: number;
public invInertiaSolve: Vec3;
public invInteriaWorldSolve: Mat3;
public fixedRotation: boolean;
public angularDamping: number;
public aabb: AABB;
public aabbNeedsUpdate: boolean;
public wlambda: Vec3;
public angularFactor: Vec3;
public linearFactor: Vec3;
public useGravity: boolean;
public hasTrigger: boolean;
constructor (options?: IBodyOptions);
public isAwake (): boolean;
public isSleeping (): boolean;
public isSleepy (): boolean;
public wakeUp (): void;
public sleep (): void;
public sleepTick (time: number): void;
public updateSolveMassProperties (): void;
public pointToLocalFrame (worldPoint: Vec3, result?: Vec3): Vec3;
public pointToWorldFrame (localPoint: Vec3, result?: Vec3): Vec3;
public vectorToWorldFrame (localVector: Vec3, result?: Vec3): Vec3;
public addShape (shape: Shape, offset?: Vec3, orientation?: Quaternion): void;
public removeShape (shape: Shape): void;
public updateBoundingRadius (): void;
public computeAABB (): void;
public updateInertiaWorld (force: Vec3): void;
public applyForce (force: Vec3, worldPoint: Vec3): void;
public applyImpulse (impulse: Vec3, worldPoint: Vec3): void;
public applyLocalForce (force: Vec3, localPoint: Vec3): void;
public applyLocalImpulse (impulse: Vec3, localPoint: Vec3): void;
public updateMassProperties (): void;
public getVelocityAtWorldPoint (worldPoint: Vec3, result: Vec3): Vec3;
public updateHasTrigger (): void;
}
interface IRaycastVehicleOptions {
chassisBody?: Body;
indexRightAxis?: number;
indexLeftAxis?: number;
indexUpAxis?: number;
}
interface IWheelInfoOptions {
chassisConnectionPointLocal?: Vec3;
chassisConnectionPointWorld?: Vec3;
directionLocal?: Vec3;
directionWorld?: Vec3;
axleLocal?: Vec3;
axleWorld?: Vec3;
suspensionRestLength?: number;
suspensionMaxLength?: number;
radius?: number;
suspensionStiffness?: number;
dampingCompression?: number;
dampingRelaxation?: number;
frictionSlip?: number;
steering?: number;
rotation?: number;
deltaRotation?: number;
rollInfluence?: number;
maxSuspensionForce?: number;
isFronmtWheel?: boolean;
clippedInvContactDotSuspension?: number;
suspensionRelativeVelocity?: number;
suspensionForce?: number;
skidInfo?: number;
suspensionLength?: number;
maxSuspensionTravel?: number;
useCustomSlidingRotationalSpeed?: boolean;
customSlidingRotationalSpeed?: number;
position?: Vec3;
direction?: Vec3;
axis?: Vec3;
body?: Body;
}
class WheelInfo {
public maxSuspensionTravbel: number;
public customSlidingRotationalSpeed: number;
public useCustomSlidingRotationalSpeed: boolean;
public sliding: boolean;
public chassisConnectionPointLocal: Vec3;
public chassisConnectionPointWorld: Vec3;
public directionLocal: Vec3;
public directionWorld: Vec3;
public axleLocal: Vec3;
public axleWorld: Vec3;
public suspensionRestLength: number;
public suspensionMaxLength: number;
public radius: number;
public suspensionStiffness: number;
public dampingCompression: number;
public dampingRelaxation: number;
public frictionSlip: number;
public steering: number;
public rotation: number;
public deltaRotation: number;
public rollInfluence: number;
public maxSuspensionForce: number;
public engineForce: number;
public brake: number;
public isFrontWheel: boolean;
public clippedInvContactDotSuspension: number;
public suspensionRelativeVelocity: number;
public suspensionForce: number;
public skidInfo: number;
public suspensionLength: number;
public sideImpulse: number;
public forwardImpulse: number;
public raycastResult: RaycastResult;
public worldTransform: Transform;
public isInContact: boolean;
constructor (options?: IWheelInfoOptions);
}
class RaycastVehicle {
public chassisBody: Body;
public wheelInfos: IWheelInfoOptions[];
public sliding: boolean;
public world: World;
public iindexRightAxis: number;
public indexForwardAxis: number;
public indexUpAxis: number;
constructor (options?: IRaycastVehicleOptions);
public addWheel (options?: IWheelInfoOptions): void;
public setSteeringValue (value: number, wheelIndex: number): void;
public applyEngineForce (value: number, wheelIndex: number): void;
public setBrake (brake: number, wheelIndex: number): void;
public addToWorld (world: World): void;
public getVehicleAxisWorld (axisIndex: number, result: Vec3): Vec3;
public updateVehicle (timeStep: number): void;
public updateSuspension (deltaTime: number): void;
public removeFromWorld (world: World): void;
public getWheelTransformWorld (wheelIndex: number): Transform;
}
interface IRigidVehicleOptions {
chassisBody: Body;
}
class RigidVehicle {
public wheelBodies: Body[];
public coordinateSystem: Vec3;
public chassisBody: Body;
public constraints: Constraint[];
public wheelAxes: Vec3[];
public wheelForces: Vec3[];
constructor (options?: IRigidVehicleOptions);
public addWheel (options?: IWheelInfoOptions): Body;
public setSteeringValue (value: number, wheelIndex: number): void;
public setMotorSpeed (value: number, wheelIndex: number): void;
public disableMotor (wheelIndex: number): void;
public setWheelForce (value: number, wheelIndex: number): void;
public applyWheelForce (value: number, wheelIndex: number): void;
public addToWorld (world: World): void;
public removeFromWorld (world: World): void;
public getWheelSpeed (wheelIndex: number): number;
}
class SPHSystem {
public particles: Particle[];
public density: number;
public smoothingRadius: number;
public speedOfSound: number;
public viscosity: number;
public eps: number;
public pressures: number[];
public densities: number[];
public neighbors: number[];
public add (particle: Particle): void;
public remove (particle: Particle): void;
public getNeighbors (particle: Particle, neighbors: Particle[]): void;
public update (): void;
public w (r: number): number;
public gradw (rVec: Vec3, resultVec: Vec3): void;
public nablaw (r: number): number;
}
interface ISpringOptions {
restLength?: number;
stiffness?: number;
damping?: number;
worldAnchorA?: Vec3;
worldAnchorB?: Vec3;
localAnchorA?: Vec3;
localAnchorB?: Vec3;
}
class Spring {
public restLength: number;
public stffness: number;
public damping: number;
public bodyA: Body;
public bodyB: Body;
public localAnchorA: Vec3;
public localAnchorB: Vec3;
constructor (options?: ISpringOptions);
public setWorldAnchorA (worldAnchorA: Vec3): void;
public setWorldAnchorB (worldAnchorB: Vec3): void;
public getWorldAnchorA (result: Vec3): void;
public getWorldAnchorB (result: Vec3): void;
public applyForce (): void;
}
class Box extends Shape {
public static calculateIntertia (halfExtents: Vec3, mass: number, target: Vec3): void;
public boundingSphereRadius: number;
public collisionResponse: boolean;
public halfExtents: Vec3;
public convexPolyhedronRepresentation: ConvexPolyhedron;
constructor (halfExtents: Vec3);
public updateConvexPolyhedronRepresentation (): void;
public calculateLocalInertia (mass: number, target?: Vec3): Vec3;
public getSideNormals (sixTargetVectors: boolean, quat?: Quaternion): Vec3[];
public updateBoundingSphereRadius (): number;
public volume (): number;
public forEachWorldCorner (pos: Vec3, quat: Quaternion, callback: Function): void;
}
class ConvexPolyhedron extends Shape {
public static computeNormal (va: Vec3, vb: Vec3, vc: Vec3, target: Vec3): void;
public static project (hull: ConvexPolyhedron, axis: Vec3, pos: Vec3, quat: Quaternion, result: number[]): void;
public vertices: Vec3[];
public worldVertices: Vec3[];
public worldVerticesNeedsUpdate: boolean;
public worldFaceNormalsNeedsUpdate: boolean;
public faces: number[][];
public faceNormals: Vec3[];
public uniqueEdges: Vec3[];
public uniqueAxes: Vec3[];
constructor (points?: Vec3[], faces?: number[]);
public computeEdges (): void;
public computeNormals (): void;
public computeWorldFaceNormals (quat: Quaternion): void;
public getFaceNormal (i: number, target: Vec3): Vec3;
public clipAgainstHull (posA: Vec3, quatA: Quaternion, hullB: Vec3, quatB: Quaternion, separatingNormal: Vec3, minDist: number, maxDist: number, result: any[]): void;
public findSaparatingAxis (hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion, target: Vec3, faceListA: any[], faceListB: any[]): boolean;
public testSepAxis (axis: Vec3, hullB: ConvexPolyhedron, posA: Vec3, quatA: Quaternion, posB: Vec3, quatB: Quaternion): number;
public getPlaneConstantOfFace (face_i: number): number;
public clipFaceAgainstHull (separatingNormal: Vec3, posA: Vec3, quatA: Quaternion, worldVertsB1: Vec3[], minDist: number, maxDist: number, result: any[]): void;
public clipFaceAgainstPlane (inVertices: Vec3[], outVertices: Vec3[], planeNormal: Vec3, planeConstant: number): Vec3;
public computeWorldVertices (position: Vec3, quat: Quaternion): void;
public computeLocalAABB (aabbmin: Vec3, aabbmax: Vec3): void;
public computeWorldFaceNormals (quat: Quaternion): void;
public calculateWorldAABB (pos: Vec3, quat: Quaternion, min: Vec3, max: Vec3): void;
public getAveragePointLocal (target: Vec3): Vec3;
public transformAllPoints (offset: Vec3, quat: Quaternion): void;
public pointIsInside (p: Vec3): boolean;
}
class Cylinder extends ConvexPolyhedron {
constructor (radiusTop: number, radiusBottom: number, height: number, numSegments: number);
}
interface IHightfield {
minValue?: number;
maxValue?: number;
elementSize: number;
}
class Heightfield extends Shape {
public data: number[][];
public maxValue: number;
public minValue: number;
public elementSize: number;
public cacheEnabled: boolean;
public pillarConvex: ConvexPolyhedron;
public pillarOffset: Vec3;
public type: number;
constructor (data: number[], options?: IHightfield);
public update (): void;
public updateMinValue (): void;
public updateMaxValue (): void;
public setHeightValueAtIndex (xi: number, yi: number, value: number): void;
public getRectMinMax (iMinX: number, iMinY: number, iMaxX: number, iMaxY: number, result: any[]): void;
public getIndexOfPosition (x: number, y: number, result: any[], clamp: boolean): boolean;
public getConvexTrianglePillar (xi: number, yi: number, getUpperTriangle: boolean): void;
}
class Particle extends Shape {
}
class Plane extends Shape {
public worldNormal: Vec3;
public worldNormalNeedsUpdate: boolean;
public boundingSphereRadius: number;
public computeWorldNormal (quat: Quaternion): void;
public calculateWorldAABB (pos: Vec3, quat: Quaternion, min: number, max: number): void;
}
class Shape extends EventTarget {
public static types: {
SPHERE: number;
PLANE: number;
BOX: number;
COMPOUND: number;
CONVEXPOLYHEDRON: number;
HEIGHTFIELD: number;
PARTICLE: number;
CYLINDER: number;
};
public readonly id: number;
public type: number;
public body: Body;
public boundingSphereRadius: number;
public collisionFilterMask: number;
public collisionFilterGroup: number;
public collisionResponse: boolean;
public material: Material;
public updateBoundingSphereRadius (): number;
public volume (): number;
public calculateLocalInertia (mass: number, target: Vec3): Vec3;
}
class Sphere extends Shape {
public radius: number;
constructor (radius: number);
}
class Trimesh extends Shape {
/**
* @property vertices
* @type {Array}
*/
public vertices: Float32Array;
/**
* Array of integers, indicating which vertices each triangle consists of. The length of this array is thus 3 times the number of triangles.
* @property indices
* @type {Array}
*/
public indices: Int16Array;