@pinkaphant/kolmo 0.4.2 → 0.4.5
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 +60 -6
- package/bin/kolmo.mjs +455 -15
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +8 -5
- package/dist/engine/kolmoActions.js +24 -9
- package/dist/engine/kolmoActions.js.map +1 -1
- package/dist/engine/kolmoActor.js +19 -31
- package/dist/engine/kolmoActor.js.map +1 -1
- package/dist/engine/kolmoActorHelpers.d.ts +24 -0
- package/dist/engine/kolmoActorHelpers.js +64 -0
- package/dist/engine/kolmoActorHelpers.js.map +1 -0
- package/dist/engine/kolmoGame.js +4 -1
- package/dist/engine/kolmoGame.js.map +1 -1
- package/dist/engine/kolmoHud.js +34 -15
- package/dist/engine/kolmoHud.js.map +1 -1
- package/dist/engine/kolmoInput.d.ts +3 -1
- package/dist/engine/kolmoInput.js +18 -12
- package/dist/engine/kolmoInput.js.map +1 -1
- package/dist/engine/kolmoLongDrive.d.ts +1 -1
- package/dist/engine/kolmoLongDrive.js +10 -8
- package/dist/engine/kolmoLongDrive.js.map +1 -1
- package/dist/engine/kolmoPilotMesh.js +189 -48
- package/dist/engine/kolmoPilotMesh.js.map +1 -1
- package/dist/engine/kolmoStore.js +4 -0
- package/dist/engine/kolmoStore.js.map +1 -0
- package/dist/engine/kolmoTouchOverlay.d.ts +21 -0
- package/dist/engine/kolmoTouchOverlay.js +326 -0
- package/dist/engine/kolmoTouchOverlay.js.map +1 -0
- package/dist/engine/kolmoTouchState.d.ts +50 -0
- package/dist/engine/kolmoTouchState.js +210 -0
- package/dist/engine/kolmoTouchState.js.map +1 -0
- package/dist/engine/kolmoVehicle.js +30 -27
- package/dist/engine/kolmoVehicle.js.map +1 -1
- package/dist/engine/kolmoVehicleAutoCompile.d.ts +10 -0
- package/dist/engine/kolmoVehicleAutoCompile.js +78 -0
- package/dist/engine/kolmoVehicleAutoCompile.js.map +1 -0
- package/dist/engine/kolmoVehicleConfig.d.ts +2 -0
- package/dist/engine/kolmoVehicleConfig.js +8 -4
- package/dist/engine/kolmoVehicleConfig.js.map +1 -1
- package/dist/engine/kolmoVehicleDriver.d.ts +5 -0
- package/dist/engine/kolmoVehicleDriver.js +18 -11
- package/dist/engine/kolmoVehicleDriver.js.map +1 -1
- package/dist/engine/kolmoVehicleInner.js +49 -19
- package/dist/engine/kolmoVehicleInner.js.map +1 -1
- package/dist/engine/kolmoWorld.js +6 -2
- package/dist/engine/kolmoWorld.js.map +1 -1
- package/dist/engine/longDriveKit.d.ts +6 -1
- package/dist/engine/longDriveKit.js +8 -5
- package/dist/engine/longDriveKit.js.map +1 -1
- package/dist/engine/macroCellBuilder.d.ts +10 -0
- package/dist/engine/macroCellBuilder.js +101 -18
- package/dist/engine/macroCellBuilder.js.map +1 -1
- package/dist/engine/mainlandMacroCell.js +18 -9
- package/dist/engine/mainlandMacroCell.js.map +1 -1
- package/dist/importer/DomainWorkshopPanel.d.ts +3 -3
- package/dist/importer/DomainWorkshopPanel.js +148 -44
- package/dist/importer/DomainWorkshopPanel.js.map +1 -1
- package/dist/importer/GateHudBar.d.ts +2 -0
- package/dist/importer/GateHudBar.js +113 -35
- package/dist/importer/GateHudBar.js.map +1 -1
- package/dist/importer/GlbImportGate.js +16 -3
- package/dist/importer/GlbImportGate.js.map +1 -1
- package/dist/importer/LiveDrivePads.js +5 -3
- package/dist/importer/LiveDrivePads.js.map +1 -1
- package/dist/importer/Step1CalibrationPlinth.js +3 -3
- package/dist/importer/WheelRingHandles3D.js +2 -1
- package/dist/importer/WheelRingHandles3D.js.map +1 -1
- package/dist/importer/chopShopActions.js +22 -18
- package/dist/importer/chopShopActions.js.map +1 -1
- package/dist/importer/chopShopHandlers.js +17 -10
- package/dist/importer/chopShopHandlers.js.map +1 -1
- package/dist/importer/chopShopIoActions.d.ts +2 -0
- package/dist/importer/chopShopIoActions.js +33 -2
- package/dist/importer/chopShopIoActions.js.map +1 -1
- package/dist/importer/cylinderBooleanSlice.js.map +1 -1
- package/dist/importer/fusedWheelDetect.d.ts +2 -2
- package/dist/importer/fusedWheelDetect.js +227 -106
- package/dist/importer/fusedWheelDetect.js.map +1 -1
- package/dist/importer/fusedWheelFit.d.ts +6 -0
- package/dist/importer/fusedWheelFit.js +82 -1
- package/dist/importer/fusedWheelFit.js.map +1 -1
- package/dist/importer/gateStore.d.ts +2 -2
- package/dist/importer/gateStore.js +4 -3
- package/dist/importer/gateStore.js.map +1 -1
- package/dist/importer/glbNormalizer.js +5 -0
- package/dist/importer/glbNormalizer.js.map +1 -1
- package/dist/importer/importerWebMcpTools.js +3 -2
- package/dist/importer/importerWebMcpTools.js.map +1 -1
- package/dist/importer/index.d.ts +4 -2
- package/dist/importer/index.js +16 -12
- package/dist/importer/khrCarGeometryMass.d.ts +20 -0
- package/dist/importer/khrCarGeometryMass.js +125 -0
- package/dist/importer/khrCarGeometryMass.js.map +1 -0
- package/dist/importer/khrCarPlanHelpers.js +13 -23
- package/dist/importer/khrCarPlanHelpers.js.map +1 -1
- package/dist/importer/khrCarPlanner.js +52 -85
- package/dist/importer/khrCarPlanner.js.map +1 -1
- package/dist/importer/khrCompiler.js +1 -1
- package/dist/importer/launcherBake.js +4 -2
- package/dist/importer/launcherBake.js.map +1 -1
- package/dist/importer/launcherCadGeometry.d.ts +22 -0
- package/dist/importer/launcherCadGeometry.js +185 -0
- package/dist/importer/launcherCadGeometry.js.map +1 -0
- package/dist/importer/proceduralC12AndCraft.d.ts +18 -0
- package/dist/importer/proceduralC12AndCraft.js +302 -0
- package/dist/importer/proceduralC12AndCraft.js.map +1 -0
- package/dist/importer/proceduralDomainBuilders.d.ts +10 -0
- package/dist/importer/proceduralDomainBuilders.js +346 -0
- package/dist/importer/proceduralDomainBuilders.js.map +1 -0
- package/dist/importer/proceduralPersonAndProp.d.ts +8 -0
- package/dist/importer/proceduralPersonAndProp.js +303 -0
- package/dist/importer/proceduralPersonAndProp.js.map +1 -0
- package/dist/importer/starterScene.d.ts +3 -1
- package/dist/importer/starterScene.js +76 -13
- package/dist/importer/starterScene.js.map +1 -1
- package/dist/importer/universalGateBake.js +43 -11
- package/dist/importer/universalGateBake.js.map +1 -1
- package/dist/importer/useChopShopController.d.ts +3 -1
- package/dist/importer/useChopShopController.js +33 -18
- package/dist/importer/useChopShopController.js.map +1 -1
- package/dist/importer/useChopShopState.d.ts +1 -1
- package/dist/importer/useChopShopState.js +35 -9
- package/dist/importer/useChopShopState.js.map +1 -1
- package/dist/importer/wheelCutterHelpers.d.ts +7 -4
- package/dist/importer/wheelCutterHelpers.js +58 -28
- package/dist/importer/wheelCutterHelpers.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +34 -20
- package/dist/junk/DestructibleTarget.js +9 -3
- package/dist/junk/DestructibleTarget.js.map +1 -1
- package/dist/junk/ShardPieces.js +10 -2
- package/dist/junk/ShardPieces.js.map +1 -1
- package/dist/junk/index.d.ts +1 -0
- package/dist/junk/index.js +2 -1
- package/dist/junk/junkProceduralScenes.d.ts +12 -0
- package/dist/junk/junkProceduralScenes.js +220 -0
- package/dist/junk/junkProceduralScenes.js.map +1 -0
- package/dist/junk/junkTypes.js +0 -0
- package/dist/junk/junkTypes.js.map +1 -0
- package/dist/sand3d/KolmoSand3D.d.ts +19 -0
- package/dist/sand3d/KolmoSand3D.js +92 -0
- package/dist/sand3d/KolmoSand3D.js.map +1 -0
- package/dist/sand3d/Sand3dWorkshopSection.d.ts +8 -0
- package/dist/sand3d/Sand3dWorkshopSection.js +117 -0
- package/dist/sand3d/Sand3dWorkshopSection.js.map +1 -0
- package/dist/sand3d/gateBakeHelpers.d.ts +21 -0
- package/dist/sand3d/gateBakeHelpers.js +225 -0
- package/dist/sand3d/gateBakeHelpers.js.map +1 -0
- package/dist/sand3d/gateDoorwayBake.d.ts +12 -0
- package/dist/sand3d/gateDoorwayBake.js +203 -0
- package/dist/sand3d/gateDoorwayBake.js.map +1 -0
- package/dist/sand3d/index.d.ts +3 -0
- package/dist/sand3d/index.js +4 -0
- package/dist/sand3d/index.js.map +1 -0
- package/dist/sand3d/sand3dAssetLoader.d.ts +28 -0
- package/dist/sand3d/sand3dAssetLoader.js +177 -0
- package/dist/sand3d/sand3dAssetLoader.js.map +1 -0
- package/dist/suika/KolmoSuikaOrb.d.ts +33 -0
- package/dist/suika/KolmoSuikaOrb.js +375 -0
- package/dist/suika/KolmoSuikaOrb.js.map +1 -0
- package/dist/suika/index.d.ts +4 -0
- package/dist/suika/index.js +5 -0
- package/dist/suika/index.js.map +1 -0
- package/dist/suika/suikaArbiter.d.ts +60 -0
- package/dist/suika/suikaArbiter.js +265 -0
- package/dist/suika/suikaArbiter.js.map +1 -0
- package/dist/suika/suikaGeometry.d.ts +10 -0
- package/dist/suika/suikaGeometry.js +251 -0
- package/dist/suika/suikaGeometry.js.map +1 -0
- package/dist/suika/suikaTypes.d.ts +74 -0
- package/dist/suika/suikaTypes.js +196 -0
- package/dist/suika/suikaTypes.js.map +1 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +2 -2
- package/dist/world/worldTypes.d.ts +4 -0
- package/dist/world/worldTypes.js +21 -1
- package/dist/world/worldTypes.js.map +1 -1
- package/docs/api-reference.md +82 -124
- package/package.json +16 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateStore.js","names":[],"sources":["../../src/importer/gateStore.ts"],"sourcesContent":["import { create } from \"zustand\";\nimport { ALL_PANELS_ATTACHED_MASK, type PaperShellPresetId, type ShadingMode, type ShellPartId } from \"@khr3/vehicles/paper-shell\";\nimport type { CarDriveMode } from \"./khrCompiler.js\";\n\nexport type GateStep = 1 | 2;\nexport type GateDomain = \"vehicle\" | \"c12\" | \"launcher\" | \"person\" | \"prop\" | \"junk\";\nexport type VehicleSubArchetype = \"car\" | \"craft\";\nexport type EraMode = \"dreamcast-60\" | \"psx-1-3\";\nexport type FreqBucket = \"TRUCK\" | \"STREET\" | \"SPORT\";\nexport type DampBucket = \"PLUSH\" | \"BALANCED\" | \"STIFF\";\nexport type WrenchMode = \"UNLATCH_200\" | \"RIP_1800\";\n\nexport const FREQ_HZ: Readonly<Record<FreqBucket, number>> = Object.freeze({\n TRUCK: 1.4,\n STREET: 1.9,\n SPORT: 2.8,\n});\n\nexport const DAMP_ZETA: Readonly<Record<DampBucket, number>> = Object.freeze({\n PLUSH: 0.65,\n BALANCED: 0.75,\n STIFF: 0.85,\n});\n\nexport interface CalibrationMetrics {\n readonly wheelbase: number;\n readonly trackWidth: number;\n readonly wheelRadii: readonly [number, number, number, number];\n readonly minY: number;\n readonly aabbSize: readonly [number, number, number];\n readonly c12Ticks: readonly [number, number, number];\n readonly c12Aligned: boolean;\n readonly detectedAnchors: readonly string[];\n readonly isSingleMeshProxy: boolean;\n}\n\nexport interface DetachedDebrisItem {\n readonly id: string;\n readonly partId: ShellPartId;\n readonly massKg: number;\n readonly position: [number, number, number];\n readonly quaternion: [number, number, number, number];\n readonly linvel: [number, number, number];\n readonly angvel: [number, number, number];\n readonly aabbSize: [number, number, number];\n readonly colorHex: number;\n}\n\n/** Mutable
|
|
1
|
+
{"version":3,"file":"gateStore.js","names":[],"sources":["../../src/importer/gateStore.ts"],"sourcesContent":["import { create } from \"zustand\";\nimport { ALL_PANELS_ATTACHED_MASK, type PaperShellPresetId, type ShadingMode, type ShellPartId } from \"@khr3/vehicles/paper-shell\";\nimport type { CarDriveMode } from \"./khrCompiler.js\";\n\nexport type GateStep = 1 | 2;\nexport type GateDomain = \"vehicle\" | \"c12\" | \"launcher\" | \"person\" | \"prop\" | \"junk\" | \"suika\" | \"sand3d\";\nexport type VehicleSubArchetype = \"car\" | \"craft\";\nexport type EraMode = \"dreamcast-60\" | \"psx-1-3\";\nexport type FreqBucket = \"TRUCK\" | \"STREET\" | \"SPORT\";\nexport type DampBucket = \"PLUSH\" | \"BALANCED\" | \"STIFF\";\nexport type WrenchMode = \"UNLATCH_200\" | \"RIP_1800\";\n\nexport const FREQ_HZ: Readonly<Record<FreqBucket, number>> = Object.freeze({\n TRUCK: 1.4,\n STREET: 1.9,\n SPORT: 2.8,\n});\n\nexport const DAMP_ZETA: Readonly<Record<DampBucket, number>> = Object.freeze({\n PLUSH: 0.65,\n BALANCED: 0.75,\n STIFF: 0.85,\n});\n\nexport interface CalibrationMetrics {\n readonly wheelbase: number;\n readonly trackWidth: number;\n readonly wheelRadii: readonly [number, number, number, number];\n readonly minY: number;\n readonly aabbSize: readonly [number, number, number];\n readonly c12Ticks: readonly [number, number, number];\n readonly c12Aligned: boolean;\n readonly detectedAnchors: readonly string[];\n readonly isSingleMeshProxy: boolean;\n}\n\nexport interface DetachedDebrisItem {\n readonly id: string;\n readonly partId: ShellPartId;\n readonly massKg: number;\n readonly position: [number, number, number];\n readonly quaternion: [number, number, number, number];\n readonly linvel: [number, number, number];\n readonly angvel: [number, number, number];\n readonly aabbSize: [number, number, number];\n readonly colorHex: number;\n}\n\n/** Mutable 60 Hz telemetry structure updated inside Rapier and useFrame callbacks. */\nexport const gateTelemetry = {\n massKg: 780,\n com: [0, 0.42, 0.08] as [number, number, number],\n frontSplit: 0.53,\n cornerK: [28500, 26200] as [number, number],\n speedKmh: 0,\n rpm: 850,\n sparkBurst: null as [number, number, number] | null,\n massDirty: true,\n};\n\nexport function isGateStep1Unlocked(\n cal: CalibrationMetrics,\n domain: GateDomain,\n vehicleArchetype: VehicleSubArchetype,\n usePaperShellProxy: boolean,\n): boolean {\n const [sx, sy, sz] = cal.aabbSize;\n const minDim = domain === \"sand3d\" ? 0.004 : 0.04;\n const validSize = sx >= minDim && sy >= minDim && sz >= minDim && Math.max(sx, sy, sz) <= 120;\n const grounded = domain === \"sand3d\" ? Math.abs(cal.minY) <= 0.25 : Math.abs(cal.minY) <= 0.005;\n if (!validSize || !grounded)\n return false;\n if (domain === \"c12\")\n return cal.c12Aligned;\n if (domain === \"vehicle\" && (usePaperShellProxy || vehicleArchetype === \"car\")) {\n const validWheelbase = cal.wheelbase >= 1.2 && cal.wheelbase <= 5.6;\n const validRadii = cal.wheelRadii.every((r) => r >= 0.16 && r <= 0.65);\n return validWheelbase && validRadii;\n }\n return true;\n}\n\nexport interface GateState {\n step: GateStep;\n domain: GateDomain;\n vehicleArchetype: VehicleSubArchetype;\n usePaperShellProxy: boolean;\n presetId: PaperShellPresetId;\n shadingMode: ShadingMode;\n eraMode: EraMode;\n freqBucket: FreqBucket;\n dampBucket: DampBucket;\n wrenchMode: WrenchMode;\n driveType: CarDriveMode;\n staticProp: boolean;\n massKg: number;\n powerOrThrust: number;\n attachedMask: number;\n unlatchedMask: number;\n fuelLiters: number;\n dropTrigger: number;\n chaseCam: boolean;\n detachedDebris: readonly DetachedDebrisItem[];\n calibration: CalibrationMetrics;\n setField: <K extends keyof GateState>(key: K, value: GateState[K]) => void;\n setCalibration: (cal: CalibrationMetrics) => void;\n triggerDrop: () => void;\n resetAllPanels: () => void;\n}\n\nexport const useGateStore = create<GateState>((set) => ({\n step: 1,\n domain: \"vehicle\",\n vehicleArchetype: \"car\",\n usePaperShellProxy: false,\n presetId: \"coupe_86\",\n shadingMode: \"psx-flat\",\n eraMode: \"dreamcast-60\",\n freqBucket: \"STREET\",\n dampBucket: \"BALANCED\",\n wrenchMode: \"UNLATCH_200\",\n driveType: \"AWD\",\n staticProp: false,\n massKg: 1380,\n powerOrThrust: 240,\n attachedMask: ALL_PANELS_ATTACHED_MASK,\n unlatchedMask: 0,\n fuelLiters: 42,\n dropTrigger: 0,\n chaseCam: true,\n detachedDebris: [],\n calibration: {\n wheelbase: 2.4,\n trackWidth: 1.36,\n wheelRadii: [0.31, 0.31, 0.31, 0.31],\n minY: 0,\n aabbSize: [1.62, 1.28, 4.18],\n c12Ticks: [19, 15, 50],\n c12Aligned: false,\n detectedAnchors: [],\n isSingleMeshProxy: false,\n },\n setField: (key, value) => set({ [key]: value } as Partial<GateState>),\n setCalibration: (calibration) => set({ calibration }),\n triggerDrop: () => set((s) => ({ dropTrigger: s.dropTrigger + 1 })),\n resetAllPanels: () =>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eAAe;CACf,YAAY;CACZ,aAAa;CACb,UAAU;CACV,gBAAgB,CAAC;CACjB,aAAa;EACT,WAAW;EACX,YAAY;EACZ,YAAY;GAAC;GAAM;GAAM;GAAM;EAAI;EACnC,MAAM;EACN,UAAU;GAAC;GAAM;GAAM;EAAI;EAC3B,UAAU;GAAC;GAAI;GAAI;EAAE;EACrB,YAAY;EACZ,iBAAiB,CAAC;EAClB,mBAAmB;CACvB;CACA,WAAW,KAAK,UAAU,IAAI,GAAG,MAAM,MAAM,CAAuB;CACpE,iBAAiB,gBAAgB,IAAI,EAAE,YAAY,CAAC;CACpD,mBAAmB,KAAK,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,EAAE;CAClE,sBAAsB;EAClB,cAAc,YAAY;EAC1B,IAAI;GAAE,cAAc;GAA0B,eAAe;GAAG,gBAAgB,CAAC;EAAE,CAAC;CACxF;AACJ,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"glbNormalizer.js","names":[],"sources":["../../src/importer/glbNormalizer.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { buildPaperShellAssembly, type PaperShellAssembly, type PaperShellPresetId, type ShadingMode } from \"@khr3/vehicles/paper-shell\";\nimport { useGateStore, type CalibrationMetrics, type GateDomain, type VehicleSubArchetype } from \"./gateStore.js\";\n\nexport const C12_TICK_M = 1 / 12;\n\nexport const UNIFIED_ANCHOR_NAMES: readonly string[] = Object.freeze([\n \"IK_Palm_Primary\",\n \"IK_Index_Trigger\",\n \"IK_Thumb_Safety\",\n \"IK_Palm_Forend\",\n \"Socket_Muzzle\",\n \"Socket_Eject\",\n \"Socket_HitStart\",\n \"Socket_HitEnd\",\n \"Socket_Tip\",\n \"Socket_Holster\",\n \"Socket_Seat\",\n \"Socket_Optic\",\n]);\n\nconst _box = new THREE.Box3();\nconst _size = new THREE.Vector3();\n\n/** Convert KHR_implicit_shapes box.size (FULL [w, h, d] in meters) to Rapier CuboidCollider half-extents. */\nexport function khrBoxToRapierHalfExtents(fullSize: readonly [number, number, number]): [number, number, number] {\n return [fullSize[0] * 0.5, fullSize[1] * 0.5, fullSize[2] * 0.5];\n}\n\nexport function snapMetersToC12(meters: number): number {\n return Number((Math.max(1, Math.round(meters * 12)) / 12).toFixed(6));\n}\n\nexport function computeC12Metrics(size: readonly [number, number, number]): {\n c12Ticks: [number, number, number];\n c12Aligned: boolean;\n} {\n const c12Ticks: [number, number, number] = [\n Math.round(size[0] * 12),\n Math.round(size[1] * 12),\n Math.round(size[2] * 12),\n ];\n const c12Aligned =\n c12Ticks.every((t) => t >= 1) &&\n Math.abs(size[0] * 12 - c12Ticks[0]) <= 0.06 &&\n Math.abs(size[1] * 12 - c12Ticks[1]) <= 0.06 &&\n Math.abs(size[2] * 12 - c12Ticks[2]) <= 0.06;\n return { c12Ticks, c12Aligned };\n}\n\nexport function detectSceneAnchors(root: THREE.Object3D | null): string[] {\n if (!root)\n return [];\n const found = new Set<string>();\n root.traverse((obj) => {\n if (\n obj.name &&\n (UNIFIED_ANCHOR_NAMES.includes(obj.name) ||\n obj.name.startsWith(\"IK_\") ||\n obj.name.startsWith(\"Socket_\") ||\n obj.name.startsWith(\"Kolmo_\"))\n ) {\n found.add(obj.name);\n }\n });\n return [...found];\n}\n\nexport function defaultTargetMeters(\n domain: GateDomain,\n sub: VehicleSubArchetype,\n): { len: number; massKg: number; power: number } {\n if (domain === \"c12\") return { len: 3, massKg: 0, power: 0 };\n if (domain === \"person\") return { len: 1.75, massKg: 72, power: 0 };\n if (domain === \"launcher\") return { len: 0.92, massKg: 4.2, power: 120 };\n if (domain === \"junk\") return { len: 0.85, massKg: 18, power: 0 };\n if (domain === \"prop\") return { len: 1.5, massKg: 85, power: 0 };\n if (sub === \"craft\") return { len: 7.2, massKg: 680, power: 4500 };\n return { len: 4.35, massKg: 1380, power: 260 };\n}\n\nexport function measureAssemblyCalibration(\n assembly: PaperShellAssembly,\n scaleFactor = 1,\n yOffset = 0,\n isProxy = false,\n importedRoot: THREE.Object3D | null = null,\n): CalibrationMetrics {\n const preset = assembly.lattice.preset;\n const wheelbase = preset.wheelbase * scaleFactor;\n const trackWidth = preset.trackWidth * scaleFactor;\n const r = Number((preset.wheelRadius * scaleFactor).toFixed(3));\n const len = (assembly.lattice.rings[assembly.lattice.rings.length - 1].z - assembly.lattice.rings[0].z) * scaleFactor;\n const aabbSize: [number, number, number] = [\n Number((preset.halfWidth * 2 * scaleFactor).toFixed(3)),\n Number((preset.roofY * scaleFactor).toFixed(3)),\n Number(len.toFixed(3)),\n ];\n const { c12Ticks, c12Aligned } = computeC12Metrics(aabbSize);\n const cal: CalibrationMetrics = {\n wheelbase: Number(wheelbase.toFixed(3)),\n trackWidth: Number(trackWidth.toFixed(3)),\n wheelRadii: [r, r, r, r],\n minY: Number(yOffset.toFixed(4)),\n aabbSize,\n c12Ticks,\n c12Aligned,\n detectedAnchors: detectSceneAnchors(importedRoot),\n isSingleMeshProxy: isProxy,\n };\n useGateStore.getState().setCalibration(cal);\n return cal;\n}\n\nexport function measureNormalizedSceneCalibration(scene: THREE.Object3D, yOffset = 0): CalibrationMetrics {\n scene.updateMatrixWorld(true);\n _box.setFromObject(scene);\n if (_box.isEmpty())\n _size.set(1, 1, 1);\n else\n _box.getSize(_size);\n const aabbSize: [number, number, number] = [\n Number(_size.x.toFixed(3)),\n Number(_size.y.toFixed(3)),\n Number(_size.z.toFixed(3)),\n ];\n const wheelbase = Number(Math.max(1.25, _size.z * 0.62).toFixed(3));\n const trackWidth = Number(Math.max(0.4, _size.x * 0.82).toFixed(3));\n const wheelR = Number(Math.max(0.2, Math.min(0.45, _size.y * 0.24)).toFixed(3));\n const { c12Ticks, c12Aligned } = computeC12Metrics(aabbSize);\n const cal: CalibrationMetrics = {\n wheelbase,\n trackWidth,\n wheelRadii: [wheelR, wheelR, wheelR, wheelR],\n minY: Number(((_box.isEmpty() ? 0 : _box.min.y) + yOffset).toFixed(4)),\n aabbSize,\n c12Ticks,\n c12Aligned,\n detectedAnchors: detectSceneAnchors(scene),\n isSingleMeshProxy: false,\n };\n useGateStore.getState().setCalibration(cal);\n return cal;\n}\n\n/** Wrap an unsegmented single-mesh GLB import with a synchronized C0 paper-shell collider + breakaway lattice. */\nexport function wrapSingleMeshWithPaperShellProxy(\n importedRoot: THREE.Object3D | null,\n fallbackPreset: PaperShellPresetId = \"coupe_86\",\n shadingMode: ShadingMode = \"psx-flat\",\n): PaperShellAssembly {\n const assembly = buildPaperShellAssembly(fallbackPreset, shadingMode);\n if (!importedRoot) {\n measureAssemblyCalibration(assembly, 1, 0, true, null);\n return assembly;\n }\n _box.setFromObject(importedRoot);\n if (_box.isEmpty()) {\n measureAssemblyCalibration(assembly, 1, 0, true, importedRoot);\n return assembly;\n }\n _box.getSize(_size);\n const refLen = assembly.lattice.rings[assembly.lattice.rings.length - 1].z - assembly.lattice.rings[0].z;\n const scaleFactor = _size.z > 0.2 ? Math.max(0.5, Math.min(2, _size.z / refLen)) : 1;\n measureAssemblyCalibration(assembly, scaleFactor, 0, true, importedRoot);\n return assembly;\n}\n"],"mappings":";;;;AAIA,IAAa,aAAa,IAAI;AAE9B,IAAa,uBAA0C,OAAO,OAAO;CACjE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,IAAM,OAAO,IAAI,MAAM,KAAK;AAC5B,IAAM,QAAQ,IAAI,MAAM,QAAQ;;AAGhC,SAAgB,0BAA0B,UAAuE;CAC7G,OAAO;EAAC,SAAS,KAAK;EAAK,SAAS,KAAK;EAAK,SAAS,KAAK;CAAG;AACnE;AAEA,SAAgB,gBAAgB,QAAwB;CACpD,OAAO,QAAQ,KAAK,IAAI,GAAG,KAAK,MAAM,SAAS,EAAE,CAAC,IAAI,GAAA,CAAI,QAAQ,CAAC,CAAC;AACxE;AAEA,SAAgB,kBAAkB,MAGhC;CACE,MAAM,WAAqC;EACvC,KAAK,MAAM,KAAK,KAAK,EAAE;EACvB,KAAK,MAAM,KAAK,KAAK,EA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ent":["import * as THREE from \"three\";\nimport { buildPaperShellAssembly, type PaperShellAssembly, type PaperShellPresetId, type ShadingMode } from \"@khr3/vehicles/paper-shell\";\nimport { useGateStore, type CalibrationMetrics, type GateDomain, type VehicleSubArchetype } from \"./gateStore.js\";\n\nexport const C12_TICK_M = 1 / 12;\n\nexport const UNIFIED_ANCHOR_NAMES: readonly string[] = Object.freeze([\n \"IK_Palm_Primary\",\n \"IK_Index_Trigger\",\n \"IK_Thumb_Safety\",\n \"IK_Palm_Forend\",\n \"Socket_Muzzle\",\n \"Socket_Eject\",\n \"Socket_HitStart\",\n \"Socket_HitEnd\",\n \"Socket_Tip\",\n \"Socket_Holster\",\n \"Socket_Seat\",\n \"Socket_Optic\",\n]);\n\nconst _box = new THREE.Box3();\nconst _size = new THREE.Vector3();\n\n/** Convert KHR_implicit_shapes box.size (FULL [w, h, d] in meters) to Rapier CuboidCollider half-extents. */\nexport function khrBoxToRapierHalfExtents(fullSize: readonly [number, number, number]): [number, number, number] {\n return [fullSize[0] * 0.5, fullSize[1] * 0.5, fullSize[2] * 0.5];\n}\n\nexport function snapMetersToC12(meters: number): number {\n return Number((Math.max(1, Math.round(meters * 12)) / 12).toFixed(6));\n}\n\nexport function computeC12Metrics(size: readonly [number, number, number]): {\n c12Ticks: [number, number, number];\n c12Aligned: boolean;\n} {\n const c12Ticks: [number, number, number] = [\n Math.round(size[0] * 12),\n Math.round(size[1] * 12),\n Math.round(size[2] * 12),\n ];\n const c12Aligned =\n c12Ticks.every((t) => t >= 1) &&\n Math.abs(size[0] * 12 - c12Ticks[0]) <= 0.06 &&\n Math.abs(size[1] * 12 - c12Ticks[1]) <= 0.06 &&\n Math.abs(size[2] * 12 - c12Ticks[2]) <= 0.06;\n return { c12Ticks, c12Aligned };\n}\n\nexport function detectSceneAnchors(root: THREE.Object3D | null): string[] {\n if (!root)\n return [];\n const found = new Set<string>();\n root.traverse((obj) => {\n if (\n obj.name &&\n (UNIFIED_ANCHOR_NAMES.includes(obj.name) ||\n obj.name.startsWith(\"IK_\") ||\n obj.name.startsWith(\"Socket_\") ||\n obj.name.startsWith(\"Kolmo_\"))\n ) {\n found.add(obj.name);\n }\n });\n return [...found];\n}\n\nexport function defaultTargetMeters(\n domain: GateDomain,\n sub: VehicleSubArchetype,\n): { len: number; massKg: number; power: number } {\n if (domain === \"c12\") return { len: 3, massKg: 0, power: 0 };\n if (domain === \"person\") return { len: 1.75, massKg: 72, power: 0 };\n if (domain === \"launcher\") return { len: 0.92, massKg: 4.2, power: 120 };\n if (domain === \"junk\") return { len: 0.85, massKg: 18, power: 0 };\n if (domain === \"suika\") return { len: 0.28, massKg: 1, power: 0 };\n if (domain === \"prop\") return { len: 1.5, massKg: 85, power: 0 };\n if (sub === \"craft\") return { len: 7.2, massKg: 680, power: 4500 };\n return { len: 4.35, massKg: 1380, power: 260 };\n}\n\nexport function measureAssemblyCalibration(\n assembly: PaperShellAssembly,\n scaleFactor = 1,\n yOffset = 0,\n isProxy = false,\n importedRoot: THREE.Object3D | null = null,\n): CalibrationMetrics {\n const preset = assembly.lattice.preset;\n const wheelbase = preset.wheelbase * scaleFactor;\n const trackWidth = preset.trackWidth * scaleFactor;\n const r = Number((preset.wheelRadius * scaleFactor).toFixed(3));\n const len = (assembly.lattice.rings[assembly.lattice.rings.length - 1].z - assembly.lattice.rings[0].z) * scaleFactor;\n const aabbSize: [number, number, number] = [\n Number((preset.halfWidth * 2 * scaleFactor).toFixed(3)),\n Number((preset.roofY * scaleFactor).toFixed(3)),\n Number(len.toFixed(3)),\n ];\n const { c12Ticks, c12Aligned } = computeC12Metrics(aabbSize);\n const cal: CalibrationMetrics = {\n wheelbase: Number(wheelbase.toFixed(3)),\n trackWidth: Number(trackWidth.toFixed(3)),\n wheelRadii: [r, r, r, r],\n minY: Number(yOffset.toFixed(4)),\n aabbSize,\n c12Ticks,\n c12Aligned,\n detectedAnchors: detectSceneAnchors(importedRoot),\n isSingleMeshProxy: isProxy,\n };\n useGateStore.getState().setCalibration(cal);\n return cal;\n}\n\nexport function measureNormalizedSceneCalibration(scene: THREE.Object3D, yOffset = 0): CalibrationMetrics {\n scene.updateMatrixWorld(true);\n _box.setFromObject(scene);\n if (_box.isEmpty())\n _size.set(1, 1, 1);\n else\n _box.getSize(_size);\n const aabbSize: [number, number, number] = [\n Number(_size.x.toFixed(3)),\n Number(_size.y.toFixed(3)),\n Number(_size.z.toFixed(3)),\n ];\n const wheelbase = Number(Math.max(1.25, _size.z * 0.62).toFixed(3));\n const trackWidth = Number(Math.max(0.4, _size.x * 0.82).toFixed(3));\n const wheelR = Number(Math.max(0.2, Math.min(0.45, _size.y * 0.24)).toFixed(3));\n const { c12Ticks, c12Aligned } = computeC12Metrics(aabbSize);\n const cal: CalibrationMetrics = {\n wheelbase,\n trackWidth,\n wheelRadii: [wheelR, wheelR, wheelR, wheelR],\n minY: Number(((_box.isEmpty() ? 0 : _box.min.y) + yOffset).toFixed(4)),\n aabbSize,\n c12Ticks,\n c12Aligned,\n detectedAnchors: detectSceneAnchors(scene),\n isSingleMeshProxy: false,\n };\n useGateStore.getState().setCalibration(cal);\n return cal;\n}\n\n/** Wrap an unsegmented single-mesh GLB import with a synchronized C0 paper-shell collider + breakaway lattice. */\nexport function wrapSingleMeshWithPaperShellProxy(\n importedRoot: THREE.Object3D | null,\n fallbackPreset: PaperShellPresetId = \"coupe_86\",\n shadingMode: ShadingMode = \"psx-flat\",\n): PaperShellAssembly {\n const assembly = buildPaperShellAssembly(fallbackPreset, shadingMode);\n if (!importedRoot) {\n measureAssemblyCalibration(assembly, 1, 0, true, null);\n return assembly;\n }\n _box.setFromObject(importedRoot);\n if (_box.isEmpty()) {\n measureAssemblyCalibration(assembly, 1, 0, true, importedRoot);\n return assembly;\n }\n _box.getSize(_size);\n const refLen = assembly.lattice.rings[assembly.lattice.rings.length - 1].z - assembly.lattice.rings[0].z;\n const scaleFactor = _size.z > 0.2 ? Math.max(0.5, Math.min(2, _size.z / refLen)) : 1;\n measureAssemblyCalibration(assembly, sca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C,eAAe,GAAG;CAC1C,OAAO;AACX;;AAGA,SAAgB,kCACZ,cACA,iBAAqC,YACrC,cAA2B,YACT;CAClB,MAAM,WAAW,wBAAwB,gBAAgB,WAAW;CACpE,IAAI,CAAC,cAAc;EACf,2BAA2B,UAAU,GAAG,GAAG,MAAM,IAAI;EACrD,OAAO;CACX;CACA,KAAK,cAAc,YAAY;CAC/B,IAAI,KAAK,QAAQ,GAAG;EAChB,2BAA2B,UAAU,GAAG,GAAG,MAAM,YAAY;EAC7D,OAAO;CACX;CACA,KAAK,QAAQ,KAAK;CAClB,MAAM,SAAS,SAAS,QAAQ,MAAM,SAAS,QAAQ,MAAM,SAAS,EAAE,CAAC,IAAI,SAAS,QAAQ,MAAM,EAAE,CAAC;CAEvG,2BAA2B,UADP,MAAM,IAAI,KAAM,KAAK,IAAI,IAAK,KAAK,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,GACjC,GAAG,MAAM,YAAY;CACvE,OAAO;AACX"}
|
|
@@ -172,7 +172,7 @@ function createImporterWebMcpTools(getHost) {
|
|
|
172
172
|
},
|
|
173
173
|
{
|
|
174
174
|
name: "importer_set_kind",
|
|
175
|
-
description: "Set asset domain (vehicle, c12, launcher, person, prop, junk) and optional vehicle archetype.",
|
|
175
|
+
description: "Set asset domain (vehicle, c12, launcher, person, prop, junk, suika) and optional vehicle archetype.",
|
|
176
176
|
inputSchema: {
|
|
177
177
|
type: "object",
|
|
178
178
|
properties: {
|
|
@@ -184,7 +184,8 @@ function createImporterWebMcpTools(getHost) {
|
|
|
184
184
|
"launcher",
|
|
185
185
|
"person",
|
|
186
186
|
"prop",
|
|
187
|
-
"junk"
|
|
187
|
+
"junk",
|
|
188
|
+
"suika"
|
|
188
189
|
]
|
|
189
190
|
},
|
|
190
191
|
archetype: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importerWebMcpTools.js","names":[],"sources":["../../src/importer/importerWebMcpTools.ts"],"sourcesContent":["import { VAULT_CATALOG, createAssetVault } from \"@khr3/assets\";\nimport { inferKolmoSocketRole, type KolmoSocketRole } from \"../schema/kolmoSchema.js\";\nimport { useGateStore, type GateDomain } from \"./gateStore.js\";\nimport type { ImporterWebMcpHost, WebMcpTool } from \"./importerWebMcp.js\";\nimport type { ActiveChopRole } from \"./surfaceCutter.js\";\n\nfunction resolveModelUrl(raw: string, resolveKey: (key: string) => string): string {\n const trimmed = raw.trim();\n if (!trimmed || /^(javascript|data|vbscript|file):/i.test(trimmed))\n throw new Error(`Invalid importer model URL: \"${raw}\"`);\n return /^https?:\\/\\//i.test(trimmed) || trimmed.startsWith(\"/\") ? trimmed : resolveKey(trimmed);\n}\n\nconst VALID_ROLES = new Set<string>([\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"]);\n\nexport function createImporterWebMcpTools(getHost: () => ImporterWebMcpHost): readonly WebMcpTool[] {\n const vault = createAssetVault();\n return [\n {\n name: \"importer_state\",\n description: \"Read current calibration bounds, SI scale, domain, step, wheel axles, and unlock status.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const h = getHost(), st = useGateStore.getState();\n return {\n assetName: h.assetName, domain: st.domain, step: st.step, vehicleArchetype: st.vehicleArchetype,\n targetMeters: h.targetMeters, wheelCount: h.wheelCount, choppedCount: h.choppedCount,\n unlocked: h.unlocked, calibration: st.calibration,\n };\n },\n },\n {\n name: \"importer_capture_view\",\n description: \"Capture current 3D calibration viewport PNG data URL.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const dataUrl = getHost().captureDataUrl?.() ?? null;\n return { ok: !!dataUrl, mimeType: \"image/png\", dataUrl };\n },\n },\n {\n name: \"importer_list_models\",\n description: \"List available starter and R2 vault .glb models across cars, weapons, and city categories.\",\n inputSchema: { type: \"object\", properties: { prefix: { type: \"string\" } } },\n annotations: { readOnlyHint: true },\n execute: async (input) => {\n const prefix = typeof input.prefix === \"string\" ? input.prefix : \"\";\n try { return { catalog: VAULT_CATALOG, liveVault: await vault.listPrefix(prefix) }; }\n catch { return { catalog: VAULT_CATALOG, liveVault: null }; }\n },\n },\n {\n name: \"importer_set_stage\",\n description: \"Switch importer stage (1 = Chop & Calibrate, 2 = Live Drive / Seal Pad; requires Step 1 unlocked).\",\n inputSchema: { type: \"object\", properties: { step: { type: \"number\", enum: [1, 2] } }, required: [\"step\"] },\n execute: (input) => {\n const step = input.step === 2 ? 2 : 1;\n if (step === 2 && !getHost().unlocked)\n return { ok: false, error: \"Step 1 calibration requirements are not yet unlocked.\", step: 1 };\n useGateStore.getState().setField(\"step\", step);\n return { ok: true, step };\n },\n },\n {\n name: \"importer_load\",\n description: \"Load a .glb model by URL or vault key into the calibration bay.\",\n inputSchema: { type: \"object\", properties: { url: { type: \"string\" }, name: { type: \"string\" } }, required: [\"url\"] },\n execute: async (input) => {\n const rawUrl = String(input.url ?? \"\");\n const url = resolveModelUrl(rawUrl, (k) => vault.url(k));\n const label = typeof input.name === \"string\" && input.name.trim()\n ? input.name.trim()\n : rawUrl.split(\"/\").pop()?.replace(/\\.glb$/i, \"\") || \"asset\";\n await getHost().loadStarterCar(url, label);\n return { ok: true, url, label };\n },\n },\n {\n name: \"importer_orient\",\n description: \"Rotate asset in exact 90-degree quarter-turns around X (0), Y (1), or Z (2).\",\n inputSchema: { type: \"object\", properties: { axis: { type: \"number\", enum: [0, 1, 2] } }, required: [\"axis\"] },\n execute: (input) => {\n const axis: 0 | 1 | 2 = input.axis === 1 ? 1 : input.axis === 2 ? 2 : 0;\n getHost().bumpTurn(axis);\n return { ok: true, axis };\n },\n },\n {\n name: \"importer_scale\",\n description: \"Scale asset cleanly to exact SI target meters with [1,1,1] node scale and Y=0 contact.\",\n inputSchema: { type: \"object\", properties: { meters: { type: \"number\" } }, required: [\"meters\"] },\n execute: (input) => {\n const targetMeters = Math.max(0.05, Number(input.meters) || 1);\n getHost().setTargetMeters(targetMeters);\n return { ok: true, targetMeters };\n },\n },\n {\n name: \"importer_set_kind\",\n description: \"Set asset domain (vehicle, c12, launcher, person, prop, junk) and optional vehicle archetype.\",\n inputSchema: {\n type: \"object\",\n properties: {\n domain: { type: \"string\", enum: [\"vehicle\", \"c12\", \"launcher\", \"person\", \"prop\", \"junk\"] },\n archetype: { type: \"string\", enum: [\"car\", \"craft\"] },\n },\n required: [\"domain\"],\n },\n execute: (input) => {\n const domain = (input.domain as GateDomain) || \"vehicle\";\n const archetype = input.archetype === \"craft\" ? \"craft\" : \"car\";\n getHost().applyDomainDefaults(domain, archetype, false);\n return { ok: true, domain, archetype };\n },\n },\n {\n name: \"importer_pop_wheels\",\n description: \"Auto-detect and pair symmetric wheel islands into Ecctrl ShapeCastWheel axles.\",\n inputSchema: { type: \"object\", properties: {} },\n execute: () => { getHost().autoPopWheels(); return { ok: true }; },\n },\n {\n name: \"importer_cut_part\",\n description: \"Cut or tag an openable/hinged KHR vehicle part by islandId, crease faceIndex, or loopPoints.\",\n inputSchema: {\n type: \"object\",\n properties: {\n role: { type: \"string\", enum: [\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"] },\n islandId: { type: \"number\" }, faceIndex: { type: \"number\" }, creaseDeg: { type: \"number\" }, mirrorX: { type: \"boolean\" },\n loopPoints: { type: \"array\", items: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 } },\n },\n required: [\"role\"],\n },\n execute: (input) => {\n const h = getHost();\n if (!h.cutPart) return { ok: false, error: \"Cut tool unavailable on current host.\" };\n const role: ActiveChopRole = VALID_ROLES.has(String(input.role)) ? (input.role as ActiveChopRole) : \"door\";\n const loopPoints = Array.isArray(input.loopPoints)\n ? input.loopPoints.filter((pt): pt is number[] => Array.isArray(pt) && pt.length >= 3)\n .map((pt) => [Number(pt[0]) || 0, Number(pt[1]) || 0, Number(pt[2]) || 0] as const)\n : undefined;\n return h.cutPart({\n role,\n ...(typeof input.islandId === \"number\" ? { islandId: input.islandId } : {}),\n ...(typeof input.faceIndex === \"number\" ? { faceIndex: input.faceIndex } : {}),\n ...(typeof input.creaseDeg === \"number\" ? { creaseDeg: input.creaseDeg } : {}),\n ...(typeof input.mirrorX === \"boolean\" ? { mirrorX: input.mirrorX } : {}),\n ...(loopPoints && loopPoints.length >= 3 ? { loopPoints } : {}),\n });\n },\n },\n {\n name: \"importer_set_points\",\n description: \"Stamp an explicit IK / muzzle / grip / seat / contact / hinge socket point in local SI meters.\",\n inputSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n role: { type: \"string\", enum: [\"seat\", \"exit\", \"grip_primary\", \"grip_secondary\", \"optic\", \"muzzle\", \"eject\", \"hinge\", \"mount\", \"contact\"] },\n position: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 },\n },\n required: [\"name\", \"position\"],\n },\n execute: (input) => {\n const name = String(input.name ?? \"\").trim(), posArr = input.position;\n if (!name || !Array.isArray(posArr) || posArr.length !== 3 || !posArr.every((v) => typeof v === \"number\" && Number.isFinite(v)))\n throw new Error(\"importer_set_points requires a non-empty name and a 3-element finite numeric position array.\");\n const pos: [number, number, number] = [posArr[0], posArr[1], posArr[2]];\n const role = inferKolmoSocketRole(name, typeof input.role === \"string\" ? (input.role as KolmoSocketRole) : undefined);\n getHost().addAnchorPoint(name, pos, role);\n return { ok: true, name, role, position: pos };\n },\n },\n {\n name: \"importer_export\",\n description: \"Bake and export the KHR_physics_rigid_bodies .glb (or spawn straight into the active world).\",\n inputSchema: { type: \"object\", properties: { spawnInWorld: { type: \"boolean\" } } },\n execute: async (input) => { await getHost().sealAndExport(!!input.spawnInWorld); return { ok: true }; },\n },\n ];\n}\n"],"mappings":";;;;AAMA,SAAS,gBAAgB,KAAa,YAA6C;CAC/E,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,CAAC,WAAW,qCAAqC,KAAK,OAAO,GAC7D,MAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;CAC1D,OAAO,gBAAgB,KAAK,OAAO,KAAK,QAAQ,WAAW,G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ACnF;IACA,UAAU,CAAC,QAAQ,UAAU;GACjC;GACA,UAAU,UAAU;IAChB,MAAM,OAAO,OAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,SAAS,MAAM;IAC7D,IAAI,CAAC,QAAQ,CAAC,MAAM,QAAQ,MAAM,KAAK,OAAO,WAAW,KAAK,CAAC,OAAO,OAAO,MAAM,OAAO,MAAM,YAAY,OAAO,SAAS,CAAC,CAAC,GAC1H,MAAM,IAAI,MAAM,8FAA8F;IAClH,MAAM,MAAgC;KAAC,OAAO;KAAI,OAAO;KAAI,OAAO;IAAE;IACtE,MAAM,OAAO,qBAAqB,MAAM,OAAO,MAAM,SAAS,WAAY,MAAM,OAA2B,KAAA,CAAS;IACpH,QAAQ,CAAC,CAAC,eAAe,MAAM,KAAK,IAAI;IACxC,OAAO;KAAE,IAAI;KAAM;KAAM;KAAM,UAAU;IAAI;GACjD;EACJ;EACA;GACI,MAAM;GACN,aAAa;GACb,aAAa;IAAE,MAAM;IAAU,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,EAAE;GAAE;GACjF,SAAS,OAAO,UAAU;IAAE,MAAM,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,YAAY;IAAG,OAAO,EAAE,IAAI,KAAK;GAAG;EAC1G;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"importerWebMcpTools.js","names":[],"sources":["../../src/importer/importerWebMcpTools.ts"],"sourcesContent":["import { VAULT_CATALOG, createAssetVault } from \"@khr3/assets\";\nimport { inferKolmoSocketRole, type KolmoSocketRole } from \"../schema/kolmoSchema.js\";\nimport { useGateStore, type GateDomain } from \"./gateStore.js\";\nimport type { ImporterWebMcpHost, WebMcpTool } from \"./importerWebMcp.js\";\nimport type { ActiveChopRole } from \"./surfaceCutter.js\";\n\nfunction resolveModelUrl(raw: string, resolveKey: (key: string) => string): string {\n const trimmed = raw.trim();\n if (!trimmed || /^(javascript|data|vbscript|file):/i.test(trimmed))\n throw new Error(`Invalid importer model URL: \"${raw}\"`);\n return /^https?:\\/\\//i.test(trimmed) || trimmed.startsWith(\"/\") ? trimmed : resolveKey(trimmed);\n}\n\nconst VALID_ROLES = new Set<string>([\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"]);\n\nexport function createImporterWebMcpTools(getHost: () => ImporterWebMcpHost): readonly WebMcpTool[] {\n const vault = createAssetVault();\n return [\n {\n name: \"importer_state\",\n description: \"Read current calibration bounds, SI scale, domain, step, wheel axles, and unlock status.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const h = getHost(), st = useGateStore.getState();\n return {\n assetName: h.assetName, domain: st.domain, step: st.step, vehicleArchetype: st.vehicleArchetype,\n targetMeters: h.targetMeters, wheelCount: h.wheelCount, choppedCount: h.choppedCount,\n unlocked: h.unlocked, calibration: st.calibration,\n };\n },\n },\n {\n name: \"importer_capture_view\",\n description: \"Capture current 3D calibration viewport PNG data URL.\",\n inputSchema: { type: \"object\", properties: {} },\n annotations: { readOnlyHint: true },\n execute: () => {\n const dataUrl = getHost().captureDataUrl?.() ?? null;\n return { ok: !!dataUrl, mimeType: \"image/png\", dataUrl };\n },\n },\n {\n name: \"importer_list_models\",\n description: \"List available starter and R2 vault .glb models across cars, weapons, and city categories.\",\n inputSchema: { type: \"object\", properties: { prefix: { type: \"string\" } } },\n annotations: { readOnlyHint: true },\n execute: async (input) => {\n const prefix = typeof input.prefix === \"string\" ? input.prefix : \"\";\n try { return { catalog: VAULT_CATALOG, liveVault: await vault.listPrefix(prefix) }; }\n catch { return { catalog: VAULT_CATALOG, liveVault: null }; }\n },\n },\n {\n name: \"importer_set_stage\",\n description: \"Switch importer stage (1 = Chop & Calibrate, 2 = Live Drive / Seal Pad; requires Step 1 unlocked).\",\n inputSchema: { type: \"object\", properties: { step: { type: \"number\", enum: [1, 2] } }, required: [\"step\"] },\n execute: (input) => {\n const step = input.step === 2 ? 2 : 1;\n if (step === 2 && !getHost().unlocked)\n return { ok: false, error: \"Step 1 calibration requirements are not yet unlocked.\", step: 1 };\n useGateStore.getState().setField(\"step\", step);\n return { ok: true, step };\n },\n },\n {\n name: \"importer_load\",\n description: \"Load a .glb model by URL or vault key into the calibration bay.\",\n inputSchema: { type: \"object\", properties: { url: { type: \"string\" }, name: { type: \"string\" } }, required: [\"url\"] },\n execute: async (input) => {\n const rawUrl = String(input.url ?? \"\");\n const url = resolveModelUrl(rawUrl, (k) => vault.url(k));\n const label = typeof input.name === \"string\" && input.name.trim()\n ? input.name.trim()\n : rawUrl.split(\"/\").pop()?.replace(/\\.glb$/i, \"\") || \"asset\";\n await getHost().loadStarterCar(url, label);\n return { ok: true, url, label };\n },\n },\n {\n name: \"importer_orient\",\n description: \"Rotate asset in exact 90-degree quarter-turns around X (0), Y (1), or Z (2).\",\n inputSchema: { type: \"object\", properties: { axis: { type: \"number\", enum: [0, 1, 2] } }, required: [\"axis\"] },\n execute: (input) => {\n const axis: 0 | 1 | 2 = input.axis === 1 ? 1 : input.axis === 2 ? 2 : 0;\n getHost().bumpTurn(axis);\n return { ok: true, axis };\n },\n },\n {\n name: \"importer_scale\",\n description: \"Scale asset cleanly to exact SI target meters with [1,1,1] node scale and Y=0 contact.\",\n inputSchema: { type: \"object\", properties: { meters: { type: \"number\" } }, required: [\"meters\"] },\n execute: (input) => {\n const targetMeters = Math.max(0.05, Number(input.meters) || 1);\n getHost().setTargetMeters(targetMeters);\n return { ok: true, targetMeters };\n },\n },\n {\n name: \"importer_set_kind\",\n description: \"Set asset domain (vehicle, c12, launcher, person, prop, junk, suika) and optional vehicle archetype.\",\n inputSchema: {\n type: \"object\",\n properties: {\n domain: { type: \"string\", enum: [\"vehicle\", \"c12\", \"launcher\", \"person\", \"prop\", \"junk\", \"suika\"] },\n archetype: { type: \"string\", enum: [\"car\", \"craft\"] },\n },\n required: [\"domain\"],\n },\n execute: (input) => {\n const domain = (input.domain as GateDomain) || \"vehicle\";\n const archetype = input.archetype === \"craft\" ? \"craft\" : \"car\";\n getHost().applyDomainDefaults(domain, archetype, false);\n return { ok: true, domain, archetype };\n },\n },\n {\n name: \"importer_pop_wheels\",\n description: \"Auto-detect and pair symmetric wheel islands into Ecctrl ShapeCastWheel axles.\",\n inputSchema: { type: \"object\", properties: {} },\n execute: () => { getHost().autoPopWheels(); return { ok: true }; },\n },\n {\n name: \"importer_cut_part\",\n description: \"Cut or tag an openable/hinged KHR vehicle part by islandId, crease faceIndex, or loopPoints.\",\n inputSchema: {\n type: \"object\",\n properties: {\n role: { type: \"string\", enum: [\"door\", \"hood\", \"trunk\", \"fender\", \"bumper\", \"wheel\"] },\n islandId: { type: \"number\" }, faceIndex: { type: \"number\" }, creaseDeg: { type: \"number\" }, mirrorX: { type: \"boolean\" },\n loopPoints: { type: \"array\", items: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 } },\n },\n required: [\"role\"],\n },\n execute: (input) => {\n const h = getHost();\n if (!h.cutPart) return { ok: false, error: \"Cut tool unavailable on current host.\" };\n const role: ActiveChopRole = VALID_ROLES.has(String(input.role)) ? (input.role as ActiveChopRole) : \"door\";\n const loopPoints = Array.isArray(input.loopPoints)\n ? input.loopPoints.filter((pt): pt is number[] => Array.isArray(pt) && pt.length >= 3)\n .map((pt) => [Number(pt[0]) || 0, Number(pt[1]) || 0, Number(pt[2]) || 0] as const)\n : undefined;\n return h.cutPart({\n role,\n ...(typeof input.islandId === \"number\" ? { islandId: input.islandId } : {}),\n ...(typeof input.faceIndex === \"number\" ? { faceIndex: input.faceIndex } : {}),\n ...(typeof input.creaseDeg === \"number\" ? { creaseDeg: input.creaseDeg } : {}),\n ...(typeof input.mirrorX === \"boolean\" ? { mirrorX: input.mirrorX } : {}),\n ...(loopPoints && loopPoints.length >= 3 ? { loopPoints } : {}),\n });\n },\n },\n {\n name: \"importer_set_points\",\n description: \"Stamp an explicit IK / muzzle / grip / seat / contact / hinge socket point in local SI meters.\",\n inputSchema: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n role: { type: \"string\", enum: [\"seat\", \"exit\", \"grip_primary\", \"grip_secondary\", \"optic\", \"muzzle\", \"eject\", \"hinge\", \"mount\", \"contact\"] },\n position: { type: \"array\", items: { type: \"number\" }, minItems: 3, maxItems: 3 },\n },\n required: [\"name\", \"position\"],\n },\n execute: (input) => {\n const name = String(input.name ?? \"\").trim(), posArr = input.position;\n if (!name || !Array.isArray(posArr) || posArr.length !== 3 || !posArr.every((v) => typeof v === \"number\" && Number.isFinite(v)))\n throw new Error(\"importer_set_points requires a non-empty name and a 3-element finite numeric position array.\");\n const pos: [number, number, number] = [posArr[0], posArr[1], posArr[2]];\n const role = inferKolmoSocketRole(name, typeof input.role === \"string\" ? (input.role as KolmoSocketRole) : undefined);\n getHost().addAnchorPoint(name, pos, role);\n return { ok: true, name, role, position: pos };\n },\n },\n {\n name: \"importer_export\",\n description: \"Bake and export the KHR_physics_rigid_bodies .glb (or spawn straight into the active world).\",\n inputSchema: { type: \"object\", properties: { spawnInWorld: { type: \"boolean\" } } },\n execute: async (input) => { await getHost().sealAndExport(!!input.spawnInWorld); return { ok: true }; },\n },\n ];\n}\n"],"mappings":";;;;AAMA,SAAS,gBAAgB,KAAa,YAA6C;CAC/E,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,CAAC,WAAW,qCAAqC,KAAK,OAAO,GAC7D,MAAM,IAAI,MAAM,gCAAgC,IAAI,EAAE;CAC1D,OAAO,gBAAgB,KAAK,OAAO,KAAK,QAAQ,WAAW,GAAG,IAAI,UAAU,WAAW,OAAO;AAClG;AAEA,IAAM,8BAAc,IAAI,IAAY;CAAC;CAAQ;CAAQ;CAAS;CAAU;CAAU;AAAO,CAAC;AAE1F,SAAgB,0BAA0B,SAA0D;CAChG,MAAM,QAAQ,iBAAiB;CAC/B,OAAO;EACH;GACI,MAAM;GACN,aAAa;GACb,aAAa;IAAE,MAAM;IAAU,YAAY,CAAC;GAAE;GAC9C,aAAa,EAAE,cAAc,KAAK;GAClC,eAAe;I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MAAM,8FAA8F;IAClH,MAAM,MAAgC;KAAC,OAAO;KAAI,OAAO;KAAI,OAAO;IAAE;IACtE,MAAM,OAAO,qBAAqB,MAAM,OAAO,MAAM,SAAS,WAAY,MAAM,OAA2B,KAAA,CAAS;IACpH,QAAQ,CAAC,CAAC,eAAe,MAAM,KAAK,IAAI;IACxC,OAAO;KAAE,IAAI;KAAM;KAAM;KAAM,UAAU;IAAI;GACjD;EACJ;EACA;GACI,MAAM;GACN,aAAa;GACb,aAAa;IAAE,MAAM;IAAU,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,EAAE;GAAE;GACjF,SAAS,OAAO,UAAU;IAAE,MAAM,QAAQ,CAAC,CAAC,cAAc,CAAC,CAAC,MAAM,YAAY;IAAG,OAAO,EAAE,IAAI,KAAK;GAAG;EAC1G;CACJ;AACJ"}
|
package/dist/importer/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { GlbImportGate, GlbImportGate as ImporterWorkbench, type GlbImportGateProps } from "./GlbImportGate.js";
|
|
2
|
-
export { GateHudBar, type GateHudBarProps, type StampToolId } from "./GateHudBar.js";
|
|
3
|
-
export { Step1CalibrationPlinth,
|
|
2
|
+
export { GateHudBar, resolveVaultCarSelection, type GateHudBarProps, type StampToolId } from "./GateHudBar.js";
|
|
3
|
+
export { Step1CalibrationPlinth, type Step1CalibrationPlinthProps } from "./Step1CalibrationPlinth.js";
|
|
4
|
+
export { makeStarterDomainScene, registerSand3dStarterFactory, type StarterDomainKey } from "./starterScene.js";
|
|
4
5
|
export { WheelRingHandles3D, type WheelRingHandles3DProps } from "./WheelRingHandles3D.js";
|
|
5
6
|
export { ImperativeVehicleRig, type ImperativeVehicleRigProps } from "./ImperativeVehicleRig.js";
|
|
6
7
|
export { Step2UniversalPad, type Step2UniversalPadProps } from "./Step2UniversalPad.js";
|
|
@@ -14,6 +15,7 @@ export { ChopShopPanel, type ChopShopPanelProps } from "./ChopShopPanel.js";
|
|
|
14
15
|
export { useChopShopController, type ChopShopController } from "./useChopShopController.js";
|
|
15
16
|
export { DomainWorkshopPanel, enforceRetroPersonMaterials, type DomainWorkshopPanelProps } from "./DomainWorkshopPanel.js";
|
|
16
17
|
export { buildImporterWebMcpTools, getNavigatorModelContext, useImporterWebMcp, type ImporterWebMcpHost, type ModelContext, type WebMcpTool, } from "./importerWebMcp.js";
|
|
18
|
+
export * from "./proceduralDomainBuilders.js";
|
|
17
19
|
export * from "./surfaceCutter.js";
|
|
18
20
|
export * from "./meshIslands.js";
|
|
19
21
|
export * from "./khrCompiler.js";
|
package/dist/importer/index.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CHOP_ROLES, buildSurfaceTopology, floodFillByCrease, getIslandTopology } from "./surfaceTopology.js";
|
|
3
|
-
import { GlbImportGate } from "./GlbImportGate.js";
|
|
1
|
+
import { buildPatchPreviewEmitters, computeChopPartHinge, normalToMinusZQuaternion } from "./chopHingeHelpers.js";
|
|
4
2
|
import { normalizeSceneToSi, sliceMeshTriangles } from "./sceneSiNormalize.js";
|
|
5
|
-
import {
|
|
3
|
+
import { enforceMirrorCutterSymmetry, inferMirrorOriginX, mirrorCutterId, snapCuttersAxles, updateWheelCutter } from "./wheelCutterHelpers.js";
|
|
4
|
+
import { GlbImportGate } from "./GlbImportGate.js";
|
|
5
|
+
import { GateHudBar, resolveVaultCarSelection } from "./GateHudBar.js";
|
|
6
|
+
import { separateVehicleMeshes } from "./vehiclePartSplit.js";
|
|
7
|
+
import { measureSelection, suggestCarAxles, toggleIslandSelection } from "./wheelAxlePairing.js";
|
|
6
8
|
import { Step1CalibrationPlinth } from "./Step1CalibrationPlinth.js";
|
|
9
|
+
import { mirrorTriangles } from "./surfaceGeodesic.js";
|
|
10
|
+
import { CHOP_ROLES, buildSurfaceTopology, floodFillByCrease, getIslandTopology } from "./surfaceTopology.js";
|
|
11
|
+
import { refineMeshAlongLoop } from "./surfaceLoopRefine.js";
|
|
12
|
+
import { buildSelectionOverlayGeometry, createFleet12GonWheelGroup, findMirrorIslandId, peelIslandSelection, remapIslandIds } from "./surfacePeel.js";
|
|
13
|
+
import { makeStarterDomainScene, registerSand3dStarterFactory } from "./starterScene.js";
|
|
7
14
|
import { WheelRingHandles3D } from "./WheelRingHandles3D.js";
|
|
8
15
|
import { ImperativeVehicleRig } from "./ImperativeVehicleRig.js";
|
|
9
|
-
import { buildPatchPreviewEmitters, computeChopPartHinge, normalToMinusZQuaternion } from "./chopHingeHelpers.js";
|
|
10
|
-
import { enforceMirrorCutterSymmetry, inferMirrorOriginX, mirrorCutterId, snapCuttersAxles, updateWheelCutter } from "./wheelCutterHelpers.js";
|
|
11
16
|
import { Step2UniversalPad } from "./Step2UniversalPad.js";
|
|
12
|
-
import { makeStarterDomainScene } from "./starterScene.js";
|
|
13
|
-
import { refineMeshAlongLoop } from "./surfaceLoopRefine.js";
|
|
14
|
-
import { separateVehicleMeshes } from "./vehiclePartSplit.js";
|
|
15
|
-
import { measureSelection, suggestCarAxles, toggleIslandSelection } from "./wheelAxlePairing.js";
|
|
16
17
|
import { VfxEmitterPool } from "./VfxEmitterPool.js";
|
|
17
|
-
import { buildSelectionOverlayGeometry, createFleet12GonWheelGroup, findMirrorIslandId, peelIslandSelection, remapIslandIds } from "./surfacePeel.js";
|
|
18
18
|
import { DAMP_ZETA, FREQ_HZ, gateTelemetry, isGateStep1Unlocked, useGateStore } from "./gateStore.js";
|
|
19
|
+
import { JUNK_PROCEDURAL_RECIPES, buildProceduralJunkScene } from "../junk/junkProceduralScenes.js";
|
|
20
|
+
import { C12_PROCEDURAL_RECIPES, buildProceduralC12Scene } from "./proceduralC12AndCraft.js";
|
|
21
|
+
import { PERSON_PROCEDURAL_RECIPES, PROP_PROCEDURAL_RECIPES, buildProceduralPersonScene, buildProceduralPropScene } from "./proceduralPersonAndProp.js";
|
|
19
22
|
import { C12_TICK_M, UNIFIED_ANCHOR_NAMES, computeC12Metrics, defaultTargetMeters, detectSceneAnchors, khrBoxToRapierHalfExtents, measureAssemblyCalibration, measureNormalizedSceneCalibration, snapMetersToC12, wrapSingleMeshWithPaperShellProxy } from "./glbNormalizer.js";
|
|
20
23
|
import { bakeUniversalGateGlb } from "./universalGateBake.js";
|
|
21
24
|
import { bakeArticulatedLauncherGlb, buildLauncherSceneFromPlan } from "./launcherBake.js";
|
|
@@ -24,9 +27,10 @@ import { ChopShopPanel } from "./ChopShopPanel.js";
|
|
|
24
27
|
import { useChopShopController } from "./useChopShopController.js";
|
|
25
28
|
import { DomainWorkshopPanel, enforceRetroPersonMaterials } from "./DomainWorkshopPanel.js";
|
|
26
29
|
import { buildImporterWebMcpTools, getNavigatorModelContext, useImporterWebMcp } from "./importerWebMcp.js";
|
|
30
|
+
import { CRAFT_PROCEDURAL_RECIPES, buildProceduralCraftScene, buildProceduralDomainScene } from "./proceduralDomainBuilders.js";
|
|
27
31
|
import { previewLoopPolyline, selectFacesByClick, selectFacesByLoop } from "./surfaceCutter.js";
|
|
28
32
|
import { extractMeshIslands } from "./meshIslands.js";
|
|
29
33
|
import { compileKhrAssetGlb } from "./khrCompiler.js";
|
|
30
34
|
import { detectFusedCarWheels } from "./fusedWheelDetect.js";
|
|
31
35
|
import { sliceCarWheelCylinders } from "./cylinderBooleanSlice.js";
|
|
32
|
-
export { C12_TICK_M, CHOP_ROLES, ChopShopPanel, DAMP_ZETA, DomainWorkshopPanel, FREQ_HZ, GateHudBar, GlbImportGate, ImperativeVehicleRig, GlbImportGate as ImporterWorkbench, Step1CalibrationPlinth, Step2UniversalPad, UNIFIED_ANCHOR_NAMES, VfxEmitterPool, WheelRingHandles3D, bakeArticulatedLauncherGlb, bakeUniversalGateGlb, buildImporterWebMcpTools, buildLauncherSceneFromPlan, buildPatchPreviewEmitters, buildSelectionOverlayGeometry, buildSurfaceTopology, compileKhrAssetGlb, computeC12Metrics, computeChopPartHinge, convertUsdToGlb, createFleet12GonWheelGroup, defaultTargetMeters, detectFusedCarWheels, detectSceneAnchors, enforceMirrorCutterSymmetry, enforceRetroPersonMaterials, extractMeshIslands, findMirrorIslandId, floodFillByCrease, gateTelemetry, getIslandTopology, getNavigatorModelContext, inferMirrorOriginX, isGateStep1Unlocked, isUsdFileName, khrBoxToRapierHalfExtents, makeStarterDomainScene, measureAssemblyCalibration, measureNormalizedSceneCalibration, measureSelection, mirrorCutterId, mirrorTriangles, normalToMinusZQuaternion, normalizeSceneToSi, peelIslandSelection, previewLoopPolyline, refineMeshAlongLoop, remapIslandIds, selectFacesByClick, selectFacesByLoop, separateVehicleMeshes, sliceCarWheelCylinders, sliceMeshTriangles, snapCuttersAxles, snapMetersToC12, suggestCarAxles, toggleIslandSelection, updateWheelCutter, useChopShopController, useGateStore, useImporterWebMcp, wrapSingleMeshWithPaperShellProxy };
|
|
36
|
+
export { C12_PROCEDURAL_RECIPES, C12_TICK_M, CHOP_ROLES, CRAFT_PROCEDURAL_RECIPES, ChopShopPanel, DAMP_ZETA, DomainWorkshopPanel, FREQ_HZ, GateHudBar, GlbImportGate, ImperativeVehicleRig, GlbImportGate as ImporterWorkbench, JUNK_PROCEDURAL_RECIPES, PERSON_PROCEDURAL_RECIPES, PROP_PROCEDURAL_RECIPES, Step1CalibrationPlinth, Step2UniversalPad, UNIFIED_ANCHOR_NAMES, VfxEmitterPool, WheelRingHandles3D, bakeArticulatedLauncherGlb, bakeUniversalGateGlb, buildImporterWebMcpTools, buildLauncherSceneFromPlan, buildPatchPreviewEmitters, buildProceduralC12Scene, buildProceduralCraftScene, buildProceduralDomainScene, buildProceduralJunkScene, buildProceduralPersonScene, buildProceduralPropScene, buildSelectionOverlayGeometry, buildSurfaceTopology, compileKhrAssetGlb, computeC12Metrics, computeChopPartHinge, convertUsdToGlb, createFleet12GonWheelGroup, defaultTargetMeters, detectFusedCarWheels, detectSceneAnchors, enforceMirrorCutterSymmetry, enforceRetroPersonMaterials, extractMeshIslands, findMirrorIslandId, floodFillByCrease, gateTelemetry, getIslandTopology, getNavigatorModelContext, inferMirrorOriginX, isGateStep1Unlocked, isUsdFileName, khrBoxToRapierHalfExtents, makeStarterDomainScene, measureAssemblyCalibration, measureNormalizedSceneCalibration, measureSelection, mirrorCutterId, mirrorTriangles, normalToMinusZQuaternion, normalizeSceneToSi, peelIslandSelection, previewLoopPolyline, refineMeshAlongLoop, registerSand3dStarterFactory, remapIslandIds, resolveVaultCarSelection, selectFacesByClick, selectFacesByLoop, separateVehicleMeshes, sliceCarWheelCylinders, sliceMeshTriangles, snapCuttersAxles, snapMetersToC12, suggestCarAxles, toggleIslandSelection, updateWheelCutter, useChopShopController, useGateStore, useImporterWebMcp, wrapSingleMeshWithPaperShellProxy };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import type { KhrExportNodeSpec } from "@khr3/core";
|
|
3
|
+
export interface DerivedChassisPlan {
|
|
4
|
+
readonly chassisMass: number;
|
|
5
|
+
readonly centerOfMass: [number, number, number];
|
|
6
|
+
readonly inertiaDiagonal: [number, number, number];
|
|
7
|
+
readonly inertiaOrientation: [number, number, number, number];
|
|
8
|
+
readonly hullNodeName: "Chassis_Hull";
|
|
9
|
+
readonly hullCenter: [number, number, number];
|
|
10
|
+
readonly hullSize: [number, number, number];
|
|
11
|
+
readonly colliderSpec: KhrExportNodeSpec;
|
|
12
|
+
}
|
|
13
|
+
export declare function deriveChassisGeometryPlan(params: {
|
|
14
|
+
readonly chassis: THREE.Group;
|
|
15
|
+
readonly totalMass: number;
|
|
16
|
+
readonly panelsMassKg: number;
|
|
17
|
+
readonly size: readonly [number, number, number];
|
|
18
|
+
readonly center: THREE.Vector3;
|
|
19
|
+
readonly maxWheelRadius: number;
|
|
20
|
+
}): DerivedChassisPlan;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { boxInertia, r4 } from "./khrCraftPropCompiler.js";
|
|
2
|
+
import { isMeshObject } from "./sceneSiNormalize.js";
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
// src/importer/khrCarGeometryMass.ts
|
|
5
|
+
function deriveChassisGeometryPlan(params) {
|
|
6
|
+
const { chassis, totalMass, panelsMassKg, size, center, maxWheelRadius } = params;
|
|
7
|
+
const chassisMass = Math.max(80, totalMass - panelsMassKg);
|
|
8
|
+
chassis.updateMatrixWorld(true);
|
|
9
|
+
const invChassis = new THREE.Matrix4().copy(chassis.matrixWorld).invert();
|
|
10
|
+
const relMat = new THREE.Matrix4();
|
|
11
|
+
const v = new THREE.Vector3();
|
|
12
|
+
const hullBox = new THREE.Box3();
|
|
13
|
+
const partBoxes = [];
|
|
14
|
+
chassis.traverse((obj) => {
|
|
15
|
+
if (!isMeshObject(obj) || obj.name.startsWith("ArchLiner")) return;
|
|
16
|
+
const pos = obj.geometry.getAttribute("position");
|
|
17
|
+
if (!pos || pos.count === 0) return;
|
|
18
|
+
relMat.multiplyMatrices(invChassis, obj.matrixWorld);
|
|
19
|
+
const mb = new THREE.Box3();
|
|
20
|
+
for (let i = 0; i < pos.count; i++) {
|
|
21
|
+
v.fromBufferAttribute(pos, i).applyMatrix4(relMat);
|
|
22
|
+
if (Number.isFinite(v.x) && Number.isFinite(v.y) && Number.isFinite(v.z)) {
|
|
23
|
+
mb.expandByPoint(v);
|
|
24
|
+
hullBox.expandByPoint(v);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (!mb.isEmpty()) {
|
|
28
|
+
const pSize = mb.getSize(new THREE.Vector3());
|
|
29
|
+
const pCenter = mb.getCenter(new THREE.Vector3());
|
|
30
|
+
const vol = Math.max(1e-4, Math.max(.02, pSize.x) * Math.max(.02, pSize.y) * Math.max(.02, pSize.z));
|
|
31
|
+
partBoxes.push({
|
|
32
|
+
box: mb,
|
|
33
|
+
size: pSize,
|
|
34
|
+
center: pCenter,
|
|
35
|
+
vol
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const groundClearance = Math.max(.08, Math.min(maxWheelRadius * .65, size[1] * .25));
|
|
40
|
+
const fallbackSize = new THREE.Vector3(Math.max(.4, size[0] * .85), Math.max(.32, size[1] - groundClearance), Math.max(.8, size[2] * .92));
|
|
41
|
+
const fallbackCenter = new THREE.Vector3(center.x, groundClearance + fallbackSize.y * .5, center.z);
|
|
42
|
+
const measuredSize = hullBox.isEmpty() ? fallbackSize : hullBox.getSize(new THREE.Vector3());
|
|
43
|
+
const measuredCenter = hullBox.isEmpty() ? fallbackCenter : hullBox.getCenter(new THREE.Vector3());
|
|
44
|
+
const hx = Math.max(.35, measuredSize.x);
|
|
45
|
+
const hy = Math.max(.24, measuredSize.y);
|
|
46
|
+
const hz = Math.max(.7, measuredSize.z);
|
|
47
|
+
const hullCenter = [
|
|
48
|
+
r4(measuredCenter.x),
|
|
49
|
+
r4(measuredCenter.y),
|
|
50
|
+
r4(measuredCenter.z)
|
|
51
|
+
];
|
|
52
|
+
const hullSize = [
|
|
53
|
+
r4(hx),
|
|
54
|
+
r4(hy),
|
|
55
|
+
r4(hz)
|
|
56
|
+
];
|
|
57
|
+
let comX = measuredCenter.x;
|
|
58
|
+
let comY = (hullBox.isEmpty() ? groundClearance : hullBox.min.y) + hy * .36;
|
|
59
|
+
let comZ = measuredCenter.z;
|
|
60
|
+
let inertiaDiagonal;
|
|
61
|
+
if (partBoxes.length >= 2) {
|
|
62
|
+
const totalVol = partBoxes.reduce((s, p) => s + p.vol, 0);
|
|
63
|
+
let wx = 0, wy = 0, wz = 0;
|
|
64
|
+
for (const p of partBoxes) {
|
|
65
|
+
const w = p.vol / totalVol;
|
|
66
|
+
wx += p.center.x * w;
|
|
67
|
+
wy += p.center.y * w;
|
|
68
|
+
wz += p.center.z * w;
|
|
69
|
+
}
|
|
70
|
+
comX = wx;
|
|
71
|
+
comY = Math.min(wy, (hullBox.isEmpty() ? groundClearance : hullBox.min.y) + hy * .42);
|
|
72
|
+
comZ = wz;
|
|
73
|
+
let ix = 0, iy = 0, iz = 0;
|
|
74
|
+
for (const p of partBoxes) {
|
|
75
|
+
const m = chassisMass * (p.vol / totalVol);
|
|
76
|
+
const dx = p.center.x - comX, dy = p.center.y - comY, dz = p.center.z - comZ;
|
|
77
|
+
ix += m / 12 * (p.size.y * p.size.y + p.size.z * p.size.z) + m * (dy * dy + dz * dz);
|
|
78
|
+
iy += m / 12 * (p.size.x * p.size.x + p.size.z * p.size.z) + m * (dx * dx + dz * dz);
|
|
79
|
+
iz += m / 12 * (p.size.x * p.size.x + p.size.y * p.size.y) + m * (dx * dx + dy * dy);
|
|
80
|
+
}
|
|
81
|
+
inertiaDiagonal = [
|
|
82
|
+
r4(Math.max(20, ix)),
|
|
83
|
+
r4(Math.max(20, iy)),
|
|
84
|
+
r4(Math.max(15, iz))
|
|
85
|
+
];
|
|
86
|
+
} else inertiaDiagonal = boxInertia(chassisMass, hx, hy, hz);
|
|
87
|
+
const hullObj = new THREE.Object3D();
|
|
88
|
+
hullObj.name = "Chassis_Hull";
|
|
89
|
+
hullObj.position.set(hullCenter[0], hullCenter[1], hullCenter[2]);
|
|
90
|
+
chassis.add(hullObj);
|
|
91
|
+
const colliderSpec = {
|
|
92
|
+
nodeName: "Chassis_Hull",
|
|
93
|
+
collider: {
|
|
94
|
+
shape: {
|
|
95
|
+
type: "box",
|
|
96
|
+
size: hullSize
|
|
97
|
+
},
|
|
98
|
+
friction: .38,
|
|
99
|
+
restitution: .05
|
|
100
|
+
},
|
|
101
|
+
extras: { role: "chassis_hull" }
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
chassisMass,
|
|
105
|
+
centerOfMass: [
|
|
106
|
+
r4(comX),
|
|
107
|
+
r4(comY),
|
|
108
|
+
r4(comZ)
|
|
109
|
+
],
|
|
110
|
+
inertiaDiagonal,
|
|
111
|
+
inertiaOrientation: [
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
0,
|
|
115
|
+
1
|
|
116
|
+
],
|
|
117
|
+
hullNodeName: "Chassis_Hull",
|
|
118
|
+
hullCenter,
|
|
119
|
+
hullSize,
|
|
120
|
+
colliderSpec
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export { deriveChassisGeometryPlan };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=khrCarGeometryMass.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"khrCarGeometryMass.js","names":[],"sources":["../../src/importer/khrCarGeometryMass.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { KhrExportNodeSpec } from \"@khr3/core\";\nimport { boxInertia, r4 } from \"./khrCraftPropCompiler.js\";\nimport { isMeshObject } from \"./sceneSiNormalize.js\";\n\nexport interface DerivedChassisPlan {\n readonly chassisMass: number;\n readonly centerOfMass: [number, number, number];\n readonly inertiaDiagonal: [number, number, number];\n readonly inertiaOrientation: [number, number, number, number];\n readonly hullNodeName: \"Chassis_Hull\";\n readonly hullCenter: [number, number, number];\n readonly hullSize: [number, number, number];\n readonly colliderSpec: KhrExportNodeSpec;\n}\n\nexport function deriveChassisGeometryPlan(params: {\n readonly chassis: THREE.Group;\n readonly totalMass: number;\n readonly panelsMassKg: number;\n readonly size: readonly [number, number, number];\n readonly center: THREE.Vector3;\n readonly maxWheelRadius: number;\n}): DerivedChassisPlan {\n const { chassis, totalMass, panelsMassKg, size, center, maxWheelRadius } = params;\n const chassisMass = Math.max(80, totalMass - panelsMassKg);\n\n chassis.updateMatrixWorld(true);\n const invChassis = new THREE.Matrix4().copy(chassis.matrixWorld).invert();\n const relMat = new THREE.Matrix4();\n const v = new THREE.Vector3();\n\n const hullBox = new THREE.Box3();\n const partBoxes: Array<{ box: THREE.Box3; size: THREE.Vector3; center: THREE.Vector3; vol: number }> = [];\n\n chassis.traverse((obj) => {\n if (!isMeshObject(obj) || obj.name.startsWith(\"ArchLiner\")) return;\n const pos = obj.geometry.getAttribute(\"position\");\n if (!pos || pos.count === 0) return;\n relMat.multiplyMatrices(invChassis, obj.matrixWorld);\n const mb = new THREE.Box3();\n for (let i = 0; i < pos.count; i++) {\n v.fromBufferAttribute(pos, i).applyMatrix4(relMat);\n if (Number.isFinite(v.x) && Number.isFinite(v.y) && Number.isFinite(v.z)) {\n mb.expandByPoint(v);\n hullBox.expandByPoint(v);\n }\n }\n if (!mb.isEmpty()) {\n const pSize = mb.getSize(new THREE.Vector3());\n const pCenter = mb.getCenter(new THREE.Vector3());\n const vol = Math.max(1e-4, Math.max(0.02, pSize.x) * Math.max(0.02, pSize.y) * Math.max(0.02, pSize.z));\n partBoxes.push({ box: mb, size: pSize, center: pCenter, vol });\n }\n });\n\n const groundClearance = Math.max(0.08, Math.min(maxWheelRadius * 0.65, size[1] * 0.25));\n const fallbackSize = new THREE.Vector3(\n Math.max(0.4, size[0] * 0.85),\n Math.max(0.32, size[1] - groundClearance),\n Math.max(0.8, size[2] * 0.92),\n );\n const fallbackCenter = new THREE.Vector3(center.x, groundClearance + fallbackSize.y * 0.5, center.z);\n\n const measuredSize = hullBox.isEmpty() ? fallbackSize : hullBox.getSize(new THREE.Vector3());\n const measuredCenter = hullBox.isEmpty() ? fallbackCenter : hullBox.getCenter(new THREE.Vector3());\n const hx = Math.max(0.35, measuredSize.x);\n const hy = Math.max(0.24, measuredSize.y);\n const hz = Math.max(0.7, measuredSize.z);\n const hullCenter: [number, number, number] = [r4(measuredCenter.x), r4(measuredCenter.y), r4(measuredCenter.z)];\n const hullSize: [number, number, number] = [r4(hx), r4(hy), r4(hz)];\n\n let comX = measuredCenter.x;\n let comY = (hullBox.isEmpty() ? groundClearance : hullBox.min.y) + hy * 0.36;\n let comZ = measuredCenter.z;\n let inertiaDiagonal: [number, number, number];\n\n if (partBoxes.length >= 2) {\n const totalVol = partBoxes.reduce((s, p) => s + p.vol, 0);\n let wx = 0, wy = 0, wz = 0;\n for (const p of partBoxes) {\n const w = p.vol / totalVol;\n wx += p.center.x * w;\n wy += p.center.y * w;\n wz += p.center.z * w;\n }\n comX = wx;\n comY = Math.min(wy, (hullBox.isEmpty() ? groundClearance : hullBox.min.y) + hy * 0.42);\n comZ = wz;\n let ix = 0, iy = 0, iz = 0;\n for (const p of partBoxes) {\n const m = chassisMass * (p.vol / totalVol);\n const dx = p.center.x - comX, dy = p.center.y - comY, dz = p.center.z - comZ;\n ix += (m / 12) * (p.size.y * p.size.y + p.size.z * p.size.z) + m * (dy * dy + dz * dz);\n iy += (m / 12) * (p.size.x * p.size.x + p.size.z * p.size.z) + m * (dx * dx + dz * dz);\n iz += (m / 12) * (p.size.x * p.size.x + p.size.y * p.size.y) + m * (dx * dx + dy * dy);\n }\n inertiaDiagonal = [\n r4(Math.max(20, ix)),\n r4(Math.max(20, iy)),\n r4(Math.max(15, iz)),\n ];\n } else {\n inertiaDiagonal = boxInertia(chassisMass, hx, hy, hz);\n }\n\n const hullObj = new THREE.Object3D();\n hullObj.name = \"Chassis_Hull\";\n hullObj.position.set(hullCenter[0], hullCenter[1], hullCenter[2]);\n chassis.add(hullObj);\n\n const colliderSpec: KhrExportNodeSpec = {\n nodeName: \"Chassis_Hull\",\n collider: {\n shape: { type: \"box\", size: hullSize },\n friction: 0.38,\n restitution: 0.05,\n },\n extras: { role: \"chassis_hull\" },\n };\n\n return {\n chassisMass,\n centerOfMass: [r4(comX), r4(comY), r4(comZ)],\n inertiaDiagonal,\n inertiaOrientation: [0, 0, 0, 1],\n hullNodeName: \"Chassis_Hull\",\n hullCenter,\n hullSize,\n colliderSpec,\n };\n}\n"],"mappings":";;;;AAgBA,SAAgB,0BAA0B,QAOnB;CACnB,MAAM,EAAE,SAAS,WAAW,cAAc,MAAM,QAAQ,mBAAmB;CAC3E,MAAM,cAAc,KAAK,IAAI,IAAI,YAAY,YAAY;CAEzD,QAAQ,kBAAkB,IAAI;CAC9B,MAAM,aAAa,IAAI,MAAM,QAAQ,CAAC,CAAC,KAAK,QAAQ,WAAW,CAAC,CAAC,OAAO;CACxE,MAAM,SAAS,IAAI,MAAM,QAAQ;CACjC,MAAM,IAAI,IAAI,MAAM,QAAQ;CAE5B,MAAM,UAAU,IAAI,MAAM,KAAK;CAC/B,MAAM,YAAiG,CAAC;CA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IAAI,MAAM,KAAK,EAAE,OAAO,IAAI;GACxE,MAAO,IAAI,MAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;GACnF,MAAO,IAAI,MAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;GACnF,MAAO,IAAI,MAAO,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,IAAI,EAAE,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;EACvF;EACA,kBAAkB;GACd,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;GACnB,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;GACnB,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;EACvB;CACJ,OACI,kBAAkB,WAAW,aAAa,IAAI,IAAI,EAAE;CAGxD,MAAM,UAAU,IAAI,MAAM,SAAS;CACnC,QAAQ,OAAO;CACf,QAAQ,SAAS,IAAI,WAAW,IAAI,WAAW,IAAI,WAAW,EAAE;CAChE,QAAQ,IAAI,OAAO;CAEnB,MAAM,eAAkC;EACpC,UAAU;EACV,UAAU;GACN,OAAO;IAAE,MAAM;IAAO,MAAM;GAAS;GACrC,UAAU;GACV,aAAa;EACjB;EACA,QAAQ,EAAE,MAAM,eAAe;CACnC;CAEA,OAAO;EACH;EACA,cAAc;GAAC,GAAG,IAAI;GAAG,GAAG,IAAI;GAAG,GAAG,IAAI;EAAC;EAC3C;EACA,oBAAoB;GAAC;GAAG;GAAG;GAAG;EAAC;EAC/B,cAAc;EACd;EACA;EACA;CACJ;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extractMeshIslands } from "./meshIslands.js";
|
|
2
2
|
import { isMeshObject } from "./sceneSiNormalize.js";
|
|
3
|
-
import { createFleet12GonWheelGroup } from "./surfacePeel.js";
|
|
4
3
|
import { separateVehicleMeshes } from "./vehiclePartSplit.js";
|
|
4
|
+
import { createFleet12GonWheelGroup } from "./surfacePeel.js";
|
|
5
5
|
import { CHOP_ROLES } from "./surfaceTopology.js";
|
|
6
6
|
import { computeChopPartHinge } from "./chopHingeHelpers.js";
|
|
7
7
|
import { measureSelection } from "./wheelAxlePairing.js";
|
|
@@ -12,14 +12,8 @@ function collectArchLinerNodes(normalizedScene) {
|
|
|
12
12
|
}
|
|
13
13
|
function collectCarChassisExcludeSet(normalizedScene, linerNodes) {
|
|
14
14
|
const excludeSet = new Set(linerNodes);
|
|
15
|
-
if (normalizedScene.children.some((c) => c.name === "ChassisVisuals"))
|
|
16
|
-
|
|
17
|
-
"Wheel_FR",
|
|
18
|
-
"Wheel_RL",
|
|
19
|
-
"Wheel_RR"
|
|
20
|
-
]) {
|
|
21
|
-
const wObj = normalizedScene.children.find((c) => c.name === wn);
|
|
22
|
-
if (wObj) excludeSet.add(wObj);
|
|
15
|
+
if (normalizedScene.children.some((c) => c.name === "ChassisVisuals")) {
|
|
16
|
+
for (const c of normalizedScene.children) if (/^Wheel_/i.test(c.name)) excludeSet.add(c);
|
|
23
17
|
}
|
|
24
18
|
return excludeSet.size > 0 ? excludeSet : void 0;
|
|
25
19
|
}
|
|
@@ -82,7 +76,7 @@ function buildPanelSpecs(islands, partPicks, wheelIslandIds) {
|
|
|
82
76
|
return out;
|
|
83
77
|
}
|
|
84
78
|
function resolveCarWheels(islands, axles, driveType, size) {
|
|
85
|
-
const validAxles = axles.filter((a) => a.left.length > 0);
|
|
79
|
+
const validAxles = axles.filter((a) => a.left.length > 0 || a.right.length > 0);
|
|
86
80
|
if (validAxles.length > 0) {
|
|
87
81
|
const ordered = validAxles.map((a) => ({
|
|
88
82
|
a,
|
|
@@ -91,7 +85,8 @@ function resolveCarWheels(islands, axles, driveType, size) {
|
|
|
91
85
|
const totalAxles = ordered.length;
|
|
92
86
|
const plans = [];
|
|
93
87
|
ordered.forEach(({ a: axle }, idx) => {
|
|
94
|
-
const
|
|
88
|
+
const single = axle.left.length === 0 || axle.right.length === 0;
|
|
89
|
+
const lb = measureSelection(islands, axle.left.length > 0 ? axle.left : axle.right);
|
|
95
90
|
const rb = axle.right.length > 0 ? measureSelection(islands, axle.right) : lb;
|
|
96
91
|
const radius = Math.max(.12, lb.radius, rb.radius);
|
|
97
92
|
const width = Math.max(.09, Math.max(lb.halfWidth, rb.halfWidth) * 2);
|
|
@@ -99,10 +94,10 @@ function resolveCarWheels(islands, axles, driveType, size) {
|
|
|
99
94
|
const steered = axle.steered ?? idx === 0;
|
|
100
95
|
const driven = axle.driven ?? autoDrive;
|
|
101
96
|
const brake = axle.brake ?? true;
|
|
102
|
-
const tag = totalAxles === 2 ? idx === 0 ? "F" : "R" : `A${idx}`;
|
|
103
|
-
if (
|
|
97
|
+
const tag = totalAxles === 2 ? idx === 0 ? "F" : "R" : totalAxles === 3 ? idx === 0 ? "F" : idx === 1 ? "M" : "R" : `A${idx}`;
|
|
98
|
+
if (single) plans.push({
|
|
104
99
|
nodeName: `Wheel_${tag}C`,
|
|
105
|
-
islandIds: [...axle.left],
|
|
100
|
+
islandIds: [...axle.left, ...axle.right],
|
|
106
101
|
radius,
|
|
107
102
|
width,
|
|
108
103
|
steered,
|
|
@@ -196,13 +191,8 @@ function resolveCarWheels(islands, axles, driveType, size) {
|
|
|
196
191
|
function tryExtractPreCoredCar(normalizedScene, chassis, exportRoot, opts, driveType) {
|
|
197
192
|
const chassisVis = normalizedScene.children.find((c) => c.name === "ChassisVisuals");
|
|
198
193
|
if (!chassisVis) return null;
|
|
199
|
-
const wheelObjs =
|
|
200
|
-
|
|
201
|
-
"Wheel_FR",
|
|
202
|
-
"Wheel_RL",
|
|
203
|
-
"Wheel_RR"
|
|
204
|
-
].map((n) => normalizedScene.children.find((c) => c.name === n) ?? null);
|
|
205
|
-
if (wheelObjs.some((w) => !w)) return null;
|
|
194
|
+
const wheelObjs = normalizedScene.children.filter((c) => /^Wheel_/i.test(c.name));
|
|
195
|
+
if (wheelObjs.length < 2) return null;
|
|
206
196
|
const userSubtrees = [];
|
|
207
197
|
const coveredSourceNodes = /* @__PURE__ */ new Set();
|
|
208
198
|
let panels = [];
|
|
@@ -253,8 +243,8 @@ function tryExtractPreCoredCar(normalizedScene, chassis, exportRoot, opts, drive
|
|
|
253
243
|
const fwd = driveType === "AWD" || driveType === "FWD", rwd = driveType === "AWD" || driveType === "RWD";
|
|
254
244
|
const wheels = [];
|
|
255
245
|
const wheelZs = [];
|
|
246
|
+
const midZ = wheelObjs.reduce((s, o) => s + o.position.z, 0) / wheelObjs.length;
|
|
256
247
|
for (const src of wheelObjs) {
|
|
257
|
-
if (!src) continue;
|
|
258
248
|
const cutter = cutterByName.get(src.name);
|
|
259
249
|
const lb = new THREE.Box3();
|
|
260
250
|
const v = new THREE.Vector3();
|
|
@@ -279,7 +269,7 @@ function tryExtractPreCoredCar(normalizedScene, chassis, exportRoot, opts, drive
|
|
|
279
269
|
});
|
|
280
270
|
coveredSourceNodes.add(src);
|
|
281
271
|
}
|
|
282
|
-
const isFront = src.name.includes("_F");
|
|
272
|
+
const isFront = cutter ? cutter.axle === "front" : src.name.includes("_F") || src.position.z > midZ;
|
|
283
273
|
wheels.push({
|
|
284
274
|
nodeName: src.name,
|
|
285
275
|
islandIds: [],
|