@khr3/core 0.2.9 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -175
- package/dist/KhrAssembly-CKW8I_2z.js +1667 -0
- package/dist/KhrAssembly-CKW8I_2z.js.map +1 -0
- package/dist/KhrAssembly.d.ts +46 -8
- package/dist/KhrCollider.d.ts +21 -7
- package/dist/clone.d.ts +40 -0
- package/dist/{khrExporter.d.ts → exporter.d.ts} +2 -2
- package/dist/{khrGlb.d.ts → glb.d.ts} +4 -3
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1548 -343
- package/dist/index.js.map +1 -1
- package/dist/{khrInertia.d.ts → inertia.d.ts} +22 -8
- package/dist/{jointDynamics.d.ts → joints.d.ts} +8 -7
- package/dist/loader.d.ts +9 -0
- package/dist/types.d.ts +282 -0
- package/dist/useKhrGlb.d.ts +6 -1
- package/dist/vehicle.d.ts +35 -2
- package/dist/vehicle.js +435 -539
- package/dist/vehicle.js.map +1 -1
- package/dist/wheelLoads.d.ts +5 -4
- package/package.json +6 -25
- package/AGENTS.md +0 -12
- package/CLAUDE.md +0 -8
- package/dist/AssemblyRootBody.d.ts +0 -16
- package/dist/BundleSceneHost.d.ts +0 -23
- package/dist/KhrVehicle.d.ts +0 -20
- package/dist/assemblyPlan.d.ts +0 -61
- package/dist/curves-Cf8okB-M.js +0 -542
- package/dist/curves-Cf8okB-M.js.map +0 -1
- package/dist/curves.d.ts +0 -378
- package/dist/curves.js +0 -1
- package/dist/khrBundleFinalize.d.ts +0 -15
- package/dist/khrClone.d.ts +0 -14
- package/dist/khrConfigTypes.d.ts +0 -62
- package/dist/khrExportEncoders.d.ts +0 -8
- package/dist/khrExtras.d.ts +0 -22
- package/dist/khrInertia-DgCUCDTx.js +0 -247
- package/dist/khrInertia-DgCUCDTx.js.map +0 -1
- package/dist/khrJointParser.d.ts +0 -3
- package/dist/khrLoader.d.ts +0 -7
- package/dist/khrMassProps.d.ts +0 -16
- package/dist/khrParsers.d.ts +0 -10
- package/dist/khrPlugin.d.ts +0 -8
- package/dist/khrPluginHelpers.d.ts +0 -26
- package/dist/khrRotorDecoders.d.ts +0 -4
- package/dist/khrShapeParser.d.ts +0 -8
- package/dist/khrTypes.d.ts +0 -141
- package/dist/khrVehicleChassis.d.ts +0 -20
- package/dist/khrVehicleJointHelpers.d.ts +0 -37
- package/dist/khrVehicleJoints.d.ts +0 -30
- package/dist/khrVehicleRotors.d.ts +0 -22
- package/dist/khrVehicleSlots.d.ts +0 -41
- package/dist/khrVehicleTypes.d.ts +0 -52
- package/dist/pacejka.d.ts +0 -22
- package/dist/physicsEcs-C00N5zCh.js +0 -914
- package/dist/physicsEcs-C00N5zCh.js.map +0 -1
- package/dist/physicsEcs.d.ts +0 -25
- package/dist/sand3d/sand3dAssemblyHelpers.d.ts +0 -30
- package/dist/sand3d/sand3dCavityOps.d.ts +0 -15
- package/dist/sand3d/sand3dCompiler.d.ts +0 -121
- package/dist/sand3d/sand3dEvaluator.d.ts +0 -80
- package/dist/sand3d/sand3dFramesAndEdits.d.ts +0 -30
- package/dist/sand3d/sand3dHullAndSweep.d.ts +0 -27
- package/dist/sand3d/sand3dParser.d.ts +0 -6
- package/dist/sand3d/sand3dPrimitives.d.ts +0 -50
- package/dist/sand3d/sand3dProfiles.d.ts +0 -32
- package/dist/sand3d/sand3dRecipes.d.ts +0 -5
- package/dist/sand3d/sand3dShellOp.d.ts +0 -8
- package/dist/sand3d/sand3dSolids.d.ts +0 -32
- package/dist/sand3d/sand3dTokenizer.d.ts +0 -8
- package/dist/sand3d/sand3dTypes.d.ts +0 -157
- package/dist/sand3d-DQ8-OMlo.js +0 -5045
- package/dist/sand3d-DQ8-OMlo.js.map +0 -1
- package/dist/sand3d.d.ts +0 -23
- package/dist/sand3d.js +0 -1
- package/docs/api-reference.md +0 -383
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"physicsEcs-C00N5zCh.js","names":[],"sources":["../src/khrClone.ts","../src/KhrCollider.tsx","../src/khrMassProps.ts","../src/assemblyPlan.ts","../src/BundleSceneHost.tsx","../src/jointDynamics.ts","../src/physicsEcs.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { type KhrAssetBundle, type KhrCarConfig, type KhrCurveData, KhrValidationError } from \"./khrTypes.js\";\n\nconst mountedScenes = new WeakSet<THREE.Object3D>();\nconst clonedScenes = new WeakSet<THREE.Object3D>();\nconst disposedScenes = new WeakSet<THREE.Object3D>();\nconst activeSubtreeRestorers: Array<() => () => void> = [];\n\nexport function registerMountedSubtree(restoreForClone: () => () => void): () => void {\n activeSubtreeRestorers.push(restoreForClone);\n return () => {\n const idx = activeSubtreeRestorers.indexOf(restoreForClone);\n if (idx >= 0)\n activeSubtreeRestorers.splice(idx, 1);\n };\n}\n\nexport function claimBundleMount(bundle: KhrAssetBundle, ownerComponent: string): void {\n if (disposedScenes.has(bundle.scene)) {\n throw new KhrValidationError(`${ownerComponent}: KhrAssetBundle \"${bundle.scene.name || bundle.scene.uuid}\" has already been disposed`);\n }\n if (mountedScenes.has(bundle.scene)) {\n throw new KhrValidationError(`${ownerComponent}: KhrAssetBundle \"${bundle.scene.name || bundle.scene.uuid}\" is already mounted; call cloneKhrBundle(template) per concurrent instance`);\n }\n mountedScenes.add(bundle.scene);\n}\n\nexport function releaseBundleMount(bundle: KhrAssetBundle): void {\n mountedScenes.delete(bundle.scene);\n}\n\nfunction remapNode(srcRoot: THREE.Object3D, node: THREE.Object3D, dstRoot: THREE.Object3D): THREE.Object3D {\n if (node === srcRoot)\n return dstRoot;\n const path: number[] = [];\n let cur: THREE.Object3D | null = node;\n while (cur && cur !== srcRoot) {\n const parent: THREE.Object3D | null = cur.parent;\n if (!parent)\n throw new KhrValidationError(`cloneKhrBundle: body node \"${node.name}\" is detached from bundle.scene`);\n const idx = parent.children.indexOf(cur);\n if (idx < 0)\n throw new KhrValidationError(`cloneKhrBundle: child index missing for \"${node.name}\"`);\n path.push(idx);\n cur = parent;\n }\n let out = dstRoot;\n for (let i = path.length - 1; i >= 0; i--)\n out = out.children[path[i]];\n return out;\n}\n\nfunction cloneCurve(curve?: KhrCurveData): KhrCurveData | undefined {\n if (!curve)\n return undefined;\n return {\n ...curve,\n points: curve.points.map((pt) => ({ ...pt })),\n };\n}\n\nfunction cloneCarTune(tune?: Partial<KhrCarConfig>): Partial<KhrCarConfig> | undefined {\n if (!tune)\n return undefined;\n return {\n ...tune,\n ...(tune.gearRatios ? { gearRatios: [...tune.gearRatios] } : {}),\n ...(tune.engineTorqueCurveData ? { engineTorqueCurveData: cloneCurve(tune.engineTorqueCurveData) } : {}),\n ...(tune.steerAngleCurveData ? { steerAngleCurveData: cloneCurve(tune.steerAngleCurveData) } : {}),\n };\n}\n\n/**\n * Clones a parsed `KhrAssetBundle` in O(nodes) while sharing parsed `.glb` buffers,\n * GPU `BufferGeometry` / `Material` buffers, and Rapier `Float32Array` collider vertices.\n */\nexport function cloneKhrBundle(bundle: KhrAssetBundle): KhrAssetBundle {\n if (disposedScenes.has(bundle.scene)) {\n throw new KhrValidationError(`cloneKhrBundle: cannot clone disposed KhrAssetBundle \"${bundle.scene.name || bundle.scene.uuid}\"`);\n }\n const reattach: Array<() => void> = [];\n for (let i = activeSubtreeRestorers.length - 1; i >= 0; i--) {\n reattach.push(activeSubtreeRestorers[i]());\n }\n try {\n const scene = bundle.scene.clone(true);\n clonedScenes.add(scene);\n return {\n scene,\n bodies: bundle.bodies.map((b) => {\n const drives = b.joint ? b.joint.drives.map((d) => ({ ...d })) : [];\n return {\n ...b,\n centerOfMass: [...b.centerOfMass],\n inertiaDiagonal: [...b.inertiaDiagonal],\n inertiaOrientation: [...b.inertiaOrientation],\n ...(b.linearVelocity ? { linearVelocity: [...b.linearVelocity] } : {}),\n ...(b.angularVelocity ? { angularVelocity: [...b.angularVelocity] } : {}),\n localPosition: [...b.localPosition],\n localQuaternion: [...b.localQuaternion],\n colliders: b.colliders.map((c) => ({\n ...c,\n shape: c.shape.type === \"box\" ? { ...c.shape, size: [...c.shape.size] } : { ...c.shape },\n localPosition: [...c.localPosition],\n localQuaternion: [...c.localQuaternion],\n })),\n joint: b.joint\n ? {\n ...b.joint,\n axis: [...b.joint.axis],\n limits: b.joint.limits ? [...b.joint.limits] : null,\n drive: drives[0] ?? (b.joint.drive ? { ...b.joint.drive } : null),\n drives,\n anchor1: [...b.joint.anchor1],\n anchor2: [...b.joint.anchor2],\n }\n : null,\n ...(b.breakaway ? { breakaway: { ...b.breakaway } } : {}),\n object: remapNode(bundle.scene, b.object, scene),\n };\n }),\n wheels: bundle.wheels.map((w) => ({\n ...w,\n object: remapNode(bundle.scene, w.object, scene),\n position: [...w.position],\n ...(w.quaternion ? { quaternion: [...w.quaternion] } : {}),\n ...(w.lngSlipRatioCurveData ? { lngSlipRatioCurveData: cloneCurve(w.lngSlipRatioCurveData) } : {}),\n ...(w.latSlipRatioCurveData ? { latSlipRatioCurveData: cloneCurve(w.latSlipRatioCurveData) } : {}),\n })),\n propellers: bundle.propellers.map((p) => ({\n ...p,\n object: remapNode(bundle.scene, p.object, scene),\n position: [...p.position],\n ...(p.quaternion ? { quaternion: [...p.quaternion] } : {}),\n })),\n sockets: Object.fromEntries(Object.entries(bundle.sockets).map(([k, v]) => [k, [...v]])),\n totalDynamicMass: bundle.totalDynamicMass,\n centerOfMass: [...bundle.centerOfMass],\n ...(bundle.tune ? { tune: cloneCarTune(bundle.tune) } : {}),\n ...(bundle.droneTune ? { droneTune: { ...bundle.droneTune } } : {}),\n };\n }\n finally {\n for (let i = reattach.length - 1; i >= 0; i--)\n reattach[i]();\n }\n}\n\n/**\n * Releases clone mount ownership while keeping shared template GPU resources intact.\n * When called on a root template bundle, disposes unique GPU geometries, materials, and textures once.\n */\nexport function disposeKhrBundle(bundle: KhrAssetBundle): void {\n mountedScenes.delete(bundle.scene);\n if (clonedScenes.has(bundle.scene) || disposedScenes.has(bundle.scene)) {\n disposedScenes.add(bundle.scene);\n return;\n }\n disposedScenes.add(bundle.scene);\n const geos = new Set<THREE.BufferGeometry>();\n const mats = new Set<THREE.Material>();\n const texs = new Set<THREE.Texture>();\n const disposeTree = (obj: THREE.Object3D): void => {\n obj.traverse((child) => {\n const mesh = child as THREE.Mesh;\n if (mesh.geometry && !geos.has(mesh.geometry)) {\n geos.add(mesh.geometry);\n mesh.geometry.dispose();\n }\n const matList = Array.isArray(mesh.material) ? mesh.material : mesh.material ? [mesh.material] : [];\n for (const mat of matList) {\n if (!mats.has(mat)) {\n mats.add(mat);\n for (const val of Object.values(mat)) {\n if (val && typeof val === \"object\" && \"isTexture\" in val && (val as THREE.Texture).isTexture) {\n const tex = val as THREE.Texture;\n if (!texs.has(tex)) {\n texs.add(tex);\n tex.dispose();\n }\n }\n }\n mat.dispose();\n }\n }\n });\n };\n disposeTree(bundle.scene);\n for (const w of bundle.wheels)\n disposeTree(w.object);\n for (const p of bundle.propellers)\n disposeTree(p.object);\n}\n","import React, { useCallback, useEffect, useRef } from \"react\";\nimport {\n BallCollider,\n CapsuleCollider,\n CoefficientCombineRule,\n ConvexHullCollider,\n CuboidCollider,\n CylinderCollider,\n TrimeshCollider,\n type RapierCollider,\n} from \"@react-three/rapier\";\nimport type { ColliderMass } from \"./assemblyPlan.js\";\nimport type { KhrColliderSpec, KhrCombineMode } from \"./khrTypes.js\";\n\nconst COMBINE_RULES: Record<KhrCombineMode, CoefficientCombineRule> = {\n average: CoefficientCombineRule.Average,\n minimum: CoefficientCombineRule.Min,\n maximum: CoefficientCombineRule.Max,\n multiply: CoefficientCombineRule.Multiply,\n};\n\nexport interface KhrColliderProps {\n c: KhrColliderSpec;\n /** Pose override in the parent RigidBody frame; defaults to the authored KHR collider offset. */\n position?: [number, number, number];\n quaternion?: [number, number, number, number];\n /** Authored body mass carried declaratively by this collider (`density: 0` when omitted). */\n massProperties?: ColliderMass;\n /** Fallback Rapier collision groups when `c.collisionGroups` is omitted. */\n collisionGroups?: number;\n /** Fallback Rapier solver groups when `c.collisionGroups` is omitted. */\n solverGroups?: number;\n ref?: React.Ref<RapierCollider>;\n}\n\nexport function KhrCollider({ c, position, quaternion, massProperties, collisionGroups, solverGroups, ref }: KhrColliderProps): React.JSX.Element {\n const innerRef = useRef<RapierCollider | null>(null);\n const setRef = useCallback((node: RapierCollider | null) => {\n innerRef.current = node;\n if (typeof ref === \"function\")\n ref(node);\n else if (ref)\n (ref as React.MutableRefObject<RapierCollider | null>).current = node;\n }, [ref]);\n // Rapier WASM only auto-flushes dirty collider mass flags inside world.step(); flush once after\n // @react-three/rapier's AnyCollider useEffect so body.mass() is already exact before step 0.\n useEffect(() => {\n innerRef.current?.parent()?.recomputeMassPropertiesFromColliders();\n }, [c, massProperties]);\n const effCollisionGroups = c.collisionGroups ?? collisionGroups;\n const effSolverGroups = c.collisionGroups === undefined ? solverGroups : undefined;\n const common = {\n ref: setRef,\n position: position ?? c.localPosition,\n quaternion: quaternion ?? c.localQuaternion,\n ...(massProperties ? { massProperties } : { density: 0 }),\n ...(c.friction === undefined ? {} : { friction: c.friction }),\n ...(c.restitution === undefined ? {} : { restitution: c.restitution }),\n ...(c.frictionCombine === undefined ? {} : { frictionCombineRule: COMBINE_RULES[c.frictionCombine] }),\n ...(c.restitutionCombine === undefined ? {} : { restitutionCombineRule: COMBINE_RULES[c.restitutionCombine] }),\n ...(effCollisionGroups === undefined ? {} : { collisionGroups: effCollisionGroups }),\n ...(effSolverGroups === undefined ? {} : { solverGroups: effSolverGroups }),\n };\n const { shape } = c;\n if (shape.type === \"box\") {\n const [sx, sy, sz] = shape.size;\n return <CuboidCollider args={[sx * 0.5, sy * 0.5, sz * 0.5]} {...common} />;\n }\n if (shape.type === \"sphere\")\n return <BallCollider args={[shape.radius]} {...common} />;\n if (shape.type === \"cylinder\")\n return <CylinderCollider args={[shape.height * 0.5, shape.radiusTop]} {...common} />;\n if (shape.type === \"capsule\")\n return <CapsuleCollider args={[shape.height * 0.5, shape.radiusTop]} {...common} />;\n if (shape.type === \"convexHull\")\n return <ConvexHullCollider args={[shape.vertices]} {...common} />;\n return <TrimeshCollider args={[shape.vertices, shape.indices]} {...common} />;\n}\n","import * as THREE from \"three\";\nimport type { KhrBodySpec } from \"./khrTypes.js\";\n\nexport type Vec3Tuple = [number, number, number];\nexport type QuatTuple = [number, number, number, number];\n\nexport interface LumpedMassProps {\n mass: number;\n com: Vec3Tuple;\n inertia: Vec3Tuple;\n inertiaFrame: QuatTuple;\n}\n\nconst _pos = new THREE.Vector3();\nconst _quat = new THREE.Quaternion();\nconst _qExtra = new THREE.Quaternion();\nconst _comVec = new THREE.Vector3();\nconst _one = new THREE.Vector3(1, 1, 1);\nconst _mat = new THREE.Matrix4();\nconst _tmpMat = new THREE.Matrix4();\nconst _rCom = new THREE.Vector3();\n\nexport function bodyPoseMatrix(body: KhrBodySpec, target = new THREE.Matrix4()): THREE.Matrix4 {\n _pos.fromArray(body.localPosition);\n _quat.fromArray(body.localQuaternion);\n return target.compose(_pos, _quat, _one);\n}\n\nexport function jacobiPrincipalInertia(\n ixx: number,\n iyy: number,\n izz: number,\n ixy: number,\n ixz: number,\n iyz: number,\n): { inertia: Vec3Tuple; inertiaFrame: QuatTuple } {\n const a: [Vec3Tuple, Vec3Tuple, Vec3Tuple] = [\n [ixx, ixy, ixz],\n [ixy, iyy, iyz],\n [ixz, iyz, izz],\n ];\n const v: [Vec3Tuple, Vec3Tuple, Vec3Tuple] = [\n [1, 0, 0],\n [0, 1, 0],\n [0, 0, 1],\n ];\n for (let iter = 0; iter < 32; iter++) {\n const tr = Math.max(a[0][0] + a[1][1] + a[2][2], 0);\n let p = 0, q = 1, maxOff = Math.abs(a[0][1]);\n if (Math.abs(a[0][2]) > maxOff) {\n p = 0;\n q = 2;\n maxOff = Math.abs(a[0][2]);\n }\n if (Math.abs(a[1][2]) > maxOff) {\n p = 1;\n q = 2;\n maxOff = Math.abs(a[1][2]);\n }\n if (maxOff <= 1e-12 * tr)\n break;\n const apq = a[p][q], app = a[p][p], aqq = a[q][q];\n const tau = (aqq - app) / (2 * apq);\n const t = tau >= 0 ? 1 / (tau + Math.sqrt(1 + tau * tau)) : -1 / (-tau + Math.sqrt(1 + tau * tau));\n const c = 1 / Math.sqrt(1 + t * t), s = t * c;\n const r = 3 - p - q;\n a[p][p] = c * c * app - 2 * s * c * apq + s * s * aqq;\n a[q][q] = s * s * app + 2 * s * c * apq + c * c * aqq;\n a[p][q] = a[q][p] = 0;\n const arp = a[r][p], arq = a[r][q];\n a[r][p] = a[p][r] = c * arp - s * arq;\n a[r][q] = a[q][r] = s * arp + c * arq;\n for (let i = 0; i < 3; i++) {\n const vip = v[i][p], viq = v[i][q];\n v[i][p] = c * vip - s * viq;\n v[i][q] = s * vip + c * viq;\n }\n }\n const det = v[0][0] * (v[1][1] * v[2][2] - v[1][2] * v[2][1])\n - v[0][1] * (v[1][0] * v[2][2] - v[1][2] * v[2][0])\n + v[0][2] * (v[1][0] * v[2][1] - v[1][1] * v[2][0]);\n if (det < 0) {\n v[0][2] = -v[0][2];\n v[1][2] = -v[1][2];\n v[2][2] = -v[2][2];\n }\n _mat.set(\n v[0][0], v[0][1], v[0][2], 0,\n v[1][0], v[1][1], v[1][2], 0,\n v[2][0], v[2][1], v[2][2], 0,\n 0, 0, 0, 1,\n );\n _quat.setFromRotationMatrix(_mat).normalize();\n return {\n inertia: [a[0][0], a[1][1], a[2][2]],\n inertiaFrame: [_quat.x, _quat.y, _quat.z, _quat.w],\n };\n}\n\nfunction resolvePose(body: KhrBodySpec, invFrame?: THREE.Matrix4): void {\n if (invFrame) {\n _mat.multiplyMatrices(invFrame, bodyPoseMatrix(body, _tmpMat)).decompose(_pos, _quat, _comVec);\n _quat.normalize();\n }\n else {\n _pos.fromArray(body.localPosition);\n _quat.fromArray(body.localQuaternion).normalize();\n }\n}\n\nexport function computeLumpedMassProps(bodies: readonly KhrBodySpec[], invFrame?: THREE.Matrix4): LumpedMassProps | null {\n const dyn = bodies.filter((b) => !b.isKinematic && b.mass > 0);\n if (dyn.length === 0)\n return null;\n let totalMass = 0, mx = 0, my = 0, mz = 0;\n for (const b of dyn) {\n resolvePose(b, invFrame);\n _rCom.fromArray(b.centerOfMass).applyQuaternion(_quat);\n totalMass += b.mass;\n mx += (_pos.x + _rCom.x) * b.mass;\n my += (_pos.y + _rCom.y) * b.mass;\n mz += (_pos.z + _rCom.z) * b.mass;\n }\n if (!(totalMass > 0))\n return null;\n const com: Vec3Tuple = [mx / totalMass, my / totalMass, mz / totalMass];\n let ixx = 0, iyy = 0, izz = 0, ixy = 0, ixz = 0, iyz = 0;\n const m = _mat.elements;\n for (const b of dyn) {\n resolvePose(b, invFrame);\n _rCom.fromArray(b.centerOfMass).applyQuaternion(_quat);\n const dx = _pos.x + _rCom.x - com[0];\n const dy = _pos.y + _rCom.y - com[1];\n const dz = _pos.z + _rCom.z - com[2];\n _mat.makeRotationFromQuaternion(_quat.multiply(_qExtra.fromArray(b.inertiaOrientation)));\n const [d0, d1, d2] = b.inertiaDiagonal;\n ixx += m[0] * m[0] * d0 + m[4] * m[4] * d1 + m[8] * m[8] * d2 + b.mass * (dy * dy + dz * dz);\n iyy += m[1] * m[1] * d0 + m[5] * m[5] * d1 + m[9] * m[9] * d2 + b.mass * (dx * dx + dz * dz);\n izz += m[2] * m[2] * d0 + m[6] * m[6] * d1 + m[10] * m[10] * d2 + b.mass * (dx * dx + dy * dy);\n ixy += m[0] * m[1] * d0 + m[4] * m[5] * d1 + m[8] * m[9] * d2 - b.mass * dx * dy;\n ixz += m[0] * m[2] * d0 + m[4] * m[6] * d1 + m[8] * m[10] * d2 - b.mass * dx * dz;\n iyz += m[1] * m[2] * d0 + m[5] * m[6] * d1 + m[9] * m[10] * d2 - b.mass * dy * dz;\n }\n if (dyn.length === 1) {\n const b = dyn[0];\n resolvePose(b, invFrame);\n _quat.multiply(_qExtra.fromArray(b.inertiaOrientation)).normalize();\n return {\n mass: totalMass,\n com,\n inertia: [b.inertiaDiagonal[0], b.inertiaDiagonal[1], b.inertiaDiagonal[2]],\n inertiaFrame: [_quat.x, _quat.y, _quat.z, _quat.w],\n };\n }\n const diagSum = Math.max(ixx + iyy + izz, 0);\n if (Math.max(Math.abs(ixy), Math.abs(ixz), Math.abs(iyz)) <= 1e-12 * diagSum) {\n return {\n mass: totalMass,\n com,\n inertia: [ixx, iyy, izz],\n inertiaFrame: [0, 0, 0, 1],\n };\n }\n const { inertia, inertiaFrame } = jacobiPrincipalInertia(ixx, iyy, izz, ixy, ixz, iyz);\n return { mass: totalMass, com, inertia, inertiaFrame };\n}\n","import * as THREE from \"three\";\nimport { bodyPoseMatrix, computeLumpedMassProps, type LumpedMassProps } from \"./khrMassProps.js\";\nimport { type KhrAssetBundle, type KhrBodySpec, type KhrColliderSpec, type KhrJointSpec, KhrValidationError } from \"./khrTypes.js\";\n\ntype Vec3 = [number, number, number];\ntype Quat = [number, number, number, number];\n\nexport interface ColliderMass {\n mass: number;\n centerOfMass: { x: number; y: number; z: number };\n principalAngularInertia: { x: number; y: number; z: number };\n angularInertiaLocalFrame: { x: number; y: number; z: number; w: number };\n}\n\nexport interface PlannedCollider {\n spec: KhrColliderSpec;\n local: THREE.Matrix4;\n position: Vec3;\n quaternion: Quat;\n massProperties?: ColliderMass;\n}\n\nexport interface PartPlan {\n spec: KhrBodySpec;\n joint: KhrJointSpec;\n parent: PartPlan | null;\n restRelParentPos: Vec3;\n restRelParentQuat: Quat;\n restRelRootPos: Vec3;\n restRelRootQuat: Quat;\n axisParent: Vec3;\n axisChild: Vec3;\n inertia: number;\n partMass?: ColliderMass;\n colliders: PlannedCollider[];\n}\n\nexport interface RootPlan {\n spec: KhrBodySpec;\n sceneInRootPos: Vec3;\n sceneInRootQuat: Quat;\n mountNode: THREE.Object3D;\n mountInRoot: THREE.Matrix4;\n mountPosition: Vec3;\n mountQuaternion: Quat;\n rootMass?: ColliderMass;\n colliders: PlannedCollider[];\n parts: PartPlan[];\n}\n\nfunction matrixToRoot(node: THREE.Object3D, sceneRoot: THREE.Object3D): THREE.Matrix4 {\n const out = new THREE.Matrix4();\n for (let cur: THREE.Object3D | null = node; cur && cur !== sceneRoot; cur = cur.parent) {\n if (!cur.parent)\n throw new KhrValidationError(`Node \"${node.name}\" is detached from bundle.scene`);\n cur.updateMatrix();\n out.premultiply(cur.matrix);\n }\n return out;\n}\n\nfunction lowestCommonAncestor(nodes: readonly THREE.Object3D[], sceneRoot: THREE.Object3D): THREE.Object3D {\n const chain = (n: THREE.Object3D): THREE.Object3D[] => {\n const list: THREE.Object3D[] = [];\n for (let cur: THREE.Object3D | null = n; cur; cur = cur.parent) {\n list.push(cur);\n if (cur === sceneRoot) break;\n }\n return list;\n };\n let shared = new Set(chain(nodes[0]));\n for (let i = 1; i < nodes.length; i++) {\n const setI = new Set(chain(nodes[i]));\n shared = new Set([...shared].filter((x) => setI.has(x)));\n }\n return chain(nodes[0]).find((c) => shared.has(c)) ?? sceneRoot;\n}\n\nexport function toColliderMass(lumped: LumpedMassProps, colMat?: THREE.Matrix4, colQuat?: THREE.Quaternion): ColliderMass {\n const com = new THREE.Vector3().fromArray(lumped.com);\n const frame = new THREE.Quaternion().fromArray(lumped.inertiaFrame);\n if (colMat && colQuat) {\n com.applyMatrix4(colMat.clone().invert());\n frame.premultiply(colQuat.clone().invert()).normalize();\n }\n return {\n mass: lumped.mass,\n centerOfMass: { x: com.x, y: com.y, z: com.z },\n principalAngularInertia: { x: lumped.inertia[0], y: lumped.inertia[1], z: lumped.inertia[2] },\n angularInertiaLocalFrame: { x: frame.x, y: frame.y, z: frame.z, w: frame.w },\n };\n}\n\nfunction planOwnColliders(body: KhrBodySpec, lumped: LumpedMassProps | null, frameQuat?: THREE.Quaternion): PlannedCollider[] {\n const one = new THREE.Vector3(1, 1, 1);\n const frameMat = frameQuat ? new THREE.Matrix4().makeRotationFromQuaternion(frameQuat) : null;\n const pos = new THREE.Vector3(), quat = new THREE.Quaternion(), scl = new THREE.Vector3();\n return body.colliders.map((spec, idx) => {\n const colQuat = new THREE.Quaternion().fromArray(spec.localQuaternion);\n const local = new THREE.Matrix4().compose(new THREE.Vector3().fromArray(spec.localPosition), colQuat, one);\n if (frameMat)\n local.premultiply(frameMat);\n local.decompose(pos, quat, scl);\n quat.normalize();\n const planned: PlannedCollider = {\n spec,\n local,\n position: [pos.x, pos.y, pos.z],\n quaternion: [quat.x, quat.y, quat.z, quat.w],\n };\n if (idx === 0 && lumped)\n planned.massProperties = toColliderMass(lumped, local, quat);\n return planned;\n });\n}\n\nfunction isSceneDescendant(node: THREE.Object3D, ancestor: THREE.Object3D): boolean {\n for (let cur: THREE.Object3D | null = node; cur; cur = cur.parent) {\n if (cur === ancestor)\n return true;\n }\n return false;\n}\n\nfunction approxPartInertia(b: KhrBodySpec, axisChild: Vec3): number {\n if (b.joint?.kind === \"fixed\")\n return 0;\n if (b.joint?.kind === \"prismatic\")\n return b.mass;\n const ax = new THREE.Vector3().fromArray(axisChild).normalize();\n const qInv = new THREE.Quaternion().fromArray(b.inertiaOrientation).invert();\n const axLocal = ax.clone().applyQuaternion(qInv);\n const [d0, d1, d2] = b.inertiaDiagonal;\n const com = new THREE.Vector3().fromArray(b.centerOfMass);\n const along = com.dot(ax);\n return d0 * axLocal.x * axLocal.x + d1 * axLocal.y * axLocal.y + d2 * axLocal.z * axLocal.z + b.mass * (com.lengthSq() - along * along);\n}\n\n/** Plans independent Rapier bodies for roots and jointed dynamic children connected by Rapier ImpulseJoints. */\nexport function planAssembly(bundle: KhrAssetBundle): RootPlan[] {\n const byName = new Map(bundle.bodies.map((b) => [b.nodeName, b]));\n const findRoot = (b: KhrBodySpec, seen = new Set<string>()): KhrBodySpec => {\n if (!b.joint)\n return b;\n if (seen.has(b.nodeName))\n throw new KhrValidationError(`Joint cycle through \"${b.nodeName}\"`);\n seen.add(b.nodeName);\n const parent = byName.get(b.joint.connectedNodeName);\n if (!parent) {\n throw new KhrValidationError(`Joint on \"${b.nodeName}\" targets \"${b.joint.connectedNodeName}\", which is not a KHR body`);\n }\n return findRoot(parent, seen);\n };\n\n const plans = bundle.bodies\n .filter((b) => !b.joint)\n .map((root): RootPlan => {\n const rootMat = bodyPoseMatrix(root);\n const invRoot = rootMat.clone().invert();\n const descendants = bundle.bodies.filter((b) => b.joint && findRoot(b) === root);\n const depthOf = (b: KhrBodySpec): number => b.joint ? 1 + depthOf(byName.get(b.joint.connectedNodeName)!) : 0;\n descendants.sort((a, b) => depthOf(a) - depthOf(b));\n\n const partByName = new Map<string, PartPlan>();\n const parts: PartPlan[] = descendants.map((b) => {\n const joint = b.joint!;\n const parent = partByName.get(joint.connectedNodeName) ?? null;\n if (parent && !isSceneDescendant(b.object, parent.spec.object)) {\n throw new KhrValidationError(`Jointed node \"${b.nodeName}\" must be a scene-graph descendant of its jointed parent \"${joint.connectedNodeName}\"`);\n }\n const parentSpec = parent ? parent.spec : root;\n const relParentMat = bodyPoseMatrix(parentSpec).clone().invert().multiply(bodyPoseMatrix(b));\n const relRootMat = invRoot.clone().multiply(bodyPoseMatrix(b));\n const rpPos = new THREE.Vector3(), rpQuat = new THREE.Quaternion(), rpScl = new THREE.Vector3();\n relParentMat.decompose(rpPos, rpQuat, rpScl);\n rpQuat.normalize();\n const rrPos = new THREE.Vector3(), rrQuat = new THREE.Quaternion();\n relRootMat.decompose(rrPos, rrQuat, rpScl);\n rrQuat.normalize();\n\n const axChildVec = new THREE.Vector3().fromArray(joint.axis).normalize();\n const axParentVec = axChildVec.clone().applyQuaternion(rrQuat).normalize();\n const axisChild: Vec3 = [axChildVec.x, axChildVec.y, axChildVec.z];\n const axisParent: Vec3 = [axParentVec.x, axParentVec.y, axParentVec.z];\n const anchorParent: Vec3 = parent\n ? [rrPos.x - parent.restRelRootPos[0], rrPos.y - parent.restRelRootPos[1], rrPos.z - parent.restRelRootPos[2]]\n : [rpPos.x, rpPos.y, rpPos.z];\n\n const bodyAlignInv = new THREE.Matrix4().compose(new THREE.Vector3().fromArray(b.localPosition), new THREE.Quaternion().fromArray(root.localQuaternion), new THREE.Vector3(1, 1, 1)).invert();\n const ownLumped = b.isKinematic ? null : computeLumpedMassProps([b], bodyAlignInv);\n const colliders = planOwnColliders(b, ownLumped, rrQuat);\n const partMass = ownLumped && colliders.length === 0 ? toColliderMass(ownLumped) : undefined;\n\n const plan: PartPlan = {\n spec: b,\n joint,\n parent,\n restRelParentPos: anchorParent,\n restRelParentQuat: [rrQuat.x, rrQuat.y, rrQuat.z, rrQuat.w],\n restRelRootPos: [rrPos.x, rrPos.y, rrPos.z],\n restRelRootQuat: [rrQuat.x, rrQuat.y, rrQuat.z, rrQuat.w],\n axisParent,\n axisChild,\n inertia: approxPartInertia(b, axisChild),\n ...(partMass ? { partMass } : {}),\n colliders,\n };\n partByName.set(b.nodeName, plan);\n return plan;\n });\n\n const rootLumped = root.isKinematic ? null : computeLumpedMassProps([root], invRoot);\n const colliders = planOwnColliders(root, rootLumped);\n const rootMass = rootLumped && colliders.length === 0 ? toColliderMass(rootLumped) : undefined;\n const mountNode = lowestCommonAncestor([root.object, ...descendants.map((d) => d.object)], bundle.scene);\n const mountInRoot = invRoot.clone().multiply(matrixToRoot(mountNode, bundle.scene));\n\n const scenePos = new THREE.Vector3(), sceneQuat = new THREE.Quaternion(), sceneScl = new THREE.Vector3();\n invRoot.decompose(scenePos, sceneQuat, sceneScl);\n sceneQuat.normalize();\n const mountPos = new THREE.Vector3(), mountQuat = new THREE.Quaternion();\n mountInRoot.decompose(mountPos, mountQuat, sceneScl);\n mountQuat.normalize();\n\n return {\n spec: root,\n sceneInRootPos: [scenePos.x, scenePos.y, scenePos.z],\n sceneInRootQuat: [sceneQuat.x, sceneQuat.y, sceneQuat.z, sceneQuat.w],\n mountNode,\n mountInRoot,\n mountPosition: [mountPos.x, mountPos.y, mountPos.z],\n mountQuaternion: [mountQuat.x, mountQuat.y, mountQuat.z, mountQuat.w],\n ...(rootMass ? { rootMass } : {}),\n colliders,\n parts,\n };\n });\n\n for (const a of plans) {\n for (const b of plans) {\n if (a !== b && isSceneDescendant(b.mountNode, a.mountNode)) {\n throw new KhrValidationError(`Root bodies \"${a.spec.nodeName}\" and \"${b.spec.nodeName}\" share scene subtree \"${a.mountNode.name}\"; split them into separate glTF branches`);\n }\n }\n }\n return plans;\n}\n","import React, { useLayoutEffect, useRef } from \"react\";\nimport * as THREE from \"three\";\nimport { claimBundleMount, registerMountedSubtree, releaseBundleMount } from \"./khrClone.js\";\nimport type { KhrAssetBundle } from \"./khrTypes.js\";\n\nexport interface SubtreeOrigin {\n origParent: THREE.Object3D | null;\n origIndex: number;\n origOrder: Map<THREE.Object3D, number>;\n origPos: THREE.Vector3;\n origQuat: THREE.Quaternion;\n origScale: THREE.Vector3;\n}\n\nexport function captureSubtreeOrigins(objects: readonly THREE.Object3D[]): Map<THREE.Object3D, SubtreeOrigin> {\n const parentOrders = new Map<THREE.Object3D, Map<THREE.Object3D, number>>();\n const origins = new Map<THREE.Object3D, SubtreeOrigin>();\n for (const obj of objects) {\n const origParent = obj.parent;\n let origOrder = new Map<THREE.Object3D, number>();\n let origIndex = -1;\n if (origParent) {\n let order = parentOrders.get(origParent);\n if (!order) {\n order = new Map<THREE.Object3D, number>();\n origParent.children.forEach((child, idx) => order!.set(child, idx));\n parentOrders.set(origParent, order);\n }\n origOrder = order;\n origIndex = order.get(obj) ?? origParent.children.indexOf(obj);\n }\n origins.set(obj, {\n origParent,\n origIndex,\n origOrder,\n origPos: obj.position.clone(),\n origQuat: obj.quaternion.clone(),\n origScale: obj.scale.clone(),\n });\n }\n return origins;\n}\n\nexport function restoreSubtreeOrigin(object: THREE.Object3D, snap: SubtreeOrigin): void {\n object.position.copy(snap.origPos);\n object.quaternion.copy(snap.origQuat);\n object.scale.copy(snap.origScale);\n const { origParent, origIndex, origOrder } = snap;\n if (origParent) {\n origParent.add(object);\n const curIdx = origParent.children.indexOf(object);\n if (curIdx >= 0)\n origParent.children.splice(curIdx, 1);\n let insertAt = origParent.children.length;\n if (origOrder.size > 0) {\n for (let i = 0; i < origParent.children.length; i++) {\n if ((origOrder.get(origParent.children[i]) ?? Infinity) > origIndex) {\n insertAt = i;\n break;\n }\n }\n }\n else if (origIndex >= 0) {\n insertAt = Math.min(origIndex, origParent.children.length);\n }\n origParent.children.splice(insertAt, 0, object);\n }\n}\n\nexport function BundleSceneHost({ bundle, owner }: { bundle: KhrAssetBundle; owner: string }): React.JSX.Element {\n const hostRef = useRef<THREE.Group | null>(null);\n useLayoutEffect(() => {\n const host = hostRef.current;\n if (!host)\n return;\n claimBundleMount(bundle, owner);\n host.add(bundle.scene);\n return () => {\n if (bundle.scene.parent === host)\n host.remove(bundle.scene);\n releaseBundleMount(bundle);\n };\n }, [bundle, owner]);\n return <group ref={hostRef} />;\n}\n\nexport function MountSubtreeSlot({\n object,\n position,\n quaternion,\n origin,\n}: {\n object: THREE.Object3D;\n position: [number, number, number];\n quaternion: [number, number, number, number];\n origin?: SubtreeOrigin;\n}): React.JSX.Element {\n const slotRef = useRef<THREE.Group | null>(null);\n useLayoutEffect(() => {\n const slot = slotRef.current;\n if (!slot)\n return;\n const snap = origin ?? captureSubtreeOrigins([object]).get(object)!;\n if (snap.origParent)\n snap.origParent.remove(object);\n object.position.set(0, 0, 0);\n object.quaternion.set(0, 0, 0, 1);\n object.scale.set(1, 1, 1);\n slot.add(object);\n const untrack = registerMountedSubtree(() => {\n const p = object.position.clone(), q = object.quaternion.clone(), s = object.scale.clone();\n if (object.parent === slot)\n slot.remove(object);\n restoreSubtreeOrigin(object, snap);\n return () => {\n if (snap.origParent)\n snap.origParent.remove(object);\n object.position.copy(p);\n object.quaternion.copy(q);\n object.scale.copy(s);\n slot.add(object);\n };\n });\n return () => {\n untrack();\n if (object.parent === slot)\n slot.remove(object);\n restoreSubtreeOrigin(object, snap);\n };\n }, [object, origin]);\n return <group ref={slotRef} position={position} quaternion={quaternion} />;\n}\n","import * as THREE from \"three\";\nimport type RAPIER from \"@dimforge/rapier3d-compat\";\nimport { type KhrBreakawaySpec, type KhrJointDriveSpec, type KhrJointSpec, KhrValidationError } from \"./khrTypes.js\";\nimport type { JointRuntime } from \"./physicsEcs.js\";\n\n/**\n * Rapier interaction group bitmask for attached vehicle articulated panels:\n * member of group 14 (`0x4000`), collides with all groups except 14 (`0xbfff`),\n * preventing adjacent hinged panels (e.g. `door_fl` <-> `door_rl` / `hood`) from\n * fighting across joints while colliding normally with world geometry and projectiles.\n */\nexport const VEHICLE_PANEL_INTERACTION_GROUPS = 0x0002fffd;\n\nconst _q1 = new THREE.Quaternion();\nconst _q2 = new THREE.Quaternion();\nconst _qRel = new THREE.Quaternion();\nconst _restInv = new THREE.Quaternion();\nconst _deltaPos = new THREE.Vector3();\nconst _axWorld = new THREE.Vector3();\n\nexport function createRapierImpulseJoint(\n rapier: typeof RAPIER,\n world: RAPIER.World,\n parentBody: RAPIER.RigidBody,\n childBody: RAPIER.RigidBody,\n joint: KhrJointSpec,\n anchorParent: readonly [number, number, number],\n anchorChild: readonly [number, number, number],\n axisParent: readonly [number, number, number],\n axisChild: readonly [number, number, number],\n restFrameRelQuat: readonly [number, number, number, number],\n): RAPIER.ImpulseJoint {\n const a1 = { x: anchorParent[0], y: anchorParent[1], z: anchorParent[2] };\n const a2 = { x: anchorChild[0], y: anchorChild[1], z: anchorChild[2] };\n const qRel = _qRel.set(restFrameRelQuat[0], restFrameRelQuat[1], restFrameRelQuat[2], restFrameRelQuat[3]).normalize();\n const axFromChild = _axWorld.set(axisChild[0], axisChild[1], axisChild[2]).applyQuaternion(qRel);\n const ax = (axFromChild.lengthSq() > 1e-12 ? axFromChild : _axWorld.set(axisParent[0], axisParent[1], axisParent[2])).normalize();\n let data: RAPIER.JointData;\n if (joint.kind === \"fixed\") {\n const pr = parentBody.rotation();\n const cr = childBody.rotation();\n const bodyRel = _q1.set(pr.x, pr.y, pr.z, pr.w).invert().multiply(_q2.set(cr.x, cr.y, cr.z, cr.w)).normalize();\n const useBodyRel = Math.abs(bodyRel.x) + Math.abs(bodyRel.y) + Math.abs(bodyRel.z) <= 1e-6 && Math.abs(Math.abs(bodyRel.w) - 1) <= 1e-6;\n const f1 = useBodyRel\n ? { x: bodyRel.x, y: bodyRel.y, z: bodyRel.z, w: bodyRel.w }\n : { x: qRel.x, y: qRel.y, z: qRel.z, w: qRel.w };\n data = rapier.JointData.fixed(\n a1,\n f1,\n a2,\n { x: 0, y: 0, z: 0, w: 1 },\n );\n }\n else if (joint.kind === \"revolute\") {\n data = rapier.JointData.revolute(a1, a2, { x: ax.x, y: ax.y, z: ax.z });\n if (joint.limits) {\n data.limitsEnabled = true;\n data.limits = [joint.limits[0], joint.limits[1]];\n }\n }\n else {\n data = rapier.JointData.prismatic(a1, a2, { x: ax.x, y: ax.y, z: ax.z });\n if (joint.limits) {\n data.limitsEnabled = true;\n data.limits = [joint.limits[0], joint.limits[1]];\n }\n }\n const imp = world.createImpulseJoint(data, parentBody, childBody, true);\n imp.setContactsEnabled(Boolean(joint.enableCollision));\n configureJointDrive(rapier, imp, joint.kind, joint.drive, joint.drive?.positionTarget ?? null);\n return imp;\n}\n\nexport function configureJointDrive(\n rapier: typeof RAPIER,\n imp: RAPIER.ImpulseJoint,\n kind: KhrJointSpec[\"kind\"],\n drive: KhrJointDriveSpec | null,\n targetPos: number | null,\n): void {\n if (kind === \"fixed\" || !drive)\n return;\n const unit = imp as RAPIER.UnitImpulseJoint & { setMotorMaxForce?: (maxForce: number) => void };\n unit.configureMotorModel(\n drive.mode === \"force\" ? rapier.MotorModel.ForceBased : rapier.MotorModel.AccelerationBased,\n );\n const effTargetPos = targetPos ?? drive.positionTarget ?? (drive.stiffness !== undefined && drive.stiffness > 0 ? 0 : null);\n if (effTargetPos !== null && drive.stiffness !== undefined) {\n if (drive.velocityTarget !== undefined) {\n unit.configureMotor(effTargetPos, drive.velocityTarget, drive.stiffness, drive.damping ?? 0);\n }\n else {\n unit.configureMotorPosition(effTargetPos, drive.stiffness, drive.damping ?? 0);\n }\n }\n else if (drive.velocityTarget !== undefined) {\n unit.configureMotorVelocity(drive.velocityTarget, drive.damping ?? 0);\n }\n if (drive.maxForce !== undefined) {\n unit.setMotorMaxForce?.(drive.maxForce);\n }\n}\n\nexport function measureJointCoordinate(\n parentBody: RAPIER.RigidBody | null,\n childBody: RAPIER.RigidBody | null,\n kind: KhrJointSpec[\"kind\"],\n axisParent: readonly [number, number, number],\n anchorParent: readonly [number, number, number],\n restRelQuat: readonly [number, number, number, number],\n): number {\n if (!parentBody || !childBody || kind === \"fixed\")\n return 0;\n const pr = parentBody.rotation();\n const cr = childBody.rotation();\n _q1.set(pr.x, pr.y, pr.z, pr.w);\n _q2.set(cr.x, cr.y, cr.z, cr.w);\n if (kind === \"prismatic\") {\n const pt = parentBody.translation();\n const ct = childBody.translation();\n _deltaPos.set(anchorParent[0], anchorParent[1], anchorParent[2]).applyQuaternion(_q1);\n _deltaPos.set(ct.x - (pt.x + _deltaPos.x), ct.y - (pt.y + _deltaPos.y), ct.z - (pt.z + _deltaPos.z));\n _axWorld.set(axisParent[0], axisParent[1], axisParent[2]).applyQuaternion(_q1).normalize();\n return _deltaPos.dot(_axWorld);\n }\n _restInv.set(restRelQuat[0], restRelQuat[1], restRelQuat[2], restRelQuat[3]).invert();\n _qRel.copy(_q1).invert().multiply(_q2).premultiply(_restInv).normalize();\n if (_qRel.w < 0)\n _qRel.set(-_qRel.x, -_qRel.y, -_qRel.z, -_qRel.w);\n const sinHalf = _qRel.x * axisParent[0] + _qRel.y * axisParent[1] + _qRel.z * axisParent[2];\n return 2 * Math.atan2(sinHalf, _qRel.w);\n}\n\nexport function buildJointRuntime(params: {\n rapier: typeof RAPIER;\n world?: RAPIER.World;\n nodeName: string;\n role: string | null;\n kind: KhrJointSpec[\"kind\"];\n object: THREE.Object3D;\n axisParent: readonly [number, number, number];\n anchorParent: readonly [number, number, number];\n restRelQuat: readonly [number, number, number, number];\n limits: [number, number] | null;\n drive: KhrJointDriveSpec | null;\n breakaway?: KhrBreakawaySpec;\n rapierJoint: RAPIER.ImpulseJoint;\n parentBody: RAPIER.RigidBody;\n childBody: RAPIER.RigidBody;\n}): JointRuntime {\n const { rapier, world, nodeName, role, kind, object, axisParent, anchorParent, restRelQuat, limits, drive, breakaway, rapierJoint, parentBody, childBody } = params;\n const rt: JointRuntime = {\n nodeName,\n role,\n kind,\n object,\n axis: new THREE.Vector3(axisParent[0], axisParent[1], axisParent[2]).normalize(),\n limits,\n drive,\n positionTarget: drive?.positionTarget ?? null,\n velocityTarget: drive?.velocityTarget ?? 0,\n rapierJoint,\n parentBody,\n childBody,\n unlatched: false,\n detached: false,\n getCoordinate: () => measureJointCoordinate(rt.parentBody, rt.childBody, kind, axisParent, anchorParent, restRelQuat),\n applyTarget: (target: number) => {\n if (rt.detached || !rt.rapierJoint)\n return;\n if (!drive || drive.stiffness === undefined) {\n throw new KhrValidationError(`Joint \"${nodeName}\" has no authored drive stiffness; cannot set a position target`);\n }\n rt.unlatched = false;\n rt.positionTarget = target;\n configureJointDrive(rapier, rt.rapierJoint, kind, drive, target);\n if (parentBody.isDynamic())\n parentBody.wakeUp();\n if (childBody.isDynamic())\n childBody.wakeUp();\n },\n applyImpactImpulse: (impulseNs: number) => {\n if (rt.detached || !breakaway || !(impulseNs > 0))\n return rt.detached ? \"detached\" : rt.unlatched ? \"unlatched\" : \"intact\";\n if (impulseNs >= breakaway.breakImpulseNs) {\n if (world && rt.rapierJoint && world.getImpulseJoint(rt.rapierJoint.handle)) {\n world.removeImpulseJoint(rt.rapierJoint, true);\n }\n rt.rapierJoint = null;\n rt.detached = true;\n rt.unlatched = true;\n rt.positionTarget = null;\n const ud = childBody.userData as { ecctrl?: Record<string, unknown> } | undefined;\n if (ud?.ecctrl) {\n childBody.userData = { ...ud, ecctrl: { ...ud.ecctrl, excludeVehicleRay: false } };\n }\n for (let i = 0; i < childBody.numColliders(); i++) {\n const col = childBody.collider(i);\n const cg = col.collisionGroups();\n if (cg === VEHICLE_PANEL_INTERACTION_GROUPS || cg === 0x4000bfff) {\n col.setCollisionGroups(0xffffffff);\n col.setSolverGroups(0xffffffff);\n }\n }\n if (childBody.isDynamic())\n childBody.wakeUp();\n return \"detached\";\n }\n if (breakaway.latchImpulseNs !== undefined && impulseNs >= breakaway.latchImpulseNs && !rt.unlatched) {\n rt.unlatched = true;\n rt.positionTarget = null;\n if (kind !== \"fixed\" && rt.rapierJoint) {\n const unit = rt.rapierJoint as RAPIER.UnitImpulseJoint;\n unit.configureMotorPosition(0, 0, Math.min(drive?.damping ?? 1, 1.5));\n }\n if (childBody.isDynamic())\n childBody.wakeUp();\n return \"unlatched\";\n }\n return rt.unlatched ? \"unlatched\" : \"intact\";\n },\n };\n return rt;\n}\n","import { createContext } from \"react\";\nimport type * as THREE from \"three\";\nimport type RAPIER from \"@dimforge/rapier3d-compat\";\nimport type { KhrJointDriveSpec, KhrJointSpec } from \"./khrTypes.js\";\n\nexport interface JointRuntime {\n nodeName: string;\n role: string | null;\n kind: KhrJointSpec[\"kind\"];\n object: THREE.Object3D;\n axis: THREE.Vector3;\n limits: [number, number] | null;\n drive: KhrJointDriveSpec | null;\n positionTarget: number | null;\n velocityTarget: number;\n rapierJoint: RAPIER.ImpulseJoint | null;\n parentBody: RAPIER.RigidBody | null;\n childBody: RAPIER.RigidBody | null;\n unlatched: boolean;\n detached: boolean;\n getCoordinate: () => number;\n applyTarget: (target: number) => void;\n applyImpactImpulse: (impulseNs: number) => \"intact\" | \"unlatched\" | \"detached\";\n}\n\nexport type JointRegistry = Set<JointRuntime>;\n\n/** Retained as an optional context export for compatibility; Rapier steps ImpulseJoints natively. */\nexport const JointRegistryContext = createContext<JointRegistry | null>(null);\n"],"mappings":";;;;;;AAGA,IAAM,gCAAgB,IAAI,QAAwB;AAClD,IAAM,+BAAe,IAAI,QAAwB;AACjD,IAAM,iCAAiB,IAAI,QAAwB;AACnD,IAAM,yBAAkD,CAAC;AAEzD,SAAgB,uBAAuB,iBAA+C;CAClF,uBAAuB,KAAK,eAAe;CAC3C,aAAa;EACT,MAAM,MAAM,uBAAuB,QAAQ,eAAe;EAC1D,IAAI,OAAO,GACP,uBAAuB,OAAO,KAAK,CAAC;CAC5C;AACJ;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jD,GAAG,cAAc;IACjB,GAAG,WAAW;IACd,GAAG,YAAY;IACf,GAAG,iBAAiB;IACpB,MAAM,KAAK,UAAU;IACrB,IAAI,IAAI,QACJ,UAAU,WAAW;KAAE,GAAG;KAAI,QAAQ;MAAE,GAAG,GAAG;MAAQ,mBAAmB;KAAM;IAAE;IAErF,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,aAAa,GAAG,KAAK;KAC/C,MAAM,MAAM,UAAU,SAAS,CAAC;KAChC,MAAM,KAAK,IAAI,gBAAgB;KAC/B,IAAI,OAAA,UAA2C,OAAO,YAAY;MAC9D,IAAI,mBAAmB,UAAU;MACjC,IAAI,gBAAgB,UAAU;KAClC;IACJ;IACA,IAAI,UAAU,UAAU,GACpB,UAAU,OAAO;IACrB,OAAO;GACX;GACA,IAAI,UAAU,mBAAmB,KAAA,KAAa,aAAa,UAAU,kBAAkB,CAAC,GAAG,WAAW;IAClG,GAAG,YAAY;IACf,GAAG,iBAAiB;IACpB,IAAI,SAAS,WAAW,GAAG,aAEvB,GADgB,YACX,uBAAuB,GAAG,GAAG,KAAK,IAAI,OAAO,WAAW,GAAG,GAAG,CAAC;IAExE,IAAI,UAAU,UAAU,GACpB,UAAU,OAAO;IACrB,OAAO;GACX;GACA,OAAO,GAAG,YAAY,cAAc;EACxC;CACJ;CACA,OAAO;AACX;;;ACnMA,IAAa,uBAAuB,cAAoC,IAAI"}
|
package/dist/physicsEcs.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type * as THREE from "three";
|
|
2
|
-
import type RAPIER from "@dimforge/rapier3d-compat";
|
|
3
|
-
import type { KhrJointDriveSpec, KhrJointSpec } from "./khrTypes.js";
|
|
4
|
-
export interface JointRuntime {
|
|
5
|
-
nodeName: string;
|
|
6
|
-
role: string | null;
|
|
7
|
-
kind: KhrJointSpec["kind"];
|
|
8
|
-
object: THREE.Object3D;
|
|
9
|
-
axis: THREE.Vector3;
|
|
10
|
-
limits: [number, number] | null;
|
|
11
|
-
drive: KhrJointDriveSpec | null;
|
|
12
|
-
positionTarget: number | null;
|
|
13
|
-
velocityTarget: number;
|
|
14
|
-
rapierJoint: RAPIER.ImpulseJoint | null;
|
|
15
|
-
parentBody: RAPIER.RigidBody | null;
|
|
16
|
-
childBody: RAPIER.RigidBody | null;
|
|
17
|
-
unlatched: boolean;
|
|
18
|
-
detached: boolean;
|
|
19
|
-
getCoordinate: () => number;
|
|
20
|
-
applyTarget: (target: number) => void;
|
|
21
|
-
applyImpactImpulse: (impulseNs: number) => "intact" | "unlatched" | "detached";
|
|
22
|
-
}
|
|
23
|
-
export type JointRegistry = Set<JointRuntime>;
|
|
24
|
-
/** Retained as an optional context export for compatibility; Rapier steps ImpulseJoints natively. */
|
|
25
|
-
export declare const JointRegistryContext: import("react").Context<JointRegistry | null>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import type { KhrCarConfig, KhrDroneConfig, KhrExportNodeSpec } from "../khrTypes.js";
|
|
3
|
-
import type { Sand3dAssembly, Sand3dJointDef, Sand3dNodeItem, Sand3dPartOpts, Sand3dPartSpec, Sand3dSocketDef, Sand3dSolid, Sand3dThrusterDef, Sand3dUnits, Sand3dWheelDef, Vec3 } from "./sand3dTypes.js";
|
|
4
|
-
export declare const r4: (v: number) => number;
|
|
5
|
-
export declare const scaleV3: (v: Vec3 | undefined, s: number) => Vec3;
|
|
6
|
-
export declare function makeSand3dMaterial(name: string, shade: string | number | undefined, rough?: number, metal?: number, opacity?: number): THREE.MeshStandardMaterial;
|
|
7
|
-
export declare function part(name: string, solid: Sand3dSolid, opts?: Sand3dPartOpts): Sand3dPartSpec;
|
|
8
|
-
type JointOptsLike = Partial<Sand3dJointDef> & {
|
|
9
|
-
range?: [number, number] | null;
|
|
10
|
-
};
|
|
11
|
-
export declare function joint(kindOrSpec: "revolute" | "prismatic" | "fixed" | (Omit<Sand3dJointDef, "kind" | "jointKind"> & {
|
|
12
|
-
kind?: "revolute" | "prismatic" | "fixed";
|
|
13
|
-
jointKind?: "revolute" | "prismatic" | "fixed";
|
|
14
|
-
range?: [number, number] | null;
|
|
15
|
-
}), parentOrOpts?: string | JointOptsLike, childArg?: string, optsArg?: JointOptsLike): Sand3dJointDef;
|
|
16
|
-
export declare function wheel(name: string, opts: Omit<Sand3dWheelDef, "kind" | "name">): Sand3dWheelDef;
|
|
17
|
-
export declare function thruster(name: string, opts: Omit<Sand3dThrusterDef, "kind" | "name">): Sand3dThrusterDef;
|
|
18
|
-
export declare function socket(name: string, position: Vec3, opts?: Omit<Sand3dSocketDef, "kind" | "name" | "position">): Sand3dSocketDef;
|
|
19
|
-
export declare function assembly(name: string, itemsOrConfig: readonly Sand3dNodeItem[] | Partial<Omit<Sand3dAssembly, "kind" | "name">>, opts?: {
|
|
20
|
-
units?: Sand3dUnits;
|
|
21
|
-
carTune?: Partial<KhrCarConfig>;
|
|
22
|
-
droneTune?: Partial<KhrDroneConfig>;
|
|
23
|
-
extras?: Record<string, unknown>;
|
|
24
|
-
}): Sand3dAssembly;
|
|
25
|
-
export declare function exportTarget(target: Sand3dAssembly | Sand3dPartSpec | Sand3dSolid, opts?: {
|
|
26
|
-
name?: string;
|
|
27
|
-
units?: Sand3dUnits;
|
|
28
|
-
}): Sand3dAssembly;
|
|
29
|
-
export declare function appendRotorsAndSockets(asm: Sand3dAssembly, s: number, totalBodyMass: number, primaryBodyName: string, nodeMap: Map<string, THREE.Object3D>, worldOriginByPart: Map<string, Vec3>, scene: THREE.Group, specs: KhrExportNodeSpec[]): void;
|
|
30
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { resolveFaceFrame, shell } from "./sand3dShellOp.js";
|
|
2
|
-
import type { Sand3dFaceSelector, Sand3dProfile, Sand3dSolid, Vec2 } from "./sand3dTypes.js";
|
|
3
|
-
export { resolveFaceFrame, shell };
|
|
4
|
-
/** Carves cylindrical through-bores or blind bores with re-triangulated planar cap rings. */
|
|
5
|
-
export declare function hole(solid: Sand3dSolid, diameter: number, opts?: {
|
|
6
|
-
depth?: number;
|
|
7
|
-
on?: readonly Vec2[] | Vec2;
|
|
8
|
-
face?: Sand3dFaceSelector;
|
|
9
|
-
segments?: number;
|
|
10
|
-
}): Sand3dSolid;
|
|
11
|
-
/** Carves recessed or through polygonal cavities with re-triangulated walls and floor caps. */
|
|
12
|
-
export declare function pocket(solid: Sand3dSolid, profile: Sand3dProfile, depth: number, opts?: {
|
|
13
|
-
on?: readonly Vec2[] | Vec2;
|
|
14
|
-
face?: Sand3dFaceSelector;
|
|
15
|
-
}): Sand3dSolid;
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { type KhrAssetBundle } from "../khrTypes.js";
|
|
2
|
-
import { assembly, exportTarget, joint, part, socket, thruster, wheel } from "./sand3dAssemblyHelpers.js";
|
|
3
|
-
import * as edits from "./sand3dFramesAndEdits.js";
|
|
4
|
-
import * as solids from "./sand3dSolids.js";
|
|
5
|
-
import { type CompiledSand3dAssembly, type Sand3dAssembly, type Sand3dPartSpec, type Sand3dSolid, type Sand3dUnits, type Vec3 } from "./sand3dTypes.js";
|
|
6
|
-
export { assembly, exportTarget, joint, part, socket, thruster, wheel };
|
|
7
|
-
/** Compiles a Sand3D assembly, part, or solid into a unit-scale Three.js scene and KHR export specs. */
|
|
8
|
-
export declare function compileSand3dAssembly(input: Sand3dAssembly | Sand3dPartSpec | Sand3dSolid, opts?: {
|
|
9
|
-
units?: Sand3dUnits;
|
|
10
|
-
}): CompiledSand3dAssembly;
|
|
11
|
-
export declare function exportSand3dGlb(input: Sand3dAssembly | Sand3dPartSpec | Sand3dSolid, opts?: {
|
|
12
|
-
units?: Sand3dUnits;
|
|
13
|
-
}): Promise<Uint8Array>;
|
|
14
|
-
export declare function loadSand3dBundle(input: Sand3dAssembly | Sand3dPartSpec | Sand3dSolid, opts?: {
|
|
15
|
-
units?: Sand3dUnits;
|
|
16
|
-
}): Promise<KhrAssetBundle>;
|
|
17
|
-
export declare const s3d: {
|
|
18
|
-
part: typeof part;
|
|
19
|
-
joint: typeof joint;
|
|
20
|
-
wheel: typeof wheel;
|
|
21
|
-
thruster: typeof thruster;
|
|
22
|
-
socket: typeof socket;
|
|
23
|
-
assembly: typeof assembly;
|
|
24
|
-
export: typeof exportTarget;
|
|
25
|
-
compile: typeof compileSand3dAssembly;
|
|
26
|
-
exportGlb: typeof exportSand3dGlb;
|
|
27
|
-
loadBundle: typeof loadSand3dBundle;
|
|
28
|
-
grid(nx: number, ny: number, pitchX: number, pitchYOrOpts?: number | {
|
|
29
|
-
pitchY?: number;
|
|
30
|
-
center?: import("./sand3dTypes.js").Vec2;
|
|
31
|
-
}, center?: import("./sand3dTypes.js").Vec2): import("./sand3dTypes.js").Vec2[];
|
|
32
|
-
polar(count: number, radius: number, startOrOpts?: number | {
|
|
33
|
-
startDeg?: number;
|
|
34
|
-
spanDeg?: number;
|
|
35
|
-
}, spanDeg?: number): import("./sand3dTypes.js").Vec2[];
|
|
36
|
-
at(origin: Vec3, rotDeg?: Vec3): import("./sand3dTypes.js").Sand3dFrame;
|
|
37
|
-
on(target: Sand3dSolid | Sand3dPartSpec, selector?: import("./sand3dTypes.js").Sand3dFaceSelector, offset?: Vec3): import("./sand3dTypes.js").Sand3dFrame;
|
|
38
|
-
chamfer(solid: Sand3dSolid, distance: number): Sand3dSolid;
|
|
39
|
-
fillet(solid: Sand3dSolid, radius: number): Sand3dSolid;
|
|
40
|
-
taper(solid: Sand3dSolid, factor: number, axis?: "X" | "Y" | "Z"): Sand3dSolid;
|
|
41
|
-
twist(solid: Sand3dSolid, angleDeg: number, axis?: "X" | "Y" | "Z"): Sand3dSolid;
|
|
42
|
-
bend(solid: Sand3dSolid, angleDeg: number, axis?: "X" | "Z"): Sand3dSolid;
|
|
43
|
-
color(solid: Sand3dSolid, shade: string | number, opts?: {
|
|
44
|
-
roughness?: number;
|
|
45
|
-
metalness?: number;
|
|
46
|
-
opacity?: number;
|
|
47
|
-
}): Sand3dSolid;
|
|
48
|
-
translate(solid: Sand3dSolid, offset: Vec3): Sand3dSolid;
|
|
49
|
-
rotate(solid: Sand3dSolid, rotDeg: Vec3): Sand3dSolid;
|
|
50
|
-
unionSolids(solids: readonly Sand3dSolid[], name?: string, shade?: string | number): Sand3dSolid;
|
|
51
|
-
hole: typeof edits.hole;
|
|
52
|
-
pocket: typeof edits.pocket;
|
|
53
|
-
resolveFaceFrame: typeof edits.resolveFaceFrame;
|
|
54
|
-
shell: typeof edits.shell;
|
|
55
|
-
extrude(profile: import("./sand3dTypes.js").Sand3dProfile, height: number, opts?: {
|
|
56
|
-
centered?: boolean;
|
|
57
|
-
bevel?: number;
|
|
58
|
-
taper?: number;
|
|
59
|
-
twistDeg?: number;
|
|
60
|
-
name?: string;
|
|
61
|
-
color?: string | number;
|
|
62
|
-
}): Sand3dSolid;
|
|
63
|
-
revolve(profile: import("./sand3dTypes.js").Sand3dProfile, angleOrOpts?: number | {
|
|
64
|
-
angleDeg?: number;
|
|
65
|
-
segments?: number;
|
|
66
|
-
name?: string;
|
|
67
|
-
color?: string | number;
|
|
68
|
-
}, segmentsOrOpts?: number | {
|
|
69
|
-
segments?: number;
|
|
70
|
-
name?: string;
|
|
71
|
-
color?: string | number;
|
|
72
|
-
}, optsArg?: {
|
|
73
|
-
name?: string;
|
|
74
|
-
color?: string | number;
|
|
75
|
-
}): Sand3dSolid;
|
|
76
|
-
loft(profiles: readonly import("./sand3dTypes.js").Sand3dProfile[], heights?: readonly number[], opts?: {
|
|
77
|
-
name?: string;
|
|
78
|
-
color?: string | number;
|
|
79
|
-
}): Sand3dSolid;
|
|
80
|
-
box: typeof solids.box;
|
|
81
|
-
cone: typeof solids.cone;
|
|
82
|
-
cylinder: typeof solids.cylinder;
|
|
83
|
-
dome: typeof solids.dome;
|
|
84
|
-
finalizeManifoldGeometry: typeof solids.finalizeManifoldGeometry;
|
|
85
|
-
helix: typeof solids.helix;
|
|
86
|
-
hull: typeof solids.hull;
|
|
87
|
-
sphere: typeof solids.sphere;
|
|
88
|
-
sweep: typeof solids.sweep;
|
|
89
|
-
torus: typeof solids.torus;
|
|
90
|
-
tube: typeof solids.tube;
|
|
91
|
-
signedArea2D(pts: readonly import("./sand3dTypes.js").Vec2[]): number;
|
|
92
|
-
cleanLoop2D(pts: readonly import("./sand3dTypes.js").Vec2[], ccw: boolean): import("./sand3dTypes.js").Vec2[];
|
|
93
|
-
polygon(pts: readonly import("./sand3dTypes.js").Vec2[], holes?: readonly (readonly import("./sand3dTypes.js").Vec2[])[]): import("./sand3dTypes.js").Sand3dProfile;
|
|
94
|
-
rect(w: number, d: number, opts?: {
|
|
95
|
-
r?: number;
|
|
96
|
-
chamfer?: number;
|
|
97
|
-
segments?: number;
|
|
98
|
-
center?: import("./sand3dTypes.js").Vec2;
|
|
99
|
-
}): import("./sand3dTypes.js").Sand3dProfile;
|
|
100
|
-
circle(diameter: number, segmentsOrOpts?: number | {
|
|
101
|
-
segments?: number;
|
|
102
|
-
center?: import("./sand3dTypes.js").Vec2;
|
|
103
|
-
}, center?: import("./sand3dTypes.js").Vec2): import("./sand3dTypes.js").Sand3dProfile;
|
|
104
|
-
ngon(sides: number, radius: number, startOrOpts?: number | {
|
|
105
|
-
startDeg?: number;
|
|
106
|
-
center?: import("./sand3dTypes.js").Vec2;
|
|
107
|
-
}, center?: import("./sand3dTypes.js").Vec2): import("./sand3dTypes.js").Sand3dProfile;
|
|
108
|
-
star(points: number, rOuter: number, rInner: number, startOrOpts?: number | {
|
|
109
|
-
startDeg?: number;
|
|
110
|
-
center?: import("./sand3dTypes.js").Vec2;
|
|
111
|
-
}, center?: import("./sand3dTypes.js").Vec2): import("./sand3dTypes.js").Sand3dProfile;
|
|
112
|
-
slot(length: number, width: number, segmentsOrOpts?: number | {
|
|
113
|
-
segments?: number;
|
|
114
|
-
center?: import("./sand3dTypes.js").Vec2;
|
|
115
|
-
}, center?: import("./sand3dTypes.js").Vec2): import("./sand3dTypes.js").Sand3dProfile;
|
|
116
|
-
subtractProfileHole(profile: import("./sand3dTypes.js").Sand3dProfile, hole: import("./sand3dTypes.js").Sand3dProfile | readonly import("./sand3dTypes.js").Vec2[], offset?: import("./sand3dTypes.js").Vec2): import("./sand3dTypes.js").Sand3dProfile;
|
|
117
|
-
triangulateProfile2D(profile: import("./sand3dTypes.js").Sand3dProfile): {
|
|
118
|
-
vertices: import("./sand3dTypes.js").Vec2[];
|
|
119
|
-
triangles: [number, number, number][];
|
|
120
|
-
};
|
|
121
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { Sand3dAssembly, Sand3dUnits } from "./sand3dTypes.js";
|
|
2
|
-
export type S3dExpr = {
|
|
3
|
-
t: "lit";
|
|
4
|
-
v: unknown;
|
|
5
|
-
} | {
|
|
6
|
-
t: "id";
|
|
7
|
-
name: string;
|
|
8
|
-
} | {
|
|
9
|
-
t: "list";
|
|
10
|
-
items: S3dExpr[];
|
|
11
|
-
} | {
|
|
12
|
-
t: "dict";
|
|
13
|
-
entries: Array<[string, S3dExpr]>;
|
|
14
|
-
} | {
|
|
15
|
-
t: "un";
|
|
16
|
-
op: string;
|
|
17
|
-
arg: S3dExpr;
|
|
18
|
-
} | {
|
|
19
|
-
t: "bin";
|
|
20
|
-
op: string;
|
|
21
|
-
l: S3dExpr;
|
|
22
|
-
r: S3dExpr;
|
|
23
|
-
} | {
|
|
24
|
-
t: "mem";
|
|
25
|
-
obj: S3dExpr;
|
|
26
|
-
prop: string;
|
|
27
|
-
} | {
|
|
28
|
-
t: "idx";
|
|
29
|
-
obj: S3dExpr;
|
|
30
|
-
idx: S3dExpr;
|
|
31
|
-
} | {
|
|
32
|
-
t: "tern";
|
|
33
|
-
cond: S3dExpr;
|
|
34
|
-
tr: S3dExpr;
|
|
35
|
-
fa: S3dExpr;
|
|
36
|
-
} | {
|
|
37
|
-
t: "call";
|
|
38
|
-
callee: S3dExpr;
|
|
39
|
-
args: S3dExpr[];
|
|
40
|
-
kwargs: Array<[string, S3dExpr]>;
|
|
41
|
-
};
|
|
42
|
-
export type S3dStmt = {
|
|
43
|
-
s: "assign";
|
|
44
|
-
names: string[];
|
|
45
|
-
op: string;
|
|
46
|
-
val: S3dExpr;
|
|
47
|
-
} | {
|
|
48
|
-
s: "def";
|
|
49
|
-
name: string;
|
|
50
|
-
params: Array<{
|
|
51
|
-
name: string;
|
|
52
|
-
def?: S3dExpr;
|
|
53
|
-
}>;
|
|
54
|
-
body: S3dStmt[];
|
|
55
|
-
} | {
|
|
56
|
-
s: "for";
|
|
57
|
-
vars: string[];
|
|
58
|
-
iter: S3dExpr;
|
|
59
|
-
body: S3dStmt[];
|
|
60
|
-
} | {
|
|
61
|
-
s: "if";
|
|
62
|
-
cond: S3dExpr;
|
|
63
|
-
thenB: S3dStmt[];
|
|
64
|
-
elseB: S3dStmt[];
|
|
65
|
-
} | {
|
|
66
|
-
s: "ret";
|
|
67
|
-
val: S3dExpr | null;
|
|
68
|
-
} | {
|
|
69
|
-
s: "expr";
|
|
70
|
-
val: S3dExpr;
|
|
71
|
-
};
|
|
72
|
-
export declare const toSand3dCamel: (k: string) => string;
|
|
73
|
-
/** Evaluates a parsed Sand3D statement list into a normalized Sand3dAssembly. */
|
|
74
|
-
export declare function evaluateSand3dAst(stmts: readonly S3dStmt[], source: string, opts?: {
|
|
75
|
-
units?: Sand3dUnits;
|
|
76
|
-
}): Sand3dAssembly;
|
|
77
|
-
/** Evaluates a .s3d.json manifest object into a normalized Sand3dAssembly. */
|
|
78
|
-
export declare function evaluateSand3dJson(source: string, opts?: {
|
|
79
|
-
units?: Sand3dUnits;
|
|
80
|
-
}): Sand3dAssembly;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { hole, pocket, resolveFaceFrame, shell } from "./sand3dCavityOps.js";
|
|
2
|
-
import type { Sand3dFaceSelector, Sand3dFrame, Sand3dPartSpec, Sand3dSolid, Vec2, Vec3 } from "./sand3dTypes.js";
|
|
3
|
-
export { hole, pocket, resolveFaceFrame, shell };
|
|
4
|
-
/** Generates a centered 2D rectangular bolt or feature grid of nx by ny points. */
|
|
5
|
-
export declare function grid(nx: number, ny: number, pitchX: number, pitchYOrOpts?: number | {
|
|
6
|
-
pitchY?: number;
|
|
7
|
-
center?: Vec2;
|
|
8
|
-
}, center?: Vec2): Vec2[];
|
|
9
|
-
/** Generates a circular bolt pattern of count points at given radius. */
|
|
10
|
-
export declare function polar(count: number, radius: number, startOrOpts?: number | {
|
|
11
|
-
startDeg?: number;
|
|
12
|
-
spanDeg?: number;
|
|
13
|
-
}, spanDeg?: number): Vec2[];
|
|
14
|
-
/** Constructs an explicit local coordinate frame from origin and optional Euler degrees. */
|
|
15
|
-
export declare function at(origin: Vec3, rotDeg?: Vec3): Sand3dFrame;
|
|
16
|
-
/** Resolves a named topological face or corner frame on a solid or placed part. */
|
|
17
|
-
export declare function on(target: Sand3dSolid | Sand3dPartSpec, selector?: Sand3dFaceSelector, offset?: Vec3): Sand3dFrame;
|
|
18
|
-
export declare function chamfer(solid: Sand3dSolid, distance: number): Sand3dSolid;
|
|
19
|
-
export declare function fillet(solid: Sand3dSolid, radius: number): Sand3dSolid;
|
|
20
|
-
export declare function taper(solid: Sand3dSolid, factor: number, axis?: "X" | "Y" | "Z"): Sand3dSolid;
|
|
21
|
-
export declare function twist(solid: Sand3dSolid, angleDeg: number, axis?: "X" | "Y" | "Z"): Sand3dSolid;
|
|
22
|
-
export declare function bend(solid: Sand3dSolid, angleDeg: number, axis?: "X" | "Z"): Sand3dSolid;
|
|
23
|
-
export declare function color(solid: Sand3dSolid, shade: string | number, opts?: {
|
|
24
|
-
roughness?: number;
|
|
25
|
-
metalness?: number;
|
|
26
|
-
opacity?: number;
|
|
27
|
-
}): Sand3dSolid;
|
|
28
|
-
export declare function translate(solid: Sand3dSolid, offset: Vec3): Sand3dSolid;
|
|
29
|
-
export declare function rotate(solid: Sand3dSolid, rotDeg: Vec3): Sand3dSolid;
|
|
30
|
-
export declare function unionSolids(solids: readonly Sand3dSolid[], name?: string, shade?: string | number): Sand3dSolid;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import type { Sand3dProfile, Sand3dSolid, Vec3 } from "./sand3dTypes.js";
|
|
3
|
-
export declare function finalizeManifoldGeometry(positions: number[]): THREE.BufferGeometry;
|
|
4
|
-
export declare function pushTri(out: number[], a: THREE.Vector3, b: THREE.Vector3, c: THREE.Vector3): void;
|
|
5
|
-
export declare function pushQuad(out: number[], a: THREE.Vector3, b: THREE.Vector3, c: THREE.Vector3, d: THREE.Vector3): void;
|
|
6
|
-
/** Sweeps a 2D profile along a 3D polyline using Bishop parallel-transport frames. */
|
|
7
|
-
export declare function sweep(profile: Sand3dProfile, path: readonly Vec3[], opts?: {
|
|
8
|
-
closed?: boolean;
|
|
9
|
-
scaleEnd?: number;
|
|
10
|
-
twistDeg?: number;
|
|
11
|
-
name?: string;
|
|
12
|
-
color?: string | number;
|
|
13
|
-
}): Sand3dSolid;
|
|
14
|
-
/** Sweeps a 2D profile along a cylindrical helix of given radius, pitch, and turn count. */
|
|
15
|
-
export declare function helix(profile: Sand3dProfile, opts: {
|
|
16
|
-
radius: number;
|
|
17
|
-
pitch: number;
|
|
18
|
-
turns: number;
|
|
19
|
-
segmentsPerTurn?: number;
|
|
20
|
-
name?: string;
|
|
21
|
-
color?: string | number;
|
|
22
|
-
}): Sand3dSolid;
|
|
23
|
-
/** Builds a 3D incremental convex hull over a point cloud or an array of Sand3D solids. */
|
|
24
|
-
export declare function hull(source: readonly Vec3[] | readonly Sand3dSolid[], opts?: {
|
|
25
|
-
name?: string;
|
|
26
|
-
color?: string | number;
|
|
27
|
-
}): Sand3dSolid;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Sand3dAssembly, Sand3dUnits } from "./sand3dTypes.js";
|
|
2
|
-
/** Returns true when a file path carries a Sand3D script or JSON manifest extension. */
|
|
3
|
-
export declare function isSand3dFileName(fileName: string): boolean;
|
|
4
|
-
export declare function parseSand3dSource(source: string, opts?: {
|
|
5
|
-
units?: Sand3dUnits;
|
|
6
|
-
}): Sand3dAssembly;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { Sand3dSolid } from "./sand3dTypes.js";
|
|
2
|
-
export declare function box(w: number, h: number, d: number, opts?: {
|
|
3
|
-
centered?: boolean;
|
|
4
|
-
chamfer?: number;
|
|
5
|
-
fillet?: number;
|
|
6
|
-
name?: string;
|
|
7
|
-
color?: string | number;
|
|
8
|
-
}): Sand3dSolid;
|
|
9
|
-
export declare function cylinder(diameter: number, height: number, opts?: {
|
|
10
|
-
segments?: number;
|
|
11
|
-
centered?: boolean;
|
|
12
|
-
name?: string;
|
|
13
|
-
color?: string | number;
|
|
14
|
-
}): Sand3dSolid;
|
|
15
|
-
export declare function tube(outerDiameter: number, innerDiameter: number, height: number, opts?: {
|
|
16
|
-
segments?: number;
|
|
17
|
-
centered?: boolean;
|
|
18
|
-
name?: string;
|
|
19
|
-
color?: string | number;
|
|
20
|
-
}): Sand3dSolid;
|
|
21
|
-
export declare function cone(diameterBottom: number, diameterTop: number, height: number, opts?: {
|
|
22
|
-
segments?: number;
|
|
23
|
-
centered?: boolean;
|
|
24
|
-
name?: string;
|
|
25
|
-
color?: string | number;
|
|
26
|
-
}): Sand3dSolid;
|
|
27
|
-
export declare function sphere(diameter: number, opts?: {
|
|
28
|
-
segments?: number;
|
|
29
|
-
rings?: number;
|
|
30
|
-
name?: string;
|
|
31
|
-
color?: string | number;
|
|
32
|
-
}): Sand3dSolid;
|
|
33
|
-
export declare function dome(diameter: number, heightOrOpts?: number | {
|
|
34
|
-
height?: number;
|
|
35
|
-
segments?: number;
|
|
36
|
-
rings?: number;
|
|
37
|
-
name?: string;
|
|
38
|
-
color?: string | number;
|
|
39
|
-
}, optsArg?: {
|
|
40
|
-
segments?: number;
|
|
41
|
-
rings?: number;
|
|
42
|
-
name?: string;
|
|
43
|
-
color?: string | number;
|
|
44
|
-
}): Sand3dSolid;
|
|
45
|
-
export declare function torus(majorDiameter: number, tubeDiameter: number, opts?: {
|
|
46
|
-
majorSegments?: number;
|
|
47
|
-
tubeSegments?: number;
|
|
48
|
-
name?: string;
|
|
49
|
-
color?: string | number;
|
|
50
|
-
}): Sand3dSolid;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { Sand3dProfile, Vec2 } from "./sand3dTypes.js";
|
|
2
|
-
export declare function signedArea2D(pts: readonly Vec2[]): number;
|
|
3
|
-
export declare function cleanLoop2D(pts: readonly Vec2[], ccw: boolean): Vec2[];
|
|
4
|
-
export declare function polygon(pts: readonly Vec2[], holes?: readonly (readonly Vec2[])[]): Sand3dProfile;
|
|
5
|
-
export declare function rect(w: number, d: number, opts?: {
|
|
6
|
-
r?: number;
|
|
7
|
-
chamfer?: number;
|
|
8
|
-
segments?: number;
|
|
9
|
-
center?: Vec2;
|
|
10
|
-
}): Sand3dProfile;
|
|
11
|
-
export declare function circle(diameter: number, segmentsOrOpts?: number | {
|
|
12
|
-
segments?: number;
|
|
13
|
-
center?: Vec2;
|
|
14
|
-
}, center?: Vec2): Sand3dProfile;
|
|
15
|
-
export declare function ngon(sides: number, radius: number, startOrOpts?: number | {
|
|
16
|
-
startDeg?: number;
|
|
17
|
-
center?: Vec2;
|
|
18
|
-
}, center?: Vec2): Sand3dProfile;
|
|
19
|
-
export declare function star(points: number, rOuter: number, rInner: number, startOrOpts?: number | {
|
|
20
|
-
startDeg?: number;
|
|
21
|
-
center?: Vec2;
|
|
22
|
-
}, center?: Vec2): Sand3dProfile;
|
|
23
|
-
export declare function slot(length: number, width: number, segmentsOrOpts?: number | {
|
|
24
|
-
segments?: number;
|
|
25
|
-
center?: Vec2;
|
|
26
|
-
}, center?: Vec2): Sand3dProfile;
|
|
27
|
-
export declare function subtractProfileHole(profile: Sand3dProfile, hole: Sand3dProfile | readonly Vec2[], offset?: Vec2): Sand3dProfile;
|
|
28
|
-
/** Bridges inner hole contours by rightmost visibility and triangulates by ear clipping. */
|
|
29
|
-
export declare function triangulateProfile2D(profile: Sand3dProfile): {
|
|
30
|
-
vertices: Vec2[];
|
|
31
|
-
triangles: [number, number, number][];
|
|
32
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CompiledSand3dAssembly, Sand3dRecipe, Sand3dRecipeId } from "./sand3dTypes.js";
|
|
2
|
-
export declare const SAND3D_RECIPES: readonly Sand3dRecipe[];
|
|
3
|
-
export declare const SAND3D_RECIPE_MAP: Record<Sand3dRecipeId, Sand3dRecipe>;
|
|
4
|
-
export declare function findSand3dRecipe(id: string): Sand3dRecipe | undefined;
|
|
5
|
-
export declare function buildSand3dRecipe(id: Sand3dRecipeId): CompiledSand3dAssembly;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import type { Sand3dFaceSelector, Sand3dFrame, Sand3dSolid, Vec3 } from "./sand3dTypes.js";
|
|
3
|
-
export declare function emitOrientedTri(out: number[], a: THREE.Vector3, b: THREE.Vector3, c: THREE.Vector3, desiredN: THREE.Vector3): void;
|
|
4
|
-
export declare function resolveFaceFrame(solid: Sand3dSolid, selector?: Sand3dFaceSelector, offset?: Vec3): Sand3dFrame;
|
|
5
|
-
/** Hollows a solid to uniform wall thickness while opening the selected face and sealing the rim. */
|
|
6
|
-
export declare function shell(solid: Sand3dSolid, thickness: number, opts?: {
|
|
7
|
-
openFace?: Sand3dFaceSelector;
|
|
8
|
-
}): Sand3dSolid;
|