-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
Copy pathmatter.d.ts
5264 lines (4629 loc) · 189 KB
/
matter.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
// Type definitions specifically for Matter.js as used by Phaser 3
//
// Definitions by: Ivane Gegia <https://twitter.com/ivanegegia>,
// David Asmuth <https://github.com/piranha771>,
// Piotr Pietrzak <https://github.com/hasparus>,
// Richard Davey <[email protected]>
/// <reference types="./phaser" />
declare namespace MatterJS {
// --------------------------------------------------------------
// Interfaces
// --------------------------------------------------------------
interface IChamfer {
radius?: number | Array<number>;
quality?: number;
qualityMin?: number;
qualityMax?: number;
}
interface IChamferableBodyDefinition extends IBodyDefinition {
chamfer?: IChamfer;
}
interface IBodyDefinition {
/**
* A `Number` specifying the angle of the body, in radians.
*
* @property angle
* @type number
* @default 0
*/
angle?: number;
/**
* A `Number` that _measures_ the current angular speed of the body after the last `Body.update`. It is read-only and always positive (it's the magnitude of `body.angularVelocity`).
*
* @readOnly
* @property angularSpeed
* @type number
* @default 0
*/
angularSpeed?: number;
/**
* A `Number` that _measures_ the current angular velocity of the body after the last `Body.update`. It is read-only.
* If you need to modify a body's angular velocity directly, you should apply a torque or simply change the body's `angle` (as the engine uses position-Verlet integration).
*
* @readOnly
* @property angularVelocity
* @type number
* @default 0
*/
angularVelocity?: number;
/**
* A `Number` that _measures_ the area of the body's convex hull, calculated at creation by `Body.create`.
*
* @property area
* @type string
* @default
*/
area?: number;
/**
* An array of unique axis vectors (edge normals) used for collision detection.
* These are automatically calculated from the given convex hull (`vertices` array) in `Body.create`.
* They are constantly updated by `Body.update` during the simulation.
*
* @property axes
* @type vector[]
*/
axes?: Array<Vector>;
/**
* A `Bounds` object that defines the AABB region for the body.
* It is automatically calculated from the given convex hull (`vertices` array) in `Body.create` and constantly updated by `Body.update` during simulation.
*
* @property bounds
* @type bounds
*/
bounds?: IBound;
/**
* A `Number` that defines the density of the body, that is its mass per unit area.
* If you pass the density via `Body.create` the `mass` property is automatically calculated for you based on the size (area) of the object.
* This is generally preferable to simply setting mass and allows for more intuitive definition of materials (e.g. rock has a higher density than wood).
*
* @property density
* @type number
* @default 0.001
*/
density?: number;
/**
* A `Vector` that specifies the force to apply in the current step. It is zeroed after every `Body.update`. See also `Body.applyForce`.
*
* @property force
* @type vector
* @default { x: 0, y: 0 }
*/
force?: Vector;
/**
* A `Number` that defines the friction of the body. The value is always positive and is in the range `(0, 1)`.
* A value of `0` means that the body may slide indefinitely.
* A value of `1` means the body may come to a stop almost instantly after a force is applied.
*
* The effects of the value may be non-linear.
* High values may be unstable depending on the body.
* The engine uses a Coulomb friction model including static and kinetic friction.
* Note that collision response is based on _pairs_ of bodies, and that `friction` values are _combined_ with the following formula:
*
* Math.min(bodyA.friction, bodyB.friction)
*
* @property friction
* @type number
* @default 0.1
*/
friction?: number;
/**
* A `Number` that defines the air friction of the body (air resistance).
* A value of `0` means the body will never slow as it moves through space.
* The higher the value, the faster a body slows when moving through space.
* The effects of the value are non-linear.
*
* @property frictionAir
* @type number
* @default 0.01
*/
frictionAir?: number;
/**
* A `Number` that defines the moment of inertia (i.e. second moment of area) of the body.
* It is automatically calculated from the given convex hull (`vertices` array) and density in `Body.create`.
* If you modify this value, you must also modify the `body.inverseInertia` property (`1 / inertia`).
*
* @property inertia
* @type number
*/
inertia?: number;
/**
* A `Number` that defines the inverse moment of inertia of the body (`1 / inertia`).
* If you modify this value, you must also modify the `body.inertia` property.
*
* @property inverseInertia
* @type number
*/
inverseInertia?: number;
/**
* A `Number` that defines the inverse mass of the body (`1 / mass`).
* If you modify this value, you must also modify the `body.mass` property.
*
* @property inverseMass
* @type number
*/
inverseMass?: number;
/**
* A flag that indicates whether a body is a sensor. Sensor triggers collision events, but doesn't react with colliding body physically.
*
* @property isSensor
* @type boolean
* @default false
*/
isSensor?: boolean;
/**
* A flag that indicates whether the body is considered sleeping. A sleeping body acts similar to a static body, except it is only temporary and can be awoken.
* If you need to set a body as sleeping, you should use `Sleeping.set` as this requires more than just setting this flag.
*
* @property isSleeping
* @type boolean
* @default false
*/
isSleeping?: boolean;
/**
* A flag that indicates whether a body is considered static. A static body can never change position or angle and is completely fixed.
* If you need to set a body as static after its creation, you should use `Body.setStatic` as this requires more than just setting this flag.
*
* @property isStatic
* @type boolean
* @default false
*/
isStatic?: boolean;
/**
* An arbitrary `String` name to help the user identify and manage bodies.
*
* @property label
* @type string
* @default "Body"
*/
label?: string;
/**
* A `Number` that defines the mass of the body, although it may be more appropriate to specify the `density` property instead.
* If you modify this value, you must also modify the `body.inverseMass` property (`1 / mass`).
*
* @property mass
* @type number
*/
mass?: number;
/**
* A `Number` that _measures_ the amount of movement a body currently has (a combination of `speed` and `angularSpeed`). It is read-only and always positive.
* It is used and updated by the `Matter.Sleeping` module during simulation to decide if a body has come to rest.
*
* @readOnly
* @property motion
* @type number
* @default 0
*/
motion?: number;
/**
* A `Vector` that specifies the current world-space position of the body.
*
* @property position
* @type vector
*/
position?: Vector;
/**
* An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`.
*
* @property render
* @type object
*/
render?: IBodyRenderOptions;
/**
* A `Number` that defines the restitution (elasticity) of the body. The value is always positive and is in the range `(0, 1)`.
* A value of `0` means collisions may be perfectly inelastic and no bouncing may occur.
* A value of `0.8` means the body may bounce back with approximately 80% of its kinetic energy.
* Note that collision response is based on _pairs_ of bodies, and that `restitution` values are _combined_ with the following formula:
*
* Math.max(bodyA.restitution, bodyB.restitution)
*
* @property restitution
* @type number
* @default 0
*/
restitution?: number;
/**
* A `Number` that defines the number of updates in which this body must have near-zero velocity before it is set as sleeping by the `Matter.Sleeping` module (if sleeping is enabled by the engine).
*
* @property sleepThreshold
* @type number
* @default 60
*/
sleepThreshold?: number;
/**
* A `Number` that specifies a tolerance on how far a body is allowed to 'sink' or rotate into other bodies.
* Avoid changing this value unless you understand the purpose of `slop` in physics engines.
* The default should generally suffice, although very large bodies may require larger values for stable stacking.
*
* @property slop
* @type number
* @default 0.05
*/
slop?: number;
/**
* A `Number` that _measures_ the current speed of the body after the last `Body.update`. It is read-only and always positive (it's the magnitude of `body.velocity`).
*
* @readOnly
* @property speed
* @type number
* @default 0
*/
speed?: number;
/**
* A `Number` that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed.
*
* @property timeScale
* @type number
* @default 1
*/
timeScale?: number;
/**
* A `Number` that specifies the torque (turning force) to apply in the current step. It is zeroed after every `Body.update`.
*
* @property torque
* @type number
* @default 0
*/
torque?: number;
/**
* A `String` denoting the type of object.
*
* @property type
* @type string
* @default "body"
*/
type?: string;
/**
* A `Vector` that _measures_ the current velocity of the body after the last `Body.update`. It is read-only.
* If you need to modify a body's velocity directly, you should either apply a force or simply change the body's `position` (as the engine uses position-Verlet integration).
*
* @readOnly
* @property velocity
* @type vector
* @default { x: 0, y: 0 }
*/
velocity?: Vector;
/**
* An array of `Vector` objects that specify the convex hull of the rigid body.
* These should be provided about the origin `(0, 0)`. E.g.
*
* [{ x: 0, y: 0 }, { x: 25, y: 50 }, { x: 50, y: 0 }]
*
* When passed via `Body.create`, the vertices are translated relative to `body.position` (i.e. world-space, and constantly updated by `Body.update` during simulation).
* The `Vector` objects are also augmented with additional properties required for efficient collision detection.
*
* Other properties such as `inertia` and `bounds` are automatically calculated from the passed vertices (unless provided via `options`).
* Concave hulls are not currently supported. The module `Matter.Vertices` contains useful methods for working with vertices.
*
* @property vertices
* @type vector[]
*/
vertices?: Array<Vector>;
/**
* An array of bodies that make up this body.
* The first body in the array must always be a self reference to the current body instance.
* All bodies in the `parts` array together form a single rigid compound body.
* Parts are allowed to overlap, have gaps or holes or even form concave bodies.
* Parts themselves should never be added to a `World`, only the parent body should be.
* Use `Body.setParts` when setting parts to ensure correct updates of all properties.
*
* @property parts
* @type body[]
*/
parts?: Array<BodyType>;
/**
* A self reference if the body is _not_ a part of another body.
* Otherwise this is a reference to the body that this is a part of.
* See `body.parts`.
*
* @property parent
* @type body
*/
parent?: BodyType;
/**
* A `Number` that defines the static friction of the body (in the Coulomb friction model).
* A value of `0` means the body will never 'stick' when it is nearly stationary and only dynamic `friction` is used.
* The higher the value (e.g. `10`), the more force it will take to initially get the body moving when nearly stationary.
* This value is multiplied with the `friction` property to make it easier to change `friction` and maintain an appropriate amount of static friction.
*
* @property frictionStatic
* @type number
* @default 0.5
*/
frictionStatic?: number;
/**
* An `Object` that specifies the collision filtering properties of this body.
*
* Collisions between two bodies will obey the following rules:
* - If the two bodies have the same non-zero value of `collisionFilter.group`,
* they will always collide if the value is positive, and they will never collide
* if the value is negative.
* - If the two bodies have different values of `collisionFilter.group` or if one
* (or both) of the bodies has a value of 0, then the category/mask rules apply as follows:
*
* Each body belongs to a collision category, given by `collisionFilter.category`. This
* value is used as a bit field and the category should have only one bit set, meaning that
* the value of this property is a power of two in the range [1, 2^31]. Thus, there are 32
* different collision categories available.
*
* Each body also defines a collision bitmask, given by `collisionFilter.mask` which specifies
* the categories it collides with (the value is the bitwise AND value of all these categories).
*
* Using the category/mask rules, two bodies `A` and `B` collide if each includes the other's
* category in its mask, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0`
* are both true.
*
* @property collisionFilter
* @type object
*/
collisionFilter?: ICollisionFilter;
/**
* A reference to the Phaser Game Object this body belongs to, if any.
*
* @property gameObject
* @type Phaser.GameObjects.GameObject
*/
gameObject?: Phaser.GameObjects.GameObject;
/**
* Scale the influence of World gravity when applied to this body.
*
* @property gravityScale
* @type vector
* @default { x: 1, y: 1 }
*/
gravityScale?: Vector;
/**
* Will this Body ignore World gravity during the Engine update?
*
* @property ignoreGravity
* @type boolean
* @default false
*/
ignoreGravity?: boolean;
/**
* Will this Body ignore Phaser Pointer input events?
*
* @property ignorePointer
* @type boolean
* @default false
*/
ignorePointer?: boolean;
/**
* A callback that is invoked when this Body starts colliding with any other Body.
*
* You can register callbacks by providing a function of type `( pair: Matter.Pair) => void`.
*
* @property onCollideCallback
* @type function
* @default null
*/
onCollideCallback?: Function;
/**
* A callback that is invoked when this Body stops colliding with any other Body.
*
* You can register callbacks by providing a function of type `( pair: Matter.Pair) => void`.
*
* @property onCollideEndCallback
* @type function
* @default null
*/
onCollideEndCallback?: Function;
/**
* A callback that is invoked for the duration that this Body is colliding with any other Body.
*
* You can register callbacks by providing a function of type `( pair: Matter.Pair) => void`.
*
* @property onCollideActiveCallback
* @type function
* @default null
*/
onCollideActiveCallback?: Function;
/**
* A collision callback dictionary _(body id -> function)_ used by the `Body.setOnCollideWith` function.
*
* @property onCollideWith
* @type {Object.<number, Function>}
* @default {}
*/
onCollideWith?: Record<number, Function>;
}
interface IBodyRenderOptions {
/**
* A flag that indicates if the body should be rendered.
*
* @property visible
* @type boolean
* @default true
*/
visible?: boolean;
/**
* Sets the opacity. 1.0 is fully opaque. 0.0 is fully translucent.
*
* @property opacity
* @type number
* @default 1
*/
opacity?: number;
/**
* An `Object` that defines the sprite properties to use when rendering, if any.
*
* @property sprite
* @type object
*/
sprite?: IBodyRenderOptionsSprite;
/**
* A hex color value that defines the fill color to use when rendering the body.
*
* @property fillColor
* @type number
*/
fillColor?: number;
/**
* A value that defines the fill opacity to use when rendering the body.
*
* @property fillOpacity
* @type number
*/
fillOpacity?: number;
/**
* A hex color value that defines the line color to use when rendering the body.
*
* @property lineColor
* @type number
*/
lineColor?: number;
/**
* A value that defines the line opacity to use when rendering the body.
*
* @property lineOpacity
* @type number
*/
lineOpacity?: number;
/**
* A `Number` that defines the line width to use when rendering the body outline.
*
* @property lineThickness
* @type number
*/
lineThickness?: number;
}
interface IBodyRenderOptionsSprite {
/**
* A `Number` that defines the scaling in the x-axis for the sprite, if any.
*
* @property xOffset
* @type number
* @default 0
*/
xOffset: number;
/**
* A `Number` that defines the scaling in the y-axis for the sprite, if any.
*
* @property yOffset
* @type number
* @default 0
*/
yOffset: number;
}
interface IBound {
min: { x: number, y: number }
max: { x: number, y: number }
}
interface ICompositeDefinition {
/**
* An array of `Body` that are _direct_ children of this composite.
* To add or remove bodies you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property.
* If you wish to recursively find all descendants, you should use the `Composite.allBodies` method.
*
* @property bodies
* @type body[]
* @default []
*/
bodies?: Array<BodyType>;
/**
* An array of `Composite` that are _direct_ children of this composite.
* To add or remove composites you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property.
* If you wish to recursively find all descendants, you should use the `Composite.allComposites` method.
*
* @property composites
* @type composite[]
* @default []
*/
composites?: Array<CompositeType>;
/**
* An array of `Constraint` that are _direct_ children of this composite.
* To add or remove constraints you should use `Composite.add` and `Composite.remove` methods rather than directly modifying this property.
* If you wish to recursively find all descendants, you should use the `Composite.allConstraints` method.
*
* @property constraints
* @type constraint[]
* @default []
*/
constraints?: Array<ConstraintType>;
/**
* An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`.
*
* @property id
* @type number
*/
id?: number;
/**
* A flag that specifies whether the composite has been modified during the current step.
* Most `Matter.Composite` methods will automatically set this flag to `true` to inform the engine of changes to be handled.
* If you need to change it manually, you should use the `Composite.setModified` method.
*
* @property isModified
* @type boolean
* @default false
*/
isModified?: boolean;
/**
* An arbitrary `String` name to help the user identify and manage composites.
*
* @property label
* @type string
* @default "Composite"
*/
label?: string;
/**
* The `Composite` that is the parent of this composite. It is automatically managed by the `Matter.Composite` methods.
*
* @property parent
* @type composite
* @default null
*/
parent?: CompositeType;
/**
* A `String` denoting the type of object.
*
* @property type
* @type string
* @default "composite"
*/
type?: string;
}
interface IConstraintDefinition {
/**
* The first possible `Body` that this constraint is attached to.
*
* @property bodyA
* @type body
* @default null
*/
bodyA?: IBodyDefinition;
/**
* The second possible `Body` that this constraint is attached to.
*
* @property bodyB
* @type body
* @default null
*/
bodyB?: IBodyDefinition;
/**
* An integer `Number` uniquely identifying number generated in `Composite.create` by `Common.nextId`.
*
* @property id
* @type number
*/
id?: number;
/**
* An arbitrary `String` name to help the user identify and manage bodies.
*
* @property label
* @type string
* @default "Constraint"
*/
label?: string;
/**
* A `Number` that specifies the target resting length of the constraint.
* It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB`.
*
* @property length
* @type number
*/
length?: number;
/**
* A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position.
*
* @property pointA
* @type vector
* @default { x: 0, y: 0 }
*/
pointA?: Vector;
/**
* A `Vector` that specifies the offset of the constraint from center of the `constraint.bodyA` if defined, otherwise a world-space position.
*
* @property pointB
* @type vector
* @default { x: 0, y: 0 }
*/
pointB?: Vector;
/**
* An `Object` that defines the rendering properties to be consumed by the module `Matter.Render`.
*
* @property render
* @type object
*/
render?: IConstraintRenderDefinition;
/**
* A `Number` that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`.
* A value of `1` means the constraint should be very stiff.
* A value of `0.2` means the constraint acts like a soft spring.
*
* @property stiffness
* @type number
* @default 1
*/
stiffness?: number;
/**
* A `Number` that specifies the damping of the constraint,
* i.e. the amount of resistance applied to each body based on their velocities to limit the amount of oscillation.
* Damping will only be apparent when the constraint also has a very low `stiffness`.
* A value of `0.1` means the constraint will apply heavy damping, resulting in little to no oscillation.
* A value of `0` means the constraint will apply no damping.
*
* @property damping
* @type number
* @default 0
*/
damping?: number;
/**
* A `String` denoting the type of object.
*
* @property type
* @type string
* @default "constraint"
*/
type?: string;
}
interface IConstraintRenderDefinition {
/**
* A flag that indicates if the constraint should be rendered.
*
* @property visible
* @type boolean
* @default true
*/
visible?: boolean;
/**
* The type of constraint.
*
* @property type
* @type string
* @default 'line'
*/
type?: string;
/**
* A flag that indicates if the constraint anchors should be rendered.
*
* @property anchors
* @type boolean
* @default true
*/
anchors?: boolean;
/**
* A hex color value that defines the line color to use when rendering the body.
*
* @property lineColor
* @type number
*/
lineColor?: number;
/**
* A value that defines the line opacity to use when rendering the body.
*
* @property lineOpacity
* @type number
*/
lineOpacity?: number;
/**
* A `Number` that defines the line width to use when rendering the body outline.
*
* @property lineThickness
* @type number
*/
lineThickness?: number;
/**
* The size of the pins during rendering.
*
* @property pinSize
* @type number
*/
pinSize?: number;
/**
* A hex color value that defines the color to use when rendering the anchors.
*
* @property anchorColor
* @type number
*/
anchorColor?: number;
/**
* The size of the anchors during rendering.
*
* @property anchorSize
* @type number
*/
anchorSize?: number;
}
interface IEngineDefinition {
/**
* An integer `Number` that specifies the number of position iterations to perform each update.
* The higher the value, the higher quality the simulation will be at the expense of performance.
*
* @property positionIterations
* @type number
* @default 6
*/
positionIterations?: number;
/**
* An integer `Number` that specifies the number of velocity iterations to perform each update.
* The higher the value, the higher quality the simulation will be at the expense of performance.
*
* @property velocityIterations
* @type number
* @default 4
*/
velocityIterations?: number;
/**
* An integer `Number` that specifies the number of constraint iterations to perform each update.
* The higher the value, the higher quality the simulation will be at the expense of performance.
* The default value of `2` is usually very adequate.
*
* @property constraintIterations
* @type number
* @default 2
*/
constraintIterations?: number;
/**
* A flag that specifies whether the engine should allow sleeping via the `Matter.Sleeping` module.
* Sleeping can improve stability and performance, but often at the expense of accuracy.
*
* @property enableSleeping
* @type boolean
* @default false
*/
enableSleeping?: boolean;
/**
* An `Object` containing properties regarding the timing systems of the engine.
*
* @property timing
* @type object
*/
timing?: IEngineTimingOptions;
/**
* An instance of a broadphase controller. The default value is a `Matter.Grid` instance created by `Engine.create`.
*
* @property broadphase
* @type grid
* @default a Matter.Grid instance
*/
grid?: Grid;
/**
* A `World` composite object that will contain all simulated bodies and constraints.
*
* @property world
* @type world
* @default a Matter.World instance
*/
world?: World;
}
interface IEngineTimingOptions {
/**
* A `Number` that specifies the global scaling factor of time for all bodies.
* A value of `0` freezes the simulation.
* A value of `0.1` gives a slow-motion effect.
* A value of `1.2` gives a speed-up effect.
*
* @property timing.timeScale
* @type number
* @default 1
*/
timeScale: number;
/**
* A `Number` that specifies the current simulation-time in milliseconds starting from `0`.
* It is incremented on every `Engine.update` by the given `delta` argument.
*
* @property timing.timestamp
* @type number
* @default 0
*/
timestamp: number;
}
interface IMouseConstraintDefinition {
/**
* The `Constraint` object that is used to move the body during interaction.
*
* @property constraint
* @type constraint
*/
constraint?: ConstraintType;
/**
* An `Object` that specifies the collision filter properties.
* The collision filter allows the user to define which types of body this mouse constraint can interact with.
* See `body.collisionFilter` for more information.
*
* @property collisionFilter
* @type object
*/
collisionFilter?: ICollisionFilter;
/**
* The `Body` that is currently being moved by the user, or `null` if no body.
*
* @property body
* @type body
* @default null
*/
body?: BodyType;
/**
* A `String` denoting the type of object.
*
* @property type
* @type string
* @default "constraint"
*/
type?: string;
}
interface IGridDefinition {}
interface IPair {
id: number;
bodyA: Body;
bodyB: Body;
contacts: any;
contactCount: number;
separation: number;
isActive: boolean;
timeCreated: number;
timeUpdated: number,
inverseMass: number;
friction: number;