@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,47 @@
|
|
|
1
|
+
import { Collider } from "./collider";
|
|
2
|
+
import { Vector } from "../math";
|
|
3
|
+
import { RawPointColliderProjection, RawPointProjection } from "../raw";
|
|
4
|
+
import { FeatureType } from "./feature";
|
|
5
|
+
import { ColliderSet } from "./collider_set";
|
|
6
|
+
/**
|
|
7
|
+
* The projection of a point on a collider.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PointProjection {
|
|
10
|
+
/**
|
|
11
|
+
* The projection of the point on the collider.
|
|
12
|
+
*/
|
|
13
|
+
point: Vector;
|
|
14
|
+
/**
|
|
15
|
+
* Is the point inside of the collider?
|
|
16
|
+
*/
|
|
17
|
+
isInside: boolean;
|
|
18
|
+
constructor(point: Vector, isInside: boolean);
|
|
19
|
+
static fromRaw(raw: RawPointProjection): PointProjection;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The projection of a point on a collider (includes the collider handle).
|
|
23
|
+
*/
|
|
24
|
+
export declare class PointColliderProjection {
|
|
25
|
+
/**
|
|
26
|
+
* The collider hit by the ray.
|
|
27
|
+
*/
|
|
28
|
+
collider: Collider;
|
|
29
|
+
/**
|
|
30
|
+
* The projection of the point on the collider.
|
|
31
|
+
*/
|
|
32
|
+
point: Vector;
|
|
33
|
+
/**
|
|
34
|
+
* Is the point inside of the collider?
|
|
35
|
+
*/
|
|
36
|
+
isInside: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The type of the geometric feature the point was projected on.
|
|
39
|
+
*/
|
|
40
|
+
featureType: FeatureType;
|
|
41
|
+
/**
|
|
42
|
+
* The id of the geometric feature the point was projected on.
|
|
43
|
+
*/
|
|
44
|
+
featureId: number | undefined;
|
|
45
|
+
constructor(collider: Collider, point: Vector, isInside: boolean, featureType?: FeatureType, featureId?: number);
|
|
46
|
+
static fromRaw(colliderSet: ColliderSet, raw: RawPointColliderProjection): PointColliderProjection;
|
|
47
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { VectorOps } from "../math";
|
|
2
|
+
import { FeatureType } from "./feature";
|
|
3
|
+
/**
|
|
4
|
+
* The projection of a point on a collider.
|
|
5
|
+
*/
|
|
6
|
+
export class PointProjection {
|
|
7
|
+
constructor(point, isInside) {
|
|
8
|
+
this.point = point;
|
|
9
|
+
this.isInside = isInside;
|
|
10
|
+
}
|
|
11
|
+
static fromRaw(raw) {
|
|
12
|
+
if (!raw)
|
|
13
|
+
return null;
|
|
14
|
+
const result = new PointProjection(VectorOps.fromRaw(raw.point()), raw.isInside());
|
|
15
|
+
raw.free();
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The projection of a point on a collider (includes the collider handle).
|
|
21
|
+
*/
|
|
22
|
+
export class PointColliderProjection {
|
|
23
|
+
constructor(collider, point, isInside, featureType, featureId) {
|
|
24
|
+
/**
|
|
25
|
+
* The type of the geometric feature the point was projected on.
|
|
26
|
+
*/
|
|
27
|
+
this.featureType = FeatureType.Unknown;
|
|
28
|
+
/**
|
|
29
|
+
* The id of the geometric feature the point was projected on.
|
|
30
|
+
*/
|
|
31
|
+
this.featureId = undefined;
|
|
32
|
+
this.collider = collider;
|
|
33
|
+
this.point = point;
|
|
34
|
+
this.isInside = isInside;
|
|
35
|
+
if (featureId !== undefined)
|
|
36
|
+
this.featureId = featureId;
|
|
37
|
+
if (featureType !== undefined)
|
|
38
|
+
this.featureType = featureType;
|
|
39
|
+
}
|
|
40
|
+
static fromRaw(colliderSet, raw) {
|
|
41
|
+
if (!raw)
|
|
42
|
+
return null;
|
|
43
|
+
const result = new PointColliderProjection(colliderSet.get(raw.colliderHandle()), VectorOps.fromRaw(raw.point()), raw.isInside(), raw.featureType(), raw.featureId());
|
|
44
|
+
raw.free();
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=point.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"point.js","sourceRoot":"","sources":["../src/geometry/point.ts"],"names":[],"mappings":"AACA,OAAO,EAAS,SAAS,EAAC,MAAM,SAAS,CAAC;AAE1C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC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C9B,GAAG,CAAC,QAAQ,EAAE,EACd,GAAG,CAAC,WAAW,EAAE,EACjB,GAAG,CAAC,SAAS,EAAE,CAClB,CAAC;QACF,GAAG,CAAC,IAAI,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Vector } from "../math";
|
|
2
|
+
import { RawRayColliderIntersection, RawRayColliderToi, RawRayIntersection } from "../raw";
|
|
3
|
+
import { Collider } from "./collider";
|
|
4
|
+
import { FeatureType } from "./feature";
|
|
5
|
+
import { ColliderSet } from "./collider_set";
|
|
6
|
+
/**
|
|
7
|
+
* A ray. This is a directed half-line.
|
|
8
|
+
*/
|
|
9
|
+
export declare class Ray {
|
|
10
|
+
/**
|
|
11
|
+
* The starting point of the ray.
|
|
12
|
+
*/
|
|
13
|
+
origin: Vector;
|
|
14
|
+
/**
|
|
15
|
+
* The direction of propagation of the ray.
|
|
16
|
+
*/
|
|
17
|
+
dir: Vector;
|
|
18
|
+
/**
|
|
19
|
+
* Builds a ray from its origin and direction.
|
|
20
|
+
*
|
|
21
|
+
* @param origin - The ray's starting point.
|
|
22
|
+
* @param dir - The ray's direction of propagation.
|
|
23
|
+
*/
|
|
24
|
+
constructor(origin: Vector, dir: Vector);
|
|
25
|
+
pointAt(t: number): Vector;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The intersection between a ray and a collider.
|
|
29
|
+
*/
|
|
30
|
+
export declare class RayIntersection {
|
|
31
|
+
/**
|
|
32
|
+
* The time-of-impact of the ray with the collider.
|
|
33
|
+
*
|
|
34
|
+
* The hit point is obtained from the ray's origin and direction: `origin + dir * toi`.
|
|
35
|
+
*/
|
|
36
|
+
toi: number;
|
|
37
|
+
/**
|
|
38
|
+
* The normal of the collider at the hit point.
|
|
39
|
+
*/
|
|
40
|
+
normal: Vector;
|
|
41
|
+
/**
|
|
42
|
+
* The type of the geometric feature the point was projected on.
|
|
43
|
+
*/
|
|
44
|
+
featureType: FeatureType;
|
|
45
|
+
/**
|
|
46
|
+
* The id of the geometric feature the point was projected on.
|
|
47
|
+
*/
|
|
48
|
+
featureId: number | undefined;
|
|
49
|
+
constructor(toi: number, normal: Vector, featureType?: FeatureType, featureId?: number);
|
|
50
|
+
static fromRaw(raw: RawRayIntersection): RayIntersection;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The intersection between a ray and a collider (includes the collider handle).
|
|
54
|
+
*/
|
|
55
|
+
export declare class RayColliderIntersection {
|
|
56
|
+
/**
|
|
57
|
+
* The collider hit by the ray.
|
|
58
|
+
*/
|
|
59
|
+
collider: Collider;
|
|
60
|
+
/**
|
|
61
|
+
* The time-of-impact of the ray with the collider.
|
|
62
|
+
*
|
|
63
|
+
* The hit point is obtained from the ray's origin and direction: `origin + dir * toi`.
|
|
64
|
+
*/
|
|
65
|
+
toi: number;
|
|
66
|
+
/**
|
|
67
|
+
* The normal of the collider at the hit point.
|
|
68
|
+
*/
|
|
69
|
+
normal: Vector;
|
|
70
|
+
/**
|
|
71
|
+
* The type of the geometric feature the point was projected on.
|
|
72
|
+
*/
|
|
73
|
+
featureType: FeatureType;
|
|
74
|
+
/**
|
|
75
|
+
* The id of the geometric feature the point was projected on.
|
|
76
|
+
*/
|
|
77
|
+
featureId: number | undefined;
|
|
78
|
+
constructor(collider: Collider, toi: number, normal: Vector, featureType?: FeatureType, featureId?: number);
|
|
79
|
+
static fromRaw(colliderSet: ColliderSet, raw: RawRayColliderIntersection): RayColliderIntersection;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The time of impact between a ray and a collider.
|
|
83
|
+
*/
|
|
84
|
+
export declare class RayColliderToi {
|
|
85
|
+
/**
|
|
86
|
+
* The handle of the collider hit by the ray.
|
|
87
|
+
*/
|
|
88
|
+
collider: Collider;
|
|
89
|
+
/**
|
|
90
|
+
* The time-of-impact of the ray with the collider.
|
|
91
|
+
*
|
|
92
|
+
* The hit point is obtained from the ray's origin and direction: `origin + dir * toi`.
|
|
93
|
+
*/
|
|
94
|
+
toi: number;
|
|
95
|
+
constructor(collider: Collider, toi: number);
|
|
96
|
+
static fromRaw(colliderSet: ColliderSet, raw: RawRayColliderToi): RayColliderToi;
|
|
97
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { VectorOps } from "../math";
|
|
2
|
+
import { FeatureType } from "./feature";
|
|
3
|
+
/**
|
|
4
|
+
* A ray. This is a directed half-line.
|
|
5
|
+
*/
|
|
6
|
+
export class Ray {
|
|
7
|
+
/**
|
|
8
|
+
* Builds a ray from its origin and direction.
|
|
9
|
+
*
|
|
10
|
+
* @param origin - The ray's starting point.
|
|
11
|
+
* @param dir - The ray's direction of propagation.
|
|
12
|
+
*/
|
|
13
|
+
constructor(origin, dir) {
|
|
14
|
+
this.origin = origin;
|
|
15
|
+
this.dir = dir;
|
|
16
|
+
}
|
|
17
|
+
pointAt(t) {
|
|
18
|
+
return {
|
|
19
|
+
x: this.origin.x + this.dir.x * t,
|
|
20
|
+
y: this.origin.y + this.dir.y * t,
|
|
21
|
+
// #if DIM3
|
|
22
|
+
z: this.origin.z + this.dir.z * t,
|
|
23
|
+
// #endif
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The intersection between a ray and a collider.
|
|
29
|
+
*/
|
|
30
|
+
export class RayIntersection {
|
|
31
|
+
constructor(toi, normal, featureType, featureId) {
|
|
32
|
+
/**
|
|
33
|
+
* The type of the geometric feature the point was projected on.
|
|
34
|
+
*/
|
|
35
|
+
this.featureType = FeatureType.Unknown;
|
|
36
|
+
/**
|
|
37
|
+
* The id of the geometric feature the point was projected on.
|
|
38
|
+
*/
|
|
39
|
+
this.featureId = undefined;
|
|
40
|
+
this.toi = toi;
|
|
41
|
+
this.normal = normal;
|
|
42
|
+
if (featureId !== undefined)
|
|
43
|
+
this.featureId = featureId;
|
|
44
|
+
if (featureType !== undefined)
|
|
45
|
+
this.featureType = featureType;
|
|
46
|
+
}
|
|
47
|
+
static fromRaw(raw) {
|
|
48
|
+
if (!raw)
|
|
49
|
+
return null;
|
|
50
|
+
const result = new RayIntersection(raw.toi(), VectorOps.fromRaw(raw.normal()), raw.featureType(), raw.featureId());
|
|
51
|
+
raw.free();
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The intersection between a ray and a collider (includes the collider handle).
|
|
57
|
+
*/
|
|
58
|
+
export class RayColliderIntersection {
|
|
59
|
+
constructor(collider, toi, normal, featureType, featureId) {
|
|
60
|
+
/**
|
|
61
|
+
* The type of the geometric feature the point was projected on.
|
|
62
|
+
*/
|
|
63
|
+
this.featureType = FeatureType.Unknown;
|
|
64
|
+
/**
|
|
65
|
+
* The id of the geometric feature the point was projected on.
|
|
66
|
+
*/
|
|
67
|
+
this.featureId = undefined;
|
|
68
|
+
this.collider = collider;
|
|
69
|
+
this.toi = toi;
|
|
70
|
+
this.normal = normal;
|
|
71
|
+
if (featureId !== undefined)
|
|
72
|
+
this.featureId = featureId;
|
|
73
|
+
if (featureType !== undefined)
|
|
74
|
+
this.featureType = featureType;
|
|
75
|
+
}
|
|
76
|
+
static fromRaw(colliderSet, raw) {
|
|
77
|
+
if (!raw)
|
|
78
|
+
return null;
|
|
79
|
+
const result = new RayColliderIntersection(colliderSet.get(raw.colliderHandle()), raw.toi(), VectorOps.fromRaw(raw.normal()), raw.featureType(), raw.featureId());
|
|
80
|
+
raw.free();
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The time of impact between a ray and a collider.
|
|
86
|
+
*/
|
|
87
|
+
export class RayColliderToi {
|
|
88
|
+
constructor(collider, toi) {
|
|
89
|
+
this.collider = collider;
|
|
90
|
+
this.toi = toi;
|
|
91
|
+
}
|
|
92
|
+
static fromRaw(colliderSet, raw) {
|
|
93
|
+
if (!raw)
|
|
94
|
+
return null;
|
|
95
|
+
const result = new RayColliderToi(colliderSet.get(raw.colliderHandle()), raw.toi());
|
|
96
|
+
raw.free();
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=ray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ray.js","sourceRoot":"","sources":["../src/geometry/ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,SAAS,EAAC,MAAM,SAAS,CAAC;AAO1C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AAGtC;;GAEG;AACH,MAAM,OAAO,GAAG;IAUZ;;;;;OAKG;IACH,YAAY,MAAc,EAAE,GAAW;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACnB,CAAC;IAEM,OAAO,CAAC,CAAS;QACpB,OAAO;YACH,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;YACjC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;YACjC,WAAW;YACX,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;YACjC,SAAS;SACZ,CAAC;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,eAAe;IAsBxB,YACI,GAAW,EACX,MAAc,EACd,WAAyB,EACzB,SAAkB;QAdtB;;WAEG;QACH,gBAAW,GAAG,WAAW,CAAC,OAAO,CAAC;QAElC;;WAEG;QACH,cAAS,GAAuB,SAAS,CAAC;QAQtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,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