@gg-web-engine/rapier3d 0.0.24
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/README.md +17 -0
- package/dist/components/rapier-3d-rigid-body.component.d.ts +26 -0
- package/dist/components/rapier-3d-rigid-body.component.js +88 -0
- package/dist/components/rapier-3d-trigger.component.d.ts +17 -0
- package/dist/components/rapier-3d-trigger.component.js +41 -0
- package/dist/components/rapier-3d-world.component.d.ts +27 -0
- package/dist/components/rapier-3d-world.component.js +81 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6 -0
- package/dist/rapier-3d-factory.d.ts +22 -0
- package/dist/rapier-3d-factory.js +89 -0
- package/dist/rapier-3d-loader.d.ts +6 -0
- package/dist/rapier-3d-loader.js +7 -0
- package/etc/@dimforge/rapier3d/LICENSE +201 -0
- package/etc/@dimforge/rapier3d/README.md +33 -0
- package/etc/@dimforge/rapier3d/coarena.d.ts +15 -0
- package/etc/@dimforge/rapier3d/coarena.js +61 -0
- package/etc/@dimforge/rapier3d/coarena.js.map +1 -0
- package/etc/@dimforge/rapier3d/control/character_controller.d.ts +188 -0
- package/etc/@dimforge/rapier3d/control/character_controller.js +256 -0
- package/etc/@dimforge/rapier3d/control/character_controller.js.map +1 -0
- package/etc/@dimforge/rapier3d/control/index.d.ts +2 -0
- package/etc/@dimforge/rapier3d/control/index.js +5 -0
- package/etc/@dimforge/rapier3d/control/index.js.map +1 -0
- package/etc/@dimforge/rapier3d/control/ray_cast_vehicle_controller.d.ts +240 -0
- package/etc/@dimforge/rapier3d/control/ray_cast_vehicle_controller.js +362 -0
- package/etc/@dimforge/rapier3d/control/ray_cast_vehicle_controller.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/ccd_solver.d.ts +15 -0
- package/etc/@dimforge/rapier3d/dynamics/ccd_solver.js +22 -0
- package/etc/@dimforge/rapier3d/dynamics/ccd_solver.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/coefficient_combine_rule.d.ts +13 -0
- package/etc/@dimforge/rapier3d/dynamics/coefficient_combine_rule.js +15 -0
- package/etc/@dimforge/rapier3d/dynamics/coefficient_combine_rule.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/impulse_joint.d.ts +204 -0
- package/etc/@dimforge/rapier3d/dynamics/impulse_joint.js +335 -0
- package/etc/@dimforge/rapier3d/dynamics/impulse_joint.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/impulse_joint_set.d.ts +79 -0
- package/etc/@dimforge/rapier3d/dynamics/impulse_joint_set.js +123 -0
- package/etc/@dimforge/rapier3d/dynamics/impulse_joint_set.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/index.d.ts +10 -0
- package/etc/@dimforge/rapier3d/dynamics/index.js +11 -0
- package/etc/@dimforge/rapier3d/dynamics/index.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/integration_parameters.d.ts +55 -0
- package/etc/@dimforge/rapier3d/dynamics/integration_parameters.js +98 -0
- package/etc/@dimforge/rapier3d/dynamics/integration_parameters.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/island_manager.d.ts +24 -0
- package/etc/@dimforge/rapier3d/dynamics/island_manager.js +32 -0
- package/etc/@dimforge/rapier3d/dynamics/island_manager.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/multibody_joint.d.ts +42 -0
- package/etc/@dimforge/rapier3d/dynamics/multibody_joint.js +124 -0
- package/etc/@dimforge/rapier3d/dynamics/multibody_joint.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/multibody_joint_set.d.ts +76 -0
- package/etc/@dimforge/rapier3d/dynamics/multibody_joint_set.js +118 -0
- package/etc/@dimforge/rapier3d/dynamics/multibody_joint_set.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/rigid_body.d.ts +679 -0
- package/etc/@dimforge/rapier3d/dynamics/rigid_body.js +960 -0
- package/etc/@dimforge/rapier3d/dynamics/rigid_body.js.map +1 -0
- package/etc/@dimforge/rapier3d/dynamics/rigid_body_set.d.ts +78 -0
- package/etc/@dimforge/rapier3d/dynamics/rigid_body_set.js +147 -0
- package/etc/@dimforge/rapier3d/dynamics/rigid_body_set.js.map +1 -0
- package/etc/@dimforge/rapier3d/exports.d.ts +7 -0
- package/etc/@dimforge/rapier3d/exports.js +11 -0
- package/etc/@dimforge/rapier3d/exports.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/broad_phase.d.ts +15 -0
- package/etc/@dimforge/rapier3d/geometry/broad_phase.js +22 -0
- package/etc/@dimforge/rapier3d/geometry/broad_phase.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/collider.d.ts +763 -0
- package/etc/@dimforge/rapier3d/geometry/collider.js +1140 -0
- package/etc/@dimforge/rapier3d/geometry/collider.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/collider_set.d.ts +72 -0
- package/etc/@dimforge/rapier3d/geometry/collider_set.js +144 -0
- package/etc/@dimforge/rapier3d/geometry/collider_set.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/contact.d.ts +31 -0
- package/etc/@dimforge/rapier3d/geometry/contact.js +21 -0
- package/etc/@dimforge/rapier3d/geometry/contact.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/feature.d.ts +6 -0
- package/etc/@dimforge/rapier3d/geometry/feature.js +10 -0
- package/etc/@dimforge/rapier3d/geometry/feature.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/index.d.ts +11 -0
- package/etc/@dimforge/rapier3d/geometry/index.js +12 -0
- package/etc/@dimforge/rapier3d/geometry/index.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/interaction_groups.d.ts +18 -0
- package/etc/@dimforge/rapier3d/geometry/interaction_groups.js +2 -0
- package/etc/@dimforge/rapier3d/geometry/interaction_groups.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/narrow_phase.d.ts +71 -0
- package/etc/@dimforge/rapier3d/geometry/narrow_phase.js +148 -0
- package/etc/@dimforge/rapier3d/geometry/narrow_phase.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/point.d.ts +47 -0
- package/etc/@dimforge/rapier3d/geometry/point.js +48 -0
- package/etc/@dimforge/rapier3d/geometry/point.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/ray.d.ts +97 -0
- package/etc/@dimforge/rapier3d/geometry/ray.js +100 -0
- package/etc/@dimforge/rapier3d/geometry/ray.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/shape.d.ts +489 -0
- package/etc/@dimforge/rapier3d/geometry/shape.js +686 -0
- package/etc/@dimforge/rapier3d/geometry/shape.js.map +1 -0
- package/etc/@dimforge/rapier3d/geometry/toi.d.ts +46 -0
- package/etc/@dimforge/rapier3d/geometry/toi.js +37 -0
- package/etc/@dimforge/rapier3d/geometry/toi.js.map +1 -0
- package/etc/@dimforge/rapier3d/init.d.ts +1 -0
- package/etc/@dimforge/rapier3d/init.js +2 -0
- package/etc/@dimforge/rapier3d/init.js.map +1 -0
- package/etc/@dimforge/rapier3d/math.d.ts +94 -0
- package/etc/@dimforge/rapier3d/math.js +138 -0
- package/etc/@dimforge/rapier3d/math.js.map +1 -0
- package/etc/@dimforge/rapier3d/package.json +33 -0
- package/etc/@dimforge/rapier3d/pipeline/debug_render_pipeline.d.ts +39 -0
- package/etc/@dimforge/rapier3d/pipeline/debug_render_pipeline.js +38 -0
- package/etc/@dimforge/rapier3d/pipeline/debug_render_pipeline.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/event_queue.d.ts +101 -0
- package/etc/@dimforge/rapier3d/pipeline/event_queue.js +135 -0
- package/etc/@dimforge/rapier3d/pipeline/event_queue.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/index.d.ts +7 -0
- package/etc/@dimforge/rapier3d/pipeline/index.js +8 -0
- package/etc/@dimforge/rapier3d/pipeline/index.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/physics_hooks.d.ts +39 -0
- package/etc/@dimforge/rapier3d/pipeline/physics_hooks.js +13 -0
- package/etc/@dimforge/rapier3d/pipeline/physics_hooks.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/physics_pipeline.d.ts +12 -0
- package/etc/@dimforge/rapier3d/pipeline/physics_pipeline.js +24 -0
- package/etc/@dimforge/rapier3d/pipeline/physics_pipeline.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/query_pipeline.d.ts +190 -0
- package/etc/@dimforge/rapier3d/pipeline/query_pipeline.js +271 -0
- package/etc/@dimforge/rapier3d/pipeline/query_pipeline.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/serialization_pipeline.d.ts +37 -0
- package/etc/@dimforge/rapier3d/pipeline/serialization_pipeline.js +49 -0
- package/etc/@dimforge/rapier3d/pipeline/serialization_pipeline.js.map +1 -0
- package/etc/@dimforge/rapier3d/pipeline/world.d.ts +419 -0
- package/etc/@dimforge/rapier3d/pipeline/world.js +581 -0
- package/etc/@dimforge/rapier3d/pipeline/world.js.map +1 -0
- package/etc/@dimforge/rapier3d/rapier.d.ts +3 -0
- package/etc/@dimforge/rapier3d/rapier.js +4 -0
- package/etc/@dimforge/rapier3d/rapier.js.map +1 -0
- package/etc/@dimforge/rapier3d/rapier_wasm3d.d.ts +2921 -0
- package/etc/@dimforge/rapier3d/rapier_wasm3d.js +2 -0
- package/etc/@dimforge/rapier3d/rapier_wasm3d_bg.js +5585 -0
- package/etc/@dimforge/rapier3d/rapier_wasm3d_bg.wasm +0 -0
- package/etc/@dimforge/rapier3d/rapier_wasm3d_bg.wasm.d.ts +486 -0
- package/etc/@dimforge/rapier3d/raw.d.ts +1 -0
- package/etc/@dimforge/rapier3d/raw.js +2 -0
- package/etc/@dimforge/rapier3d/raw.js.map +1 -0
- package/package.json +43 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,1140 @@
|
|
|
1
|
+
import { RotationOps, VectorOps } from "../math";
|
|
2
|
+
import { CoefficientCombineRule, } from "../dynamics";
|
|
3
|
+
import { ActiveHooks, ActiveEvents } from "../pipeline";
|
|
4
|
+
import { Shape, Cuboid, Ball, Capsule, TriMesh, Polyline, Heightfield, Segment, Triangle, RoundTriangle, RoundCuboid,
|
|
5
|
+
// #if DIM3
|
|
6
|
+
Cylinder, RoundCylinder, Cone, RoundCone, ConvexPolyhedron, RoundConvexPolyhedron,
|
|
7
|
+
// #endif
|
|
8
|
+
} from "./shape";
|
|
9
|
+
import { RayIntersection } from "./ray";
|
|
10
|
+
import { PointProjection } from "./point";
|
|
11
|
+
import { ShapeColliderTOI, ShapeTOI } from "./toi";
|
|
12
|
+
import { ShapeContact } from "./contact";
|
|
13
|
+
/**
|
|
14
|
+
* Flags affecting whether collision-detection happens between two colliders
|
|
15
|
+
* depending on the type of rigid-bodies they are attached to.
|
|
16
|
+
*/
|
|
17
|
+
export var ActiveCollisionTypes;
|
|
18
|
+
(function (ActiveCollisionTypes) {
|
|
19
|
+
/**
|
|
20
|
+
* Enable collision-detection between a collider attached to a dynamic body
|
|
21
|
+
* and another collider attached to a dynamic body.
|
|
22
|
+
*/
|
|
23
|
+
ActiveCollisionTypes[ActiveCollisionTypes["DYNAMIC_DYNAMIC"] = 1] = "DYNAMIC_DYNAMIC";
|
|
24
|
+
/**
|
|
25
|
+
* Enable collision-detection between a collider attached to a dynamic body
|
|
26
|
+
* and another collider attached to a kinematic body.
|
|
27
|
+
*/
|
|
28
|
+
ActiveCollisionTypes[ActiveCollisionTypes["DYNAMIC_KINEMATIC"] = 12] = "DYNAMIC_KINEMATIC";
|
|
29
|
+
/**
|
|
30
|
+
* Enable collision-detection between a collider attached to a dynamic body
|
|
31
|
+
* and another collider attached to a fixed body (or not attached to any body).
|
|
32
|
+
*/
|
|
33
|
+
ActiveCollisionTypes[ActiveCollisionTypes["DYNAMIC_FIXED"] = 2] = "DYNAMIC_FIXED";
|
|
34
|
+
/**
|
|
35
|
+
* Enable collision-detection between a collider attached to a kinematic body
|
|
36
|
+
* and another collider attached to a kinematic body.
|
|
37
|
+
*/
|
|
38
|
+
ActiveCollisionTypes[ActiveCollisionTypes["KINEMATIC_KINEMATIC"] = 52224] = "KINEMATIC_KINEMATIC";
|
|
39
|
+
/**
|
|
40
|
+
* Enable collision-detection between a collider attached to a kinematic body
|
|
41
|
+
* and another collider attached to a fixed body (or not attached to any body).
|
|
42
|
+
*/
|
|
43
|
+
ActiveCollisionTypes[ActiveCollisionTypes["KINEMATIC_FIXED"] = 8704] = "KINEMATIC_FIXED";
|
|
44
|
+
/**
|
|
45
|
+
* Enable collision-detection between a collider attached to a fixed body (or
|
|
46
|
+
* not attached to any body) and another collider attached to a fixed body (or
|
|
47
|
+
* not attached to any body).
|
|
48
|
+
*/
|
|
49
|
+
ActiveCollisionTypes[ActiveCollisionTypes["FIXED_FIXED"] = 32] = "FIXED_FIXED";
|
|
50
|
+
/**
|
|
51
|
+
* The default active collision types, enabling collisions between a dynamic body
|
|
52
|
+
* and another body of any type, but not enabling collisions between two non-dynamic bodies.
|
|
53
|
+
*/
|
|
54
|
+
ActiveCollisionTypes[ActiveCollisionTypes["DEFAULT"] = 15] = "DEFAULT";
|
|
55
|
+
/**
|
|
56
|
+
* Enable collisions between any kind of rigid-bodies (including between two non-dynamic bodies).
|
|
57
|
+
*/
|
|
58
|
+
ActiveCollisionTypes[ActiveCollisionTypes["ALL"] = 60943] = "ALL";
|
|
59
|
+
})(ActiveCollisionTypes || (ActiveCollisionTypes = {}));
|
|
60
|
+
/**
|
|
61
|
+
* A geometric entity that can be attached to a body so it can be affected
|
|
62
|
+
* by contacts and proximity queries.
|
|
63
|
+
*/
|
|
64
|
+
export class Collider {
|
|
65
|
+
constructor(colliderSet, handle, parent, shape) {
|
|
66
|
+
this.colliderSet = colliderSet;
|
|
67
|
+
this.handle = handle;
|
|
68
|
+
this._parent = parent;
|
|
69
|
+
this._shape = shape;
|
|
70
|
+
}
|
|
71
|
+
/** @internal */
|
|
72
|
+
finalizeDeserialization(bodies) {
|
|
73
|
+
if (this.handle != null) {
|
|
74
|
+
this._parent = bodies.get(this.colliderSet.raw.coParent(this.handle));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
ensureShapeIsCached() {
|
|
78
|
+
if (!this._shape)
|
|
79
|
+
this._shape = Shape.fromRaw(this.colliderSet.raw, this.handle);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The shape of this collider.
|
|
83
|
+
*/
|
|
84
|
+
get shape() {
|
|
85
|
+
this.ensureShapeIsCached();
|
|
86
|
+
return this._shape;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Checks if this collider is still valid (i.e. that it has
|
|
90
|
+
* not been deleted from the collider set yet).
|
|
91
|
+
*/
|
|
92
|
+
isValid() {
|
|
93
|
+
return this.colliderSet.raw.contains(this.handle);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The world-space translation of this rigid-body.
|
|
97
|
+
*/
|
|
98
|
+
translation() {
|
|
99
|
+
return VectorOps.fromRaw(this.colliderSet.raw.coTranslation(this.handle));
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The world-space orientation of this rigid-body.
|
|
103
|
+
*/
|
|
104
|
+
rotation() {
|
|
105
|
+
return RotationOps.fromRaw(this.colliderSet.raw.coRotation(this.handle));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Is this collider a sensor?
|
|
109
|
+
*/
|
|
110
|
+
isSensor() {
|
|
111
|
+
return this.colliderSet.raw.coIsSensor(this.handle);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Sets whether or not this collider is a sensor.
|
|
115
|
+
* @param isSensor - If `true`, the collider will be a sensor.
|
|
116
|
+
*/
|
|
117
|
+
setSensor(isSensor) {
|
|
118
|
+
this.colliderSet.raw.coSetSensor(this.handle, isSensor);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Sets the new shape of the collider.
|
|
122
|
+
* @param shape - The collider’s new shape.
|
|
123
|
+
*/
|
|
124
|
+
setShape(shape) {
|
|
125
|
+
let rawShape = shape.intoRaw();
|
|
126
|
+
this.colliderSet.raw.coSetShape(this.handle, rawShape);
|
|
127
|
+
rawShape.free();
|
|
128
|
+
this._shape = shape;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Sets whether this collider is enabled or not.
|
|
132
|
+
*
|
|
133
|
+
* @param enabled - Set to `false` to disable this collider (its parent rigid-body won’t be disabled automatically by this).
|
|
134
|
+
*/
|
|
135
|
+
setEnabled(enabled) {
|
|
136
|
+
this.colliderSet.raw.coSetEnabled(this.handle, enabled);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Is this collider enabled?
|
|
140
|
+
*/
|
|
141
|
+
isEnabled() {
|
|
142
|
+
return this.colliderSet.raw.coIsEnabled(this.handle);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Sets the restitution coefficient of the collider to be created.
|
|
146
|
+
*
|
|
147
|
+
* @param restitution - The restitution coefficient in `[0, 1]`. A value of 0 (the default) means no bouncing behavior
|
|
148
|
+
* while 1 means perfect bouncing (though energy may still be lost due to numerical errors of the
|
|
149
|
+
* constraints solver).
|
|
150
|
+
*/
|
|
151
|
+
setRestitution(restitution) {
|
|
152
|
+
this.colliderSet.raw.coSetRestitution(this.handle, restitution);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Sets the friction coefficient of the collider to be created.
|
|
156
|
+
*
|
|
157
|
+
* @param friction - The friction coefficient. Must be greater or equal to 0. This is generally smaller than 1. The
|
|
158
|
+
* higher the coefficient, the stronger friction forces will be for contacts with the collider
|
|
159
|
+
* being built.
|
|
160
|
+
*/
|
|
161
|
+
setFriction(friction) {
|
|
162
|
+
this.colliderSet.raw.coSetFriction(this.handle, friction);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Gets the rule used to combine the friction coefficients of two colliders
|
|
166
|
+
* colliders involved in a contact.
|
|
167
|
+
*/
|
|
168
|
+
frictionCombineRule() {
|
|
169
|
+
return this.colliderSet.raw.coFrictionCombineRule(this.handle);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Sets the rule used to combine the friction coefficients of two colliders
|
|
173
|
+
* colliders involved in a contact.
|
|
174
|
+
*
|
|
175
|
+
* @param rule − The combine rule to apply.
|
|
176
|
+
*/
|
|
177
|
+
setFrictionCombineRule(rule) {
|
|
178
|
+
this.colliderSet.raw.coSetFrictionCombineRule(this.handle, rule);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Gets the rule used to combine the restitution coefficients of two colliders
|
|
182
|
+
* colliders involved in a contact.
|
|
183
|
+
*/
|
|
184
|
+
restitutionCombineRule() {
|
|
185
|
+
return this.colliderSet.raw.coRestitutionCombineRule(this.handle);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Sets the rule used to combine the restitution coefficients of two colliders
|
|
189
|
+
* colliders involved in a contact.
|
|
190
|
+
*
|
|
191
|
+
* @param rule − The combine rule to apply.
|
|
192
|
+
*/
|
|
193
|
+
setRestitutionCombineRule(rule) {
|
|
194
|
+
this.colliderSet.raw.coSetRestitutionCombineRule(this.handle, rule);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Sets the collision groups used by this collideA
|
|
198
|
+
*
|
|
199
|
+
* Two colliders will interact iff. their collision groups are compatible.
|
|
200
|
+
* See the documentation of `InteractionGroups` for details on teh used bit pattern.
|
|
201
|
+
*
|
|
202
|
+
* @param groups - The collision groups used for the collider being built.
|
|
203
|
+
*/
|
|
204
|
+
setCollisionGroups(groups) {
|
|
205
|
+
this.colliderSet.raw.coSetCollisionGroups(this.handle, groups);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Sets the solver groups used by this collider.
|
|
209
|
+
*
|
|
210
|
+
* Forces between two colliders in contact will be computed iff their solver
|
|
211
|
+
* groups are compatible.
|
|
212
|
+
* See the documentation of `InteractionGroups` for details on the used bit pattern.
|
|
213
|
+
*
|
|
214
|
+
* @param groups - The solver groups used for the collider being built.
|
|
215
|
+
*/
|
|
216
|
+
setSolverGroups(groups) {
|
|
217
|
+
this.colliderSet.raw.coSetSolverGroups(this.handle, groups);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get the physics hooks active for this collider.
|
|
221
|
+
*/
|
|
222
|
+
activeHooks() {
|
|
223
|
+
return this.colliderSet.raw.coActiveHooks(this.handle);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Set the physics hooks active for this collider.
|
|
227
|
+
*
|
|
228
|
+
* Use this to enable custom filtering rules for contact/intersecstion pairs involving this collider.
|
|
229
|
+
*
|
|
230
|
+
* @param activeHooks - The hooks active for contact/intersection pairs involving this collider.
|
|
231
|
+
*/
|
|
232
|
+
setActiveHooks(activeHooks) {
|
|
233
|
+
this.colliderSet.raw.coSetActiveHooks(this.handle, activeHooks);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The events active for this collider.
|
|
237
|
+
*/
|
|
238
|
+
activeEvents() {
|
|
239
|
+
return this.colliderSet.raw.coActiveEvents(this.handle);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Set the events active for this collider.
|
|
243
|
+
*
|
|
244
|
+
* Use this to enable contact and/or intersection event reporting for this collider.
|
|
245
|
+
*
|
|
246
|
+
* @param activeEvents - The events active for contact/intersection pairs involving this collider.
|
|
247
|
+
*/
|
|
248
|
+
setActiveEvents(activeEvents) {
|
|
249
|
+
this.colliderSet.raw.coSetActiveEvents(this.handle, activeEvents);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Gets the collision types active for this collider.
|
|
253
|
+
*/
|
|
254
|
+
activeCollisionTypes() {
|
|
255
|
+
return this.colliderSet.raw.coActiveCollisionTypes(this.handle);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Sets the total force magnitude beyond which a contact force event can be emitted.
|
|
259
|
+
*
|
|
260
|
+
* @param threshold - The new force threshold.
|
|
261
|
+
*/
|
|
262
|
+
setContactForceEventThreshold(threshold) {
|
|
263
|
+
return this.colliderSet.raw.coSetContactForceEventThreshold(this.handle, threshold);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The total force magnitude beyond which a contact force event can be emitted.
|
|
267
|
+
*/
|
|
268
|
+
contactForceEventThreshold() {
|
|
269
|
+
return this.colliderSet.raw.coContactForceEventThreshold(this.handle);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Set the collision types active for this collider.
|
|
273
|
+
*
|
|
274
|
+
* @param activeCollisionTypes - The hooks active for contact/intersection pairs involving this collider.
|
|
275
|
+
*/
|
|
276
|
+
setActiveCollisionTypes(activeCollisionTypes) {
|
|
277
|
+
this.colliderSet.raw.coSetActiveCollisionTypes(this.handle, activeCollisionTypes);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Sets the uniform density of this collider.
|
|
281
|
+
*
|
|
282
|
+
* This will override any previous mass-properties set by `this.setDensity`,
|
|
283
|
+
* `this.setMass`, `this.setMassProperties`, `ColliderDesc.density`,
|
|
284
|
+
* `ColliderDesc.mass`, or `ColliderDesc.massProperties` for this collider.
|
|
285
|
+
*
|
|
286
|
+
* The mass and angular inertia of this collider will be computed automatically based on its
|
|
287
|
+
* shape.
|
|
288
|
+
*/
|
|
289
|
+
setDensity(density) {
|
|
290
|
+
this.colliderSet.raw.coSetDensity(this.handle, density);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Sets the mass of this collider.
|
|
294
|
+
*
|
|
295
|
+
* This will override any previous mass-properties set by `this.setDensity`,
|
|
296
|
+
* `this.setMass`, `this.setMassProperties`, `ColliderDesc.density`,
|
|
297
|
+
* `ColliderDesc.mass`, or `ColliderDesc.massProperties` for this collider.
|
|
298
|
+
*
|
|
299
|
+
* The angular inertia of this collider will be computed automatically based on its shape
|
|
300
|
+
* and this mass value.
|
|
301
|
+
*/
|
|
302
|
+
setMass(mass) {
|
|
303
|
+
this.colliderSet.raw.coSetMass(this.handle, mass);
|
|
304
|
+
}
|
|
305
|
+
// #if DIM3
|
|
306
|
+
/**
|
|
307
|
+
* Sets the mass of this collider.
|
|
308
|
+
*
|
|
309
|
+
* This will override any previous mass-properties set by `this.setDensity`,
|
|
310
|
+
* `this.setMass`, `this.setMassProperties`, `ColliderDesc.density`,
|
|
311
|
+
* `ColliderDesc.mass`, or `ColliderDesc.massProperties` for this collider.
|
|
312
|
+
*/
|
|
313
|
+
setMassProperties(mass, centerOfMass, principalAngularInertia, angularInertiaLocalFrame) {
|
|
314
|
+
let rawCom = VectorOps.intoRaw(centerOfMass);
|
|
315
|
+
let rawPrincipalInertia = VectorOps.intoRaw(principalAngularInertia);
|
|
316
|
+
let rawInertiaFrame = RotationOps.intoRaw(angularInertiaLocalFrame);
|
|
317
|
+
this.colliderSet.raw.coSetMassProperties(this.handle, mass, rawCom, rawPrincipalInertia, rawInertiaFrame);
|
|
318
|
+
rawCom.free();
|
|
319
|
+
rawPrincipalInertia.free();
|
|
320
|
+
rawInertiaFrame.free();
|
|
321
|
+
}
|
|
322
|
+
// #endif
|
|
323
|
+
/**
|
|
324
|
+
* Sets the translation of this collider.
|
|
325
|
+
*
|
|
326
|
+
* @param tra - The world-space position of the collider.
|
|
327
|
+
*/
|
|
328
|
+
setTranslation(tra) {
|
|
329
|
+
// #if DIM3
|
|
330
|
+
this.colliderSet.raw.coSetTranslation(this.handle, tra.x, tra.y, tra.z);
|
|
331
|
+
// #endif
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Sets the translation of this collider relative to its parent rigid-body.
|
|
335
|
+
*
|
|
336
|
+
* Does nothing if this collider isn't attached to a rigid-body.
|
|
337
|
+
*
|
|
338
|
+
* @param tra - The new translation of the collider relative to its parent.
|
|
339
|
+
*/
|
|
340
|
+
setTranslationWrtParent(tra) {
|
|
341
|
+
// #if DIM3
|
|
342
|
+
this.colliderSet.raw.coSetTranslationWrtParent(this.handle, tra.x, tra.y, tra.z);
|
|
343
|
+
// #endif
|
|
344
|
+
}
|
|
345
|
+
// #if DIM3
|
|
346
|
+
/**
|
|
347
|
+
* Sets the rotation quaternion of this collider.
|
|
348
|
+
*
|
|
349
|
+
* This does nothing if a zero quaternion is provided.
|
|
350
|
+
*
|
|
351
|
+
* @param rotation - The rotation to set.
|
|
352
|
+
*/
|
|
353
|
+
setRotation(rot) {
|
|
354
|
+
this.colliderSet.raw.coSetRotation(this.handle, rot.x, rot.y, rot.z, rot.w);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Sets the rotation quaternion of this collider relative to its parent rigid-body.
|
|
358
|
+
*
|
|
359
|
+
* This does nothing if a zero quaternion is provided or if this collider isn't
|
|
360
|
+
* attached to a rigid-body.
|
|
361
|
+
*
|
|
362
|
+
* @param rotation - The rotation to set.
|
|
363
|
+
*/
|
|
364
|
+
setRotationWrtParent(rot) {
|
|
365
|
+
this.colliderSet.raw.coSetRotationWrtParent(this.handle, rot.x, rot.y, rot.z, rot.w);
|
|
366
|
+
}
|
|
367
|
+
// #endif
|
|
368
|
+
/**
|
|
369
|
+
* The type of the shape of this collider.
|
|
370
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
371
|
+
*/
|
|
372
|
+
shapeType() {
|
|
373
|
+
return this.colliderSet.raw.coShapeType(this.handle);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* The half-extents of this collider if it is a cuboid shape.
|
|
377
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
378
|
+
*/
|
|
379
|
+
halfExtents() {
|
|
380
|
+
return VectorOps.fromRaw(this.colliderSet.raw.coHalfExtents(this.handle));
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Sets the half-extents of this collider if it is a cuboid shape.
|
|
384
|
+
*
|
|
385
|
+
* @param newHalfExtents - desired half extents.
|
|
386
|
+
*/
|
|
387
|
+
setHalfExtents(newHalfExtents) {
|
|
388
|
+
const rawPoint = VectorOps.intoRaw(newHalfExtents);
|
|
389
|
+
this.colliderSet.raw.coSetHalfExtents(this.handle, rawPoint);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* The radius of this collider if it is a ball, cylinder, capsule, or cone shape.
|
|
393
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
394
|
+
*/
|
|
395
|
+
radius() {
|
|
396
|
+
return this.colliderSet.raw.coRadius(this.handle);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Sets the radius of this collider if it is a ball, cylinder, capsule, or cone shape.
|
|
400
|
+
*
|
|
401
|
+
* @param newRadius - desired radius.
|
|
402
|
+
*/
|
|
403
|
+
setRadius(newRadius) {
|
|
404
|
+
this.colliderSet.raw.coSetRadius(this.handle, newRadius);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* The radius of the round edges of this collider if it is a round cylinder.
|
|
408
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
409
|
+
*/
|
|
410
|
+
roundRadius() {
|
|
411
|
+
return this.colliderSet.raw.coRoundRadius(this.handle);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Sets the radius of the round edges of this collider if it has round edges.
|
|
415
|
+
*
|
|
416
|
+
* @param newBorderRadius - desired round edge radius.
|
|
417
|
+
*/
|
|
418
|
+
setRoundRadius(newBorderRadius) {
|
|
419
|
+
this.colliderSet.raw.coSetRoundRadius(this.handle, newBorderRadius);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* The half height of this collider if it is a cylinder, capsule, or cone shape.
|
|
423
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
424
|
+
*/
|
|
425
|
+
halfHeight() {
|
|
426
|
+
return this.colliderSet.raw.coHalfHeight(this.handle);
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Sets the half height of this collider if it is a cylinder, capsule, or cone shape.
|
|
430
|
+
*
|
|
431
|
+
* @param newHalfheight - desired half height.
|
|
432
|
+
*/
|
|
433
|
+
setHalfHeight(newHalfheight) {
|
|
434
|
+
this.colliderSet.raw.coSetHalfHeight(this.handle, newHalfheight);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* If this collider has a triangle mesh, polyline, convex polygon, or convex polyhedron shape,
|
|
438
|
+
* this returns the vertex buffer of said shape.
|
|
439
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
440
|
+
*/
|
|
441
|
+
vertices() {
|
|
442
|
+
return this.colliderSet.raw.coVertices(this.handle);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* If this collider has a triangle mesh, polyline, or convex polyhedron shape,
|
|
446
|
+
* this returns the index buffer of said shape.
|
|
447
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
448
|
+
*/
|
|
449
|
+
indices() {
|
|
450
|
+
return this.colliderSet.raw.coIndices(this.handle);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* If this collider has a heightfield shape, this returns the heights buffer of
|
|
454
|
+
* the heightfield.
|
|
455
|
+
* In 3D, the returned height matrix is provided in column-major order.
|
|
456
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
457
|
+
*/
|
|
458
|
+
heightfieldHeights() {
|
|
459
|
+
return this.colliderSet.raw.coHeightfieldHeights(this.handle);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* If this collider has a heightfield shape, this returns the scale
|
|
463
|
+
* applied to it.
|
|
464
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
465
|
+
*/
|
|
466
|
+
heightfieldScale() {
|
|
467
|
+
let scale = this.colliderSet.raw.coHeightfieldScale(this.handle);
|
|
468
|
+
return VectorOps.fromRaw(scale);
|
|
469
|
+
}
|
|
470
|
+
// #if DIM3
|
|
471
|
+
/**
|
|
472
|
+
* If this collider has a heightfield shape, this returns the number of
|
|
473
|
+
* rows of its height matrix.
|
|
474
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
475
|
+
*/
|
|
476
|
+
heightfieldNRows() {
|
|
477
|
+
return this.colliderSet.raw.coHeightfieldNRows(this.handle);
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* If this collider has a heightfield shape, this returns the number of
|
|
481
|
+
* columns of its height matrix.
|
|
482
|
+
* @deprecated this field will be removed in the future, please access this field on `shape` member instead.
|
|
483
|
+
*/
|
|
484
|
+
heightfieldNCols() {
|
|
485
|
+
return this.colliderSet.raw.coHeightfieldNCols(this.handle);
|
|
486
|
+
}
|
|
487
|
+
// #endif
|
|
488
|
+
/**
|
|
489
|
+
* The rigid-body this collider is attached to.
|
|
490
|
+
*/
|
|
491
|
+
parent() {
|
|
492
|
+
return this._parent;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* The friction coefficient of this collider.
|
|
496
|
+
*/
|
|
497
|
+
friction() {
|
|
498
|
+
return this.colliderSet.raw.coFriction(this.handle);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* The restitution coefficient of this collider.
|
|
502
|
+
*/
|
|
503
|
+
restitution() {
|
|
504
|
+
return this.colliderSet.raw.coRestitution(this.handle);
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* The density of this collider.
|
|
508
|
+
*/
|
|
509
|
+
density() {
|
|
510
|
+
return this.colliderSet.raw.coDensity(this.handle);
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* The mass of this collider.
|
|
514
|
+
*/
|
|
515
|
+
mass() {
|
|
516
|
+
return this.colliderSet.raw.coMass(this.handle);
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* The volume of this collider.
|
|
520
|
+
*/
|
|
521
|
+
volume() {
|
|
522
|
+
return this.colliderSet.raw.coVolume(this.handle);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* The collision groups of this collider.
|
|
526
|
+
*/
|
|
527
|
+
collisionGroups() {
|
|
528
|
+
return this.colliderSet.raw.coCollisionGroups(this.handle);
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* The solver groups of this collider.
|
|
532
|
+
*/
|
|
533
|
+
solverGroups() {
|
|
534
|
+
return this.colliderSet.raw.coSolverGroups(this.handle);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Tests if this collider contains a point.
|
|
538
|
+
*
|
|
539
|
+
* @param point - The point to test.
|
|
540
|
+
*/
|
|
541
|
+
containsPoint(point) {
|
|
542
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
543
|
+
let result = this.colliderSet.raw.coContainsPoint(this.handle, rawPoint);
|
|
544
|
+
rawPoint.free();
|
|
545
|
+
return result;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Find the projection of a point on this collider.
|
|
549
|
+
*
|
|
550
|
+
* @param point - The point to project.
|
|
551
|
+
* @param solid - If this is set to `true` then the collider shapes are considered to
|
|
552
|
+
* be plain (if the point is located inside of a plain shape, its projection is the point
|
|
553
|
+
* itself). If it is set to `false` the collider shapes are considered to be hollow
|
|
554
|
+
* (if the point is located inside of an hollow shape, it is projected on the shape's
|
|
555
|
+
* boundary).
|
|
556
|
+
*/
|
|
557
|
+
projectPoint(point, solid) {
|
|
558
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
559
|
+
let result = PointProjection.fromRaw(this.colliderSet.raw.coProjectPoint(this.handle, rawPoint, solid));
|
|
560
|
+
rawPoint.free();
|
|
561
|
+
return result;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Tests if this collider intersects the given ray.
|
|
565
|
+
*
|
|
566
|
+
* @param ray - The ray to cast.
|
|
567
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
568
|
+
* limits the length of the ray to `ray.dir.norm() * maxToi`.
|
|
569
|
+
*/
|
|
570
|
+
intersectsRay(ray, maxToi) {
|
|
571
|
+
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
572
|
+
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
573
|
+
let result = this.colliderSet.raw.coIntersectsRay(this.handle, rawOrig, rawDir, maxToi);
|
|
574
|
+
rawOrig.free();
|
|
575
|
+
rawDir.free();
|
|
576
|
+
return result;
|
|
577
|
+
}
|
|
578
|
+
/*
|
|
579
|
+
* Computes the smallest time between this and the given shape under translational movement are separated by a distance smaller or equal to distance.
|
|
580
|
+
*
|
|
581
|
+
* @param collider1Vel - The constant velocity of the current shape to cast (i.e. the cast direction).
|
|
582
|
+
* @param shape2 - The shape to cast against.
|
|
583
|
+
* @param shape2Pos - The position of the second shape.
|
|
584
|
+
* @param shape2Rot - The rotation of the second shape.
|
|
585
|
+
* @param shape2Vel - The constant velocity of the second shape.
|
|
586
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
587
|
+
* limits the distance traveled by the shape to `collider1Vel.norm() * maxToi`.
|
|
588
|
+
* @param stopAtPenetration - If set to `false`, the linear shape-cast won’t immediately stop if
|
|
589
|
+
* the shape is penetrating another shape at its starting point **and** its trajectory is such
|
|
590
|
+
* that it’s on a path to exist that penetration state.
|
|
591
|
+
*/
|
|
592
|
+
castShape(collider1Vel, shape2, shape2Pos, shape2Rot, shape2Vel, maxToi, stopAtPenetration) {
|
|
593
|
+
let rawCollider1Vel = VectorOps.intoRaw(collider1Vel);
|
|
594
|
+
let rawShape2Pos = VectorOps.intoRaw(shape2Pos);
|
|
595
|
+
let rawShape2Rot = RotationOps.intoRaw(shape2Rot);
|
|
596
|
+
let rawShape2Vel = VectorOps.intoRaw(shape2Vel);
|
|
597
|
+
let rawShape2 = shape2.intoRaw();
|
|
598
|
+
let result = ShapeTOI.fromRaw(this.colliderSet, this.colliderSet.raw.coCastShape(this.handle, rawCollider1Vel, rawShape2, rawShape2Pos, rawShape2Rot, rawShape2Vel, maxToi, stopAtPenetration));
|
|
599
|
+
rawCollider1Vel.free();
|
|
600
|
+
rawShape2Pos.free();
|
|
601
|
+
rawShape2Rot.free();
|
|
602
|
+
rawShape2Vel.free();
|
|
603
|
+
rawShape2.free();
|
|
604
|
+
return result;
|
|
605
|
+
}
|
|
606
|
+
/*
|
|
607
|
+
* Computes the smallest time between this and the given collider under translational movement are separated by a distance smaller or equal to distance.
|
|
608
|
+
*
|
|
609
|
+
* @param collider1Vel - The constant velocity of the current collider to cast (i.e. the cast direction).
|
|
610
|
+
* @param collider2 - The collider to cast against.
|
|
611
|
+
* @param collider2Vel - The constant velocity of the second collider.
|
|
612
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
613
|
+
* limits the distance traveled by the shape to `shapeVel.norm() * maxToi`.
|
|
614
|
+
* @param stopAtPenetration - If set to `false`, the linear shape-cast won’t immediately stop if
|
|
615
|
+
* the shape is penetrating another shape at its starting point **and** its trajectory is such
|
|
616
|
+
* that it’s on a path to exist that penetration state.
|
|
617
|
+
*/
|
|
618
|
+
castCollider(collider1Vel, collider2, collider2Vel, maxToi, stopAtPenetration) {
|
|
619
|
+
let rawCollider1Vel = VectorOps.intoRaw(collider1Vel);
|
|
620
|
+
let rawCollider2Vel = VectorOps.intoRaw(collider2Vel);
|
|
621
|
+
let result = ShapeColliderTOI.fromRaw(this.colliderSet, this.colliderSet.raw.coCastCollider(this.handle, rawCollider1Vel, collider2.handle, rawCollider2Vel, maxToi, stopAtPenetration));
|
|
622
|
+
rawCollider1Vel.free();
|
|
623
|
+
rawCollider2Vel.free();
|
|
624
|
+
return result;
|
|
625
|
+
}
|
|
626
|
+
intersectsShape(shape2, shapePos2, shapeRot2) {
|
|
627
|
+
let rawPos2 = VectorOps.intoRaw(shapePos2);
|
|
628
|
+
let rawRot2 = RotationOps.intoRaw(shapeRot2);
|
|
629
|
+
let rawShape2 = shape2.intoRaw();
|
|
630
|
+
let result = this.colliderSet.raw.coIntersectsShape(this.handle, rawShape2, rawPos2, rawRot2);
|
|
631
|
+
rawPos2.free();
|
|
632
|
+
rawRot2.free();
|
|
633
|
+
rawShape2.free();
|
|
634
|
+
return result;
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Computes one pair of contact points between the shape owned by this collider and the given shape.
|
|
638
|
+
*
|
|
639
|
+
* @param shape2 - The second shape.
|
|
640
|
+
* @param shape2Pos - The initial position of the second shape.
|
|
641
|
+
* @param shape2Rot - The rotation of the second shape.
|
|
642
|
+
* @param prediction - The prediction value, if the shapes are separated by a distance greater than this value, test will fail.
|
|
643
|
+
* @returns `null` if the shapes are separated by a distance greater than prediction, otherwise contact details. The result is given in world-space.
|
|
644
|
+
*/
|
|
645
|
+
contactShape(shape2, shape2Pos, shape2Rot, prediction) {
|
|
646
|
+
let rawPos2 = VectorOps.intoRaw(shape2Pos);
|
|
647
|
+
let rawRot2 = RotationOps.intoRaw(shape2Rot);
|
|
648
|
+
let rawShape2 = shape2.intoRaw();
|
|
649
|
+
let result = ShapeContact.fromRaw(this.colliderSet.raw.coContactShape(this.handle, rawShape2, rawPos2, rawRot2, prediction));
|
|
650
|
+
rawPos2.free();
|
|
651
|
+
rawRot2.free();
|
|
652
|
+
rawShape2.free();
|
|
653
|
+
return result;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Computes one pair of contact points between the collider and the given collider.
|
|
657
|
+
*
|
|
658
|
+
* @param collider2 - The second collider.
|
|
659
|
+
* @param prediction - The prediction value, if the shapes are separated by a distance greater than this value, test will fail.
|
|
660
|
+
* @returns `null` if the shapes are separated by a distance greater than prediction, otherwise contact details. The result is given in world-space.
|
|
661
|
+
*/
|
|
662
|
+
contactCollider(collider2, prediction) {
|
|
663
|
+
let result = ShapeContact.fromRaw(this.colliderSet.raw.coContactCollider(this.handle, collider2.handle, prediction));
|
|
664
|
+
return result;
|
|
665
|
+
}
|
|
666
|
+
/*
|
|
667
|
+
* Find the closest intersection between a ray and this collider.
|
|
668
|
+
*
|
|
669
|
+
* This also computes the normal at the hit point.
|
|
670
|
+
* @param ray - The ray to cast.
|
|
671
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
672
|
+
* limits the length of the ray to `ray.dir.norm() * maxToi`.
|
|
673
|
+
* @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
|
|
674
|
+
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
|
|
675
|
+
* whereas `false` implies that all shapes are hollow for this ray-cast.
|
|
676
|
+
* @returns The time-of-impact between this collider and the ray, or `-1` if there is no intersection.
|
|
677
|
+
*/
|
|
678
|
+
castRay(ray, maxToi, solid) {
|
|
679
|
+
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
680
|
+
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
681
|
+
let result = this.colliderSet.raw.coCastRay(this.handle, rawOrig, rawDir, maxToi, solid);
|
|
682
|
+
rawOrig.free();
|
|
683
|
+
rawDir.free();
|
|
684
|
+
return result;
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Find the closest intersection between a ray and this collider.
|
|
688
|
+
*
|
|
689
|
+
* This also computes the normal at the hit point.
|
|
690
|
+
* @param ray - The ray to cast.
|
|
691
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
692
|
+
* limits the length of the ray to `ray.dir.norm() * maxToi`.
|
|
693
|
+
* @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
|
|
694
|
+
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
|
|
695
|
+
* whereas `false` implies that all shapes are hollow for this ray-cast.
|
|
696
|
+
*/
|
|
697
|
+
castRayAndGetNormal(ray, maxToi, solid) {
|
|
698
|
+
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
699
|
+
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
700
|
+
let result = RayIntersection.fromRaw(this.colliderSet.raw.coCastRayAndGetNormal(this.handle, rawOrig, rawDir, maxToi, solid));
|
|
701
|
+
rawOrig.free();
|
|
702
|
+
rawDir.free();
|
|
703
|
+
return result;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
export var MassPropsMode;
|
|
707
|
+
(function (MassPropsMode) {
|
|
708
|
+
MassPropsMode[MassPropsMode["Density"] = 0] = "Density";
|
|
709
|
+
MassPropsMode[MassPropsMode["Mass"] = 1] = "Mass";
|
|
710
|
+
MassPropsMode[MassPropsMode["MassProps"] = 2] = "MassProps";
|
|
711
|
+
})(MassPropsMode || (MassPropsMode = {}));
|
|
712
|
+
export class ColliderDesc {
|
|
713
|
+
/**
|
|
714
|
+
* Initializes a collider descriptor from the collision shape.
|
|
715
|
+
*
|
|
716
|
+
* @param shape - The shape of the collider being built.
|
|
717
|
+
*/
|
|
718
|
+
constructor(shape) {
|
|
719
|
+
this.enabled = true;
|
|
720
|
+
this.shape = shape;
|
|
721
|
+
this.massPropsMode = MassPropsMode.Density;
|
|
722
|
+
this.density = 1.0;
|
|
723
|
+
this.friction = 0.5;
|
|
724
|
+
this.restitution = 0.0;
|
|
725
|
+
this.rotation = RotationOps.identity();
|
|
726
|
+
this.translation = VectorOps.zeros();
|
|
727
|
+
this.isSensor = false;
|
|
728
|
+
this.collisionGroups = 4294967295;
|
|
729
|
+
this.solverGroups = 4294967295;
|
|
730
|
+
this.frictionCombineRule = CoefficientCombineRule.Average;
|
|
731
|
+
this.restitutionCombineRule = CoefficientCombineRule.Average;
|
|
732
|
+
this.activeCollisionTypes = ActiveCollisionTypes.DEFAULT;
|
|
733
|
+
this.activeEvents = ActiveEvents.NONE;
|
|
734
|
+
this.activeHooks = ActiveHooks.NONE;
|
|
735
|
+
this.mass = 0.0;
|
|
736
|
+
this.centerOfMass = VectorOps.zeros();
|
|
737
|
+
this.contactForceEventThreshold = 0.0;
|
|
738
|
+
// #if DIM3
|
|
739
|
+
this.principalAngularInertia = VectorOps.zeros();
|
|
740
|
+
this.angularInertiaLocalFrame = RotationOps.identity();
|
|
741
|
+
// #endif
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Create a new collider descriptor with a ball shape.
|
|
745
|
+
*
|
|
746
|
+
* @param radius - The radius of the ball.
|
|
747
|
+
*/
|
|
748
|
+
static ball(radius) {
|
|
749
|
+
const shape = new Ball(radius);
|
|
750
|
+
return new ColliderDesc(shape);
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* Create a new collider descriptor with a capsule shape.
|
|
754
|
+
*
|
|
755
|
+
* @param halfHeight - The half-height of the capsule, along the `y` axis.
|
|
756
|
+
* @param radius - The radius of the capsule basis.
|
|
757
|
+
*/
|
|
758
|
+
static capsule(halfHeight, radius) {
|
|
759
|
+
const shape = new Capsule(halfHeight, radius);
|
|
760
|
+
return new ColliderDesc(shape);
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Creates a new segment shape.
|
|
764
|
+
*
|
|
765
|
+
* @param a - The first point of the segment.
|
|
766
|
+
* @param b - The second point of the segment.
|
|
767
|
+
*/
|
|
768
|
+
static segment(a, b) {
|
|
769
|
+
const shape = new Segment(a, b);
|
|
770
|
+
return new ColliderDesc(shape);
|
|
771
|
+
}
|
|
772
|
+
/**
|
|
773
|
+
* Creates a new triangle shape.
|
|
774
|
+
*
|
|
775
|
+
* @param a - The first point of the triangle.
|
|
776
|
+
* @param b - The second point of the triangle.
|
|
777
|
+
* @param c - The third point of the triangle.
|
|
778
|
+
*/
|
|
779
|
+
static triangle(a, b, c) {
|
|
780
|
+
const shape = new Triangle(a, b, c);
|
|
781
|
+
return new ColliderDesc(shape);
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Creates a new triangle shape with round corners.
|
|
785
|
+
*
|
|
786
|
+
* @param a - The first point of the triangle.
|
|
787
|
+
* @param b - The second point of the triangle.
|
|
788
|
+
* @param c - The third point of the triangle.
|
|
789
|
+
* @param borderRadius - The radius of the borders of this triangle. In 3D,
|
|
790
|
+
* this is also equal to half the thickness of the triangle.
|
|
791
|
+
*/
|
|
792
|
+
static roundTriangle(a, b, c, borderRadius) {
|
|
793
|
+
const shape = new RoundTriangle(a, b, c, borderRadius);
|
|
794
|
+
return new ColliderDesc(shape);
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* Creates a new collider descriptor with a polyline shape.
|
|
798
|
+
*
|
|
799
|
+
* @param vertices - The coordinates of the polyline's vertices.
|
|
800
|
+
* @param indices - The indices of the polyline's segments. If this is `undefined` or `null`,
|
|
801
|
+
* the vertices are assumed to describe a line strip.
|
|
802
|
+
*/
|
|
803
|
+
static polyline(vertices, indices) {
|
|
804
|
+
const shape = new Polyline(vertices, indices);
|
|
805
|
+
return new ColliderDesc(shape);
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Creates a new collider descriptor with a triangle mesh shape.
|
|
809
|
+
*
|
|
810
|
+
* @param vertices - The coordinates of the triangle mesh's vertices.
|
|
811
|
+
* @param indices - The indices of the triangle mesh's triangles.
|
|
812
|
+
*/
|
|
813
|
+
static trimesh(vertices, indices) {
|
|
814
|
+
const shape = new TriMesh(vertices, indices);
|
|
815
|
+
return new ColliderDesc(shape);
|
|
816
|
+
}
|
|
817
|
+
// #if DIM3
|
|
818
|
+
/**
|
|
819
|
+
* Creates a new collider descriptor with a cuboid shape.
|
|
820
|
+
*
|
|
821
|
+
* @param hx - The half-width of the rectangle along its local `x` axis.
|
|
822
|
+
* @param hy - The half-width of the rectangle along its local `y` axis.
|
|
823
|
+
* @param hz - The half-width of the rectangle along its local `z` axis.
|
|
824
|
+
*/
|
|
825
|
+
static cuboid(hx, hy, hz) {
|
|
826
|
+
const shape = new Cuboid(hx, hy, hz);
|
|
827
|
+
return new ColliderDesc(shape);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Creates a new collider descriptor with a rectangular shape with round borders.
|
|
831
|
+
*
|
|
832
|
+
* @param hx - The half-width of the rectangle along its local `x` axis.
|
|
833
|
+
* @param hy - The half-width of the rectangle along its local `y` axis.
|
|
834
|
+
* @param hz - The half-width of the rectangle along its local `z` axis.
|
|
835
|
+
* @param borderRadius - The radius of the cuboid's borders.
|
|
836
|
+
*/
|
|
837
|
+
static roundCuboid(hx, hy, hz, borderRadius) {
|
|
838
|
+
const shape = new RoundCuboid(hx, hy, hz, borderRadius);
|
|
839
|
+
return new ColliderDesc(shape);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Creates a new collider descriptor with a heightfield shape.
|
|
843
|
+
*
|
|
844
|
+
* @param nrows − The number of rows in the heights matrix.
|
|
845
|
+
* @param ncols - The number of columns in the heights matrix.
|
|
846
|
+
* @param heights - The heights of the heightfield along its local `y` axis,
|
|
847
|
+
* provided as a matrix stored in column-major order.
|
|
848
|
+
* @param scale - The scale factor applied to the heightfield.
|
|
849
|
+
*/
|
|
850
|
+
static heightfield(nrows, ncols, heights, scale) {
|
|
851
|
+
const shape = new Heightfield(nrows, ncols, heights, scale);
|
|
852
|
+
return new ColliderDesc(shape);
|
|
853
|
+
}
|
|
854
|
+
/**
|
|
855
|
+
* Create a new collider descriptor with a cylinder shape.
|
|
856
|
+
*
|
|
857
|
+
* @param halfHeight - The half-height of the cylinder, along the `y` axis.
|
|
858
|
+
* @param radius - The radius of the cylinder basis.
|
|
859
|
+
*/
|
|
860
|
+
static cylinder(halfHeight, radius) {
|
|
861
|
+
const shape = new Cylinder(halfHeight, radius);
|
|
862
|
+
return new ColliderDesc(shape);
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* Create a new collider descriptor with a cylinder shape with rounded corners.
|
|
866
|
+
*
|
|
867
|
+
* @param halfHeight - The half-height of the cylinder, along the `y` axis.
|
|
868
|
+
* @param radius - The radius of the cylinder basis.
|
|
869
|
+
* @param borderRadius - The radius of the cylinder's rounded edges and vertices.
|
|
870
|
+
*/
|
|
871
|
+
static roundCylinder(halfHeight, radius, borderRadius) {
|
|
872
|
+
const shape = new RoundCylinder(halfHeight, radius, borderRadius);
|
|
873
|
+
return new ColliderDesc(shape);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Create a new collider descriptor with a cone shape.
|
|
877
|
+
*
|
|
878
|
+
* @param halfHeight - The half-height of the cone, along the `y` axis.
|
|
879
|
+
* @param radius - The radius of the cone basis.
|
|
880
|
+
*/
|
|
881
|
+
static cone(halfHeight, radius) {
|
|
882
|
+
const shape = new Cone(halfHeight, radius);
|
|
883
|
+
return new ColliderDesc(shape);
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Create a new collider descriptor with a cone shape with rounded corners.
|
|
887
|
+
*
|
|
888
|
+
* @param halfHeight - The half-height of the cone, along the `y` axis.
|
|
889
|
+
* @param radius - The radius of the cone basis.
|
|
890
|
+
* @param borderRadius - The radius of the cone's rounded edges and vertices.
|
|
891
|
+
*/
|
|
892
|
+
static roundCone(halfHeight, radius, borderRadius) {
|
|
893
|
+
const shape = new RoundCone(halfHeight, radius, borderRadius);
|
|
894
|
+
return new ColliderDesc(shape);
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Computes the convex-hull of the given points and use the resulting
|
|
898
|
+
* convex polyhedron as the shape for this new collider descriptor.
|
|
899
|
+
*
|
|
900
|
+
* @param points - The point that will be used to compute the convex-hull.
|
|
901
|
+
*/
|
|
902
|
+
static convexHull(points) {
|
|
903
|
+
const shape = new ConvexPolyhedron(points, null);
|
|
904
|
+
return new ColliderDesc(shape);
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Creates a new collider descriptor that uses the given set of points assumed
|
|
908
|
+
* to form a convex polyline (no convex-hull computation will be done).
|
|
909
|
+
*
|
|
910
|
+
* @param vertices - The vertices of the convex polyline.
|
|
911
|
+
*/
|
|
912
|
+
static convexMesh(vertices, indices) {
|
|
913
|
+
const shape = new ConvexPolyhedron(vertices, indices);
|
|
914
|
+
return new ColliderDesc(shape);
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Computes the convex-hull of the given points and use the resulting
|
|
918
|
+
* convex polyhedron as the shape for this new collider descriptor. A
|
|
919
|
+
* border is added to that convex polyhedron to give it round corners.
|
|
920
|
+
*
|
|
921
|
+
* @param points - The point that will be used to compute the convex-hull.
|
|
922
|
+
* @param borderRadius - The radius of the round border added to the convex polyhedron.
|
|
923
|
+
*/
|
|
924
|
+
static roundConvexHull(points, borderRadius) {
|
|
925
|
+
const shape = new RoundConvexPolyhedron(points, null, borderRadius);
|
|
926
|
+
return new ColliderDesc(shape);
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* Creates a new collider descriptor that uses the given set of points assumed
|
|
930
|
+
* to form a round convex polyline (no convex-hull computation will be done).
|
|
931
|
+
*
|
|
932
|
+
* @param vertices - The vertices of the convex polyline.
|
|
933
|
+
* @param borderRadius - The radius of the round border added to the convex polyline.
|
|
934
|
+
*/
|
|
935
|
+
static roundConvexMesh(vertices, indices, borderRadius) {
|
|
936
|
+
const shape = new RoundConvexPolyhedron(vertices, indices, borderRadius);
|
|
937
|
+
return new ColliderDesc(shape);
|
|
938
|
+
}
|
|
939
|
+
// #endif
|
|
940
|
+
// #if DIM3
|
|
941
|
+
/**
|
|
942
|
+
* Sets the position of the collider to be created relative to the rigid-body it is attached to.
|
|
943
|
+
*/
|
|
944
|
+
setTranslation(x, y, z) {
|
|
945
|
+
if (typeof x != "number" ||
|
|
946
|
+
typeof y != "number" ||
|
|
947
|
+
typeof z != "number")
|
|
948
|
+
throw TypeError("The translation components must be numbers.");
|
|
949
|
+
this.translation = { x: x, y: y, z: z };
|
|
950
|
+
return this;
|
|
951
|
+
}
|
|
952
|
+
// #endif
|
|
953
|
+
/**
|
|
954
|
+
* Sets the rotation of the collider to be created relative to the rigid-body it is attached to.
|
|
955
|
+
*
|
|
956
|
+
* @param rot - The rotation of the collider to be created relative to the rigid-body it is attached to.
|
|
957
|
+
*/
|
|
958
|
+
setRotation(rot) {
|
|
959
|
+
// #if DIM3
|
|
960
|
+
RotationOps.copy(this.rotation, rot);
|
|
961
|
+
// #endif
|
|
962
|
+
return this;
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Sets whether or not the collider being created is a sensor.
|
|
966
|
+
*
|
|
967
|
+
* A sensor collider does not take part of the physics simulation, but generates
|
|
968
|
+
* proximity events.
|
|
969
|
+
*
|
|
970
|
+
* @param sensor - Set to `true` of the collider built is to be a sensor.
|
|
971
|
+
*/
|
|
972
|
+
setSensor(sensor) {
|
|
973
|
+
this.isSensor = sensor;
|
|
974
|
+
return this;
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Sets whether the created collider will be enabled or disabled.
|
|
978
|
+
* @param enabled − If set to `false` the collider will be disabled at creation.
|
|
979
|
+
*/
|
|
980
|
+
setEnabled(enabled) {
|
|
981
|
+
this.enabled = enabled;
|
|
982
|
+
return this;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Sets the density of the collider being built.
|
|
986
|
+
*
|
|
987
|
+
* The mass and angular inertia tensor will be computed automatically based on this density and the collider’s shape.
|
|
988
|
+
*
|
|
989
|
+
* @param density - The density to set, must be greater or equal to 0. A density of 0 means that this collider
|
|
990
|
+
* will not affect the mass or angular inertia of the rigid-body it is attached to.
|
|
991
|
+
*/
|
|
992
|
+
setDensity(density) {
|
|
993
|
+
this.massPropsMode = MassPropsMode.Density;
|
|
994
|
+
this.density = density;
|
|
995
|
+
return this;
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Sets the mass of the collider being built.
|
|
999
|
+
*
|
|
1000
|
+
* The angular inertia tensor will be computed automatically based on this mass and the collider’s shape.
|
|
1001
|
+
*
|
|
1002
|
+
* @param mass - The mass to set, must be greater or equal to 0.
|
|
1003
|
+
*/
|
|
1004
|
+
setMass(mass) {
|
|
1005
|
+
this.massPropsMode = MassPropsMode.Mass;
|
|
1006
|
+
this.mass = mass;
|
|
1007
|
+
return this;
|
|
1008
|
+
}
|
|
1009
|
+
// #if DIM3
|
|
1010
|
+
/**
|
|
1011
|
+
* Sets the mass properties of the collider being built.
|
|
1012
|
+
*
|
|
1013
|
+
* This replaces the mass-properties automatically computed from the collider's density and shape.
|
|
1014
|
+
* These mass-properties will be added to the mass-properties of the rigid-body this collider will be attached to.
|
|
1015
|
+
*
|
|
1016
|
+
* @param mass − The mass of the collider to create.
|
|
1017
|
+
* @param centerOfMass − The center-of-mass of the collider to create.
|
|
1018
|
+
* @param principalAngularInertia − The initial principal angular inertia of the collider to create.
|
|
1019
|
+
* These are the eigenvalues of the angular inertia matrix.
|
|
1020
|
+
* @param angularInertiaLocalFrame − The initial local angular inertia frame of the collider to create.
|
|
1021
|
+
* These are the eigenvectors of the angular inertia matrix.
|
|
1022
|
+
*/
|
|
1023
|
+
setMassProperties(mass, centerOfMass, principalAngularInertia, angularInertiaLocalFrame) {
|
|
1024
|
+
this.massPropsMode = MassPropsMode.MassProps;
|
|
1025
|
+
this.mass = mass;
|
|
1026
|
+
VectorOps.copy(this.centerOfMass, centerOfMass);
|
|
1027
|
+
VectorOps.copy(this.principalAngularInertia, principalAngularInertia);
|
|
1028
|
+
RotationOps.copy(this.angularInertiaLocalFrame, angularInertiaLocalFrame);
|
|
1029
|
+
return this;
|
|
1030
|
+
}
|
|
1031
|
+
// #endif
|
|
1032
|
+
/**
|
|
1033
|
+
* Sets the restitution coefficient of the collider to be created.
|
|
1034
|
+
*
|
|
1035
|
+
* @param restitution - The restitution coefficient in `[0, 1]`. A value of 0 (the default) means no bouncing behavior
|
|
1036
|
+
* while 1 means perfect bouncing (though energy may still be lost due to numerical errors of the
|
|
1037
|
+
* constraints solver).
|
|
1038
|
+
*/
|
|
1039
|
+
setRestitution(restitution) {
|
|
1040
|
+
this.restitution = restitution;
|
|
1041
|
+
return this;
|
|
1042
|
+
}
|
|
1043
|
+
/**
|
|
1044
|
+
* Sets the friction coefficient of the collider to be created.
|
|
1045
|
+
*
|
|
1046
|
+
* @param friction - The friction coefficient. Must be greater or equal to 0. This is generally smaller than 1. The
|
|
1047
|
+
* higher the coefficient, the stronger friction forces will be for contacts with the collider
|
|
1048
|
+
* being built.
|
|
1049
|
+
*/
|
|
1050
|
+
setFriction(friction) {
|
|
1051
|
+
this.friction = friction;
|
|
1052
|
+
return this;
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Sets the rule used to combine the friction coefficients of two colliders
|
|
1056
|
+
* colliders involved in a contact.
|
|
1057
|
+
*
|
|
1058
|
+
* @param rule − The combine rule to apply.
|
|
1059
|
+
*/
|
|
1060
|
+
setFrictionCombineRule(rule) {
|
|
1061
|
+
this.frictionCombineRule = rule;
|
|
1062
|
+
return this;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Sets the rule used to combine the restitution coefficients of two colliders
|
|
1066
|
+
* colliders involved in a contact.
|
|
1067
|
+
*
|
|
1068
|
+
* @param rule − The combine rule to apply.
|
|
1069
|
+
*/
|
|
1070
|
+
setRestitutionCombineRule(rule) {
|
|
1071
|
+
this.restitutionCombineRule = rule;
|
|
1072
|
+
return this;
|
|
1073
|
+
}
|
|
1074
|
+
/**
|
|
1075
|
+
* Sets the collision groups used by this collider.
|
|
1076
|
+
*
|
|
1077
|
+
* Two colliders will interact iff. their collision groups are compatible.
|
|
1078
|
+
* See the documentation of `InteractionGroups` for details on teh used bit pattern.
|
|
1079
|
+
*
|
|
1080
|
+
* @param groups - The collision groups used for the collider being built.
|
|
1081
|
+
*/
|
|
1082
|
+
setCollisionGroups(groups) {
|
|
1083
|
+
this.collisionGroups = groups;
|
|
1084
|
+
return this;
|
|
1085
|
+
}
|
|
1086
|
+
/**
|
|
1087
|
+
* Sets the solver groups used by this collider.
|
|
1088
|
+
*
|
|
1089
|
+
* Forces between two colliders in contact will be computed iff their solver
|
|
1090
|
+
* groups are compatible.
|
|
1091
|
+
* See the documentation of `InteractionGroups` for details on the used bit pattern.
|
|
1092
|
+
*
|
|
1093
|
+
* @param groups - The solver groups used for the collider being built.
|
|
1094
|
+
*/
|
|
1095
|
+
setSolverGroups(groups) {
|
|
1096
|
+
this.solverGroups = groups;
|
|
1097
|
+
return this;
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Set the physics hooks active for this collider.
|
|
1101
|
+
*
|
|
1102
|
+
* Use this to enable custom filtering rules for contact/intersecstion pairs involving this collider.
|
|
1103
|
+
*
|
|
1104
|
+
* @param activeHooks - The hooks active for contact/intersection pairs involving this collider.
|
|
1105
|
+
*/
|
|
1106
|
+
setActiveHooks(activeHooks) {
|
|
1107
|
+
this.activeHooks = activeHooks;
|
|
1108
|
+
return this;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Set the events active for this collider.
|
|
1112
|
+
*
|
|
1113
|
+
* Use this to enable contact and/or intersection event reporting for this collider.
|
|
1114
|
+
*
|
|
1115
|
+
* @param activeEvents - The events active for contact/intersection pairs involving this collider.
|
|
1116
|
+
*/
|
|
1117
|
+
setActiveEvents(activeEvents) {
|
|
1118
|
+
this.activeEvents = activeEvents;
|
|
1119
|
+
return this;
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Set the collision types active for this collider.
|
|
1123
|
+
*
|
|
1124
|
+
* @param activeCollisionTypes - The hooks active for contact/intersection pairs involving this collider.
|
|
1125
|
+
*/
|
|
1126
|
+
setActiveCollisionTypes(activeCollisionTypes) {
|
|
1127
|
+
this.activeCollisionTypes = activeCollisionTypes;
|
|
1128
|
+
return this;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Sets the total force magnitude beyond which a contact force event can be emitted.
|
|
1132
|
+
*
|
|
1133
|
+
* @param threshold - The force threshold to set.
|
|
1134
|
+
*/
|
|
1135
|
+
setContactForceEventThreshold(threshold) {
|
|
1136
|
+
this.contactForceEventThreshold = threshold;
|
|
1137
|
+
return this;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
//# sourceMappingURL=collider.js.map
|