@pinkaphant/kolmo 0.4.4 → 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 +2 -0
- package/dist/engine/index.js +7 -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 +2 -0
- package/dist/engine/kolmoInput.js +12 -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/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/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 +1 -0
- package/dist/engine/kolmoVehicleDriver.js +26 -50
- package/dist/engine/kolmoVehicleDriver.js.map +1 -1
- package/dist/engine/kolmoVehicleInner.js +31 -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 +2 -2
- package/dist/importer/WheelRingHandles3D.js +2 -1
- package/dist/importer/WheelRingHandles3D.js.map +1 -1
- package/dist/importer/chopShopActions.js +20 -16
- package/dist/importer/chopShopActions.js.map +1 -1
- package/dist/importer/chopShopHandlers.js +16 -9
- 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 +7 -3
- 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 +12 -22
- 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/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 +69 -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 +20 -7
- 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/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 -125
- package/package.json +14 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proceduralPersonAndProp.js","names":[],"sources":["../../src/importer/proceduralPersonAndProp.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { DOOR_HINGE_SPEC } from \"@khr3/c12\";\nimport {\n addKolmoSocket,\n addPartBox,\n buildDoorLeafMesh,\n makeFlatMat,\n type ProceduralRecipeSpec,\n} from \"./proceduralC12AndCraft.js\";\n\nexport type PersonProceduralRecipeId =\n | \"astronaut_eva\"\n | \"street_runner\"\n | \"mech_pilot\"\n | \"bandit_raider\";\n\nexport type PropProceduralRecipeId =\n | \"arcade_cabinet\"\n | \"vending_machine\"\n | \"fuel_pump\"\n | \"holo_terminal\"\n | \"supply_locker\";\n\nexport const PERSON_PROCEDURAL_RECIPES: readonly ProceduralRecipeSpec<PersonProceduralRecipeId>[] = Object.freeze([\n { id: \"astronaut_eva\", label: \"Astronaut EVA\", domain: \"person\", targetMeters: 1.75, massKg: 84, color: \"#f8fafc\" },\n { id: \"street_runner\", label: \"Street Runner\", domain: \"person\", targetMeters: 1.75, massKg: 70, color: \"#06b6d4\" },\n { id: \"mech_pilot\", label: \"Mech Pilot\", domain: \"person\", targetMeters: 1.75, massKg: 76, color: \"#10b981\" },\n { id: \"bandit_raider\", label: \"Bandit Raider\", domain: \"person\", targetMeters: 1.75, massKg: 82, color: \"#ef4444\" },\n]);\n\nexport const PROP_PROCEDURAL_RECIPES: readonly ProceduralRecipeSpec<PropProceduralRecipeId>[] = Object.freeze([\n { id: \"arcade_cabinet\", label: \"Arcade Cabinet\", domain: \"prop\", targetMeters: 1.82, massKg: 95, color: \"#38bdf8\" },\n { id: \"vending_machine\", label: \"Vending Machine\", domain: \"prop\", targetMeters: 1.9, massKg: 140, color: \"#ef4444\" },\n { id: \"fuel_pump\", label: \"Fuel Pump\", domain: \"prop\", targetMeters: 1.68, massKg: 85, color: \"#f59e0b\" },\n { id: \"holo_terminal\", label: \"Holo Terminal\", domain: \"prop\", targetMeters: 1.45, massKg: 60, color: \"#06b6d4\" },\n { id: \"supply_locker\", label: \"Supply Locker\", domain: \"prop\", targetMeters: 1.95, massKg: 78, color: \"#64748b\" },\n]);\n\ninterface PersonPalette {\n readonly suit: string;\n readonly secondary: string;\n readonly visor: string;\n readonly visorGlow?: string;\n readonly pack: string;\n readonly boot: string;\n}\n\nconst PERSON_PALETTES: Readonly<Record<PersonProceduralRecipeId, PersonPalette>> = {\n astronaut_eva: { suit: \"#f1f5f9\", secondary: \"#cbd5e1\", visor: \"#f59e0b\", pack: \"#e2e8f0\", boot: \"#475569\" },\n street_runner: { suit: \"#0891b2\", secondary: \"#1e293b\", visor: \"#fbbf24\", visorGlow: \"#f59e0b\", pack: \"#334155\", boot: \"#f8fafc\" },\n mech_pilot: { suit: \"#059669\", secondary: \"#334155\", visor: \"#34d399\", visorGlow: \"#10b981\", pack: \"#475569\", boot: \"#1e293b\" },\n bandit_raider: { suit: \"#b91c1c\", secondary: \"#27272a\", visor: \"#f87171\", visorGlow: \"#ef4444\", pack: \"#78350f\", boot: \"#18181b\" },\n};\n\nexport function buildProceduralPersonScene(recipeOrId: PersonProceduralRecipeId | ProceduralRecipeSpec | string = \"astronaut_eva\"): THREE.Group {\n const id = (typeof recipeOrId === \"string\" ? recipeOrId : recipeOrId.id) as PersonProceduralRecipeId;\n const pal = PERSON_PALETTES[id] ?? PERSON_PALETTES.astronaut_eva;\n const root = new THREE.Group();\n root.name = id;\n\n const suitMat = makeFlatMat(pal.suit, 0.54, 0.16);\n const secMat = makeFlatMat(pal.secondary, 0.62, 0.2);\n const visorMat = makeFlatMat(pal.visor, 0.18, 0.72, pal.visorGlow);\n const packMat = makeFlatMat(pal.pack, 0.5, 0.28);\n const bootMat = makeFlatMat(pal.boot, 0.68, 0.18);\n\n // Exact 1.75 m standing stature grounded at y = 0.00 m with top of Helmet at y = 1.75 m\n addPartBox(root, \"Pelvis\", 0.31, 0.16, 0.21, 0, 0.92, 0, secMat);\n addPartBox(root, \"Torso\", 0.38, 0.44, 0.24, 0, 1.23, 0, suitMat);\n addPartBox(root, \"NeckCollar\", 0.2, 0.05, 0.2, 0, 1.47, 0, secMat);\n addPartBox(root, \"Helmet\", 0.26, 0.26, 0.27, 0, 1.62, 0.01, id === \"street_runner\" ? secMat : suitMat);\n addPartBox(root, \"Visor\", 0.22, 0.12, 0.06, 0, 1.62, 0.13, visorMat);\n\n const packH = id === \"astronaut_eva\" ? 0.42 : 0.3;\n addPartBox(root, \"Backpack\", 0.3, packH, 0.14, 0, 1.24, -0.18, packMat);\n if (id === \"astronaut_eva\") {\n addPartBox(root, \"ChestControlUnit\", 0.18, 0.14, 0.06, 0, 1.26, 0.14, packMat);\n } else if (id === \"mech_pilot\" || id === \"bandit_raider\") {\n addPartBox(root, \"ChestArmorPlate\", 0.34, 0.24, 0.05, 0, 1.28, 0.13, packMat);\n }\n\n for (const [tag, sx] of [[\"L\", -1], [\"R\", 1]] as const) {\n addPartBox(root, `Shoulder_${tag}`, 0.13, 0.12, 0.15, sx * 0.255, 1.38, 0, id === \"bandit_raider\" && tag === \"L\" ? visorMat : suitMat);\n addPartBox(root, `UpperArm_${tag}`, 0.11, 0.25, 0.11, sx * 0.26, 1.2, 0.02, suitMat);\n const fore = addPartBox(root, `Forearm_${tag}`, 0.1, 0.24, 0.1, sx * 0.25, 1.02, 0.11, secMat);\n fore.rotation.x = -0.45;\n addPartBox(root, `Glove_${tag}`, 0.09, 0.09, 0.11, sx * 0.24, 0.94, 0.21, bootMat);\n\n addPartBox(root, `Thigh_${tag}`, 0.14, 0.38, 0.15, sx * 0.095, 0.65, 0, secMat);\n addPartBox(root, `Shin_${tag}`, 0.12, 0.34, 0.13, sx * 0.095, 0.29, 0, suitMat);\n addPartBox(root, `Boot_${tag}`, 0.13, 0.12, 0.23, sx * 0.095, 0.06, 0.035, bootMat);\n }\n\n addKolmoSocket(root, \"Socket_Hand_R\", [0.24, 0.94, 0.24], \"grip_primary\");\n addKolmoSocket(root, \"Socket_Hand_L\", [-0.24, 0.94, 0.24], \"grip_secondary\");\n addKolmoSocket(root, \"butt\", [0, 0.88, -0.03], \"seat\");\n addKolmoSocket(root, \"Socket_Head\", [0, 1.62, 0.14], \"optic\");\n\n root.userData = { proceduralDomain: \"person\", proceduralRecipeId: id };\n return root;\n}\n\nexport function buildProceduralPropScene(recipeOrId: PropProceduralRecipeId | ProceduralRecipeSpec | string = \"arcade_cabinet\"): THREE.Group {\n const id = (typeof recipeOrId === \"string\" ? recipeOrId : recipeOrId.id) as PropProceduralRecipeId;\n const root = new THREE.Group();\n root.name = id;\n const darkMat = makeFlatMat(\"#18181b\", 0.56, 0.26);\n const steelMat = makeFlatMat(\"#94a3b8\", 0.38, 0.68);\n const cyanGlow = makeFlatMat(\"#22d3ee\", 0.2, 0.1, \"#06b6d4\");\n const amberGlow = makeFlatMat(\"#fbbf24\", 0.24, 0.12, \"#f59e0b\");\n\n if (id === \"vending_machine\") {\n const bodyMat = makeFlatMat(\"#dc2626\", 0.45, 0.24);\n const glassMat = new THREE.MeshStandardMaterial({ color: \"#bae6fd\", transparent: true, opacity: 0.38, roughness: 0.1, flatShading: true });\n addPartBox(root, \"CabinetShell\", 0.96, 1.86, 0.78, 0, 0.97, 0, bodyMat);\n addPartBox(root, \"BaseFeet\", 0.92, 0.04, 0.74, 0, 0.02, 0, darkMat);\n addPartBox(root, \"DisplayBack\", 0.62, 1.05, 0.18, -0.1, 1.24, 0.28, darkMat);\n for (const [si, sy] of [[0, 0.88], [1, 1.18], [2, 1.48]] as const) {\n addPartBox(root, `Shelf_${si}`, 0.58, 0.025, 0.16, -0.1, sy, 0.3, steelMat);\n for (let c = 0; c < 4; c++) {\n const can = new THREE.Mesh(new THREE.CylinderGeometry(0.035, 0.035, 0.11, 8), c % 2 === 0 ? cyanGlow : amberGlow);\n can.name = `StockCan_${si}_${c}`;\n can.position.set(-0.3 + c * 0.13, sy + 0.07, 0.31);\n root.add(can);\n }\n }\n addPartBox(root, \"DisplayWindow\", 0.62, 1.06, 0.02, -0.1, 1.24, 0.395, glassMat);\n addPartBox(root, \"SelectPanel\", 0.2, 0.85, 0.03, 0.33, 1.22, 0.395, darkMat);\n addPartBox(root, \"PickupChute\", 0.56, 0.2, 0.06, -0.1, 0.34, 0.39, darkMat);\n } else if (id === \"fuel_pump\") {\n const pumpMat = makeFlatMat(\"#f59e0b\", 0.44, 0.22);\n addPartBox(root, \"IslandPlinth\", 0.82, 0.1, 0.58, 0, 0.05, 0, steelMat);\n addPartBox(root, \"PumpHousing\", 0.62, 1.24, 0.38, 0, 0.72, 0, pumpMat);\n addPartBox(root, \"MeterBezel\", 0.46, 0.34, 0.04, 0, 1.02, 0.2, darkMat);\n addPartBox(root, \"MeterDisplay\", 0.38, 0.2, 0.02, 0, 1.04, 0.22, cyanGlow);\n const globe = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.2, 0.1, 12), amberGlow);\n globe.name = \"TopperGlobe\"; globe.rotation.x = Math.PI * 0.5; globe.position.set(0, 1.54, 0); root.add(globe);\n addPartBox(root, \"TopperNeck\", 0.12, 0.12, 0.1, 0, 1.4, 0, steelMat);\n addPartBox(root, \"NozzleBoot\", 0.08, 0.24, 0.14, 0.35, 0.88, 0, darkMat);\n addPartBox(root, \"FuelNozzle\", 0.05, 0.2, 0.12, 0.38, 0.92, 0.06, steelMat);\n addPartBox(root, \"HoseLoop\", 0.04, 0.48, 0.22, 0.38, 0.58, 0.02, darkMat);\n } else if (id === \"holo_terminal\") {\n const pedMat = makeFlatMat(\"#1e293b\", 0.48, 0.36);\n const base = new THREE.Mesh(new THREE.CylinderGeometry(0.36, 0.46, 0.14, 8), steelMat);\n base.name = \"PedestalBase\"; base.position.y = 0.07; root.add(base);\n const col = new THREE.Mesh(new THREE.CylinderGeometry(0.18, 0.24, 0.82, 8), pedMat);\n col.name = \"PedestalColumn\"; col.position.y = 0.55; root.add(col);\n const deck = addPartBox(root, \"ConsoleDeck\", 0.68, 0.1, 0.44, 0, 0.98, 0.08, pedMat);\n deck.rotation.x = 0.32;\n addPartBox(root, \"KeyMatrix\", 0.48, 0.03, 0.22, 0, 1.03, 0.14, amberGlow);\n const ring = new THREE.Mesh(new THREE.TorusGeometry(0.18, 0.025, 6, 10), steelMat);\n ring.name = \"EmitterRing\"; ring.rotation.x = Math.PI * 0.5; ring.position.set(0, 1.08, -0.04); root.add(ring);\n const holo = new THREE.Mesh(new THREE.OctahedronGeometry(0.2, 0), cyanGlow);\n holo.name = \"HoloProjection\"; holo.position.set(0, 1.32, -0.04); root.add(holo);\n } else if (id === \"supply_locker\") {\n const lockerMat = makeFlatMat(\"#475569\", 0.52, 0.45);\n const W = 0.78, H = 1.95, D = 0.52, t = 0.04;\n addPartBox(root, \"LockerBottom\", W, 0.06, D, 0, 0.03, 0, darkMat);\n addPartBox(root, \"LockerTop\", W, t, D, 0, H - t * 0.5, 0, lockerMat);\n addPartBox(root, \"LockerBack\", W, H - 0.1, t, 0, H * 0.5, -D * 0.5 + t * 0.5, lockerMat);\n addPartBox(root, \"LockerWall_L\", t, H - 0.1, D - t, -W * 0.5 + t * 0.5, H * 0.5, t * 0.5, lockerMat);\n addPartBox(root, \"LockerWall_R\", t, H - 0.1, D - t, W * 0.5 - t * 0.5, H * 0.5, t * 0.5, lockerMat);\n addPartBox(root, \"ShelfMid\", W - t * 2, 0.03, D - 0.08, 0, 0.98, 0, steelMat);\n addPartBox(root, \"ShelfUpper\", W - t * 2, 0.03, D - 0.08, 0, 1.48, 0, steelMat);\n const hingePos: [number, number, number] = [-W * 0.5 + t, 0.06, D * 0.5 - 0.02];\n const leaf = buildDoorLeafMesh(W - t * 2 - 0.01, H - 0.12, 0.032, 0x64748b, 0xfbbf24);\n leaf.position.set(...hingePos);\n leaf.userData = { c12Role: \"DoorLeaf\", hingeOffsetLocal: hingePos, limitsRad: [...DOOR_HINGE_SPEC.limitsRad] };\n root.add(leaf);\n addKolmoSocket(root, \"Socket_DoorHinge\", hingePos, \"hinge\");\n } else {\n const cabMat = makeFlatMat(\"#1d4ed8\", 0.46, 0.22), trimMat = makeFlatMat(\"#38bdf8\", 0.4, 0.25);\n addPartBox(root, \"CabinetBase\", 0.74, 0.92, 0.72, 0, 0.46, 0, cabMat);\n addPartBox(root, \"SideCheek_L\", 0.05, 1.78, 0.74, -0.37, 0.89, 0, trimMat);\n addPartBox(root, \"SideCheek_R\", 0.05, 1.78, 0.74, 0.37, 0.89, 0, trimMat);\n addPartBox(root, \"RearBackbox\", 0.69, 0.86, 0.34, 0, 1.35, -0.19, cabMat);\n const crt = addPartBox(root, \"CRT_Screen\", 0.58, 0.46, 0.06, 0, 1.24, 0.08, cyanGlow);\n crt.rotation.x = -0.38;\n addPartBox(root, \"MarqueeHood\", 0.7, 0.22, 0.42, 0, 1.71, 0.14, cabMat);\n addPartBox(root, \"MarqueeSign\", 0.64, 0.16, 0.04, 0, 1.7, 0.35, amberGlow);\n const deck = addPartBox(root, \"ControlDeck\", 0.7, 0.1, 0.32, 0, 0.94, 0.26, darkMat);\n deck.rotation.x = 0.16;\n addPartBox(root, \"JoystickShaft\", 0.02, 0.09, 0.02, -0.18, 1.01, 0.26, steelMat);\n const ball = new THREE.Mesh(new THREE.OctahedronGeometry(0.032, 0), makeFlatMat(\"#ef4444\", 0.28, 0.15));\n ball.name = \"JoystickBall\"; ball.position.set(-0.18, 1.06, 0.26); root.add(ball);\n for (let b = 0; b < 6; b++) {\n const bx = 0.04 + (b % 3) * 0.075, bz = 0.22 + Math.floor(b / 3) * 0.07;\n addPartBox(root, `ActionBtn_${b}`, 0.042, 0.025, 0.042, bx, 0.995, bz, b < 3 ? cyanGlow : amberGlow);\n }\n addPartBox(root, \"CoinDoor\", 0.38, 0.42, 0.03, 0, 0.44, 0.365, darkMat);\n addPartBox(root, \"CoinSlot_L\", 0.05, 0.08, 0.02, -0.07, 0.52, 0.38, amberGlow);\n addPartBox(root, \"CoinSlot_R\", 0.05, 0.08, 0.02, 0.07, 0.52, 0.38, amberGlow);\n addKolmoSocket(root, \"screen_rect\", [0, 1.24, 0.12], \"optic\");\n }\n\n root.userData = { proceduralDomain: \"prop\", proceduralRecipeId: id };\n return root;\n}\n"],"mappings":";;;;AAuBA,IAAa,4BAAuF,OAAO,OAAO;CAC9G;EAAE,IAAI;EAAiB,OAAO;EAAiB,QAAQ;EAAU,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;CAClH;EAAE,IAAI;EAAiB,OAAO;EAAiB,QAAQ;EAAU,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;CAClH;EAAE,IAAI;EAAc,OAAO;EAAc,QAAQ;EAAU,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;CAC5G;EAAE,IAAI;EAAiB,OAAO;EAAiB,QAAQ;EAAU,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;AACtH,CAAC;AAED,IAAa,0BAAmF,OAAO,OAAO;CAC1G;EAAE,IAAI;EAAkB,OAAO;EAAkB,QAAQ;EAAQ,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;CAClH;EAAE,IAAI;EAAmB,OAAO;EAAmB,QAAQ;EAAQ,cAAc;EAAK,QAAQ;EAAK,OAAO;CAAU;CACpH;EAAE,IAAI;EAAa,OAAO;EAAa,QAAQ;EAAQ,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;CACxG;EAAE,IAAI;EAAiB,OAAO;EAAiB,QAAQ;EAAQ,cAAc;EAAM,QAAQ;EAAI,OAAO;CAAU;CAChH;EAAE,IAAI;EAAiB,OAAO;EAAiB,QAAQ;EA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AK,KAAM,GAAG,KAAM,KAAM,OAAO;EACnF,KAAK,SAAS,IAAI;EAClB,WAAW,MAAM,iBAAiB,KAAM,KAAM,KAAM,MAAO,MAAM,KAAM,QAAQ;EAC/E,MAAM,OAAO,IAAI,MAAM,KAAK,IAAI,MAAM,mBAAmB,MAAO,CAAC,GAAG,YAAY,WAAW,KAAM,GAAI,CAAC;EACtG,KAAK,OAAO;EAAgB,KAAK,SAAS,IAAI,MAAO,MAAM,GAAI;EAAG,KAAK,IAAI,IAAI;EAC/E,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;GACxB,MAAM,KAAK,MAAQ,IAAI,IAAK,MAAO,KAAK,MAAO,KAAK,MAAM,IAAI,CAAC,IAAI;GACnE,WAAW,MAAM,aAAa,KAAK,MAAO,MAAO,MAAO,IAAI,MAAO,IAAI,IAAI,IAAI,WAAW,SAAS;EACvG;EACA,WAAW,MAAM,YAAY,KAAM,KAAM,KAAM,GAAG,KAAM,MAAO,OAAO;EACtE,WAAW,MAAM,cAAc,KAAM,KAAM,KAAM,MAAO,KAAM,KAAM,SAAS;EAC7E,WAAW,MAAM,cAAc,KAAM,KAAM,KAAM,KAAM,KAAM,KAAM,SAAS;EAC5E,eAAe,MAAM,eAAe;GAAC;GAAG;GAAM;EAAI,GAAG,OAAO;CAChE;CAEA,KAAK,WAAW;EAAE,kBAAkB;EAAQ,oBAAoB;CAAG;CACnE,OAAO;AACX"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
import type { GateDomain } from "./gateStore.js";
|
|
3
|
-
export
|
|
3
|
+
export type StarterDomainKey = GateDomain | "craft" | "sand3d";
|
|
4
|
+
export declare function registerSand3dStarterFactory(factory: ((recipeId?: string) => THREE.Group) | null): void;
|
|
5
|
+
export declare function makeStarterDomainScene(domain: StarterDomainKey, subOrRecipe?: string): THREE.Group;
|
|
@@ -1,8 +1,39 @@
|
|
|
1
|
+
import { buildSuikaTierScene } from "../suika/suikaGeometry.js";
|
|
1
2
|
import { KOLMOGOROV_CARBINE, buildLauncherSceneFromPlan } from "./launcherBake.js";
|
|
3
|
+
import { buildProceduralJunkScene } from "../junk/junkProceduralScenes.js";
|
|
4
|
+
import { buildProceduralC12Scene } from "./proceduralC12AndCraft.js";
|
|
5
|
+
import { buildProceduralPersonScene, buildProceduralPropScene } from "./proceduralPersonAndProp.js";
|
|
6
|
+
import { buildProceduralCraftScene } from "./proceduralDomainBuilders.js";
|
|
2
7
|
import * as THREE from "three";
|
|
3
8
|
import { buildPaperShellAssembly } from "@khr3/vehicles/paper-shell";
|
|
4
9
|
import { planLauncher } from "@khr3/launchers";
|
|
5
10
|
// src/importer/starterScene.ts
|
|
11
|
+
var sand3dStarterFactory = null;
|
|
12
|
+
function registerSand3dStarterFactory(factory) {
|
|
13
|
+
sand3dStarterFactory = factory;
|
|
14
|
+
}
|
|
15
|
+
function buildSand3dFallbackBracket() {
|
|
16
|
+
const group = new THREE.Group();
|
|
17
|
+
group.name = "cnc_mounting_bracket";
|
|
18
|
+
const mat = new THREE.MeshStandardMaterial({
|
|
19
|
+
color: "#38bdf8",
|
|
20
|
+
roughness: .42,
|
|
21
|
+
metalness: .55,
|
|
22
|
+
flatShading: true
|
|
23
|
+
});
|
|
24
|
+
const base = new THREE.Mesh(new THREE.BoxGeometry(.8, .08, .4), mat);
|
|
25
|
+
base.name = "BracketBase";
|
|
26
|
+
base.position.set(0, .04, 0);
|
|
27
|
+
const flange = new THREE.Mesh(new THREE.BoxGeometry(.8, .36, .08), mat);
|
|
28
|
+
flange.name = "BracketFlange";
|
|
29
|
+
flange.position.set(0, .26, -.16);
|
|
30
|
+
group.add(base, flange);
|
|
31
|
+
group.userData = {
|
|
32
|
+
proceduralDomain: "sand3d",
|
|
33
|
+
proceduralRecipeId: "cnc_mounting_bracket"
|
|
34
|
+
};
|
|
35
|
+
return group;
|
|
36
|
+
}
|
|
6
37
|
function buildFusedCoupeStarterMesh() {
|
|
7
38
|
const asm = buildPaperShellAssembly("coupe_86", "dc-smooth");
|
|
8
39
|
const posChunks = [];
|
|
@@ -56,28 +87,53 @@ function buildFusedCoupeStarterMesh() {
|
|
|
56
87
|
mesh.name = "Coupe86_OneBlob";
|
|
57
88
|
return mesh;
|
|
58
89
|
}
|
|
59
|
-
function makeStarterDomainScene(domain) {
|
|
60
|
-
const group = new THREE.Group();
|
|
61
|
-
group.name = `Starter_${domain}`;
|
|
90
|
+
function makeStarterDomainScene(domain, subOrRecipe) {
|
|
62
91
|
if (domain === "vehicle") {
|
|
92
|
+
if (subOrRecipe === "craft" || subOrRecipe && subOrRecipe.includes("_") && subOrRecipe !== "coupe_86") {
|
|
93
|
+
const craft = buildProceduralCraftScene(subOrRecipe === "craft" ? void 0 : subOrRecipe);
|
|
94
|
+
craft.name = `Starter_${craft.name}`;
|
|
95
|
+
return craft;
|
|
96
|
+
}
|
|
97
|
+
const group = new THREE.Group();
|
|
98
|
+
group.name = "Starter_vehicle";
|
|
63
99
|
group.add(buildFusedCoupeStarterMesh());
|
|
64
100
|
return group;
|
|
65
101
|
}
|
|
102
|
+
if (domain === "craft") {
|
|
103
|
+
const craft = buildProceduralCraftScene(subOrRecipe);
|
|
104
|
+
craft.name = `Starter_${craft.name}`;
|
|
105
|
+
return craft;
|
|
106
|
+
}
|
|
66
107
|
if (domain === "launcher") {
|
|
67
108
|
const forged = buildLauncherSceneFromPlan(planLauncher(KOLMOGOROV_CARBINE));
|
|
68
109
|
forged.userData.isProceduralLauncher = true;
|
|
69
110
|
return forged;
|
|
70
111
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
112
|
+
if (domain === "suika") return buildSuikaTierScene(0, { groundAtZero: true });
|
|
113
|
+
if (domain === "c12") {
|
|
114
|
+
const scene = buildProceduralC12Scene(subOrRecipe);
|
|
115
|
+
scene.name = `Starter_${scene.name}`;
|
|
116
|
+
return scene;
|
|
117
|
+
}
|
|
118
|
+
if (domain === "person") {
|
|
119
|
+
const scene = buildProceduralPersonScene(subOrRecipe);
|
|
120
|
+
scene.name = `Starter_${scene.name}`;
|
|
121
|
+
return scene;
|
|
122
|
+
}
|
|
123
|
+
if (domain === "prop") {
|
|
124
|
+
const scene = buildProceduralPropScene(subOrRecipe);
|
|
125
|
+
scene.name = `Starter_${scene.name}`;
|
|
126
|
+
return scene;
|
|
127
|
+
}
|
|
128
|
+
if (domain === "junk") {
|
|
129
|
+
const scene = buildProceduralJunkScene(subOrRecipe);
|
|
130
|
+
scene.name = `Starter_${scene.name}`;
|
|
131
|
+
return scene;
|
|
132
|
+
}
|
|
133
|
+
const sand = sand3dStarterFactory ? sand3dStarterFactory(subOrRecipe) : buildSand3dFallbackBracket();
|
|
134
|
+
sand.name = `Starter_${sand.name}`;
|
|
135
|
+
return sand;
|
|
80
136
|
}
|
|
81
|
-
export { makeStarterDomainScene };
|
|
137
|
+
export { makeStarterDomainScene, registerSand3dStarterFactory };
|
|
82
138
|
|
|
83
139
|
//# sourceMappingURL=starterScene.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"starterScene.js","names":[],"sources":["../../src/importer/starterScene.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { planLauncher } from \"@khr3/launchers\";\nimport { buildPaperShellAssembly } from \"@khr3/vehicles/paper-shell\";\nimport type { GateDomain } from \"./gateStore.js\";\nimport { KOLMOGOROV_CARBINE, buildLauncherSceneFromPlan } from \"./launcherBake.js\";\n\nfunction buildFusedCoupeStarterMesh(): THREE.Mesh {\n const asm = buildPaperShellAssembly(\"coupe_86\", \"dc-smooth\");\n const posChunks: number[] = [];\n const normChunks: number[] = [];\n const colChunks: number[] = [];\n const tmpColor = new THREE.Color();\n\n const appendPart = (positions: Float32Array, normals: Float32Array, ox: number, oy: number, oz: number, hex: number): void => {\n tmpColor.setHex(hex);\n for (let i = 0; i < positions.length; i += 3) {\n posChunks.push(positions[i] + ox, positions[i + 1] + oy, positions[i + 2] + oz);\n normChunks.push(normals[i], normals[i + 1], normals[i + 2]);\n colChunks.push(tmpColor.r, tmpColor.g, tmpColor.b);\n }\n };\n\n appendPart(asm.skateboardPositions, asm.skateboardNormals, 0, 0, 0, 0x1e242b);\n const skateVert0: [number, number, number] = [\n asm.skateboardPositions[0],\n asm.skateboardPositions[1],\n asm.skateboardPositions[2],\n ];\n for (const pan of asm.panels) {\n const px = pan.localPositions[0] + pan.anchorChassis[0];\n const py = pan.localPositions[1] + pan.anchorChassis[1];\n const pz = pan.localPositions[2] + pan.anchorChassis[2];\n posChunks.push(skateVert0[0], skateVert0[1], skateVert0[2], px, py, pz, skateVert0[0], skateVert0[1] + 0.02, skateVert0[2]);\n normChunks.push(0, 1, 0, 0, 1, 0, 0, 1, 0);\n colChunks.push(0.12, 0.14, 0.17, 0.12, 0.14, 0.17, 0.12, 0.14, 0.17);\n appendPart(pan.localPositions, pan.localNormals, pan.anchorChassis[0], pan.anchorChassis[1], pan.anchorChassis[2], pan.colorHex);\n }\n for (const w of asm.wheels) {\n const wx = w.positions[0] + w.position[0];\n const wy = w.positions[1] + w.position[1];\n const wz = w.positions[2] + w.position[2];\n posChunks.push(skateVert0[0], skateVert0[1], skateVert0[2], wx, wy, wz, skateVert0[0], skateVert0[1] + 0.02, skateVert0[2]);\n normChunks.push(0, 1, 0, 0, 1, 0, 0, 1, 0);\n colChunks.push(0.1, 0.12, 0.14, 0.1, 0.12, 0.14, 0.1, 0.12, 0.14);\n appendPart(w.positions, w.normals, w.position[0], w.position[1], w.position[2], 0x181c22);\n }\n\n const geo = new THREE.BufferGeometry();\n geo.setAttribute(\"position\", new THREE.Float32BufferAttribute(posChunks, 3));\n geo.setAttribute(\"normal\", new THREE.Float32BufferAttribute(normChunks, 3));\n geo.setAttribute(\"color\", new THREE.Float32BufferAttribute(colChunks, 3));\n geo.computeBoundingBox();\n geo.computeBoundingSphere();\n\n const mesh = new THREE.Mesh(\n geo,\n new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.52, metalness: 0.14, flatShading: true }),\n );\n mesh.name = \"Coupe86_OneBlob\";\n return mesh;\n}\n\nexport function makeStarterDomainScene(domain:
|
|
1
|
+
{"version":3,"file":"starterScene.js","names":[],"sources":["../../src/importer/starterScene.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { planLauncher } from \"@khr3/launchers\";\nimport { buildPaperShellAssembly } from \"@khr3/vehicles/paper-shell\";\nimport { buildSuikaTierScene } from \"../suika/suikaGeometry.js\";\nimport type { GateDomain } from \"./gateStore.js\";\nimport { KOLMOGOROV_CARBINE, buildLauncherSceneFromPlan } from \"./launcherBake.js\";\nimport {\n buildProceduralC12Scene,\n buildProceduralCraftScene,\n buildProceduralJunkScene,\n buildProceduralPersonScene,\n buildProceduralPropScene,\n} from \"./proceduralDomainBuilders.js\";\n\nexport type StarterDomainKey = GateDomain | \"craft\" | \"sand3d\";\n\nlet sand3dStarterFactory: ((recipeId?: string) => THREE.Group) | null = null;\n\nexport function registerSand3dStarterFactory(factory: ((recipeId?: string) => THREE.Group) | null): void {\n sand3dStarterFactory = factory;\n}\n\nfunction buildSand3dFallbackBracket(): THREE.Group {\n const group = new THREE.Group();\n group.name = \"cnc_mounting_bracket\";\n const mat = new THREE.MeshStandardMaterial({ color: \"#38bdf8\", roughness: 0.42, metalness: 0.55, flatShading: true });\n const base = new THREE.Mesh(new THREE.BoxGeometry(0.8, 0.08, 0.4), mat);\n base.name = \"BracketBase\";\n base.position.set(0, 0.04, 0);\n const flange = new THREE.Mesh(new THREE.BoxGeometry(0.8, 0.36, 0.08), mat);\n flange.name = \"BracketFlange\";\n flange.position.set(0, 0.26, -0.16);\n group.add(base, flange);\n group.userData = { proceduralDomain: \"sand3d\", proceduralRecipeId: \"cnc_mounting_bracket\" };\n return group;\n}\n\nfunction buildFusedCoupeStarterMesh(): THREE.Mesh {\n const asm = buildPaperShellAssembly(\"coupe_86\", \"dc-smooth\");\n const posChunks: number[] = [];\n const normChunks: number[] = [];\n const colChunks: number[] = [];\n const tmpColor = new THREE.Color();\n\n const appendPart = (positions: Float32Array, normals: Float32Array, ox: number, oy: number, oz: number, hex: number): void => {\n tmpColor.setHex(hex);\n for (let i = 0; i < positions.length; i += 3) {\n posChunks.push(positions[i] + ox, positions[i + 1] + oy, positions[i + 2] + oz);\n normChunks.push(normals[i], normals[i + 1], normals[i + 2]);\n colChunks.push(tmpColor.r, tmpColor.g, tmpColor.b);\n }\n };\n\n appendPart(asm.skateboardPositions, asm.skateboardNormals, 0, 0, 0, 0x1e242b);\n const skateVert0: [number, number, number] = [\n asm.skateboardPositions[0],\n asm.skateboardPositions[1],\n asm.skateboardPositions[2],\n ];\n for (const pan of asm.panels) {\n const px = pan.localPositions[0] + pan.anchorChassis[0];\n const py = pan.localPositions[1] + pan.anchorChassis[1];\n const pz = pan.localPositions[2] + pan.anchorChassis[2];\n posChunks.push(skateVert0[0], skateVert0[1], skateVert0[2], px, py, pz, skateVert0[0], skateVert0[1] + 0.02, skateVert0[2]);\n normChunks.push(0, 1, 0, 0, 1, 0, 0, 1, 0);\n colChunks.push(0.12, 0.14, 0.17, 0.12, 0.14, 0.17, 0.12, 0.14, 0.17);\n appendPart(pan.localPositions, pan.localNormals, pan.anchorChassis[0], pan.anchorChassis[1], pan.anchorChassis[2], pan.colorHex);\n }\n for (const w of asm.wheels) {\n const wx = w.positions[0] + w.position[0];\n const wy = w.positions[1] + w.position[1];\n const wz = w.positions[2] + w.position[2];\n posChunks.push(skateVert0[0], skateVert0[1], skateVert0[2], wx, wy, wz, skateVert0[0], skateVert0[1] + 0.02, skateVert0[2]);\n normChunks.push(0, 1, 0, 0, 1, 0, 0, 1, 0);\n colChunks.push(0.1, 0.12, 0.14, 0.1, 0.12, 0.14, 0.1, 0.12, 0.14);\n appendPart(w.positions, w.normals, w.position[0], w.position[1], w.position[2], 0x181c22);\n }\n\n const geo = new THREE.BufferGeometry();\n geo.setAttribute(\"position\", new THREE.Float32BufferAttribute(posChunks, 3));\n geo.setAttribute(\"normal\", new THREE.Float32BufferAttribute(normChunks, 3));\n geo.setAttribute(\"color\", new THREE.Float32BufferAttribute(colChunks, 3));\n geo.computeBoundingBox();\n geo.computeBoundingSphere();\n\n const mesh = new THREE.Mesh(\n geo,\n new THREE.MeshStandardMaterial({ vertexColors: true, roughness: 0.52, metalness: 0.14, flatShading: true }),\n );\n mesh.name = \"Coupe86_OneBlob\";\n return mesh;\n}\n\nexport function makeStarterDomainScene(domain: StarterDomainKey, subOrRecipe?: string): THREE.Group {\n if (domain === \"vehicle\") {\n if (subOrRecipe === \"craft\" || (subOrRecipe && subOrRecipe.includes(\"_\") && subOrRecipe !== \"coupe_86\")) {\n const craft = buildProceduralCraftScene(subOrRecipe === \"craft\" ? undefined : subOrRecipe);\n craft.name = `Starter_${craft.name}`;\n return craft;\n }\n const group = new THREE.Group();\n group.name = \"Starter_vehicle\";\n group.add(buildFusedCoupeStarterMesh());\n return group;\n }\n if (domain === \"craft\") {\n const craft = buildProceduralCraftScene(subOrRecipe);\n craft.name = `Starter_${craft.name}`;\n return craft;\n }\n if (domain === \"launcher\") {\n const forged = buildLauncherSceneFromPlan(planLauncher(KOLMOGOROV_CARBINE));\n forged.userData.isProceduralLauncher = true;\n return forged;\n }\n if (domain === \"suika\") {\n return buildSuikaTierScene(0, { groundAtZero: true });\n }\n if (domain === \"c12\") {\n const scene = buildProceduralC12Scene(subOrRecipe);\n scene.name = `Starter_${scene.name}`;\n return scene;\n }\n if (domain === \"person\") {\n const scene = buildProceduralPersonScene(subOrRecipe);\n scene.name = `Starter_${scene.name}`;\n return scene;\n }\n if (domain === \"prop\") {\n const scene = buildProceduralPropScene(subOrRecipe);\n scene.name = `Starter_${scene.name}`;\n return scene;\n }\n if (domain === \"junk\") {\n const scene = buildProceduralJunkScene(subOrRecipe);\n scene.name = `Starter_${scene.name}`;\n return scene;\n }\n const sand = sand3dStarterFactory ? sand3dStarterFactory(subOrRecipe) : buildSand3dFallback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AAM,QAAQ,2BAA2B,WAAW;EACpD,MAAM,OAAO,WAAW,MAAM;EAC9B,OAAO;CACX;CACA,IAAI,WAAW,QAAQ;EACnB,MAAM,QAAQ,yBAAyB,WAAW;EAClD,MAAM,OAAO,WAAW,MAAM;EAC9B,OAAO;CACX;CACA,IAAI,WAAW,QAAQ;EACnB,MAAM,QAAQ,yBAAyB,WAAW;EAClD,MAAM,OAAO,WAAW,MAAM;EAC9B,OAAO;CACX;CACA,MAAM,OAAO,uBAAuB,qBAAqB,WAAW,IAAI,2BAA2B;CACnG,KAAK,OAAO,WAAW,KAAK;CAC5B,OAAO;AACX"}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
+
import { bakeSand3dGateScene, bakeSocketCraftScene } from "../sand3d/gateBakeHelpers.js";
|
|
1
2
|
import { disambiguateExplicitPatches, stampKolmoNodesIntoGlb } from "../schema/kolmoStamp.js";
|
|
3
|
+
import { ORB_TIERS, getSuikaTier, matchSuikaTierByRadius } from "../suika/suikaTypes.js";
|
|
4
|
+
import { buildSuikaTierScene } from "../suika/suikaGeometry.js";
|
|
2
5
|
import { compileKhrAssetGlb } from "./khrCompiler.js";
|
|
3
6
|
import { boxInertia, collectPreservedRigPatches, restoreStrippedTextures, stripUnloadedTextures } from "./khrCraftPropCompiler.js";
|
|
4
7
|
import { assignMissingEmitterNames, collectSceneNodeNames, disambiguateSubtreeNodeNames, ensureRootNameUnique } from "./khrNodeNameGuard.js";
|
|
5
8
|
import { KOLMOGOROV_CARBINE, LAUNCHER_RECIPES, bakeArticulatedLauncherGlb } from "./launcherBake.js";
|
|
9
|
+
import { bakeHingedDoorwayScene } from "../sand3d/gateDoorwayBake.js";
|
|
6
10
|
import { cloneForNormalize, isMeshObject } from "./sceneSiNormalize.js";
|
|
7
11
|
import * as THREE from "three";
|
|
8
12
|
import { exportKhrGlb, loadKhrGlb, patchGlbJsonChunk } from "@khr3/core";
|
|
9
13
|
import { exportPaperShellKhrGlb } from "@khr3/vehicles/paper-shell";
|
|
10
14
|
// src/importer/universalGateBake.ts
|
|
15
|
+
function resolveSuikaBakeTier(scene, name, maxSpanM) {
|
|
16
|
+
if (typeof scene?.userData?.suikaTier === "number") return getSuikaTier(scene.userData.suikaTier);
|
|
17
|
+
const clean = name.toLowerCase();
|
|
18
|
+
if (/(?:^|[^a-z0-9])t(0\d|10)(?:$|[^a-z0-9])/i.test(clean) || ORB_TIERS.some((t) => clean.includes(t.name.toLowerCase().replace(/\s+/g, "_")))) return getSuikaTier(name);
|
|
19
|
+
if (maxSpanM > .05) return matchSuikaTierByRadius(maxSpanM * .5);
|
|
20
|
+
return ORB_TIERS[0];
|
|
21
|
+
}
|
|
11
22
|
async function exportAndStampGlb(scene, specs, sceneExtras, preservedPatches, explicitPatches) {
|
|
12
23
|
const stripped = stripUnloadedTextures(scene);
|
|
13
24
|
let exported;
|
|
@@ -22,6 +33,10 @@ async function exportAndStampGlb(scene, specs, sceneExtras, preservedPatches, ex
|
|
|
22
33
|
}
|
|
23
34
|
var toArrayBuffer = (u8) => new Uint8Array(u8).buffer;
|
|
24
35
|
async function bakeUniversalGateGlb(input) {
|
|
36
|
+
if (input.domain === "sand3d") {
|
|
37
|
+
const sand3dBaked = await bakeSand3dGateScene(input.normalizedScene, input.name, input.patches);
|
|
38
|
+
if (sand3dBaked) return sand3dBaked;
|
|
39
|
+
}
|
|
25
40
|
if (input.domain === "vehicle" && input.usePaperShellProxy) {
|
|
26
41
|
const { glb } = await exportPaperShellKhrGlb(input.assembly, input.attachedMask, input.fuelLiters);
|
|
27
42
|
const patched = new Uint8Array(patchGlbJsonChunk(glb, (gltf) => {
|
|
@@ -56,8 +71,12 @@ async function bakeUniversalGateGlb(input) {
|
|
|
56
71
|
worldKind: "vehicle"
|
|
57
72
|
};
|
|
58
73
|
}
|
|
59
|
-
const baseScene = input.normalizedScene ?? new THREE.Group();
|
|
74
|
+
const baseScene = input.domain === "suika" && (!input.normalizedScene || input.normalizedScene.children.length === 0) ? buildSuikaTierScene(resolveSuikaBakeTier(input.normalizedScene, input.name, 0), { groundAtZero: true }) : input.normalizedScene ?? new THREE.Group();
|
|
60
75
|
if (input.domain === "vehicle") {
|
|
76
|
+
if (input.vehicleArchetype === "craft") {
|
|
77
|
+
const socketCraft = await bakeSocketCraftScene(baseScene, input.name, input.massKg, input.powerOrThrust, input.patches);
|
|
78
|
+
if (socketCraft) return socketCraft;
|
|
79
|
+
}
|
|
61
80
|
const glbBytes = await compileKhrAssetGlb(baseScene, {
|
|
62
81
|
archetype: input.vehicleArchetype,
|
|
63
82
|
massKg: input.massKg,
|
|
@@ -82,7 +101,7 @@ async function bakeUniversalGateGlb(input) {
|
|
|
82
101
|
if (input.domain === "launcher") {
|
|
83
102
|
const lower = input.name.toLowerCase();
|
|
84
103
|
const recipe = LAUNCHER_RECIPES.find((r) => lower.includes(r.id.replace("kolmogorov_", ""))) ?? KOLMOGOROV_CARBINE;
|
|
85
|
-
const hasOverlay =
|
|
104
|
+
const hasOverlay = Boolean(input.normalizedScene && !input.normalizedScene.name.startsWith("Starter_") && !input.normalizedScene.userData?.isProceduralLauncher);
|
|
86
105
|
const { glbBytes, bundle } = await bakeArticulatedLauncherGlb(recipe, hasOverlay ? baseScene : null, input.patches);
|
|
87
106
|
return {
|
|
88
107
|
glbBytes,
|
|
@@ -90,17 +109,20 @@ async function bakeUniversalGateGlb(input) {
|
|
|
90
109
|
worldKind: "prop"
|
|
91
110
|
};
|
|
92
111
|
}
|
|
112
|
+
if (input.domain === "c12" || input.domain === "prop") {
|
|
113
|
+
const hinged = await bakeHingedDoorwayScene(baseScene, input.name, input.domain, input.staticProp, input.massKg, input.patches);
|
|
114
|
+
if (hinged) return hinged;
|
|
115
|
+
}
|
|
93
116
|
baseScene.updateMatrixWorld(true);
|
|
94
117
|
const box = new THREE.Box3().setFromObject(baseScene);
|
|
95
118
|
const size = box.isEmpty() ? new THREE.Vector3(1, 1, 1) : box.getSize(new THREE.Vector3());
|
|
96
119
|
const center = box.isEmpty() ? new THREE.Vector3(0, .5, 0) : box.getCenter(new THREE.Vector3());
|
|
97
|
-
const sx = Math.max(.08, size.x);
|
|
98
|
-
const
|
|
99
|
-
const sz = Math.max(.08, size.z);
|
|
120
|
+
const sx = Math.max(.08, size.x), sy = Math.max(.08, size.y), sz = Math.max(.08, size.z);
|
|
121
|
+
const suikaTier = input.domain === "suika" ? resolveSuikaBakeTier(baseScene, input.name, Math.max(size.x, size.y, size.z)) : null;
|
|
100
122
|
const root = new THREE.Group();
|
|
101
123
|
root.name = input.name;
|
|
102
124
|
const bodyGroup = new THREE.Group();
|
|
103
|
-
bodyGroup.name = input.domain === "c12" ? "C12Shell" : input.domain === "person" ? "PersonRig" : input.domain === "junk" ? "JunkTarget" : "PropBody";
|
|
125
|
+
bodyGroup.name = input.domain === "c12" ? "C12Shell" : input.domain === "person" ? "PersonRig" : input.domain === "junk" ? "JunkTarget" : input.domain === "suika" ? "SuikaOrb" : "PropBody";
|
|
104
126
|
const reservedNames = /* @__PURE__ */ new Set([bodyGroup.name]);
|
|
105
127
|
const clonedBase = cloneForNormalize(baseScene);
|
|
106
128
|
disambiguateSubtreeNodeNames(clonedBase, reservedNames, false);
|
|
@@ -120,12 +142,14 @@ async function bakeUniversalGateGlb(input) {
|
|
|
120
142
|
const existingNames = collectSceneNodeNames(root, preserved.map((p) => p.nodeName));
|
|
121
143
|
const safeExplicit = disambiguateExplicitPatches(input.patches, existingNames);
|
|
122
144
|
const isFixed = input.domain === "c12" || input.domain === "prop" && input.staticProp;
|
|
123
|
-
const massKg = Math.max(.5, input.massKg || (input.domain === "person" ? 72 : input.domain === "junk" ? 18 : 65));
|
|
145
|
+
const massKg = suikaTier ? suikaTier.mass : Math.max(.5, input.massKg || (input.domain === "person" ? 72 : input.domain === "junk" ? 18 : 65));
|
|
124
146
|
const com = [
|
|
125
147
|
Number(center.x.toFixed(4)),
|
|
126
148
|
Number(center.y.toFixed(4)),
|
|
127
149
|
Number(center.z.toFixed(4))
|
|
128
150
|
];
|
|
151
|
+
const friction = suikaTier ? .75 : hasGeometry && !isFixed ? .62 : .72;
|
|
152
|
+
const restitution = suikaTier ? .32 : hasGeometry && !isFixed ? .12 : .08;
|
|
129
153
|
const glbBytes = await exportAndStampGlb(root, [{
|
|
130
154
|
nodeName: bodyGroup.name,
|
|
131
155
|
motion: isFixed ? { isKinematic: true } : {
|
|
@@ -137,8 +161,8 @@ async function bakeUniversalGateGlb(input) {
|
|
|
137
161
|
collider: hasGeometry && !isFixed ? {
|
|
138
162
|
meshNodeName: bodyGroup.name,
|
|
139
163
|
convexHull: true,
|
|
140
|
-
friction
|
|
141
|
-
restitution
|
|
164
|
+
friction,
|
|
165
|
+
restitution
|
|
142
166
|
} : {
|
|
143
167
|
shape: {
|
|
144
168
|
type: "box",
|
|
@@ -148,8 +172,8 @@ async function bakeUniversalGateGlb(input) {
|
|
|
148
172
|
Number(sz.toFixed(4))
|
|
149
173
|
]
|
|
150
174
|
},
|
|
151
|
-
friction
|
|
152
|
-
restitution
|
|
175
|
+
friction,
|
|
176
|
+
restitution
|
|
153
177
|
},
|
|
154
178
|
extras: {
|
|
155
179
|
role: input.domain,
|
|
@@ -157,6 +181,14 @@ async function bakeUniversalGateGlb(input) {
|
|
|
157
181
|
fractureShards: 8,
|
|
158
182
|
decalBudget: 16,
|
|
159
183
|
breakImpulseNs: 65
|
|
184
|
+
} } : {},
|
|
185
|
+
...suikaTier ? { suikaOrb: {
|
|
186
|
+
tier: suikaTier.id,
|
|
187
|
+
code: suikaTier.code,
|
|
188
|
+
name: suikaTier.name,
|
|
189
|
+
radius: suikaTier.radius,
|
|
190
|
+
shape: suikaTier.shape,
|
|
191
|
+
scoreValue: suikaTier.scoreValue
|
|
160
192
|
} } : {}
|
|
161
193
|
}
|
|
162
194
|
}], { gateDomain: input.domain }, preserved, safeExplicit);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"universalGateBake.js","names":[],"sources":["../../src/importer/universalGateBake.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { exportKhrGlb, loadKhrGlb, patchGlbJsonChunk, type KhrAssetBundle, type KhrExportNodeSpec } from \"@khr3/core\";\nimport { exportPaperShellKhrGlb, type PaperShellAssembly } from \"@khr3/vehicles/paper-shell\";\nimport { stampKolmoNodesIntoGlb, type KolmoAuthoredNodePatch } from \"../schema/kolmoSchema.js\";\nimport type { WheelCutterSpec } from \"./fusedWheelDetect.js\";\nimport type { GateDomain, VehicleSubArchetype } from \"./gateStore.js\";\nimport { compileKhrAssetGlb, type CarDriveMode, type WheelVisualSource } from \"./khrCompiler.js\";\nimport { boxInertia, collectPreservedRigPatches, restoreStrippedTextures, stripUnloadedTextures } from \"./khrCraftPropCompiler.js\";\nimport {\n assignMissingEmitterNames,\n collectSceneNodeNames,\n disambiguateExplicitPatches,\n disambiguateSubtreeNodeNames,\n ensureRootNameUnique,\n} from \"./khrNodeNameGuard.js\";\nimport { KOLMOGOROV_CARBINE, LAUNCHER_RECIPES, bakeArticulatedLauncherGlb } from \"./launcherBake.js\";\nimport type { MeshIsland, WheelAxle } from \"./meshIslands.js\";\nimport { cloneForNormalize, isMeshObject } from \"./sceneSiNormalize.js\";\nimport type { ChopPartRole } from \"./surfaceCutter.js\";\n\nexport type WorldAssetKind = \"vehicle\" | \"prop\";\n\nexport interface GateWorldPayload {\n readonly id: string;\n readonly label: string;\n readonly kind: WorldAssetKind;\n readonly domain: GateDomain;\n readonly glbBytes: Uint8Array;\n readonly bundle: KhrAssetBundle;\n}\n\nexport interface UniversalBakeInput {\n readonly name: string;\n readonly domain: GateDomain;\n readonly vehicleArchetype: VehicleSubArchetype;\n readonly usePaperShellProxy: boolean;\n readonly assembly: PaperShellAssembly;\n readonly attachedMask: number;\n readonly fuelLiters: number;\n readonly normalizedScene: THREE.Group | null;\n readonly massKg: number;\n readonly powerOrThrust: number;\n readonly driveType: CarDriveMode;\n readonly staticProp: boolean;\n readonly axles: readonly WheelAxle[];\n readonly islands: readonly MeshIsland[];\n readonly partPicks?: Readonly<Record<number, ChopPartRole>>;\n readonly wheelSource?: WheelVisualSource;\n readonly wheelCutters?: readonly WheelCutterSpec[];\n readonly sealArchLiner?: boolean;\n readonly mirrorX?: boolean;\n readonly patches: readonly KolmoAuthoredNodePatch[];\n}\n\nasync function exportAndStampGlb(\n scene: THREE.Group,\n specs: KhrExportNodeSpec[],\n sceneExtras: Record<string, unknown>,\n preservedPatches: readonly KolmoAuthoredNodePatch[],\n explicitPatches: readonly KolmoAuthoredNodePatch[],\n): Promise<Uint8Array<ArrayBuffer>> {\n const stripped = stripUnloadedTextures(scene);\n let exported: Uint8Array;\n try {\n exported = new Uint8Array(await exportKhrGlb(scene, specs, sceneExtras));\n } finally {\n restoreStrippedTextures(stripped);\n }\n const withPreserved = stampKolmoNodesIntoGlb(exported, preservedPatches);\n const stamped = stampKolmoNodesIntoGlb(withPreserved, explicitPatches, undefined, { preserveExistingNodes: true });\n return new Uint8Array(stamped);\n}\n\nconst toArrayBuffer = (u8: Uint8Array): ArrayBuffer => new Uint8Array(u8).buffer;\n\nexport async function bakeUniversalGateGlb(input: UniversalBakeInput): Promise<{\n glbBytes: Uint8Array;\n bundle: KhrAssetBundle;\n worldKind: WorldAssetKind;\n}> {\n if (input.domain === \"vehicle\" && input.usePaperShellProxy) {\n const { glb } = await exportPaperShellKhrGlb(input.assembly, input.attachedMask, input.fuelLiters);\n const patched = new Uint8Array(\n patchGlbJsonChunk(glb, (gltf) => {\n const s0 = gltf.scenes?.[0];\n if (s0) {\n s0.extras = {\n ...(s0.extras ?? {}),\n tune: { engineHorsepower: 190, gearRatios: [3.5, 2.1, 1.4, 1], finalDriveRatio: 3.9 },\n };\n }\n }),\n );\n const withSeat = stampKolmoNodesIntoGlb(\n patched,\n [{ nodeName: \"Socket_seat_gate\", translation: [0.34, 0.62, -0.08], extension: { socket: \"seat\" } }],\n undefined,\n { preserveExistingNodes: true },\n );\n const glbBytes = new Uint8Array(\n stampKolmoNodesIntoGlb(withSeat, input.patches, undefined, { preserveExistingNodes: true }),\n );\n return { glbBytes, bundle: await loadKhrGlb(toArrayBuffer(glbBytes)), worldKind: \"vehicle\" };\n }\n\n const baseScene = input.normalizedScene ?? new THREE.Group();\n if (input.domain === \"vehicle\") {\n const glbBytes = await compileKhrAssetGlb(baseScene, {\n archetype: input.vehicleArchetype,\n massKg: input.massKg,\n powerOrThrust: input.powerOrThrust,\n driveType: input.driveType,\n wheelSource: input.wheelSource,\n axles: input.axles,\n islands: input.islands,\n partPicks: input.partPicks,\n wheelCutters: input.wheelCutters,\n sealArchLiner: input.sealArchLiner,\n mirrorX: input.mirrorX,\n patches: input.patches,\n name: input.name,\n });\n return { glbBytes, bundle: await loadKhrGlb(toArrayBuffer(glbBytes)), worldKind: \"vehicle\" };\n }\n\n if (input.domain === \"launcher\") {\n const lower = input.name.toLowerCase();\n const recipe =\n LAUNCHER_RECIPES.find((r) => lower.includes(r.id.replace(\"kolmogorov_\", \"\"))) ?? KOLMOGOROV_CARBINE;\n const hasOverlay = !!(\n input.normalizedScene &&\n !input.normalizedScene.name.startsWith(\"Starter_\") &&\n !input.normalizedScene.userData?.isProceduralLauncher\n );\n const { glbBytes, bundle } = await bakeArticulatedLauncherGlb(recipe, hasOverlay ? baseScene : null, input.patches);\n return { glbBytes, bundle, worldKind: \"prop\" };\n }\n\n baseScene.updateMatrixWorld(true);\n const box = new THREE.Box3().setFromObject(baseScene);\n const size = box.isEmpty() ? new THREE.Vector3(1, 1, 1) : box.getSize(new THREE.Vector3());\n const center = box.isEmpty() ? new THREE.Vector3(0, 0.5, 0) : box.getCenter(new THREE.Vector3());\n const sx = Math.max(0.08, size.x);\n const sy = Math.max(0.08, size.y);\n const sz = Math.max(0.08, size.z);\n\n const root = new THREE.Group();\n root.name = input.name;\n const bodyGroup = new THREE.Group();\n bodyGroup.name =\n input.domain === \"c12\" ? \"C12Shell\" : input.domain === \"person\" ? \"PersonRig\" : input.domain === \"junk\" ? \"JunkTarget\" : \"PropBody\";\n const reservedNames = new Set<string>([bodyGroup.name]);\n const clonedBase = cloneForNormalize(baseScene);\n disambiguateSubtreeNodeNames(clonedBase, reservedNames, false);\n let hasGeometry = false;\n for (const child of [...clonedBase.children]) {\n bodyGroup.add(child);\n child.traverse((obj) => {\n if (isMeshObject(obj) && (obj.geometry.getAttribute(\"position\")?.count ?? 0) >= 3)\n hasGeometry = true;\n });\n }\n root.add(bodyGroup);\n ensureRootNameUnique(root, reservedNames);\n const emitterReserved = new Set<string>(reservedNames);\n for (const p of input.patches) emitterReserved.add(p.nodeName);\n assignMissingEmitterNames(root, emitterReserved);\n const preserved = collectPreservedRigPatches(root, [], { localToParent: true });\n const existingNames = collectSceneNodeNames(root, preserved.map((p) => p.nodeName));\n const safeExplicit = disambiguateExplicitPatches(input.patches, existingNames);\n\n const isFixed = input.domain === \"c12\" || (input.domain === \"prop\" && input.staticProp);\n const massKg = Math.max(0.5, input.massKg || (input.domain === \"person\" ? 72 : input.domain === \"junk\" ? 18 : 65));\n const com: [number, number, number] = [Number(center.x.toFixed(4)), Number(center.y.toFixed(4)), Number(center.z.toFixed(4))];\n const glbBytes = await exportAndStampGlb(\n root,\n [\n {\n nodeName: bodyGroup.name,\n motion: isFixed\n ? { isKinematic: true }\n : { isKinematic: false, mass: massKg, centerOfMass: com, inertiaDiagonal: boxInertia(massKg, sx, sy, sz) },\n collider:\n hasGeometry && !isFixed\n ? { meshNodeName: bodyGroup.name, convexHull: true, friction: 0.62, restitution: 0.12 }\n : { shape: { type: \"box\", size: [Number(sx.toFixed(4)), Number(sy.toFixed(4)), Number(sz.toFixed(4))] }, friction: 0.72, restitution: 0.08 },\n extras: {\n role: input.domain,\n ...(input.domain === \"junk\" ? { destructible: { fractureShards: 8, decalBudget: 16, breakImpulseNs: 65 } } : {}),\n },\n },\n ],\n { gateDomain: input.domain },\n preserved,\n safeExplicit,\n );\n\n return { glbBytes, bundle: await loadKhrGlb(toArrayBuffer(glbBytes)), worldKind: \"prop\" };\n}\n"],"mappings":";;;;;;;;;;AAsDA,eAAe,kB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E,QAAQ,CAAC,CAAC;CAAC;CAC5H,MAAM,WAAW,MAAM,kBACnB,MACA,CACI;EACI,UAAU,UAAU;EACpB,QAAQ,UACF,EAAE,aAAa,KAAK,IACpB;GAAE,aAAa;GAAO,MAAM;GAAQ,cAAc;GAAK,iBAAiB,WAAW,QAAQ,IAAI,IAAI,EAAE;EAAE;EAC7G,UACI,eAAe,CAAC,UACV;GAAE,cAAc,UAAU;GAAM,YAAY;GAAM,UAAU;GAAM,aAAa;EAAK,IACpF;GAAE,OAAO;IAAE,MAAM;IAAO,MAAM;KAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;KAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;KAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;IAAC;GAAE;GAAG,UAAU;GAAM,aAAa;EAAK;EACnJ,QAAQ;GACJ,MAAM,MAAM;GACZ,GAAI,MAAM,WAAW,SAAS,EAAE,cAAc;IAAE,gBAAgB;IAAG,aAAa;IAAI,gBAAgB;GAAG,EAAE,IAAI,CAAC;EAClH;CACJ,CACJ,GACA,EAAE,YAAY,MAAM,OAAO,GAC3B,WACA,YACJ;CAEA,OAAO;EAAE;EAAU,QAAQ,MAAM,WAAW,cAAc,QAAQ,CAAC;EAAG,WAAW;CAAO;AAC5F"}
|
|
1
|
+
{"version":3,"file":"universalGateBake.js","names":[],"sources":["../../src/importer/universalGateBake.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { exportKhrGlb, loadKhrGlb, patchGlbJsonChunk, type KhrAssetBundle, type KhrExportNodeSpec } from \"@khr3/core\";\nimport { exportPaperShellKhrGlb, type PaperShellAssembly } from \"@khr3/vehicles/paper-shell\";\nimport { bakeHingedDoorwayScene, bakeSand3dGateScene, bakeSocketCraftScene } from \"../sand3d/gateBakeHelpers.js\";\nimport { stampKolmoNodesIntoGlb, type KolmoAuthoredNodePatch } from \"../schema/kolmoSchema.js\";\nimport { ORB_TIERS, buildSuikaTierScene, getSuikaTier, matchSuikaTierByRadius, type OrbTier } from \"../suika/index.js\";\nimport type { WheelCutterSpec } from \"./fusedWheelDetect.js\";\nimport type { GateDomain, VehicleSubArchetype } from \"./gateStore.js\";\nimport { compileKhrAssetGlb, type CarDriveMode, type WheelVisualSource } from \"./khrCompiler.js\";\nimport { boxInertia, collectPreservedRigPatches, restoreStrippedTextures, stripUnloadedTextures } from \"./khrCraftPropCompiler.js\";\nimport {\n assignMissingEmitterNames,\n collectSceneNodeNames,\n disambiguateExplicitPatches,\n disambiguateSubtreeNodeNames,\n ensureRootNameUnique,\n} from \"./khrNodeNameGuard.js\";\nimport { KOLMOGOROV_CARBINE, LAUNCHER_RECIPES, bakeArticulatedLauncherGlb } from \"./launcherBake.js\";\nimport type { MeshIsland, WheelAxle } from \"./meshIslands.js\";\nimport { cloneForNormalize, isMeshObject } from \"./sceneSiNormalize.js\";\nimport type { ChopPartRole } from \"./surfaceCutter.js\";\n\nexport type WorldAssetKind = \"vehicle\" | \"prop\";\n\nexport interface GateWorldPayload {\n readonly id: string;\n readonly label: string;\n readonly kind: WorldAssetKind;\n readonly domain: GateDomain;\n readonly glbBytes: Uint8Array;\n readonly bundle: KhrAssetBundle;\n}\n\nexport interface UniversalBakeInput {\n readonly name: string;\n readonly domain: GateDomain;\n readonly vehicleArchetype: VehicleSubArchetype;\n readonly usePaperShellProxy: boolean;\n readonly assembly: PaperShellAssembly;\n readonly attachedMask: number;\n readonly fuelLiters: number;\n readonly normalizedScene: THREE.Group | null;\n readonly massKg: number;\n readonly powerOrThrust: number;\n readonly driveType: CarDriveMode;\n readonly staticProp: boolean;\n readonly axles: readonly WheelAxle[];\n readonly islands: readonly MeshIsland[];\n readonly partPicks?: Readonly<Record<number, ChopPartRole>>;\n readonly wheelSource?: WheelVisualSource;\n readonly wheelCutters?: readonly WheelCutterSpec[];\n readonly sealArchLiner?: boolean;\n readonly mirrorX?: boolean;\n readonly patches: readonly KolmoAuthoredNodePatch[];\n}\n\nfunction resolveSuikaBakeTier(scene: THREE.Object3D | null, name: string, maxSpanM: number): OrbTier {\n if (typeof scene?.userData?.suikaTier === \"number\") return getSuikaTier(scene.userData.suikaTier);\n const clean = name.toLowerCase();\n if (/(?:^|[^a-z0-9])t(0\\d|10)(?:$|[^a-z0-9])/i.test(clean) || ORB_TIERS.some((t) => clean.includes(t.name.toLowerCase().replace(/\\s+/g, \"_\")))) {\n return getSuikaTier(name);\n }\n if (maxSpanM > 0.05) return matchSuikaTierByRadius(maxSpanM * 0.5);\n return ORB_TIERS[0];\n}\n\nasync function exportAndStampGlb(\n scene: THREE.Group,\n specs: KhrExportNodeSpec[],\n sceneExtras: Record<string, unknown>,\n preservedPatches: readonly KolmoAuthoredNodePatch[],\n explicitPatches: readonly KolmoAuthoredNodePatch[],\n): Promise<Uint8Array<ArrayBuffer>> {\n const stripped = stripUnloadedTextures(scene);\n let exported: Uint8Array;\n try {\n exported = new Uint8Array(await exportKhrGlb(scene, specs, sceneExtras));\n } finally {\n restoreStrippedTextures(stripped);\n }\n const withPreserved = stampKolmoNodesIntoGlb(exported, preservedPatches);\n const stamped = stampKolmoNodesIntoGlb(withPreserved, explicitPatches, undefined, { preserveExistingNodes: true });\n return new Uint8Array(stamped);\n}\n\nconst toArrayBuffer = (u8: Uint8Array): ArrayBuffer => new Uint8Array(u8).buffer;\n\nexport async function bakeUniversalGateGlb(input: UniversalBakeInput): Promise<{\n glbBytes: Uint8Array;\n bundle: KhrAssetBundle;\n worldKind: WorldAssetKind;\n}> {\n if (input.domain === \"sand3d\") {\n const sand3dBaked = await bakeSand3dGateScene(input.normalizedScene, input.name, input.patches);\n if (sand3dBaked) return sand3dBaked;\n }\n\n if (input.domain === \"vehicle\" && input.usePaperShellProxy) {\n const { glb } = await exportPaperShellKhrGlb(input.assembly, input.attachedMask, input.fuelLiters);\n const patched = new Uint8Array(\n patchGlbJsonChunk(glb, (gltf) => {\n const s0 = gltf.scenes?.[0];\n if (s0) s0.extras = { ...(s0.extras ?? {}), tune: { engineHorsepower: 190, gearRatios: [3.5, 2.1, 1.4, 1], finalDriveRatio: 3.9 } };\n }),\n );\n const withSeat = stampKolmoNodesIntoGlb(\n patched,\n [{ nodeName: \"Socket_seat_gate\", translation: [0.34, 0.62, -0.08], extension: { socket: \"seat\" } }],\n undefined,\n { preserveExistingNodes: true },\n );\n const glbBytes = new Uint8Array(stampKolmoNodesIntoGlb(withSeat, input.patches, undefined, { preserveExistingNodes: true }));\n return { glbBytes, bundle: await loadKhrGlb(toArrayBuffer(glbBytes)), worldKind: \"vehicle\" };\n }\n\n const baseScene =\n input.domain === \"suika\" && (!input.normalizedScene || input.normalizedScene.children.length === 0)\n ? buildSuikaTierScene(resolveSuikaBakeTier(input.normalizedScene, input.name, 0), { groundAtZero: true })\n : (input.normalizedScene ?? new THREE.Group());\n\n if (input.domain === \"vehicle\") {\n if (input.vehicleArchetype === \"craft\") {\n const socketCraft = await bakeSocketCraftScene(baseScene, input.name, input.massKg, input.powerOrThrust, input.patches);\n if (socketCraft) return socketCraft;\n }\n const glbBytes = await compileKhrAssetGlb(baseScene, {\n archetype: input.vehicleArchetype, massKg: input.massKg, powerOrThrust: input.powerOrThrust,\n driveType: input.driveType, wheelSource: input.wheelSource, axles: input.axles,\n islands: input.islands, partPicks: input.partPicks, wheelCutters: input.wheelCutters,\n sealArchLiner: input.sealArchLiner, mirrorX: input.mirrorX, patches: input.patches, name: input.name,\n });\n return { glbBytes, bundle: await loadKhrGlb(toArrayBuffer(glbBytes)), worldKind: \"vehicle\" };\n }\n\n if (input.domain === \"launcher\") {\n const lower = input.name.toLowerCase();\n const recipe = LAUNCHER_RECIPES.find((r) => lower.includes(r.id.replace(\"kolmogorov_\", \"\"))) ?? KOLMOGOROV_CARBINE;\n const hasOverlay = Boolean(input.normalizedScene && !input.normalizedScene.name.startsWith(\"Starter_\") && !input.normalizedScene.userData?.isProceduralLauncher);\n const { glbBytes, bundle } = await bakeArticulatedLauncherGlb(recipe, hasOverlay ? baseScene : null, input.patches);\n return { glbBytes, bundle, worldKind: \"prop\" };\n }\n\n if (input.domain === \"c12\" || input.domain === \"prop\") {\n const hinged = await bakeHingedDoorwayScene(baseScene, input.name, input.domain, input.staticProp, input.massKg, input.patches);\n if (hinged) return hinged;\n }\n\n baseScene.updateMatrixWorld(true);\n const box = new THREE.Box3().setFromObject(baseScene);\n const size = box.isEmpty() ? new THREE.Vector3(1, 1, 1) : box.getSize(new THREE.Vector3());\n const center = box.isEmpty() ? new THREE.Vector3(0, 0.5, 0) : box.getCenter(new THREE.Vector3());\n const sx = Math.max(0.08, size.x), sy = Math.max(0.08, size.y), sz = Math.max(0.08, size.z);\n const suikaTier = input.domain === \"suika\" ? resolveSuikaBakeTier(baseScene, input.name, Math.max(size.x, size.y, size.z)) : null;\n\n const root = new THREE.Group();\n root.name = input.name;\n const bodyGroup = new THREE.Group();\n bodyGroup.name =\n input.domain === \"c12\" ? \"C12Shell\" : input.domain === \"person\" ? \"PersonRig\" : input.domain === \"junk\" ? \"JunkTarget\" : input.domain === \"suika\" ? \"SuikaOrb\" : \"PropBody\";\n const reservedNames = new Set<string>([bodyGroup.name]);\n const clonedBase = cloneForNormalize(baseScene);\n disambiguateSubtreeNodeNames(clonedBase, reservedNames, false);\n let hasGeometry = false;\n for (const child of [...clonedBase.children]) {\n bodyGroup.add(child);\n child.traverse((obj) => {\n if (isMeshObject(obj) && (obj.geometry.getAttribute(\"position\")?.count ?? 0) >= 3) hasGeometry = true;\n });\n }\n root.add(bodyGroup);\n ensureRootNameUnique(root, reservedNames);\n const emitterReserved = new Set<string>(reservedNames);\n for (const p of input.patches) emitterReserved.add(p.nodeName);\n assignMissingEmitterNames(root, emitterReserved);\n const preserved = collectPreservedRigPatches(root, [], { localToParent: true });\n const existingNames = collectSceneNodeNames(root, preserved.map((p) => p.nodeName));\n const safeExplicit = disambiguateExplicitPatches(input.patches, existingNames);\n\n const isFixed = input.domain === \"c12\" || (input.domain === \"prop\" && input.staticProp);\n const massKg = suikaTier ? suikaTier.mass : Math.max(0.5, input.massKg || (input.domain === \"person\" ? 72 : input.domain === \"junk\" ? 18 : 65));\n const com: [number, number, number] = [Number(center.x.toFixed(4)), Number(center.y.toFixed(4)), Number(center.z.toFixed(4))];\n const friction = suikaTier ? 0.75 : hasGeometry && !isFixed ? 0.62 : 0.72;\n const restitution = suikaTier ? 0.32 : hasGeometry && !isFixed ? 0.12 : 0.08;\n const glbBytes = await exportAndStampGlb(\n root,\n [{\n nodeName: bodyGroup.name,\n motion: isFixed ? { isKinematic: true } : { isKinematic: false, mass: massKg, centerOfMass: com, inertiaDiagonal: boxInertia(massKg, sx, sy, sz) },\n collider: hasGeometry && !isFixed ? { meshNodeName: bodyGroup.name, convexHull: true, friction, restitution } : { shape: { type: \"box\", size: [Number(sx.toFixed(4)), Number(sy.toFixed(4)), Number(sz.toFixed(4))] }, friction, restitution },\n extras: {\n role: input.domain,\n ...(input.domain === \"junk\" ? { destructible: { fractureShards: 8, decalBudget: 16, breakImpulseNs: 65 } } : {}),\n ...(suikaTier ? { suikaOrb: { tier: suikaTier.id, code: suikaTier.code, name: suikaTier.name, radius: suikaTier.radius, shape: suikaTier.shape, scoreValue: suikaTier.scoreValue } } : {}),\n },\n }],\n { gateDomain: input.domain },\n preserved,\n safeExplicit,\n );\n\n return { glbBytes, bundle: await loadKhrGlb(toArrayBuffer(glbBytes)), worldKind: \"prop\" };\n}\n"],"mappings":";;;;;;;;;;;;;;AAwDA,SAAS,qBAAqB,OAA8B,MAAc,UAA2B;CACjG,IAAI,OAAO,OAAO,UAAU,cAAc,UAAU,OAAO,aAAa,MAAM,SAAS,SAAS;CAChG,MAAM,QAAQ,KAAK,YAAY;CAC/B,IAAI,2CAA2C,KAAK,KAAK,KAAK,UAAU,MAAM,MAAM,MAAM,SAAS,EAAE,KAAK,YAAY,CAAC,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAAC,GACzI,OAAO,aAAa,IAAI;CAE5B,IAAI,WAAW,KAAM,OAAO,uBAAuB,WAAW,EAAG;CACjE,OAAO,UAAU;AACr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AAE,OAAO;IAAE,MAAM;IAAO,MAAM;KAAC,OAAO,GAAG,QAAQ,CAAC,CAAC;KAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;KAAG,OAAO,GAAG,QAAQ,CAAC,CAAC;IAAC;GAAE;GAAG;GAAU;EAAY;EAC7O,QAAQ;GACJ,MAAM,MAAM;GACZ,GAAI,MAAM,WAAW,SAAS,EAAE,cAAc;IAAE,gBAAgB;IAAG,aAAa;IAAI,gBAAgB;GAAG,EAAE,IAAI,CAAC;GAC9G,GAAI,YAAY,EAAE,UAAU;IAAE,MAAM,UAAU;IAAI,MAAM,UAAU;IAAM,MAAM,UAAU;IAAM,QAAQ,UAAU;IAAQ,OAAO,UAAU;IAAO,YAAY,UAAU;GAAW,EAAE,IAAI,CAAC;EAC5L;CACJ,CAAC,GACD,EAAE,YAAY,MAAM,OAAO,GAC3B,WACA,YACJ;CAEA,OAAO;EAAE;EAAU,QAAQ,MAAM,WAAW,cAAc,QAAQ,CAAC;EAAG,WAAW;CAAO;AAC5F"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as THREE from "three";
|
|
2
|
+
import type { PaperShellPresetId } from "@khr3/vehicles/paper-shell";
|
|
2
3
|
import { buildSurfaceStampPatch } from "./chopShopActions.js";
|
|
3
4
|
import type { CutPartMcpRequest } from "./importerWebMcp.js";
|
|
4
5
|
import type { GateWorldPayload } from "./universalGateBake.js";
|
|
@@ -79,7 +80,8 @@ export declare function useChopShopController(onSpawnInWorld?: (asset: GateWorld
|
|
|
79
80
|
sealArchLiner?: boolean;
|
|
80
81
|
mirrorX?: boolean;
|
|
81
82
|
}) => void;
|
|
82
|
-
forgeScene: (label: string, sc: THREE.Group, lenM: number) => void;
|
|
83
|
+
forgeScene: (label: string, sc: THREE.Group, lenM: number, massKg?: number, powerOrThrust?: number) => void;
|
|
84
|
+
forgeProceduralCar: (presetId: PaperShellPresetId) => void;
|
|
83
85
|
handleCloseLoop: () => void;
|
|
84
86
|
handlePeelSelection: () => void;
|
|
85
87
|
cutPart: (req: CutPartMcpRequest) => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { buildProceduralPaperShellCarGroup } from "../sand3d/gateBakeHelpers.js";
|
|
1
2
|
import { hasPostCoreUndoEntries } from "./chopShopActions.js";
|
|
2
3
|
import { createChopShopHandlers } from "./chopShopHandlers.js";
|
|
3
|
-
import { defaultTargetMeters, snapMetersToC12 } from "./glbNormalizer.js";
|
|
4
4
|
import { executeCutPartMcp } from "./chopShopMcpAction.js";
|
|
5
5
|
import { appendUniqueAnchorPatch, buildSurfaceStampPatch, downloadBlobGlb, nextStampPatchIndex, putAuthenticatedVaultGlb } from "./chopShopIoActions.js";
|
|
6
|
+
import { defaultTargetMeters, snapMetersToC12 } from "./glbNormalizer.js";
|
|
6
7
|
import { isGateStep1Unlocked } from "./gateStore.js";
|
|
7
8
|
import { CHOP_ROLES } from "./surfaceTopology.js";
|
|
8
9
|
import { useChopShopState } from "./useChopShopState.js";
|
|
@@ -12,6 +13,33 @@ function useChopShopController(onSpawnInWorld) {
|
|
|
12
13
|
const h = createChopShopHandlers(s);
|
|
13
14
|
const axleWheelCount = s.axles.reduce((sum, a) => sum + +(a.left.length > 0) + +(a.right.length > 0), 0);
|
|
14
15
|
const wheelCount = axleWheelCount > 0 ? axleWheelCount : s.wheelCutters.length;
|
|
16
|
+
const forgeScene = (label, sc, lenM, massKg, powerOrThrust) => {
|
|
17
|
+
if (s.st.domain === "launcher") sc.userData.isProceduralLauncher = true;
|
|
18
|
+
if (massKg !== void 0) s.st.setField("massKg", massKg);
|
|
19
|
+
if (powerOrThrust !== void 0) s.st.setField("powerOrThrust", powerOrThrust);
|
|
20
|
+
s.setAssetName(label);
|
|
21
|
+
s.setRawScene(sc);
|
|
22
|
+
s.setTurns([
|
|
23
|
+
0,
|
|
24
|
+
0,
|
|
25
|
+
0
|
|
26
|
+
]);
|
|
27
|
+
s.setTargetMeters(lenM);
|
|
28
|
+
s.setYOffset(0);
|
|
29
|
+
s.setPatches([]);
|
|
30
|
+
s.setUsdInfo(null);
|
|
31
|
+
s.setHasCustomFile(false);
|
|
32
|
+
};
|
|
33
|
+
const forgeProceduralCar = (presetId) => {
|
|
34
|
+
const built = buildProceduralPaperShellCarGroup(presetId);
|
|
35
|
+
s.st.setField("domain", "vehicle");
|
|
36
|
+
s.st.setField("vehicleArchetype", "car");
|
|
37
|
+
s.st.setField("usePaperShellProxy", false);
|
|
38
|
+
s.st.setField("presetId", presetId);
|
|
39
|
+
s.st.setField("step", 1);
|
|
40
|
+
forgeScene(presetId, built.scene, built.lengthM, built.massKg);
|
|
41
|
+
s.setStatusNote(`Forged procedural ${presetId} · 4 wheels paired.`);
|
|
42
|
+
};
|
|
15
43
|
return {
|
|
16
44
|
st: s.st,
|
|
17
45
|
assetName: s.assetName,
|
|
@@ -80,27 +108,14 @@ function useChopShopController(onSpawnInWorld) {
|
|
|
80
108
|
updateWheelCutter: h.updateWheelCutter,
|
|
81
109
|
commitWheelCutter: h.commitWheelCutter,
|
|
82
110
|
applyWheelCutters: h.applyWheelCutters,
|
|
83
|
-
forgeScene
|
|
84
|
-
|
|
85
|
-
s.setAssetName(label);
|
|
86
|
-
s.setRawScene(sc);
|
|
87
|
-
s.setTurns([
|
|
88
|
-
0,
|
|
89
|
-
0,
|
|
90
|
-
0
|
|
91
|
-
]);
|
|
92
|
-
s.setTargetMeters(lenM);
|
|
93
|
-
s.setYOffset(0);
|
|
94
|
-
s.setPatches([]);
|
|
95
|
-
s.setUsdInfo(null);
|
|
96
|
-
s.setHasCustomFile(false);
|
|
97
|
-
},
|
|
111
|
+
forgeScene,
|
|
112
|
+
forgeProceduralCar,
|
|
98
113
|
handleCloseLoop: h.handleCloseLoop,
|
|
99
114
|
handlePeelSelection: () => {
|
|
100
115
|
try {
|
|
101
116
|
h.peelSelection(s.faceSelection, s.activeRole);
|
|
102
117
|
} catch (err) {
|
|
103
|
-
s.setStatusNote(err instanceof Error ? err.message : "Peel failed.");
|
|
118
|
+
s.setStatusNote(err instanceof Error ? err.message : "Peel action failed.");
|
|
104
119
|
}
|
|
105
120
|
},
|
|
106
121
|
cutPart: (req) => executeCutPartMcp({
|
|
@@ -129,7 +144,7 @@ function useChopShopController(onSpawnInWorld) {
|
|
|
129
144
|
s.setFaceSelection(null);
|
|
130
145
|
s.setLoopDots(null);
|
|
131
146
|
s.setCutVersion((v) => v + 1);
|
|
132
|
-
s.setStatusNote("
|
|
147
|
+
s.setStatusNote("Restored previous cut state.");
|
|
133
148
|
},
|
|
134
149
|
sealAndExport: async (spawnInWorld) => {
|
|
135
150
|
s.setBusy(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChopShopController.js","names":[],"sources":["../../src/importer/useChopShopController.ts"],"sourcesContent":["import type * as THREE from \"three\";\nimport {\n appendUniqueAnchorPatch,\n buildSurfaceStampPatch,\n downloadBlobGlb,\n executeCutPartMcp,\n hasPostCoreUndoEntries,\n nextStampPatchIndex,\n putAuthenticatedVaultGlb,\n} from \"./chopShopActions.js\";\nimport { createChopShopHandlers } from \"./chopShopHandlers.js\";\nimport type { CutPartMcpRequest } from \"./importerWebMcp.js\";\nimport { defaultTargetMeters, snapMetersToC12 } from \"./glbNormalizer.js\";\nimport { isGateStep1Unlocked } from \"./gateStore.js\";\nimport type { QuarterTurn } from \"./meshIslands.js\";\nimport { CHOP_ROLES } from \"./surfaceTopology.js\";\nimport type { GateWorldPayload } from \"./universalGateBake.js\";\nimport { useChopShopState } from \"./useChopShopState.js\";\n\nexport function useChopShopController(onSpawnInWorld?: (asset: GateWorldPayload) => void) {\n const s = useChopShopState();\n const h = createChopShopHandlers(s);\n\n const axleWheelCount = s.axles.reduce((sum, a) => sum + +(a.left.length > 0) + +(a.right.length > 0), 0);\n const wheelCount = axleWheelCount > 0 ? axleWheelCount : s.wheelCutters.length;\n\n return {\n st: s.st,\n assetName: s.assetName,\n hasCustomFile: s.hasCustomFile,\n usdInfo: s.usdInfo,\n targetMeters: s.targetMeters,\n setTargetMeters: s.setTargetMeters,\n setYOffset: s.setYOffset,\n setTurns: s.setTurns,\n axles: s.axles,\n setAxles: s.setAxles,\n wheelCutters: s.wheelCutters,\n setWheelCutters: s.setWheelCutters,\n partPicks: s.partPicks,\n setPartPicks: s.setPartPicks,\n wheelSource: s.wheelSource,\n setWheelSource: s.setWheelSource,\n activeRole: s.activeRole,\n setActiveRole: s.setActiveRole,\n surfaceMode: s.surfaceMode,\n setSurfaceMode: s.setSurfaceMode,\n creaseDeg: s.creaseDeg,\n setCreaseDeg: s.setCreaseDeg,\n mirrorX: s.mirrorX,\n setMirrorX: h.toggleMirrorX,\n toggleMirrorX: h.toggleMirrorX,\n snapAxles: s.snapAxles,\n setSnapAxles: s.setSnapAxles,\n toggleSnapAxles: h.toggleSnapAxles,\n sealArchLiner: s.sealArchLiner,\n setSealArchLiner: s.setSealArchLiner,\n toggleSealArchLiner: h.toggleSealArchLiner,\n isCored: s.isCored,\n hasPostCorePeels: s.isCored && hasPostCoreUndoEntries(s.undoStack),\n splitCoarse: s.splitCoarse,\n setSplitCoarse: s.setSplitCoarse,\n faceSelection: s.faceSelection,\n setFaceSelection: s.setFaceSelection,\n loopDots: s.loopDots,\n setLoopDots: s.setLoopDots,\n hingeScrub: s.hingeScrub,\n setHingeScrub: s.setHingeScrub,\n explodeAmount: s.explodeAmount,\n setExplodeAmount: s.setExplodeAmount,\n undoStack: s.undoStack,\n statusNote: s.statusNote,\n stampTool: s.stampTool,\n setStampTool: s.setStampTool,\n patches: s.patches,\n setPatches: s.setPatches,\n liveBundle: s.liveBundle,\n busy: s.busy,\n fileRef: s.fileRef,\n rootObjRef: s.rootObjRef,\n panelJointsRef: s.panelJointsRef,\n workingScene: s.workingScene,\n assembly: s.assembly,\n setProxyAssembly: s.setProxyAssembly,\n islands: s.islands,\n wheelColors: s.wheelColors,\n loadStarterCar: s.loadStarterCar,\n ingestFile: h.ingestFile,\n applyDomainDefaults: h.applyDomainDefaults,\n handleBucketIsland: (id: number) => h.applyBucketIsland(id),\n handlePickFace: h.handlePickFace,\n updateWheelCutter: h.updateWheelCutter,\n commitWheelCutter: h.commitWheelCutter,\n applyWheelCutters: h.applyWheelCutters,\n forgeScene: (label: string, sc: THREE.Group, lenM: number) => {\n sc.userData.isProceduralLauncher = true;\n s.setAssetName(label);\n s.setRawScene(sc);\n s.setTurns([0, 0, 0]);\n s.setTargetMeters(lenM);\n s.setYOffset(0);\n s.setPatches([]);\n s.setUsdInfo(null);\n s.setHasCustomFile(false);\n },\n handleCloseLoop: h.handleCloseLoop,\n handlePeelSelection: () => {\n try {\n h.peelSelection(s.faceSelection, s.activeRole);\n } catch (err) {\n s.setStatusNote(err instanceof Error ? err.message : \"Peel failed.\");\n }\n },\n cutPart: (req: CutPartMcpRequest) =>\n executeCutPartMcp({\n req,\n workingScene: s.workingScene,\n islands: s.islands,\n creaseDeg: s.creaseDeg,\n mirrorX: s.mirrorX,\n onPeel: (sel, role) => {\n const res = h.peelSelection(sel, role);\n return res ? { status: res.status } : null;\n },\n onBucket: h.applyBucketIsland,\n }),\n handleUndoCut: () => {\n const top = s.undoStack[s.undoStack.length - 1];\n if (!top) return;\n top.undo();\n s.setUndoStack((prev) => prev.slice(0, -1));\n s.setAxles(top.axles);\n s.setPartPicks(top.picks);\n if (top.cutters !== undefined) {\n s.setWheelCutters(top.cutters);\n s.setIsCored(false);\n }\n s.setFaceSelection(null);\n s.setLoopDots(null);\n s.setCutVersion((v) => v + 1);\n s.setStatusNote(\"Undid last cut.\");\n },\n sealAndExport: async (spawnInWorld: boolean) => {\n s.setBusy(true);\n try {\n const baked = await s.runBake();\n if (spawnInWorld && onSpawnInWorld) {\n onSpawnInWorld({\n id: `${s.assetName.toLowerCase().replace(/[^a-z0-9]+/g, \"_\")}_${Date.now().toString(36)}`,\n label: s.assetName,\n kind: baked.worldKind,\n domain: s.st.domain,\n glbBytes: baked.glbBytes,\n bundle: baked.bundle,\n });\n } else {\n downloadBlobGlb(s.assetName, baked.glbBytes);\n }\n } finally {\n s.setBusy(false);\n }\n },\n uploadToVault: async (category: string, token: string) => {\n s.setBusy(true);\n try {\n const baked = await s.runBake();\n return await putAuthenticatedVaultGlb(category, s.assetName, baked.glbBytes, token);\n } finally {\n s.setBusy(false);\n }\n },\n handleStampSurface: (e: Parameters<typeof buildSurfaceStampPatch>[0]) => {\n const idx = nextStampPatchIndex(s.stampTool, s.patches, s.workingScene, s.liveBundle?.scene);\n const patch = buildSurfaceStampPatch(e, s.stampTool, idx);\n if (patch) s.setPatches((prev) => appendUniqueAnchorPatch(prev, patch, s.workingScene, s.liveBundle?.scene));\n },\n wheelCount,\n choppedCount: Object.keys(s.partPicks).length,\n unlocked: isGateStep1Unlocked(s.st.calibration, s.st.domain, s.st.vehicleArchetype, s.st.usePaperShellProxy),\n activeRoleColor: CHOP_ROLES.find((r) => r.role === s.activeRole)?.color ?? \"#FFB000\",\n bumpTurn: (ax: 0 | 1 | 2) =>\n s.setTurns((prev) => {\n const next: [QuarterTurn, QuarterTurn, QuarterTurn] = [prev[0], prev[1], prev[2]];\n next[ax] = ((next[ax] + 1) % 4) as QuarterTurn;\n return next;\n }),\n wrapProxy: h.wrapProxy,\n autoPopWheels: h.autoPopWheels,\n autoScaleSi: () => s.setTargetMeters(defaultTargetMeters(s.st.domain, s.st.vehicleArchetype).len),\n snapC12: () => s.setTargetMeters((m) => snapMetersToC12(m)),\n };\n}\n\nexport type ChopShopController = ReturnType<typeof useChopShopController>;\n"],"mappings":";;;;;;;;;AAmBA,SAAgB,sBAAsB,gBAAoD;CACtF,MAAM,IAAI,iBAAiB;CAC3B,MAAM,IAAI,uBAAuB,CAAC;CAElC,MAAM,iBAAiB,EAAE,MAAM,QAAQ,KAAK,MAAM,MAAM,EAAE,EAAE,KAAK,SAAS,KAAK,EAAE,EAAE,MAAM,SAAS,IAAI,CAAC;CACvG,MAAM,aAAa,iBAAiB,IAAI,iBAAiB,EAAE,aAAa;CAExE,OAAO;EACH,IAAI,EAAE;EACN,WAAW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,EAAE;EACb,eAAe,EAAE;EACjB,mBAAmB,EAAE,gBAAgB,oBAAoB,EAAE,GAAG,QAAQ,EAAE,GAAG,gBAAgB,CAAC,CAAC,GAAG;EAChG,eAAe,EAAE,iBAAiB,MAAM,gBAAgB,CAAC,CAAC;CAC9D;AACJ"}
|
|
1
|
+
{"version":3,"file":"useChopShopController.js","names":[],"sources":["../../src/importer/useChopShopController.ts"],"sourcesContent":["import type * as THREE from \"three\";\nimport type { PaperShellPresetId } from \"@khr3/vehicles/paper-shell\";\nimport { buildProceduralPaperShellCarGroup } from \"../sand3d/gateBakeHelpers.js\";\nimport {\n appendUniqueAnchorPatch,\n buildSurfaceStampPatch,\n downloadBlobGlb,\n executeCutPartMcp,\n hasPostCoreUndoEntries,\n nextStampPatchIndex,\n putAuthenticatedVaultGlb,\n} from \"./chopShopActions.js\";\nimport { createChopShopHandlers } from \"./chopShopHandlers.js\";\nimport type { CutPartMcpRequest } from \"./importerWebMcp.js\";\nimport { defaultTargetMeters, snapMetersToC12 } from \"./glbNormalizer.js\";\nimport { isGateStep1Unlocked } from \"./gateStore.js\";\nimport type { QuarterTurn } from \"./meshIslands.js\";\nimport { CHOP_ROLES } from \"./surfaceTopology.js\";\nimport type { GateWorldPayload } from \"./universalGateBake.js\";\nimport { useChopShopState } from \"./useChopShopState.js\";\n\nexport function useChopShopController(onSpawnInWorld?: (asset: GateWorldPayload) => void) {\n const s = useChopShopState();\n const h = createChopShopHandlers(s);\n\n const axleWheelCount = s.axles.reduce((sum, a) => sum + +(a.left.length > 0) + +(a.right.length > 0), 0);\n const wheelCount = axleWheelCount > 0 ? axleWheelCount : s.wheelCutters.length;\n\n const forgeScene = (label: string, sc: THREE.Group, lenM: number, massKg?: number, powerOrThrust?: number): void => {\n if (s.st.domain === \"launcher\") sc.userData.isProceduralLauncher = true;\n if (massKg !== undefined) s.st.setField(\"massKg\", massKg);\n if (powerOrThrust !== undefined) s.st.setField(\"powerOrThrust\", powerOrThrust);\n s.setAssetName(label);\n s.setRawScene(sc);\n s.setTurns([0, 0, 0]);\n s.setTargetMeters(lenM);\n s.setYOffset(0);\n s.setPatches([]);\n s.setUsdInfo(null);\n s.setHasCustomFile(false);\n };\n\n const forgeProceduralCar = (presetId: PaperShellPresetId): void => {\n const built = buildProceduralPaperShellCarGroup(presetId);\n s.st.setField(\"domain\", \"vehicle\");\n s.st.setField(\"vehicleArchetype\", \"car\");\n s.st.setField(\"usePaperShellProxy\", false);\n s.st.setField(\"presetId\", presetId);\n s.st.setField(\"step\", 1);\n forgeScene(presetId, built.scene, built.lengthM, built.massKg);\n s.setStatusNote(`Forged procedural ${presetId} · 4 wheels paired.`);\n };\n\n return {\n st: s.st,\n assetName: s.assetName,\n hasCustomFile: s.hasCustomFile,\n usdInfo: s.usdInfo,\n targetMeters: s.targetMeters,\n setTargetMeters: s.setTargetMeters,\n setYOffset: s.setYOffset,\n setTurns: s.setTurns,\n axles: s.axles,\n setAxles: s.setAxles,\n wheelCutters: s.wheelCutters,\n setWheelCutters: s.setWheelCutters,\n partPicks: s.partPicks,\n setPartPicks: s.setPartPicks,\n wheelSource: s.wheelSource,\n setWheelSource: s.setWheelSource,\n activeRole: s.activeRole,\n setActiveRole: s.setActiveRole,\n surfaceMode: s.surfaceMode,\n setSurfaceMode: s.setSurfaceMode,\n creaseDeg: s.creaseDeg,\n setCreaseDeg: s.setCreaseDeg,\n mirrorX: s.mirrorX,\n setMirrorX: h.toggleMirrorX,\n toggleMirrorX: h.toggleMirrorX,\n snapAxles: s.snapAxles,\n setSnapAxles: s.setSnapAxles,\n toggleSnapAxles: h.toggleSnapAxles,\n sealArchLiner: s.sealArchLiner,\n setSealArchLiner: s.setSealArchLiner,\n toggleSealArchLiner: h.toggleSealArchLiner,\n isCored: s.isCored,\n hasPostCorePeels: s.isCored && hasPostCoreUndoEntries(s.undoStack),\n splitCoarse: s.splitCoarse,\n setSplitCoarse: s.setSplitCoarse,\n faceSelection: s.faceSelection,\n setFaceSelection: s.setFaceSelection,\n loopDots: s.loopDots,\n setLoopDots: s.setLoopDots,\n hingeScrub: s.hingeScrub,\n setHingeScrub: s.setHingeScrub,\n explodeAmount: s.explodeAmount,\n setExplodeAmount: s.setExplodeAmount,\n undoStack: s.undoStack,\n statusNote: s.statusNote,\n stampTool: s.stampTool,\n setStampTool: s.setStampTool,\n patches: s.patches,\n setPatches: s.setPatches,\n liveBundle: s.liveBundle,\n busy: s.busy,\n fileRef: s.fileRef,\n rootObjRef: s.rootObjRef,\n panelJointsRef: s.panelJointsRef,\n workingScene: s.workingScene,\n assembly: s.assembly,\n setProxyAssembly: s.setProxyAssembly,\n islands: s.islands,\n wheelColors: s.wheelColors,\n loadStarterCar: s.loadStarterCar,\n ingestFile: h.ingestFile,\n applyDomainDefaults: h.applyDomainDefaults,\n handleBucketIsland: (id: number) => h.applyBucketIsland(id),\n handlePickFace: h.handlePickFace,\n updateWheelCutter: h.updateWheelCutter,\n commitWheelCutter: h.commitWheelCutter,\n applyWheelCutters: h.applyWheelCutters,\n forgeScene,\n forgeProceduralCar,\n handleCloseLoop: h.handleCloseLoop,\n handlePeelSelection: () => {\n try {\n h.peelSelection(s.faceSelection, s.activeRole);\n } catch (err) {\n s.setStatusNote(err instanceof Error ? err.message : \"Peel action failed.\");\n }\n },\n cutPart: (req: CutPartMcpRequest) =>\n executeCutPartMcp({\n req,\n workingScene: s.workingScene,\n islands: s.islands,\n creaseDeg: s.creaseDeg,\n mirrorX: s.mirrorX,\n onPeel: (sel, role) => {\n const res = h.peelSelection(sel, role);\n return res ? { status: res.status } : null;\n },\n onBucket: h.applyBucketIsland,\n }),\n handleUndoCut: () => {\n const top = s.undoStack[s.undoStack.length - 1];\n if (!top) return;\n top.undo();\n s.setUndoStack((prev) => prev.slice(0, -1));\n s.setAxles(top.axles);\n s.setPartPicks(top.picks);\n if (top.cutters !== undefined) {\n s.setWheelCutters(top.cutters);\n s.setIsCored(false);\n }\n s.setFaceSelection(null);\n s.setLoopDots(null);\n s.setCutVersion((v) => v + 1);\n s.setStatusNote(\"Restored previous cut state.\");\n },\n sealAndExport: async (spawnInWorld: boolean) => {\n s.setBusy(true);\n try {\n const baked = await s.runBake();\n if (spawnInWorld && onSpawnInWorld) {\n onSpawnInWorld({\n id: `${s.assetName.toLowerCase().replace(/[^a-z0-9]+/g, \"_\")}_${Date.now().toString(36)}`,\n label: s.assetName,\n kind: baked.worldKind,\n domain: s.st.domain,\n glbBytes: baked.glbBytes,\n bundle: baked.bundle,\n });\n } else {\n downloadBlobGlb(s.assetName, baked.glbBytes);\n }\n } finally {\n s.setBusy(false);\n }\n },\n uploadToVault: async (category: string, token: string) => {\n s.setBusy(true);\n try {\n const baked = await s.runBake();\n return await putAuthenticatedVaultGlb(category, s.assetName, baked.glbBytes, token);\n } finally {\n s.setBusy(false);\n }\n },\n handleStampSurface: (e: Parameters<typeof buildSurfaceStampPatch>[0]) => {\n const idx = nextStampPatchIndex(s.stampTool, s.patches, s.workingScene, s.liveBundle?.scene);\n const patch = buildSurfaceStampPatch(e, s.stampTool, idx);\n if (patch) s.setPatches((prev) => appendUniqueAnchorPatch(prev, patch, s.workingScene, s.liveBundle?.scene));\n },\n wheelCount,\n choppedCount: Object.keys(s.partPicks).length,\n unlocked: isGateStep1Unlocked(s.st.calibration, s.st.domain, s.st.vehicleArchetype, s.st.usePaperShellProxy),\n activeRoleColor: CHOP_ROLES.find((r) => r.role === s.activeRole)?.color ?? \"#FFB000\",\n bumpTurn: (ax: 0 | 1 | 2) =>\n s.setTurns((prev) => {\n const next: [QuarterTurn, QuarterTurn, QuarterTurn] = [prev[0], prev[1], prev[2]];\n next[ax] = ((next[ax] + 1) % 4) as QuarterTurn;\n return next;\n }),\n wrapProxy: h.wrapProxy,\n autoPopWheels: h.autoPopWheels,\n autoScaleSi: () => s.setTargetMeters(defaultTargetMeters(s.st.domain, s.st.vehicleArchetype).len),\n snapC12: () => s.setTargetMeters((m) => snapMetersToC12(m)),\n };\n}\n\nexport type ChopShopController = ReturnType<typeof useChopShopController>;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B;EACJ;EACA,eAAe,OAAO,UAAkB,UAAkB;GACtD,EAAE,QAAQ,IAAI;GACd,IAAI;IACA,MAAM,QAAQ,MAAM,EAAE,QAAQ;IAC9B,OAAO,MAAM,yBAAyB,UAAU,EAAE,WAAW,MAAM,UAAU,KAAK;GACtF,UAAU;IACN,EAAE,QAAQ,KAAK;GACnB;EACJ;EACA,qBAAqB,MAAoD;GACrE,MAAM,MAAM,oBAAoB,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,KAAK;GAC3F,MAAM,QAAQ,uBAAuB,GAAG,EAAE,WAAW,GAAG;GACxD,IAAI,OAAO,EAAE,YAAY,SAAS,wBAAwB,MAAM,OAAO,EAAE,cAAc,EAAE,YAAY,KAAK,CAAC;EAC/G;EACA;EACA,cAAc,OAAO,KAAK,EAAE,SAAS,CAAC,CAAC;EACvC,UAAU,oBAAoB,EAAE,GAAG,aAAa,EAAE,GAAG,QAAQ,EAAE,GAAG,kBAAkB,EAAE,GAAG,kBAAkB;EAC3G,iBAAiB,WAAW,MAAM,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC,EAAE,SAAS;EAC3E,WAAW,OACP,EAAE,UAAU,SAAS;GACjB,MAAM,OAAgD;IAAC,KAAK;IAAI,KAAK;IAAI,KAAK;GAAE;GAChF,KAAK,OAAQ,KAAK,MAAM,KAAK;GAC7B,OAAO;EACX,CAAC;EACL,WAAW,EAAE;EACb,eAAe,EAAE;EACjB,mBAAmB,EAAE,gBAAgB,oBAAoB,EAAE,GAAG,QAAQ,EAAE,GAAG,gBAAgB,CAAC,CAAC,GAAG;EAChG,eAAe,EAAE,iBAAiB,MAAM,gBAAgB,CAAC,CAAC;CAC9D;AACJ"}
|
|
@@ -6,10 +6,10 @@ import type { KolmoAuthoredNodePatch } from "../schema/kolmoSchema.js";
|
|
|
6
6
|
import type { StampToolId } from "./GateHudBar.js";
|
|
7
7
|
import { type WheelCutterSpec } from "./fusedWheelDetect.js";
|
|
8
8
|
import { type GateDomain, type VehicleSubArchetype } from "./gateStore.js";
|
|
9
|
-
export declare function shouldAutoDetectVehicleCutters(domain: GateDomain, archetype: VehicleSubArchetype, suggestedAxlesCount: number): boolean;
|
|
10
9
|
import type { WheelVisualSource } from "./khrCompiler.js";
|
|
11
10
|
import { type OrientTurns, type WheelAxle } from "./meshIslands.js";
|
|
12
11
|
import type { ActiveChopRole, ChopPartRole, CutVec3, FaceSelection, SurfaceSelectMode } from "./surfaceCutter.js";
|
|
12
|
+
export declare function shouldAutoDetectVehicleCutters(domain: GateDomain, archetype: VehicleSubArchetype, suggestedAxlesCount: number): boolean;
|
|
13
13
|
export interface CutUndoEntry {
|
|
14
14
|
readonly undo: () => void;
|
|
15
15
|
readonly axles: WheelAxle[];
|