@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,686 @@
|
|
|
1
|
+
import { VectorOps, RotationOps } from "../math";
|
|
2
|
+
import { RawShape } from "../raw";
|
|
3
|
+
import { ShapeContact } from "./contact";
|
|
4
|
+
import { PointProjection } from "./point";
|
|
5
|
+
import { RayIntersection } from "./ray";
|
|
6
|
+
import { ShapeTOI } from "./toi";
|
|
7
|
+
export class Shape {
|
|
8
|
+
/**
|
|
9
|
+
* instant mode without cache
|
|
10
|
+
*/
|
|
11
|
+
static fromRaw(rawSet, handle) {
|
|
12
|
+
const rawType = rawSet.coShapeType(handle);
|
|
13
|
+
let extents;
|
|
14
|
+
let borderRadius;
|
|
15
|
+
let vs;
|
|
16
|
+
let indices;
|
|
17
|
+
let halfHeight;
|
|
18
|
+
let radius;
|
|
19
|
+
let normal;
|
|
20
|
+
switch (rawType) {
|
|
21
|
+
case ShapeType.Ball:
|
|
22
|
+
return new Ball(rawSet.coRadius(handle));
|
|
23
|
+
case ShapeType.Cuboid:
|
|
24
|
+
extents = rawSet.coHalfExtents(handle);
|
|
25
|
+
// #if DIM3
|
|
26
|
+
return new Cuboid(extents.x, extents.y, extents.z);
|
|
27
|
+
// #endif
|
|
28
|
+
case ShapeType.RoundCuboid:
|
|
29
|
+
extents = rawSet.coHalfExtents(handle);
|
|
30
|
+
borderRadius = rawSet.coRoundRadius(handle);
|
|
31
|
+
// #if DIM3
|
|
32
|
+
return new RoundCuboid(extents.x, extents.y, extents.z, borderRadius);
|
|
33
|
+
// #endif
|
|
34
|
+
case ShapeType.Capsule:
|
|
35
|
+
halfHeight = rawSet.coHalfHeight(handle);
|
|
36
|
+
radius = rawSet.coRadius(handle);
|
|
37
|
+
return new Capsule(halfHeight, radius);
|
|
38
|
+
case ShapeType.Segment:
|
|
39
|
+
vs = rawSet.coVertices(handle);
|
|
40
|
+
// #if DIM3
|
|
41
|
+
return new Segment(VectorOps.new(vs[0], vs[1], vs[2]), VectorOps.new(vs[3], vs[4], vs[5]));
|
|
42
|
+
// #endif
|
|
43
|
+
case ShapeType.Polyline:
|
|
44
|
+
vs = rawSet.coVertices(handle);
|
|
45
|
+
indices = rawSet.coIndices(handle);
|
|
46
|
+
return new Polyline(vs, indices);
|
|
47
|
+
case ShapeType.Triangle:
|
|
48
|
+
vs = rawSet.coVertices(handle);
|
|
49
|
+
// #if DIM3
|
|
50
|
+
return new Triangle(VectorOps.new(vs[0], vs[1], vs[2]), VectorOps.new(vs[3], vs[4], vs[5]), VectorOps.new(vs[6], vs[7], vs[8]));
|
|
51
|
+
// #endif
|
|
52
|
+
case ShapeType.RoundTriangle:
|
|
53
|
+
vs = rawSet.coVertices(handle);
|
|
54
|
+
borderRadius = rawSet.coRoundRadius(handle);
|
|
55
|
+
// #if DIM3
|
|
56
|
+
return new RoundTriangle(VectorOps.new(vs[0], vs[1], vs[2]), VectorOps.new(vs[3], vs[4], vs[5]), VectorOps.new(vs[6], vs[7], vs[8]), borderRadius);
|
|
57
|
+
// #endif
|
|
58
|
+
case ShapeType.HalfSpace:
|
|
59
|
+
normal = VectorOps.fromRaw(rawSet.coHalfspaceNormal(handle));
|
|
60
|
+
return new HalfSpace(normal);
|
|
61
|
+
case ShapeType.TriMesh:
|
|
62
|
+
vs = rawSet.coVertices(handle);
|
|
63
|
+
indices = rawSet.coIndices(handle);
|
|
64
|
+
return new TriMesh(vs, indices);
|
|
65
|
+
case ShapeType.HeightField:
|
|
66
|
+
const scale = rawSet.coHeightfieldScale(handle);
|
|
67
|
+
const heights = rawSet.coHeightfieldHeights(handle);
|
|
68
|
+
// #if DIM3
|
|
69
|
+
const nrows = rawSet.coHeightfieldNRows(handle);
|
|
70
|
+
const ncols = rawSet.coHeightfieldNCols(handle);
|
|
71
|
+
return new Heightfield(nrows, ncols, heights, scale);
|
|
72
|
+
// #endif
|
|
73
|
+
// #if DIM3
|
|
74
|
+
case ShapeType.ConvexPolyhedron:
|
|
75
|
+
vs = rawSet.coVertices(handle);
|
|
76
|
+
indices = rawSet.coIndices(handle);
|
|
77
|
+
return new ConvexPolyhedron(vs, indices);
|
|
78
|
+
case ShapeType.RoundConvexPolyhedron:
|
|
79
|
+
vs = rawSet.coVertices(handle);
|
|
80
|
+
indices = rawSet.coIndices(handle);
|
|
81
|
+
borderRadius = rawSet.coRoundRadius(handle);
|
|
82
|
+
return new RoundConvexPolyhedron(vs, indices, borderRadius);
|
|
83
|
+
case ShapeType.Cylinder:
|
|
84
|
+
halfHeight = rawSet.coHalfHeight(handle);
|
|
85
|
+
radius = rawSet.coRadius(handle);
|
|
86
|
+
return new Cylinder(halfHeight, radius);
|
|
87
|
+
case ShapeType.RoundCylinder:
|
|
88
|
+
halfHeight = rawSet.coHalfHeight(handle);
|
|
89
|
+
radius = rawSet.coRadius(handle);
|
|
90
|
+
borderRadius = rawSet.coRoundRadius(handle);
|
|
91
|
+
return new RoundCylinder(halfHeight, radius, borderRadius);
|
|
92
|
+
case ShapeType.Cone:
|
|
93
|
+
halfHeight = rawSet.coHalfHeight(handle);
|
|
94
|
+
radius = rawSet.coRadius(handle);
|
|
95
|
+
return new Cone(halfHeight, radius);
|
|
96
|
+
case ShapeType.RoundCone:
|
|
97
|
+
halfHeight = rawSet.coHalfHeight(handle);
|
|
98
|
+
radius = rawSet.coRadius(handle);
|
|
99
|
+
borderRadius = rawSet.coRoundRadius(handle);
|
|
100
|
+
return new RoundCone(halfHeight, radius, borderRadius);
|
|
101
|
+
// #endif
|
|
102
|
+
default:
|
|
103
|
+
throw new Error("unknown shape type: " + rawType);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Computes the time of impact between two moving shapes.
|
|
108
|
+
* @param shapePos1 - The initial position of this sahpe.
|
|
109
|
+
* @param shapeRot1 - The rotation of this shape.
|
|
110
|
+
* @param shapeVel1 - The velocity of this shape.
|
|
111
|
+
* @param shape2 - The second moving shape.
|
|
112
|
+
* @param shapePos2 - The initial position of the second shape.
|
|
113
|
+
* @param shapeRot2 - The rotation of the second shape.
|
|
114
|
+
* @param shapeVel2 - The velocity of the second shape.
|
|
115
|
+
* @param maxToi - The maximum time when the impact can happen.
|
|
116
|
+
* @param stopAtPenetration - If set to `false`, the linear shape-cast won’t immediately stop if
|
|
117
|
+
* the shape is penetrating another shape at its starting point **and** its trajectory is such
|
|
118
|
+
* that it’s on a path to exist that penetration state.
|
|
119
|
+
* @returns If the two moving shapes collider at some point along their trajectories, this returns the
|
|
120
|
+
* time at which the two shape collider as well as the contact information during the impact. Returns
|
|
121
|
+
* `null`if the two shapes never collide along their paths.
|
|
122
|
+
*/
|
|
123
|
+
castShape(shapePos1, shapeRot1, shapeVel1, shape2, shapePos2, shapeRot2, shapeVel2, maxToi, stopAtPenetration) {
|
|
124
|
+
let rawPos1 = VectorOps.intoRaw(shapePos1);
|
|
125
|
+
let rawRot1 = RotationOps.intoRaw(shapeRot1);
|
|
126
|
+
let rawVel1 = VectorOps.intoRaw(shapeVel1);
|
|
127
|
+
let rawPos2 = VectorOps.intoRaw(shapePos2);
|
|
128
|
+
let rawRot2 = RotationOps.intoRaw(shapeRot2);
|
|
129
|
+
let rawVel2 = VectorOps.intoRaw(shapeVel2);
|
|
130
|
+
let rawShape1 = this.intoRaw();
|
|
131
|
+
let rawShape2 = shape2.intoRaw();
|
|
132
|
+
let result = ShapeTOI.fromRaw(null, rawShape1.castShape(rawPos1, rawRot1, rawVel1, rawShape2, rawPos2, rawRot2, rawVel2, maxToi, stopAtPenetration));
|
|
133
|
+
rawPos1.free();
|
|
134
|
+
rawRot1.free();
|
|
135
|
+
rawVel1.free();
|
|
136
|
+
rawPos2.free();
|
|
137
|
+
rawRot2.free();
|
|
138
|
+
rawVel2.free();
|
|
139
|
+
rawShape1.free();
|
|
140
|
+
rawShape2.free();
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Tests if this shape intersects another shape.
|
|
145
|
+
*
|
|
146
|
+
* @param shapePos1 - The position of this shape.
|
|
147
|
+
* @param shapeRot1 - The rotation of this shape.
|
|
148
|
+
* @param shape2 - The second shape to test.
|
|
149
|
+
* @param shapePos2 - The position of the second shape.
|
|
150
|
+
* @param shapeRot2 - The rotation of the second shape.
|
|
151
|
+
* @returns `true` if the two shapes intersect, `false` if they don’t.
|
|
152
|
+
*/
|
|
153
|
+
intersectsShape(shapePos1, shapeRot1, shape2, shapePos2, shapeRot2) {
|
|
154
|
+
let rawPos1 = VectorOps.intoRaw(shapePos1);
|
|
155
|
+
let rawRot1 = RotationOps.intoRaw(shapeRot1);
|
|
156
|
+
let rawPos2 = VectorOps.intoRaw(shapePos2);
|
|
157
|
+
let rawRot2 = RotationOps.intoRaw(shapeRot2);
|
|
158
|
+
let rawShape1 = this.intoRaw();
|
|
159
|
+
let rawShape2 = shape2.intoRaw();
|
|
160
|
+
let result = rawShape1.intersectsShape(rawPos1, rawRot1, rawShape2, rawPos2, rawRot2);
|
|
161
|
+
rawPos1.free();
|
|
162
|
+
rawRot1.free();
|
|
163
|
+
rawPos2.free();
|
|
164
|
+
rawRot2.free();
|
|
165
|
+
rawShape1.free();
|
|
166
|
+
rawShape2.free();
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Computes one pair of contact points between two shapes.
|
|
171
|
+
*
|
|
172
|
+
* @param shapePos1 - The initial position of this sahpe.
|
|
173
|
+
* @param shapeRot1 - The rotation of this shape.
|
|
174
|
+
* @param shape2 - The second shape.
|
|
175
|
+
* @param shapePos2 - The initial position of the second shape.
|
|
176
|
+
* @param shapeRot2 - The rotation of the second shape.
|
|
177
|
+
* @param prediction - The prediction value, if the shapes are separated by a distance greater than this value, test will fail.
|
|
178
|
+
* @returns `null` if the shapes are separated by a distance greater than prediction, otherwise contact details. The result is given in world-space.
|
|
179
|
+
*/
|
|
180
|
+
contactShape(shapePos1, shapeRot1, shape2, shapePos2, shapeRot2, prediction) {
|
|
181
|
+
let rawPos1 = VectorOps.intoRaw(shapePos1);
|
|
182
|
+
let rawRot1 = RotationOps.intoRaw(shapeRot1);
|
|
183
|
+
let rawPos2 = VectorOps.intoRaw(shapePos2);
|
|
184
|
+
let rawRot2 = RotationOps.intoRaw(shapeRot2);
|
|
185
|
+
let rawShape1 = this.intoRaw();
|
|
186
|
+
let rawShape2 = shape2.intoRaw();
|
|
187
|
+
let result = ShapeContact.fromRaw(rawShape1.contactShape(rawPos1, rawRot1, rawShape2, rawPos2, rawRot2, prediction));
|
|
188
|
+
rawPos1.free();
|
|
189
|
+
rawRot1.free();
|
|
190
|
+
rawPos2.free();
|
|
191
|
+
rawRot2.free();
|
|
192
|
+
rawShape1.free();
|
|
193
|
+
rawShape2.free();
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
containsPoint(shapePos, shapeRot, point) {
|
|
197
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
198
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
199
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
200
|
+
let rawShape = this.intoRaw();
|
|
201
|
+
let result = rawShape.containsPoint(rawPos, rawRot, rawPoint);
|
|
202
|
+
rawPos.free();
|
|
203
|
+
rawRot.free();
|
|
204
|
+
rawPoint.free();
|
|
205
|
+
rawShape.free();
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
projectPoint(shapePos, shapeRot, point, solid) {
|
|
209
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
210
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
211
|
+
let rawPoint = VectorOps.intoRaw(point);
|
|
212
|
+
let rawShape = this.intoRaw();
|
|
213
|
+
let result = PointProjection.fromRaw(rawShape.projectPoint(rawPos, rawRot, rawPoint, solid));
|
|
214
|
+
rawPos.free();
|
|
215
|
+
rawRot.free();
|
|
216
|
+
rawPoint.free();
|
|
217
|
+
rawShape.free();
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
intersectsRay(ray, shapePos, shapeRot, maxToi) {
|
|
221
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
222
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
223
|
+
let rawRayOrig = VectorOps.intoRaw(ray.origin);
|
|
224
|
+
let rawRayDir = VectorOps.intoRaw(ray.dir);
|
|
225
|
+
let rawShape = this.intoRaw();
|
|
226
|
+
let result = rawShape.intersectsRay(rawPos, rawRot, rawRayOrig, rawRayDir, maxToi);
|
|
227
|
+
rawPos.free();
|
|
228
|
+
rawRot.free();
|
|
229
|
+
rawRayOrig.free();
|
|
230
|
+
rawRayDir.free();
|
|
231
|
+
rawShape.free();
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
castRay(ray, shapePos, shapeRot, maxToi, solid) {
|
|
235
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
236
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
237
|
+
let rawRayOrig = VectorOps.intoRaw(ray.origin);
|
|
238
|
+
let rawRayDir = VectorOps.intoRaw(ray.dir);
|
|
239
|
+
let rawShape = this.intoRaw();
|
|
240
|
+
let result = rawShape.castRay(rawPos, rawRot, rawRayOrig, rawRayDir, maxToi, solid);
|
|
241
|
+
rawPos.free();
|
|
242
|
+
rawRot.free();
|
|
243
|
+
rawRayOrig.free();
|
|
244
|
+
rawRayDir.free();
|
|
245
|
+
rawShape.free();
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
248
|
+
castRayAndGetNormal(ray, shapePos, shapeRot, maxToi, solid) {
|
|
249
|
+
let rawPos = VectorOps.intoRaw(shapePos);
|
|
250
|
+
let rawRot = RotationOps.intoRaw(shapeRot);
|
|
251
|
+
let rawRayOrig = VectorOps.intoRaw(ray.origin);
|
|
252
|
+
let rawRayDir = VectorOps.intoRaw(ray.dir);
|
|
253
|
+
let rawShape = this.intoRaw();
|
|
254
|
+
let result = RayIntersection.fromRaw(rawShape.castRayAndGetNormal(rawPos, rawRot, rawRayOrig, rawRayDir, maxToi, solid));
|
|
255
|
+
rawPos.free();
|
|
256
|
+
rawRot.free();
|
|
257
|
+
rawRayOrig.free();
|
|
258
|
+
rawRayDir.free();
|
|
259
|
+
rawShape.free();
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
// #if DIM3
|
|
264
|
+
/**
|
|
265
|
+
* An enumeration representing the type of a shape.
|
|
266
|
+
*/
|
|
267
|
+
export var ShapeType;
|
|
268
|
+
(function (ShapeType) {
|
|
269
|
+
ShapeType[ShapeType["Ball"] = 0] = "Ball";
|
|
270
|
+
ShapeType[ShapeType["Cuboid"] = 1] = "Cuboid";
|
|
271
|
+
ShapeType[ShapeType["Capsule"] = 2] = "Capsule";
|
|
272
|
+
ShapeType[ShapeType["Segment"] = 3] = "Segment";
|
|
273
|
+
ShapeType[ShapeType["Polyline"] = 4] = "Polyline";
|
|
274
|
+
ShapeType[ShapeType["Triangle"] = 5] = "Triangle";
|
|
275
|
+
ShapeType[ShapeType["TriMesh"] = 6] = "TriMesh";
|
|
276
|
+
ShapeType[ShapeType["HeightField"] = 7] = "HeightField";
|
|
277
|
+
// Compound = 8,
|
|
278
|
+
ShapeType[ShapeType["ConvexPolyhedron"] = 9] = "ConvexPolyhedron";
|
|
279
|
+
ShapeType[ShapeType["Cylinder"] = 10] = "Cylinder";
|
|
280
|
+
ShapeType[ShapeType["Cone"] = 11] = "Cone";
|
|
281
|
+
ShapeType[ShapeType["RoundCuboid"] = 12] = "RoundCuboid";
|
|
282
|
+
ShapeType[ShapeType["RoundTriangle"] = 13] = "RoundTriangle";
|
|
283
|
+
ShapeType[ShapeType["RoundCylinder"] = 14] = "RoundCylinder";
|
|
284
|
+
ShapeType[ShapeType["RoundCone"] = 15] = "RoundCone";
|
|
285
|
+
ShapeType[ShapeType["RoundConvexPolyhedron"] = 16] = "RoundConvexPolyhedron";
|
|
286
|
+
ShapeType[ShapeType["HalfSpace"] = 17] = "HalfSpace";
|
|
287
|
+
})(ShapeType || (ShapeType = {}));
|
|
288
|
+
// #endif
|
|
289
|
+
/**
|
|
290
|
+
* A shape that is a sphere in 3D and a circle in 2D.
|
|
291
|
+
*/
|
|
292
|
+
export class Ball extends Shape {
|
|
293
|
+
/**
|
|
294
|
+
* Creates a new ball with the given radius.
|
|
295
|
+
* @param radius - The balls radius.
|
|
296
|
+
*/
|
|
297
|
+
constructor(radius) {
|
|
298
|
+
super();
|
|
299
|
+
this.type = ShapeType.Ball;
|
|
300
|
+
this.radius = radius;
|
|
301
|
+
}
|
|
302
|
+
intoRaw() {
|
|
303
|
+
return RawShape.ball(this.radius);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
export class HalfSpace extends Shape {
|
|
307
|
+
/**
|
|
308
|
+
* Creates a new halfspace delimited by an infinite plane.
|
|
309
|
+
*
|
|
310
|
+
* @param normal - The outward normal of the plane.
|
|
311
|
+
*/
|
|
312
|
+
constructor(normal) {
|
|
313
|
+
super();
|
|
314
|
+
this.type = ShapeType.HalfSpace;
|
|
315
|
+
this.normal = normal;
|
|
316
|
+
}
|
|
317
|
+
intoRaw() {
|
|
318
|
+
let n = VectorOps.intoRaw(this.normal);
|
|
319
|
+
let result = RawShape.halfspace(n);
|
|
320
|
+
n.free();
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* A shape that is a box in 3D and a rectangle in 2D.
|
|
326
|
+
*/
|
|
327
|
+
export class Cuboid extends Shape {
|
|
328
|
+
// #if DIM3
|
|
329
|
+
/**
|
|
330
|
+
* Creates a new 3D cuboid.
|
|
331
|
+
* @param hx - The half width of the cuboid.
|
|
332
|
+
* @param hy - The half height of the cuboid.
|
|
333
|
+
* @param hz - The half depth of the cuboid.
|
|
334
|
+
*/
|
|
335
|
+
constructor(hx, hy, hz) {
|
|
336
|
+
super();
|
|
337
|
+
this.type = ShapeType.Cuboid;
|
|
338
|
+
this.halfExtents = VectorOps.new(hx, hy, hz);
|
|
339
|
+
}
|
|
340
|
+
// #endif
|
|
341
|
+
intoRaw() {
|
|
342
|
+
// #if DIM3
|
|
343
|
+
return RawShape.cuboid(this.halfExtents.x, this.halfExtents.y, this.halfExtents.z);
|
|
344
|
+
// #endif
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* A shape that is a box in 3D and a rectangle in 2D, with round corners.
|
|
349
|
+
*/
|
|
350
|
+
export class RoundCuboid extends Shape {
|
|
351
|
+
// #if DIM3
|
|
352
|
+
/**
|
|
353
|
+
* Creates a new 3D cuboid.
|
|
354
|
+
* @param hx - The half width of the cuboid.
|
|
355
|
+
* @param hy - The half height of the cuboid.
|
|
356
|
+
* @param hz - The half depth of the cuboid.
|
|
357
|
+
* @param borderRadius - The radius of the borders of this cuboid. This will
|
|
358
|
+
* effectively increase the half-extents of the cuboid by this radius.
|
|
359
|
+
*/
|
|
360
|
+
constructor(hx, hy, hz, borderRadius) {
|
|
361
|
+
super();
|
|
362
|
+
this.type = ShapeType.RoundCuboid;
|
|
363
|
+
this.halfExtents = VectorOps.new(hx, hy, hz);
|
|
364
|
+
this.borderRadius = borderRadius;
|
|
365
|
+
}
|
|
366
|
+
// #endif
|
|
367
|
+
intoRaw() {
|
|
368
|
+
// #if DIM3
|
|
369
|
+
return RawShape.roundCuboid(this.halfExtents.x, this.halfExtents.y, this.halfExtents.z, this.borderRadius);
|
|
370
|
+
// #endif
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* A shape that is a capsule.
|
|
375
|
+
*/
|
|
376
|
+
export class Capsule extends Shape {
|
|
377
|
+
/**
|
|
378
|
+
* Creates a new capsule with the given radius and half-height.
|
|
379
|
+
* @param halfHeight - The balls half-height along the `y` axis.
|
|
380
|
+
* @param radius - The balls radius.
|
|
381
|
+
*/
|
|
382
|
+
constructor(halfHeight, radius) {
|
|
383
|
+
super();
|
|
384
|
+
this.type = ShapeType.Capsule;
|
|
385
|
+
this.halfHeight = halfHeight;
|
|
386
|
+
this.radius = radius;
|
|
387
|
+
}
|
|
388
|
+
intoRaw() {
|
|
389
|
+
return RawShape.capsule(this.halfHeight, this.radius);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* A shape that is a segment.
|
|
394
|
+
*/
|
|
395
|
+
export class Segment extends Shape {
|
|
396
|
+
/**
|
|
397
|
+
* Creates a new segment shape.
|
|
398
|
+
* @param a - The first point of the segment.
|
|
399
|
+
* @param b - The second point of the segment.
|
|
400
|
+
*/
|
|
401
|
+
constructor(a, b) {
|
|
402
|
+
super();
|
|
403
|
+
this.type = ShapeType.Segment;
|
|
404
|
+
this.a = a;
|
|
405
|
+
this.b = b;
|
|
406
|
+
}
|
|
407
|
+
intoRaw() {
|
|
408
|
+
let ra = VectorOps.intoRaw(this.a);
|
|
409
|
+
let rb = VectorOps.intoRaw(this.b);
|
|
410
|
+
let result = RawShape.segment(ra, rb);
|
|
411
|
+
ra.free();
|
|
412
|
+
rb.free();
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* A shape that is a segment.
|
|
418
|
+
*/
|
|
419
|
+
export class Triangle extends Shape {
|
|
420
|
+
/**
|
|
421
|
+
* Creates a new triangle shape.
|
|
422
|
+
*
|
|
423
|
+
* @param a - The first point of the triangle.
|
|
424
|
+
* @param b - The second point of the triangle.
|
|
425
|
+
* @param c - The third point of the triangle.
|
|
426
|
+
*/
|
|
427
|
+
constructor(a, b, c) {
|
|
428
|
+
super();
|
|
429
|
+
this.type = ShapeType.Triangle;
|
|
430
|
+
this.a = a;
|
|
431
|
+
this.b = b;
|
|
432
|
+
this.c = c;
|
|
433
|
+
}
|
|
434
|
+
intoRaw() {
|
|
435
|
+
let ra = VectorOps.intoRaw(this.a);
|
|
436
|
+
let rb = VectorOps.intoRaw(this.b);
|
|
437
|
+
let rc = VectorOps.intoRaw(this.c);
|
|
438
|
+
let result = RawShape.triangle(ra, rb, rc);
|
|
439
|
+
ra.free();
|
|
440
|
+
rb.free();
|
|
441
|
+
rc.free();
|
|
442
|
+
return result;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* A shape that is a triangle with round borders and a non-zero thickness.
|
|
447
|
+
*/
|
|
448
|
+
export class RoundTriangle extends Shape {
|
|
449
|
+
/**
|
|
450
|
+
* Creates a new triangle shape with round corners.
|
|
451
|
+
*
|
|
452
|
+
* @param a - The first point of the triangle.
|
|
453
|
+
* @param b - The second point of the triangle.
|
|
454
|
+
* @param c - The third point of the triangle.
|
|
455
|
+
* @param borderRadius - The radius of the borders of this triangle. In 3D,
|
|
456
|
+
* this is also equal to half the thickness of the triangle.
|
|
457
|
+
*/
|
|
458
|
+
constructor(a, b, c, borderRadius) {
|
|
459
|
+
super();
|
|
460
|
+
this.type = ShapeType.RoundTriangle;
|
|
461
|
+
this.a = a;
|
|
462
|
+
this.b = b;
|
|
463
|
+
this.c = c;
|
|
464
|
+
this.borderRadius = borderRadius;
|
|
465
|
+
}
|
|
466
|
+
intoRaw() {
|
|
467
|
+
let ra = VectorOps.intoRaw(this.a);
|
|
468
|
+
let rb = VectorOps.intoRaw(this.b);
|
|
469
|
+
let rc = VectorOps.intoRaw(this.c);
|
|
470
|
+
let result = RawShape.roundTriangle(ra, rb, rc, this.borderRadius);
|
|
471
|
+
ra.free();
|
|
472
|
+
rb.free();
|
|
473
|
+
rc.free();
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* A shape that is a triangle mesh.
|
|
479
|
+
*/
|
|
480
|
+
export class Polyline extends Shape {
|
|
481
|
+
/**
|
|
482
|
+
* Creates a new polyline shape.
|
|
483
|
+
*
|
|
484
|
+
* @param vertices - The coordinates of the polyline's vertices.
|
|
485
|
+
* @param indices - The indices of the polyline's segments. If this is `null` or not provided, then
|
|
486
|
+
* the vertices are assumed to form a line strip.
|
|
487
|
+
*/
|
|
488
|
+
constructor(vertices, indices) {
|
|
489
|
+
super();
|
|
490
|
+
this.type = ShapeType.Polyline;
|
|
491
|
+
this.vertices = vertices;
|
|
492
|
+
this.indices = indices !== null && indices !== void 0 ? indices : new Uint32Array(0);
|
|
493
|
+
}
|
|
494
|
+
intoRaw() {
|
|
495
|
+
return RawShape.polyline(this.vertices, this.indices);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* A shape that is a triangle mesh.
|
|
500
|
+
*/
|
|
501
|
+
export class TriMesh extends Shape {
|
|
502
|
+
/**
|
|
503
|
+
* Creates a new triangle mesh shape.
|
|
504
|
+
*
|
|
505
|
+
* @param vertices - The coordinates of the triangle mesh's vertices.
|
|
506
|
+
* @param indices - The indices of the triangle mesh's triangles.
|
|
507
|
+
*/
|
|
508
|
+
constructor(vertices, indices) {
|
|
509
|
+
super();
|
|
510
|
+
this.type = ShapeType.TriMesh;
|
|
511
|
+
this.vertices = vertices;
|
|
512
|
+
this.indices = indices;
|
|
513
|
+
}
|
|
514
|
+
intoRaw() {
|
|
515
|
+
return RawShape.trimesh(this.vertices, this.indices);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
// #if DIM3
|
|
519
|
+
/**
|
|
520
|
+
* A shape that is a convex polygon.
|
|
521
|
+
*/
|
|
522
|
+
export class ConvexPolyhedron extends Shape {
|
|
523
|
+
/**
|
|
524
|
+
* Creates a new convex polygon shape.
|
|
525
|
+
*
|
|
526
|
+
* @param vertices - The coordinates of the convex polygon's vertices.
|
|
527
|
+
* @param indices - The index buffer of this convex mesh. If this is `null`
|
|
528
|
+
* or `undefined`, the convex-hull of the input vertices will be computed
|
|
529
|
+
* automatically. Otherwise, it will be assumed that the mesh you provide
|
|
530
|
+
* is already convex.
|
|
531
|
+
*/
|
|
532
|
+
constructor(vertices, indices) {
|
|
533
|
+
super();
|
|
534
|
+
this.type = ShapeType.ConvexPolyhedron;
|
|
535
|
+
this.vertices = vertices;
|
|
536
|
+
this.indices = indices;
|
|
537
|
+
}
|
|
538
|
+
intoRaw() {
|
|
539
|
+
if (!!this.indices) {
|
|
540
|
+
return RawShape.convexMesh(this.vertices, this.indices);
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
return RawShape.convexHull(this.vertices);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* A shape that is a convex polygon.
|
|
549
|
+
*/
|
|
550
|
+
export class RoundConvexPolyhedron extends Shape {
|
|
551
|
+
/**
|
|
552
|
+
* Creates a new convex polygon shape.
|
|
553
|
+
*
|
|
554
|
+
* @param vertices - The coordinates of the convex polygon's vertices.
|
|
555
|
+
* @param indices - The index buffer of this convex mesh. If this is `null`
|
|
556
|
+
* or `undefined`, the convex-hull of the input vertices will be computed
|
|
557
|
+
* automatically. Otherwise, it will be assumed that the mesh you provide
|
|
558
|
+
* is already convex.
|
|
559
|
+
* @param borderRadius - The radius of the borders of this convex polyhedron.
|
|
560
|
+
*/
|
|
561
|
+
constructor(vertices, indices, borderRadius) {
|
|
562
|
+
super();
|
|
563
|
+
this.type = ShapeType.RoundConvexPolyhedron;
|
|
564
|
+
this.vertices = vertices;
|
|
565
|
+
this.indices = indices;
|
|
566
|
+
this.borderRadius = borderRadius;
|
|
567
|
+
}
|
|
568
|
+
intoRaw() {
|
|
569
|
+
if (!!this.indices) {
|
|
570
|
+
return RawShape.roundConvexMesh(this.vertices, this.indices, this.borderRadius);
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
return RawShape.roundConvexHull(this.vertices, this.borderRadius);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* A shape that is a heightfield.
|
|
579
|
+
*/
|
|
580
|
+
export class Heightfield extends Shape {
|
|
581
|
+
/**
|
|
582
|
+
* Creates a new heightfield shape.
|
|
583
|
+
*
|
|
584
|
+
* @param nrows − The number of rows in the heights matrix.
|
|
585
|
+
* @param ncols - The number of columns in the heights matrix.
|
|
586
|
+
* @param heights - The heights of the heightfield along its local `y` axis,
|
|
587
|
+
* provided as a matrix stored in column-major order.
|
|
588
|
+
* @param scale - The dimensions of the heightfield's local `x,z` plane.
|
|
589
|
+
*/
|
|
590
|
+
constructor(nrows, ncols, heights, scale) {
|
|
591
|
+
super();
|
|
592
|
+
this.type = ShapeType.HeightField;
|
|
593
|
+
this.nrows = nrows;
|
|
594
|
+
this.ncols = ncols;
|
|
595
|
+
this.heights = heights;
|
|
596
|
+
this.scale = scale;
|
|
597
|
+
}
|
|
598
|
+
intoRaw() {
|
|
599
|
+
let rawScale = VectorOps.intoRaw(this.scale);
|
|
600
|
+
let rawShape = RawShape.heightfield(this.nrows, this.ncols, this.heights, rawScale);
|
|
601
|
+
rawScale.free();
|
|
602
|
+
return rawShape;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* A shape that is a 3D cylinder.
|
|
607
|
+
*/
|
|
608
|
+
export class Cylinder extends Shape {
|
|
609
|
+
/**
|
|
610
|
+
* Creates a new cylinder with the given radius and half-height.
|
|
611
|
+
* @param halfHeight - The balls half-height along the `y` axis.
|
|
612
|
+
* @param radius - The balls radius.
|
|
613
|
+
*/
|
|
614
|
+
constructor(halfHeight, radius) {
|
|
615
|
+
super();
|
|
616
|
+
this.type = ShapeType.Cylinder;
|
|
617
|
+
this.halfHeight = halfHeight;
|
|
618
|
+
this.radius = radius;
|
|
619
|
+
}
|
|
620
|
+
intoRaw() {
|
|
621
|
+
return RawShape.cylinder(this.halfHeight, this.radius);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* A shape that is a 3D cylinder with round corners.
|
|
626
|
+
*/
|
|
627
|
+
export class RoundCylinder extends Shape {
|
|
628
|
+
/**
|
|
629
|
+
* Creates a new cylinder with the given radius and half-height.
|
|
630
|
+
* @param halfHeight - The balls half-height along the `y` axis.
|
|
631
|
+
* @param radius - The balls radius.
|
|
632
|
+
* @param borderRadius - The radius of the borders of this cylinder.
|
|
633
|
+
*/
|
|
634
|
+
constructor(halfHeight, radius, borderRadius) {
|
|
635
|
+
super();
|
|
636
|
+
this.type = ShapeType.RoundCylinder;
|
|
637
|
+
this.borderRadius = borderRadius;
|
|
638
|
+
this.halfHeight = halfHeight;
|
|
639
|
+
this.radius = radius;
|
|
640
|
+
}
|
|
641
|
+
intoRaw() {
|
|
642
|
+
return RawShape.roundCylinder(this.halfHeight, this.radius, this.borderRadius);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* A shape that is a 3D cone.
|
|
647
|
+
*/
|
|
648
|
+
export class Cone extends Shape {
|
|
649
|
+
/**
|
|
650
|
+
* Creates a new cone with the given radius and half-height.
|
|
651
|
+
* @param halfHeight - The balls half-height along the `y` axis.
|
|
652
|
+
* @param radius - The balls radius.
|
|
653
|
+
*/
|
|
654
|
+
constructor(halfHeight, radius) {
|
|
655
|
+
super();
|
|
656
|
+
this.type = ShapeType.Cone;
|
|
657
|
+
this.halfHeight = halfHeight;
|
|
658
|
+
this.radius = radius;
|
|
659
|
+
}
|
|
660
|
+
intoRaw() {
|
|
661
|
+
return RawShape.cone(this.halfHeight, this.radius);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* A shape that is a 3D cone with round corners.
|
|
666
|
+
*/
|
|
667
|
+
export class RoundCone extends Shape {
|
|
668
|
+
/**
|
|
669
|
+
* Creates a new cone with the given radius and half-height.
|
|
670
|
+
* @param halfHeight - The balls half-height along the `y` axis.
|
|
671
|
+
* @param radius - The balls radius.
|
|
672
|
+
* @param borderRadius - The radius of the borders of this cone.
|
|
673
|
+
*/
|
|
674
|
+
constructor(halfHeight, radius, borderRadius) {
|
|
675
|
+
super();
|
|
676
|
+
this.type = ShapeType.RoundCone;
|
|
677
|
+
this.halfHeight = halfHeight;
|
|
678
|
+
this.radius = radius;
|
|
679
|
+
this.borderRadius = borderRadius;
|
|
680
|
+
}
|
|
681
|
+
intoRaw() {
|
|
682
|
+
return RawShape.roundCone(this.halfHeight, this.radius, this.borderRadius);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
// #endif
|
|
686
|
+
//# sourceMappingURL=shape.js.map
|