@khr3/core 0.1.5 → 0.2.0
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 +3 -114
- package/dist/BundleSceneHost-DUqqPtJF.js +1036 -0
- package/dist/BundleSceneHost-DUqqPtJF.js.map +1 -0
- package/dist/KhrCollider.d.ts +1 -1
- package/dist/KhrVehicle.d.ts +5 -7
- package/dist/PhysicsWorld.d.ts +2 -2
- package/dist/assemblyPlan.d.ts +2 -0
- package/dist/curves.d.ts +11 -32
- package/dist/curves.js +141 -139
- package/dist/curves.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1639 -1240
- package/dist/index.js.map +1 -0
- package/dist/jointDynamics.d.ts +1 -1
- package/dist/khrBundleFinalize.d.ts +14 -0
- package/dist/khrConfigTypes.d.ts +62 -0
- package/dist/khrExportEncoders.d.ts +8 -0
- package/dist/khrExporter.d.ts +2 -1
- package/dist/khrExtras.d.ts +3 -3
- package/dist/khrGlb.d.ts +23 -0
- package/dist/khrJointParser.d.ts +3 -0
- package/dist/khrLoader.d.ts +2 -1
- package/dist/khrParsers.d.ts +5 -9
- package/dist/khrPlugin.d.ts +2 -3
- package/dist/khrPluginHelpers.d.ts +4 -0
- package/dist/khrRotorDecoders.d.ts +4 -0
- package/dist/khrShapeParser.d.ts +8 -0
- package/dist/khrTypes.d.ts +11 -103
- package/dist/khrVehicleChassis.d.ts +9 -17
- package/dist/khrVehicleJointHelpers.d.ts +24 -0
- package/dist/khrVehicleJoints.d.ts +18 -0
- package/dist/khrVehicleRotors.d.ts +22 -0
- package/dist/khrVehicleSlots.d.ts +19 -15
- package/dist/khrVehicleTypes.d.ts +52 -0
- package/dist/pacejka.d.ts +1 -1
- package/dist/physicsEcs.d.ts +2 -7
- package/dist/useKhrGlb.d.ts +2 -2
- package/dist/vehicle.d.ts +2 -2
- package/dist/vehicle.js +757 -451
- package/dist/vehicle.js.map +1 -0
- package/dist/wheelLoads.d.ts +4 -7
- package/docs/api-reference.md +209 -0
- package/package.json +8 -7
- package/dist/BundleSceneHost-CE3HPB8a.js +0 -556
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundleSceneHost-DUqqPtJF.js","names":["_qExtra"],"sources":["../src/khrMassProps.ts","../src/khrConfigTypes.ts","../src/jointDynamics.ts","../src/physicsEcs.ts","../src/khrInertia.ts","../src/khrClone.ts","../src/KhrCollider.tsx","../src/assemblyPlan.ts","../src/BundleSceneHost.tsx"],"sourcesContent":["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 type { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\";\n\nexport class KhrValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"KhrValidationError\";\n }\n}\n\nexport interface KhrCurvePoint {\n x: number;\n y: number;\n r_in?: number;\n r_out?: number;\n w_in?: number;\n w_out?: number;\n}\n\nexport interface KhrCurveData {\n points: KhrCurvePoint[];\n samples?: number;\n}\n\nexport interface KhrCarConfig {\n controlMode?: \"VELOCITY\" | \"POSITION\";\n engineHorsepower?: number;\n engineMaxRPM?: number;\n gearRatios?: number[];\n finalDriveRatio?: number;\n transmissionMode?: \"auto\" | \"manual\";\n shiftUpRPM?: number;\n shiftDownRPM?: number;\n shiftCooldown?: number;\n steerRate?: number;\n maxSteerAngle?: number;\n reverseTorqueScale?: number;\n reverseRPMScale?: number;\n engineTorqueCurveData?: KhrCurveData;\n steerAngleCurveData?: KhrCurveData;\n}\n\nexport interface KhrDroneConfig {\n controlMode?: \"VELOCITY\" | \"POSITION\";\n maxYawRate?: number;\n maxHorizSpeed?: number;\n maxVertSpeed?: number;\n maxTiltAngle?: number;\n airDragFactor?: number;\n TILT_P?: number;\n TILT_D?: number;\n YAW_POS_P?: number;\n YAW_VEL_P?: number;\n VERT_POS_P?: number;\n VERT_POS_D?: number;\n HORIZ_POS_P?: number;\n HORIZ_POS_D?: number;\n HORIZ_VEL_P?: number;\n VERT_VEL_P?: number;\n}\n\nexport interface KhrPluginOptions {\n extractRole?: (nodeName: string, extras: Record<string, unknown>) => string | null;\n isSocketNode?: (nodeName: string, extras: Record<string, unknown>) => boolean | string;\n}\n\nexport interface LoadKhrGlbOptions extends KhrPluginOptions {\n loader?: GLTFLoader;\n}\n\nexport interface UseKhrGlbOptions extends KhrPluginOptions {\n extendLoader?: (loader: GLTFLoader) => void;\n cacheKey?: string;\n}\n","import * as THREE from \"three\";\nimport { bodyPoseMatrix } from \"./khrMassProps.js\";\nimport { type KhrBodySpec, type KhrJointSpec, KhrValidationError } from \"./khrTypes.js\";\nimport type { JointRuntime } from \"./physicsEcs.js\";\n\nconst _axis = new THREE.Vector3();\nconst _axisInPart = new THREE.Vector3();\nconst _com = new THREE.Vector3();\nconst _qExtra = new THREE.Quaternion();\nconst _qPart = new THREE.Quaternion();\nconst _invRoot = new THREE.Matrix4();\nconst _relMat = new THREE.Matrix4();\nconst _deltaMat = new THREE.Matrix4();\nconst _colMat = new THREE.Matrix4();\nconst _tmpPos = new THREE.Vector3();\nconst _tmpQuat = new THREE.Quaternion();\nconst _tmpScale = new THREE.Vector3();\nconst _childMat = new THREE.Matrix4();\n\n/**\n * Effective inertia of a jointed subtree `[body, ...descendants]` about `body`'s joint axis\n * (axis through `body`'s node origin, in `body`'s rest frame).\n * Revolute: Sum_k [ a^T * R_k * diag(I_k) * R_k^T * a + m_k * (|c_k|^2 - (a . c_k)^2) ]. Prismatic: Sum_k m_k.\n */\nexport function effectiveJointInertia(\n body: KhrBodySpec,\n joint: KhrJointSpec,\n descendants: readonly KhrBodySpec[] = [],\n): number {\n if (joint.kind === \"fixed\")\n return 0;\n const subtree = descendants.length > 0 ? [body, ...descendants] : [body];\n if (joint.kind === \"prismatic\") {\n let m = 0;\n for (const b of subtree) {\n if (!(b.isKinematic && b !== body))\n m += b.mass;\n }\n return m;\n }\n _axis.fromArray(joint.axis).normalize();\n if (descendants.length > 0)\n bodyPoseMatrix(body, _invRoot).invert();\n let total = 0;\n for (const part of subtree) {\n if (part !== body && part.isKinematic)\n continue;\n if (part === body) {\n _tmpPos.set(0, 0, 0);\n _tmpQuat.identity();\n }\n else {\n _relMat.multiplyMatrices(_invRoot, bodyPoseMatrix(part, _colMat)).decompose(_tmpPos, _tmpQuat, _tmpScale);\n _tmpQuat.normalize();\n }\n _qPart.copy(_tmpQuat).multiply(_qExtra.fromArray(part.inertiaOrientation)).invert();\n _axisInPart.copy(_axis).applyQuaternion(_qPart);\n const [d0, d1, d2] = part.inertiaDiagonal;\n const iSpin = d0 * _axisInPart.x * _axisInPart.x + d1 * _axisInPart.y * _axisInPart.y + d2 * _axisInPart.z * _axisInPart.z;\n _com.fromArray(part.centerOfMass).applyQuaternion(_tmpQuat).add(_tmpPos);\n const along = _com.dot(_axis);\n total += iSpin + part.mass * (_com.lengthSq() - along * along);\n }\n return total;\n}\n\n/**\n * Advances one joint by `dt` seconds with the authored KHR drive (implicit spring-damper, unconditionally stable):\n * force mode: I * a = k * (q* - q) + c * (v* - v)\n * acceleration mode: a = k * (q* - q) + c * (v* - v)\n * Soft limits add physical restoring stiffness/damping scaled by `1 / I` outside [min, max];\n * hard limits (`limitStiffness === null`) clamp position and inward-Zero velocity.\n */\nexport function stepJoint(j: JointRuntime, dt: number): void {\n if (j.kind === \"fixed\" || !(dt > 0))\n return;\n const drive = j.drive;\n const isForce = drive?.mode === \"force\";\n const hasSoftLimit = j.limits !== null && j.limitStiffness !== null;\n if ((isForce || hasSoftLimit) && !(j.inertia > 0)) {\n throw new KhrValidationError(`Joint \"${j.nodeName}\" requires positive effective inertia (got ${j.inertia})`);\n }\n const invI = isForce ? 1 / j.inertia : 1;\n const k = j.positionTarget !== null && drive?.stiffness !== undefined ? drive.stiffness * invI : 0;\n const c = drive?.damping === undefined ? 0 : drive.damping * invI;\n let kLim = 0, cLim = 0, qBound = 0;\n if (j.limits && j.limitStiffness !== null && (j.q < j.limits[0] || j.q > j.limits[1])) {\n qBound = j.q < j.limits[0] ? j.limits[0] : j.limits[1];\n const invILim = 1 / j.inertia;\n kLim = j.limitStiffness * invILim;\n cLim = j.limitDamping * invILim;\n }\n const qStar = j.positionTarget ?? 0;\n let vNext = (j.v + dt * (k * (qStar - j.q) + c * j.velocityTarget + kLim * (qBound - j.q))) /\n (1 + dt * (c + cLim) + dt * dt * (k + kLim));\n if (drive?.maxForce !== undefined) {\n if (!(drive.maxForce >= 0)) {\n throw new KhrValidationError(`Joint \"${j.nodeName}\" has negative drive.maxForce ${drive.maxForce}`);\n }\n const maxAccel = isForce ? drive.maxForce / j.inertia : drive.maxForce;\n const accel = k * (qStar - (j.q + dt * vNext)) + c * (j.velocityTarget - vNext);\n if (Math.abs(accel) > maxAccel) {\n const clamped = Math.sign(accel) * maxAccel;\n vNext = (j.v + dt * (clamped + kLim * (qBound - j.q))) / (1 + dt * cLim + dt * dt * kLim);\n }\n }\n j.v = vNext;\n j.q += vNext * dt;\n if (j.limits && j.limitStiffness === null) {\n if (j.q < j.limits[0]) {\n j.q = j.limits[0];\n if (j.v < 0)\n j.v = 0;\n }\n else if (j.q > j.limits[1]) {\n j.q = j.limits[1];\n if (j.v > 0)\n j.v = 0;\n }\n }\n}\n\nconst JOINT_POSE_EPS = 1e-7;\n\n/** Writes `q` onto the live glTF node and re-poses its compound colliders inside the root body when moved. */\nexport function writeJointPose(j: JointRuntime, frame: number): void {\n if (j.stamp === frame)\n return;\n if (j.parent && j.parent.stamp !== frame)\n writeJointPose(j.parent, frame);\n j.stamp = frame;\n const parentDirty = j.parent !== null && j.parent.dirtyStamp === frame;\n const allCollidersReady = j.colliders.every((c) => c.ref.current !== null);\n if (j.lastWrittenQ === undefined || Math.abs(j.q - j.lastWrittenQ) > JOINT_POSE_EPS || parentDirty) {\n j.dirtyStamp = frame;\n if (allCollidersReady)\n j.lastWrittenQ = j.q;\n if (j.kind === \"revolute\") {\n _qExtra.setFromAxisAngle(j.axis, j.q);\n j.object.quaternion.copy(j.restQuaternion).multiply(_qExtra);\n j.object.position.copy(j.restPosition);\n _deltaMat.makeRotationFromQuaternion(_qExtra);\n }\n else if (j.kind === \"prismatic\") {\n _axis.copy(j.axis).multiplyScalar(j.q);\n j.object.quaternion.copy(j.restQuaternion);\n j.object.position.copy(_axis).applyQuaternion(j.restQuaternion).add(j.restPosition);\n _deltaMat.makeTranslation(_axis.x, _axis.y, _axis.z);\n }\n else {\n _deltaMat.identity();\n }\n if (j.parent)\n j.current.multiplyMatrices(j.parent.current, j.restRelParent);\n else\n j.current.copy(j.restRelParent);\n j.current.multiply(_deltaMat);\n for (const col of j.colliders) {\n const rapierCol = col.ref.current;\n if (rapierCol) {\n _childMat.multiplyMatrices(j.current, col.local).decompose(_tmpPos, _tmpQuat, _tmpScale);\n rapierCol.setTranslationWrtParent(_tmpPos);\n rapierCol.setRotationWrtParent(_tmpQuat);\n }\n }\n }\n}\n","import { createContext } from \"react\";\nimport type * as THREE from \"three\";\nimport type { RapierCollider } from \"@react-three/rapier\";\nimport type { KhrJointDriveSpec, KhrJointSpec } from \"./khrTypes.js\";\n\nexport interface JointCollider {\n ref: {\n current: RapierCollider | null;\n };\n /** Collider pose in the jointed part's local frame (authored KHR collider offset). */\n local: THREE.Matrix4;\n}\n\n/**\n * Runtime state of one articulated glTF node. The node stays in the live scene graph and the\n * root `RigidBody` carries composite authored mass; `PhysicsWorld` integrates `q`.\n */\nexport interface JointRuntime {\n assemblyId: number;\n nodeName: string;\n role: string | null;\n kind: KhrJointSpec[\"kind\"];\n object: THREE.Object3D;\n /** Unit joint axis in the part's local frame. */\n axis: THREE.Vector3;\n restPosition: THREE.Vector3;\n restQuaternion: THREE.Quaternion;\n /** Joint coordinate (rad for revolute, m for prismatic) and its rate. */\n q: number;\n v: number;\n positionTarget: number | null;\n velocityTarget: number;\n drive: KhrJointDriveSpec | null;\n limits: [number, number] | null;\n limitStiffness: number | null;\n limitDamping: number;\n /** Effective inertia about the joint axis (kg*m^2 revolute, kg prismatic). */\n inertia: number;\n parent: JointRuntime | null;\n /** Rest pose relative to the parent joint's frame (or the root body frame when `parent` is null). */\n restRelParent: THREE.Matrix4;\n /** Current pose in the root body frame, rewritten every step. */\n current: THREE.Matrix4;\n /** Frame counter of the last pose write, so parents are always posed before children. */\n stamp: number;\n /** Last `q` written to Rapier colliders (`undefined` until first write) so resting joints skip WASM calls. */\n lastWrittenQ?: number;\n /** Frame counter when this joint's pose changed, so child joints know when an ancestor moved. */\n dirtyStamp?: number;\n colliders: JointCollider[];\n}\n\nexport type JointRegistry = Set<JointRuntime>;\n\n/** Zero-dependency joint registry provided by `<PhysicsWorld>` and populated by `<KhrAssembly>` / `<KhrVehicle>`. */\nexport const JointRegistryContext = createContext<JointRegistry | null>(null);\n\n/** Internal gravity tuple provided by `<PhysicsWorld>` so `<KhrVehicle>` reacts immediately to prop updates. */\nexport const WorldGravityContext = createContext<readonly [number, number, number] | null>(null);\n","import * as THREE from \"three\";\nimport { type KhrBodySpec, type KhrColliderShape, type KhrColliderSpec, KhrValidationError } from \"./khrTypes.js\";\n\nconst SCALE_EPS = 1e-4;\n\nfunction isUnitScalar(v: unknown): boolean {\n return typeof v === \"number\" && Number.isFinite(v) && Math.abs(v - 1) <= 1e-9;\n}\n\nexport function assertUnitScale(scale: unknown, owner: string): void {\n if (scale === undefined) return;\n let ok = false;\n if (typeof scale === \"number\") ok = isUnitScalar(scale);\n else if (Array.isArray(scale)) ok = scale.length === 3 && scale.every(isUnitScalar);\n else if (typeof scale === \"object\" && scale && \"x\" in scale && \"y\" in scale && \"z\" in scale) {\n const v = scale as { x: unknown; y: unknown; z: unknown };\n ok = isUnitScalar(v.x) && isUnitScalar(v.y) && isUnitScalar(v.z);\n }\n if (!ok) throw new KhrValidationError(`${owner}: scale must be 1 (got ${typeof scale === \"number\" && !Number.isFinite(scale) ? String(scale) : JSON.stringify(scale)}); bake scale into the .glb at import`);\n}\n\nexport function readFiniteVec3(val: unknown, fieldLabel: string): [number, number, number] {\n if (!Array.isArray(val) || val.length !== 3 || !val.every((n) => typeof n === \"number\" && Number.isFinite(n))) {\n throw new KhrValidationError(`Invalid ${fieldLabel}: expected finite 3-tuple`);\n }\n return [val[0], val[1], val[2]];\n}\n\nexport function readUnitQuat(val: unknown, fieldLabel: string): [number, number, number, number] {\n if (!Array.isArray(val) || val.length !== 4 || !val.every((n) => typeof n === \"number\" && Number.isFinite(n))) {\n throw new KhrValidationError(`Invalid ${fieldLabel}: expected finite 4-tuple`);\n }\n const norm = Math.hypot(val[0], val[1], val[2], val[3]);\n if (!(norm > 1e-6))\n throw new KhrValidationError(`Invalid ${fieldLabel}: zero-norm quaternion`);\n return [val[0] / norm, val[1] / norm, val[2] / norm, val[3] / norm];\n}\n\nexport function assertIdentityWorldScale(obj: THREE.Object3D, nodeName: string): void {\n const ws = obj.getWorldScale(new THREE.Vector3());\n if (!Number.isFinite(ws.x) || !Number.isFinite(ws.y) || !Number.isFinite(ws.z) ||\n Math.abs(ws.x - 1) > SCALE_EPS || Math.abs(ws.y - 1) > SCALE_EPS || Math.abs(ws.z - 1) > SCALE_EPS) {\n throw new KhrValidationError(`Non-identity world scale [${ws.x.toFixed(4)}, ${ws.y.toFixed(4)}, ${ws.z.toFixed(4)}] on \"${nodeName}\"; bake scale=[1,1,1]`);\n }\n const ls = obj.scale;\n if (!Number.isFinite(ls.x) || !Number.isFinite(ls.y) || !Number.isFinite(ls.z) ||\n Math.abs(ls.x - 1) > SCALE_EPS || Math.abs(ls.y - 1) > SCALE_EPS || Math.abs(ls.z - 1) > SCALE_EPS) {\n throw new KhrValidationError(`Non-identity local scale [${ls.x.toFixed(4)}, ${ls.y.toFixed(4)}, ${ls.z.toFixed(4)}] on \"${nodeName}\"; bake scale=[1,1,1]`);\n }\n}\n\nexport function assertSceneIdentityWorldScale(root: THREE.Object3D): void {\n root.traverse((child) => {\n assertIdentityWorldScale(child, child.name || (child === root ? \"gltf.scene\" : \"unnamed_node\"));\n });\n}\n\nexport function computeRelativePose(ownerObj: THREE.Object3D, childObj: THREE.Object3D): {\n localPosition: [number, number, number];\n localQuaternion: [number, number, number, number];\n} {\n const ownerPos = ownerObj.getWorldPosition(new THREE.Vector3());\n const ownerInvQuat = ownerObj.getWorldQuaternion(new THREE.Quaternion()).invert();\n const pos = childObj.getWorldPosition(new THREE.Vector3()).sub(ownerPos).applyQuaternion(ownerInvQuat);\n const quat = ownerInvQuat.multiply(childObj.getWorldQuaternion(new THREE.Quaternion()));\n return {\n localPosition: [pos.x, pos.y, pos.z],\n localQuaternion: [quat.x, quat.y, quat.z, quat.w],\n };\n}\n\nexport function extractMeshColliderShape(targetObj: THREE.Object3D, meshNodeName: string, convexHull: boolean): KhrColliderShape {\n assertIdentityWorldScale(targetObj, meshNodeName);\n const invOwner = targetObj.matrixWorld.clone().invert();\n const rel = new THREE.Matrix4();\n const v = new THREE.Vector3();\n const verts: number[] = [];\n const indices: number[] = [];\n targetObj.traverse((child) => {\n const mesh = child as THREE.Mesh;\n if (!mesh.isMesh || !mesh.geometry)\n return;\n assertIdentityWorldScale(mesh, mesh.name || meshNodeName);\n const posAttr = mesh.geometry.getAttribute(\"position\");\n if (!posAttr || posAttr.count === 0)\n return;\n rel.multiplyMatrices(invOwner, mesh.matrixWorld);\n const base = verts.length / 3;\n for (let i = 0; i < posAttr.count; i++) {\n v.fromBufferAttribute(posAttr, i).applyMatrix4(rel);\n if (!Number.isFinite(v.x) || !Number.isFinite(v.y) || !Number.isFinite(v.z)) {\n throw new KhrValidationError(`Non-finite vertex in collider mesh \"${meshNodeName}\"`);\n }\n verts.push(v.x, v.y, v.z);\n }\n const idx = mesh.geometry.getIndex();\n if (idx) {\n for (let i = 0; i < idx.count; i++)\n indices.push(base + idx.getX(i));\n }\n else {\n for (let i = 0; i < posAttr.count; i++)\n indices.push(base + i);\n }\n });\n if (verts.length < 9)\n throw new KhrValidationError(`Collider node \"${meshNodeName}\" has fewer than 3 vertices`);\n if (convexHull) {\n return { type: \"convexHull\", vertices: new Float32Array(verts), meshNodeName };\n }\n if (indices.length < 3)\n throw new KhrValidationError(`Trimesh node \"${meshNodeName}\" has fewer than 3 indices`);\n return { type: \"trimesh\", vertices: new Float32Array(verts), indices: new Uint32Array(indices), meshNodeName };\n}\n\nfunction unitInertiaForShape(shape: KhrColliderShape): {\n volume: number;\n centroid: THREE.Vector3;\n unitInertia: [number, number, number];\n} {\n if (shape.type === \"box\") {\n const [x, y, z] = shape.size;\n return {\n volume: x * y * z,\n centroid: new THREE.Vector3(),\n unitInertia: [(y * y + z * z) / 12, (x * x + z * z) / 12, (x * x + y * y) / 12],\n };\n }\n if (shape.type === \"sphere\") {\n const r = shape.radius;\n const i = 0.4 * r * r;\n return {\n volume: (4 / 3) * Math.PI * r * r * r,\n centroid: new THREE.Vector3(),\n unitInertia: [i, i, i],\n };\n }\n if (shape.type === \"convexHull\" || shape.type === \"trimesh\") {\n const box = new THREE.Box3();\n const pt = new THREE.Vector3();\n const verts = shape.vertices;\n for (let i = 0; i < verts.length; i += 3)\n box.expandByPoint(pt.set(verts[i], verts[i + 1], verts[i + 2]));\n const s = box.getSize(new THREE.Vector3());\n return {\n volume: s.x * s.y * s.z,\n centroid: box.getCenter(new THREE.Vector3()),\n unitInertia: [(s.y * s.y + s.z * s.z) / 12, (s.x * s.x + s.z * s.z) / 12, (s.x * s.x + s.y * s.y) / 12],\n };\n }\n const r = shape.radiusTop;\n const h = shape.height;\n if (shape.type === \"capsule\") {\n const cylVol = Math.PI * r * r * h;\n const totVol = cylVol + (4 / 3) * Math.PI * r * r * r;\n const fc = cylVol / totVol;\n const fh = 1 - fc;\n const iy = 0.5 * fc * r * r + 0.4 * fh * r * r;\n const ix = fc * ((h * h) / 12 + 0.25 * r * r) + fh * (0.4 * r * r + 0.25 * h * h + 0.375 * h * r);\n return {\n volume: totVol,\n centroid: new THREE.Vector3(),\n unitInertia: [ix, iy, ix],\n };\n }\n const ix = (3 * r * r + h * h) / 12;\n return {\n volume: Math.PI * r * r * h,\n centroid: new THREE.Vector3(),\n unitInertia: [ix, 0.5 * r * r, ix],\n };\n}\n\nexport function computeShapeInertia(shape: KhrColliderShape, mass: number): [number, number, number] {\n const [ix, iy, iz] = unitInertiaForShape(shape).unitInertia;\n return [mass * ix, mass * iy, mass * iz];\n}\n\nexport function computeBodyInertia(\n colliders: readonly KhrColliderSpec[],\n mass: number,\n centerOfMass: readonly [number, number, number],\n inertiaOrientation: readonly [number, number, number, number],\n nodeName: string,\n): [number, number, number] {\n if (colliders.length === 0) {\n throw new KhrValidationError(`Dynamic node \"${nodeName}\" is missing motion.inertiaDiagonal and has no colliders`);\n }\n const shapes = colliders.map((c) => unitInertiaForShape(c.shape));\n let totalVol = 0;\n for (const s of shapes)\n totalVol += s.volume;\n const invFrame = new THREE.Quaternion().fromArray(inertiaOrientation).invert();\n const com = new THREE.Vector3().fromArray(centerOfMass);\n const colQuat = new THREE.Quaternion();\n const relQuat = new THREE.Quaternion();\n const offset = new THREE.Vector3();\n const rotMat = new THREE.Matrix4();\n const m = rotMat.elements;\n let ix = 0, iy = 0, iz = 0;\n for (let i = 0; i < colliders.length; i++) {\n const col = colliders[i];\n const shp = shapes[i];\n const mShare = totalVol > 0 ? mass * (shp.volume / totalVol) : mass / colliders.length;\n colQuat.fromArray(col.localQuaternion);\n offset.copy(shp.centroid).applyQuaternion(colQuat).add(new THREE.Vector3().fromArray(col.localPosition)).sub(com).applyQuaternion(invFrame);\n relQuat.copy(invFrame).multiply(colQuat);\n rotMat.makeRotationFromQuaternion(relQuat);\n const [u0, u1, u2] = shp.unitInertia;\n const rx = m[0] * m[0] * u0 + m[4] * m[4] * u1 + m[8] * m[8] * u2;\n const ry = m[1] * m[1] * u0 + m[5] * m[5] * u1 + m[9] * m[9] * u2;\n const rz = m[2] * m[2] * u0 + m[6] * m[6] * u1 + m[10] * m[10] * u2;\n ix += mShare * (rx + offset.y * offset.y + offset.z * offset.z);\n iy += mShare * (ry + offset.x * offset.x + offset.z * offset.z);\n iz += mShare * (rz + offset.x * offset.x + offset.y * offset.y);\n }\n if (!Number.isFinite(ix) || !Number.isFinite(iy) || !Number.isFinite(iz) || ix <= 0 || iy <= 0 || iz <= 0) {\n throw new KhrValidationError(`Dynamic node \"${nodeName}\" has degenerate collider geometry; cannot compute positive motion.inertiaDiagonal`);\n }\n return [ix, iy, iz];\n}\n\nexport function computeAssemblyMassAndCom(bodies: readonly KhrBodySpec[]): {\n totalDynamicMass: number;\n centerOfMass: [number, number, number];\n} {\n let totalDynamicMass = 0, mx = 0, my = 0, mz = 0;\n const q = new THREE.Quaternion();\n const c = new THREE.Vector3();\n for (const b of bodies) {\n if (b.isKinematic)\n continue;\n totalDynamicMass += b.mass;\n c.fromArray(b.centerOfMass).applyQuaternion(q.fromArray(b.localQuaternion));\n mx += (b.localPosition[0] + c.x) * b.mass;\n my += (b.localPosition[1] + c.y) * b.mass;\n mz += (b.localPosition[2] + c.z) * b.mass;\n }\n return {\n totalDynamicMass,\n centerOfMass: totalDynamicMass > 0 ? [mx / totalDynamicMass, my / totalDynamicMass, mz / totalDynamicMass] : [0, 0, 0],\n };\n}\n","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>();\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) without re-parsing `.glb` bytes or duplicating\n * GPU `BufferGeometry` / `Material` buffers or 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 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 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\n/**\n * Releases mount ownership on clones without destroying shared template GPU resources.\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 ref?: React.Ref<RapierCollider>;\n}\n\nexport function KhrCollider({ c, position, quaternion, massProperties, 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 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 ...(c.collisionGroups === undefined ? {} : { collisionGroups: c.collisionGroups }),\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 { effectiveJointInertia } from \"./jointDynamics.js\";\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: {\n x: number;\n y: number;\n z: number;\n };\n principalAngularInertia: {\n x: number;\n y: number;\n z: number;\n };\n angularInertiaLocalFrame: {\n x: number;\n y: number;\n z: number;\n w: number;\n };\n}\n\nexport interface PlannedCollider {\n spec: KhrColliderSpec;\n /** Pose in the owning body's local frame. */\n local: THREE.Matrix4;\n /** Rest pose in the root body frame. */\n position: Vec3;\n quaternion: Quat;\n /** Composite mass properties carried by the stationary root's first collider; moving child colliders stay massless. */\n massProperties?: ColliderMass;\n}\n\nexport interface PartPlan {\n spec: KhrBodySpec;\n joint: KhrJointSpec;\n parent: PartPlan | null;\n restRelParent: THREE.Matrix4;\n inertia: number;\n colliders: PlannedCollider[];\n}\n\nexport interface RootPlan {\n spec: KhrBodySpec;\n /** Pose of `bundle.scene` in this root body's local frame (used when `plans.length === 1`). */\n sceneInRootPos: Vec3;\n sceneInRootQuat: Quat;\n /** Disjoint glTF subtree root that rides on this body when `plans.length > 1`. */\n mountNode: THREE.Object3D;\n mountInRoot: THREE.Matrix4;\n mountPosition: Vec3;\n mountQuaternion: Quat;\n /** Composite mass properties in the root RigidBody frame when `colliders` is empty on a dynamic root. */\n rootMass?: ColliderMass;\n colliders: PlannedCollider[];\n /** Parent-first order. */\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)\n 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 for (const candidate of chain(nodes[0])) {\n if (shared.has(candidate))\n return candidate;\n }\n return 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 planBodyColliders(body: KhrBodySpec, relToRoot: THREE.Matrix4, lumped: LumpedMassProps | null): PlannedCollider[] {\n return body.colliders.map((spec, idx) => {\n const colQuat = new THREE.Quaternion().fromArray(spec.localQuaternion);\n const local = new THREE.Matrix4().compose(\n new THREE.Vector3().fromArray(spec.localPosition),\n colQuat,\n new THREE.Vector3(1, 1, 1),\n );\n const pos = new THREE.Vector3();\n const quat = new THREE.Quaternion();\n const scl = new THREE.Vector3();\n new THREE.Matrix4().multiplyMatrices(relToRoot, local).decompose(pos, quat, scl);\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, colQuat);\n }\n return planned;\n });\n}\n\nfunction isJointDescendant(body: KhrBodySpec, ancestorName: string, byName: Map<string, KhrBodySpec>): boolean {\n for (let cur = body.joint ? byName.get(body.joint.connectedNodeName) : undefined; cur; cur = cur.joint ? byName.get(cur.joint.connectedNodeName) : undefined) {\n if (cur.nodeName === ancestorName)\n return true;\n }\n return false;\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\n/** Splits a bundle into one rigid body per jointless root; jointed bodies become articulated compound parts of their root. */\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 invRoot = bodyPoseMatrix(root).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 relToRoot = invRoot.clone().multiply(bodyPoseMatrix(b));\n const plan: PartPlan = {\n spec: b,\n joint,\n parent,\n restRelParent: parent ? bodyPoseMatrix(parent.spec).invert().multiply(bodyPoseMatrix(b)) : relToRoot,\n inertia: effectiveJointInertia(b, joint, descendants.filter((d) => d !== b && isJointDescendant(d, b.nodeName, byName))),\n colliders: planBodyColliders(b, relToRoot, null),\n };\n partByName.set(b.nodeName, plan);\n return plan;\n });\n\n const lumped = root.isKinematic ? null : computeLumpedMassProps([root, ...descendants], invRoot);\n const colliders = planBodyColliders(root, new THREE.Matrix4(), lumped);\n const rootMass = lumped && colliders.length === 0 ? toColliderMass(lumped) : 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();\n const sceneQuat = new THREE.Quaternion();\n const sceneScl = new THREE.Vector3();\n invRoot.decompose(scenePos, sceneQuat, sceneScl);\n sceneQuat.normalize();\n\n const mountPos = new THREE.Vector3();\n const mountQuat = new THREE.Quaternion();\n const mountScl = new THREE.Vector3();\n mountInRoot.decompose(mountPos, mountQuat, mountScl);\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, 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 return () => {\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"],"mappings":";;;;;AAaA,IAAM,OAAO,IAAI,MAAM,QAAQ;AAC/B,IAAM,QAAQ,IAAI,MAAM,WAAW;AACnC,IAAMA,YAAU,IAAI,MAAM,WAAW;AACrC,IAAM,UAAU,IAAI,MAAM,QAAQ;AAClC,IAAM,OAAO,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;AACtC,IAAM,OAAO,IAAI,MAAM,QAA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S,OAAO,UAAU,GAAG,MAAM;CAClD;AACJ;AAEA,SAAgB,gBAAgB,EAAE,QAAQ,SAAuE;CAC7G,MAAM,UAAU,OAA2B,IAAI;CAC/C,sBAAsB;EAClB,MAAM,OAAO,QAAQ;EACrB,IAAI,CAAC,MACD;EACJ,iBAAiB,QAAQ,KAAK;EAC9B,KAAK,IAAI,OAAO,KAAK;EACrB,aAAa;GACT,IAAI,OAAO,MAAM,WAAW,MACxB,KAAK,OAAO,OAAO,KAAK;GAC5B,mBAAmB,MAAM;EAC7B;CACJ,GAAG,CAAC,QAAQ,KAAK,CAAC;CAClB,OAAO,oBAAC,SAAD,EAAO,KAAK,QAAU,CAAA;AACjC;AAEA,SAAgB,iBAAiB,EAC7B,QACA,UACA,YACA,UAMkB;CAClB,MAAM,UAAU,OAA2B,IAAI;CAC/C,sBAAsB;EAClB,MAAM,OAAO,QAAQ;EACrB,IAAI,CAAC,MACD;EACJ,MAAM,OAAO,UAAU,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,MAAM;EACjE,IAAI,KAAK,YACL,KAAK,WAAW,OAAO,MAAM;EACjC,OAAO,SAAS,IAAI,GAAG,GAAG,CAAC;EAC3B,OAAO,WAAW,IAAI,GAAG,GAAG,GAAG,CAAC;EAChC,OAAO,MAAM,IAAI,GAAG,GAAG,CAAC;EACxB,KAAK,IAAI,MAAM;EACf,aAAa;GACT,IAAI,OAAO,WAAW,MAClB,KAAK,OAAO,MAAM;GACtB,qBAAqB,QAAQ,IAAI;EACrC;CACJ,GAAG,CAAC,QAAQ,MAAM,CAAC;CACnB,OAAO,oBAAC,SAAD;EAAO,KAAK;EAAmB;EAAsB;CAAa,CAAA;AAC7E"}
|
package/dist/KhrCollider.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface KhrColliderProps {
|
|
|
7
7
|
/** Pose override in the parent RigidBody frame; defaults to the authored KHR collider offset. */
|
|
8
8
|
position?: [number, number, number];
|
|
9
9
|
quaternion?: [number, number, number, number];
|
|
10
|
-
/** Authored body mass carried by this collider
|
|
10
|
+
/** Authored body mass carried declaratively by this collider (`density: 0` when omitted). */
|
|
11
11
|
massProperties?: ColliderMass;
|
|
12
12
|
ref?: React.Ref<RapierCollider>;
|
|
13
13
|
}
|
package/dist/KhrVehicle.d.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type EcctrlVehicleHandle, type EcctrlVehicleProps } from "@pinkaphant/ecctrl/vehicle";
|
|
3
3
|
import { type KhrAssetBundle, type KhrCarConfig, type KhrDroneConfig } from "./khrTypes.js";
|
|
4
|
-
import { type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export declare const WHEEL_ASSEMBLY_DENSITY_KG_M3 = 220;
|
|
4
|
+
import { type KhrVehicleJointsHandle } from "./khrVehicleJoints.js";
|
|
5
|
+
import { type KhrPropellerConfig, type KhrWheelConfig } from "./khrVehicleRotors.js";
|
|
6
|
+
import { solveWheelLoads, type SolvedWheel } from "./wheelLoads.js";
|
|
7
|
+
export { solveWheelLoads, type KhrPropellerConfig, type KhrVehicleJointsHandle, type KhrWheelConfig, type SolvedWheel, };
|
|
9
8
|
export interface KhrVehicleProps extends Omit<EcctrlVehicleProps, "ref" | "carConfig" | "droneConfig"> {
|
|
10
9
|
ref?: React.Ref<EcctrlVehicleHandle>;
|
|
11
10
|
bundle: KhrAssetBundle;
|
|
12
11
|
vehicleRef?: React.RefObject<EcctrlVehicleHandle | null>;
|
|
12
|
+
jointsRef?: React.Ref<KhrVehicleJointsHandle>;
|
|
13
13
|
carConfig?: Partial<KhrCarConfig>;
|
|
14
14
|
droneConfig?: Partial<KhrDroneConfig>;
|
|
15
15
|
wheelConfig?: KhrWheelConfig;
|
|
16
16
|
frontWheelConfig?: KhrWheelConfig;
|
|
17
17
|
rearWheelConfig?: KhrWheelConfig;
|
|
18
|
-
wheelConfigs?: KhrWheelConfigSelector;
|
|
19
18
|
propellerConfig?: KhrPropellerConfig;
|
|
20
|
-
propellerConfigs?: KhrPropellerConfigSelector;
|
|
21
19
|
}
|
|
22
20
|
export declare function KhrVehicle({ scale, colliders, bundle, ...rest }: KhrVehicleProps): React.JSX.Element;
|
package/dist/PhysicsWorld.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode, type RefObject } from "react";
|
|
1
|
+
import React, { type ReactNode, type RefObject } from "react";
|
|
2
2
|
import { type PhysicsProps } from "@react-three/rapier";
|
|
3
3
|
export type TimeControlValue = number | RefObject<number>;
|
|
4
4
|
export interface PhysicsWorldProps extends Omit<PhysicsProps, "paused" | "timeStep" | "gravity" | "children"> {
|
|
@@ -8,4 +8,4 @@ export interface PhysicsWorldProps extends Omit<PhysicsProps, "paused" | "timeSt
|
|
|
8
8
|
gravity?: [number, number, number];
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
}
|
|
11
|
-
export declare function PhysicsWorld({ paused, timeScale, maxDelta, gravity, children, ...physicsProps }: PhysicsWorldProps):
|
|
11
|
+
export declare function PhysicsWorld({ paused, timeScale, maxDelta, gravity, children, ...physicsProps }: PhysicsWorldProps): React.JSX.Element;
|
package/dist/assemblyPlan.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
|
+
import { type LumpedMassProps } from "./khrMassProps.js";
|
|
2
3
|
import { type KhrAssetBundle, type KhrBodySpec, type KhrColliderSpec, type KhrJointSpec } from "./khrTypes.js";
|
|
3
4
|
type Vec3 = [number, number, number];
|
|
4
5
|
type Quat = [number, number, number, number];
|
|
@@ -55,6 +56,7 @@ export interface RootPlan {
|
|
|
55
56
|
/** Parent-first order. */
|
|
56
57
|
parts: PartPlan[];
|
|
57
58
|
}
|
|
59
|
+
export declare function toColliderMass(lumped: LumpedMassProps, colMat?: THREE.Matrix4, colQuat?: THREE.Quaternion): ColliderMass;
|
|
58
60
|
/** Splits a bundle into one rigid body per jointless root; jointed bodies become articulated compound parts of their root. */
|
|
59
61
|
export declare function planAssembly(bundle: KhrAssetBundle): RootPlan[];
|
|
60
62
|
export {};
|
package/dist/curves.d.ts
CHANGED
|
@@ -97,13 +97,13 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
97
97
|
readonly x: 0.95;
|
|
98
98
|
readonly y: 0.962;
|
|
99
99
|
readonly r_in: -0.68;
|
|
100
|
-
readonly r_out: -
|
|
100
|
+
readonly r_out: -0.68;
|
|
101
101
|
readonly w_in: 1;
|
|
102
102
|
readonly w_out: 1;
|
|
103
103
|
}, {
|
|
104
104
|
readonly x: 1;
|
|
105
|
-
readonly y: 0;
|
|
106
|
-
readonly r_in:
|
|
105
|
+
readonly y: 0.82;
|
|
106
|
+
readonly r_in: -1.32;
|
|
107
107
|
readonly w_in: 1;
|
|
108
108
|
}];
|
|
109
109
|
};
|
|
@@ -142,17 +142,10 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
142
142
|
readonly r_out: -0.66;
|
|
143
143
|
readonly w_in: 1;
|
|
144
144
|
readonly w_out: 1;
|
|
145
|
-
}, {
|
|
146
|
-
readonly x: 0.96;
|
|
147
|
-
readonly y: 0.86;
|
|
148
|
-
readonly r_in: -1.05;
|
|
149
|
-
readonly r_out: -1.45;
|
|
150
|
-
readonly w_in: 1;
|
|
151
|
-
readonly w_out: 1;
|
|
152
145
|
}, {
|
|
153
146
|
readonly x: 1;
|
|
154
|
-
readonly y: 0;
|
|
155
|
-
readonly r_in:
|
|
147
|
+
readonly y: 0.8;
|
|
148
|
+
readonly r_in: -1.12;
|
|
156
149
|
readonly w_in: 1;
|
|
157
150
|
}];
|
|
158
151
|
};
|
|
@@ -191,17 +184,10 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
191
184
|
readonly r_out: -0.92;
|
|
192
185
|
readonly w_in: 1;
|
|
193
186
|
readonly w_out: 1;
|
|
194
|
-
}, {
|
|
195
|
-
readonly x: 0.94;
|
|
196
|
-
readonly y: 0.36;
|
|
197
|
-
readonly r_in: -1.02;
|
|
198
|
-
readonly r_out: -1.35;
|
|
199
|
-
readonly w_in: 1;
|
|
200
|
-
readonly w_out: 1;
|
|
201
187
|
}, {
|
|
202
188
|
readonly x: 1;
|
|
203
|
-
readonly y: 0;
|
|
204
|
-
readonly r_in:
|
|
189
|
+
readonly y: 0.28;
|
|
190
|
+
readonly r_in: -1.08;
|
|
205
191
|
readonly w_in: 1;
|
|
206
192
|
}];
|
|
207
193
|
};
|
|
@@ -240,17 +226,10 @@ export declare const ENGINE_TORQUE_CURVES: {
|
|
|
240
226
|
readonly r_out: -0.4842;
|
|
241
227
|
readonly w_in: 1;
|
|
242
228
|
readonly w_out: 1;
|
|
243
|
-
}, {
|
|
244
|
-
readonly x: 0.95;
|
|
245
|
-
readonly y: 0.3368;
|
|
246
|
-
readonly r_in: -0.3408;
|
|
247
|
-
readonly r_out: -1.35;
|
|
248
|
-
readonly w_in: 1;
|
|
249
|
-
readonly w_out: 1;
|
|
250
229
|
}, {
|
|
251
230
|
readonly x: 1;
|
|
252
|
-
readonly y: 0;
|
|
253
|
-
readonly r_in: 0;
|
|
231
|
+
readonly y: 0.32;
|
|
232
|
+
readonly r_in: -0.3097;
|
|
254
233
|
readonly w_in: 1;
|
|
255
234
|
}];
|
|
256
235
|
};
|
|
@@ -344,14 +323,14 @@ export declare const STEER_SPEED_CURVES: {
|
|
|
344
323
|
readonly x: 0.2;
|
|
345
324
|
readonly y: 0.28;
|
|
346
325
|
readonly r_in: -1.1;
|
|
347
|
-
readonly r_out: -
|
|
326
|
+
readonly r_out: -1.1;
|
|
348
327
|
readonly w_in: 1;
|
|
349
328
|
readonly w_out: 1;
|
|
350
329
|
}, {
|
|
351
330
|
readonly x: 0.5;
|
|
352
331
|
readonly y: 0.11;
|
|
353
332
|
readonly r_in: -0.25;
|
|
354
|
-
readonly r_out: -0.
|
|
333
|
+
readonly r_out: -0.25;
|
|
355
334
|
readonly w_in: 1;
|
|
356
335
|
readonly w_out: 1;
|
|
357
336
|
}, {
|