@pinkaphant/kolmo 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -100
- package/dist/engine/actor.d.ts +13 -0
- package/dist/engine/gltfLoader.d.ts +19 -0
- package/dist/engine/index.d.ts +8 -13
- package/dist/engine/index.js +1270 -22
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/{kolmoInput.d.ts → input.d.ts} +7 -6
- package/dist/engine/surface.d.ts +19 -0
- package/dist/engine/{kolmoTraits.d.ts → traits.d.ts} +18 -47
- package/dist/engine/vehicle.d.ts +20 -0
- package/dist/engine/world.d.ts +76 -0
- package/dist/index.d.ts +12 -18
- package/dist/index.js +14 -104
- package/dist/physics/index.d.ts +4 -1
- package/dist/physics/index.js +1 -105
- package/dist/physics/nBodyGravity.d.ts +42 -0
- package/dist/physics-FhWvTBfH.js +424 -0
- package/dist/physics-FhWvTBfH.js.map +1 -0
- package/dist/vite/index.d.ts +2 -12
- package/dist/vite/index.js +8 -77
- package/dist/vite/index.js.map +1 -1
- package/package.json +33 -87
- package/AGENTS.md +0 -29
- package/CLAUDE.md +0 -8
- package/bin/kolmo.mjs +0 -560
- package/dist/engine/causewayBridge.d.ts +0 -14
- package/dist/engine/causewayBridge.js +0 -166
- package/dist/engine/causewayBridge.js.map +0 -1
- package/dist/engine/islandSettlementMesh.d.ts +0 -26
- package/dist/engine/islandSettlementMesh.js +0 -166
- package/dist/engine/islandSettlementMesh.js.map +0 -1
- package/dist/engine/kolmoActions.d.ts +0 -23
- package/dist/engine/kolmoActions.js +0 -179
- package/dist/engine/kolmoActions.js.map +0 -1
- package/dist/engine/kolmoActor.d.ts +0 -13
- package/dist/engine/kolmoActor.js +0 -263
- package/dist/engine/kolmoActor.js.map +0 -1
- package/dist/engine/kolmoActorHelpers.d.ts +0 -24
- package/dist/engine/kolmoActorHelpers.js +0 -64
- package/dist/engine/kolmoActorHelpers.js.map +0 -1
- package/dist/engine/kolmoFloatingOrigin.d.ts +0 -17
- package/dist/engine/kolmoFloatingOrigin.js +0 -98
- package/dist/engine/kolmoFloatingOrigin.js.map +0 -1
- package/dist/engine/kolmoGame.d.ts +0 -27
- package/dist/engine/kolmoGame.js +0 -83
- package/dist/engine/kolmoGame.js.map +0 -1
- package/dist/engine/kolmoHud.d.ts +0 -23
- package/dist/engine/kolmoHud.js +0 -214
- package/dist/engine/kolmoHud.js.map +0 -1
- package/dist/engine/kolmoInput.js +0 -163
- package/dist/engine/kolmoInput.js.map +0 -1
- package/dist/engine/kolmoIsland.d.ts +0 -14
- package/dist/engine/kolmoIsland.js +0 -243
- package/dist/engine/kolmoIsland.js.map +0 -1
- package/dist/engine/kolmoLongDrive.d.ts +0 -12
- package/dist/engine/kolmoLongDrive.js +0 -160
- package/dist/engine/kolmoLongDrive.js.map +0 -1
- package/dist/engine/kolmoPilotMesh.d.ts +0 -2
- package/dist/engine/kolmoPilotMesh.js +0 -205
- package/dist/engine/kolmoPilotMesh.js.map +0 -1
- package/dist/engine/kolmoProcedural.d.ts +0 -13
- package/dist/engine/kolmoProcedural.js +0 -101
- package/dist/engine/kolmoProcedural.js.map +0 -1
- package/dist/engine/kolmoRigs.d.ts +0 -13
- package/dist/engine/kolmoRigs.js +0 -100
- package/dist/engine/kolmoRigs.js.map +0 -1
- package/dist/engine/kolmoStore.d.ts +0 -3
- package/dist/engine/kolmoStore.js +0 -4
- package/dist/engine/kolmoStore.js.map +0 -1
- package/dist/engine/kolmoSurface.d.ts +0 -18
- package/dist/engine/kolmoSurface.js +0 -198
- package/dist/engine/kolmoSurface.js.map +0 -1
- package/dist/engine/kolmoTouchOverlay.d.ts +0 -21
- package/dist/engine/kolmoTouchOverlay.js +0 -326
- package/dist/engine/kolmoTouchOverlay.js.map +0 -1
- package/dist/engine/kolmoTouchState.d.ts +0 -50
- package/dist/engine/kolmoTouchState.js +0 -210
- package/dist/engine/kolmoTouchState.js.map +0 -1
- package/dist/engine/kolmoTraits.js +0 -140
- package/dist/engine/kolmoTraits.js.map +0 -1
- package/dist/engine/kolmoVehicle.d.ts +0 -4
- package/dist/engine/kolmoVehicle.js +0 -80
- package/dist/engine/kolmoVehicle.js.map +0 -1
- package/dist/engine/kolmoVehicleAutoCompile.d.ts +0 -10
- package/dist/engine/kolmoVehicleAutoCompile.js +0 -78
- package/dist/engine/kolmoVehicleAutoCompile.js.map +0 -1
- package/dist/engine/kolmoVehicleConfig.d.ts +0 -56
- package/dist/engine/kolmoVehicleConfig.js +0 -84
- package/dist/engine/kolmoVehicleConfig.js.map +0 -1
- package/dist/engine/kolmoVehicleDriver.d.ts +0 -38
- package/dist/engine/kolmoVehicleDriver.js +0 -139
- package/dist/engine/kolmoVehicleDriver.js.map +0 -1
- package/dist/engine/kolmoVehicleInner.d.ts +0 -7
- package/dist/engine/kolmoVehicleInner.js +0 -291
- package/dist/engine/kolmoVehicleInner.js.map +0 -1
- package/dist/engine/kolmoWorld.d.ts +0 -45
- package/dist/engine/kolmoWorld.js +0 -161
- package/dist/engine/kolmoWorld.js.map +0 -1
- package/dist/engine/longDriveKit.d.ts +0 -19
- package/dist/engine/longDriveKit.js +0 -145
- package/dist/engine/longDriveKit.js.map +0 -1
- package/dist/engine/longDriveRoadside.d.ts +0 -16
- package/dist/engine/longDriveRoadside.js +0 -171
- package/dist/engine/longDriveRoadside.js.map +0 -1
- package/dist/engine/macroCellBuilder.d.ts +0 -44
- package/dist/engine/macroCellBuilder.js +0 -228
- package/dist/engine/macroCellBuilder.js.map +0 -1
- package/dist/engine/mainlandMacroCell.d.ts +0 -15
- package/dist/engine/mainlandMacroCell.js +0 -168
- package/dist/engine/mainlandMacroCell.js.map +0 -1
- package/dist/engine/shiftedFixedBody.d.ts +0 -13
- package/dist/engine/shiftedFixedBody.js +0 -75
- package/dist/engine/shiftedFixedBody.js.map +0 -1
- package/dist/importer/ChopShopPanel.d.ts +0 -52
- package/dist/importer/ChopShopPanel.js +0 -409
- package/dist/importer/ChopShopPanel.js.map +0 -1
- package/dist/importer/DomainWorkshopPanel.d.ts +0 -23
- package/dist/importer/DomainWorkshopPanel.js +0 -418
- package/dist/importer/DomainWorkshopPanel.js.map +0 -1
- package/dist/importer/GateHudBar.d.ts +0 -39
- package/dist/importer/GateHudBar.js +0 -401
- package/dist/importer/GateHudBar.js.map +0 -1
- package/dist/importer/GlbImportGate.d.ts +0 -8
- package/dist/importer/GlbImportGate.js +0 -291
- package/dist/importer/GlbImportGate.js.map +0 -1
- package/dist/importer/ImperativeVehicleRig.d.ts +0 -9
- package/dist/importer/ImperativeVehicleRig.js +0 -273
- package/dist/importer/ImperativeVehicleRig.js.map +0 -1
- package/dist/importer/LiveDrivePads.d.ts +0 -20
- package/dist/importer/LiveDrivePads.js +0 -171
- package/dist/importer/LiveDrivePads.js.map +0 -1
- package/dist/importer/PaperShellDebrisRig.d.ts +0 -25
- package/dist/importer/PaperShellDebrisRig.js +0 -143
- package/dist/importer/PaperShellDebrisRig.js.map +0 -1
- package/dist/importer/R2VaultDrawer.d.ts +0 -12
- package/dist/importer/R2VaultDrawer.js +0 -90
- package/dist/importer/R2VaultDrawer.js.map +0 -1
- package/dist/importer/Step1CalibrationPlinth.d.ts +0 -56
- package/dist/importer/Step1CalibrationPlinth.js +0 -204
- package/dist/importer/Step1CalibrationPlinth.js.map +0 -1
- package/dist/importer/Step1ExplodedIslands.d.ts +0 -31
- package/dist/importer/Step1ExplodedIslands.js +0 -144
- package/dist/importer/Step1ExplodedIslands.js.map +0 -1
- package/dist/importer/Step2UniversalPad.d.ts +0 -18
- package/dist/importer/Step2UniversalPad.js +0 -123
- package/dist/importer/Step2UniversalPad.js.map +0 -1
- package/dist/importer/VfxEmitterPool.d.ts +0 -8
- package/dist/importer/VfxEmitterPool.js +0 -64
- package/dist/importer/VfxEmitterPool.js.map +0 -1
- package/dist/importer/WheelRingHandles3D.d.ts +0 -11
- package/dist/importer/WheelRingHandles3D.js +0 -319
- package/dist/importer/WheelRingHandles3D.js.map +0 -1
- package/dist/importer/archLinerGeom.d.ts +0 -2
- package/dist/importer/archLinerGeom.js +0 -51
- package/dist/importer/archLinerGeom.js.map +0 -1
- package/dist/importer/chopHingeHelpers.d.ts +0 -15
- package/dist/importer/chopHingeHelpers.js +0 -193
- package/dist/importer/chopHingeHelpers.js.map +0 -1
- package/dist/importer/chopShopActions.d.ts +0 -58
- package/dist/importer/chopShopActions.js +0 -165
- package/dist/importer/chopShopActions.js.map +0 -1
- package/dist/importer/chopShopHandlers.d.ts +0 -26
- package/dist/importer/chopShopHandlers.js +0 -283
- package/dist/importer/chopShopHandlers.js.map +0 -1
- package/dist/importer/chopShopIoActions.d.ts +0 -20
- package/dist/importer/chopShopIoActions.js +0 -192
- package/dist/importer/chopShopIoActions.js.map +0 -1
- package/dist/importer/chopShopMcpAction.d.ts +0 -18
- package/dist/importer/chopShopMcpAction.js +0 -58
- package/dist/importer/chopShopMcpAction.js.map +0 -1
- package/dist/importer/cylinderBooleanSlice.d.ts +0 -14
- package/dist/importer/cylinderBooleanSlice.js +0 -110
- package/dist/importer/cylinderBooleanSlice.js.map +0 -1
- package/dist/importer/cylinderSliceMath.d.ts +0 -14
- package/dist/importer/cylinderSliceMath.js +0 -251
- package/dist/importer/cylinderSliceMath.js.map +0 -1
- package/dist/importer/fusedWheelDetect.d.ts +0 -4
- package/dist/importer/fusedWheelDetect.js +0 -297
- package/dist/importer/fusedWheelDetect.js.map +0 -1
- package/dist/importer/fusedWheelFit.d.ts +0 -19
- package/dist/importer/fusedWheelFit.js +0 -219
- package/dist/importer/fusedWheelFit.js.map +0 -1
- package/dist/importer/gateStore.d.ts +0 -73
- package/dist/importer/gateStore.js +0 -102
- package/dist/importer/gateStore.js.map +0 -1
- package/dist/importer/glbNormalizer.d.ts +0 -22
- package/dist/importer/glbNormalizer.js +0 -177
- package/dist/importer/glbNormalizer.js.map +0 -1
- package/dist/importer/importerWebMcp.d.ts +0 -49
- package/dist/importer/importerWebMcp.js +0 -48
- package/dist/importer/importerWebMcp.js.map +0 -1
- package/dist/importer/importerWebMcpTools.d.ts +0 -2
- package/dist/importer/importerWebMcpTools.js +0 -341
- package/dist/importer/importerWebMcpTools.js.map +0 -1
- package/dist/importer/index.d.ts +0 -23
- package/dist/importer/index.js +0 -36
- package/dist/importer/index.js.map +0 -1
- package/dist/importer/khrCarGeometryMass.d.ts +0 -20
- package/dist/importer/khrCarGeometryMass.js +0 -125
- package/dist/importer/khrCarGeometryMass.js.map +0 -1
- package/dist/importer/khrCarPlanHelpers.d.ts +0 -39
- package/dist/importer/khrCarPlanHelpers.js +0 -300
- package/dist/importer/khrCarPlanHelpers.js.map +0 -1
- package/dist/importer/khrCarPlanner.d.ts +0 -8
- package/dist/importer/khrCarPlanner.js +0 -283
- package/dist/importer/khrCarPlanner.js.map +0 -1
- package/dist/importer/khrCompiler.d.ts +0 -5
- package/dist/importer/khrCompiler.js +0 -87
- package/dist/importer/khrCompiler.js.map +0 -1
- package/dist/importer/khrCraftPropCompiler.d.ts +0 -45
- package/dist/importer/khrCraftPropCompiler.js +0 -263
- package/dist/importer/khrCraftPropCompiler.js.map +0 -1
- package/dist/importer/khrNodeNameGuard.d.ts +0 -20
- package/dist/importer/khrNodeNameGuard.js +0 -139
- package/dist/importer/khrNodeNameGuard.js.map +0 -1
- package/dist/importer/launcherBake.d.ts +0 -15
- package/dist/importer/launcherBake.js +0 -117
- package/dist/importer/launcherBake.js.map +0 -1
- package/dist/importer/launcherCadGeometry.d.ts +0 -22
- package/dist/importer/launcherCadGeometry.js +0 -185
- package/dist/importer/launcherCadGeometry.js.map +0 -1
- package/dist/importer/meshIslands.d.ts +0 -17
- package/dist/importer/meshIslands.js +0 -102
- package/dist/importer/meshIslands.js.map +0 -1
- package/dist/importer/meshSliceBuffers.d.ts +0 -15
- package/dist/importer/meshSliceBuffers.js +0 -159
- package/dist/importer/meshSliceBuffers.js.map +0 -1
- package/dist/importer/polygonEarClipYZ.d.ts +0 -3
- package/dist/importer/polygonEarClipYZ.js +0 -67
- package/dist/importer/polygonEarClipYZ.js.map +0 -1
- package/dist/importer/proceduralC12AndCraft.d.ts +0 -18
- package/dist/importer/proceduralC12AndCraft.js +0 -302
- package/dist/importer/proceduralC12AndCraft.js.map +0 -1
- package/dist/importer/proceduralDomainBuilders.d.ts +0 -10
- package/dist/importer/proceduralDomainBuilders.js +0 -346
- package/dist/importer/proceduralDomainBuilders.js.map +0 -1
- package/dist/importer/proceduralPersonAndProp.d.ts +0 -8
- package/dist/importer/proceduralPersonAndProp.js +0 -303
- package/dist/importer/proceduralPersonAndProp.js.map +0 -1
- package/dist/importer/sceneSiNormalize.d.ts +0 -19
- package/dist/importer/sceneSiNormalize.js +0 -145
- package/dist/importer/sceneSiNormalize.js.map +0 -1
- package/dist/importer/starterScene.d.ts +0 -5
- package/dist/importer/starterScene.js +0 -139
- package/dist/importer/starterScene.js.map +0 -1
- package/dist/importer/surfaceCutter.d.ts +0 -16
- package/dist/importer/surfaceCutter.js +0 -83
- package/dist/importer/surfaceCutter.js.map +0 -1
- package/dist/importer/surfaceGeodesic.d.ts +0 -7
- package/dist/importer/surfaceGeodesic.js +0 -130
- package/dist/importer/surfaceGeodesic.js.map +0 -1
- package/dist/importer/surfaceLoopRefine.d.ts +0 -6
- package/dist/importer/surfaceLoopRefine.js +0 -171
- package/dist/importer/surfaceLoopRefine.js.map +0 -1
- package/dist/importer/surfacePeel.d.ts +0 -11
- package/dist/importer/surfacePeel.js +0 -119
- package/dist/importer/surfacePeel.js.map +0 -1
- package/dist/importer/surfaceTopology.d.ts +0 -36
- package/dist/importer/surfaceTopology.js +0 -143
- package/dist/importer/surfaceTopology.js.map +0 -1
- package/dist/importer/universalGateBake.d.ts +0 -45
- package/dist/importer/universalGateBake.js +0 -203
- package/dist/importer/universalGateBake.js.map +0 -1
- package/dist/importer/usdPhysicsSpecs.d.ts +0 -3
- package/dist/importer/usdPhysicsSpecs.js +0 -245
- package/dist/importer/usdPhysicsSpecs.js.map +0 -1
- package/dist/importer/usdTextParse.d.ts +0 -12
- package/dist/importer/usdTextParse.js +0 -118
- package/dist/importer/usdTextParse.js.map +0 -1
- package/dist/importer/usdToGlb.d.ts +0 -12
- package/dist/importer/usdToGlb.js +0 -94
- package/dist/importer/usdToGlb.js.map +0 -1
- package/dist/importer/useChopShopController.d.ts +0 -108
- package/dist/importer/useChopShopController.js +0 -201
- package/dist/importer/useChopShopController.js.map +0 -1
- package/dist/importer/useChopShopState.d.ts +0 -103
- package/dist/importer/useChopShopState.js +0 -350
- package/dist/importer/useChopShopState.js.map +0 -1
- package/dist/importer/useWasdKeyRef.d.ts +0 -9
- package/dist/importer/useWasdKeyRef.js +0 -35
- package/dist/importer/useWasdKeyRef.js.map +0 -1
- package/dist/importer/vehiclePartSplit.d.ts +0 -33
- package/dist/importer/vehiclePartSplit.js +0 -183
- package/dist/importer/vehiclePartSplit.js.map +0 -1
- package/dist/importer/wheelAxlePairing.d.ts +0 -21
- package/dist/importer/wheelAxlePairing.js +0 -157
- package/dist/importer/wheelAxlePairing.js.map +0 -1
- package/dist/importer/wheelCutterHelpers.d.ts +0 -45
- package/dist/importer/wheelCutterHelpers.js +0 -208
- package/dist/importer/wheelCutterHelpers.js.map +0 -1
- package/dist/importer/wheelRingHandleMath.d.ts +0 -20
- package/dist/importer/wheelRingHandleMath.js +0 -66
- package/dist/importer/wheelRingHandleMath.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/junk/DestructibleTarget.d.ts +0 -18
- package/dist/junk/DestructibleTarget.js +0 -223
- package/dist/junk/DestructibleTarget.js.map +0 -1
- package/dist/junk/KolmoJunk.d.ts +0 -14
- package/dist/junk/KolmoJunk.js +0 -76
- package/dist/junk/KolmoJunk.js.map +0 -1
- package/dist/junk/ShardPieces.d.ts +0 -13
- package/dist/junk/ShardPieces.js +0 -101
- package/dist/junk/ShardPieces.js.map +0 -1
- package/dist/junk/TargetDecals.d.ts +0 -9
- package/dist/junk/TargetDecals.js +0 -77
- package/dist/junk/TargetDecals.js.map +0 -1
- package/dist/junk/bvhShatter.d.ts +0 -3
- package/dist/junk/bvhShatter.js +0 -101
- package/dist/junk/bvhShatter.js.map +0 -1
- package/dist/junk/bvhTriCollector.d.ts +0 -16
- package/dist/junk/bvhTriCollector.js +0 -127
- package/dist/junk/bvhTriCollector.js.map +0 -1
- package/dist/junk/index.d.ts +0 -13
- package/dist/junk/index.js +0 -12
- package/dist/junk/index.js.map +0 -1
- package/dist/junk/junkGeometry.d.ts +0 -13
- package/dist/junk/junkGeometry.js +0 -87
- package/dist/junk/junkGeometry.js.map +0 -1
- package/dist/junk/junkImportSanitize.d.ts +0 -5
- package/dist/junk/junkImportSanitize.js +0 -74
- package/dist/junk/junkImportSanitize.js.map +0 -1
- package/dist/junk/junkImporter.d.ts +0 -14
- package/dist/junk/junkImporter.js +0 -124
- package/dist/junk/junkImporter.js.map +0 -1
- package/dist/junk/junkLabelCanvas.d.ts +0 -2
- package/dist/junk/junkLabelCanvas.js +0 -185
- package/dist/junk/junkLabelCanvas.js.map +0 -1
- package/dist/junk/junkLabels.d.ts +0 -9
- package/dist/junk/junkLabels.js +0 -49
- package/dist/junk/junkLabels.js.map +0 -1
- package/dist/junk/junkProceduralScenes.d.ts +0 -12
- package/dist/junk/junkProceduralScenes.js +0 -220
- package/dist/junk/junkProceduralScenes.js.map +0 -1
- package/dist/junk/junkTypes.d.ts +0 -48
- package/dist/junk/junkTypes.js +0 -0
- package/dist/junk/junkTypes.js.map +0 -1
- package/dist/junk/targetHelpers.d.ts +0 -55
- package/dist/junk/targetHelpers.js +0 -157
- package/dist/junk/targetHelpers.js.map +0 -1
- package/dist/junk/targetHitLogic.d.ts +0 -30
- package/dist/junk/targetHitLogic.js +0 -163
- package/dist/junk/targetHitLogic.js.map +0 -1
- package/dist/junk/useTargetAssets.d.ts +0 -19
- package/dist/junk/useTargetAssets.js +0 -130
- package/dist/junk/useTargetAssets.js.map +0 -1
- package/dist/physics/index.js.map +0 -1
- package/dist/sand3d/KolmoSand3D.d.ts +0 -19
- package/dist/sand3d/KolmoSand3D.js +0 -92
- package/dist/sand3d/KolmoSand3D.js.map +0 -1
- package/dist/sand3d/Sand3dWorkshopSection.d.ts +0 -8
- package/dist/sand3d/Sand3dWorkshopSection.js +0 -117
- package/dist/sand3d/Sand3dWorkshopSection.js.map +0 -1
- package/dist/sand3d/gateBakeHelpers.d.ts +0 -21
- package/dist/sand3d/gateBakeHelpers.js +0 -225
- package/dist/sand3d/gateBakeHelpers.js.map +0 -1
- package/dist/sand3d/gateDoorwayBake.d.ts +0 -12
- package/dist/sand3d/gateDoorwayBake.js +0 -203
- package/dist/sand3d/gateDoorwayBake.js.map +0 -1
- package/dist/sand3d/index.d.ts +0 -3
- package/dist/sand3d/index.js +0 -4
- package/dist/sand3d/index.js.map +0 -1
- package/dist/sand3d/sand3dAssetLoader.d.ts +0 -28
- package/dist/sand3d/sand3dAssetLoader.js +0 -177
- package/dist/sand3d/sand3dAssetLoader.js.map +0 -1
- package/dist/schema/kolmoSchema.d.ts +0 -9
- package/dist/schema/kolmoSchema.js +0 -110
- package/dist/schema/kolmoSchema.js.map +0 -1
- package/dist/schema/kolmoStamp.d.ts +0 -11
- package/dist/schema/kolmoStamp.js +0 -119
- package/dist/schema/kolmoStamp.js.map +0 -1
- package/dist/schema/kolmoTypes.d.ts +0 -63
- package/dist/schema/kolmoTypes.js +0 -66
- package/dist/schema/kolmoTypes.js.map +0 -1
- package/dist/shaders/celestialBackdrop.d.ts +0 -14
- package/dist/shaders/celestialBackdrop.js +0 -181
- package/dist/shaders/celestialBackdrop.js.map +0 -1
- package/dist/shaders/emitterShaders.d.ts +0 -9
- package/dist/shaders/emitterShaders.js +0 -114
- package/dist/shaders/emitterShaders.js.map +0 -1
- package/dist/shaders/index.d.ts +0 -5
- package/dist/shaders/index.js +0 -12
- package/dist/shaders/index.js.map +0 -1
- package/dist/shaders/plumeAndSparkle.d.ts +0 -12
- package/dist/shaders/plumeAndSparkle.js +0 -233
- package/dist/shaders/plumeAndSparkle.js.map +0 -1
- package/dist/shaders/ps2GlslShared.d.ts +0 -20
- package/dist/shaders/ps2GlslShared.js +0 -30
- package/dist/shaders/ps2GlslShared.js.map +0 -1
- package/dist/shaders/ps2MaterialsTSL.d.ts +0 -23
- package/dist/shaders/ps2MaterialsTSL.js +0 -146
- package/dist/shaders/ps2MaterialsTSL.js.map +0 -1
- package/dist/shaders/ps2MaterialsWebGL.d.ts +0 -15
- package/dist/shaders/ps2MaterialsWebGL.js +0 -57
- package/dist/shaders/ps2MaterialsWebGL.js.map +0 -1
- package/dist/shaders/ps2RoadWebGL.d.ts +0 -7
- package/dist/shaders/ps2RoadWebGL.js +0 -138
- package/dist/shaders/ps2RoadWebGL.js.map +0 -1
- package/dist/shaders/ps2TerrainWebGL.d.ts +0 -8
- package/dist/shaders/ps2TerrainWebGL.js +0 -131
- package/dist/shaders/ps2TerrainWebGL.js.map +0 -1
- package/dist/shaders/ps2Textures.d.ts +0 -22
- package/dist/shaders/ps2Textures.js +0 -299
- package/dist/shaders/ps2Textures.js.map +0 -1
- package/dist/shaders/retroPalettes.d.ts +0 -24
- package/dist/shaders/retroPalettes.js +0 -221
- package/dist/shaders/retroPalettes.js.map +0 -1
- package/dist/shaders/retroShader.d.ts +0 -13
- package/dist/shaders/retroShader.js +0 -110
- package/dist/shaders/retroShader.js.map +0 -1
- package/dist/shaders/retroUniforms.d.ts +0 -60
- package/dist/shaders/retroUniforms.js +0 -215
- package/dist/shaders/retroUniforms.js.map +0 -1
- package/dist/shaders/skyboxShaders.d.ts +0 -16
- package/dist/shaders/skyboxShaders.js +0 -266
- package/dist/shaders/skyboxShaders.js.map +0 -1
- package/dist/shaders/tsl.d.ts +0 -1
- package/dist/shaders/tsl.js +0 -1
- package/dist/shaders/tsl.js.map +0 -1
- package/dist/suika/KolmoSuikaOrb.d.ts +0 -33
- package/dist/suika/KolmoSuikaOrb.js +0 -375
- package/dist/suika/KolmoSuikaOrb.js.map +0 -1
- package/dist/suika/index.d.ts +0 -4
- package/dist/suika/index.js +0 -5
- package/dist/suika/index.js.map +0 -1
- package/dist/suika/suikaArbiter.d.ts +0 -60
- package/dist/suika/suikaArbiter.js +0 -265
- package/dist/suika/suikaArbiter.js.map +0 -1
- package/dist/suika/suikaGeometry.d.ts +0 -10
- package/dist/suika/suikaGeometry.js +0 -251
- package/dist/suika/suikaGeometry.js.map +0 -1
- package/dist/suika/suikaTypes.d.ts +0 -74
- package/dist/suika/suikaTypes.js +0 -196
- package/dist/suika/suikaTypes.js.map +0 -1
- package/dist/world/frontage.d.ts +0 -26
- package/dist/world/frontage.js +0 -36
- package/dist/world/frontage.js.map +0 -1
- package/dist/world/index.d.ts +0 -9
- package/dist/world/index.js +0 -12
- package/dist/world/index.js.map +0 -1
- package/dist/world/infiniteWorld2D.d.ts +0 -19
- package/dist/world/infiniteWorld2D.js +0 -219
- package/dist/world/infiniteWorld2D.js.map +0 -1
- package/dist/world/island.d.ts +0 -29
- package/dist/world/island.js +0 -116
- package/dist/world/island.js.map +0 -1
- package/dist/world/islandPathing.d.ts +0 -6
- package/dist/world/islandPathing.js +0 -166
- package/dist/world/islandPathing.js.map +0 -1
- package/dist/world/macroCellSchema.d.ts +0 -72
- package/dist/world/macroCellSchema.js +0 -34
- package/dist/world/macroCellSchema.js.map +0 -1
- package/dist/world/macroKnightAStar.d.ts +0 -11
- package/dist/world/macroKnightAStar.js +0 -240
- package/dist/world/macroKnightAStar.js.map +0 -1
- package/dist/world/macroSettlementZones.d.ts +0 -9
- package/dist/world/macroSettlementZones.js +0 -108
- package/dist/world/macroSettlementZones.js.map +0 -1
- package/dist/world/random.d.ts +0 -23
- package/dist/world/random.js +0 -59
- package/dist/world/random.js.map +0 -1
- package/dist/world/road.d.ts +0 -37
- package/dist/world/road.js +0 -198
- package/dist/world/road.js.map +0 -1
- package/dist/world/roadRibbon.d.ts +0 -29
- package/dist/world/roadRibbon.js +0 -166
- package/dist/world/roadRibbon.js.map +0 -1
- package/dist/world/terrain.d.ts +0 -62
- package/dist/world/terrain.js +0 -133
- package/dist/world/terrain.js.map +0 -1
- package/dist/world/terrainGeometry.d.ts +0 -14
- package/dist/world/terrainGeometry.js +0 -76
- package/dist/world/terrainGeometry.js.map +0 -1
- package/dist/world/worldTypes.d.ts +0 -43
- package/dist/world/worldTypes.js +0 -197
- package/dist/world/worldTypes.js.map +0 -1
- package/docs/api-reference.md +0 -148
- package/skills/kolmo-engine/SKILL.md +0 -111
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"junkProceduralScenes.js","names":[],"sources":["../../src/junk/junkProceduralScenes.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport {\n BOTTLE_HEIGHT,\n TIN_CAN_HEIGHT,\n TIN_CAN_RADIUS,\n buildGlassBottleGeometry,\n buildTinCanGeometry,\n createGlassBottleMaterial,\n createTinCanMaterials,\n} from \"./junkGeometry.js\";\nimport { getProceduralLabelTexture } from \"./junkLabels.js\";\nimport type { ProceduralLabelId } from \"./junkTypes.js\";\n\nexport type JunkProceduralRecipeId =\n | \"tin_can_cola\"\n | \"tin_can_oil\"\n | \"glass_bottle_amber\"\n | \"glass_bottle_emerald\"\n | \"wooden_supply_crate\"\n | \"hazard_fuel_drum\";\n\nexport interface JunkProceduralRecipe {\n readonly id: JunkProceduralRecipeId;\n readonly label: string;\n readonly domain: \"junk\";\n readonly targetMeters: number;\n readonly massKg: number;\n readonly color: string;\n}\n\nexport const JUNK_PROCEDURAL_RECIPES: readonly JunkProceduralRecipe[] = Object.freeze([\n { id: \"tin_can_cola\", label: \"Tin Can Cola\", domain: \"junk\", targetMeters: 0.25, massKg: 0.42, color: \"#06b6d4\" },\n { id: \"tin_can_oil\", label: \"Tin Can Oil\", domain: \"junk\", targetMeters: 0.28, massKg: 0.68, color: \"#d97706\" },\n { id: \"glass_bottle_amber\", label: \"Glass Bottle Amber\", domain: \"junk\", targetMeters: 0.32, massKg: 0.48, color: \"#f59e0b\" },\n { id: \"glass_bottle_emerald\", label: \"Glass Bottle Emerald\", domain: \"junk\", targetMeters: 0.32, massKg: 0.48, color: \"#10b981\" },\n { id: \"wooden_supply_crate\", label: \"Wooden Supply Crate\", domain: \"junk\", targetMeters: 0.64, massKg: 16, color: \"#b45309\" },\n { id: \"hazard_fuel_drum\", label: \"Hazard Fuel Drum\", domain: \"junk\", targetMeters: 0.88, massKg: 24, color: \"#eab308\" },\n]);\n\nfunction flatMat(color: string, roughness = 0.52, metalness = 0.18): THREE.MeshStandardMaterial {\n return new THREE.MeshStandardMaterial({ color, roughness, metalness, flatShading: true });\n}\n\nfunction addBox(parent: THREE.Object3D, name: string, sx: number, sy: number, sz: number, x: number, y: number, z: number, mat: THREE.Material): THREE.Mesh {\n const mesh = new THREE.Mesh(new THREE.BoxGeometry(sx, sy, sz), mat);\n mesh.name = name;\n mesh.position.set(x, y, z);\n parent.add(mesh);\n return mesh;\n}\n\nfunction buildCanVariant(id: \"tin_can_cola\" | \"tin_can_oil\", labelId: ProceduralLabelId, accentHex: string): THREE.Group {\n const group = new THREE.Group();\n group.name = id;\n const tex = getProceduralLabelTexture(labelId);\n const mats = createTinCanMaterials(tex);\n for (const m of mats) m.flatShading = true;\n if (!tex) mats[0].color.set(accentHex);\n\n const body = new THREE.Mesh(buildTinCanGeometry(\"12-gon\"), mats);\n body.name = \"CanBody\";\n body.position.y = TIN_CAN_HEIGHT * 0.5 + 0.004;\n group.add(body);\n\n const rimMat = flatMat(\"#cbd5e1\", 0.32, 0.78);\n for (const [nm, ry] of [[\"ChimeBottom\", 0.006], [\"ChimeTop\", TIN_CAN_HEIGHT + 0.004]] as const) {\n const ring = new THREE.Mesh(new THREE.TorusGeometry(TIN_CAN_RADIUS + 0.002, 0.005, 6, 12), rimMat);\n ring.name = nm;\n ring.rotation.x = Math.PI * 0.5;\n ring.position.y = ry;\n group.add(ring);\n }\n\n if (id === \"tin_can_cola\") {\n addBox(group, \"PullTab\", 0.024, 0.004, 0.038, 0, TIN_CAN_HEIGHT + 0.008, 0.014, rimMat);\n } else {\n const spout = new THREE.Mesh(new THREE.CylinderGeometry(0.014, 0.018, 0.028, 8), flatMat(\"#f59e0b\", 0.4, 0.3));\n spout.name = \"OilSpout\";\n spout.position.set(0.038, TIN_CAN_HEIGHT + 0.018, 0);\n group.add(spout);\n addBox(group, \"CarryHandle\", 0.07, 0.012, 0.014, -0.015, TIN_CAN_HEIGHT + 0.016, 0, rimMat);\n }\n return group;\n}\n\nfunction buildBottleVariant(id: \"glass_bottle_amber\" | \"glass_bottle_emerald\", labelId: ProceduralLabelId): THREE.Group {\n const group = new THREE.Group();\n group.name = id;\n const glassMat = createGlassBottleMaterial();\n glassMat.flatShading = true;\n if (id === \"glass_bottle_amber\") {\n glassMat.color.set(\"#d97706\");\n glassMat.opacity = 0.54;\n }\n\n const body = new THREE.Mesh(buildGlassBottleGeometry(), glassMat);\n body.name = \"BottleGlass\";\n body.position.y = BOTTLE_HEIGHT * 0.5;\n group.add(body);\n\n const tex = getProceduralLabelTexture(labelId);\n const bandMat = new THREE.MeshStandardMaterial({\n color: tex ? \"#ffffff\" : id === \"glass_bottle_amber\" ? \"#fef3c7\" : \"#ecfccb\",\n map: tex ?? null,\n roughness: 0.6,\n metalness: 0.06,\n flatShading: true,\n });\n const labelBand = new THREE.Mesh(new THREE.CylinderGeometry(0.0565, 0.0565, 0.095, 12, 1, true), bandMat);\n labelBand.name = \"BottleLabel\";\n labelBand.position.y = 0.115;\n group.add(labelBand);\n\n const capMat = flatMat(id === \"glass_bottle_amber\" ? \"#fbbf24\" : \"#a16207\", 0.42, id === \"glass_bottle_amber\" ? 0.68 : 0.12);\n const cap = new THREE.Mesh(new THREE.CylinderGeometry(0.025, 0.026, 0.022, 10), capMat);\n cap.name = \"BottleCap\";\n cap.position.y = BOTTLE_HEIGHT + 0.008;\n group.add(cap);\n return group;\n}\n\nfunction buildWoodenSupplyCrate(): THREE.Group {\n const group = new THREE.Group();\n group.name = \"wooden_supply_crate\";\n const S = 0.64, half = S * 0.5, post = 0.055;\n const plankMat = flatMat(\"#b45309\", 0.78, 0.06);\n const frameMat = flatMat(\"#92400e\", 0.82, 0.08);\n const ironMat = flatMat(\"#3f3f46\", 0.46, 0.62);\n\n addBox(group, \"CrateCore\", S - 0.06, S - 0.06, S - 0.06, 0, half, 0, plankMat);\n for (const sx of [-1, 1] as const) {\n for (const sz of [-1, 1] as const) {\n const o = half - post * 0.5;\n addBox(group, `CornerPost_${sx > 0 ? \"R\" : \"L\"}_${sz > 0 ? \"F\" : \"B\"}`, post, S, post, sx * o, half, sz * o, frameMat);\n addBox(group, `CornerBracket_${sx > 0 ? \"R\" : \"L\"}_${sz > 0 ? \"F\" : \"B\"}`, post + 0.01, 0.05, post + 0.01, sx * o, S - 0.025, sz * o, ironMat);\n }\n }\n for (let i = 0; i < 3; i++) {\n const y = 0.14 + i * 0.18;\n addBox(group, `SlatFront_${i}`, S - post * 1.6, 0.09, 0.024, 0, y, half - 0.012, frameMat);\n addBox(group, `SlatBack_${i}`, S - post * 1.6, 0.09, 0.024, 0, y, -(half - 0.012), frameMat);\n addBox(group, `SlatLeft_${i}`, 0.024, 0.09, S - post * 1.6, -(half - 0.012), y, 0, frameMat);\n addBox(group, `SlatRight_${i}`, 0.024, 0.09, S - post * 1.6, half - 0.012, y, 0, frameMat);\n }\n for (const [nm, z] of [[\"BraceFront\", half - 0.008], [\"BraceBack\", -(half - 0.008)]] as const) {\n const brace = addBox(group, nm, S * 0.92, 0.055, 0.02, 0, half, z, frameMat);\n brace.rotation.z = Math.PI * 0.25;\n }\n return group;\n}\n\nfunction buildHazardFuelDrum(): THREE.Group {\n const group = new THREE.Group();\n group.name = \"hazard_fuel_drum\";\n const H = 0.88, R = 0.285;\n const shellMat = flatMat(\"#dc2626\", 0.46, 0.42);\n const bandMat = flatMat(\"#facc15\", 0.48, 0.25);\n const steelMat = flatMat(\"#94a3b8\", 0.35, 0.72);\n\n const drum = new THREE.Mesh(new THREE.CylinderGeometry(R, R, H - 0.02, 12), shellMat);\n drum.name = \"DrumShell\";\n drum.position.y = H * 0.5;\n group.add(drum);\n\n const stripe = new THREE.Mesh(new THREE.CylinderGeometry(R + 0.003, R + 0.003, 0.22, 12), bandMat);\n stripe.name = \"HazardBand\";\n stripe.position.y = H * 0.5;\n group.add(stripe);\n\n for (const [idx, cy] of [[0, 0.018], [1, H * 0.33], [2, H * 0.67], [3, H - 0.018]] as const) {\n const chime = new THREE.Mesh(new THREE.TorusGeometry(R + 0.008, 0.014, 6, 12), steelMat);\n chime.name = `DrumChime_${idx}`;\n chime.rotation.x = Math.PI * 0.5;\n chime.position.y = cy;\n group.add(chime);\n }\n\n const bungMain = new THREE.Mesh(new THREE.CylinderGeometry(0.032, 0.032, 0.024, 8), steelMat);\n bungMain.name = \"BungFill\";\n bungMain.position.set(0.13, H, 0.05);\n const bungVent = new THREE.Mesh(new THREE.CylinderGeometry(0.018, 0.018, 0.02, 8), steelMat);\n bungVent.name = \"BungVent\";\n bungVent.position.set(-0.12, H, -0.06);\n group.add(bungMain, bungVent);\n return group;\n}\n\nexport function buildProceduralJunkScene(\n recipeOrId: JunkProceduralRecipeId | JunkProceduralRecipe | string = \"hazard_fuel_drum\",\n): THREE.Group {\n const id = typeof recipeOrId === \"string\" ? recipeOrId : recipeOrId.id;\n let scene: THREE.Group;\n switch (id) {\n case \"tin_can_cola\":\n scene = buildCanVariant(\"tin_can_cola\", \"tris-soda\", \"#06b6d4\");\n break;\n case \"tin_can_oil\":\n scene = buildCanVariant(\"tin_can_oil\", \"garys-beans\", \"#d97706\");\n break;\n case \"glass_bottle_amber\":\n scene = buildBottleVariant(\"glass_bottle_amber\", \"target\");\n break;\n case \"glass_bottle_emerald\":\n scene = buildBottleVariant(\"glass_bottle_emerald\", \"goofy-emoji\");\n break;\n case \"wooden_supply_crate\":\n scene = buildWoodenSupplyCrate();\n break;\n default:\n scene = buildHazardFuelDrum();\n break;\n }\n scene.userData.proceduralDomain = \"junk\";\n scene.userData.proceduralRecipeId = scene.name;\n return scene;\n}\n"],"mappings":";;;;AA8BA,IAAa,0BAA2D,O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D,QAAQ,uBAAuB;GAC/B;EACJ,SACI,QAAQ,oBAAoB;CAEpC;CACA,MAAM,SAAS,mBAAmB;CAClC,MAAM,SAAS,qBAAqB,MAAM;CAC1C,OAAO;AACX"}
|
package/dist/junk/junkTypes.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type * as THREE from "three";
|
|
2
|
-
export type JunkKind = "tin-can" | "glass-bottle" | "imported-glb";
|
|
3
|
-
export type CanLodMode = "auto" | "3-gon" | "12-gon";
|
|
4
|
-
export type ProceduralLabelId = "target" | "goofy-emoji" | "tris-soda" | "garys-beans" | "custom";
|
|
5
|
-
export interface DecalRecord {
|
|
6
|
-
id: string;
|
|
7
|
-
/** Position in target mesh local space. */
|
|
8
|
-
position: [number, number, number];
|
|
9
|
-
/** Euler XYZ rotation aligned to surface normal in target mesh local space. */
|
|
10
|
-
rotation: [number, number, number];
|
|
11
|
-
scale: number;
|
|
12
|
-
}
|
|
13
|
-
export interface ShardSpec {
|
|
14
|
-
id: string;
|
|
15
|
-
geometry: THREE.BufferGeometry;
|
|
16
|
-
centroid: [number, number, number];
|
|
17
|
-
halfExtents: [number, number, number];
|
|
18
|
-
volumeFraction: number;
|
|
19
|
-
}
|
|
20
|
-
export interface ImportedJunkSegment {
|
|
21
|
-
segmentId: string;
|
|
22
|
-
originalName: string;
|
|
23
|
-
customName: string;
|
|
24
|
-
destructible: boolean;
|
|
25
|
-
triCount: number;
|
|
26
|
-
bboxSizeM: [number, number, number];
|
|
27
|
-
}
|
|
28
|
-
export interface DestructibleTargetSpec {
|
|
29
|
-
id: string;
|
|
30
|
-
kind: JunkKind;
|
|
31
|
-
labelId: ProceduralLabelId;
|
|
32
|
-
customAlbedoUrl: string | null;
|
|
33
|
-
canLodMode: CanLodMode;
|
|
34
|
-
position: [number, number, number];
|
|
35
|
-
hp: number;
|
|
36
|
-
maxHp: number;
|
|
37
|
-
fragile: boolean;
|
|
38
|
-
shatterPieceCount: number;
|
|
39
|
-
importedUrl?: string | null;
|
|
40
|
-
segments?: ImportedJunkSegment[];
|
|
41
|
-
}
|
|
42
|
-
export interface BallisticHitEvent {
|
|
43
|
-
targetId: string;
|
|
44
|
-
point: [number, number, number];
|
|
45
|
-
normal: [number, number, number];
|
|
46
|
-
impulse: [number, number, number];
|
|
47
|
-
distance: number;
|
|
48
|
-
}
|
package/dist/junk/junkTypes.js
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"junkTypes.js","sources":["../../src/junk/junkTypes.ts"],"mappings":""}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import { type ResolvedCanLod } from "./junkGeometry.js";
|
|
3
|
-
import type { BallisticHitEvent, CanLodMode, JunkKind, ProceduralLabelId, ShardSpec } from "./junkTypes.js";
|
|
4
|
-
export declare const SHARD_COLLIDER_INSET = 0.65;
|
|
5
|
-
export declare function getTargetDensity(kind: JunkKind): number;
|
|
6
|
-
export interface SpawnedShardState {
|
|
7
|
-
spec: ShardSpec;
|
|
8
|
-
worldPos: [number, number, number];
|
|
9
|
-
worldQuat: [number, number, number, number];
|
|
10
|
-
impulse: [number, number, number];
|
|
11
|
-
torque: [number, number, number];
|
|
12
|
-
linvel: [number, number, number];
|
|
13
|
-
angvel: [number, number, number];
|
|
14
|
-
density: number;
|
|
15
|
-
}
|
|
16
|
-
export interface DestructibleTargetSnapshot {
|
|
17
|
-
id: string;
|
|
18
|
-
kind: JunkKind;
|
|
19
|
-
lodMode: CanLodMode;
|
|
20
|
-
activeLod: ResolvedCanLod;
|
|
21
|
-
triCount: number;
|
|
22
|
-
labelId: ProceduralLabelId;
|
|
23
|
-
customLabelLoaded: boolean;
|
|
24
|
-
materialTransparent: boolean;
|
|
25
|
-
opacity: number;
|
|
26
|
-
hp: number;
|
|
27
|
-
maxHp: number;
|
|
28
|
-
alive: boolean;
|
|
29
|
-
decalCount: number;
|
|
30
|
-
activeShardCount: number;
|
|
31
|
-
position: [number, number, number];
|
|
32
|
-
linearVelocity: [number, number, number];
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Computes target-mesh local-space position & Euler XYZ rotation for a `<Decal>`.
|
|
36
|
-
*/
|
|
37
|
-
export declare function computeLocalDecalTransform(mesh: THREE.Mesh, worldPoint: [number, number, number], worldNormal: [number, number, number]): {
|
|
38
|
-
position: [number, number, number];
|
|
39
|
-
rotation: [number, number, number];
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* Finds the nearest non-decal Mesh inside an Object3D to a world-space hit point.
|
|
43
|
-
*/
|
|
44
|
-
export declare function findClosestMeshInGroup(root: THREE.Object3D, worldPoint: [number, number, number]): THREE.Mesh | null;
|
|
45
|
-
/**
|
|
46
|
-
* Splits a target Object3D into BVH shards and computes world poses + impulses.
|
|
47
|
-
*/
|
|
48
|
-
export declare function buildShardStates(rootObj: THREE.Object3D, targetPieces: number, worldPos: THREE.Vector3, worldQuat: THREE.Quaternion, hit: BallisticHitEvent, kind?: JunkKind): {
|
|
49
|
-
states: SpawnedShardState[];
|
|
50
|
-
specs: ShardSpec[];
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Creates a DoubleSide material for tumbling shatter shards matching target kind.
|
|
54
|
-
*/
|
|
55
|
-
export declare function createShardMaterial(kind: JunkKind, labelTexture: THREE.Texture | null, importedRoot?: THREE.Object3D | null): THREE.Material;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { splitObjectIntoShards } from "./bvhShatter.js";
|
|
2
|
-
import { createGlassBottleMaterial } from "./junkGeometry.js";
|
|
3
|
-
import { isMeshNode } from "./junkImportSanitize.js";
|
|
4
|
-
import * as THREE from "three";
|
|
5
|
-
// src/junk/targetHelpers.ts
|
|
6
|
-
var SHARD_COLLIDER_INSET = .65;
|
|
7
|
-
function getTargetDensity(kind) {
|
|
8
|
-
return kind === "glass-bottle" ? 1200 : kind === "imported-glb" ? 800 : 220;
|
|
9
|
-
}
|
|
10
|
-
var _pt = new THREE.Vector3();
|
|
11
|
-
var _norm = new THREE.Vector3();
|
|
12
|
-
var _zAxis = new THREE.Vector3(0, 0, 1);
|
|
13
|
-
var _q = new THREE.Quaternion();
|
|
14
|
-
var _euler = new THREE.Euler();
|
|
15
|
-
var _invWorld = new THREE.Matrix4();
|
|
16
|
-
var _normMat = new THREE.Matrix3();
|
|
17
|
-
var _box = new THREE.Box3();
|
|
18
|
-
/**
|
|
19
|
-
* Computes target-mesh local-space position & Euler XYZ rotation for a `<Decal>`.
|
|
20
|
-
*/
|
|
21
|
-
function computeLocalDecalTransform(mesh, worldPoint, worldNormal) {
|
|
22
|
-
mesh.updateMatrixWorld(true);
|
|
23
|
-
_pt.set(worldPoint[0], worldPoint[1], worldPoint[2]);
|
|
24
|
-
mesh.worldToLocal(_pt);
|
|
25
|
-
_invWorld.copy(mesh.matrixWorld).invert();
|
|
26
|
-
_normMat.getNormalMatrix(_invWorld);
|
|
27
|
-
_norm.set(worldNormal[0], worldNormal[1], worldNormal[2]).applyMatrix3(_normMat);
|
|
28
|
-
if (_norm.lengthSq() > 1e-8) _norm.normalize();
|
|
29
|
-
else _norm.set(0, 0, 1);
|
|
30
|
-
_q.setFromUnitVectors(_zAxis, _norm);
|
|
31
|
-
_euler.setFromQuaternion(_q, "XYZ");
|
|
32
|
-
return {
|
|
33
|
-
position: [
|
|
34
|
-
_pt.x,
|
|
35
|
-
_pt.y,
|
|
36
|
-
_pt.z
|
|
37
|
-
],
|
|
38
|
-
rotation: [
|
|
39
|
-
_euler.x,
|
|
40
|
-
_euler.y,
|
|
41
|
-
_euler.z
|
|
42
|
-
]
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Finds the nearest non-decal Mesh inside an Object3D to a world-space hit point.
|
|
47
|
-
*/
|
|
48
|
-
function findClosestMeshInGroup(root, worldPoint) {
|
|
49
|
-
_pt.set(worldPoint[0], worldPoint[1], worldPoint[2]);
|
|
50
|
-
let best = null;
|
|
51
|
-
let bestDist = Infinity;
|
|
52
|
-
root.traverse((obj) => {
|
|
53
|
-
if (!isMeshNode(obj) || obj.userData.isDecal || obj.userData.isGizmo) return;
|
|
54
|
-
_box.setFromObject(obj);
|
|
55
|
-
const d = _box.distanceToPoint(_pt);
|
|
56
|
-
if (d < bestDist) {
|
|
57
|
-
bestDist = d;
|
|
58
|
-
best = obj;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return best;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Splits a target Object3D into BVH shards and computes world poses + impulses.
|
|
65
|
-
*/
|
|
66
|
-
function buildShardStates(rootObj, targetPieces, worldPos, worldQuat, hit, kind = "tin-can") {
|
|
67
|
-
const specs = splitObjectIntoShards(rootObj, targetPieces);
|
|
68
|
-
const density = getTargetDensity(kind);
|
|
69
|
-
const impVec = new THREE.Vector3(...hit.impulse);
|
|
70
|
-
const speedScale = Math.min(1.5, Math.max(.75, .75 + impVec.length() * .12));
|
|
71
|
-
const hitDir = impVec.lengthSq() > 1e-6 ? impVec.clone().normalize() : new THREE.Vector3(0, .25, -1).normalize();
|
|
72
|
-
return {
|
|
73
|
-
states: specs.map((spec, idx) => {
|
|
74
|
-
const off = new THREE.Vector3(...spec.centroid).applyQuaternion(worldQuat);
|
|
75
|
-
const dir = off.lengthSq() > 1e-6 ? off.clone().normalize() : new THREE.Vector3(idx % 3 - 1, .5, (idx + 1) % 3 - 1).normalize();
|
|
76
|
-
const pos = worldPos.clone().add(off).addScaledVector(dir, .008);
|
|
77
|
-
const hx = Math.max(.01, spec.halfExtents[0] * SHARD_COLLIDER_INSET);
|
|
78
|
-
const hy = Math.max(.01, spec.halfExtents[1] * SHARD_COLLIDER_INSET);
|
|
79
|
-
const hz = Math.max(.01, spec.halfExtents[2] * SHARD_COLLIDER_INSET);
|
|
80
|
-
const mass = Math.max(.008, 8 * hx * hy * hz * density);
|
|
81
|
-
const linvel = dir.clone().multiplyScalar(1.25 * speedScale).addScaledVector(hitDir, .85 * speedScale);
|
|
82
|
-
linvel.y += .8 * speedScale;
|
|
83
|
-
const imp = linvel.clone().multiplyScalar(mass);
|
|
84
|
-
const sign = idx % 2 === 0 ? 1 : -1;
|
|
85
|
-
const angvel = new THREE.Vector3(sign * (.6 + dir.z * .4), sign * (.7 + dir.x * .4), -sign * (.5 + dir.y * .4)).multiplyScalar(7.5);
|
|
86
|
-
const I = Math.max(1e-5, mass * (hx * hx + hy * hy + hz * hz) * .35);
|
|
87
|
-
const torque = angvel.clone().multiplyScalar(I);
|
|
88
|
-
return {
|
|
89
|
-
spec,
|
|
90
|
-
worldPos: [
|
|
91
|
-
pos.x,
|
|
92
|
-
pos.y,
|
|
93
|
-
pos.z
|
|
94
|
-
],
|
|
95
|
-
worldQuat: [
|
|
96
|
-
worldQuat.x,
|
|
97
|
-
worldQuat.y,
|
|
98
|
-
worldQuat.z,
|
|
99
|
-
worldQuat.w
|
|
100
|
-
],
|
|
101
|
-
impulse: [
|
|
102
|
-
imp.x,
|
|
103
|
-
imp.y,
|
|
104
|
-
imp.z
|
|
105
|
-
],
|
|
106
|
-
torque: [
|
|
107
|
-
torque.x,
|
|
108
|
-
torque.y,
|
|
109
|
-
torque.z
|
|
110
|
-
],
|
|
111
|
-
linvel: [
|
|
112
|
-
linvel.x,
|
|
113
|
-
linvel.y,
|
|
114
|
-
linvel.z
|
|
115
|
-
],
|
|
116
|
-
angvel: [
|
|
117
|
-
angvel.x,
|
|
118
|
-
angvel.y,
|
|
119
|
-
angvel.z
|
|
120
|
-
],
|
|
121
|
-
density
|
|
122
|
-
};
|
|
123
|
-
}),
|
|
124
|
-
specs
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Creates a DoubleSide material for tumbling shatter shards matching target kind.
|
|
129
|
-
*/
|
|
130
|
-
function createShardMaterial(kind, labelTexture, importedRoot) {
|
|
131
|
-
if (kind === "glass-bottle") return createGlassBottleMaterial();
|
|
132
|
-
if (kind === "tin-can") return new THREE.MeshStandardMaterial({
|
|
133
|
-
color: labelTexture ? "#e2e8f0" : "#94a3b8",
|
|
134
|
-
map: labelTexture ?? null,
|
|
135
|
-
roughness: .45,
|
|
136
|
-
metalness: .35,
|
|
137
|
-
side: THREE.DoubleSide
|
|
138
|
-
});
|
|
139
|
-
let foundMat = null;
|
|
140
|
-
importedRoot?.traverse((obj) => {
|
|
141
|
-
if (!foundMat && isMeshNode(obj) && !obj.userData.isDecal && !obj.userData.isGizmo) foundMat = Array.isArray(obj.material) ? obj.material[0] ?? null : obj.material ?? null;
|
|
142
|
-
});
|
|
143
|
-
if (foundMat) {
|
|
144
|
-
const cloned = foundMat.clone();
|
|
145
|
-
cloned.side = THREE.DoubleSide;
|
|
146
|
-
return cloned;
|
|
147
|
-
}
|
|
148
|
-
return new THREE.MeshStandardMaterial({
|
|
149
|
-
color: "#cbd5e1",
|
|
150
|
-
roughness: .6,
|
|
151
|
-
metalness: .2,
|
|
152
|
-
side: THREE.DoubleSide
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
export { SHARD_COLLIDER_INSET, buildShardStates, computeLocalDecalTransform, createShardMaterial, findClosestMeshInGroup, getTargetDensity };
|
|
156
|
-
|
|
157
|
-
//# sourceMappingURL=targetHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targetHelpers.js","names":[],"sources":["../../src/junk/targetHelpers.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { splitObjectIntoShards } from \"./bvhShatter.js\";\nimport { createGlassBottleMaterial, type ResolvedCanLod } from \"./junkGeometry.js\";\nimport { isMeshNode } from \"./junkImportSanitize.js\";\nimport type { BallisticHitEvent, CanLodMode, JunkKind, ProceduralLabelId, ShardSpec } from \"./junkTypes.js\";\n\nexport const SHARD_COLLIDER_INSET = 0.65;\n\nexport function getTargetDensity(kind: JunkKind): number {\n return kind === \"glass-bottle\" ? 1200 : kind === \"imported-glb\" ? 800 : 220;\n}\n\nexport interface SpawnedShardState {\n spec: ShardSpec;\n worldPos: [number, number, number];\n worldQuat: [number, number, number, number];\n impulse: [number, number, number];\n torque: [number, number, number];\n linvel: [number, number, number];\n angvel: [number, number, number];\n density: number;\n}\n\nexport interface DestructibleTargetSnapshot {\n id: string;\n kind: JunkKind;\n lodMode: CanLodMode;\n activeLod: ResolvedCanLod;\n triCount: number;\n labelId: ProceduralLabelId;\n customLabelLoaded: boolean;\n materialTransparent: boolean;\n opacity: number;\n hp: number;\n maxHp: number;\n alive: boolean;\n decalCount: number;\n activeShardCount: number;\n position: [number, number, number];\n linearVelocity: [number, number, number];\n}\n\nconst _pt = new THREE.Vector3();\nconst _norm = new THREE.Vector3();\nconst _zAxis = new THREE.Vector3(0, 0, 1);\nconst _q = new THREE.Quaternion();\nconst _euler = new THREE.Euler();\nconst _invWorld = new THREE.Matrix4();\nconst _normMat = new THREE.Matrix3();\nconst _box = new THREE.Box3();\n\n/**\n * Computes target-mesh local-space position & Euler XYZ rotation for a `<Decal>`.\n */\nexport function computeLocalDecalTransform(\n mesh: THREE.Mesh,\n worldPoint: [number, number, number],\n worldNormal: [number, number, number],\n): { position: [number, number, number]; rotation: [number, number, number] } {\n mesh.updateMatrixWorld(true);\n _pt.set(worldPoint[0], worldPoint[1], worldPoint[2]);\n mesh.worldToLocal(_pt);\n _invWorld.copy(mesh.matrixWorld).invert();\n _normMat.getNormalMatrix(_invWorld);\n _norm.set(worldNormal[0], worldNormal[1], worldNormal[2]).applyMatrix3(_normMat);\n if (_norm.lengthSq() > 1e-8)\n _norm.normalize();\n else\n _norm.set(0, 0, 1);\n _q.setFromUnitVectors(_zAxis, _norm);\n _euler.setFromQuaternion(_q, \"XYZ\");\n return {\n position: [_pt.x, _pt.y, _pt.z],\n rotation: [_euler.x, _euler.y, _euler.z],\n };\n}\n\n/**\n * Finds the nearest non-decal Mesh inside an Object3D to a world-space hit point.\n */\nexport function findClosestMeshInGroup(root: THREE.Object3D, worldPoint: [number, number, number]): THREE.Mesh | null {\n _pt.set(worldPoint[0], worldPoint[1], worldPoint[2]);\n let best: THREE.Mesh | null = null;\n let bestDist = Infinity;\n root.traverse((obj) => {\n if (!isMeshNode(obj) || obj.userData.isDecal || obj.userData.isGizmo)\n return;\n _box.setFromObject(obj);\n const d = _box.distanceToPoint(_pt);\n if (d < bestDist) {\n bestDist = d;\n best = obj;\n }\n });\n return best;\n}\n\n/**\n * Splits a target Object3D into BVH shards and computes world poses + impulses.\n */\nexport function buildShardStates(\n rootObj: THREE.Object3D,\n targetPieces: number,\n worldPos: THREE.Vector3,\n worldQuat: THREE.Quaternion,\n hit: BallisticHitEvent,\n kind: JunkKind = \"tin-can\",\n): { states: SpawnedShardState[]; specs: ShardSpec[] } {\n const specs = splitObjectIntoShards(rootObj, targetPieces);\n const density = getTargetDensity(kind);\n const impVec = new THREE.Vector3(...hit.impulse);\n const speedScale = Math.min(1.5, Math.max(0.75, 0.75 + impVec.length() * 0.12));\n const hitDir = impVec.lengthSq() > 1e-6 ? impVec.clone().normalize() : new THREE.Vector3(0, 0.25, -1).normalize();\n\n const states: SpawnedShardState[] = specs.map((spec, idx) => {\n const off = new THREE.Vector3(...spec.centroid).applyQuaternion(worldQuat);\n const dir =\n off.lengthSq() > 1e-6\n ? off.clone().normalize()\n : new THREE.Vector3((idx % 3) - 1, 0.5, ((idx + 1) % 3) - 1).normalize();\n const pos = worldPos.clone().add(off).addScaledVector(dir, 0.008);\n const hx = Math.max(0.01, spec.halfExtents[0] * SHARD_COLLIDER_INSET);\n const hy = Math.max(0.01, spec.halfExtents[1] * SHARD_COLLIDER_INSET);\n const hz = Math.max(0.01, spec.halfExtents[2] * SHARD_COLLIDER_INSET);\n const mass = Math.max(0.008, 8 * hx * hy * hz * density);\n const linvel = dir.clone().multiplyScalar(1.25 * speedScale).addScaledVector(hitDir, 0.85 * speedScale);\n linvel.y += 0.8 * speedScale;\n const imp = linvel.clone().multiplyScalar(mass);\n const sign = idx % 2 === 0 ? 1 : -1;\n const angvel = new THREE.Vector3(sign * (0.6 + dir.z * 0.4), sign * (0.7 + dir.x * 0.4), -sign * (0.5 + dir.y * 0.4)).multiplyScalar(7.5);\n const I = Math.max(1e-5, mass * (hx * hx + hy * hy + hz * hz) * 0.35);\n const torque = angvel.clone().multiplyScalar(I);\n return {\n spec,\n worldPos: [pos.x, pos.y, pos.z],\n worldQuat: [worldQuat.x, worldQuat.y, worldQuat.z, worldQuat.w],\n impulse: [imp.x, imp.y, imp.z],\n torque: [torque.x, torque.y, torque.z],\n linvel: [linvel.x, linvel.y, linvel.z],\n angvel: [angvel.x, angvel.y, angvel.z],\n density,\n };\n });\n return { states, specs };\n}\n\n/**\n * Creates a DoubleSide material for tumbling shatter shards matching target kind.\n */\nexport function createShardMaterial(\n kind: JunkKind,\n labelTexture: THREE.Texture | null,\n importedRoot?: THREE.Object3D | null,\n): THREE.Material {\n if (kind === \"glass-bottle\")\n return createGlassBottleMaterial();\n if (kind === \"tin-can\") {\n return new THREE.MeshStandardMaterial({\n color: labelTexture ? \"#e2e8f0\" : \"#94a3b8\",\n map: labelTexture ?? null,\n roughness: 0.45,\n metalness: 0.35,\n side: THREE.DoubleSide,\n });\n }\n let foundMat: THREE.Material | null = null;\n importedRoot?.traverse((obj) => {\n if (!foundMat && isMeshNode(obj) && !obj.userData.isDecal && !obj.userData.isGizmo) {\n foundMat = Array.isArray(obj.material) ? (obj.material[0] ?? null) : (obj.material ?? null);\n }\n });\n if (foundMat) {\n const cloned = (foundMat as THREE.Material).clone();\n cloned.side = THREE.DoubleSide;\n return cloned;\n }\n return new THREE.MeshStandardMaterial({\n color: \"#cbd5e1\",\n roughness: 0.6,\n metalness: 0.2,\n side: THREE.DoubleSide,\n });\n}\n"],"mappings":";;;;;AAMA,IAAa,uBAAuB;AAEpC,SAAgB,iBAAiB,MAAwB;CACrD,OAAO,SAAS,iBAAiB,OAAO,SAAS,iBAAiB,MAAM;AAC5E;AAgCA,IAAM,MAAM,IAAI,MAAM,QAAQ;AAC9B,IAAM,QA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AClD,OAAO,OAAO,MAAM;EACpB,OAAO;CACX;CACA,OAAO,IAAI,MAAM,qBAAqB;EAClC,OAAO;EACP,WAAW;EACX,WAAW;EACX,MAAM,MAAM;CAChB,CAAC;AACL"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { RefObject } from "react";
|
|
2
|
-
import type { RapierRigidBody } from "@react-three/rapier";
|
|
3
|
-
import * as THREE from "three";
|
|
4
|
-
import type { ResolvedCanLod } from "./junkGeometry.js";
|
|
5
|
-
import type { BallisticHitEvent, DecalRecord, DestructibleTargetSpec, ShardSpec } from "./junkTypes.js";
|
|
6
|
-
import { type DestructibleTargetSnapshot, type SpawnedShardState } from "./targetHelpers.js";
|
|
7
|
-
import type { TargetAssetBundle } from "./useTargetAssets.js";
|
|
8
|
-
export interface HitExecutionResult {
|
|
9
|
-
shattered: boolean;
|
|
10
|
-
nextHp: number;
|
|
11
|
-
shatterPos?: [number, number, number];
|
|
12
|
-
bodyPos?: [number, number, number];
|
|
13
|
-
shardStates?: SpawnedShardState[];
|
|
14
|
-
shardSpecs?: ShardSpec[];
|
|
15
|
-
shardMaterial?: THREE.Material;
|
|
16
|
-
newDecal?: DecalRecord;
|
|
17
|
-
newDecalMesh?: THREE.Mesh;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Applies physical knockback impulse and computes either a shatter state or a local decal.
|
|
21
|
-
*/
|
|
22
|
-
export declare function executeTargetHit(spec: DestructibleTargetSpec, assets: TargetAssetBundle, rb: RapierRigidBody | null, group: THREE.Group | null, primaryMesh: THREE.Mesh | null, currentHp: number, nextDecalId: string, hit: BallisticHitEvent): HitExecutionResult;
|
|
23
|
-
/**
|
|
24
|
-
* Formats a runtime telemetry snapshot for a DestructibleTarget.
|
|
25
|
-
*/
|
|
26
|
-
export declare function buildTargetSnapshot(spec: DestructibleTargetSpec, assets: TargetAssetBundle, rb: RapierRigidBody | null, hp: number, alive: boolean, decalCount: number, shardCount: number, lastPosition?: [number, number, number], activeLod?: ResolvedCanLod): DestructibleTargetSnapshot;
|
|
27
|
-
export declare function attachDecalMeshRef(map: Map<string, RefObject<THREE.Mesh>>, decalId: string, mesh?: THREE.Mesh): void;
|
|
28
|
-
export declare function appendDecalBounded(prev: ReadonlyArray<DecalRecord>, nextDecal: DecalRecord, meshRefs: Map<string, RefObject<THREE.Mesh>>, nextMesh?: THREE.Mesh, maxDecals?: number): DecalRecord[];
|
|
29
|
-
export declare function tagImportedMeshes(root: THREE.Object3D | null, targetId: string, applyHit: (hit: BallisticHitEvent) => void): void;
|
|
30
|
-
export declare function readTargetWorldPos(rb: RapierRigidBody | null, group: THREE.Group | null, out: THREE.Vector3): boolean;
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { isMeshNode } from "./junkImportSanitize.js";
|
|
2
|
-
import { buildShardStates, computeLocalDecalTransform, createShardMaterial, findClosestMeshInGroup } from "./targetHelpers.js";
|
|
3
|
-
import * as THREE from "three";
|
|
4
|
-
// src/junk/targetHitLogic.ts
|
|
5
|
-
var _scale = new THREE.Vector3();
|
|
6
|
-
/**
|
|
7
|
-
* Applies physical knockback impulse and computes either a shatter state or a local decal.
|
|
8
|
-
*/
|
|
9
|
-
function executeTargetHit(spec, assets, rb, group, primaryMesh, currentHp, nextDecalId, hit) {
|
|
10
|
-
let bodyPos;
|
|
11
|
-
if (rb) {
|
|
12
|
-
const maxImp = Math.max(.001, rb.mass()) * 3.5;
|
|
13
|
-
const impMag = Math.hypot(hit.impulse[0], hit.impulse[1], hit.impulse[2]);
|
|
14
|
-
const scale = impMag > maxImp && impMag > 1e-6 ? maxImp / impMag : 1;
|
|
15
|
-
rb.applyImpulseAtPoint({
|
|
16
|
-
x: hit.impulse[0] * scale,
|
|
17
|
-
y: hit.impulse[1] * scale,
|
|
18
|
-
z: hit.impulse[2] * scale
|
|
19
|
-
}, {
|
|
20
|
-
x: hit.point[0],
|
|
21
|
-
y: hit.point[1],
|
|
22
|
-
z: hit.point[2]
|
|
23
|
-
}, true);
|
|
24
|
-
const t = rb.translation();
|
|
25
|
-
bodyPos = [
|
|
26
|
-
t.x,
|
|
27
|
-
t.y,
|
|
28
|
-
t.z
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
const hitMag = Math.hypot(hit.impulse[0], hit.impulse[1], hit.impulse[2]);
|
|
32
|
-
const dmg = Math.max(1, Math.round(spec.maxHp * Math.min(1, Math.max(.28, hitMag / 8))));
|
|
33
|
-
const nextHp = Math.max(0, currentHp - dmg);
|
|
34
|
-
if ((spec.fragile || nextHp <= 0) && group) {
|
|
35
|
-
const wPos = new THREE.Vector3(...spec.position);
|
|
36
|
-
const wQuat = new THREE.Quaternion();
|
|
37
|
-
if (rb) {
|
|
38
|
-
const t = rb.translation();
|
|
39
|
-
const r = rb.rotation();
|
|
40
|
-
wPos.set(t.x, t.y, t.z);
|
|
41
|
-
wQuat.set(r.x, r.y, r.z, r.w);
|
|
42
|
-
} else {
|
|
43
|
-
group.getWorldPosition(wPos);
|
|
44
|
-
group.getWorldQuaternion(wQuat);
|
|
45
|
-
}
|
|
46
|
-
const { states, specs } = buildShardStates(group, spec.shatterPieceCount, wPos, wQuat, hit, spec.kind);
|
|
47
|
-
const shardMaterial = createShardMaterial(spec.kind, assets.activeLabelTex, assets.importedRoot);
|
|
48
|
-
return {
|
|
49
|
-
shattered: true,
|
|
50
|
-
nextHp: 0,
|
|
51
|
-
shatterPos: [
|
|
52
|
-
wPos.x,
|
|
53
|
-
wPos.y,
|
|
54
|
-
wPos.z
|
|
55
|
-
],
|
|
56
|
-
shardStates: states,
|
|
57
|
-
shardSpecs: specs,
|
|
58
|
-
shardMaterial
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
const hitMesh = primaryMesh ?? (group ? findClosestMeshInGroup(group, hit.point) : null);
|
|
62
|
-
if (!hitMesh) return {
|
|
63
|
-
shattered: false,
|
|
64
|
-
nextHp,
|
|
65
|
-
bodyPos
|
|
66
|
-
};
|
|
67
|
-
const xf = computeLocalDecalTransform(hitMesh, hit.point, hit.normal);
|
|
68
|
-
hitMesh.getWorldScale(_scale);
|
|
69
|
-
const avgScale = Math.max(1e-4, (Math.abs(_scale.x) + Math.abs(_scale.y) + Math.abs(_scale.z)) / 3);
|
|
70
|
-
return {
|
|
71
|
-
shattered: false,
|
|
72
|
-
nextHp,
|
|
73
|
-
bodyPos,
|
|
74
|
-
newDecal: {
|
|
75
|
-
id: nextDecalId,
|
|
76
|
-
position: xf.position,
|
|
77
|
-
rotation: xf.rotation,
|
|
78
|
-
scale: .045 / avgScale
|
|
79
|
-
},
|
|
80
|
-
newDecalMesh: primaryMesh ? void 0 : hitMesh
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Formats a runtime telemetry snapshot for a DestructibleTarget.
|
|
85
|
-
*/
|
|
86
|
-
function buildTargetSnapshot(spec, assets, rb, hp, alive, decalCount, shardCount, lastPosition, activeLod = "12-gon") {
|
|
87
|
-
let t = null;
|
|
88
|
-
let lv = null;
|
|
89
|
-
if (alive && rb) try {
|
|
90
|
-
t = rb.translation();
|
|
91
|
-
lv = rb.linvel();
|
|
92
|
-
} catch {
|
|
93
|
-
t = null;
|
|
94
|
-
lv = null;
|
|
95
|
-
}
|
|
96
|
-
const fallbackPos = lastPosition ?? spec.position;
|
|
97
|
-
const triCount = spec.kind === "tin-can" ? activeLod === "3-gon" ? assets.can3TriCount : assets.can12TriCount : assets.baseTriCount;
|
|
98
|
-
return {
|
|
99
|
-
id: spec.id,
|
|
100
|
-
kind: spec.kind,
|
|
101
|
-
lodMode: spec.canLodMode,
|
|
102
|
-
activeLod,
|
|
103
|
-
triCount,
|
|
104
|
-
labelId: spec.labelId,
|
|
105
|
-
customLabelLoaded: assets.customLabelLoaded,
|
|
106
|
-
materialTransparent: spec.kind === "glass-bottle",
|
|
107
|
-
opacity: spec.kind === "glass-bottle" ? .42 : 1,
|
|
108
|
-
hp,
|
|
109
|
-
maxHp: spec.maxHp,
|
|
110
|
-
alive,
|
|
111
|
-
decalCount: alive ? decalCount : 0,
|
|
112
|
-
activeShardCount: alive ? 0 : shardCount,
|
|
113
|
-
position: t ? [
|
|
114
|
-
t.x,
|
|
115
|
-
t.y,
|
|
116
|
-
t.z
|
|
117
|
-
] : [...fallbackPos],
|
|
118
|
-
linearVelocity: lv ? [
|
|
119
|
-
lv.x,
|
|
120
|
-
lv.y,
|
|
121
|
-
lv.z
|
|
122
|
-
] : [
|
|
123
|
-
0,
|
|
124
|
-
0,
|
|
125
|
-
0
|
|
126
|
-
]
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function attachDecalMeshRef(map, decalId, mesh) {
|
|
130
|
-
if (mesh) map.set(decalId, { current: mesh });
|
|
131
|
-
}
|
|
132
|
-
function appendDecalBounded(prev, nextDecal, meshRefs, nextMesh, maxDecals = 16) {
|
|
133
|
-
const combined = [...prev, nextDecal];
|
|
134
|
-
const drop = Math.max(0, combined.length - maxDecals);
|
|
135
|
-
for (let i = 0; i < drop; i++) meshRefs.delete(combined[i].id);
|
|
136
|
-
attachDecalMeshRef(meshRefs, nextDecal.id, nextMesh);
|
|
137
|
-
return drop > 0 ? combined.slice(drop) : combined;
|
|
138
|
-
}
|
|
139
|
-
function tagImportedMeshes(root, targetId, applyHit) {
|
|
140
|
-
root?.traverse((obj) => {
|
|
141
|
-
if (isMeshNode(obj) && !obj.userData.isDecal) {
|
|
142
|
-
obj.userData.targetId = targetId;
|
|
143
|
-
obj.userData.destructibleTarget = true;
|
|
144
|
-
obj.userData.isDestructibleTarget = true;
|
|
145
|
-
obj.userData.applyHit = applyHit;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
function readTargetWorldPos(rb, group, out) {
|
|
150
|
-
if (rb) try {
|
|
151
|
-
const t = rb.translation();
|
|
152
|
-
out.set(t.x, t.y, t.z);
|
|
153
|
-
return true;
|
|
154
|
-
} catch {}
|
|
155
|
-
if (group) {
|
|
156
|
-
group.getWorldPosition(out);
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
return false;
|
|
160
|
-
}
|
|
161
|
-
export { appendDecalBounded, attachDecalMeshRef, buildTargetSnapshot, executeTargetHit, readTargetWorldPos, tagImportedMeshes };
|
|
162
|
-
|
|
163
|
-
//# sourceMappingURL=targetHitLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"targetHitLogic.js","names":[],"sources":["../../src/junk/targetHitLogic.ts"],"sourcesContent":["import type { RefObject } from \"react\";\nimport type { RapierRigidBody } from \"@react-three/rapier\";\nimport * as THREE from \"three\";\nimport type { ResolvedCanLod } from \"./junkGeometry.js\";\nimport type { BallisticHitEvent, DecalRecord, DestructibleTargetSpec, ShardSpec } from \"./junkTypes.js\";\nimport { isMeshNode } from \"./junkImportSanitize.js\";\nimport {\n buildShardStates,\n computeLocalDecalTransform,\n createShardMaterial,\n findClosestMeshInGroup,\n type DestructibleTargetSnapshot,\n type SpawnedShardState,\n} from \"./targetHelpers.js\";\nimport type { TargetAssetBundle } from \"./useTargetAssets.js\";\n\nexport interface HitExecutionResult {\n shattered: boolean;\n nextHp: number;\n shatterPos?: [number, number, number];\n bodyPos?: [number, number, number];\n shardStates?: SpawnedShardState[];\n shardSpecs?: ShardSpec[];\n shardMaterial?: THREE.Material;\n newDecal?: DecalRecord;\n newDecalMesh?: THREE.Mesh;\n}\n\nconst _scale = new THREE.Vector3();\n\n/**\n * Applies physical knockback impulse and computes either a shatter state or a local decal.\n */\nexport function executeTargetHit(\n spec: DestructibleTargetSpec,\n assets: TargetAssetBundle,\n rb: RapierRigidBody | null,\n group: THREE.Group | null,\n primaryMesh: THREE.Mesh | null,\n currentHp: number,\n nextDecalId: string,\n hit: BallisticHitEvent,\n): HitExecutionResult {\n let bodyPos: [number, number, number] | undefined;\n if (rb) {\n const maxImp = Math.max(0.001, rb.mass()) * 3.5;\n const impMag = Math.hypot(hit.impulse[0], hit.impulse[1], hit.impulse[2]);\n const scale = impMag > maxImp && impMag > 1e-6 ? maxImp / impMag : 1;\n rb.applyImpulseAtPoint(\n { x: hit.impulse[0] * scale, y: hit.impulse[1] * scale, z: hit.impulse[2] * scale },\n { x: hit.point[0], y: hit.point[1], z: hit.point[2] },\n true,\n );\n const t = rb.translation();\n bodyPos = [t.x, t.y, t.z];\n }\n\n const hitMag = Math.hypot(hit.impulse[0], hit.impulse[1], hit.impulse[2]);\n const dmg = Math.max(1, Math.round(spec.maxHp * Math.min(1, Math.max(0.28, hitMag / 8))));\n const nextHp = Math.max(0, currentHp - dmg);\n\n if ((spec.fragile || nextHp <= 0) && group) {\n const wPos = new THREE.Vector3(...spec.position);\n const wQuat = new THREE.Quaternion();\n if (rb) {\n const t = rb.translation();\n const r = rb.rotation();\n wPos.set(t.x, t.y, t.z);\n wQuat.set(r.x, r.y, r.z, r.w);\n }\n else {\n group.getWorldPosition(wPos);\n group.getWorldQuaternion(wQuat);\n }\n const { states, specs } = buildShardStates(group, spec.shatterPieceCount, wPos, wQuat, hit, spec.kind);\n const shardMaterial = createShardMaterial(spec.kind, assets.activeLabelTex, assets.importedRoot);\n return {\n shattered: true,\n nextHp: 0,\n shatterPos: [wPos.x, wPos.y, wPos.z],\n shardStates: states,\n shardSpecs: specs,\n shardMaterial,\n };\n }\n\n const hitMesh = primaryMesh ?? (group ? findClosestMeshInGroup(group, hit.point) : null);\n if (!hitMesh)\n return { shattered: false, nextHp, bodyPos };\n const xf = computeLocalDecalTransform(hitMesh, hit.point, hit.normal);\n hitMesh.getWorldScale(_scale);\n const avgScale = Math.max(1e-4, (Math.abs(_scale.x) + Math.abs(_scale.y) + Math.abs(_scale.z)) / 3);\n return {\n shattered: false,\n nextHp,\n bodyPos,\n newDecal: {\n id: nextDecalId,\n position: xf.position,\n rotation: xf.rotation,\n scale: 0.045 / avgScale,\n },\n newDecalMesh: primaryMesh ? undefined : hitMesh,\n };\n}\n\n/**\n * Formats a runtime telemetry snapshot for a DestructibleTarget.\n */\nexport function buildTargetSnapshot(\n spec: DestructibleTargetSpec,\n assets: TargetAssetBundle,\n rb: RapierRigidBody | null,\n hp: number,\n alive: boolean,\n decalCount: number,\n shardCount: number,\n lastPosition?: [number, number, number],\n activeLod: ResolvedCanLod = \"12-gon\",\n): DestructibleTargetSnapshot {\n let t: { x: number; y: number; z: number } | null = null;\n let lv: { x: number; y: number; z: number } | null = null;\n if (alive && rb) {\n try {\n t = rb.translation();\n lv = rb.linvel();\n }\n catch {\n t = null;\n lv = null;\n }\n }\n const fallbackPos = lastPosition ?? spec.position;\n const triCount =\n spec.kind === \"tin-can\"\n ? (activeLod === \"3-gon\" ? assets.can3TriCount : assets.can12TriCount)\n : assets.baseTriCount;\n return {\n id: spec.id,\n kind: spec.kind,\n lodMode: spec.canLodMode,\n activeLod,\n triCount,\n labelId: spec.labelId,\n customLabelLoaded: assets.customLabelLoaded,\n materialTransparent: spec.kind === \"glass-bottle\",\n opacity: spec.kind === \"glass-bottle\" ? 0.42 : 1,\n hp,\n maxHp: spec.maxHp,\n alive,\n decalCount: alive ? decalCount : 0,\n activeShardCount: alive ? 0 : shardCount,\n position: t ? [t.x, t.y, t.z] : [...fallbackPos],\n linearVelocity: lv ? [lv.x, lv.y, lv.z] : [0, 0, 0],\n };\n}\n\nexport function attachDecalMeshRef(map: Map<string, RefObject<THREE.Mesh>>, decalId: string, mesh?: THREE.Mesh): void {\n if (mesh)\n map.set(decalId, { current: mesh });\n}\n\nexport function appendDecalBounded(\n prev: ReadonlyArray<DecalRecord>,\n nextDecal: DecalRecord,\n meshRefs: Map<string, RefObject<THREE.Mesh>>,\n nextMesh?: THREE.Mesh,\n maxDecals = 16,\n): DecalRecord[] {\n const combined = [...prev, nextDecal];\n const drop = Math.max(0, combined.length - maxDecals);\n for (let i = 0; i < drop; i++)\n meshRefs.delete(combined[i].id);\n attachDecalMeshRef(meshRefs, nextDecal.id, nextMesh);\n return drop > 0 ? combined.slice(drop) : combined;\n}\n\nexport function tagImportedMeshes(\n root: THREE.Object3D | null,\n targetId: string,\n applyHit: (hit: BallisticHitEvent) => void,\n): void {\n root?.traverse((obj) => {\n if (isMeshNode(obj) && !obj.userData.isDecal) {\n obj.userData.targetId = targetId;\n obj.userData.destructibleTarget = true;\n obj.userData.isDestructibleTarget = true;\n obj.userData.applyHit = applyHit;\n }\n });\n}\n\nexport function readTargetWorldPos(rb: RapierRigidBody | null, group: THREE.Group | null, out: THREE.Vector3): boolean {\n if (rb) {\n try {\n const t = rb.translation();\n out.set(t.x, t.y, t.z);\n return true;\n }\n catch {\n // body not yet registered or removed\n }\n }\n if (group) {\n group.getWorldPosition(out);\n return true;\n }\n return false;\n}\n"],"mappings":";;;;AA4BA,IAAM,SAAS,IAAI,MAAM,QAAQ;;;;AAKjC,SAAgB,iBACZ,MACA,QACA,IACA,OACA,aACA,WACA,aACA,KACkB;CAClB,IAAI;CACJ,IAAI,IAAI;EACJ,MAAM,SAAS,KAAK,IAAI,MAAO,GAAG,KAAK,CAAC,IAAI;EAC5C,MAAM,SAAS,KAAK,MAAM,IAAI,QAAQ,IAAI,IAAI,QAAQ,IAAI,IAAI,QAAQ,EAAE;EACxE,MAAM,QAAQ,SAAS,UAAU,SAAS,OAAO,SAAS,SAAS;EACnE,GAAG,oBACC;GAAE,GAAG,IAAI,QAAQ,KAAK;GAAO,GAAG,IAAI,QAAQ,KAAK;GAAO,GAAG,IAAI,QAAQ,KAAK;EAAM,GAClF;GAAE,GAAG,IAAI,MAAM;GAAI,GAAG,IAAI,MAAM;GAAI,GAAG,IAAI,MAAM;EAAG,GACpD,IACJ;EACA,MAAM,IAAI,GAAG,YAAY;EACzB,UAAU;GAAC,EAAE;GAAG,EAAE;GAAG,EAAE;EAAC;CAC5B;CAEA,MAAM,SAAS,KAAK,MAAM,IAAI,QAAQ,IAAI,IAAI,QAAQ,IAAI,IAAI,QAAQ,EAAE;CACxE,MAAM,MAAM,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,KAAM,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S,MAAM,IAAI,IAAI;AAC7C;AAEA,SAAgB,kBACZ,MACA,UACA,UACI;CACJ,MAAM,UAAU,QAAQ;EACpB,IAAI,WAAW,GAAG,KAAK,CAAC,IAAI,SAAS,SAAS;GAC1C,IAAI,SAAS,WAAW;GACxB,IAAI,SAAS,qBAAqB;GAClC,IAAI,SAAS,uBAAuB;GACpC,IAAI,SAAS,WAAW;EAC5B;CACJ,CAAC;AACL;AAEA,SAAgB,mBAAmB,IAA4B,OAA2B,KAA6B;CACnH,IAAI,IACA,IAAI;EACA,MAAM,IAAI,GAAG,YAAY;EACzB,IAAI,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;EACrB,OAAO;CACX,QACM,CAEN;CAEJ,IAAI,OAAO;EACP,MAAM,iBAAiB,GAAG;EAC1B,OAAO;CACX;CACA,OAAO;AACX"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as THREE from "three";
|
|
2
|
-
import { type ImportedGlbAsset } from "./junkImporter.js";
|
|
3
|
-
import type { DestructibleTargetSpec } from "./junkTypes.js";
|
|
4
|
-
export interface TargetAssetBundle {
|
|
5
|
-
can3Geo: THREE.BufferGeometry | null;
|
|
6
|
-
can12Geo: THREE.BufferGeometry | null;
|
|
7
|
-
can3TriCount: number;
|
|
8
|
-
can12TriCount: number;
|
|
9
|
-
baseTriCount: number;
|
|
10
|
-
canMats: THREE.MeshStandardMaterial[] | null;
|
|
11
|
-
bottleGeo: THREE.LatheGeometry | null;
|
|
12
|
-
bottleMat: THREE.MeshStandardMaterial | null;
|
|
13
|
-
activeLabelTex: THREE.Texture | null;
|
|
14
|
-
customLabelLoaded: boolean;
|
|
15
|
-
importedRoot: THREE.Group | null;
|
|
16
|
-
importedHalfExtents: [number, number, number] | null;
|
|
17
|
-
importedKey: string;
|
|
18
|
-
}
|
|
19
|
-
export declare function useTargetAssets(spec: DestructibleTargetSpec, importedAsset?: ImportedGlbAsset | null): TargetAssetBundle;
|