angular-three-cannon 4.2.0 → 4.2.2
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/fesm2022/angular-three-cannon-body.mjs +2 -2
- package/fesm2022/angular-three-cannon-body.mjs.map +1 -1
- package/fesm2022/angular-three-cannon-constraint.mjs +3 -3
- package/fesm2022/angular-three-cannon-constraint.mjs.map +1 -1
- package/fesm2022/angular-three-cannon-debug.mjs +4 -4
- package/fesm2022/angular-three-cannon-debug.mjs.map +1 -1
- package/fesm2022/angular-three-cannon.mjs +5 -5
- package/fesm2022/angular-three-cannon.mjs.map +1 -1
- package/package.json +64 -63
|
@@ -280,7 +280,7 @@ function body(type, getPropFn, ref, { transformArgs, injector } = {}) {
|
|
|
280
280
|
const transform = transformArgs ?? defaultTransformArgs[type];
|
|
281
281
|
const isRefSignal = isSignal(ref);
|
|
282
282
|
const bodyRef = (isRefSignal ? ref : signal(ref));
|
|
283
|
-
const body = computed(() => resolveRef(bodyRef()), ...(ngDevMode ? [{ debugName: "body" }] : []));
|
|
283
|
+
const body = computed(() => resolveRef(bodyRef()), ...(ngDevMode ? [{ debugName: "body" }] : /* istanbul ignore next */ []));
|
|
284
284
|
const api = computed(() => {
|
|
285
285
|
const _body = body();
|
|
286
286
|
if (!_body)
|
|
@@ -290,7 +290,7 @@ function body(type, getPropFn, ref, { transformArgs, injector } = {}) {
|
|
|
290
290
|
if (!_worker)
|
|
291
291
|
return null;
|
|
292
292
|
return makeBodyApi(_body, _worker, rest);
|
|
293
|
-
}, ...(ngDevMode ? [{ debugName: "api" }] : []));
|
|
293
|
+
}, ...(ngDevMode ? [{ debugName: "api" }] : /* istanbul ignore next */ []));
|
|
294
294
|
effect((onCleanup) => {
|
|
295
295
|
const currentWorker = physics.worker();
|
|
296
296
|
if (!currentWorker)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-three-cannon-body.mjs","sources":["../../../../libs/cannon/body/src/lib/utils.ts","../../../../libs/cannon/body/src/lib/body.ts","../../../../libs/cannon/body/src/angular-three-cannon-body.ts"],"sourcesContent":["import {\n\tAtomicName,\n\tBodyProps,\n\tBoxProps,\n\tCannonWorkerAPI,\n\tCompoundBodyProps,\n\tConvexPolyhedronArgs,\n\tCylinderArgs,\n\tHeightfieldArgs,\n\tParticleProps,\n\tPlaneProps,\n\tPropValue,\n\tQuad,\n\tSetOpName,\n\tSphereArgs,\n\tSubscriptionName,\n\tSubscriptionTarget,\n\tSubscriptions,\n\tTrimeshArgs,\n\tTriplet,\n\tVectorName,\n} from '@pmndrs/cannon-worker-api';\nimport { is } from 'angular-three';\nimport { NgtcCannonEvents, NgtcPhysics } from 'angular-three-cannon';\nimport * as THREE from 'three';\nimport { NgtcWorkerApi } from './types';\n\nfunction capitalize<T extends string>(str: T): Capitalize<T> {\n\treturn (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<T>;\n}\n\nfunction getUUID(body: THREE.Object3D, index?: number) {\n\tconst suffix = index === undefined ? '' : `/${index}`;\n\tif (typeof body === 'function') return null;\n\treturn body && body && `${body.uuid}${suffix}`;\n}\n\nconst e = new THREE.Euler();\nconst q = new THREE.Quaternion();\n\nfunction quaternionToRotation(callback: (v: Triplet) => void) {\n\treturn (v: Quad) => callback(e.setFromQuaternion(q.fromArray(v)).toArray() as Triplet);\n}\n\nlet incrementingId = 0;\n\n/**\n * Creates a subscription function for monitoring physics body property changes.\n *\n * @template T - The subscription property name type\n * @param body - The Three.js Object3D associated with the physics body\n * @param worker - The Cannon.js worker API instance\n * @param subscriptions - Map to store active subscriptions\n * @param type - The property type to subscribe to (e.g., 'position', 'velocity')\n * @param index - Optional instance index for InstancedMesh bodies\n * @param target - Subscription target, defaults to 'bodies'\n * @returns Function that creates a subscription and returns an unsubscribe function\n *\n * @example\n * ```typescript\n * const subscribe = createSubscribe(body, worker, subscriptions, 'position');\n * const unsubscribe = subscribe((position) => console.log(position));\n * // Later: unsubscribe();\n * ```\n */\nexport function createSubscribe<T extends SubscriptionName>(\n\tbody: THREE.Object3D,\n\tworker: CannonWorkerAPI,\n\tsubscriptions: Subscriptions,\n\ttype: T,\n\tindex?: number,\n\ttarget: SubscriptionTarget = 'bodies',\n) {\n\treturn (callback: (value: PropValue<T>) => void) => {\n\t\tconst id = incrementingId++;\n\t\tsubscriptions[id] = { [type]: callback };\n\t\tconst uuid = getUUID(body, index);\n\t\tuuid && worker.subscribe({ props: { id, target, type }, uuid });\n\t\treturn () => {\n\t\t\tdelete subscriptions[id];\n\t\t\tworker.unsubscribe({ props: id });\n\t\t};\n\t};\n}\n\nfunction makeTriplet(v: THREE.Vector3 | Triplet): Triplet {\n\treturn is.three<THREE.Vector3>(v, 'isVector3') ? [v.x, v.y, v.z] : v;\n}\n\n/**\n * Prepares a Three.js Object3D with initial physics body properties.\n * Sets the object's position, rotation, and userData from body props.\n *\n * @param object - The Three.js Object3D to prepare\n * @param props - Body properties containing position, rotation, and userData\n *\n * @example\n * ```typescript\n * prepare(mesh, { position: [0, 5, 0], rotation: [0, Math.PI, 0] });\n * ```\n */\nexport function prepare(\n\tobject: THREE.Object3D,\n\t{ position = [0, 0, 0], rotation = [0, 0, 0], userData = {} }: BodyProps,\n) {\n\tobject.userData = userData;\n\tobject.position.set(...position);\n\tobject.rotation.set(...rotation);\n\tobject.updateMatrix();\n}\n\n/**\n * Sets up collision event handlers for a physics body.\n * Registers callbacks for collide, collideBegin, and collideEnd events.\n *\n * @param events - The events map to register handlers in\n * @param props - Body props containing collision callback functions\n * @param uuid - The unique identifier for the physics body\n */\nexport function setupCollision(\n\tevents: NgtcCannonEvents,\n\t{ onCollide, onCollideBegin, onCollideEnd }: Partial<BodyProps>,\n\tuuid: string,\n) {\n\tevents[uuid] = { collide: onCollide, collideBegin: onCollideBegin, collideEnd: onCollideEnd };\n}\n\n/**\n * Creates the public API for controlling a physics body.\n * Provides methods for applying forces, setting properties, and subscribing to changes.\n *\n * @param body - The Three.js Object3D associated with the physics body\n * @param worker - The Cannon.js worker API instance\n * @param context - Physics context containing subscriptions and scale overrides\n * @returns The body's public API with all available methods\n *\n * @example\n * ```typescript\n * const api = makeBodyApi(mesh, worker, { subscriptions, scaleOverrides });\n * api.applyForce([0, 100, 0], [0, 0, 0]);\n * api.position.subscribe((pos) => console.log(pos));\n * ```\n */\nexport function makeBodyApi(\n\tbody: THREE.Object3D,\n\tworker: CannonWorkerAPI,\n\t{ subscriptions, scaleOverrides }: Pick<NgtcPhysics, 'subscriptions' | 'scaleOverrides'>,\n) {\n\tconst makeAtomic = <T extends AtomicName>(type: T, index?: number) => {\n\t\tconst op: SetOpName<T> = `set${capitalize(type)}`;\n\n\t\treturn {\n\t\t\tset: (value: PropValue<T>) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker[op]({ props: value, uuid } as never);\n\t\t\t},\n\t\t\tsubscribe: createSubscribe(body, worker, subscriptions, type, index),\n\t\t};\n\t};\n\n\tconst makeQuaternion = (index?: number) => {\n\t\tconst type = 'quaternion';\n\t\treturn {\n\t\t\tcopy: ({ w, x, y, z }: THREE.Quaternion) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setQuaternion({ props: [x, y, z, w], uuid });\n\t\t\t},\n\t\t\tset: (x: number, y: number, z: number, w: number) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setQuaternion({ props: [x, y, z, w], uuid });\n\t\t\t},\n\t\t\tsubscribe: createSubscribe(body, worker, subscriptions, type, index),\n\t\t};\n\t};\n\n\tconst makeRotation = (index?: number) => {\n\t\treturn {\n\t\t\tcopy: ({ x, y, z }: THREE.Vector3 | THREE.Euler) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setRotation({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tset: (x: number, y: number, z: number) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setRotation({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tsubscribe: (callback: (value: Triplet) => void) => {\n\t\t\t\tconst id = incrementingId++;\n\t\t\t\tconst target = 'bodies';\n\t\t\t\tconst type = 'quaternion';\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tsubscriptions[id] = { [type]: quaternionToRotation(callback) };\n\t\t\t\tuuid && worker.subscribe({ props: { id, target, type }, uuid });\n\t\t\t\treturn () => {\n\t\t\t\t\tdelete subscriptions[id];\n\t\t\t\t\tworker.unsubscribe({ props: id });\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t};\n\tconst makeVec = (type: VectorName, index?: number) => {\n\t\tconst op: SetOpName<VectorName> = `set${capitalize(type)}`;\n\t\treturn {\n\t\t\tcopy: ({ x, y, z }: THREE.Vector3 | THREE.Euler) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker[op]({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tset: (x: number, y: number, z: number) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker[op]({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tsubscribe: createSubscribe(body, worker, subscriptions, type, index),\n\t\t};\n\t};\n\n\tconst makeRemove = (index?: number) => {\n\t\tconst uuid = getUUID(body, index);\n\t\treturn () => {\n\t\t\tif (uuid) worker.removeBodies({ uuid: [uuid] });\n\t\t};\n\t};\n\n\tfunction makeApi(index?: number): NgtcWorkerApi {\n\t\treturn {\n\t\t\tallowSleep: makeAtomic('allowSleep', index),\n\t\t\tangularDamping: makeAtomic('angularDamping', index),\n\t\t\tangularFactor: makeVec('angularFactor', index),\n\t\t\tangularVelocity: makeVec('angularVelocity', index),\n\t\t\tapplyForce(force: Triplet, worldPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyForce({ props: [force, worldPoint], uuid });\n\t\t\t},\n\t\t\tapplyImpulse(impulse: Triplet, worldPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyImpulse({ props: [impulse, worldPoint], uuid });\n\t\t\t},\n\t\t\tapplyLocalForce(force: Triplet, localPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyLocalForce({ props: [force, localPoint], uuid });\n\t\t\t},\n\t\t\tapplyLocalImpulse(impulse: Triplet, localPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyLocalImpulse({ props: [impulse, localPoint], uuid });\n\t\t\t},\n\t\t\tapplyTorque(torque: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyTorque({ props: [torque], uuid });\n\t\t\t},\n\t\t\tcollisionFilterGroup: makeAtomic('collisionFilterGroup', index),\n\t\t\tcollisionFilterMask: makeAtomic('collisionFilterMask', index),\n\t\t\tcollisionResponse: makeAtomic('collisionResponse', index),\n\t\t\tfixedRotation: makeAtomic('fixedRotation', index),\n\t\t\tisTrigger: makeAtomic('isTrigger', index),\n\t\t\tlinearDamping: makeAtomic('linearDamping', index),\n\t\t\tlinearFactor: makeVec('linearFactor', index),\n\t\t\tmass: makeAtomic('mass', index),\n\t\t\tmaterial: makeAtomic('material', index),\n\t\t\tposition: makeVec('position', index),\n\t\t\tquaternion: makeQuaternion(index),\n\t\t\trotation: makeRotation(index),\n\t\t\tscaleOverride(scale) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tif (uuid) scaleOverrides[uuid] = new THREE.Vector3(...scale);\n\t\t\t},\n\t\t\tsleep() {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.sleep({ uuid });\n\t\t\t},\n\t\t\tsleepSpeedLimit: makeAtomic('sleepSpeedLimit', index),\n\t\t\tsleepTimeLimit: makeAtomic('sleepTimeLimit', index),\n\t\t\tuserData: makeAtomic('userData', index),\n\t\t\tvelocity: makeVec('velocity', index),\n\t\t\tremove: makeRemove(index),\n\t\t\twakeUp() {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.wakeUp({ uuid });\n\t\t\t},\n\t\t};\n\t}\n\tconst cache: Record<number, NgtcWorkerApi> = {};\n\treturn { ...makeApi(), at: (index: number) => cache[index] || (cache[index] = makeApi(index)) };\n}\n\n/**\n * Default argument transformation functions for each physics body shape type.\n * These functions convert Three.js-friendly arguments to Cannon.js-compatible formats.\n *\n * Each transformer handles the specific requirements of its shape type:\n * - Plane: No arguments needed\n * - Box: [width, height, depth], defaults to [1, 1, 1]\n * - Trimesh: Passes through vertices and indices unchanged\n * - Cylinder: No arguments needed (uses shape defaults)\n * - Heightfield: Passes through height data unchanged\n * - ConvexPolyhedron: Converts Vector3 arrays to triplet arrays\n * - Particle: No arguments needed\n * - Sphere: [radius], defaults to [1]\n * - Compound: Passes through shape array unchanged\n */\nexport const defaultTransformArgs = {\n\tPlane: (_: PlaneProps['args']) => [],\n\tBox: (args: BoxProps['args'] = [1, 1, 1]) => args,\n\tTrimesh: (args: TrimeshArgs) => args,\n\tCylinder: (_: CylinderArgs = []) => [],\n\tHeightfield: (args: HeightfieldArgs) => args,\n\tConvexPolyhedron: ([vertices, faces, normals, axes, boundingSphereRadius]: ConvexPolyhedronArgs = []) => [\n\t\tvertices && vertices.map(makeTriplet),\n\t\tfaces,\n\t\tnormals && normals.map(makeTriplet),\n\t\taxes && axes.map(makeTriplet),\n\t\tboundingSphereRadius,\n\t],\n\tParticle: (_: ParticleProps['args']) => [],\n\tSphere: (args: SphereArgs = [1]) => {\n\t\tif (!Array.isArray(args)) throw new Error('Sphere body args must be an array');\n\t\treturn [args[0]];\n\t},\n\tCompound: (args: CompoundBodyProps['args']) => args,\n};\n","import {\n\tElementRef,\n\tInjector,\n\tSignal,\n\tWritableSignal,\n\tcomputed,\n\teffect,\n\tinject,\n\tisSignal,\n\tsignal,\n} from '@angular/core';\nimport { BodyShapeType } from '@pmndrs/cannon-worker-api';\nimport { is, resolveRef } from 'angular-three';\nimport { NgtcPhysics } from 'angular-three-cannon';\nimport { NgtcDebug } from 'angular-three-cannon/debug';\nimport { assertInjector } from 'ngxtension/assert-injector';\nimport * as THREE from 'three';\nimport { NgtcArgFn, NgtcBodyPropsMap, NgtcBodyPublicApi, NgtcGetByIndex } from './types';\nimport { defaultTransformArgs, makeBodyApi, prepare, setupCollision } from './utils';\n\n/**\n * Configuration options for creating a physics body.\n * @template TShape - The shape type of the physics body\n */\nexport interface NgtcBodyOptions<TShape extends BodyShapeType> {\n\t/**\n\t * Custom function to transform body arguments before passing to the physics engine.\n\t * Useful for converting Three.js geometries to physics-compatible formats.\n\t */\n\ttransformArgs?: NgtcArgFn<NgtcBodyPropsMap[TShape]>;\n\t/**\n\t * Angular injector to use for dependency injection.\n\t * If not provided, uses the current injection context.\n\t */\n\tinjector?: Injector;\n}\n\nfunction createBody<TShape extends BodyShapeType>(type: TShape) {\n\treturn <TObject extends THREE.Object3D>(\n\t\tgetPropFn: NgtcGetByIndex<NgtcBodyPropsMap[TShape]>,\n\t\tref: ElementRef<TObject> | TObject | Signal<ElementRef<TObject> | TObject | undefined>,\n\t\toptions?: NgtcBodyOptions<TShape>,\n\t) => body<TShape, TObject>(type, getPropFn, ref, options);\n}\n\nfunction body<TShape extends BodyShapeType, TObject extends THREE.Object3D>(\n\ttype: TShape,\n\tgetPropFn: NgtcGetByIndex<NgtcBodyPropsMap[TShape]>,\n\tref: ElementRef<TObject> | TObject | Signal<ElementRef<TObject> | TObject | undefined>,\n\t{ transformArgs, injector }: NgtcBodyOptions<TShape> = {},\n): Signal<NgtcBodyPublicApi | null> {\n\treturn assertInjector(body, injector, () => {\n\t\tconst physics = inject(NgtcPhysics, { optional: true });\n\n\t\tif (!physics) {\n\t\t\tthrow new Error(`[NGT Cannon] injectBody was called outside of <ngtc-physics>`);\n\t\t}\n\n\t\tconst debug = inject(NgtcDebug, { optional: true });\n\n\t\tconst transform = transformArgs ?? defaultTransformArgs[type];\n\t\tconst isRefSignal = isSignal(ref);\n\t\tconst bodyRef = (isRefSignal ? ref : signal(ref)) as WritableSignal<TObject | undefined>;\n\t\tconst body = computed(() => resolveRef(bodyRef()));\n\n\t\tconst api = computed(() => {\n\t\t\tconst _body = body();\n\t\t\tif (!_body) return null;\n\n\t\t\tconst { worker, ...rest } = physics;\n\t\t\tconst _worker = worker();\n\t\t\tif (!_worker) return null;\n\n\t\t\treturn makeBodyApi(_body, _worker, rest);\n\t\t});\n\n\t\teffect((onCleanup) => {\n\t\t\tconst currentWorker = physics.worker();\n\t\t\tif (!currentWorker) return;\n\n\t\t\tconst object = body();\n\n\t\t\tif (!isRefSignal && !object) {\n\t\t\t\tbodyRef.set(resolveRef(ref));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!object) return;\n\n\t\t\tconst [uuid, props] = (() => {\n\t\t\t\tlet uuids: string[] = [];\n\t\t\t\tlet temp: THREE.Object3D;\n\t\t\t\tif (is.three<THREE.InstancedMesh>(object, 'isInstancedMesh')) {\n\t\t\t\t\tobject.instanceMatrix.setUsage(THREE.DynamicDrawUsage);\n\t\t\t\t\tuuids = new Array(object.count).fill(0).map((_, i) => `${object.uuid}/${i}`);\n\t\t\t\t\ttemp = new THREE.Object3D();\n\t\t\t\t} else {\n\t\t\t\t\tuuids = [object.uuid];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tuuids,\n\t\t\t\t\tuuids.map((id, index) => {\n\t\t\t\t\t\tconst props = getPropFn(index);\n\t\t\t\t\t\tif (temp) {\n\t\t\t\t\t\t\tprepare(temp, props);\n\t\t\t\t\t\t\t(object as unknown as THREE.InstancedMesh).setMatrixAt(index, temp.matrix);\n\t\t\t\t\t\t\t(object as unknown as THREE.InstancedMesh).instanceMatrix.needsUpdate = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tprepare(object, props);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tphysics.refs[id] = object;\n\t\t\t\t\t\tdebug?.add(id, props, type);\n\t\t\t\t\t\tsetupCollision(physics.events, props, id);\n\t\t\t\t\t\t// @ts-expect-error - if args is undefined, there's default\n\t\t\t\t\t\treturn { ...props, args: transform(props.args) };\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t})();\n\n\t\t\t// Register on mount, unregister on unmount\n\t\t\tcurrentWorker.addBodies({\n\t\t\t\tprops: props.map(({ onCollide, onCollideBegin, onCollideEnd, ...serializableProps }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tonCollide: Boolean(onCollide),\n\t\t\t\t\t\tonCollideBegin: Boolean(onCollideBegin),\n\t\t\t\t\t\tonCollideEnd: Boolean(onCollideEnd),\n\t\t\t\t\t\t...serializableProps,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t\ttype,\n\t\t\t\tuuid,\n\t\t\t});\n\n\t\t\tonCleanup(() => {\n\t\t\t\tuuid.forEach((id) => {\n\t\t\t\t\tdelete physics.refs[id];\n\t\t\t\t\tdebug?.remove(id);\n\t\t\t\t\tdelete physics.events[id];\n\t\t\t\t});\n\t\t\t\tcurrentWorker.removeBodies({ uuid });\n\t\t\t});\n\t\t});\n\n\t\treturn api;\n\t});\n}\n\n/**\n * Creates a box-shaped physics body.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = box(() => ({ mass: 1, args: [1, 1, 1], position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const box = createBody('Box');\n\n/**\n * Creates a convex polyhedron physics body from vertices and faces.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = convexPolyhedron(() => ({\n * mass: 1,\n * args: [vertices, faces],\n * position: [0, 5, 0]\n * }), mesh);\n * ```\n */\nexport const convexPolyhedron = createBody('ConvexPolyhedron');\n\n/**\n * Creates a cylinder-shaped physics body.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * // args: [radiusTop, radiusBottom, height, numSegments]\n * const api = cylinder(() => ({ mass: 1, args: [0.5, 0.5, 2, 16], position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const cylinder = createBody('Cylinder');\n\n/**\n * Creates a heightfield physics body for terrain simulation.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const heightData = [[0, 0, 0], [0, 1, 0], [0, 0, 0]];\n * const api = heightfield(() => ({\n * mass: 0,\n * args: [heightData, { elementSize: 1 }],\n * position: [0, 0, 0]\n * }), mesh);\n * ```\n */\nexport const heightfield = createBody('Heightfield');\n\n/**\n * Creates a particle (point mass) physics body with no shape.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = particle(() => ({ mass: 1, position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const particle = createBody('Particle');\n\n/**\n * Creates an infinite plane physics body, typically used for floors or walls.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = plane(() => ({\n * mass: 0, // Static body\n * rotation: [-Math.PI / 2, 0, 0], // Horizontal\n * position: [0, 0, 0]\n * }), mesh);\n * ```\n */\nexport const plane = createBody('Plane');\n\n/**\n * Creates a sphere-shaped physics body.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * // args: [radius]\n * const api = sphere(() => ({ mass: 1, args: [1], position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const sphere = createBody('Sphere');\n\n/**\n * Creates a trimesh physics body from vertices and indices.\n * Useful for complex static geometry like terrain or obstacles.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = trimesh(() => ({\n * mass: 0,\n * args: [vertices, indices],\n * position: [0, 0, 0]\n * }), mesh);\n * ```\n */\nexport const trimesh = createBody('Trimesh');\n\n/**\n * Creates a compound physics body composed of multiple shapes.\n * Useful for complex objects that can be approximated by combining primitives.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = compound(() => ({\n * mass: 1,\n * shapes: [\n * { type: 'Box', args: [1, 1, 1], position: [0, 0, 0] },\n * { type: 'Sphere', args: [0.5], position: [0, 1, 0] }\n * ],\n * position: [0, 5, 0]\n * }), mesh);\n * ```\n */\nexport const compound = createBody('Compound');\n\n/**\n * @deprecated Use `box` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectBox = box;\n\n/**\n * @deprecated Use `convexPolyhedron` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectConvexPolyhedron = convexPolyhedron;\n\n/**\n * @deprecated Use `cylinder` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectCylinder = cylinder;\n\n/**\n * @deprecated Use `heightfield` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectHeightfield = heightfield;\n\n/**\n * @deprecated Use `particle` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectParticle = particle;\n\n/**\n * @deprecated Use `plane` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectPlane = plane;\n\n/**\n * @deprecated Use `sphere` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectSphere = sphere;\n\n/**\n * @deprecated Use `trimesh` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectTrimesh = trimesh;\n\n/**\n * @deprecated Use `compound` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectCompound = compound;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AA2BA,SAAS,UAAU,CAAmB,GAAM,EAAA;AAC3C,IAAA,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AACnD;AAEA,SAAS,OAAO,CAAC,IAAoB,EAAE,KAAc,EAAA;AACpD,IAAA,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,GAAG,EAAE,GAAG,CAAA,CAAA,EAAI,KAAK,EAAE;IACrD,IAAI,OAAO,IAAI,KAAK,UAAU;AAAE,QAAA,OAAO,IAAI;IAC3C,OAAO,IAAI,IAAI,IAAI,IAAI,CAAA,EAAG,IAAI,CAAC,IAAI,CAAA,EAAG,MAAM,CAAA,CAAE;AAC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mjs","sources":["../../../../libs/cannon/body/src/lib/utils.ts","../../../../libs/cannon/body/src/lib/body.ts","../../../../libs/cannon/body/src/angular-three-cannon-body.ts"],"sourcesContent":["import {\n\tAtomicName,\n\tBodyProps,\n\tBoxProps,\n\tCannonWorkerAPI,\n\tCompoundBodyProps,\n\tConvexPolyhedronArgs,\n\tCylinderArgs,\n\tHeightfieldArgs,\n\tParticleProps,\n\tPlaneProps,\n\tPropValue,\n\tQuad,\n\tSetOpName,\n\tSphereArgs,\n\tSubscriptionName,\n\tSubscriptionTarget,\n\tSubscriptions,\n\tTrimeshArgs,\n\tTriplet,\n\tVectorName,\n} from '@pmndrs/cannon-worker-api';\nimport { is } from 'angular-three';\nimport { NgtcCannonEvents, NgtcPhysics } from 'angular-three-cannon';\nimport * as THREE from 'three';\nimport { NgtcWorkerApi } from './types';\n\nfunction capitalize<T extends string>(str: T): Capitalize<T> {\n\treturn (str.charAt(0).toUpperCase() + str.slice(1)) as Capitalize<T>;\n}\n\nfunction getUUID(body: THREE.Object3D, index?: number) {\n\tconst suffix = index === undefined ? '' : `/${index}`;\n\tif (typeof body === 'function') return null;\n\treturn body && body && `${body.uuid}${suffix}`;\n}\n\nconst e = new THREE.Euler();\nconst q = new THREE.Quaternion();\n\nfunction quaternionToRotation(callback: (v: Triplet) => void) {\n\treturn (v: Quad) => callback(e.setFromQuaternion(q.fromArray(v)).toArray() as Triplet);\n}\n\nlet incrementingId = 0;\n\n/**\n * Creates a subscription function for monitoring physics body property changes.\n *\n * @template T - The subscription property name type\n * @param body - The Three.js Object3D associated with the physics body\n * @param worker - The Cannon.js worker API instance\n * @param subscriptions - Map to store active subscriptions\n * @param type - The property type to subscribe to (e.g., 'position', 'velocity')\n * @param index - Optional instance index for InstancedMesh bodies\n * @param target - Subscription target, defaults to 'bodies'\n * @returns Function that creates a subscription and returns an unsubscribe function\n *\n * @example\n * ```typescript\n * const subscribe = createSubscribe(body, worker, subscriptions, 'position');\n * const unsubscribe = subscribe((position) => console.log(position));\n * // Later: unsubscribe();\n * ```\n */\nexport function createSubscribe<T extends SubscriptionName>(\n\tbody: THREE.Object3D,\n\tworker: CannonWorkerAPI,\n\tsubscriptions: Subscriptions,\n\ttype: T,\n\tindex?: number,\n\ttarget: SubscriptionTarget = 'bodies',\n) {\n\treturn (callback: (value: PropValue<T>) => void) => {\n\t\tconst id = incrementingId++;\n\t\tsubscriptions[id] = { [type]: callback };\n\t\tconst uuid = getUUID(body, index);\n\t\tuuid && worker.subscribe({ props: { id, target, type }, uuid });\n\t\treturn () => {\n\t\t\tdelete subscriptions[id];\n\t\t\tworker.unsubscribe({ props: id });\n\t\t};\n\t};\n}\n\nfunction makeTriplet(v: THREE.Vector3 | Triplet): Triplet {\n\treturn is.three<THREE.Vector3>(v, 'isVector3') ? [v.x, v.y, v.z] : v;\n}\n\n/**\n * Prepares a Three.js Object3D with initial physics body properties.\n * Sets the object's position, rotation, and userData from body props.\n *\n * @param object - The Three.js Object3D to prepare\n * @param props - Body properties containing position, rotation, and userData\n *\n * @example\n * ```typescript\n * prepare(mesh, { position: [0, 5, 0], rotation: [0, Math.PI, 0] });\n * ```\n */\nexport function prepare(\n\tobject: THREE.Object3D,\n\t{ position = [0, 0, 0], rotation = [0, 0, 0], userData = {} }: BodyProps,\n) {\n\tobject.userData = userData;\n\tobject.position.set(...position);\n\tobject.rotation.set(...rotation);\n\tobject.updateMatrix();\n}\n\n/**\n * Sets up collision event handlers for a physics body.\n * Registers callbacks for collide, collideBegin, and collideEnd events.\n *\n * @param events - The events map to register handlers in\n * @param props - Body props containing collision callback functions\n * @param uuid - The unique identifier for the physics body\n */\nexport function setupCollision(\n\tevents: NgtcCannonEvents,\n\t{ onCollide, onCollideBegin, onCollideEnd }: Partial<BodyProps>,\n\tuuid: string,\n) {\n\tevents[uuid] = { collide: onCollide, collideBegin: onCollideBegin, collideEnd: onCollideEnd };\n}\n\n/**\n * Creates the public API for controlling a physics body.\n * Provides methods for applying forces, setting properties, and subscribing to changes.\n *\n * @param body - The Three.js Object3D associated with the physics body\n * @param worker - The Cannon.js worker API instance\n * @param context - Physics context containing subscriptions and scale overrides\n * @returns The body's public API with all available methods\n *\n * @example\n * ```typescript\n * const api = makeBodyApi(mesh, worker, { subscriptions, scaleOverrides });\n * api.applyForce([0, 100, 0], [0, 0, 0]);\n * api.position.subscribe((pos) => console.log(pos));\n * ```\n */\nexport function makeBodyApi(\n\tbody: THREE.Object3D,\n\tworker: CannonWorkerAPI,\n\t{ subscriptions, scaleOverrides }: Pick<NgtcPhysics, 'subscriptions' | 'scaleOverrides'>,\n) {\n\tconst makeAtomic = <T extends AtomicName>(type: T, index?: number) => {\n\t\tconst op: SetOpName<T> = `set${capitalize(type)}`;\n\n\t\treturn {\n\t\t\tset: (value: PropValue<T>) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker[op]({ props: value, uuid } as never);\n\t\t\t},\n\t\t\tsubscribe: createSubscribe(body, worker, subscriptions, type, index),\n\t\t};\n\t};\n\n\tconst makeQuaternion = (index?: number) => {\n\t\tconst type = 'quaternion';\n\t\treturn {\n\t\t\tcopy: ({ w, x, y, z }: THREE.Quaternion) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setQuaternion({ props: [x, y, z, w], uuid });\n\t\t\t},\n\t\t\tset: (x: number, y: number, z: number, w: number) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setQuaternion({ props: [x, y, z, w], uuid });\n\t\t\t},\n\t\t\tsubscribe: createSubscribe(body, worker, subscriptions, type, index),\n\t\t};\n\t};\n\n\tconst makeRotation = (index?: number) => {\n\t\treturn {\n\t\t\tcopy: ({ x, y, z }: THREE.Vector3 | THREE.Euler) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setRotation({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tset: (x: number, y: number, z: number) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.setRotation({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tsubscribe: (callback: (value: Triplet) => void) => {\n\t\t\t\tconst id = incrementingId++;\n\t\t\t\tconst target = 'bodies';\n\t\t\t\tconst type = 'quaternion';\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tsubscriptions[id] = { [type]: quaternionToRotation(callback) };\n\t\t\t\tuuid && worker.subscribe({ props: { id, target, type }, uuid });\n\t\t\t\treturn () => {\n\t\t\t\t\tdelete subscriptions[id];\n\t\t\t\t\tworker.unsubscribe({ props: id });\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t};\n\tconst makeVec = (type: VectorName, index?: number) => {\n\t\tconst op: SetOpName<VectorName> = `set${capitalize(type)}`;\n\t\treturn {\n\t\t\tcopy: ({ x, y, z }: THREE.Vector3 | THREE.Euler) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker[op]({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tset: (x: number, y: number, z: number) => {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker[op]({ props: [x, y, z], uuid });\n\t\t\t},\n\t\t\tsubscribe: createSubscribe(body, worker, subscriptions, type, index),\n\t\t};\n\t};\n\n\tconst makeRemove = (index?: number) => {\n\t\tconst uuid = getUUID(body, index);\n\t\treturn () => {\n\t\t\tif (uuid) worker.removeBodies({ uuid: [uuid] });\n\t\t};\n\t};\n\n\tfunction makeApi(index?: number): NgtcWorkerApi {\n\t\treturn {\n\t\t\tallowSleep: makeAtomic('allowSleep', index),\n\t\t\tangularDamping: makeAtomic('angularDamping', index),\n\t\t\tangularFactor: makeVec('angularFactor', index),\n\t\t\tangularVelocity: makeVec('angularVelocity', index),\n\t\t\tapplyForce(force: Triplet, worldPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyForce({ props: [force, worldPoint], uuid });\n\t\t\t},\n\t\t\tapplyImpulse(impulse: Triplet, worldPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyImpulse({ props: [impulse, worldPoint], uuid });\n\t\t\t},\n\t\t\tapplyLocalForce(force: Triplet, localPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyLocalForce({ props: [force, localPoint], uuid });\n\t\t\t},\n\t\t\tapplyLocalImpulse(impulse: Triplet, localPoint: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyLocalImpulse({ props: [impulse, localPoint], uuid });\n\t\t\t},\n\t\t\tapplyTorque(torque: Triplet) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.applyTorque({ props: [torque], uuid });\n\t\t\t},\n\t\t\tcollisionFilterGroup: makeAtomic('collisionFilterGroup', index),\n\t\t\tcollisionFilterMask: makeAtomic('collisionFilterMask', index),\n\t\t\tcollisionResponse: makeAtomic('collisionResponse', index),\n\t\t\tfixedRotation: makeAtomic('fixedRotation', index),\n\t\t\tisTrigger: makeAtomic('isTrigger', index),\n\t\t\tlinearDamping: makeAtomic('linearDamping', index),\n\t\t\tlinearFactor: makeVec('linearFactor', index),\n\t\t\tmass: makeAtomic('mass', index),\n\t\t\tmaterial: makeAtomic('material', index),\n\t\t\tposition: makeVec('position', index),\n\t\t\tquaternion: makeQuaternion(index),\n\t\t\trotation: makeRotation(index),\n\t\t\tscaleOverride(scale) {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tif (uuid) scaleOverrides[uuid] = new THREE.Vector3(...scale);\n\t\t\t},\n\t\t\tsleep() {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.sleep({ uuid });\n\t\t\t},\n\t\t\tsleepSpeedLimit: makeAtomic('sleepSpeedLimit', index),\n\t\t\tsleepTimeLimit: makeAtomic('sleepTimeLimit', index),\n\t\t\tuserData: makeAtomic('userData', index),\n\t\t\tvelocity: makeVec('velocity', index),\n\t\t\tremove: makeRemove(index),\n\t\t\twakeUp() {\n\t\t\t\tconst uuid = getUUID(body, index);\n\t\t\t\tuuid && worker.wakeUp({ uuid });\n\t\t\t},\n\t\t};\n\t}\n\tconst cache: Record<number, NgtcWorkerApi> = {};\n\treturn { ...makeApi(), at: (index: number) => cache[index] || (cache[index] = makeApi(index)) };\n}\n\n/**\n * Default argument transformation functions for each physics body shape type.\n * These functions convert Three.js-friendly arguments to Cannon.js-compatible formats.\n *\n * Each transformer handles the specific requirements of its shape type:\n * - Plane: No arguments needed\n * - Box: [width, height, depth], defaults to [1, 1, 1]\n * - Trimesh: Passes through vertices and indices unchanged\n * - Cylinder: No arguments needed (uses shape defaults)\n * - Heightfield: Passes through height data unchanged\n * - ConvexPolyhedron: Converts Vector3 arrays to triplet arrays\n * - Particle: No arguments needed\n * - Sphere: [radius], defaults to [1]\n * - Compound: Passes through shape array unchanged\n */\nexport const defaultTransformArgs = {\n\tPlane: (_: PlaneProps['args']) => [],\n\tBox: (args: BoxProps['args'] = [1, 1, 1]) => args,\n\tTrimesh: (args: TrimeshArgs) => args,\n\tCylinder: (_: CylinderArgs = []) => [],\n\tHeightfield: (args: HeightfieldArgs) => args,\n\tConvexPolyhedron: ([vertices, faces, normals, axes, boundingSphereRadius]: ConvexPolyhedronArgs = []) => [\n\t\tvertices && vertices.map(makeTriplet),\n\t\tfaces,\n\t\tnormals && normals.map(makeTriplet),\n\t\taxes && axes.map(makeTriplet),\n\t\tboundingSphereRadius,\n\t],\n\tParticle: (_: ParticleProps['args']) => [],\n\tSphere: (args: SphereArgs = [1]) => {\n\t\tif (!Array.isArray(args)) throw new Error('Sphere body args must be an array');\n\t\treturn [args[0]];\n\t},\n\tCompound: (args: CompoundBodyProps['args']) => args,\n};\n","import {\n\tElementRef,\n\tInjector,\n\tSignal,\n\tWritableSignal,\n\tcomputed,\n\teffect,\n\tinject,\n\tisSignal,\n\tsignal,\n} from '@angular/core';\nimport { BodyShapeType } from '@pmndrs/cannon-worker-api';\nimport { is, resolveRef } from 'angular-three';\nimport { NgtcPhysics } from 'angular-three-cannon';\nimport { NgtcDebug } from 'angular-three-cannon/debug';\nimport { assertInjector } from 'ngxtension/assert-injector';\nimport * as THREE from 'three';\nimport { NgtcArgFn, NgtcBodyPropsMap, NgtcBodyPublicApi, NgtcGetByIndex } from './types';\nimport { defaultTransformArgs, makeBodyApi, prepare, setupCollision } from './utils';\n\n/**\n * Configuration options for creating a physics body.\n * @template TShape - The shape type of the physics body\n */\nexport interface NgtcBodyOptions<TShape extends BodyShapeType> {\n\t/**\n\t * Custom function to transform body arguments before passing to the physics engine.\n\t * Useful for converting Three.js geometries to physics-compatible formats.\n\t */\n\ttransformArgs?: NgtcArgFn<NgtcBodyPropsMap[TShape]>;\n\t/**\n\t * Angular injector to use for dependency injection.\n\t * If not provided, uses the current injection context.\n\t */\n\tinjector?: Injector;\n}\n\nfunction createBody<TShape extends BodyShapeType>(type: TShape) {\n\treturn <TObject extends THREE.Object3D>(\n\t\tgetPropFn: NgtcGetByIndex<NgtcBodyPropsMap[TShape]>,\n\t\tref: ElementRef<TObject> | TObject | Signal<ElementRef<TObject> | TObject | undefined>,\n\t\toptions?: NgtcBodyOptions<TShape>,\n\t) => body<TShape, TObject>(type, getPropFn, ref, options);\n}\n\nfunction body<TShape extends BodyShapeType, TObject extends THREE.Object3D>(\n\ttype: TShape,\n\tgetPropFn: NgtcGetByIndex<NgtcBodyPropsMap[TShape]>,\n\tref: ElementRef<TObject> | TObject | Signal<ElementRef<TObject> | TObject | undefined>,\n\t{ transformArgs, injector }: NgtcBodyOptions<TShape> = {},\n): Signal<NgtcBodyPublicApi | null> {\n\treturn assertInjector(body, injector, () => {\n\t\tconst physics = inject(NgtcPhysics, { optional: true });\n\n\t\tif (!physics) {\n\t\t\tthrow new Error(`[NGT Cannon] injectBody was called outside of <ngtc-physics>`);\n\t\t}\n\n\t\tconst debug = inject(NgtcDebug, { optional: true });\n\n\t\tconst transform = transformArgs ?? defaultTransformArgs[type];\n\t\tconst isRefSignal = isSignal(ref);\n\t\tconst bodyRef = (isRefSignal ? ref : signal(ref)) as WritableSignal<TObject | undefined>;\n\t\tconst body = computed(() => resolveRef(bodyRef()));\n\n\t\tconst api = computed(() => {\n\t\t\tconst _body = body();\n\t\t\tif (!_body) return null;\n\n\t\t\tconst { worker, ...rest } = physics;\n\t\t\tconst _worker = worker();\n\t\t\tif (!_worker) return null;\n\n\t\t\treturn makeBodyApi(_body, _worker, rest);\n\t\t});\n\n\t\teffect((onCleanup) => {\n\t\t\tconst currentWorker = physics.worker();\n\t\t\tif (!currentWorker) return;\n\n\t\t\tconst object = body();\n\n\t\t\tif (!isRefSignal && !object) {\n\t\t\t\tbodyRef.set(resolveRef(ref));\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!object) return;\n\n\t\t\tconst [uuid, props] = (() => {\n\t\t\t\tlet uuids: string[] = [];\n\t\t\t\tlet temp: THREE.Object3D;\n\t\t\t\tif (is.three<THREE.InstancedMesh>(object, 'isInstancedMesh')) {\n\t\t\t\t\tobject.instanceMatrix.setUsage(THREE.DynamicDrawUsage);\n\t\t\t\t\tuuids = new Array(object.count).fill(0).map((_, i) => `${object.uuid}/${i}`);\n\t\t\t\t\ttemp = new THREE.Object3D();\n\t\t\t\t} else {\n\t\t\t\t\tuuids = [object.uuid];\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\tuuids,\n\t\t\t\t\tuuids.map((id, index) => {\n\t\t\t\t\t\tconst props = getPropFn(index);\n\t\t\t\t\t\tif (temp) {\n\t\t\t\t\t\t\tprepare(temp, props);\n\t\t\t\t\t\t\t(object as unknown as THREE.InstancedMesh).setMatrixAt(index, temp.matrix);\n\t\t\t\t\t\t\t(object as unknown as THREE.InstancedMesh).instanceMatrix.needsUpdate = true;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tprepare(object, props);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tphysics.refs[id] = object;\n\t\t\t\t\t\tdebug?.add(id, props, type);\n\t\t\t\t\t\tsetupCollision(physics.events, props, id);\n\t\t\t\t\t\t// @ts-expect-error - if args is undefined, there's default\n\t\t\t\t\t\treturn { ...props, args: transform(props.args) };\n\t\t\t\t\t}),\n\t\t\t\t];\n\t\t\t})();\n\n\t\t\t// Register on mount, unregister on unmount\n\t\t\tcurrentWorker.addBodies({\n\t\t\t\tprops: props.map(({ onCollide, onCollideBegin, onCollideEnd, ...serializableProps }) => {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tonCollide: Boolean(onCollide),\n\t\t\t\t\t\tonCollideBegin: Boolean(onCollideBegin),\n\t\t\t\t\t\tonCollideEnd: Boolean(onCollideEnd),\n\t\t\t\t\t\t...serializableProps,\n\t\t\t\t\t};\n\t\t\t\t}),\n\t\t\t\ttype,\n\t\t\t\tuuid,\n\t\t\t});\n\n\t\t\tonCleanup(() => {\n\t\t\t\tuuid.forEach((id) => {\n\t\t\t\t\tdelete physics.refs[id];\n\t\t\t\t\tdebug?.remove(id);\n\t\t\t\t\tdelete physics.events[id];\n\t\t\t\t});\n\t\t\t\tcurrentWorker.removeBodies({ uuid });\n\t\t\t});\n\t\t});\n\n\t\treturn api;\n\t});\n}\n\n/**\n * Creates a box-shaped physics body.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = box(() => ({ mass: 1, args: [1, 1, 1], position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const box = createBody('Box');\n\n/**\n * Creates a convex polyhedron physics body from vertices and faces.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = convexPolyhedron(() => ({\n * mass: 1,\n * args: [vertices, faces],\n * position: [0, 5, 0]\n * }), mesh);\n * ```\n */\nexport const convexPolyhedron = createBody('ConvexPolyhedron');\n\n/**\n * Creates a cylinder-shaped physics body.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * // args: [radiusTop, radiusBottom, height, numSegments]\n * const api = cylinder(() => ({ mass: 1, args: [0.5, 0.5, 2, 16], position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const cylinder = createBody('Cylinder');\n\n/**\n * Creates a heightfield physics body for terrain simulation.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const heightData = [[0, 0, 0], [0, 1, 0], [0, 0, 0]];\n * const api = heightfield(() => ({\n * mass: 0,\n * args: [heightData, { elementSize: 1 }],\n * position: [0, 0, 0]\n * }), mesh);\n * ```\n */\nexport const heightfield = createBody('Heightfield');\n\n/**\n * Creates a particle (point mass) physics body with no shape.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = particle(() => ({ mass: 1, position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const particle = createBody('Particle');\n\n/**\n * Creates an infinite plane physics body, typically used for floors or walls.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = plane(() => ({\n * mass: 0, // Static body\n * rotation: [-Math.PI / 2, 0, 0], // Horizontal\n * position: [0, 0, 0]\n * }), mesh);\n * ```\n */\nexport const plane = createBody('Plane');\n\n/**\n * Creates a sphere-shaped physics body.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * // args: [radius]\n * const api = sphere(() => ({ mass: 1, args: [1], position: [0, 5, 0] }), mesh);\n * ```\n */\nexport const sphere = createBody('Sphere');\n\n/**\n * Creates a trimesh physics body from vertices and indices.\n * Useful for complex static geometry like terrain or obstacles.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = trimesh(() => ({\n * mass: 0,\n * args: [vertices, indices],\n * position: [0, 0, 0]\n * }), mesh);\n * ```\n */\nexport const trimesh = createBody('Trimesh');\n\n/**\n * Creates a compound physics body composed of multiple shapes.\n * Useful for complex objects that can be approximated by combining primitives.\n *\n * @param getPropFn - Function returning body properties for each instance index\n * @param ref - Reference to the Three.js Object3D to attach physics to\n * @param options - Optional configuration for the body\n * @returns Signal containing the body's public API, or null if not ready\n *\n * @example\n * ```typescript\n * const mesh = viewChild.required<ElementRef<Mesh>>('mesh');\n * const api = compound(() => ({\n * mass: 1,\n * shapes: [\n * { type: 'Box', args: [1, 1, 1], position: [0, 0, 0] },\n * { type: 'Sphere', args: [0.5], position: [0, 1, 0] }\n * ],\n * position: [0, 5, 0]\n * }), mesh);\n * ```\n */\nexport const compound = createBody('Compound');\n\n/**\n * @deprecated Use `box` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectBox = box;\n\n/**\n * @deprecated Use `convexPolyhedron` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectConvexPolyhedron = convexPolyhedron;\n\n/**\n * @deprecated Use `cylinder` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectCylinder = cylinder;\n\n/**\n * @deprecated Use `heightfield` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectHeightfield = heightfield;\n\n/**\n * @deprecated Use `particle` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectParticle = particle;\n\n/**\n * @deprecated Use `plane` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectPlane = plane;\n\n/**\n * @deprecated Use `sphere` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectSphere = sphere;\n\n/**\n * @deprecated Use `trimesh` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectTrimesh = trimesh;\n\n/**\n * @deprecated Use `compound` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectCompound = compound;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AA2BA,SAAS,UAAU,CAAmB,GAAM,EAAA;AAC3C,IAAA,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AACnD;AAEA,SAAS,OAAO,CAAC,IAAoB,EAAE,KAAc,EAAA;AACpD,IAAA,MAAM,MAAM,GAAG,KAAK,KAAK,SAAS,GAAG,EAAE,GAAG,CAAA,CAAA,EAAI,KAAK,EAAE;IACrD,IAAI,OAAO,IAAI,KAAK,UAAU;AAAE,QAAA,OAAO,IAAI;IAC3C,OAAO,IAAI,IAAI,IAAI,IAAI,CAAA,EAAG,IAAI,CAAC,IAAI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|
@@ -16,8 +16,8 @@ function constraint(type, bodyA, bodyB, { injector, options = {}, disableOnStart
|
|
|
16
16
|
const uuid = makeId();
|
|
17
17
|
const bodyARef = isSignal(bodyA) ? bodyA : signal(bodyA);
|
|
18
18
|
const bodyBRef = isSignal(bodyB) ? bodyB : signal(bodyB);
|
|
19
|
-
const bodyAValue = computed(() => resolveRef(bodyARef()), ...(ngDevMode ? [{ debugName: "bodyAValue" }] : []));
|
|
20
|
-
const bodyBValue = computed(() => resolveRef(bodyBRef()), ...(ngDevMode ? [{ debugName: "bodyBValue" }] : []));
|
|
19
|
+
const bodyAValue = computed(() => resolveRef(bodyARef()), ...(ngDevMode ? [{ debugName: "bodyAValue" }] : /* istanbul ignore next */ []));
|
|
20
|
+
const bodyBValue = computed(() => resolveRef(bodyBRef()), ...(ngDevMode ? [{ debugName: "bodyBValue" }] : /* istanbul ignore next */ []));
|
|
21
21
|
const constraintApi = computed(() => {
|
|
22
22
|
const _worker = worker();
|
|
23
23
|
if (!_worker)
|
|
@@ -37,7 +37,7 @@ function constraint(type, bodyA, bodyB, { injector, options = {}, disableOnStart
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
return enableDisable;
|
|
40
|
-
}, ...(ngDevMode ? [{ debugName: "constraintApi" }] : []));
|
|
40
|
+
}, ...(ngDevMode ? [{ debugName: "constraintApi" }] : /* istanbul ignore next */ []));
|
|
41
41
|
let alreadyDisabled = false;
|
|
42
42
|
effect((onCleanup) => {
|
|
43
43
|
const currentWorker = worker();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-three-cannon-constraint.mjs","sources":["../../../../libs/cannon/constraint/src/lib/constraint.ts","../../../../libs/cannon/constraint/src/angular-three-cannon-constraint.ts"],"sourcesContent":["import { ElementRef, Injector, Signal, computed, effect, inject, isSignal, signal, untracked } from '@angular/core';\nimport {\n\tConeTwistConstraintOpts,\n\tConstraintTypes,\n\tDistanceConstraintOpts,\n\tHingeConstraintOpts,\n\tLockConstraintOpts,\n\tPointToPointConstraintOpts,\n} from '@pmndrs/cannon-worker-api';\nimport { makeId, resolveRef } from 'angular-three';\nimport { NgtcPhysics } from 'angular-three-cannon';\nimport { assertInjector } from 'ngxtension/assert-injector';\nimport * as THREE from 'three';\n\n/**\n * API for controlling a physics constraint between two bodies.\n * Provides methods to enable, disable, and remove the constraint.\n */\nexport interface NgtcConstraintApi {\n\t/** Disable the constraint, allowing bodies to move freely */\n\tdisable: () => void;\n\t/** Enable the constraint, restricting body movement */\n\tenable: () => void;\n\t/** Remove the constraint from the physics world entirely */\n\tremove: () => void;\n}\n\n/**\n * Extended API for hinge constraints with motor control.\n * Adds motor-specific methods on top of the base constraint API.\n */\nexport interface NgtcHingeConstraintApi extends NgtcConstraintApi {\n\t/** Disable the hinge motor */\n\tdisableMotor: () => void;\n\t/** Enable the hinge motor for powered rotation */\n\tenableMotor: () => void;\n\t/**\n\t * Set the maximum force the motor can apply.\n\t * @param value - Maximum force in Newtons\n\t */\n\tsetMotorMaxForce: (value: number) => void;\n\t/**\n\t * Set the target angular velocity of the motor.\n\t * @param value - Target speed in radians per second\n\t */\n\tsetMotorSpeed: (value: number) => void;\n}\n\n/**\n * Conditional type that returns the appropriate API type based on constraint type.\n * Returns NgtcHingeConstraintApi for 'Hinge', NgtcConstraintApi for all others.\n * @template T - The constraint type\n */\nexport type NgtcConstraintORHingeApi<T extends 'Hinge' | ConstraintTypes> = T extends ConstraintTypes\n\t? NgtcConstraintApi\n\t: NgtcHingeConstraintApi;\n\n/**\n * Maps constraint types to their configuration option types.\n */\nexport type NgtcConstraintOptionsMap = {\n\t/** Options for cone-twist constraints (ball-socket with limits) */\n\tConeTwist: ConeTwistConstraintOpts;\n\t/** Options for point-to-point constraints (ball-socket) */\n\tPointToPoint: PointToPointConstraintOpts;\n\t/** Options for distance constraints (fixed distance between points) */\n\tDistance: DistanceConstraintOpts;\n\t/** Options for lock constraints (bodies locked together) */\n\tLock: LockConstraintOpts;\n\t/** Options for hinge constraints (single-axis rotation) */\n\tHinge: HingeConstraintOpts;\n};\n\n/**\n * Configuration options for creating a physics constraint.\n * @template TConstraintType - The type of constraint being created\n */\nexport type NgtcConstraintOptions<TConstraintType extends 'Hinge' | ConstraintTypes> = {\n\t/**\n\t * Angular injector to use for dependency injection.\n\t * If not provided, uses the current injection context.\n\t */\n\tinjector?: Injector;\n\t/**\n\t * Whether to create the constraint in a disabled state.\n\t * @default false\n\t */\n\tdisableOnStart?: boolean;\n\t/** Constraint-specific configuration options */\n\toptions?: NgtcConstraintOptionsMap[TConstraintType];\n};\n\nfunction createConstraint<TConstraint extends ConstraintTypes | 'Hinge'>(type: TConstraint) {\n\treturn <A extends THREE.Object3D = THREE.Object3D, B extends THREE.Object3D = THREE.Object3D>(\n\t\tbodyA: ElementRef<A> | A | Signal<ElementRef<A> | A | undefined>,\n\t\tbodyB: ElementRef<B> | B | Signal<ElementRef<B> | B | undefined>,\n\t\toptions?: NgtcConstraintOptions<TConstraint>,\n\t) => constraint<TConstraint, A, B>(type, bodyA, bodyB, options);\n}\n\nfunction constraint<\n\tTConstraint extends ConstraintTypes | 'Hinge',\n\tA extends THREE.Object3D = THREE.Object3D,\n\tB extends THREE.Object3D = THREE.Object3D,\n>(\n\ttype: TConstraint,\n\tbodyA: ElementRef<A> | A | Signal<ElementRef<A> | A | undefined>,\n\tbodyB: ElementRef<B> | B | Signal<ElementRef<B> | B | undefined>,\n\t{\n\t\tinjector,\n\t\toptions = {} as NgtcConstraintOptionsMap[TConstraint],\n\t\tdisableOnStart = false,\n\t}: NgtcConstraintOptions<TConstraint> = {},\n) {\n\treturn assertInjector(constraint, injector, () => {\n\t\tconst physics = inject(NgtcPhysics, { optional: true });\n\n\t\tif (!physics) {\n\t\t\tthrow new Error(`[NGT Cannon] injectConstraint was called outside of <ngtc-physics>`);\n\t\t}\n\n\t\tconst worker = physics.worker;\n\n\t\tconst uuid = makeId();\n\t\tconst bodyARef = isSignal(bodyA) ? bodyA : signal(bodyA);\n\t\tconst bodyBRef = isSignal(bodyB) ? bodyB : signal(bodyB);\n\t\tconst bodyAValue = computed(() => resolveRef(bodyARef()));\n\t\tconst bodyBValue = computed(() => resolveRef(bodyBRef()));\n\n\t\tconst constraintApi = computed(() => {\n\t\t\tconst _worker = worker();\n\t\t\tif (!_worker) return null;\n\n\t\t\tconst enableDisable = {\n\t\t\t\tdisable: () => _worker.disableConstraint({ uuid }),\n\t\t\t\tenable: () => _worker.enableConstraint({ uuid }),\n\t\t\t\tremove: () => _worker.removeConstraint({ uuid }),\n\t\t\t};\n\t\t\tif (type === 'Hinge') {\n\t\t\t\treturn {\n\t\t\t\t\t...enableDisable,\n\t\t\t\t\tdisableMotor: () => _worker.disableConstraintMotor({ uuid }),\n\t\t\t\t\tenableMotor: () => _worker.enableConstraintMotor({ uuid }),\n\t\t\t\t\tsetMotorMaxForce: (value: number) => _worker.setConstraintMotorMaxForce({ props: value, uuid }),\n\t\t\t\t\tsetMotorSpeed: (value: number) => _worker.setConstraintMotorSpeed({ props: value, uuid }),\n\t\t\t\t} as NgtcHingeConstraintApi;\n\t\t\t}\n\t\t\treturn enableDisable as NgtcConstraintApi;\n\t\t});\n\n\t\tlet alreadyDisabled = false;\n\t\teffect((onCleanup) => {\n\t\t\tconst currentWorker = worker();\n\t\t\tif (!currentWorker) return;\n\n\t\t\tconst [a, b, api] = [bodyAValue(), bodyBValue(), untracked(constraintApi)];\n\t\t\tif (!a || !b) return;\n\n\t\t\tcurrentWorker.addConstraint({\n\t\t\t\tprops: [a.uuid, b.uuid, options],\n\t\t\t\ttype,\n\t\t\t\tuuid,\n\t\t\t});\n\n\t\t\tif (disableOnStart && !alreadyDisabled) {\n\t\t\t\talreadyDisabled = true;\n\t\t\t\tapi?.disable();\n\t\t\t}\n\n\t\t\tonCleanup(() => currentWorker.removeConstraint({ uuid }));\n\t\t});\n\n\t\treturn constraintApi;\n\t});\n}\n\n/**\n * Creates a point-to-point (ball-socket) constraint between two physics bodies.\n * This constraint keeps the pivot points of both bodies at the same world position.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = pointToPoint(meshA, meshB, {\n * options: { pivotA: [0, 1, 0], pivotB: [0, -1, 0] }\n * });\n * ```\n */\nexport const pointToPoint = createConstraint('PointToPoint');\n\n/**\n * Creates a cone-twist constraint between two physics bodies.\n * Similar to a ball-socket joint but with configurable angular limits.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = coneTwist(meshA, meshB, {\n * options: {\n * pivotA: [0, 1, 0],\n * pivotB: [0, -1, 0],\n * axisA: [0, 1, 0],\n * axisB: [0, 1, 0],\n * angle: Math.PI / 4,\n * twistAngle: Math.PI / 8\n * }\n * });\n * ```\n */\nexport const coneTwist = createConstraint('ConeTwist');\n\n/**\n * Creates a distance constraint between two physics bodies.\n * Maintains a fixed distance between two points on the bodies.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = distance(meshA, meshB, {\n * options: { distance: 5 }\n * });\n * ```\n */\nexport const distance = createConstraint('Distance');\n\n/**\n * Creates a lock constraint between two physics bodies.\n * Locks the bodies together at their current relative positions and orientations.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = lock(meshA, meshB);\n * ```\n */\nexport const lock = createConstraint('Lock');\n\n/**\n * Creates a hinge constraint between two physics bodies.\n * Allows rotation around a single axis, like a door hinge.\n * Includes motor control for powered rotation.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the hinge constraint API with motor controls, or null if not ready\n *\n * @example\n * ```typescript\n * const door = viewChild.required<ElementRef<Mesh>>('door');\n * const frame = viewChild.required<ElementRef<Mesh>>('frame');\n * const api = hinge(door, frame, {\n * options: {\n * pivotA: [-1, 0, 0],\n * pivotB: [1, 0, 0],\n * axisA: [0, 1, 0],\n * axisB: [0, 1, 0]\n * }\n * });\n *\n * // Enable motor for automatic rotation\n * api()?.enableMotor();\n * api()?.setMotorSpeed(2);\n * api()?.setMotorMaxForce(100);\n * ```\n */\nexport const hinge = createConstraint('Hinge');\n\n/**\n * @deprecated Use `pointToPoint` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectPointToPoint = pointToPoint;\n\n/**\n * @deprecated Use `coneTwist` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectConeTwist = coneTwist;\n\n/**\n * @deprecated Use `distance` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectDistance = distance;\n\n/**\n * @deprecated Use `lock` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectLock = lock;\n\n/**\n * @deprecated Use `hinge` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectHinge = hinge;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AA4FA,SAAS,gBA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,CAAC;AAEF,YAAA,IAAI,cAAc,IAAI,CAAC,eAAe,EAAE;gBACvC,eAAe,GAAG,IAAI;gBACtB,GAAG,EAAE,OAAO,EAAE;YACf;AAEA,YAAA,SAAS,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,QAAA,CAAC,CAAC;AAEF,QAAA,OAAO,aAAa;AACrB,IAAA,CAAC,CAAC;AACH;AAEA;;;;;;;;;;;;;;;;;AAiBG;MACU,YAAY,GAAG,gBAAgB,CAAC,cAAc;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MACU,SAAS,GAAG,gBAAgB,CAAC,WAAW;AAErD;;;;;;;;;;;;;;;;;AAiBG;MACU,QAAQ,GAAG,gBAAgB,CAAC,UAAU;AAEnD;;;;;;;;;;;;;;;AAeG;MACU,IAAI,GAAG,gBAAgB,CAAC,MAAM;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;MACU,KAAK,GAAG,gBAAgB,CAAC,OAAO;AAE7C;;;AAGG;AACI,MAAM,kBAAkB,GAAG;AAElC;;;AAGG;AACI,MAAM,eAAe,GAAG;AAE/B;;;AAGG;AACI,MAAM,cAAc,GAAG;AAE9B;;;AAGG;AACI,MAAM,UAAU,GAAG;AAE1B;;;AAGG;AACI,MAAM,WAAW,GAAG;;AChU3B;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"angular-three-cannon-constraint.mjs","sources":["../../../../libs/cannon/constraint/src/lib/constraint.ts","../../../../libs/cannon/constraint/src/angular-three-cannon-constraint.ts"],"sourcesContent":["import { ElementRef, Injector, Signal, computed, effect, inject, isSignal, signal, untracked } from '@angular/core';\nimport {\n\tConeTwistConstraintOpts,\n\tConstraintTypes,\n\tDistanceConstraintOpts,\n\tHingeConstraintOpts,\n\tLockConstraintOpts,\n\tPointToPointConstraintOpts,\n} from '@pmndrs/cannon-worker-api';\nimport { makeId, resolveRef } from 'angular-three';\nimport { NgtcPhysics } from 'angular-three-cannon';\nimport { assertInjector } from 'ngxtension/assert-injector';\nimport * as THREE from 'three';\n\n/**\n * API for controlling a physics constraint between two bodies.\n * Provides methods to enable, disable, and remove the constraint.\n */\nexport interface NgtcConstraintApi {\n\t/** Disable the constraint, allowing bodies to move freely */\n\tdisable: () => void;\n\t/** Enable the constraint, restricting body movement */\n\tenable: () => void;\n\t/** Remove the constraint from the physics world entirely */\n\tremove: () => void;\n}\n\n/**\n * Extended API for hinge constraints with motor control.\n * Adds motor-specific methods on top of the base constraint API.\n */\nexport interface NgtcHingeConstraintApi extends NgtcConstraintApi {\n\t/** Disable the hinge motor */\n\tdisableMotor: () => void;\n\t/** Enable the hinge motor for powered rotation */\n\tenableMotor: () => void;\n\t/**\n\t * Set the maximum force the motor can apply.\n\t * @param value - Maximum force in Newtons\n\t */\n\tsetMotorMaxForce: (value: number) => void;\n\t/**\n\t * Set the target angular velocity of the motor.\n\t * @param value - Target speed in radians per second\n\t */\n\tsetMotorSpeed: (value: number) => void;\n}\n\n/**\n * Conditional type that returns the appropriate API type based on constraint type.\n * Returns NgtcHingeConstraintApi for 'Hinge', NgtcConstraintApi for all others.\n * @template T - The constraint type\n */\nexport type NgtcConstraintORHingeApi<T extends 'Hinge' | ConstraintTypes> = T extends ConstraintTypes\n\t? NgtcConstraintApi\n\t: NgtcHingeConstraintApi;\n\n/**\n * Maps constraint types to their configuration option types.\n */\nexport type NgtcConstraintOptionsMap = {\n\t/** Options for cone-twist constraints (ball-socket with limits) */\n\tConeTwist: ConeTwistConstraintOpts;\n\t/** Options for point-to-point constraints (ball-socket) */\n\tPointToPoint: PointToPointConstraintOpts;\n\t/** Options for distance constraints (fixed distance between points) */\n\tDistance: DistanceConstraintOpts;\n\t/** Options for lock constraints (bodies locked together) */\n\tLock: LockConstraintOpts;\n\t/** Options for hinge constraints (single-axis rotation) */\n\tHinge: HingeConstraintOpts;\n};\n\n/**\n * Configuration options for creating a physics constraint.\n * @template TConstraintType - The type of constraint being created\n */\nexport type NgtcConstraintOptions<TConstraintType extends 'Hinge' | ConstraintTypes> = {\n\t/**\n\t * Angular injector to use for dependency injection.\n\t * If not provided, uses the current injection context.\n\t */\n\tinjector?: Injector;\n\t/**\n\t * Whether to create the constraint in a disabled state.\n\t * @default false\n\t */\n\tdisableOnStart?: boolean;\n\t/** Constraint-specific configuration options */\n\toptions?: NgtcConstraintOptionsMap[TConstraintType];\n};\n\nfunction createConstraint<TConstraint extends ConstraintTypes | 'Hinge'>(type: TConstraint) {\n\treturn <A extends THREE.Object3D = THREE.Object3D, B extends THREE.Object3D = THREE.Object3D>(\n\t\tbodyA: ElementRef<A> | A | Signal<ElementRef<A> | A | undefined>,\n\t\tbodyB: ElementRef<B> | B | Signal<ElementRef<B> | B | undefined>,\n\t\toptions?: NgtcConstraintOptions<TConstraint>,\n\t) => constraint<TConstraint, A, B>(type, bodyA, bodyB, options);\n}\n\nfunction constraint<\n\tTConstraint extends ConstraintTypes | 'Hinge',\n\tA extends THREE.Object3D = THREE.Object3D,\n\tB extends THREE.Object3D = THREE.Object3D,\n>(\n\ttype: TConstraint,\n\tbodyA: ElementRef<A> | A | Signal<ElementRef<A> | A | undefined>,\n\tbodyB: ElementRef<B> | B | Signal<ElementRef<B> | B | undefined>,\n\t{\n\t\tinjector,\n\t\toptions = {} as NgtcConstraintOptionsMap[TConstraint],\n\t\tdisableOnStart = false,\n\t}: NgtcConstraintOptions<TConstraint> = {},\n) {\n\treturn assertInjector(constraint, injector, () => {\n\t\tconst physics = inject(NgtcPhysics, { optional: true });\n\n\t\tif (!physics) {\n\t\t\tthrow new Error(`[NGT Cannon] injectConstraint was called outside of <ngtc-physics>`);\n\t\t}\n\n\t\tconst worker = physics.worker;\n\n\t\tconst uuid = makeId();\n\t\tconst bodyARef = isSignal(bodyA) ? bodyA : signal(bodyA);\n\t\tconst bodyBRef = isSignal(bodyB) ? bodyB : signal(bodyB);\n\t\tconst bodyAValue = computed(() => resolveRef(bodyARef()));\n\t\tconst bodyBValue = computed(() => resolveRef(bodyBRef()));\n\n\t\tconst constraintApi = computed(() => {\n\t\t\tconst _worker = worker();\n\t\t\tif (!_worker) return null;\n\n\t\t\tconst enableDisable = {\n\t\t\t\tdisable: () => _worker.disableConstraint({ uuid }),\n\t\t\t\tenable: () => _worker.enableConstraint({ uuid }),\n\t\t\t\tremove: () => _worker.removeConstraint({ uuid }),\n\t\t\t};\n\t\t\tif (type === 'Hinge') {\n\t\t\t\treturn {\n\t\t\t\t\t...enableDisable,\n\t\t\t\t\tdisableMotor: () => _worker.disableConstraintMotor({ uuid }),\n\t\t\t\t\tenableMotor: () => _worker.enableConstraintMotor({ uuid }),\n\t\t\t\t\tsetMotorMaxForce: (value: number) => _worker.setConstraintMotorMaxForce({ props: value, uuid }),\n\t\t\t\t\tsetMotorSpeed: (value: number) => _worker.setConstraintMotorSpeed({ props: value, uuid }),\n\t\t\t\t} as NgtcHingeConstraintApi;\n\t\t\t}\n\t\t\treturn enableDisable as NgtcConstraintApi;\n\t\t});\n\n\t\tlet alreadyDisabled = false;\n\t\teffect((onCleanup) => {\n\t\t\tconst currentWorker = worker();\n\t\t\tif (!currentWorker) return;\n\n\t\t\tconst [a, b, api] = [bodyAValue(), bodyBValue(), untracked(constraintApi)];\n\t\t\tif (!a || !b) return;\n\n\t\t\tcurrentWorker.addConstraint({\n\t\t\t\tprops: [a.uuid, b.uuid, options],\n\t\t\t\ttype,\n\t\t\t\tuuid,\n\t\t\t});\n\n\t\t\tif (disableOnStart && !alreadyDisabled) {\n\t\t\t\talreadyDisabled = true;\n\t\t\t\tapi?.disable();\n\t\t\t}\n\n\t\t\tonCleanup(() => currentWorker.removeConstraint({ uuid }));\n\t\t});\n\n\t\treturn constraintApi;\n\t});\n}\n\n/**\n * Creates a point-to-point (ball-socket) constraint between two physics bodies.\n * This constraint keeps the pivot points of both bodies at the same world position.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = pointToPoint(meshA, meshB, {\n * options: { pivotA: [0, 1, 0], pivotB: [0, -1, 0] }\n * });\n * ```\n */\nexport const pointToPoint = createConstraint('PointToPoint');\n\n/**\n * Creates a cone-twist constraint between two physics bodies.\n * Similar to a ball-socket joint but with configurable angular limits.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = coneTwist(meshA, meshB, {\n * options: {\n * pivotA: [0, 1, 0],\n * pivotB: [0, -1, 0],\n * axisA: [0, 1, 0],\n * axisB: [0, 1, 0],\n * angle: Math.PI / 4,\n * twistAngle: Math.PI / 8\n * }\n * });\n * ```\n */\nexport const coneTwist = createConstraint('ConeTwist');\n\n/**\n * Creates a distance constraint between two physics bodies.\n * Maintains a fixed distance between two points on the bodies.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = distance(meshA, meshB, {\n * options: { distance: 5 }\n * });\n * ```\n */\nexport const distance = createConstraint('Distance');\n\n/**\n * Creates a lock constraint between two physics bodies.\n * Locks the bodies together at their current relative positions and orientations.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the constraint API, or null if not ready\n *\n * @example\n * ```typescript\n * const meshA = viewChild.required<ElementRef<Mesh>>('meshA');\n * const meshB = viewChild.required<ElementRef<Mesh>>('meshB');\n * const api = lock(meshA, meshB);\n * ```\n */\nexport const lock = createConstraint('Lock');\n\n/**\n * Creates a hinge constraint between two physics bodies.\n * Allows rotation around a single axis, like a door hinge.\n * Includes motor control for powered rotation.\n *\n * @param bodyA - Reference to the first physics body's Three.js object\n * @param bodyB - Reference to the second physics body's Three.js object\n * @param options - Optional constraint configuration\n * @returns Signal containing the hinge constraint API with motor controls, or null if not ready\n *\n * @example\n * ```typescript\n * const door = viewChild.required<ElementRef<Mesh>>('door');\n * const frame = viewChild.required<ElementRef<Mesh>>('frame');\n * const api = hinge(door, frame, {\n * options: {\n * pivotA: [-1, 0, 0],\n * pivotB: [1, 0, 0],\n * axisA: [0, 1, 0],\n * axisB: [0, 1, 0]\n * }\n * });\n *\n * // Enable motor for automatic rotation\n * api()?.enableMotor();\n * api()?.setMotorSpeed(2);\n * api()?.setMotorMaxForce(100);\n * ```\n */\nexport const hinge = createConstraint('Hinge');\n\n/**\n * @deprecated Use `pointToPoint` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectPointToPoint = pointToPoint;\n\n/**\n * @deprecated Use `coneTwist` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectConeTwist = coneTwist;\n\n/**\n * @deprecated Use `distance` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectDistance = distance;\n\n/**\n * @deprecated Use `lock` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectLock = lock;\n\n/**\n * @deprecated Use `hinge` instead. Will be removed in v5.0.0\n * @since v4.0.0\n */\nexport const injectHinge = hinge;\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AA4FA,SAAS,gBAAgB,CAAgD,IAAiB,EAAA;AACzF,IAAA,OAAO,CACN,KAAgE,EAChE,KAAgE,EAChE,OAA4C,KACxC,UA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AG,EAAE,OAAO,EAAE;YACf;AAEA,YAAA,SAAS,CAAC,MAAM,aAAa,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1D,QAAA,CAAC,CAAC;AAEF,QAAA,OAAO,aAAa;AACrB,IAAA,CAAC,CAAC;AACH;AAEA;;;;;;;;;;;;;;;;;AAiBG;MACU,YAAY,GAAG,gBAAgB,CAAC,cAAc;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;MACU,SAAS,GAAG,gBAAgB,CAAC,WAAW;AAErD;;;;;;;;;;;;;;;;;AAiBG;MACU,QAAQ,GAAG,gBAAgB,CAAC,UAAU;AAEnD;;;;;;;;;;;;;;;AAeG;MACU,IAAI,GAAG,gBAAgB,CAAC,MAAM;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;MACU,KAAK,GAAG,gBAAgB,CAAC,OAAO;AAE7C;;;AAGG;AACI,MAAM,kBAAkB,GAAG;AAElC;;;AAGG;AACI,MAAM,eAAe,GAAG;AAE/B;;;AAGG;AACI,MAAM,cAAc,GAAG;AAE9B;;;AAGG;AACI,MAAM,UAAU,GAAG;AAE1B;;;AAGG;AACI,MAAM,WAAW,GAAG;;AChU3B;;AAEG;;;;"}
|
|
@@ -57,7 +57,7 @@ class NgtcDebug {
|
|
|
57
57
|
* Debug visualization configuration options.
|
|
58
58
|
* @see NgtcDebugInputs for available options
|
|
59
59
|
*/
|
|
60
|
-
this.debug = input(defaultOptions, { ...(ngDevMode ? { debugName: "debug" } : {}), transform: mergeInputs(defaultOptions) });
|
|
60
|
+
this.debug = input(defaultOptions, { ...(ngDevMode ? { debugName: "debug" } : /* istanbul ignore next */ {}), transform: mergeInputs(defaultOptions) });
|
|
61
61
|
this.physics = inject(NgtcPhysics);
|
|
62
62
|
this.store = injectStore();
|
|
63
63
|
this.defaultScene = this.store.scene;
|
|
@@ -117,10 +117,10 @@ class NgtcDebug {
|
|
|
117
117
|
this.bodies.splice(debugBodyIndex, 1);
|
|
118
118
|
delete this.bodyMap[uuid];
|
|
119
119
|
}
|
|
120
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
121
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
120
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgtcDebug, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
121
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: NgtcDebug, isStandalone: true, selector: "ngtc-physics[debug]", inputs: { debug: { classPropertyName: "debug", publicName: "debug", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
122
122
|
}
|
|
123
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgtcDebug, decorators: [{
|
|
124
124
|
type: Directive,
|
|
125
125
|
args: [{ selector: 'ngtc-physics[debug]' }]
|
|
126
126
|
}], ctorParameters: () => [], propDecorators: { debug: [{ type: i0.Input, args: [{ isSignal: true, alias: "debug", required: false }] }] } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-three-cannon-debug.mjs","sources":["../../../../libs/cannon/debug/src/lib/debug.ts","../../../../libs/cannon/debug/src/angular-three-cannon-debug.ts"],"sourcesContent":["import { Directive, afterNextRender, inject, input } from '@angular/core';\nimport { BodyProps, BodyShapeType, propsToBody } from '@pmndrs/cannon-worker-api';\nimport { beforeRender, injectStore, is } from 'angular-three';\nimport { NgtcPhysics } from 'angular-three-cannon';\nimport { Body, Quaternion as CQuarternion, Vec3, World } from 'cannon-es';\nimport CannonDebugger from 'cannon-es-debugger';\nimport { mergeInputs } from 'ngxtension/inject-inputs';\nimport * as THREE from 'three';\n\nconst q = new THREE.Quaternion();\nconst s = new THREE.Vector3(1, 1, 1);\nconst v = new THREE.Vector3();\nconst m = new THREE.Matrix4();\n\nfunction getMatrix(o: THREE.Object3D) {\n\tif (is.three<THREE.InstancedMesh>(o, 'isInstancedMesh')) {\n\t\to.getMatrixAt(parseInt(o.uuid.split('/')[1]), m);\n\t\treturn m;\n\t}\n\treturn o.matrix;\n}\n\n/**\n * Configuration options for the physics debug visualization.\n */\nexport interface NgtcDebugInputs {\n\t/**\n\t * Whether debug visualization is enabled.\n\t * @default true\n\t */\n\tenabled: boolean;\n\t/**\n\t * Color of the debug wireframes.\n\t * @default 'black'\n\t */\n\tcolor: string;\n\t/**\n\t * Custom CannonDebugger implementation to use.\n\t * @default CannonDebugger from 'cannon-es-debugger'\n\t */\n\timpl: typeof CannonDebugger;\n\t/**\n\t * Scale factor for debug visualization.\n\t * @default 1\n\t */\n\tscale: number;\n}\n\nconst defaultOptions: NgtcDebugInputs = {\n\tenabled: true,\n\tscale: 1,\n\tcolor: 'black',\n\timpl: CannonDebugger,\n};\n\n/**\n * Angular directive that adds debug visualization to the physics simulation.\n * Renders wireframe shapes for all physics bodies to help with debugging.\n *\n * Must be used as an attribute on the `ngtc-physics` directive.\n *\n * @example\n * ```html\n * <ngtc-physics\n * [options]=\"{ gravity: [0, -9.81, 0] }\"\n * [debug]=\"{ enabled: true, color: 'red', scale: 1 }\"\n * >\n * <app-physics-scene />\n * </ngtc-physics>\n * ```\n *\n * @example\n * ```html\n * <!-- Toggle debug visualization based on state -->\n * <ngtc-physics\n * [options]=\"physicsOptions\"\n * [debug]=\"{ enabled: isDebugging() }\"\n * >\n * <app-physics-scene />\n * </ngtc-physics>\n * ```\n */\n@Directive({ selector: 'ngtc-physics[debug]' })\nexport class NgtcDebug {\n\t/**\n\t * Debug visualization configuration options.\n\t * @see NgtcDebugInputs for available options\n\t */\n\tdebug = input(defaultOptions, { transform: mergeInputs(defaultOptions) });\n\n\tprivate physics = inject(NgtcPhysics);\n\n\tprivate store = injectStore();\n\tprivate defaultScene = this.store.scene;\n\n\tprivate debuggerScene = new THREE.Scene();\n\tprivate bodies: Body[] = [];\n\tprivate bodyMap: Record<string, Body> = {};\n\n\tprivate cannonDebugger!: ReturnType<typeof CannonDebugger>;\n\n\tconstructor() {\n\t\t// NOTE: afterNextRender so we only instantiate once after inputs have been resolved\n\t\tafterNextRender(() => {\n\t\t\tthis.defaultScene().add(this.debuggerScene);\n\t\t\tthis.cannonDebugger = this.debug().impl(this.debuggerScene, { bodies: this.bodies } as World, {\n\t\t\t\tcolor: this.debug().color,\n\t\t\t\tscale: this.debug().scale,\n\t\t\t});\n\t\t});\n\n\t\tbeforeRender(() => {\n\t\t\tif (!this.cannonDebugger) return;\n\n\t\t\tconst enabled = this.debug().enabled;\n\t\t\tconst refs = this.physics.refs;\n\t\t\tfor (const uuid in this.bodyMap) {\n\t\t\t\tconst ref = refs[uuid];\n\t\t\t\tconst body = this.bodyMap[uuid];\n\t\t\t\tif (ref) {\n\t\t\t\t\tgetMatrix(ref).decompose(v, q, s);\n\t\t\t\t\tbody.position.copy(v as unknown as Vec3);\n\t\t\t\t\tbody.quaternion.copy(q as unknown as CQuarternion);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const child of this.debuggerScene.children) child.visible = enabled;\n\t\t\tif (enabled) this.cannonDebugger.update();\n\t\t});\n\t}\n\n\t/**\n\t * Adds a physics body to the debug visualization.\n\t * Called internally when a new body is created in the physics world.\n\t *\n\t * @param uuid - Unique identifier for the body\n\t * @param props - Body properties including shape, position, and rotation\n\t * @param type - The shape type of the physics body\n\t */\n\tadd(uuid: string, props: BodyProps, type: BodyShapeType) {\n\t\tconst body = propsToBody({ uuid, props, type });\n\t\tthis.bodies.push(body);\n\t\tthis.bodyMap[uuid] = body;\n\t}\n\n\t/**\n\t * Removes a physics body from the debug visualization.\n\t * Called internally when a body is removed from the physics world.\n\t *\n\t * @param uuid - Unique identifier for the body to remove\n\t */\n\tremove(uuid: string) {\n\t\tconst debugBodyIndex = this.bodies.indexOf(this.bodyMap[uuid]);\n\t\tif (debugBodyIndex > -1) this.bodies.splice(debugBodyIndex, 1);\n\t\tdelete this.bodyMap[uuid];\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE;AAChC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE;AAC7B,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE;AAE7B,SAAS,SAAS,CAAC,CAAiB,EAAA;IACnC,IAAI,EAAE,CAAC,KAAK,CAAsB,CAAC,EAAE,iBAAiB,CAAC,EAAE;QACxD,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChD,QAAA,OAAO,CAAC;IACT;IACA,OAAO,CAAC,CAAC,MAAM;AAChB;AA4BA,MAAM,cAAc,GAAoB;AACvC,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,IAAI,EAAE,cAAc;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BG;MAEU,SAAS,CAAA;AAkBrB,IAAA,WAAA,GAAA;AAjBA;;;AAGG;AACH,QAAA,IAAA,CAAA,KAAK,GAAG,KAAK,CAAC,cAAc,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,OAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"angular-three-cannon-debug.mjs","sources":["../../../../libs/cannon/debug/src/lib/debug.ts","../../../../libs/cannon/debug/src/angular-three-cannon-debug.ts"],"sourcesContent":["import { Directive, afterNextRender, inject, input } from '@angular/core';\nimport { BodyProps, BodyShapeType, propsToBody } from '@pmndrs/cannon-worker-api';\nimport { beforeRender, injectStore, is } from 'angular-three';\nimport { NgtcPhysics } from 'angular-three-cannon';\nimport { Body, Quaternion as CQuarternion, Vec3, World } from 'cannon-es';\nimport CannonDebugger from 'cannon-es-debugger';\nimport { mergeInputs } from 'ngxtension/inject-inputs';\nimport * as THREE from 'three';\n\nconst q = new THREE.Quaternion();\nconst s = new THREE.Vector3(1, 1, 1);\nconst v = new THREE.Vector3();\nconst m = new THREE.Matrix4();\n\nfunction getMatrix(o: THREE.Object3D) {\n\tif (is.three<THREE.InstancedMesh>(o, 'isInstancedMesh')) {\n\t\to.getMatrixAt(parseInt(o.uuid.split('/')[1]), m);\n\t\treturn m;\n\t}\n\treturn o.matrix;\n}\n\n/**\n * Configuration options for the physics debug visualization.\n */\nexport interface NgtcDebugInputs {\n\t/**\n\t * Whether debug visualization is enabled.\n\t * @default true\n\t */\n\tenabled: boolean;\n\t/**\n\t * Color of the debug wireframes.\n\t * @default 'black'\n\t */\n\tcolor: string;\n\t/**\n\t * Custom CannonDebugger implementation to use.\n\t * @default CannonDebugger from 'cannon-es-debugger'\n\t */\n\timpl: typeof CannonDebugger;\n\t/**\n\t * Scale factor for debug visualization.\n\t * @default 1\n\t */\n\tscale: number;\n}\n\nconst defaultOptions: NgtcDebugInputs = {\n\tenabled: true,\n\tscale: 1,\n\tcolor: 'black',\n\timpl: CannonDebugger,\n};\n\n/**\n * Angular directive that adds debug visualization to the physics simulation.\n * Renders wireframe shapes for all physics bodies to help with debugging.\n *\n * Must be used as an attribute on the `ngtc-physics` directive.\n *\n * @example\n * ```html\n * <ngtc-physics\n * [options]=\"{ gravity: [0, -9.81, 0] }\"\n * [debug]=\"{ enabled: true, color: 'red', scale: 1 }\"\n * >\n * <app-physics-scene />\n * </ngtc-physics>\n * ```\n *\n * @example\n * ```html\n * <!-- Toggle debug visualization based on state -->\n * <ngtc-physics\n * [options]=\"physicsOptions\"\n * [debug]=\"{ enabled: isDebugging() }\"\n * >\n * <app-physics-scene />\n * </ngtc-physics>\n * ```\n */\n@Directive({ selector: 'ngtc-physics[debug]' })\nexport class NgtcDebug {\n\t/**\n\t * Debug visualization configuration options.\n\t * @see NgtcDebugInputs for available options\n\t */\n\tdebug = input(defaultOptions, { transform: mergeInputs(defaultOptions) });\n\n\tprivate physics = inject(NgtcPhysics);\n\n\tprivate store = injectStore();\n\tprivate defaultScene = this.store.scene;\n\n\tprivate debuggerScene = new THREE.Scene();\n\tprivate bodies: Body[] = [];\n\tprivate bodyMap: Record<string, Body> = {};\n\n\tprivate cannonDebugger!: ReturnType<typeof CannonDebugger>;\n\n\tconstructor() {\n\t\t// NOTE: afterNextRender so we only instantiate once after inputs have been resolved\n\t\tafterNextRender(() => {\n\t\t\tthis.defaultScene().add(this.debuggerScene);\n\t\t\tthis.cannonDebugger = this.debug().impl(this.debuggerScene, { bodies: this.bodies } as World, {\n\t\t\t\tcolor: this.debug().color,\n\t\t\t\tscale: this.debug().scale,\n\t\t\t});\n\t\t});\n\n\t\tbeforeRender(() => {\n\t\t\tif (!this.cannonDebugger) return;\n\n\t\t\tconst enabled = this.debug().enabled;\n\t\t\tconst refs = this.physics.refs;\n\t\t\tfor (const uuid in this.bodyMap) {\n\t\t\t\tconst ref = refs[uuid];\n\t\t\t\tconst body = this.bodyMap[uuid];\n\t\t\t\tif (ref) {\n\t\t\t\t\tgetMatrix(ref).decompose(v, q, s);\n\t\t\t\t\tbody.position.copy(v as unknown as Vec3);\n\t\t\t\t\tbody.quaternion.copy(q as unknown as CQuarternion);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const child of this.debuggerScene.children) child.visible = enabled;\n\t\t\tif (enabled) this.cannonDebugger.update();\n\t\t});\n\t}\n\n\t/**\n\t * Adds a physics body to the debug visualization.\n\t * Called internally when a new body is created in the physics world.\n\t *\n\t * @param uuid - Unique identifier for the body\n\t * @param props - Body properties including shape, position, and rotation\n\t * @param type - The shape type of the physics body\n\t */\n\tadd(uuid: string, props: BodyProps, type: BodyShapeType) {\n\t\tconst body = propsToBody({ uuid, props, type });\n\t\tthis.bodies.push(body);\n\t\tthis.bodyMap[uuid] = body;\n\t}\n\n\t/**\n\t * Removes a physics body from the debug visualization.\n\t * Called internally when a body is removed from the physics world.\n\t *\n\t * @param uuid - Unique identifier for the body to remove\n\t */\n\tremove(uuid: string) {\n\t\tconst debugBodyIndex = this.bodies.indexOf(this.bodyMap[uuid]);\n\t\tif (debugBodyIndex > -1) this.bodies.splice(debugBodyIndex, 1);\n\t\tdelete this.bodyMap[uuid];\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AASA,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE;AAChC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE;AAC7B,MAAM,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE;AAE7B,SAAS,SAAS,CAAC,CAAiB,EAAA;IACnC,IAAI,EAAE,CAAC,KAAK,CAAsB,CAAC,EAAE,iBAAiB,CAAC,EAAE;QACxD,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAChD,QAAA,OAAO,CAAC;IACT;IACA,OAAO,CAAC,CAAC,MAAM;AAChB;AA4BA,MAAM,cAAc,GAAoB;AACvC,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,KAAK,EAAE,CAAC;AACR,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,IAAI,EAAE,cAAc;CACpB;AAED;;;;;;;;;;;;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AS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAAT,SAAS,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,qBAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAT,SAAS,EAAA,UAAA,EAAA,CAAA;kBADrB,SAAS;mBAAC,EAAE,QAAQ,EAAE,qBAAqB,EAAE;;;AClF9C;;AAEG;;;;"}
|
|
@@ -72,7 +72,7 @@ class NgtcPhysics {
|
|
|
72
72
|
* Physics simulation configuration options.
|
|
73
73
|
* @see NgtcPhysicsOptions for available options
|
|
74
74
|
*/
|
|
75
|
-
this.options = input(defaultOptions, { ...(ngDevMode ? { debugName: "options" } : {}), transform: mergeInputs(defaultOptions) });
|
|
75
|
+
this.options = input(defaultOptions, { ...(ngDevMode ? { debugName: "options" } : /* istanbul ignore next */ {}), transform: mergeInputs(defaultOptions) });
|
|
76
76
|
this.axisIndex = pick(this.options, 'axisIndex');
|
|
77
77
|
this.broadphase = pick(this.options, 'broadphase');
|
|
78
78
|
this.gravity = pick(this.options, 'gravity');
|
|
@@ -80,7 +80,7 @@ class NgtcPhysics {
|
|
|
80
80
|
this.tolerance = pick(this.options, 'tolerance');
|
|
81
81
|
this.invalidate = this.store.invalidate;
|
|
82
82
|
// @ts-expect-error - worker is not nullable, and we don't want to use ! operator.
|
|
83
|
-
this.cannonWorker = signal(null, ...(ngDevMode ? [{ debugName: "cannonWorker" }] : []));
|
|
83
|
+
this.cannonWorker = signal(null, ...(ngDevMode ? [{ debugName: "cannonWorker" }] : /* istanbul ignore next */ []));
|
|
84
84
|
/** Map of body UUIDs to their indices in the physics world */
|
|
85
85
|
this.bodies = {};
|
|
86
86
|
/** Map of body UUIDs to their collision event callbacks */
|
|
@@ -216,10 +216,10 @@ class NgtcPhysics {
|
|
|
216
216
|
if (cb)
|
|
217
217
|
cb({ body: body ? refs[body] : null, ray: { uuid, ...rayRest }, ...rest });
|
|
218
218
|
}
|
|
219
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.
|
|
220
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.
|
|
219
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgtcPhysics, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
220
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: NgtcPhysics, isStandalone: true, selector: "ngtc-physics", inputs: { options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
221
221
|
}
|
|
222
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.
|
|
222
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NgtcPhysics, decorators: [{
|
|
223
223
|
type: Directive,
|
|
224
224
|
args: [{ selector: 'ngtc-physics' }]
|
|
225
225
|
}], ctorParameters: () => [], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }] } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-three-cannon.mjs","sources":["../../../../libs/cannon/src/lib/physics.ts","../../../../libs/cannon/src/angular-three-cannon.ts"],"sourcesContent":["import { Directive, Injector, afterNextRender, effect, inject, input, signal, untracked } from '@angular/core';\nimport {\n\tCannonWorkerAPI,\n\tCannonWorkerProps,\n\tCollideBeginEvent,\n\tCollideEndEvent,\n\tCollideEvent,\n\tRayhitEvent,\n\tRefs,\n\tSubscriptions,\n\tWorkerCollideBeginEvent,\n\tWorkerCollideEndEvent,\n\tWorkerCollideEvent,\n\tWorkerFrameMessage,\n\tWorkerRayhitEvent,\n} from '@pmndrs/cannon-worker-api';\nimport { beforeRender, injectStore, is, pick } from 'angular-three';\nimport { mergeInputs } from 'ngxtension/inject-inputs';\nimport * as THREE from 'three';\n\n/**\n * Event types emitted by the Cannon.js physics worker.\n * Maps event names to their corresponding worker event data types.\n */\nexport interface NgtcCannonWorkerEvents {\n\t/** Emitted when two physics bodies collide */\n\tcollide: WorkerCollideEvent;\n\t/** Emitted when two physics bodies begin overlapping */\n\tcollideBegin: WorkerCollideBeginEvent;\n\t/** Emitted when two physics bodies stop overlapping */\n\tcollideEnd: WorkerCollideEndEvent;\n\t/** Emitted each physics simulation frame with updated body positions and rotations */\n\tframe: WorkerFrameMessage;\n\t/** Emitted when a raycast hits a physics body */\n\trayhit: WorkerRayhitEvent;\n}\n\n/**\n * Extended Cannon.js worker API with event subscription capabilities.\n * Combines the base CannonWorkerAPI with typed event handling.\n */\nexport type NgtcCannonWorker = CannonWorkerAPI & {\n\t/**\n\t * Subscribe to physics worker events.\n\t * @param event - The event type to listen for\n\t * @param cb - Callback function invoked with event data\n\t */\n\ton: <K extends keyof NgtcCannonWorkerEvents>(\n\t\tevent: K,\n\t\tcb: (data: NgtcCannonWorkerEvents[K]['data']) => void,\n\t) => void;\n\t/** Remove all event listeners from the worker */\n\tremoveAllListeners: () => void;\n};\n\nconst v = new THREE.Vector3();\nconst s = new THREE.Vector3(1, 1, 1);\nconst q = new THREE.Quaternion();\nconst m = new THREE.Matrix4();\n\nfunction apply(\n\tindex: number,\n\tpositions: ArrayLike<number>,\n\tquaternions: ArrayLike<number>,\n\tscale = s,\n\tobject?: THREE.Object3D,\n) {\n\tif (index !== undefined) {\n\t\tm.compose(\n\t\t\tv.fromArray(positions, index * 3),\n\t\t\tq.fromArray(quaternions as THREE.QuaternionTuple, index * 4),\n\t\t\tscale,\n\t\t);\n\t\tif (object) {\n\t\t\tobject.matrixAutoUpdate = false;\n\t\t\tobject.matrix.copy(m);\n\t\t}\n\t\treturn m;\n\t}\n\treturn m.identity();\n}\n\nfunction unique() {\n\tconst values: unknown[] = [];\n\treturn (value: unknown) => (values.includes(value) ? false : !!values.push(value));\n}\n\ntype NgtcCannonEvent = CollideBeginEvent | CollideEndEvent | CollideEvent | RayhitEvent;\ntype NgtcCallbackByType<T extends { type: string }> = {\n\t[K in T['type']]?: T extends { type: K } ? (e: T) => void : never;\n};\n\n/**\n * Map of UUID strings to their associated collision event callbacks.\n * Used internally to dispatch collision events to the appropriate handlers.\n */\nexport type NgtcCannonEvents = Record<string, Partial<NgtcCallbackByType<NgtcCannonEvent>>>;\n\n/**\n * Map of UUID strings to custom scale vectors.\n * Allows overriding the default scale for specific physics bodies.\n */\nexport type ScaleOverrides = Record<string, THREE.Vector3>;\n\n/**\n * Configuration options for the physics simulation.\n * Extends CannonWorkerProps with additional Angular-specific options.\n */\nexport interface NgtcPhysicsOptions extends CannonWorkerProps {\n\t/**\n\t * Whether the physics simulation is paused.\n\t * @default false\n\t */\n\tisPaused?: boolean;\n\t/**\n\t * Maximum number of sub-steps per frame for physics calculations.\n\t * Higher values provide more accurate simulation but cost more performance.\n\t * @default 10\n\t */\n\tmaxSubSteps?: number;\n\t/**\n\t * Whether to call invalidate() after each physics frame update.\n\t * Set to true for on-demand rendering, false for continuous rendering.\n\t * @default true\n\t */\n\tshouldInvalidate?: boolean;\n\t/**\n\t * Fixed time step size for physics simulation in seconds.\n\t * @default 1/60 (60 FPS)\n\t */\n\tstepSize?: number;\n}\n\nconst defaultOptions: NgtcPhysicsOptions = {\n\tallowSleep: false,\n\taxisIndex: 0,\n\tbroadphase: 'Naive',\n\tdefaultContactMaterial: { contactEquationStiffness: 1e6 },\n\tfrictionGravity: null,\n\tgravity: [0, -9.81, 0],\n\tisPaused: false,\n\titerations: 5,\n\tmaxSubSteps: 10,\n\tquatNormalizeFast: false,\n\tquatNormalizeSkip: 0,\n\tshouldInvalidate: true,\n\tsize: 1000,\n\tsolver: 'GS',\n\tstepSize: 1 / 60,\n\ttolerance: 0.001,\n};\n\ntype NgtsPhysicsUpdatableOptions = Extract<\n\tkeyof NgtcPhysicsOptions,\n\t'gravity' | 'iterations' | 'tolerance' | 'broadphase' | 'axisIndex'\n>;\n\n/**\n * Angular directive that creates and manages a Cannon.js physics simulation.\n * This directive must wrap all physics bodies and constraints in the scene.\n *\n * @example\n * ```html\n * <ngtc-physics [options]=\"{ gravity: [0, -9.81, 0] }\">\n * <app-floor />\n * <app-falling-box />\n * </ngtc-physics>\n * ```\n *\n * @example\n * ```html\n * <!-- With debug visualization -->\n * <ngtc-physics\n * [options]=\"{ gravity: [0, -9.81, 0], iterations: 10 }\"\n * [debug]=\"{ enabled: true, color: 'red' }\"\n * >\n * <app-physics-scene />\n * </ngtc-physics>\n * ```\n */\n@Directive({ selector: 'ngtc-physics' })\nexport class NgtcPhysics {\n\tprivate store = injectStore();\n\n\t/**\n\t * Physics simulation configuration options.\n\t * @see NgtcPhysicsOptions for available options\n\t */\n\toptions = input(defaultOptions, { transform: mergeInputs(defaultOptions) });\n\n\tprivate axisIndex = pick(this.options, 'axisIndex');\n\tprivate broadphase = pick(this.options, 'broadphase');\n\tprivate gravity = pick(this.options, 'gravity');\n\tprivate iterations = pick(this.options, 'iterations');\n\tprivate tolerance = pick(this.options, 'tolerance');\n\n\tprivate invalidate = this.store.invalidate;\n\t// @ts-expect-error - worker is not nullable, and we don't want to use ! operator.\n\tprivate cannonWorker = signal<CannonWorkerAPI>(null);\n\n\t/** Map of body UUIDs to their indices in the physics world */\n\tbodies: { [uuid: string]: number } = {};\n\t/** Map of body UUIDs to their collision event callbacks */\n\tevents: NgtcCannonEvents = {};\n\t/** Map of body UUIDs to their Three.js Object3D references */\n\trefs: Refs = {};\n\t/** Map of body UUIDs to custom scale overrides */\n\tscaleOverrides: ScaleOverrides = {};\n\t/** Map of subscription IDs to their callback handlers */\n\tsubscriptions: Subscriptions = {};\n\t/** Read-only signal providing access to the physics worker API */\n\tworker = this.cannonWorker.asReadonly();\n\n\tconstructor() {\n\t\tconst injector = inject(Injector);\n\n\t\t// NOTE: set new cannonworker in afterNextRender\n\t\t// - so inputs are resolved\n\t\t// - so the worker is instantiated only once\n\t\t// - effects are started after worker is instantiated\n\t\tafterNextRender(() => {\n\t\t\tthis.cannonWorker.set(new CannonWorkerAPI(this.options()));\n\n\t\t\teffect(\n\t\t\t\t(onCleanup) => {\n\t\t\t\t\tconst cleanup = this.connectWorkerEffect();\n\t\t\t\t\tonCleanup(() => cleanup?.());\n\t\t\t\t},\n\t\t\t\t{ injector },\n\t\t\t);\n\n\t\t\teffect(\n\t\t\t\t() => {\n\t\t\t\t\tthis.updateWorkerStateEffect('axisIndex', this.axisIndex);\n\t\t\t\t\tthis.updateWorkerStateEffect('broadphase', this.broadphase);\n\t\t\t\t\tthis.updateWorkerStateEffect('gravity', this.gravity);\n\t\t\t\t\tthis.updateWorkerStateEffect('iterations', this.iterations);\n\t\t\t\t\tthis.updateWorkerStateEffect('tolerance', this.tolerance);\n\t\t\t\t},\n\t\t\t\t{ injector },\n\t\t\t);\n\t\t});\n\n\t\tlet timeSinceLastCalled = 0;\n\t\tbeforeRender(({ delta }) => {\n\t\t\tconst [{ isPaused, maxSubSteps, stepSize }, worker] = [this.options(), this.cannonWorker()];\n\t\t\tif (isPaused || !worker || stepSize == null) return;\n\t\t\ttimeSinceLastCalled += delta;\n\t\t\tworker.step({ maxSubSteps, stepSize, timeSinceLastCalled });\n\t\t\ttimeSinceLastCalled = 0;\n\t\t});\n\t}\n\n\tprivate connectWorkerEffect() {\n\t\tconst worker = this.cannonWorker() as NgtcCannonWorker;\n\t\tif (!worker) return;\n\n\t\tworker.connect();\n\t\tworker.init();\n\n\t\tworker.on('collide', this.collideHandler.bind(this));\n\t\tworker.on('collideBegin', this.collideBeginHandler.bind(this));\n\t\tworker.on('collideEnd', this.collideEndHandler.bind(this));\n\t\tworker.on('frame', this.frameHandler.bind(this));\n\t\tworker.on('rayhit', this.rayhitHandler.bind(this));\n\n\t\treturn () => {\n\t\t\tworker.terminate();\n\t\t\tworker.removeAllListeners();\n\t\t};\n\t}\n\n\tprivate updateWorkerStateEffect<TUpdatableKey extends NgtsPhysicsUpdatableOptions>(\n\t\tkey: TUpdatableKey,\n\t\toption: () => NgtcPhysicsOptions[TUpdatableKey],\n\t) {\n\t\tconst worker = this.cannonWorker();\n\t\tif (!worker) return;\n\t\tObject.assign(worker, { [key]: option() });\n\t}\n\n\tprivate collideHandler({ body, contact: { bi, bj, ...contactRest }, target, ...rest }: WorkerCollideEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cb = events[target]?.collide;\n\t\tif (cb) {\n\t\t\tcb({\n\t\t\t\tbody: refs[body],\n\t\t\t\tcontact: { bi: refs[bi], bj: refs[bj], ...contactRest },\n\t\t\t\ttarget: refs[target],\n\t\t\t\t...rest,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate collideBeginHandler({ bodyA, bodyB }: WorkerCollideBeginEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cbA = events[bodyA]?.collideBegin;\n\t\tif (cbA) cbA({ body: refs[bodyB], op: 'event', target: refs[bodyA], type: 'collideBegin' });\n\t\tconst cbB = events[bodyB]?.collideBegin;\n\t\tif (cbB) cbB({ body: refs[bodyA], op: 'event', target: refs[bodyB], type: 'collideBegin' });\n\t}\n\n\tprivate collideEndHandler({ bodyA, bodyB }: WorkerCollideEndEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cbA = events[bodyA]?.collideEnd;\n\t\tif (cbA) cbA({ body: refs[bodyB], op: 'event', target: refs[bodyA], type: 'collideEnd' });\n\t\tconst cbB = events[bodyB]?.collideEnd;\n\t\tif (cbB) cbB({ body: refs[bodyA], op: 'event', target: refs[bodyB], type: 'collideEnd' });\n\t}\n\n\tprivate frameHandler({\n\t\tactive,\n\t\tbodies: uuids = [],\n\t\tobservations,\n\t\tpositions,\n\t\tquaternions,\n\t}: WorkerFrameMessage['data']) {\n\t\tconst [{ shouldInvalidate }, { bodies, subscriptions, refs, scaleOverrides }, invalidate] = [\n\t\t\tuntracked(this.options),\n\t\t\tthis,\n\t\t\tthis.invalidate(),\n\t\t];\n\t\tfor (let i = 0; i < uuids.length; i++) {\n\t\t\tbodies[uuids[i]] = i;\n\t\t}\n\t\tobservations.forEach(([id, value, type]) => {\n\t\t\tconst subscription = subscriptions[id] || {};\n\t\t\tconst cb = subscription[type];\n\t\t\t// @ts-expect-error - We clearly know the type of the callback, but typescript can't deal with it\n\t\t\tcb && cb(value);\n\t\t});\n\t\tif (!active) return;\n\t\tfor (const ref of Object.values(refs).filter(unique())) {\n\t\t\tif (is.three<THREE.InstancedMesh>(ref, 'isInstancedMesh')) {\n\t\t\t\tfor (let i = 0; i < ref.count; i++) {\n\t\t\t\t\tconst uuid = `${ref.uuid}/${i}`;\n\t\t\t\t\tconst index = bodies[uuid];\n\t\t\t\t\tif (index !== undefined) {\n\t\t\t\t\t\tref.setMatrixAt(i, apply(index, positions, quaternions, scaleOverrides[uuid]));\n\t\t\t\t\t\tref.instanceMatrix.needsUpdate = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst scale = scaleOverrides[ref.uuid] || ref.scale;\n\t\t\t\tapply(bodies[ref.uuid], positions, quaternions, scale, ref);\n\t\t\t}\n\t\t}\n\t\tif (shouldInvalidate) invalidate();\n\t}\n\n\tprivate rayhitHandler({ body, ray: { uuid, ...rayRest }, ...rest }: WorkerRayhitEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cb = events[uuid]?.rayhit;\n\t\tif (cb) cb({ body: body ? refs[body] : null, ray: { uuid, ...rayRest }, ...rest });\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAuDA,MAAM,CAAC,GAAG,IAAI,KAAK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;AACA,QAAA,IAAI,gBAAgB;AAAE,YAAA,UAAU,EAAE;IACnC;AAEQ,IAAA,aAAa,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,GAAG,IAAI,EAA6B,EAAA;AAC5F,QAAA,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI;QAC7B,MAAM,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;AAC/B,QAAA,IAAI,EAAE;AAAE,YAAA,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC;IACnF;8GA7KY,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;kGAAX,WAAW,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,EAAA,OAAA,EAAA,EAAA,iBAAA,EAAA,SAAA,EAAA,UAAA,EAAA,SAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAX,WAAW,EAAA,UAAA,EAAA,CAAA;kBADvB,SAAS;mBAAC,EAAE,QAAQ,EAAE,cAAc,EAAE;;;ACpLvC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"angular-three-cannon.mjs","sources":["../../../../libs/cannon/src/lib/physics.ts","../../../../libs/cannon/src/angular-three-cannon.ts"],"sourcesContent":["import { Directive, Injector, afterNextRender, effect, inject, input, signal, untracked } from '@angular/core';\nimport {\n\tCannonWorkerAPI,\n\tCannonWorkerProps,\n\tCollideBeginEvent,\n\tCollideEndEvent,\n\tCollideEvent,\n\tRayhitEvent,\n\tRefs,\n\tSubscriptions,\n\tWorkerCollideBeginEvent,\n\tWorkerCollideEndEvent,\n\tWorkerCollideEvent,\n\tWorkerFrameMessage,\n\tWorkerRayhitEvent,\n} from '@pmndrs/cannon-worker-api';\nimport { beforeRender, injectStore, is, pick } from 'angular-three';\nimport { mergeInputs } from 'ngxtension/inject-inputs';\nimport * as THREE from 'three';\n\n/**\n * Event types emitted by the Cannon.js physics worker.\n * Maps event names to their corresponding worker event data types.\n */\nexport interface NgtcCannonWorkerEvents {\n\t/** Emitted when two physics bodies collide */\n\tcollide: WorkerCollideEvent;\n\t/** Emitted when two physics bodies begin overlapping */\n\tcollideBegin: WorkerCollideBeginEvent;\n\t/** Emitted when two physics bodies stop overlapping */\n\tcollideEnd: WorkerCollideEndEvent;\n\t/** Emitted each physics simulation frame with updated body positions and rotations */\n\tframe: WorkerFrameMessage;\n\t/** Emitted when a raycast hits a physics body */\n\trayhit: WorkerRayhitEvent;\n}\n\n/**\n * Extended Cannon.js worker API with event subscription capabilities.\n * Combines the base CannonWorkerAPI with typed event handling.\n */\nexport type NgtcCannonWorker = CannonWorkerAPI & {\n\t/**\n\t * Subscribe to physics worker events.\n\t * @param event - The event type to listen for\n\t * @param cb - Callback function invoked with event data\n\t */\n\ton: <K extends keyof NgtcCannonWorkerEvents>(\n\t\tevent: K,\n\t\tcb: (data: NgtcCannonWorkerEvents[K]['data']) => void,\n\t) => void;\n\t/** Remove all event listeners from the worker */\n\tremoveAllListeners: () => void;\n};\n\nconst v = new THREE.Vector3();\nconst s = new THREE.Vector3(1, 1, 1);\nconst q = new THREE.Quaternion();\nconst m = new THREE.Matrix4();\n\nfunction apply(\n\tindex: number,\n\tpositions: ArrayLike<number>,\n\tquaternions: ArrayLike<number>,\n\tscale = s,\n\tobject?: THREE.Object3D,\n) {\n\tif (index !== undefined) {\n\t\tm.compose(\n\t\t\tv.fromArray(positions, index * 3),\n\t\t\tq.fromArray(quaternions as THREE.QuaternionTuple, index * 4),\n\t\t\tscale,\n\t\t);\n\t\tif (object) {\n\t\t\tobject.matrixAutoUpdate = false;\n\t\t\tobject.matrix.copy(m);\n\t\t}\n\t\treturn m;\n\t}\n\treturn m.identity();\n}\n\nfunction unique() {\n\tconst values: unknown[] = [];\n\treturn (value: unknown) => (values.includes(value) ? false : !!values.push(value));\n}\n\ntype NgtcCannonEvent = CollideBeginEvent | CollideEndEvent | CollideEvent | RayhitEvent;\ntype NgtcCallbackByType<T extends { type: string }> = {\n\t[K in T['type']]?: T extends { type: K } ? (e: T) => void : never;\n};\n\n/**\n * Map of UUID strings to their associated collision event callbacks.\n * Used internally to dispatch collision events to the appropriate handlers.\n */\nexport type NgtcCannonEvents = Record<string, Partial<NgtcCallbackByType<NgtcCannonEvent>>>;\n\n/**\n * Map of UUID strings to custom scale vectors.\n * Allows overriding the default scale for specific physics bodies.\n */\nexport type ScaleOverrides = Record<string, THREE.Vector3>;\n\n/**\n * Configuration options for the physics simulation.\n * Extends CannonWorkerProps with additional Angular-specific options.\n */\nexport interface NgtcPhysicsOptions extends CannonWorkerProps {\n\t/**\n\t * Whether the physics simulation is paused.\n\t * @default false\n\t */\n\tisPaused?: boolean;\n\t/**\n\t * Maximum number of sub-steps per frame for physics calculations.\n\t * Higher values provide more accurate simulation but cost more performance.\n\t * @default 10\n\t */\n\tmaxSubSteps?: number;\n\t/**\n\t * Whether to call invalidate() after each physics frame update.\n\t * Set to true for on-demand rendering, false for continuous rendering.\n\t * @default true\n\t */\n\tshouldInvalidate?: boolean;\n\t/**\n\t * Fixed time step size for physics simulation in seconds.\n\t * @default 1/60 (60 FPS)\n\t */\n\tstepSize?: number;\n}\n\nconst defaultOptions: NgtcPhysicsOptions = {\n\tallowSleep: false,\n\taxisIndex: 0,\n\tbroadphase: 'Naive',\n\tdefaultContactMaterial: { contactEquationStiffness: 1e6 },\n\tfrictionGravity: null,\n\tgravity: [0, -9.81, 0],\n\tisPaused: false,\n\titerations: 5,\n\tmaxSubSteps: 10,\n\tquatNormalizeFast: false,\n\tquatNormalizeSkip: 0,\n\tshouldInvalidate: true,\n\tsize: 1000,\n\tsolver: 'GS',\n\tstepSize: 1 / 60,\n\ttolerance: 0.001,\n};\n\ntype NgtsPhysicsUpdatableOptions = Extract<\n\tkeyof NgtcPhysicsOptions,\n\t'gravity' | 'iterations' | 'tolerance' | 'broadphase' | 'axisIndex'\n>;\n\n/**\n * Angular directive that creates and manages a Cannon.js physics simulation.\n * This directive must wrap all physics bodies and constraints in the scene.\n *\n * @example\n * ```html\n * <ngtc-physics [options]=\"{ gravity: [0, -9.81, 0] }\">\n * <app-floor />\n * <app-falling-box />\n * </ngtc-physics>\n * ```\n *\n * @example\n * ```html\n * <!-- With debug visualization -->\n * <ngtc-physics\n * [options]=\"{ gravity: [0, -9.81, 0], iterations: 10 }\"\n * [debug]=\"{ enabled: true, color: 'red' }\"\n * >\n * <app-physics-scene />\n * </ngtc-physics>\n * ```\n */\n@Directive({ selector: 'ngtc-physics' })\nexport class NgtcPhysics {\n\tprivate store = injectStore();\n\n\t/**\n\t * Physics simulation configuration options.\n\t * @see NgtcPhysicsOptions for available options\n\t */\n\toptions = input(defaultOptions, { transform: mergeInputs(defaultOptions) });\n\n\tprivate axisIndex = pick(this.options, 'axisIndex');\n\tprivate broadphase = pick(this.options, 'broadphase');\n\tprivate gravity = pick(this.options, 'gravity');\n\tprivate iterations = pick(this.options, 'iterations');\n\tprivate tolerance = pick(this.options, 'tolerance');\n\n\tprivate invalidate = this.store.invalidate;\n\t// @ts-expect-error - worker is not nullable, and we don't want to use ! operator.\n\tprivate cannonWorker = signal<CannonWorkerAPI>(null);\n\n\t/** Map of body UUIDs to their indices in the physics world */\n\tbodies: { [uuid: string]: number } = {};\n\t/** Map of body UUIDs to their collision event callbacks */\n\tevents: NgtcCannonEvents = {};\n\t/** Map of body UUIDs to their Three.js Object3D references */\n\trefs: Refs = {};\n\t/** Map of body UUIDs to custom scale overrides */\n\tscaleOverrides: ScaleOverrides = {};\n\t/** Map of subscription IDs to their callback handlers */\n\tsubscriptions: Subscriptions = {};\n\t/** Read-only signal providing access to the physics worker API */\n\tworker = this.cannonWorker.asReadonly();\n\n\tconstructor() {\n\t\tconst injector = inject(Injector);\n\n\t\t// NOTE: set new cannonworker in afterNextRender\n\t\t// - so inputs are resolved\n\t\t// - so the worker is instantiated only once\n\t\t// - effects are started after worker is instantiated\n\t\tafterNextRender(() => {\n\t\t\tthis.cannonWorker.set(new CannonWorkerAPI(this.options()));\n\n\t\t\teffect(\n\t\t\t\t(onCleanup) => {\n\t\t\t\t\tconst cleanup = this.connectWorkerEffect();\n\t\t\t\t\tonCleanup(() => cleanup?.());\n\t\t\t\t},\n\t\t\t\t{ injector },\n\t\t\t);\n\n\t\t\teffect(\n\t\t\t\t() => {\n\t\t\t\t\tthis.updateWorkerStateEffect('axisIndex', this.axisIndex);\n\t\t\t\t\tthis.updateWorkerStateEffect('broadphase', this.broadphase);\n\t\t\t\t\tthis.updateWorkerStateEffect('gravity', this.gravity);\n\t\t\t\t\tthis.updateWorkerStateEffect('iterations', this.iterations);\n\t\t\t\t\tthis.updateWorkerStateEffect('tolerance', this.tolerance);\n\t\t\t\t},\n\t\t\t\t{ injector },\n\t\t\t);\n\t\t});\n\n\t\tlet timeSinceLastCalled = 0;\n\t\tbeforeRender(({ delta }) => {\n\t\t\tconst [{ isPaused, maxSubSteps, stepSize }, worker] = [this.options(), this.cannonWorker()];\n\t\t\tif (isPaused || !worker || stepSize == null) return;\n\t\t\ttimeSinceLastCalled += delta;\n\t\t\tworker.step({ maxSubSteps, stepSize, timeSinceLastCalled });\n\t\t\ttimeSinceLastCalled = 0;\n\t\t});\n\t}\n\n\tprivate connectWorkerEffect() {\n\t\tconst worker = this.cannonWorker() as NgtcCannonWorker;\n\t\tif (!worker) return;\n\n\t\tworker.connect();\n\t\tworker.init();\n\n\t\tworker.on('collide', this.collideHandler.bind(this));\n\t\tworker.on('collideBegin', this.collideBeginHandler.bind(this));\n\t\tworker.on('collideEnd', this.collideEndHandler.bind(this));\n\t\tworker.on('frame', this.frameHandler.bind(this));\n\t\tworker.on('rayhit', this.rayhitHandler.bind(this));\n\n\t\treturn () => {\n\t\t\tworker.terminate();\n\t\t\tworker.removeAllListeners();\n\t\t};\n\t}\n\n\tprivate updateWorkerStateEffect<TUpdatableKey extends NgtsPhysicsUpdatableOptions>(\n\t\tkey: TUpdatableKey,\n\t\toption: () => NgtcPhysicsOptions[TUpdatableKey],\n\t) {\n\t\tconst worker = this.cannonWorker();\n\t\tif (!worker) return;\n\t\tObject.assign(worker, { [key]: option() });\n\t}\n\n\tprivate collideHandler({ body, contact: { bi, bj, ...contactRest }, target, ...rest }: WorkerCollideEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cb = events[target]?.collide;\n\t\tif (cb) {\n\t\t\tcb({\n\t\t\t\tbody: refs[body],\n\t\t\t\tcontact: { bi: refs[bi], bj: refs[bj], ...contactRest },\n\t\t\t\ttarget: refs[target],\n\t\t\t\t...rest,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate collideBeginHandler({ bodyA, bodyB }: WorkerCollideBeginEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cbA = events[bodyA]?.collideBegin;\n\t\tif (cbA) cbA({ body: refs[bodyB], op: 'event', target: refs[bodyA], type: 'collideBegin' });\n\t\tconst cbB = events[bodyB]?.collideBegin;\n\t\tif (cbB) cbB({ body: refs[bodyA], op: 'event', target: refs[bodyB], type: 'collideBegin' });\n\t}\n\n\tprivate collideEndHandler({ bodyA, bodyB }: WorkerCollideEndEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cbA = events[bodyA]?.collideEnd;\n\t\tif (cbA) cbA({ body: refs[bodyB], op: 'event', target: refs[bodyA], type: 'collideEnd' });\n\t\tconst cbB = events[bodyB]?.collideEnd;\n\t\tif (cbB) cbB({ body: refs[bodyA], op: 'event', target: refs[bodyB], type: 'collideEnd' });\n\t}\n\n\tprivate frameHandler({\n\t\tactive,\n\t\tbodies: uuids = [],\n\t\tobservations,\n\t\tpositions,\n\t\tquaternions,\n\t}: WorkerFrameMessage['data']) {\n\t\tconst [{ shouldInvalidate }, { bodies, subscriptions, refs, scaleOverrides }, invalidate] = [\n\t\t\tuntracked(this.options),\n\t\t\tthis,\n\t\t\tthis.invalidate(),\n\t\t];\n\t\tfor (let i = 0; i < uuids.length; i++) {\n\t\t\tbodies[uuids[i]] = i;\n\t\t}\n\t\tobservations.forEach(([id, value, type]) => {\n\t\t\tconst subscription = subscriptions[id] || {};\n\t\t\tconst cb = subscription[type];\n\t\t\t// @ts-expect-error - We clearly know the type of the callback, but typescript can't deal with it\n\t\t\tcb && cb(value);\n\t\t});\n\t\tif (!active) return;\n\t\tfor (const ref of Object.values(refs).filter(unique())) {\n\t\t\tif (is.three<THREE.InstancedMesh>(ref, 'isInstancedMesh')) {\n\t\t\t\tfor (let i = 0; i < ref.count; i++) {\n\t\t\t\t\tconst uuid = `${ref.uuid}/${i}`;\n\t\t\t\t\tconst index = bodies[uuid];\n\t\t\t\t\tif (index !== undefined) {\n\t\t\t\t\t\tref.setMatrixAt(i, apply(index, positions, quaternions, scaleOverrides[uuid]));\n\t\t\t\t\t\tref.instanceMatrix.needsUpdate = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst scale = scaleOverrides[ref.uuid] || ref.scale;\n\t\t\t\tapply(bodies[ref.uuid], positions, quaternions, scale, ref);\n\t\t\t}\n\t\t}\n\t\tif (shouldInvalidate) invalidate();\n\t}\n\n\tprivate rayhitHandler({ body, ray: { uuid, ...rayRest }, ...rest }: WorkerRayhitEvent['data']) {\n\t\tconst { events, refs } = this;\n\t\tconst cb = events[uuid]?.rayhit;\n\t\tif (cb) cb({ body: body ? refs[body] : null, ray: { uuid, ...rayRest }, ...rest });\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAuDA,MAAM,CAA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-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
"name": "angular-three-cannon",
|
|
3
|
+
"version": "4.2.2",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/angular-threejs/angular-three/tree/main/libs/cannon"
|
|
10
|
+
},
|
|
11
|
+
"author": {
|
|
12
|
+
"name": "Chau Tran",
|
|
13
|
+
"email": "nartc7789@gmail.com",
|
|
14
|
+
"url": "https://nartc.me"
|
|
15
|
+
},
|
|
16
|
+
"description": "Physics Cannon for Angular Three",
|
|
17
|
+
"keywords": [
|
|
18
|
+
"angular",
|
|
19
|
+
"threejs",
|
|
20
|
+
"renderer",
|
|
21
|
+
"cannon",
|
|
22
|
+
"physics"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@angular/common": ">=20.0.0 <22.0.0",
|
|
27
|
+
"@angular/core": ">=20.0.0 <22.0.0",
|
|
28
|
+
"@pmndrs/cannon-worker-api": "^2.0.0",
|
|
29
|
+
"cannon-es": ">=0.20.0 <0.21.0",
|
|
30
|
+
"cannon-es-debugger": "^1.0.0",
|
|
31
|
+
"three": ">=0.157.0 <0.183.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependenciesMeta": {
|
|
34
|
+
"cannon-es-debugger": {
|
|
35
|
+
"optional": true
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"tslib": "^2.7.0"
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"module": "fesm2022/angular-three-cannon.mjs",
|
|
43
|
+
"typings": "types/angular-three-cannon.d.ts",
|
|
44
|
+
"exports": {
|
|
45
|
+
"./package.json": {
|
|
46
|
+
"default": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
".": {
|
|
49
|
+
"types": "./types/angular-three-cannon.d.ts",
|
|
50
|
+
"default": "./fesm2022/angular-three-cannon.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./body": {
|
|
53
|
+
"types": "./types/angular-three-cannon-body.d.ts",
|
|
54
|
+
"default": "./fesm2022/angular-three-cannon-body.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./constraint": {
|
|
57
|
+
"types": "./types/angular-three-cannon-constraint.d.ts",
|
|
58
|
+
"default": "./fesm2022/angular-three-cannon-constraint.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./debug": {
|
|
61
|
+
"types": "./types/angular-three-cannon-debug.d.ts",
|
|
62
|
+
"default": "./fesm2022/angular-three-cannon-debug.mjs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"type": "module"
|
|
65
66
|
}
|