UNPKG

@dimforge/rapier3d

Version:

3-dimensional physics engine in Rust - official JS bindings.

37 lines 1.43 kB
import { VectorOps } from "../math"; /** * The intersection between a ray and a collider. */ export class ShapeCastHit { constructor(time_of_impact, witness1, witness2, normal1, normal2) { this.time_of_impact = time_of_impact; this.witness1 = witness1; this.witness2 = witness2; this.normal1 = normal1; this.normal2 = normal2; } static fromRaw(colliderSet, raw) { if (!raw) return null; const result = new ShapeCastHit(raw.time_of_impact(), VectorOps.fromRaw(raw.witness1()), VectorOps.fromRaw(raw.witness2()), VectorOps.fromRaw(raw.normal1()), VectorOps.fromRaw(raw.normal2())); raw.free(); return result; } } /** * The intersection between a ray and a collider. */ export class ColliderShapeCastHit extends ShapeCastHit { constructor(collider, time_of_impact, witness1, witness2, normal1, normal2) { super(time_of_impact, witness1, witness2, normal1, normal2); this.collider = collider; } static fromRaw(colliderSet, raw) { if (!raw) return null; const result = new ColliderShapeCastHit(colliderSet.get(raw.colliderHandle()), raw.time_of_impact(), VectorOps.fromRaw(raw.witness1()), VectorOps.fromRaw(raw.witness2()), VectorOps.fromRaw(raw.normal1()), VectorOps.fromRaw(raw.normal2())); raw.free(); return result; } } //# sourceMappingURL=toi.js.map