@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,271 @@
|
|
|
1
|
+
import { RawQueryPipeline } from "../raw";
|
|
2
|
+
import { PointColliderProjection, RayColliderIntersection, RayColliderToi, ShapeColliderTOI, } from "../geometry";
|
|
3
|
+
import { RotationOps, VectorOps } from "../math";
|
|
4
|
+
// NOTE: must match the bits in the QueryFilterFlags on the Rust side.
|
|
5
|
+
/**
|
|
6
|
+
* Flags for excluding whole sets of colliders from a scene query.
|
|
7
|
+
*/
|
|
8
|
+
export var QueryFilterFlags;
|
|
9
|
+
(function (QueryFilterFlags) {
|
|
10
|
+
/**
|
|
11
|
+
* Exclude from the query any collider attached to a fixed rigid-body and colliders with no rigid-body attached.
|
|
12
|
+
*/
|
|
13
|
+
QueryFilterFlags[QueryFilterFlags["EXCLUDE_FIXED"] = 1] = "EXCLUDE_FIXED";
|
|
14
|
+
/**
|
|
15
|
+
* Exclude from the query any collider attached to a dynamic rigid-body.
|
|
16
|
+
*/
|
|
17
|
+
QueryFilterFlags[QueryFilterFlags["EXCLUDE_KINEMATIC"] = 2] = "EXCLUDE_KINEMATIC";
|
|
18
|
+
/**
|
|
19
|
+
* Exclude from the query any collider attached to a kinematic rigid-body.
|
|
20
|
+
*/
|
|
21
|
+
QueryFilterFlags[QueryFilterFlags["EXCLUDE_DYNAMIC"] = 4] = "EXCLUDE_DYNAMIC";
|
|
22
|
+
/**
|
|
23
|
+
* Exclude from the query any collider that is a sensor.
|
|
24
|
+
*/
|
|
25
|
+
QueryFilterFlags[QueryFilterFlags["EXCLUDE_SENSORS"] = 8] = "EXCLUDE_SENSORS";
|
|
26
|
+
/**
|
|
27
|
+
* Exclude from the query any collider that is not a sensor.
|
|
28
|
+
*/
|
|
29
|
+
QueryFilterFlags[QueryFilterFlags["EXCLUDE_SOLIDS"] = 16] = "EXCLUDE_SOLIDS";
|
|
30
|
+
/**
|
|
31
|
+
* Excludes all colliders not attached to a dynamic rigid-body.
|
|
32
|
+
*/
|
|
33
|
+
QueryFilterFlags[QueryFilterFlags["ONLY_DYNAMIC"] = 3] = "ONLY_DYNAMIC";
|
|
34
|
+
/**
|
|
35
|
+
* Excludes all colliders not attached to a kinematic rigid-body.
|
|
36
|
+
*/
|
|
37
|
+
QueryFilterFlags[QueryFilterFlags["ONLY_KINEMATIC"] = 5] = "ONLY_KINEMATIC";
|
|
38
|
+
/**
|
|
39
|
+
* Exclude all colliders attached to a non-fixed rigid-body
|
|
40
|
+
* (this will not exclude colliders not attached to any rigid-body).
|
|
41
|
+
*/
|
|
42
|
+
QueryFilterFlags[QueryFilterFlags["ONLY_FIXED"] = 6] = "ONLY_FIXED";
|
|
43
|
+
})(QueryFilterFlags || (QueryFilterFlags = {}));
|
|
44
|
+
/**
|
|
45
|
+
* A pipeline for performing queries on all the colliders of a scene.
|
|
46
|
+
*
|
|
47
|
+
* To avoid leaking WASM resources, this MUST be freed manually with `queryPipeline.free()`
|
|
48
|
+
* once you are done using it (and all the rigid-bodies it created).
|
|
49
|
+
*/
|
|
50
|
+
export class QueryPipeline {
|
|
51
|
+
/**
|
|
52
|
+
* Release the WASM memory occupied by this query pipeline.
|
|
53
|
+
*/
|
|
54
|
+
free() {
|
|
55
|
+
if (!!this.raw) {
|
|
56
|
+
this.raw.free();
|
|
57
|
+
}
|
|
58
|
+
this.raw = undefined;
|
|
59
|
+
}
|
|
60
|
+
constructor(raw) {
|
|
61
|
+
this.raw = raw || new RawQueryPipeline();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Updates the acceleration structure of the query pipeline.
|
|
65
|
+
* @param bodies - The set of rigid-bodies taking part in this pipeline.
|
|
66
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
67
|
+
*/
|
|
68
|
+
update(bodies, colliders) {
|
|
69
|
+
this.raw.update(bodies.raw, colliders.raw);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Find the closest intersection between a ray and a set of collider.
|
|
73
|
+
*
|
|
74
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
75
|
+
* @param ray - The ray to cast.
|
|
76
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
77
|
+
* limits the length of the ray to `ray.dir.norm() * maxToi`.
|
|
78
|
+
* @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
|
|
79
|
+
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
|
|
80
|
+
* whereas `false` implies that all shapes are hollow for this ray-cast.
|
|
81
|
+
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
|
|
82
|
+
* @param filter - The callback to filter out which collider will be hit.
|
|
83
|
+
*/
|
|
84
|
+
castRay(bodies, colliders, ray, maxToi, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
85
|
+
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
86
|
+
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
87
|
+
let result = RayColliderToi.fromRaw(colliders, this.raw.castRay(bodies.raw, colliders.raw, rawOrig, rawDir, maxToi, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
88
|
+
rawOrig.free();
|
|
89
|
+
rawDir.free();
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Find the closest intersection between a ray and a set of collider.
|
|
94
|
+
*
|
|
95
|
+
* This also computes the normal at the hit point.
|
|
96
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
97
|
+
* @param ray - The ray to cast.
|
|
98
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
99
|
+
* limits the length of the ray to `ray.dir.norm() * maxToi`.
|
|
100
|
+
* @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
|
|
101
|
+
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
|
|
102
|
+
* whereas `false` implies that all shapes are hollow for this ray-cast.
|
|
103
|
+
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
|
|
104
|
+
*/
|
|
105
|
+
castRayAndGetNormal(bodies, colliders, ray, maxToi, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
106
|
+
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
107
|
+
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
108
|
+
let result = RayColliderIntersection.fromRaw(colliders, this.raw.castRayAndGetNormal(bodies.raw, colliders.raw, rawOrig, rawDir, maxToi, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
109
|
+
rawOrig.free();
|
|
110
|
+
rawDir.free();
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Cast a ray and collects all the intersections between a ray and the scene.
|
|
115
|
+
*
|
|
116
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
117
|
+
* @param ray - The ray to cast.
|
|
118
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
119
|
+
* limits the length of the ray to `ray.dir.norm() * maxToi`.
|
|
120
|
+
* @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
|
|
121
|
+
* origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
|
|
122
|
+
* whereas `false` implies that all shapes are hollow for this ray-cast.
|
|
123
|
+
* @param groups - Used to filter the colliders that can or cannot be hit by the ray.
|
|
124
|
+
* @param callback - The callback called once per hit (in no particular order) between a ray and a collider.
|
|
125
|
+
* If this callback returns `false`, then the cast will stop and no further hits will be detected/reported.
|
|
126
|
+
*/
|
|
127
|
+
intersectionsWithRay(bodies, colliders, ray, maxToi, solid, callback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
128
|
+
let rawOrig = VectorOps.intoRaw(ray.origin);
|
|
129
|
+
let rawDir = VectorOps.intoRaw(ray.dir);
|
|
130
|
+
let rawCallback = (rawInter) => {
|
|
131
|
+
return callback(RayColliderIntersection.fromRaw(colliders, rawInter));
|
|
132
|
+
};
|
|
133
|
+
this.raw.intersectionsWithRay(bodies.raw, colliders.raw, rawOrig, rawDir, maxToi, solid, rawCallback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate);
|
|
134
|
+
rawOrig.free();
|
|
135
|
+
rawDir.free();
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Gets the handle of up to one collider intersecting the given shape.
|
|
139
|
+
*
|
|
140
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
141
|
+
* @param shapePos - The position of the shape used for the intersection test.
|
|
142
|
+
* @param shapeRot - The orientation of the shape used for the intersection test.
|
|
143
|
+
* @param shape - The shape used for the intersection test.
|
|
144
|
+
* @param groups - The bit groups and filter associated to the ray, in order to only
|
|
145
|
+
* hit the colliders with collision groups compatible with the ray's group.
|
|
146
|
+
*/
|
|
147
|
+
intersectionWithShape(bodies, colliders, shapePos, shapeRot, shape, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
148
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
149
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
150
|
+
let rawShape = shape.intoRaw();
|
|
151
|
+
let result = this.raw.intersectionWithShape(bodies.raw, colliders.raw, rawPos, rawRot, rawShape, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate);
|
|
152
|
+
rawPos.free();
|
|
153
|
+
rawRot.free();
|
|
154
|
+
rawShape.free();
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Find the projection of a point on the closest collider.
|
|
159
|
+
*
|
|
160
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
161
|
+
* @param point - The point to project.
|
|
162
|
+
* @param solid - If this is set to `true` then the collider shapes are considered to
|
|
163
|
+
* be plain (if the point is located inside of a plain shape, its projection is the point
|
|
164
|
+
* itself). If it is set to `false` the collider shapes are considered to be hollow
|
|
165
|
+
* (if the point is located inside of an hollow shape, it is projected on the shape's
|
|
166
|
+
* boundary).
|
|
167
|
+
* @param groups - The bit groups and filter associated to the point to project, in order to only
|
|
168
|
+
* project on colliders with collision groups compatible with the ray's group.
|
|
169
|
+
*/
|
|
170
|
+
projectPoint(bodies, colliders, point, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
171
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
172
|
+
let result = PointColliderProjection.fromRaw(colliders, this.raw.projectPoint(bodies.raw, colliders.raw, rawPoint, solid, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
173
|
+
rawPoint.free();
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Find the projection of a point on the closest collider.
|
|
178
|
+
*
|
|
179
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
180
|
+
* @param point - The point to project.
|
|
181
|
+
* @param groups - The bit groups and filter associated to the point to project, in order to only
|
|
182
|
+
* project on colliders with collision groups compatible with the ray's group.
|
|
183
|
+
*/
|
|
184
|
+
projectPointAndGetFeature(bodies, colliders, point, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
185
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
186
|
+
let result = PointColliderProjection.fromRaw(colliders, this.raw.projectPointAndGetFeature(bodies.raw, colliders.raw, rawPoint, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
187
|
+
rawPoint.free();
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Find all the colliders containing the given point.
|
|
192
|
+
*
|
|
193
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
194
|
+
* @param point - The point used for the containment test.
|
|
195
|
+
* @param groups - The bit groups and filter associated to the point to test, in order to only
|
|
196
|
+
* test on colliders with collision groups compatible with the ray's group.
|
|
197
|
+
* @param callback - A function called with the handles of each collider with a shape
|
|
198
|
+
* containing the `point`.
|
|
199
|
+
*/
|
|
200
|
+
intersectionsWithPoint(bodies, colliders, point, callback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
201
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
202
|
+
this.raw.intersectionsWithPoint(bodies.raw, colliders.raw, rawPoint, callback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate);
|
|
203
|
+
rawPoint.free();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Casts a shape at a constant linear velocity and retrieve the first collider it hits.
|
|
207
|
+
* This is similar to ray-casting except that we are casting a whole shape instead of
|
|
208
|
+
* just a point (the ray origin).
|
|
209
|
+
*
|
|
210
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
211
|
+
* @param shapePos - The initial position of the shape to cast.
|
|
212
|
+
* @param shapeRot - The initial rotation of the shape to cast.
|
|
213
|
+
* @param shapeVel - The constant velocity of the shape to cast (i.e. the cast direction).
|
|
214
|
+
* @param shape - The shape to cast.
|
|
215
|
+
* @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
|
|
216
|
+
* limits the distance traveled by the shape to `shapeVel.norm() * maxToi`.
|
|
217
|
+
* @param stopAtPenetration - If set to `false`, the linear shape-cast won’t immediately stop if
|
|
218
|
+
* the shape is penetrating another shape at its starting point **and** its trajectory is such
|
|
219
|
+
* that it’s on a path to exist that penetration state.
|
|
220
|
+
* @param groups - The bit groups and filter associated to the shape to cast, in order to only
|
|
221
|
+
* test on colliders with collision groups compatible with this group.
|
|
222
|
+
*/
|
|
223
|
+
castShape(bodies, colliders, shapePos, shapeRot, shapeVel, shape, maxToi, stopAtPenetration, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
224
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
225
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
226
|
+
let rawVel = VectorOps.intoRaw(shapeVel);
|
|
227
|
+
let rawShape = shape.intoRaw();
|
|
228
|
+
let result = ShapeColliderTOI.fromRaw(colliders, this.raw.castShape(bodies.raw, colliders.raw, rawPos, rawRot, rawVel, rawShape, maxToi, stopAtPenetration, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate));
|
|
229
|
+
rawPos.free();
|
|
230
|
+
rawRot.free();
|
|
231
|
+
rawVel.free();
|
|
232
|
+
rawShape.free();
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Retrieve all the colliders intersecting the given shape.
|
|
237
|
+
*
|
|
238
|
+
* @param colliders - The set of colliders taking part in this pipeline.
|
|
239
|
+
* @param shapePos - The position of the shape to test.
|
|
240
|
+
* @param shapeRot - The orientation of the shape to test.
|
|
241
|
+
* @param shape - The shape to test.
|
|
242
|
+
* @param groups - The bit groups and filter associated to the shape to test, in order to only
|
|
243
|
+
* test on colliders with collision groups compatible with this group.
|
|
244
|
+
* @param callback - A function called with the handles of each collider intersecting the `shape`.
|
|
245
|
+
*/
|
|
246
|
+
intersectionsWithShape(bodies, colliders, shapePos, shapeRot, shape, callback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate) {
|
|
247
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
248
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
249
|
+
let rawShape = shape.intoRaw();
|
|
250
|
+
this.raw.intersectionsWithShape(bodies.raw, colliders.raw, rawPos, rawRot, rawShape, callback, filterFlags, filterGroups, filterExcludeCollider, filterExcludeRigidBody, filterPredicate);
|
|
251
|
+
rawPos.free();
|
|
252
|
+
rawRot.free();
|
|
253
|
+
rawShape.free();
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Finds the handles of all the colliders with an AABB intersecting the given AABB.
|
|
257
|
+
*
|
|
258
|
+
* @param aabbCenter - The center of the AABB to test.
|
|
259
|
+
* @param aabbHalfExtents - The half-extents of the AABB to test.
|
|
260
|
+
* @param callback - The callback that will be called with the handles of all the colliders
|
|
261
|
+
* currently intersecting the given AABB.
|
|
262
|
+
*/
|
|
263
|
+
collidersWithAabbIntersectingAabb(aabbCenter, aabbHalfExtents, callback) {
|
|
264
|
+
let rawCenter = VectorOps.intoRaw(aabbCenter);
|
|
265
|
+
let rawHalfExtents = VectorOps.intoRaw(aabbHalfExtents);
|
|
266
|
+
this.raw.collidersWithAabbIntersectingAabb(rawCenter, rawHalfExtents, callback);
|
|
267
|
+
rawCenter.free();
|
|
268
|
+
rawHalfExtents.free();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=query_pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query_pipeline.js","sourceRoot":"","sources":["../src/pipeline/query_pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAA6B,MAAM,QAAQ,CAAC;AACpE,OAAO,EAIH,uBAAuB,EAEvB,uBAAuB,EACvB,cAAc,EAEd,gBAAgB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAW,WAAW,EAAU,SAAS,EAAC,MAAM,SAAS,CAAC;AAEjE,sEAAsE;AACtE;;GAEG;AACH,MAAM,CAAN,IAAY,gBAqCX;AArCD,WAAY,gBAAgB;IACxB;;OAEG;IACH,yEAA2B,CAAA;IAC3B;;OAEG;IACH,iFAA+B,CAAA;IAC/B;;OAEG;IACH,6EAA6B,CAAA;IAC7B;;OAEG;IACH,6EAA6B,CAAA;IAC7B;;OAEG;IACH,4EAA4B,CAAA;IAC5B;;OAEG;IACH,uEACsC,CAAA;IACtC;;OAEG;IACH,2EACkC,CAAA;IAClC;;;OAGG;IACH,mEACsC,CAAA;AAC1C,CAAC,EArCW,gBAAgB,KAAhB,gBAAgB,QAqC3B;AAED;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAGtB;;OAEG;IACH,IAAI;QACA,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACnB;QACD,IAAI,CAAC,GAAG,GAAG,SA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X,YAAY,EACZ,qBAAqB,EACrB,sBAAsB,EACtB,eAAe,CAClB,CAAC;QAEF,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,MAAM,CAAC,IAAI,EAAE,CAAC;QACd,QAAQ,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IAED;;;;;;;OAOG;IACI,iCAAiC,CACpC,UAAkB,EAClB,eAAuB,EACvB,QAA6C;QAE7C,IAAI,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC9C,IAAI,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACxD,IAAI,CAAC,GAAG,CAAC,iCAAiC,CACtC,SAAS,EACT,cAAc,EACd,QAAQ,CACX,CAAC;QACF,SAAS,CAAC,IAAI,EAAE,CAAC;QACjB,cAAc,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RawSerializationPipeline } from "../raw";
|
|
2
|
+
import { Vector } from "../math";
|
|
3
|
+
import { IntegrationParameters, IslandManager, ImpulseJointSet, MultibodyJointSet, RigidBodySet } from "../dynamics";
|
|
4
|
+
import { BroadPhase, ColliderSet, NarrowPhase } from "../geometry";
|
|
5
|
+
import { World } from "./world";
|
|
6
|
+
/**
|
|
7
|
+
* A pipeline for serializing the physics scene.
|
|
8
|
+
*
|
|
9
|
+
* To avoid leaking WASM resources, this MUST be freed manually with `queryPipeline.free()`
|
|
10
|
+
* once you are done using it (and all the rigid-bodies it created).
|
|
11
|
+
*/
|
|
12
|
+
export declare class SerializationPipeline {
|
|
13
|
+
raw: RawSerializationPipeline;
|
|
14
|
+
/**
|
|
15
|
+
* Release the WASM memory occupied by this serialization pipeline.
|
|
16
|
+
*/
|
|
17
|
+
free(): void;
|
|
18
|
+
constructor(raw?: RawSerializationPipeline);
|
|
19
|
+
/**
|
|
20
|
+
* Serialize a complete physics state into a single byte array.
|
|
21
|
+
* @param gravity - The current gravity affecting the simulation.
|
|
22
|
+
* @param integrationParameters - The integration parameters of the simulation.
|
|
23
|
+
* @param broadPhase - The broad-phase of the simulation.
|
|
24
|
+
* @param narrowPhase - The narrow-phase of the simulation.
|
|
25
|
+
* @param bodies - The rigid-bodies taking part into the simulation.
|
|
26
|
+
* @param colliders - The colliders taking part into the simulation.
|
|
27
|
+
* @param impulseJoints - The impulse joints taking part into the simulation.
|
|
28
|
+
* @param multibodyJoints - The multibody joints taking part into the simulation.
|
|
29
|
+
*/
|
|
30
|
+
serializeAll(gravity: Vector, integrationParameters: IntegrationParameters, islands: IslandManager, broadPhase: BroadPhase, narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, impulseJoints: ImpulseJointSet, multibodyJoints: MultibodyJointSet): Uint8Array;
|
|
31
|
+
/**
|
|
32
|
+
* Deserialize the complete physics state from a single byte array.
|
|
33
|
+
*
|
|
34
|
+
* @param data - The byte array to deserialize.
|
|
35
|
+
*/
|
|
36
|
+
deserializeAll(data: Uint8Array): World;
|
|
37
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RawSerializationPipeline } from "../raw";
|
|
2
|
+
import { VectorOps } from "../math";
|
|
3
|
+
import { World } from "./world";
|
|
4
|
+
/**
|
|
5
|
+
* A pipeline for serializing the physics scene.
|
|
6
|
+
*
|
|
7
|
+
* To avoid leaking WASM resources, this MUST be freed manually with `queryPipeline.free()`
|
|
8
|
+
* once you are done using it (and all the rigid-bodies it created).
|
|
9
|
+
*/
|
|
10
|
+
export class SerializationPipeline {
|
|
11
|
+
/**
|
|
12
|
+
* Release the WASM memory occupied by this serialization pipeline.
|
|
13
|
+
*/
|
|
14
|
+
free() {
|
|
15
|
+
if (!!this.raw) {
|
|
16
|
+
this.raw.free();
|
|
17
|
+
}
|
|
18
|
+
this.raw = undefined;
|
|
19
|
+
}
|
|
20
|
+
constructor(raw) {
|
|
21
|
+
this.raw = raw || new RawSerializationPipeline();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Serialize a complete physics state into a single byte array.
|
|
25
|
+
* @param gravity - The current gravity affecting the simulation.
|
|
26
|
+
* @param integrationParameters - The integration parameters of the simulation.
|
|
27
|
+
* @param broadPhase - The broad-phase of the simulation.
|
|
28
|
+
* @param narrowPhase - The narrow-phase of the simulation.
|
|
29
|
+
* @param bodies - The rigid-bodies taking part into the simulation.
|
|
30
|
+
* @param colliders - The colliders taking part into the simulation.
|
|
31
|
+
* @param impulseJoints - The impulse joints taking part into the simulation.
|
|
32
|
+
* @param multibodyJoints - The multibody joints taking part into the simulation.
|
|
33
|
+
*/
|
|
34
|
+
serializeAll(gravity, integrationParameters, islands, broadPhase, narrowPhase, bodies, colliders, impulseJoints, multibodyJoints) {
|
|
35
|
+
let rawGra = VectorOps.intoRaw(gravity);
|
|
36
|
+
const res = this.raw.serializeAll(rawGra, integrationParameters.raw, islands.raw, broadPhase.raw, narrowPhase.raw, bodies.raw, colliders.raw, impulseJoints.raw, multibodyJoints.raw);
|
|
37
|
+
rawGra.free();
|
|
38
|
+
return res;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Deserialize the complete physics state from a single byte array.
|
|
42
|
+
*
|
|
43
|
+
* @param data - The byte array to deserialize.
|
|
44
|
+
*/
|
|
45
|
+
deserializeAll(data) {
|
|
46
|
+
return World.fromRaw(this.raw.deserializeAll(data));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=serialization_pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization_pipeline.js","sourceRoot":"","sources":["../src/pipeline/serialization_pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,EAAC,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAS,SAAS,EAAC,MAAM,SAAS,CAAC;AAS1C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B;;;;;GAKG;AACH,MAAM,OAAO,q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