@pinkaphant/kolmo 0.2.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +36 -36
- package/bin/kolmo.mjs +12 -6
- package/dist/engine/causewayBridge.d.ts +14 -0
- package/dist/engine/causewayBridge.js +166 -0
- package/dist/engine/causewayBridge.js.map +1 -0
- package/dist/engine/index.d.ts +6 -4
- package/dist/engine/index.js +19 -12
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/islandSettlementMesh.d.ts +26 -0
- package/dist/engine/islandSettlementMesh.js +166 -0
- package/dist/engine/islandSettlementMesh.js.map +1 -0
- package/dist/engine/kolmoActions.d.ts +23 -0
- package/dist/engine/kolmoActions.js +164 -0
- package/dist/engine/kolmoActions.js.map +1 -0
- package/dist/engine/kolmoActor.js +242 -165
- package/dist/engine/kolmoActor.js.map +1 -0
- package/dist/engine/kolmoFloatingOrigin.d.ts +17 -0
- package/dist/engine/kolmoFloatingOrigin.js +98 -0
- package/dist/engine/kolmoFloatingOrigin.js.map +1 -0
- package/dist/engine/kolmoGame.d.ts +27 -0
- package/dist/engine/kolmoGame.js +80 -0
- package/dist/engine/kolmoGame.js.map +1 -0
- package/dist/engine/kolmoHud.d.ts +23 -0
- package/dist/engine/kolmoHud.js +195 -0
- package/dist/engine/kolmoHud.js.map +1 -0
- package/dist/engine/kolmoInput.d.ts +1 -1
- package/dist/engine/kolmoInput.js +57 -30
- package/dist/engine/kolmoInput.js.map +1 -0
- package/dist/engine/kolmoIsland.d.ts +5 -10
- package/dist/engine/kolmoIsland.js +182 -250
- package/dist/engine/kolmoIsland.js.map +1 -0
- package/dist/engine/kolmoLongDrive.d.ts +3 -4
- package/dist/engine/kolmoLongDrive.js +140 -205
- package/dist/engine/kolmoLongDrive.js.map +1 -0
- package/dist/engine/kolmoPilotMesh.d.ts +2 -0
- package/dist/engine/kolmoPilotMesh.js +64 -0
- package/dist/engine/kolmoPilotMesh.js.map +1 -0
- package/dist/engine/kolmoProcedural.d.ts +13 -0
- package/dist/engine/kolmoProcedural.js +101 -0
- package/dist/engine/kolmoProcedural.js.map +1 -0
- package/dist/engine/kolmoRigs.d.ts +1 -1
- package/dist/engine/kolmoRigs.js +88 -47
- package/dist/engine/kolmoRigs.js.map +1 -0
- package/dist/engine/kolmoStore.d.ts +3 -100
- package/dist/engine/kolmoSurface.d.ts +2 -2
- package/dist/engine/kolmoSurface.js +150 -134
- package/dist/engine/kolmoSurface.js.map +1 -0
- package/dist/engine/kolmoTraits.d.ts +128 -0
- package/dist/engine/kolmoTraits.js +140 -0
- package/dist/engine/kolmoTraits.js.map +1 -0
- package/dist/engine/kolmoVehicle.d.ts +3 -33
- package/dist/engine/kolmoVehicle.js +66 -240
- package/dist/engine/kolmoVehicle.js.map +1 -0
- package/dist/engine/kolmoVehicleConfig.d.ts +54 -0
- package/dist/engine/kolmoVehicleConfig.js +80 -0
- package/dist/engine/kolmoVehicleConfig.js.map +1 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +4 -1
- package/dist/engine/kolmoVehicleDriver.js +116 -22
- package/dist/engine/kolmoVehicleDriver.js.map +1 -0
- package/dist/engine/kolmoVehicleInner.d.ts +7 -0
- package/dist/engine/kolmoVehicleInner.js +261 -0
- package/dist/engine/kolmoVehicleInner.js.map +1 -0
- package/dist/engine/kolmoWorld.d.ts +6 -4
- package/dist/engine/kolmoWorld.js +134 -116
- package/dist/engine/kolmoWorld.js.map +1 -0
- package/dist/engine/longDriveKit.d.ts +5 -12
- package/dist/engine/longDriveKit.js +121 -233
- package/dist/engine/longDriveKit.js.map +1 -0
- package/dist/engine/longDriveRoadside.d.ts +16 -0
- package/dist/engine/longDriveRoadside.js +171 -0
- package/dist/engine/longDriveRoadside.js.map +1 -0
- package/dist/engine/macroCellBuilder.d.ts +34 -0
- package/dist/engine/macroCellBuilder.js +145 -0
- package/dist/engine/macroCellBuilder.js.map +1 -0
- package/dist/engine/mainlandMacroCell.d.ts +2 -2
- package/dist/engine/mainlandMacroCell.js +77 -165
- package/dist/engine/mainlandMacroCell.js.map +1 -0
- package/dist/engine/shiftedFixedBody.d.ts +1 -1
- package/dist/engine/shiftedFixedBody.js +55 -28
- package/dist/engine/shiftedFixedBody.js.map +1 -0
- package/dist/importer/ChopShopPanel.d.ts +9 -1
- package/dist/importer/ChopShopPanel.js +303 -359
- package/dist/importer/ChopShopPanel.js.map +1 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +2 -1
- package/dist/importer/DomainWorkshopPanel.js +172 -242
- package/dist/importer/DomainWorkshopPanel.js.map +1 -0
- package/dist/importer/GateHudBar.d.ts +8 -0
- package/dist/importer/GateHudBar.js +290 -279
- package/dist/importer/GateHudBar.js.map +1 -0
- package/dist/importer/GlbImportGate.d.ts +2 -1
- package/dist/importer/GlbImportGate.js +252 -225
- package/dist/importer/GlbImportGate.js.map +1 -0
- package/dist/importer/ImperativeVehicleRig.d.ts +2 -2
- package/dist/importer/ImperativeVehicleRig.js +223 -284
- package/dist/importer/ImperativeVehicleRig.js.map +1 -0
- package/dist/importer/LiveDrivePads.d.ts +20 -0
- package/dist/importer/LiveDrivePads.js +169 -0
- package/dist/importer/LiveDrivePads.js.map +1 -0
- package/dist/importer/PaperShellDebrisRig.d.ts +25 -0
- package/dist/importer/PaperShellDebrisRig.js +143 -0
- package/dist/importer/PaperShellDebrisRig.js.map +1 -0
- package/dist/importer/R2VaultDrawer.d.ts +12 -0
- package/dist/importer/R2VaultDrawer.js +90 -0
- package/dist/importer/R2VaultDrawer.js.map +1 -0
- package/dist/importer/Step1CalibrationPlinth.d.ts +23 -5
- package/dist/importer/Step1CalibrationPlinth.js +180 -251
- package/dist/importer/Step1CalibrationPlinth.js.map +1 -0
- package/dist/importer/Step1ExplodedIslands.d.ts +31 -0
- package/dist/importer/Step1ExplodedIslands.js +144 -0
- package/dist/importer/Step1ExplodedIslands.js.map +1 -0
- package/dist/importer/Step2UniversalPad.d.ts +7 -7
- package/dist/importer/Step2UniversalPad.js +49 -170
- package/dist/importer/Step2UniversalPad.js.map +1 -0
- package/dist/importer/VfxEmitterPool.js +59 -86
- package/dist/importer/VfxEmitterPool.js.map +1 -0
- package/dist/importer/WheelRingHandles3D.d.ts +11 -0
- package/dist/importer/WheelRingHandles3D.js +318 -0
- package/dist/importer/WheelRingHandles3D.js.map +1 -0
- package/dist/importer/archLinerGeom.d.ts +2 -0
- package/dist/importer/archLinerGeom.js +51 -0
- package/dist/importer/archLinerGeom.js.map +1 -0
- package/dist/importer/{vehiclePanelAnim.d.ts → chopHingeHelpers.d.ts} +0 -10
- package/dist/importer/chopHingeHelpers.js +193 -0
- package/dist/importer/chopHingeHelpers.js.map +1 -0
- package/dist/importer/chopShopActions.d.ts +20 -26
- package/dist/importer/chopShopActions.js +135 -210
- package/dist/importer/chopShopActions.js.map +1 -0
- package/dist/importer/chopShopHandlers.d.ts +26 -0
- package/dist/importer/chopShopHandlers.js +276 -0
- package/dist/importer/chopShopHandlers.js.map +1 -0
- package/dist/importer/chopShopIoActions.d.ts +15 -0
- package/dist/importer/chopShopIoActions.js +137 -0
- package/dist/importer/chopShopIoActions.js.map +1 -0
- package/dist/importer/chopShopMcpAction.d.ts +18 -0
- package/dist/importer/chopShopMcpAction.js +58 -0
- package/dist/importer/chopShopMcpAction.js.map +1 -0
- package/dist/importer/cylinderBooleanSlice.d.ts +14 -0
- package/dist/importer/cylinderBooleanSlice.js +110 -0
- package/dist/importer/cylinderBooleanSlice.js.map +1 -0
- package/dist/importer/cylinderSliceMath.d.ts +14 -0
- package/dist/importer/cylinderSliceMath.js +251 -0
- package/dist/importer/cylinderSliceMath.js.map +1 -0
- package/dist/importer/fusedWheelDetect.d.ts +4 -0
- package/dist/importer/fusedWheelDetect.js +175 -0
- package/dist/importer/fusedWheelDetect.js.map +1 -0
- package/dist/importer/fusedWheelFit.d.ts +13 -0
- package/dist/importer/fusedWheelFit.js +138 -0
- package/dist/importer/fusedWheelFit.js.map +1 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +36 -27
- package/dist/importer/gateStore.js.map +1 -0
- package/dist/importer/glbNormalizer.js +118 -79
- package/dist/importer/glbNormalizer.js.map +1 -0
- package/dist/importer/importerWebMcp.d.ts +4 -3
- package/dist/importer/importerWebMcp.js +41 -336
- package/dist/importer/importerWebMcp.js.map +1 -0
- package/dist/importer/importerWebMcpTools.d.ts +2 -0
- package/dist/importer/importerWebMcpTools.js +340 -0
- package/dist/importer/importerWebMcpTools.js.map +1 -0
- package/dist/importer/index.d.ts +4 -0
- package/dist/importer/index.js +32 -22
- package/dist/importer/index.js.map +1 -0
- package/dist/importer/khrCarPlanHelpers.d.ts +28 -0
- package/dist/importer/khrCarPlanHelpers.js +221 -0
- package/dist/importer/khrCarPlanHelpers.js.map +1 -0
- package/dist/importer/khrCarPlanner.d.ts +7 -0
- package/dist/importer/khrCarPlanner.js +279 -0
- package/dist/importer/khrCarPlanner.js.map +1 -0
- package/dist/importer/khrCompiler.d.ts +4 -22
- package/dist/importer/khrCompiler.js +56 -424
- package/dist/importer/khrCompiler.js.map +1 -0
- package/dist/importer/khrCraftPropCompiler.d.ts +40 -0
- package/dist/importer/khrCraftPropCompiler.js +250 -0
- package/dist/importer/khrCraftPropCompiler.js.map +1 -0
- package/dist/importer/launcherBake.js +76 -35
- package/dist/importer/launcherBake.js.map +1 -0
- package/dist/importer/meshIslands.d.ts +4 -46
- package/dist/importer/meshIslands.js +84 -283
- package/dist/importer/meshIslands.js.map +1 -0
- package/dist/importer/meshSliceBuffers.d.ts +15 -0
- package/dist/importer/meshSliceBuffers.js +159 -0
- package/dist/importer/meshSliceBuffers.js.map +1 -0
- package/dist/importer/polygonEarClipYZ.d.ts +3 -0
- package/dist/importer/polygonEarClipYZ.js +67 -0
- package/dist/importer/polygonEarClipYZ.js.map +1 -0
- package/dist/importer/sceneSiNormalize.d.ts +19 -0
- package/dist/importer/sceneSiNormalize.js +138 -0
- package/dist/importer/sceneSiNormalize.js.map +1 -0
- package/dist/importer/starterScene.d.ts +3 -0
- package/dist/importer/starterScene.js +76 -0
- package/dist/importer/starterScene.js.map +1 -0
- package/dist/importer/surfaceCutter.d.ts +4 -15
- package/dist/importer/surfaceCutter.js +69 -240
- package/dist/importer/surfaceCutter.js.map +1 -0
- package/dist/importer/surfaceGeodesic.d.ts +7 -0
- package/dist/importer/surfaceGeodesic.js +130 -0
- package/dist/importer/surfaceGeodesic.js.map +1 -0
- package/dist/importer/surfaceLoopRefine.d.ts +6 -0
- package/dist/importer/surfaceLoopRefine.js +171 -0
- package/dist/importer/surfaceLoopRefine.js.map +1 -0
- package/dist/importer/surfacePeel.d.ts +11 -0
- package/dist/importer/surfacePeel.js +119 -0
- package/dist/importer/surfacePeel.js.map +1 -0
- package/dist/importer/surfaceTopology.d.ts +2 -6
- package/dist/importer/surfaceTopology.js +93 -133
- package/dist/importer/surfaceTopology.js.map +1 -0
- package/dist/importer/universalGateBake.d.ts +7 -3
- package/dist/importer/universalGateBake.js +104 -106
- package/dist/importer/universalGateBake.js.map +1 -0
- package/dist/importer/usdPhysicsSpecs.d.ts +3 -0
- package/dist/importer/usdPhysicsSpecs.js +245 -0
- package/dist/importer/usdPhysicsSpecs.js.map +1 -0
- package/dist/importer/usdTextParse.d.ts +12 -0
- package/dist/importer/usdTextParse.js +118 -0
- package/dist/importer/usdTextParse.js.map +1 -0
- package/dist/importer/usdToGlb.d.ts +3 -2
- package/dist/importer/usdToGlb.js +80 -280
- package/dist/importer/usdToGlb.js.map +1 -0
- package/dist/importer/useChopShopController.d.ts +50 -47
- package/dist/importer/useChopShopController.js +156 -338
- package/dist/importer/useChopShopController.js.map +1 -0
- package/dist/importer/useChopShopState.d.ts +103 -0
- package/dist/importer/useChopShopState.js +319 -0
- package/dist/importer/useChopShopState.js.map +1 -0
- package/dist/importer/useWasdKeyRef.d.ts +9 -0
- package/dist/importer/useWasdKeyRef.js +35 -0
- package/dist/importer/useWasdKeyRef.js.map +1 -0
- package/dist/importer/vehiclePartSplit.d.ts +33 -0
- package/dist/importer/vehiclePartSplit.js +178 -0
- package/dist/importer/vehiclePartSplit.js.map +1 -0
- package/dist/importer/wheelAxlePairing.js +106 -70
- package/dist/importer/wheelAxlePairing.js.map +1 -0
- package/dist/importer/wheelCutterHelpers.d.ts +42 -0
- package/dist/importer/wheelCutterHelpers.js +178 -0
- package/dist/importer/wheelCutterHelpers.js.map +1 -0
- package/dist/importer/wheelRingHandleMath.d.ts +20 -0
- package/dist/importer/wheelRingHandleMath.js +66 -0
- package/dist/importer/wheelRingHandleMath.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +90 -66
- package/dist/index.js.map +1 -0
- package/dist/junk/DestructibleTarget.d.ts +3 -3
- package/dist/junk/DestructibleTarget.js +177 -114
- package/dist/junk/DestructibleTarget.js.map +1 -0
- package/dist/junk/KolmoJunk.js +55 -44
- package/dist/junk/KolmoJunk.js.map +1 -0
- package/dist/junk/ShardPieces.d.ts +2 -1
- package/dist/junk/ShardPieces.js +80 -61
- package/dist/junk/ShardPieces.js.map +1 -0
- package/dist/junk/TargetDecals.d.ts +6 -15
- package/dist/junk/TargetDecals.js +66 -40
- package/dist/junk/TargetDecals.js.map +1 -0
- package/dist/junk/bvhShatter.d.ts +2 -6
- package/dist/junk/bvhShatter.js +89 -43
- package/dist/junk/bvhShatter.js.map +1 -0
- package/dist/junk/bvhTriCollector.d.ts +2 -6
- package/dist/junk/bvhTriCollector.js +111 -62
- package/dist/junk/bvhTriCollector.js.map +1 -0
- package/dist/junk/index.d.ts +2 -2
- package/dist/junk/index.js +11 -11
- package/dist/junk/index.js.map +1 -0
- package/dist/junk/junkGeometry.d.ts +5 -26
- package/dist/junk/junkGeometry.js +61 -43
- package/dist/junk/junkGeometry.js.map +1 -0
- package/dist/junk/junkImportSanitize.d.ts +4 -5
- package/dist/junk/junkImportSanitize.js +57 -37
- package/dist/junk/junkImportSanitize.js.map +1 -0
- package/dist/junk/junkImporter.d.ts +2 -13
- package/dist/junk/junkImporter.js +105 -76
- package/dist/junk/junkImporter.js.map +1 -0
- package/dist/junk/junkLabelCanvas.d.ts +1 -6
- package/dist/junk/junkLabelCanvas.js +147 -29
- package/dist/junk/junkLabelCanvas.js.map +1 -0
- package/dist/junk/junkLabels.d.ts +4 -26
- package/dist/junk/junkLabels.js +42 -28
- package/dist/junk/junkLabels.js.map +1 -0
- package/dist/junk/targetHelpers.d.ts +3 -4
- package/dist/junk/targetHelpers.js +121 -67
- package/dist/junk/targetHelpers.js.map +1 -0
- package/dist/junk/targetHitLogic.d.ts +8 -8
- package/dist/junk/targetHitLogic.js +131 -95
- package/dist/junk/targetHitLogic.js.map +1 -0
- package/dist/junk/useTargetAssets.d.ts +9 -14
- package/dist/junk/useTargetAssets.js +113 -85
- package/dist/junk/useTargetAssets.js.map +1 -0
- package/dist/physics/index.d.ts +1 -1
- package/dist/physics/index.js +79 -58
- package/dist/physics/index.js.map +1 -0
- package/dist/schema/kolmoSchema.d.ts +3 -64
- package/dist/schema/kolmoSchema.js +75 -149
- package/dist/schema/kolmoSchema.js.map +1 -0
- package/dist/schema/kolmoStamp.d.ts +6 -0
- package/dist/schema/kolmoStamp.js +71 -0
- package/dist/schema/kolmoStamp.js.map +1 -0
- package/dist/schema/kolmoTypes.d.ts +63 -0
- package/dist/schema/kolmoTypes.js +66 -0
- package/dist/schema/kolmoTypes.js.map +1 -0
- package/dist/shaders/celestialBackdrop.d.ts +2 -10
- package/dist/shaders/celestialBackdrop.js +128 -291
- package/dist/shaders/celestialBackdrop.js.map +1 -0
- package/dist/shaders/emitterShaders.d.ts +9 -0
- package/dist/shaders/emitterShaders.js +114 -0
- package/dist/shaders/emitterShaders.js.map +1 -0
- package/dist/shaders/index.d.ts +1 -1
- package/dist/shaders/index.js +12 -9
- package/dist/shaders/index.js.map +1 -0
- package/dist/shaders/plumeAndSparkle.d.ts +2 -4
- package/dist/shaders/plumeAndSparkle.js +152 -191
- package/dist/shaders/plumeAndSparkle.js.map +1 -0
- package/dist/shaders/ps2GlslShared.js +29 -2
- package/dist/shaders/ps2GlslShared.js.map +1 -0
- package/dist/shaders/ps2MaterialsTSL.js +132 -51
- package/dist/shaders/ps2MaterialsTSL.js.map +1 -0
- package/dist/shaders/ps2MaterialsWebGL.js +45 -28
- package/dist/shaders/ps2MaterialsWebGL.js.map +1 -0
- package/dist/shaders/ps2RoadWebGL.js +69 -32
- package/dist/shaders/ps2RoadWebGL.js.map +1 -0
- package/dist/shaders/ps2TerrainWebGL.js +107 -30
- package/dist/shaders/ps2TerrainWebGL.js.map +1 -0
- package/dist/shaders/ps2Textures.d.ts +1 -1
- package/dist/shaders/ps2Textures.js +116 -41
- package/dist/shaders/ps2Textures.js.map +1 -0
- package/dist/shaders/retroPalettes.d.ts +1 -1
- package/dist/shaders/retroPalettes.js +90 -57
- package/dist/shaders/retroPalettes.js.map +1 -0
- package/dist/shaders/retroShader.d.ts +2 -86
- package/dist/shaders/retroShader.js +65 -196
- package/dist/shaders/retroShader.js.map +1 -0
- package/dist/shaders/retroUniforms.d.ts +60 -0
- package/dist/shaders/retroUniforms.js +215 -0
- package/dist/shaders/retroUniforms.js.map +1 -0
- package/dist/shaders/skyboxShaders.d.ts +16 -0
- package/dist/shaders/skyboxShaders.js +266 -0
- package/dist/shaders/skyboxShaders.js.map +1 -0
- package/dist/shaders/tsl.d.ts +1 -1
- package/dist/shaders/tsl.js.map +1 -0
- package/dist/vite/index.js +39 -23
- package/dist/vite/index.js.map +1 -0
- package/dist/world/frontage.js +25 -21
- package/dist/world/frontage.js.map +1 -0
- package/dist/world/index.d.ts +4 -4
- package/dist/world/index.js +12 -11
- package/dist/world/index.js.map +1 -0
- package/dist/world/infiniteWorld2D.d.ts +0 -5
- package/dist/world/infiniteWorld2D.js +175 -200
- package/dist/world/infiniteWorld2D.js.map +1 -0
- package/dist/world/island.js +81 -166
- package/dist/world/island.js.map +1 -0
- package/dist/world/islandPathing.d.ts +6 -0
- package/dist/world/islandPathing.js +166 -0
- package/dist/world/islandPathing.js.map +1 -0
- package/dist/world/macroCellSchema.js +15 -8
- package/dist/world/macroCellSchema.js.map +1 -0
- package/dist/world/macroKnightAStar.js +140 -71
- package/dist/world/macroKnightAStar.js.map +1 -0
- package/dist/world/macroSettlementZones.d.ts +9 -0
- package/dist/world/macroSettlementZones.js +108 -0
- package/dist/world/macroSettlementZones.js.map +1 -0
- package/dist/world/random.js +50 -24
- package/dist/world/random.js.map +1 -0
- package/dist/world/road.js +152 -90
- package/dist/world/road.js.map +1 -0
- package/dist/world/roadRibbon.d.ts +4 -19
- package/dist/world/roadRibbon.js +129 -124
- package/dist/world/roadRibbon.js.map +1 -0
- package/dist/world/terrain.d.ts +1 -1
- package/dist/world/terrain.js +111 -65
- package/dist/world/terrain.js.map +1 -0
- package/dist/world/terrainGeometry.d.ts +14 -0
- package/dist/world/terrainGeometry.js +76 -0
- package/dist/world/terrainGeometry.js.map +1 -0
- package/dist/world/worldTypes.d.ts +3 -3
- package/dist/world/worldTypes.js +133 -67
- package/dist/world/worldTypes.js.map +1 -0
- package/docs/api-reference.md +187 -0
- package/package.json +58 -32
- package/dist/engine/kolmoStore.js +0 -211
- package/dist/importer/ImporterPlinthUikitTags.d.ts +0 -19
- package/dist/importer/ImporterPlinthUikitTags.js +0 -112
- package/dist/importer/vehiclePanelAnim.js +0 -214
|
@@ -1,432 +1,64 @@
|
|
|
1
|
-
import { stampKolmoNodesIntoGlb
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { exportKhrGlb as f } from "@khr3/core";
|
|
9
|
-
import { ENGINE_TORQUE_CURVES as p, STEER_SPEED_CURVES as m, TIRE_ARCHETYPES as h, tireGripForSurface as g } from "@khr3/core/curves";
|
|
1
|
+
import { stampKolmoNodesIntoGlb } from "../schema/kolmoStamp.js";
|
|
2
|
+
import { buildCarExportPlan } from "./khrCarPlanner.js";
|
|
3
|
+
import { buildCraftExportPlan, buildPropExportPlan, collectPreservedRigPatches, restoreStrippedTextures, stripUnloadedTextures } from "./khrCraftPropCompiler.js";
|
|
4
|
+
import { buildPatchPreviewEmitters, computeChopPartHinge, normalToMinusZQuaternion } from "./chopHingeHelpers.js";
|
|
5
|
+
import { isMeshObject } from "./sceneSiNormalize.js";
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
import { exportKhrGlb } from "@khr3/core";
|
|
10
8
|
// src/importer/khrCompiler.ts
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
for (let t of [1, -1]) {
|
|
27
|
-
let r = a("door").filter((e) => (i.get(e).center[0] >= 0 ? 1 : -1) === t);
|
|
28
|
-
if (r.length === 0) continue;
|
|
29
|
-
let o = r.map((e) => i.get(e).center[2]), u = Math.max(...o) - Math.min(...o), d = (Math.min(...o) + Math.max(...o)) * .5;
|
|
30
|
-
(u > .85 ? [r.filter((e) => i.get(e).center[2] >= d), r.filter((e) => i.get(e).center[2] < d)] : [r]).filter((e) => e.length > 0).forEach((r, i) => {
|
|
31
|
-
let a = `${i === 0 ? "F" : "R"}${t > 0 ? "L" : "R"}`;
|
|
32
|
-
s.push({
|
|
33
|
-
nodeName: `Door_${a}`,
|
|
34
|
-
role: `door_${a.toLowerCase()}`,
|
|
35
|
-
islandIds: r,
|
|
36
|
-
massKg: l("door"),
|
|
37
|
-
hinge: c(n(e, r), "door")
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
for (let t of ["hood", "trunk"]) {
|
|
42
|
-
let r = a(t);
|
|
43
|
-
r.length > 0 && s.push({
|
|
44
|
-
nodeName: t === "hood" ? "Hood" : "Trunk",
|
|
45
|
-
role: t,
|
|
46
|
-
islandIds: r,
|
|
47
|
-
massKg: l(t),
|
|
48
|
-
hinge: c(n(e, r), t)
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
for (let t of ["fender", "bumper"]) a(t).forEach((r, i) => {
|
|
52
|
-
s.push({
|
|
53
|
-
nodeName: `${t === "fender" ? "Fender" : "Bumper"}_${i + 1}`,
|
|
54
|
-
role: t,
|
|
55
|
-
islandIds: [r],
|
|
56
|
-
massKg: l(t),
|
|
57
|
-
hinge: c(n(e, [r]), t)
|
|
58
|
-
});
|
|
9
|
+
function computeLocalBounds(root) {
|
|
10
|
+
root.updateMatrixWorld(true);
|
|
11
|
+
const invRoot = new THREE.Matrix4().copy(root.matrixWorld).invert();
|
|
12
|
+
const relMat = new THREE.Matrix4();
|
|
13
|
+
const box = new THREE.Box3();
|
|
14
|
+
const v = new THREE.Vector3();
|
|
15
|
+
root.traverse((obj) => {
|
|
16
|
+
if (!isMeshObject(obj)) return;
|
|
17
|
+
const pos = obj.geometry.getAttribute("position");
|
|
18
|
+
if (!pos || pos.count === 0) return;
|
|
19
|
+
relMat.multiplyMatrices(invRoot, obj.matrixWorld);
|
|
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)) box.expandByPoint(v);
|
|
23
|
+
}
|
|
59
24
|
});
|
|
60
|
-
|
|
25
|
+
if (box.isEmpty()) box.set(new THREE.Vector3(-.5, 0, -.5), new THREE.Vector3(.5, 1, .5));
|
|
26
|
+
return box;
|
|
61
27
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
let s = n(e, t.left), c = t.right.length > 0 ? n(e, t.right) : s, l = Math.max(.12, s.radius, c.radius), u = Math.max(.09, Math.max(s.halfWidth, c.halfWidth) * 2), d = r === "AWD" || i === 1 ? !0 : r === "FWD" ? a === 0 : a > 0, f = t.steered ?? a === 0, p = t.driven ?? d, m = t.brake ?? !0, h = i === 2 ? a === 0 ? "F" : "R" : `A${a}`;
|
|
71
|
-
t.right.length === 0 ? o.push({
|
|
72
|
-
nodeName: `Wheel_${h}C`,
|
|
73
|
-
islandIds: [...t.left],
|
|
74
|
-
radius: l,
|
|
75
|
-
width: u,
|
|
76
|
-
steered: f,
|
|
77
|
-
driven: p,
|
|
78
|
-
brake: m
|
|
79
|
-
}) : (o.push({
|
|
80
|
-
nodeName: `Wheel_${h}L`,
|
|
81
|
-
islandIds: [...t.left],
|
|
82
|
-
radius: l,
|
|
83
|
-
width: u,
|
|
84
|
-
steered: f,
|
|
85
|
-
driven: p,
|
|
86
|
-
brake: m
|
|
87
|
-
}), o.push({
|
|
88
|
-
nodeName: `Wheel_${h}R`,
|
|
89
|
-
islandIds: [...t.right],
|
|
90
|
-
radius: l,
|
|
91
|
-
width: u,
|
|
92
|
-
steered: f,
|
|
93
|
-
driven: p,
|
|
94
|
-
brake: m
|
|
95
|
-
}));
|
|
96
|
-
}), o;
|
|
97
|
-
}
|
|
98
|
-
let [o, s, c] = i, l = Math.max(.26, Math.min(.42, s * .24)), u = Math.max(.18, o * .14), d = o * .41, f = c * .32, p = r === "AWD" || r === "FWD", m = r === "AWD" || r === "RWD";
|
|
99
|
-
return [
|
|
100
|
-
{
|
|
101
|
-
nodeName: "Wheel_FL",
|
|
102
|
-
islandIds: [],
|
|
103
|
-
fallbackPos: [
|
|
104
|
-
d,
|
|
105
|
-
l,
|
|
106
|
-
f
|
|
107
|
-
],
|
|
108
|
-
radius: l,
|
|
109
|
-
width: u,
|
|
110
|
-
steered: !0,
|
|
111
|
-
driven: p,
|
|
112
|
-
brake: !0
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
nodeName: "Wheel_FR",
|
|
116
|
-
islandIds: [],
|
|
117
|
-
fallbackPos: [
|
|
118
|
-
-d,
|
|
119
|
-
l,
|
|
120
|
-
f
|
|
121
|
-
],
|
|
122
|
-
radius: l,
|
|
123
|
-
width: u,
|
|
124
|
-
steered: !0,
|
|
125
|
-
driven: p,
|
|
126
|
-
brake: !0
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
nodeName: "Wheel_RL",
|
|
130
|
-
islandIds: [],
|
|
131
|
-
fallbackPos: [
|
|
132
|
-
d,
|
|
133
|
-
l,
|
|
134
|
-
-f
|
|
135
|
-
],
|
|
136
|
-
radius: l,
|
|
137
|
-
width: u,
|
|
138
|
-
steered: !1,
|
|
139
|
-
driven: m,
|
|
140
|
-
brake: !0
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
nodeName: "Wheel_RR",
|
|
144
|
-
islandIds: [],
|
|
145
|
-
fallbackPos: [
|
|
146
|
-
-d,
|
|
147
|
-
l,
|
|
148
|
-
-f
|
|
149
|
-
],
|
|
150
|
-
radius: l,
|
|
151
|
-
width: u,
|
|
152
|
-
steered: !1,
|
|
153
|
-
driven: m,
|
|
154
|
-
brake: !0
|
|
155
|
-
}
|
|
28
|
+
async function compileKhrAssetGlb(normalizedScene, opts) {
|
|
29
|
+
const box = computeLocalBounds(normalizedScene);
|
|
30
|
+
const sizeVec = box.getSize(new THREE.Vector3());
|
|
31
|
+
const center = box.getCenter(new THREE.Vector3());
|
|
32
|
+
const size = [
|
|
33
|
+
Math.max(.25, sizeVec.x),
|
|
34
|
+
Math.max(.25, sizeVec.y),
|
|
35
|
+
Math.max(.25, sizeVec.z)
|
|
156
36
|
];
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
let
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
O.name = "Chassis", O.add(_.chassisGroup), T.add(O);
|
|
174
|
-
for (let e of c) {
|
|
175
|
-
let n = _.wheels.find((t) => t.nodeName === e.nodeName), r = n?.center ?? e.fallbackPos ?? [
|
|
176
|
-
0,
|
|
177
|
-
e.radius,
|
|
178
|
-
0
|
|
179
|
-
];
|
|
180
|
-
if (o.wheelSource === "fleet12" || !n) {
|
|
181
|
-
let n = t(e.radius, e.width, e.nodeName);
|
|
182
|
-
n.position.set(r[0], r[1], r[2]), T.add(n);
|
|
183
|
-
} else T.add(n.group);
|
|
184
|
-
}
|
|
185
|
-
let k = Math.max(...c.map((e) => e.radius)), A = Math.max(.08, Math.min(.3, k * .68)), j = A * .4, M = Math.min(s.max.y - .2, Math.max(k * 1.15, A - j + .16)), N = Math.max(M + .26, s.max.y * .92), P = [
|
|
186
|
-
v(Math.max(.45, u * .92)),
|
|
187
|
-
v(Math.max(.26, N - M)),
|
|
188
|
-
v(Math.max(.55, C * .92))
|
|
189
|
-
], F = new d.Object3D();
|
|
190
|
-
F.name = "Chassis_Hull", F.position.set(v(l.x), v((M + N) * .5), v(l.z)), O.add(F);
|
|
191
|
-
let I = Math.min(N, Math.max(k + .14, S * .36)), L = c.map((e) => _.wheels.find((t) => t.nodeName === e.nodeName)?.center[2] ?? e.fallbackPos?.[2] ?? 0), R = L.reduce((e, t) => e + t, 0) / Math.max(1, L.length), z = Math.max(80, w - f.reduce((e, t) => e + t.massKg, 0)), B = h.streetDrift90s, V = g(B.muPeakLng, .82);
|
|
192
|
-
E = [{
|
|
193
|
-
nodeName: "Chassis",
|
|
194
|
-
motion: {
|
|
195
|
-
isKinematic: !1,
|
|
196
|
-
mass: z,
|
|
197
|
-
centerOfMass: [
|
|
198
|
-
0,
|
|
199
|
-
v(I),
|
|
200
|
-
v(R)
|
|
201
|
-
],
|
|
202
|
-
inertiaDiagonal: y(z, u, Math.max(.45, S - k * .5), C)
|
|
203
|
-
},
|
|
204
|
-
extras: { role: "chassis" }
|
|
205
|
-
}, {
|
|
206
|
-
nodeName: "Chassis_Hull",
|
|
207
|
-
collider: {
|
|
208
|
-
shape: {
|
|
209
|
-
type: "box",
|
|
210
|
-
size: P
|
|
211
|
-
},
|
|
212
|
-
friction: .38,
|
|
213
|
-
restitution: .05
|
|
214
|
-
}
|
|
215
|
-
}];
|
|
216
|
-
for (let e of f) {
|
|
217
|
-
let t = _.panels.find((t) => t.nodeName === e.nodeName);
|
|
218
|
-
if (!t) continue;
|
|
219
|
-
O.add(t.group);
|
|
220
|
-
let n = [
|
|
221
|
-
v(t.center[0] - t.anchor[0]),
|
|
222
|
-
v(t.center[1] - t.anchor[1]),
|
|
223
|
-
v(t.center[2] - t.anchor[2])
|
|
224
|
-
], r = new d.Object3D();
|
|
225
|
-
r.name = `${e.nodeName}_Panel`, r.position.set(n[0], n[1], n[2]), t.group.add(r), E.push({
|
|
226
|
-
nodeName: r.name,
|
|
227
|
-
collider: {
|
|
228
|
-
shape: {
|
|
229
|
-
type: "box",
|
|
230
|
-
size: [
|
|
231
|
-
v(t.size[0]),
|
|
232
|
-
v(t.size[1]),
|
|
233
|
-
v(t.size[2])
|
|
234
|
-
]
|
|
235
|
-
},
|
|
236
|
-
friction: .45
|
|
237
|
-
}
|
|
238
|
-
}), E.push({
|
|
239
|
-
nodeName: e.nodeName,
|
|
240
|
-
motion: {
|
|
241
|
-
isKinematic: !1,
|
|
242
|
-
mass: e.massKg,
|
|
243
|
-
centerOfMass: n,
|
|
244
|
-
inertiaDiagonal: y(e.massKg, t.size[0], t.size[1], t.size[2])
|
|
245
|
-
},
|
|
246
|
-
joint: {
|
|
247
|
-
connectedNodeName: "Chassis",
|
|
248
|
-
kind: "revolute",
|
|
249
|
-
axis: e.hinge.axis,
|
|
250
|
-
limits: e.hinge.limits,
|
|
251
|
-
drive: {
|
|
252
|
-
mode: "acceleration",
|
|
253
|
-
stiffness: 60,
|
|
254
|
-
damping: 12,
|
|
255
|
-
positionTarget: 0
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
extras: { role: e.role }
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
for (let e of c) {
|
|
262
|
-
let t = v(Math.max(.08, Math.min(.3, e.radius * .68))), n = v(t * .4);
|
|
263
|
-
E.push({
|
|
264
|
-
nodeName: e.nodeName,
|
|
265
|
-
extras: { ecctrlWheel: {
|
|
266
|
-
radius: v(e.radius),
|
|
267
|
-
width: v(e.width),
|
|
268
|
-
travel: t,
|
|
269
|
-
sag: n,
|
|
270
|
-
steer: e.steered,
|
|
271
|
-
drive: e.driven,
|
|
272
|
-
brake: e.brake,
|
|
273
|
-
tireGripFactor: V,
|
|
274
|
-
latFrictionEllipseScale: B.latFrictionEllipseScale,
|
|
275
|
-
relaxLngRate: B.relaxLngRate,
|
|
276
|
-
relaxLatRate: B.relaxLatRate,
|
|
277
|
-
lngSlipRatioCurveData: B.lng,
|
|
278
|
-
latSlipRatioCurveData: B.lat
|
|
279
|
-
} }
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
D = { tune: {
|
|
283
|
-
engineHorsepower: Math.max(25, o.powerOrThrust || 280),
|
|
284
|
-
engineMaxRPM: 7e3,
|
|
285
|
-
gearRatios: [
|
|
286
|
-
3.1,
|
|
287
|
-
2.05,
|
|
288
|
-
1.42,
|
|
289
|
-
1,
|
|
290
|
-
.82
|
|
291
|
-
],
|
|
292
|
-
finalDriveRatio: 3.58,
|
|
293
|
-
transmissionMode: "auto",
|
|
294
|
-
maxSteerAngle: .55,
|
|
295
|
-
engineTorqueCurveData: p.naScreamer,
|
|
296
|
-
steerAngleCurveData: m.driftCountersteer
|
|
297
|
-
} };
|
|
298
|
-
} else if (o.archetype === "starcraft") {
|
|
299
|
-
for (let e of n.clone(!0).children) T.add(e);
|
|
300
|
-
let e = new d.Object3D();
|
|
301
|
-
e.name = "HullBody", e.position.set(l.x, l.y, l.z), T.add(e);
|
|
302
|
-
let t = Math.max(400, o.powerOrThrust || 4500, Math.ceil(w * 9.81 * .72));
|
|
303
|
-
E = [{
|
|
304
|
-
nodeName: "HullBody",
|
|
305
|
-
motion: {
|
|
306
|
-
isKinematic: !1,
|
|
307
|
-
mass: w,
|
|
308
|
-
centerOfMass: [
|
|
309
|
-
0,
|
|
310
|
-
v(-S * .06),
|
|
311
|
-
0
|
|
312
|
-
],
|
|
313
|
-
inertiaDiagonal: y(w, u, S, C)
|
|
314
|
-
},
|
|
315
|
-
collider: {
|
|
316
|
-
shape: {
|
|
317
|
-
type: "box",
|
|
318
|
-
size: [
|
|
319
|
-
v(u * .86),
|
|
320
|
-
v(S * .78),
|
|
321
|
-
v(C * .9)
|
|
322
|
-
]
|
|
323
|
-
},
|
|
324
|
-
friction: .35,
|
|
325
|
-
restitution: .08
|
|
326
|
-
}
|
|
327
|
-
}];
|
|
328
|
-
for (let [e, n, r, i] of [
|
|
329
|
-
[
|
|
330
|
-
"Thruster_FL",
|
|
331
|
-
u * .36,
|
|
332
|
-
C * .32,
|
|
333
|
-
!1
|
|
334
|
-
],
|
|
335
|
-
[
|
|
336
|
-
"Thruster_FR",
|
|
337
|
-
-u * .36,
|
|
338
|
-
C * .32,
|
|
339
|
-
!0
|
|
340
|
-
],
|
|
341
|
-
[
|
|
342
|
-
"Thruster_RL",
|
|
343
|
-
u * .36,
|
|
344
|
-
-C * .32,
|
|
345
|
-
!0
|
|
346
|
-
],
|
|
347
|
-
[
|
|
348
|
-
"Thruster_RR",
|
|
349
|
-
-u * .36,
|
|
350
|
-
-C * .32,
|
|
351
|
-
!1
|
|
352
|
-
]
|
|
353
|
-
]) {
|
|
354
|
-
let a = new d.Object3D();
|
|
355
|
-
a.name = e, a.position.set(l.x + n, l.y, l.z + r), T.add(a), E.push({
|
|
356
|
-
nodeName: e,
|
|
357
|
-
extras: { ecctrlPropeller: {
|
|
358
|
-
maxThrust: t,
|
|
359
|
-
torqueRatio: .6,
|
|
360
|
-
invertTorque: i
|
|
361
|
-
} }
|
|
362
|
-
});
|
|
363
|
-
}
|
|
364
|
-
D = { droneTune: {
|
|
365
|
-
controlMode: "VELOCITY",
|
|
366
|
-
maxYawRate: 2.4,
|
|
367
|
-
maxHorizSpeed: 44,
|
|
368
|
-
maxVertSpeed: 22,
|
|
369
|
-
maxTiltAngle: .52,
|
|
370
|
-
airDragFactor: .18
|
|
371
|
-
} };
|
|
372
|
-
} else {
|
|
373
|
-
let e = new d.Group();
|
|
374
|
-
e.name = "PropBody";
|
|
375
|
-
let t = !1;
|
|
376
|
-
for (let r of n.clone(!0).children) e.add(r), r.traverse((e) => {
|
|
377
|
-
e instanceof d.Mesh && (e.geometry?.getAttribute("position")?.count ?? 0) >= 3 && (t = !0);
|
|
378
|
-
});
|
|
379
|
-
T.add(e), E = [{
|
|
380
|
-
nodeName: "PropBody",
|
|
381
|
-
motion: o.staticProp ? { isKinematic: !0 } : {
|
|
382
|
-
isKinematic: !1,
|
|
383
|
-
mass: w,
|
|
384
|
-
centerOfMass: [
|
|
385
|
-
v(l.x),
|
|
386
|
-
v(l.y),
|
|
387
|
-
v(l.z)
|
|
388
|
-
],
|
|
389
|
-
inertiaDiagonal: y(w, u, S, C)
|
|
390
|
-
},
|
|
391
|
-
collider: t ? {
|
|
392
|
-
meshNodeName: "PropBody",
|
|
393
|
-
convexHull: !0,
|
|
394
|
-
friction: .6,
|
|
395
|
-
restitution: .1
|
|
396
|
-
} : {
|
|
397
|
-
shape: {
|
|
398
|
-
type: "box",
|
|
399
|
-
size: [
|
|
400
|
-
v(u),
|
|
401
|
-
v(S),
|
|
402
|
-
v(C)
|
|
403
|
-
]
|
|
404
|
-
},
|
|
405
|
-
friction: .6,
|
|
406
|
-
restitution: .1
|
|
407
|
-
}
|
|
408
|
-
}];
|
|
409
|
-
}
|
|
410
|
-
let O = [];
|
|
411
|
-
T.traverse((e) => {
|
|
412
|
-
if (!(e instanceof d.Mesh) || !e.material) return;
|
|
413
|
-
let t = e.material;
|
|
414
|
-
for (let e of _) {
|
|
415
|
-
let n = t[e];
|
|
416
|
-
n && !n.image && (O.push({
|
|
417
|
-
rec: t,
|
|
418
|
-
slot: e,
|
|
419
|
-
tex: n
|
|
420
|
-
}), t[e] = null);
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
let k;
|
|
37
|
+
const totalMass = Math.max(5, opts.massKg || 1e3);
|
|
38
|
+
const exportRoot = new THREE.Group();
|
|
39
|
+
exportRoot.name = opts.name || normalizedScene.name || `Kolmo_${opts.archetype}`;
|
|
40
|
+
let specs;
|
|
41
|
+
let sceneExtras;
|
|
42
|
+
if (opts.archetype === "car") {
|
|
43
|
+
const plan = buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center, totalMass);
|
|
44
|
+
specs = plan.specs;
|
|
45
|
+
sceneExtras = plan.sceneExtras;
|
|
46
|
+
} else if (opts.archetype === "craft") {
|
|
47
|
+
const plan = buildCraftExportPlan(normalizedScene, exportRoot, opts, size, center, totalMass);
|
|
48
|
+
specs = plan.specs;
|
|
49
|
+
sceneExtras = plan.sceneExtras;
|
|
50
|
+
} else specs = buildPropExportPlan(normalizedScene, exportRoot, opts, size, center, totalMass);
|
|
51
|
+
const stripped = stripUnloadedTextures(exportRoot);
|
|
52
|
+
let exported;
|
|
424
53
|
try {
|
|
425
|
-
|
|
54
|
+
exported = new Uint8Array(await exportKhrGlb(exportRoot, specs, sceneExtras));
|
|
426
55
|
} finally {
|
|
427
|
-
|
|
56
|
+
restoreStrippedTextures(stripped);
|
|
428
57
|
}
|
|
429
|
-
|
|
430
|
-
|
|
58
|
+
const allPatches = [...collectPreservedRigPatches(normalizedScene, opts.patches ?? []), ...opts.patches ?? []];
|
|
59
|
+
const stamped = stampKolmoNodesIntoGlb(exported, allPatches);
|
|
60
|
+
return new Uint8Array(stamped);
|
|
431
61
|
}
|
|
432
|
-
export {
|
|
62
|
+
export { buildPatchPreviewEmitters, compileKhrAssetGlb, computeChopPartHinge, normalToMinusZQuaternion };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=khrCompiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"khrCompiler.js","names":[],"sources":["../../src/importer/khrCompiler.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { exportKhrGlb, type KhrExportNodeSpec } from \"@khr3/core\";\nimport { stampKolmoNodesIntoGlb } from \"../schema/kolmoSchema.js\";\nimport {\n buildPatchPreviewEmitters,\n computeChopPartHinge,\n normalToMinusZQuaternion,\n type ChopHingeSpec,\n} from \"./chopHingeHelpers.js\";\nimport { buildCarExportPlan } from \"./khrCarPlanner.js\";\nimport {\n buildCraftExportPlan,\n buildPropExportPlan,\n collectPreservedRigPatches,\n restoreStrippedTextures,\n stripUnloadedTextures,\n type CarDriveMode,\n type KolmoAssetArchetype,\n type KolmoCompileOptions,\n type WheelVisualSource,\n} from \"./khrCraftPropCompiler.js\";\nimport { isMeshObject } from \"./sceneSiNormalize.js\";\n\ntype KhrSceneExtras = Parameters<typeof exportKhrGlb>[2];\n\nexport {\n buildPatchPreviewEmitters,\n computeChopPartHinge,\n normalToMinusZQuaternion,\n type CarDriveMode,\n type ChopHingeSpec,\n type KolmoAssetArchetype,\n type KolmoCompileOptions,\n type WheelVisualSource,\n};\n\nfunction computeLocalBounds(root: THREE.Object3D): THREE.Box3 {\n root.updateMatrixWorld(true);\n const invRoot = new THREE.Matrix4().copy(root.matrixWorld).invert();\n const relMat = new THREE.Matrix4();\n const box = new THREE.Box3();\n const v = new THREE.Vector3();\n root.traverse((obj) => {\n if (!isMeshObject(obj)) return;\n const pos = obj.geometry.getAttribute(\"position\");\n if (!pos || pos.count === 0) return;\n relMat.multiplyMatrices(invRoot, obj.matrixWorld);\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)) box.expandByPoint(v);\n }\n });\n if (box.isEmpty()) box.set(new THREE.Vector3(-0.5, 0, -0.5), new THREE.Vector3(0.5, 1, 0.5));\n return box;\n}\n\nexport async function compileKhrAssetGlb(\n normalizedScene: THREE.Group,\n opts: KolmoCompileOptions,\n): Promise<Uint8Array<ArrayBuffer>> {\n const box = computeLocalBounds(normalizedScene);\n const sizeVec = box.getSize(new THREE.Vector3());\n const center = box.getCenter(new THREE.Vector3());\n const size: [number, number, number] = [\n Math.max(0.25, sizeVec.x),\n Math.max(0.25, sizeVec.y),\n Math.max(0.25, sizeVec.z),\n ];\n const totalMass = Math.max(5, opts.massKg || 1000);\n\n const exportRoot = new THREE.Group();\n exportRoot.name = opts.name || normalizedScene.name || `Kolmo_${opts.archetype}`;\n let specs: KhrExportNodeSpec[];\n let sceneExtras: KhrSceneExtras | undefined;\n\n if (opts.archetype === \"car\") {\n const plan = buildCarExportPlan(normalizedScene, exportRoot, opts, box, size, center, totalMass);\n specs = plan.specs;\n sceneExtras = plan.sceneExtras;\n } else if (opts.archetype === \"craft\") {\n const plan = buildCraftExportPlan(normalizedScene, exportRoot, opts, size, center, totalMass);\n specs = plan.specs;\n sceneExtras = plan.sceneExtras;\n } else {\n specs = buildPropExportPlan(normalizedScene, exportRoot, opts, size, center, totalMass);\n }\n\n const stripped = stripUnloadedTextures(exportRoot);\n let exported: Uint8Array;\n try {\n exported = new Uint8Array(await exportKhrGlb(exportRoot, specs, sceneExtras));\n } finally {\n restoreStrippedTextures(stripped);\n }\n\n const preserved = collectPreservedRigPatches(normalizedScene, opts.patches ?? []);\n const allPatches = [...preserved, ...(opts.patches ?? [])];\n const stamped = stampKolmoNodesIntoGlb(exported, allPatches);\n return new Uint8Array(stamped);\n}\n"],"mappings":";;;;;;;;AAoCA,SAAS,mBAAmB,MAAkC;CAC1D,KAAK,kBAAkB,IAAI;CAC3B,MAAM,UAAU,IAAI,MAAM,QAAQ,CAAC,CAAC,KAAK,KAAK,WAAW,CAAC,CAAC,OAAO;CAClE,MAAM,SAAS,IAAI,MAAM,QAAQ;CACjC,MAAM,MAAM,IAAI,MAAM,KAAK;CAC3B,MAAM,IAAI,IAAI,MAAM,QAAQ;CAC5B,KAAK,UAAU,QAAQ;EACnB,IAAI,CAAC,aAAa,GAAG,GAAG;EACxB,MAAM,MAAM,IAAI,SAAS,aAAa,UAAU;EAChD,IAAI,CAAC,OAAO,IAAI,UAAU,GAAG;EAC7B,OAAO,iBAAiB,SAAS,IAAI,WAAW;EAChD,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,OAAO,KAAK;GAChC,EAAE,oBAAoB,KAAK,CAAC,CAAC,CAAC,aAAa,MAAM;GACjD,IAAI,OAAO,SAAS,EAAE,CAAC,KAAK,OAAO,SAAS,EAAE,CAAC,KAAK,OAAO,SAAS,EAAE,CAAC,GAAG,IAAI,cAAc,CAAC;EACjG;CACJ,CAAC;CACD,IAAI,IAAI,QAAQ,GAAG,IAAI,IAAI,IAAI,MAAM,QAAQ,KAAM,GAAG,GAAI,GAAG,IAAI,MAAM,QAAQ,IAAK,GAAG,EAAG,CAAC;CAC3F,OAAO;AACX;AAEA,eAAsB,mBAClB,iBACA,MACgC;CAChC,MAAM,MAAM,mBAAmB,eAAe;CAC9C,MAAM,UAAU,IAAI,QAAQ,IAAI,MAAM,QAAQ,CAAC;CAC/C,MAAM,SAAS,IAAI,UAAU,IAAI,MAAM,QAAQ,CAAC;CAChD,MAAM,OAAiC;EACnC,KAAK,IAAI,KAAM,QAAQ,CAAC;EACxB,KAAK,IAAI,KAAM,QAAQ,CAAC;EACxB,KAAK,IAAI,KAAM,QAAQ,CAAC;CAC5B;CACA,MAAM,YAAY,KAAK,IAAI,GAAG,KAAK,UAAU,GAAI;CAEjD,MAAM,aAAa,IAAI,MAAM,MAAM;CACnC,WAAW,OAAO,KAAK,QAAQ,gBAAgB,QAAQ,SAAS,KAAK;CACrE,IAAI;CACJ,IAAI;CAEJ,IAAI,KAAK,cAAc,OAAO;EAC1B,MAAM,OAAO,mBAAmB,iBAAiB,YAAY,MAAM,KAAK,MAAM,QAAQ,SAAS;EAC/F,QAAQ,KAAK;EACb,cAAc,KAAK;CACvB,OAAO,IAAI,KAAK,cAAc,SAAS;EACnC,MAAM,OAAO,qBAAqB,iBAAiB,YAAY,MAAM,MAAM,QAAQ,SAAS;EAC5F,QAAQ,KAAK;EACb,cAAc,KAAK;CACvB,OACI,QAAQ,oBAAoB,iBAAiB,YAAY,MAAM,MAAM,QAAQ,SAAS;CAG1F,MAAM,WAAW,sBAAsB,UAAU;CACjD,IAAI;CACJ,IAAI;EACA,WAAW,IAAI,WAAW,MAAM,aAAa,YAAY,OAAO,WAAW,CAAC;CAChF,UAAU;EACN,wBAAwB,QAAQ;CACpC;CAGA,MAAM,aAAa,CAAC,GADF,2BAA2B,iBAAiB,KAAK,WAAW,CAAC,CACxD,GAAW,GAAI,KAAK,WAAW,CAAC,CAAE;CACzD,MAAM,UAAU,uBAAuB,UAAU,UAAU;CAC3D,OAAO,IAAI,WAAW,OAAO;AACjC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import type { KhrExportNodeSpec } from "@khr3/core";
|
|
3
|
+
import type { KolmoAuthoredNodePatch } from "../schema/kolmoSchema.js";
|
|
4
|
+
import type { WheelCutterSpec } from "./fusedWheelDetect.js";
|
|
5
|
+
import type { MeshIsland, WheelAxle } from "./meshIslands.js";
|
|
6
|
+
import type { ChopPartRole } from "./surfaceCutter.js";
|
|
7
|
+
export type KolmoAssetArchetype = "car" | "craft" | "prop";
|
|
8
|
+
export type CarDriveMode = "RWD" | "FWD" | "AWD";
|
|
9
|
+
export type WheelVisualSource = "imported" | "fleet12";
|
|
10
|
+
export interface KolmoCompileOptions {
|
|
11
|
+
archetype: KolmoAssetArchetype;
|
|
12
|
+
massKg: number;
|
|
13
|
+
powerOrThrust: number;
|
|
14
|
+
driveType?: CarDriveMode;
|
|
15
|
+
wheelSource?: WheelVisualSource;
|
|
16
|
+
staticProp?: boolean;
|
|
17
|
+
axles?: readonly WheelAxle[];
|
|
18
|
+
islands?: readonly MeshIsland[];
|
|
19
|
+
partPicks?: Readonly<Record<number, ChopPartRole>>;
|
|
20
|
+
wheelCutters?: readonly WheelCutterSpec[];
|
|
21
|
+
sealArchLiner?: boolean;
|
|
22
|
+
mirrorX?: boolean;
|
|
23
|
+
patches?: readonly KolmoAuthoredNodePatch[];
|
|
24
|
+
name?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const r4: (n: number) => number;
|
|
27
|
+
export declare const boxInertia: (m: number, x: number, y: number, z: number) => [number, number, number];
|
|
28
|
+
export interface StrippedTextureSlot {
|
|
29
|
+
rec: Record<string, THREE.Texture | null | undefined>;
|
|
30
|
+
slot: string;
|
|
31
|
+
tex: THREE.Texture;
|
|
32
|
+
}
|
|
33
|
+
export declare function stripUnloadedTextures(root: THREE.Object3D): StrippedTextureSlot[];
|
|
34
|
+
export declare function restoreStrippedTextures(stripped: readonly StrippedTextureSlot[]): void;
|
|
35
|
+
export declare function collectPreservedRigPatches(scene: THREE.Object3D, explicitPatches?: readonly KolmoAuthoredNodePatch[]): KolmoAuthoredNodePatch[];
|
|
36
|
+
export declare function buildCraftExportPlan(normalizedScene: THREE.Group, exportRoot: THREE.Group, opts: KolmoCompileOptions, size: readonly [number, number, number], center: THREE.Vector3, totalMass: number): {
|
|
37
|
+
specs: KhrExportNodeSpec[];
|
|
38
|
+
sceneExtras: Record<string, unknown>;
|
|
39
|
+
};
|
|
40
|
+
export declare function buildPropExportPlan(normalizedScene: THREE.Group, exportRoot: THREE.Group, opts: KolmoCompileOptions, size: readonly [number, number, number], center: THREE.Vector3, totalMass: number): KhrExportNodeSpec[];
|