@pinkaphant/kolmo 0.4.5 → 0.4.7
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/AGENTS.md +29 -0
- package/CLAUDE.md +8 -0
- package/README.md +11 -13
- package/bin/kolmo.mjs +7 -6
- package/dist/engine/index.d.ts +5 -1
- package/dist/engine/index.js +11 -6
- package/dist/engine/kolmoActor.d.ts +9 -1
- package/dist/engine/kolmoActor.js +12 -2
- package/dist/engine/kolmoActor.js.map +1 -1
- package/dist/engine/kolmoBotControl.d.ts +44 -0
- package/dist/engine/kolmoBotControl.js +194 -0
- package/dist/engine/kolmoBotControl.js.map +1 -0
- package/dist/engine/kolmoBotJournal.d.ts +23 -0
- package/dist/engine/kolmoBotJournal.js +138 -0
- package/dist/engine/kolmoBotJournal.js.map +1 -0
- package/dist/engine/kolmoFloatingOrigin.js +1 -8
- package/dist/engine/kolmoFloatingOrigin.js.map +1 -1
- package/dist/engine/kolmoGltfLoader.d.ts +16 -0
- package/dist/engine/kolmoGltfLoader.js +46 -0
- package/dist/engine/kolmoGltfLoader.js.map +1 -0
- package/dist/engine/kolmoHud.js +85 -80
- package/dist/engine/kolmoHud.js.map +1 -1
- package/dist/engine/kolmoInput.js +9 -7
- package/dist/engine/kolmoInput.js.map +1 -1
- package/dist/engine/kolmoLongDrive.js +32 -14
- package/dist/engine/kolmoLongDrive.js.map +1 -1
- package/dist/engine/kolmoPilotMesh.d.ts +4 -0
- package/dist/engine/kolmoPilotMesh.js +174 -2
- package/dist/engine/kolmoPilotMesh.js.map +1 -1
- package/dist/engine/kolmoVehicleAutoCompile.d.ts +1 -0
- package/dist/engine/kolmoVehicleAutoCompile.js +21 -5
- package/dist/engine/kolmoVehicleAutoCompile.js.map +1 -1
- package/dist/engine/kolmoVehicleDriver.d.ts +1 -0
- package/dist/engine/kolmoVehicleDriver.js +20 -12
- package/dist/engine/kolmoVehicleDriver.js.map +1 -1
- package/dist/engine/kolmoVehicleInner.js +25 -9
- package/dist/engine/kolmoVehicleInner.js.map +1 -1
- package/dist/engine/kolmoWardrobeRig.d.ts +22 -0
- package/dist/engine/kolmoWardrobeRig.js +146 -0
- package/dist/engine/kolmoWardrobeRig.js.map +1 -0
- package/dist/engine/kolmoWorld.d.ts +2 -2
- package/dist/engine/kolmoWorld.js +4 -1
- package/dist/engine/kolmoWorld.js.map +1 -1
- package/dist/importer/DomainWorkshopPanel.d.ts +3 -1
- package/dist/importer/DomainWorkshopPanel.js +15 -48
- package/dist/importer/DomainWorkshopPanel.js.map +1 -1
- package/dist/importer/GateHudBar.js.map +1 -1
- package/dist/importer/GlbImportGate.js +219 -210
- package/dist/importer/GlbImportGate.js.map +1 -1
- package/dist/importer/ImperativeVehicleRig.js +7 -6
- package/dist/importer/ImperativeVehicleRig.js.map +1 -1
- package/dist/importer/LiveDrivePads.js +41 -17
- package/dist/importer/LiveDrivePads.js.map +1 -1
- package/dist/importer/WardrobeWorkshopPanel.d.ts +15 -0
- package/dist/importer/WardrobeWorkshopPanel.js +529 -0
- package/dist/importer/WardrobeWorkshopPanel.js.map +1 -0
- package/dist/importer/importerWebMcp.d.ts +2 -0
- package/dist/importer/importerWebMcp.js +5 -3
- package/dist/importer/importerWebMcp.js.map +1 -1
- package/dist/importer/importerWebMcpTools.js +36 -9
- package/dist/importer/importerWebMcpTools.js.map +1 -1
- package/dist/importer/index.d.ts +6 -0
- package/dist/importer/index.js +10 -4
- package/dist/importer/khrCarGeometryMass.js +14 -8
- package/dist/importer/khrCarGeometryMass.js.map +1 -1
- package/dist/importer/khrCarPlanner.js +50 -44
- package/dist/importer/khrCarPlanner.js.map +1 -1
- package/dist/importer/useChopShopController.d.ts +2 -0
- package/dist/importer/useChopShopController.js +18 -0
- package/dist/importer/useChopShopController.js.map +1 -1
- package/dist/importer/wardrobeAutoFit.d.ts +16 -0
- package/dist/importer/wardrobeAutoFit.js +410 -0
- package/dist/importer/wardrobeAutoFit.js.map +1 -0
- package/dist/importer/wardrobeCatalog.d.ts +16 -0
- package/dist/importer/wardrobeCatalog.js +409 -0
- package/dist/importer/wardrobeCatalog.js.map +1 -0
- package/dist/importer/wardrobeController.d.ts +49 -0
- package/dist/importer/wardrobeController.js +181 -0
- package/dist/importer/wardrobeController.js.map +1 -0
- package/dist/importer/wardrobeFitter.d.ts +27 -0
- package/dist/importer/wardrobeFitter.js +269 -0
- package/dist/importer/wardrobeFitter.js.map +1 -0
- package/dist/importer/wardrobeWebMcpTools.d.ts +2 -0
- package/dist/importer/wardrobeWebMcpTools.js +198 -0
- package/dist/importer/wardrobeWebMcpTools.js.map +1 -0
- package/dist/index.js +15 -3
- package/dist/junk/DestructibleTarget.js +2 -2
- package/dist/junk/DestructibleTarget.js.map +1 -1
- package/dist/junk/ShardPieces.js +2 -2
- package/dist/junk/ShardPieces.js.map +1 -1
- package/dist/junk/index.d.ts +1 -0
- package/dist/junk/index.js +2 -1
- package/dist/junk/junkImporter.js +2 -2
- package/dist/junk/junkImporter.js.map +1 -1
- package/dist/junk/junkSheetSplitter.d.ts +38 -0
- package/dist/junk/junkSheetSplitter.js +104 -0
- package/dist/junk/junkSheetSplitter.js.map +1 -0
- package/dist/physics/index.d.ts +4 -1
- package/dist/physics/index.js +34 -8
- package/dist/physics/index.js.map +1 -1
- package/dist/physics/nBodyGravity.d.ts +42 -0
- package/dist/physics/nBodyGravity.js +70 -0
- package/dist/physics/nBodyGravity.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/docs/api-reference.md +671 -91
- package/package.json +14 -11
- package/skills/kolmo-engine/SKILL.md +109 -0
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { ActorTrait, FloatingBodyTrait, InteractableTrait, PilotLink, PilotedTag, TransformTrait, VehicleTelemetryTrait, VehicleTrait, VelocityTrait, WorldSessionTrait, WorldSpawnTrait, ensureWorldSession, kolmoWorld, pilotedVehicleQuery, publishWorldSpawn, useActiveKolmoWorld, vehicleSimQuery, writeEntityKinematics, writeVehicleTelemetry } from "./engine/kolmoTraits.js";
|
|
2
|
+
import { computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity } from "./physics/nBodyGravity.js";
|
|
2
3
|
import { KolmoCanvas, KolmoInCanvasContext, KolmoWorld } from "./engine/kolmoWorld.js";
|
|
3
4
|
import { PALETTE_CRUNCHY_16, PALETTE_CRUNCHY_64, RETRO_COLOR_MODES, applyRetroFilteringToMaterial, applyRetroTextureFiltering, buildPaletteLutData, computeRetroDpr, getColorQuantVector, getPaletteLutTexture } from "./shaders/retroPalettes.js";
|
|
4
5
|
import { PS1_SNAP_RESOLUTION, RETRO_CLEAN_HD, RETRO_DREAMCAST, RETRO_PRESETS, RETRO_PS2_SHINOBI, RETRO_PSX_PLUS, RETRO_UNIFORMS, getRetroPreset, getRetroShaderUniforms, syncRetroUniforms, syncRetroViewport } from "./shaders/retroUniforms.js";
|
|
5
6
|
import { GLSL_BAYER_RGB555, GLSL_RETRO_QUANTIZE, applyPs1Material, applyRetroMaterial, applySceneRetroMaterials } from "./shaders/retroShader.js";
|
|
6
7
|
import { KolmoGravityContext, KolmoPhysics, useIsKolmoCustomGravity, useOptionalKootaWorld } from "./physics/index.js";
|
|
7
8
|
import { KolmoGame } from "./engine/kolmoGame.js";
|
|
9
|
+
import { KolmoBotJournalFeed, clearKolmoBotJournal, getKolmoBotJournal, recordKolmoBotAction, subscribeKolmoBotJournal, summarizeBotToolCall, wrapWebMcpToolWithJournal } from "./engine/kolmoBotJournal.js";
|
|
10
|
+
import { flipVehicleBodyUpright, kolmoActions, kolmoTelemetry } from "./engine/kolmoActions.js";
|
|
11
|
+
import { readFloatingOriginAnchorXZ, shiftFloatingOriginEntities } from "./engine/kolmoFloatingOrigin.js";
|
|
12
|
+
import { clearKolmoBotDriveInput, createKolmoDriveWebMcpTools, kolmoBotInput, readActiveKolmoBotInput, registerKolmoExternalTelemetry, setKolmoBotDriveInput, snapshotKolmoLiveTelemetry, useKolmoDriveWebMcp } from "./engine/kolmoBotControl.js";
|
|
8
13
|
import { KOLMO_STICK_DEADZONE, applyKolmoTouchLook, computeVirtualStick, defaultTouchActionsForMode, detectTouchDevice, kolmoTouchInput, resetKolmoTouchInput, resetKolmoTouchStick, snapshotKolmoTouchInput, writeKolmoTouchAction } from "./engine/kolmoTouchState.js";
|
|
9
14
|
import { EMPTY_KOLMO_INPUT, KOLMO_KEY_MAP, useKolmoInput } from "./engine/kolmoInput.js";
|
|
10
15
|
import { RetroViewportSync, RoomEnvRig, ShadowSnapRig } from "./engine/kolmoRigs.js";
|
|
11
|
-
import { flipVehicleBodyUpright, kolmoActions, kolmoTelemetry } from "./engine/kolmoActions.js";
|
|
12
|
-
import { readFloatingOriginAnchorXZ, shiftFloatingOriginEntities } from "./engine/kolmoFloatingOrigin.js";
|
|
13
16
|
import { KolmoHud, KolmoOverlayContext, useKolmoGame } from "./engine/kolmoHud.js";
|
|
14
17
|
import { KOLMO_EXTENSION_NAME, createDefaultSignals, inferKolmoSocketRole } from "./schema/kolmoTypes.js";
|
|
15
18
|
import { disambiguateExplicitPatches, disambiguatePatchName, stampKolmoNodesIntoGlb } from "./schema/kolmoStamp.js";
|
|
@@ -33,6 +36,11 @@ import { loadOrAutoCompileVehicleGlb } from "./engine/kolmoVehicleAutoCompile.js
|
|
|
33
36
|
import { PARTICLE_FRAG, PARTICLE_VERT, PLUME_FRAG, PLUME_VERT } from "./shaders/emitterShaders.js";
|
|
34
37
|
import { KolmoActor } from "./engine/kolmoActor.js";
|
|
35
38
|
import { KolmoProp, KolmoSurface, togglePropJoint } from "./engine/kolmoSurface.js";
|
|
39
|
+
import { TRIPO_CHARACTER_BASES, TRIPO_WARDROBE_BASE_PATH, TRIPO_WARDROBE_GARMENTS, inferWardrobeSlotFromName, tripoWardrobeUrl } from "./importer/wardrobeCatalog.js";
|
|
40
|
+
import { applyWardrobePiecePatch, listWardrobePieces, resetWardrobePiece } from "./importer/wardrobeFitter.js";
|
|
41
|
+
import { autoFitWardrobeShoes, bindWardrobeToHumanoidSkeleton, layerGarmentOntoCharacterScene, tuckInnerBodyUnderClothing } from "./importer/wardrobeAutoFit.js";
|
|
42
|
+
import { detectCharacterDefaultTurns, executeWardrobeFitOnHost, layerWardrobeGarmentIntoHost, loadGlbSceneFromUrl, loadWardrobeBaseIntoHost, removeWardrobePieceFromHost, resolveWardrobeCatalogUrl } from "./importer/wardrobeController.js";
|
|
43
|
+
import { KolmoWardrobeRig, applyActorWardrobeMutations } from "./engine/kolmoWardrobeRig.js";
|
|
36
44
|
import { KolmoIsland } from "./engine/kolmoIsland.js";
|
|
37
45
|
import { C12TileKind, C12_TILE_M, FLOATING_ORIGIN_STEP_M, MACRO_SIZE_M, TILES_PER_MACRO, quantizeFloatingOrigin192 } from "./world/macroCellSchema.js";
|
|
38
46
|
import { ShiftedFixedBody } from "./engine/shiftedFixedBody.js";
|
|
@@ -57,6 +65,7 @@ import { collectValidTris } from "./junk/bvhTriCollector.js";
|
|
|
57
65
|
import { splitObjectIntoShards } from "./junk/bvhShatter.js";
|
|
58
66
|
import { ShardPieces } from "./junk/ShardPieces.js";
|
|
59
67
|
import { TargetDecals, getBulletHoleTexture } from "./junk/TargetDecals.js";
|
|
68
|
+
import { createKolmoGltfLoader, loadKolmoGlbUrl, parseKolmoGlbBuffer } from "./engine/kolmoGltfLoader.js";
|
|
60
69
|
import { applySegmentsToImportedRoot, loadImportedGlbUrl, parseImportedGlbBuffer } from "./junk/junkImporter.js";
|
|
61
70
|
import { getProceduralLabelTexture, loadCustomLabelTexture } from "./junk/junkLabels.js";
|
|
62
71
|
import { DestructibleTarget } from "./junk/DestructibleTarget.js";
|
|
@@ -76,6 +85,7 @@ import { GOLDEN_RATIO, ORB_TIERS, getSuikaTier, matchSuikaTierByRadius } from ".
|
|
|
76
85
|
import { buildSuikaOrbGeometry, buildSuikaTierScene, extractSceneHullVertices, getConvexHullVertices, loadImportedSuikaGlbUrl, parseImportedSuikaGlbBuffer } from "./suika/suikaGeometry.js";
|
|
77
86
|
import { SuikaMergeArbiter, computeSuikaMergeMidpoint, defaultSuikaArbiter, spawnSuikaOrb, useSuikaStore } from "./suika/suikaArbiter.js";
|
|
78
87
|
import { KolmoSuikaOrb, KolmoSuikaSystem, OrbShapeGeometry, SuikaBurstMesh } from "./suika/KolmoSuikaOrb.js";
|
|
88
|
+
import { WardrobeWorkshopSection } from "./importer/WardrobeWorkshopPanel.js";
|
|
79
89
|
import { DAMP_ZETA, FREQ_HZ, gateTelemetry, isGateStep1Unlocked, useGateStore } from "./importer/gateStore.js";
|
|
80
90
|
import { bakeArticulatedLauncherGlb, buildLauncherSceneFromPlan } from "./importer/launcherBake.js";
|
|
81
91
|
import { JUNK_PROCEDURAL_RECIPES, buildProceduralJunkScene } from "./junk/junkProceduralScenes.js";
|
|
@@ -91,14 +101,16 @@ import { C12_TICK_M, UNIFIED_ANCHOR_NAMES, computeC12Metrics, defaultTargetMeter
|
|
|
91
101
|
import { ImperativeVehicleRig } from "./importer/ImperativeVehicleRig.js";
|
|
92
102
|
import { Step2UniversalPad } from "./importer/Step2UniversalPad.js";
|
|
93
103
|
import { VfxEmitterPool } from "./importer/VfxEmitterPool.js";
|
|
104
|
+
import { createWardrobeWebMcpTools } from "./importer/wardrobeWebMcpTools.js";
|
|
94
105
|
import { buildImporterWebMcpTools, getNavigatorModelContext, useImporterWebMcp } from "./importer/importerWebMcp.js";
|
|
95
106
|
import { bakeUniversalGateGlb } from "./importer/universalGateBake.js";
|
|
96
107
|
import { useChopShopController } from "./importer/useChopShopController.js";
|
|
97
108
|
import { GlbImportGate } from "./importer/GlbImportGate.js";
|
|
109
|
+
import { SUBSTRATE_DENSITY_KG_M3, splitSheetSceneIntoJunkIslands } from "./junk/junkSheetSplitter.js";
|
|
98
110
|
import { KolmoSand3D } from "./sand3d/KolmoSand3D.js";
|
|
99
111
|
import { PAPER_SHELL_PRESETS } from "@khr3/vehicles/paper-shell";
|
|
100
112
|
import { DOOR_HINGE_SPEC, Ex, ROOT3, buildFootprint, canPlace, instanceBatches, latticePose, planSettlement, poseEq, poseFromJSON, poseToFloat, poseToJSON, snapPose, socketFor, triangleCorners, vToFloat, worldSockets } from "@khr3/c12";
|
|
101
113
|
import { DEFAULT_VAULT_URL, KOLMO_ASSETS_URL, VAULT_CARS, VAULT_CATALOG, VAULT_CITY, VAULT_WEAPONS, createAssetVault, inspectGlbBuffer, normalizeGlbBuffer, vaultAssetUrl } from "@khr3/assets";
|
|
102
114
|
import { CARBINE_556, LAUNCHER_RECIPES, PISTOL_9MM, SHOTGUN_12G, attachModule, createLauncherState, detachModule, findLauncherRecipe, planLauncher, stepLauncher } from "@khr3/launchers";
|
|
103
115
|
import { CARS_R2_PREFIX, COUPE_2DOOR, FLEET, SEDAN_4DOOR, carUrl, findCar, planCar } from "@khr3/vehicles";
|
|
104
|
-
export { ATMO_FRAG, ATMO_VERT, KolmoActor as Actor, ActorTrait, BOTTLE_HEIGHT, C12TileKind, C12_PROCEDURAL_RECIPES, C12_TICK_M, C12_TILE_M, CAN_LOD_THRESHOLD_M, CARBINE_556, CARS_R2_PREFIX, CHOP_ROLES, COUPE_2DOOR, CRAFT_PROCEDURAL_RECIPES, KolmoCanvas as Canvas, ChopShopPanel, DAMP_ZETA, DEFAULT_VAULT_URL, DOOR_HINGE_SPEC, DestructibleTarget, DomainWorkshopPanel, EMPTY_KOLMO_INPUT, KolmoEmitterRig as EmitterRig, Ex, KolmoExoplanet as Exoplanet, FLEET, FLOATING_ORIGIN_STEP_M, FREQ_HZ, FloatingBodyTrait, GLSL_BAYER_RGB555, GLSL_RETRO_QUANTIZE, GOLDEN_RATIO, KolmoGame as Game, GateHudBar, GlbImportGate, KolmoHud as Hud, ImperativeVehicleRig, GlbImportGate as ImporterWorkbench, InfiniteLongDrivePlanner, InteractableTrait, KolmoIsland as Island, JUNK_PROCEDURAL_RECIPES, KolmoJunk as Junk, KEY_SUN_DIRECTION, KOLMO_ASSETS_URL, KOLMO_EXTENSION_NAME, KOLMO_KEY_MAP, KOLMO_STICK_DEADZONE, KolmoActor, KolmoCanvas, KolmoEmitterRig, KolmoExoplanet, KolmoGame, KolmoGravityContext, KolmoHud, KolmoInCanvasContext, KolmoIsland, KolmoJunk, KolmoLongDrive, KolmoOverlayContext, KolmoPhysics, KolmoProp, KolmoSand3D, KolmoSkybox, KolmoSuikaOrb, KolmoSuikaSystem, KolmoSurface, KolmoVehicle, KolmoWorld, LAUNCHER_RECIPES, KolmoLongDrive as LongDrive, MACRO_SIZE_M, MobileTouchOverlay, ORB_TIERS, OrbShapeGeometry, PALETTE_CRUNCHY_16, PALETTE_CRUNCHY_64, PAPER_SHELL_PRESETS, PARTICLE_FRAG, PARTICLE_VERT, PERSON_PROCEDURAL_RECIPES, PISTOL_9MM, PLUME_FRAG, PLUME_VERT, PROP_PROCEDURAL_RECIPES, PS1_SNAP_RESOLUTION, KolmoPhysics as Physics, PilotLink, PilotedTag, KolmoProp as Prop, RETRO_CLEAN_HD, RETRO_COLOR_MODES, RETRO_DREAMCAST, RETRO_PRESETS, RETRO_PS2_SHINOBI, RETRO_PSX_PLUS, RETRO_UNIFORMS, RING_MOONLET_COUNT, ROOT3, RetroViewportSync, RoomEnvRig, SAND3D_RECIPES, SAND3D_RECIPE_MAP, SEDAN_4DOOR, SEED8_ALPHABET, SHOTGUN_12G, SHOULDER_K, SPLAT_LAYER, KolmoSand3D as Sand3D, Sand3dWorkshopSection, SeededSimplex2D, ShadowSnapRig, ShardPieces, ShiftedFixedBody, KolmoSkybox as Skybox, SplitMix32, Step1CalibrationPlinth, Step2UniversalPad, SuikaBurstMesh, SuikaMergeArbiter, KolmoSuikaOrb as SuikaOrb, KolmoSuikaSystem as SuikaSystem, KolmoSurface as Surface, TILES_PER_MACRO, TIN_CAN_HEIGHT, TIN_CAN_RADIUS, TargetDecals, TransformTrait, UNIFIED_ANCHOR_NAMES, VAULT_CARS, VAULT_CATALOG, VAULT_CITY, VAULT_WEAPONS, KolmoVehicle as Vehicle, VehicleTelemetryTrait, VehicleTrait, VelocityTrait, VfxEmitterPool, WheelRingHandles3D, KolmoWorld as World, WorldSessionTrait, WorldSpawnTrait, applyKolmoTouchLook, applyPs1Material, applyRetroFilteringToMaterial, applyRetroMaterial, applyRetroTextureFiltering, applySceneRetroMaterials, applySegmentsToImportedRoot, attachModule, bakeArticulatedLauncherGlb, bakeUniversalGateGlb, bakeWorldSplatMaps, buildCarvedTerrainGeometry, buildDodecagonalCivicHub, buildFootprint, buildGlassBottleGeometry, buildHighwayAsphaltTexture, buildImporterWebMcpTools, buildLauncherSceneFromPlan, buildPaletteLutData, buildPatchPreviewEmitters, buildProceduralC12Scene, buildProceduralCarGlb, buildProceduralCraftScene, buildProceduralDomainScene, buildProceduralJunkScene, buildProceduralPersonScene, buildProceduralPropScene, buildRoadRibbonGeometry, buildSand3dRecipe, buildSelectionOverlayGeometry, buildSuikaOrbGeometry, buildSuikaTierScene, buildSurfaceTopology, buildTinCanGeometry, canPlace, carUrl, childSeed, closedRoadFromPoints, collectValidTris, compileKhrAssetGlb, compileSand3dAssembly, compileSand3dRecipeGlb, computeC12Metrics, computeChopPartHinge, computeIslandSpawnPose, computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn, computeRetroDpr, computeSuikaMergeMidpoint, computeVirtualStick, convertUsdToGlb, countGeometryTriangles, createAssetVault, createDefaultSignals, createFleet12GonWheelGroup, createGlassBottleMaterial, createLauncherState, createPS2RoadMaterialWebGL, createPS2TerrainMaterialWebGL, createPS2WorldTextures, createTinCanMaterials, decodeKolmoRig, defaultSuikaArbiter, defaultTargetMeters, defaultTouchActionsForMode, detachModule, detectFusedCarWheels, detectSand3dBytes, detectSceneAnchors, detectTouchDevice, disambiguateExplicitPatches, disambiguatePatchName, disposeImportedRoot, enforceMirrorCutterSymmetry, enforceRetroPersonMaterials, ensureMeshAttributes, ensureWorldSession, exportCompiledSand3dWithKolmo, exportSand3dGlb, extractMeshIslands, extractSceneHullVertices, fbm2, findCar, findLauncherRecipe, findMirrorIslandId, findSand3dRecipe, flipVehicleBodyUpright, floodFillByCrease, frontage, gateTelemetry, generatePS2DetailSlices, generateSeed8, getBulletHoleTexture, getCachedIslandPlan, getColorQuantVector, getConvexHullVertices, getIslandTopology, getNavigatorModelContext, getPaletteLutTexture, getProceduralLabelTexture, getRetroPreset, getRetroShaderUniforms, getSuikaTier, growRoad, hashSeed, inferKolmoSocketRole, inferMirrorOriginX, ingestSand3dOrGlb, inspectGlbBuffer, instanceBatches, isGateStep1Unlocked, isSand3dFileName, isSupportedCadImportFileName, isUsdFileName, isValidSeed8, khrBoxToRapierHalfExtents, kolmoActions, kolmoTelemetry, kolmoTouchInput, kolmoWorld, latticePose, loadCustomLabelTexture, loadImportedGlbUrl, loadImportedSuikaGlbUrl, loadOrAutoCompileVehicleGlb, loadSand3dBundle, makeIslandHeightfn, makeStarterDomainScene, makeTerrain, matchSuikaTierByRadius, maxGrade, measureAssemblyCalibration, measureNaturalSceneSpanM, measureNormalizedSceneCalibration, measureSelection, mirrorCutterId, mirrorTriangles, mountPS2WorldMeshes, mulberry32, normalToMinusZQuaternion, normalizeGlbBuffer, normalizeSceneToSi, normalizeSeed8, parseImportedGlbBuffer, parseImportedSuikaGlbBuffer, parseSand3dSource, peelIslandSelection, pilotedVehicleQuery, planCar, planDirtSpurs, planIslandWorld, planLauncher, planSettlement, populateMoonletMatrices, poseEq, poseFromJSON, poseToFloat, poseToJSON, previewLoopPolyline, publishWorldSpawn, quantizeFloatingOrigin192, readFloatingOriginAnchorXZ, refineMeshAlongLoop, registerSand3dStarterFactory, remapIslandIds, resetKolmoTouchInput, resetKolmoTouchStick, resolveSand3dAssembly, resolveVaultCarSelection, roadFromPoints, routeMacroKnightAStar, s3d, sampleHeightfield, seedFrom, selectCanLod, selectFacesByClick, selectFacesByLoop, separateVehicleMeshes, shiftFloatingOriginEntities, sliceCarWheelCylinders, sliceMeshTriangles, snapCuttersAxles, snapMetersToC12, snapPose, snapshotKolmoTouchInput, socketFor, spawnSuikaOrb, splitObjectIntoShards, stampKolmoNodesIntoGlb, stepLauncher, suggestCarAxles, syncRetroUniforms, syncRetroViewport, toggleIslandSelection, togglePropJoint, triangleCorners, updateWheelCutter, useActiveKolmoWorld, useChopShopController, useGateStore, useImporterWebMcp, useIsKolmoCustomGravity, useKolmoGame, useKolmoInput, useOptionalKootaWorld, useSuikaStore, vToFloat, valueNoise2, vaultAssetUrl, vehicleSimQuery, worldSockets, wrapSingleMeshWithPaperShellProxy, writeEntityKinematics, writeKolmoTouchAction, writeVehicleTelemetry };
|
|
116
|
+
export { ATMO_FRAG, ATMO_VERT, KolmoActor as Actor, ActorTrait, BOTTLE_HEIGHT, C12TileKind, C12_PROCEDURAL_RECIPES, C12_TICK_M, C12_TILE_M, CAN_LOD_THRESHOLD_M, CARBINE_556, CARS_R2_PREFIX, CHOP_ROLES, COUPE_2DOOR, CRAFT_PROCEDURAL_RECIPES, KolmoCanvas as Canvas, ChopShopPanel, DAMP_ZETA, DEFAULT_VAULT_URL, DOOR_HINGE_SPEC, DestructibleTarget, DomainWorkshopPanel, EMPTY_KOLMO_INPUT, KolmoEmitterRig as EmitterRig, Ex, KolmoExoplanet as Exoplanet, FLEET, FLOATING_ORIGIN_STEP_M, FREQ_HZ, FloatingBodyTrait, GLSL_BAYER_RGB555, GLSL_RETRO_QUANTIZE, GOLDEN_RATIO, KolmoGame as Game, GateHudBar, GlbImportGate, KolmoHud as Hud, ImperativeVehicleRig, GlbImportGate as ImporterWorkbench, InfiniteLongDrivePlanner, InteractableTrait, KolmoIsland as Island, JUNK_PROCEDURAL_RECIPES, KolmoJunk as Junk, KEY_SUN_DIRECTION, KOLMO_ASSETS_URL, KOLMO_EXTENSION_NAME, KOLMO_KEY_MAP, KOLMO_STICK_DEADZONE, KolmoActor, KolmoBotJournalFeed, KolmoCanvas, KolmoEmitterRig, KolmoExoplanet, KolmoGame, KolmoGravityContext, KolmoHud, KolmoInCanvasContext, KolmoIsland, KolmoJunk, KolmoLongDrive, KolmoOverlayContext, KolmoPhysics, KolmoProp, KolmoSand3D, KolmoSkybox, KolmoSuikaOrb, KolmoSuikaSystem, KolmoSurface, KolmoVehicle, KolmoWardrobeRig, KolmoWorld, LAUNCHER_RECIPES, KolmoLongDrive as LongDrive, MACRO_SIZE_M, MobileTouchOverlay, ORB_TIERS, OrbShapeGeometry, PALETTE_CRUNCHY_16, PALETTE_CRUNCHY_64, PAPER_SHELL_PRESETS, PARTICLE_FRAG, PARTICLE_VERT, PERSON_PROCEDURAL_RECIPES, PISTOL_9MM, PLUME_FRAG, PLUME_VERT, PROP_PROCEDURAL_RECIPES, PS1_SNAP_RESOLUTION, KolmoPhysics as Physics, PilotLink, PilotedTag, KolmoProp as Prop, RETRO_CLEAN_HD, RETRO_COLOR_MODES, RETRO_DREAMCAST, RETRO_PRESETS, RETRO_PS2_SHINOBI, RETRO_PSX_PLUS, RETRO_UNIFORMS, RING_MOONLET_COUNT, ROOT3, RetroViewportSync, RoomEnvRig, SAND3D_RECIPES, SAND3D_RECIPE_MAP, SEDAN_4DOOR, SEED8_ALPHABET, SHOTGUN_12G, SHOULDER_K, SPLAT_LAYER, SUBSTRATE_DENSITY_KG_M3, KolmoSand3D as Sand3D, Sand3dWorkshopSection, SeededSimplex2D, ShadowSnapRig, ShardPieces, ShiftedFixedBody, KolmoSkybox as Skybox, SplitMix32, Step1CalibrationPlinth, Step2UniversalPad, SuikaBurstMesh, SuikaMergeArbiter, KolmoSuikaOrb as SuikaOrb, KolmoSuikaSystem as SuikaSystem, KolmoSurface as Surface, TILES_PER_MACRO, TIN_CAN_HEIGHT, TIN_CAN_RADIUS, TRIPO_CHARACTER_BASES, TRIPO_WARDROBE_BASE_PATH, TRIPO_WARDROBE_GARMENTS, TargetDecals, TransformTrait, UNIFIED_ANCHOR_NAMES, VAULT_CARS, VAULT_CATALOG, VAULT_CITY, VAULT_WEAPONS, KolmoVehicle as Vehicle, VehicleTelemetryTrait, VehicleTrait, VelocityTrait, VfxEmitterPool, WardrobeWorkshopSection, WheelRingHandles3D, KolmoWorld as World, WorldSessionTrait, WorldSpawnTrait, applyActorWardrobeMutations, applyKolmoTouchLook, applyPs1Material, applyRetroFilteringToMaterial, applyRetroMaterial, applyRetroTextureFiltering, applySceneRetroMaterials, applySegmentsToImportedRoot, applyWardrobePiecePatch, attachModule, autoFitWardrobeShoes, bakeArticulatedLauncherGlb, bakeUniversalGateGlb, bakeWorldSplatMaps, bindWardrobeToHumanoidSkeleton, buildCarvedTerrainGeometry, buildDodecagonalCivicHub, buildFootprint, buildGlassBottleGeometry, buildHighwayAsphaltTexture, buildImporterWebMcpTools, buildLauncherSceneFromPlan, buildPaletteLutData, buildPatchPreviewEmitters, buildProceduralC12Scene, buildProceduralCarGlb, buildProceduralCraftScene, buildProceduralDomainScene, buildProceduralJunkScene, buildProceduralPersonScene, buildProceduralPropScene, buildRoadRibbonGeometry, buildSand3dRecipe, buildSelectionOverlayGeometry, buildSuikaOrbGeometry, buildSuikaTierScene, buildSurfaceTopology, buildTinCanGeometry, canPlace, carUrl, childSeed, clearKolmoBotDriveInput, clearKolmoBotJournal, closedRoadFromPoints, collectValidTris, compileKhrAssetGlb, compileSand3dAssembly, compileSand3dRecipeGlb, computeC12Metrics, computeChopPartHinge, computeCircularOrbitSpeed, computeIslandSpawnPose, computeLongDriveBridgeheadSpawn, computeLongDriveMainlandSpawn, computeRetroDpr, computeSuikaMergeMidpoint, computeVirtualStick, convertUsdToGlb, countGeometryTriangles, createAssetVault, createDefaultSignals, createFleet12GonWheelGroup, createGlassBottleMaterial, createKolmoDriveWebMcpTools, createKolmoGltfLoader, createLauncherState, createNBodyGravityField, createPS2RoadMaterialWebGL, createPS2TerrainMaterialWebGL, createPS2WorldTextures, createTinCanMaterials, createWardrobeWebMcpTools, decodeKolmoRig, defaultSuikaArbiter, defaultTargetMeters, defaultTouchActionsForMode, detachModule, detectCharacterDefaultTurns, detectFusedCarWheels, detectSand3dBytes, detectSceneAnchors, detectTouchDevice, disambiguateExplicitPatches, disambiguatePatchName, disposeImportedRoot, enforceMirrorCutterSymmetry, enforceRetroPersonMaterials, ensureMeshAttributes, ensureWorldSession, evaluateNBodyGravity, executeWardrobeFitOnHost, exportCompiledSand3dWithKolmo, exportSand3dGlb, extractMeshIslands, extractSceneHullVertices, fbm2, findCar, findLauncherRecipe, findMirrorIslandId, findSand3dRecipe, flipVehicleBodyUpright, floodFillByCrease, frontage, gateTelemetry, generatePS2DetailSlices, generateSeed8, getBulletHoleTexture, getCachedIslandPlan, getColorQuantVector, getConvexHullVertices, getIslandTopology, getKolmoBotJournal, getNavigatorModelContext, getPaletteLutTexture, getProceduralLabelTexture, getRetroPreset, getRetroShaderUniforms, getSuikaTier, growRoad, hashSeed, inferKolmoSocketRole, inferMirrorOriginX, inferWardrobeSlotFromName, ingestSand3dOrGlb, inspectGlbBuffer, instanceBatches, isGateStep1Unlocked, isSand3dFileName, isSupportedCadImportFileName, isUsdFileName, isValidSeed8, khrBoxToRapierHalfExtents, kolmoActions, kolmoBotInput, kolmoTelemetry, kolmoTouchInput, kolmoWorld, latticePose, layerGarmentOntoCharacterScene, layerWardrobeGarmentIntoHost, listWardrobePieces, loadCustomLabelTexture, loadGlbSceneFromUrl, loadImportedGlbUrl, loadImportedSuikaGlbUrl, loadKolmoGlbUrl, loadOrAutoCompileVehicleGlb, loadSand3dBundle, loadWardrobeBaseIntoHost, makeIslandHeightfn, makeStarterDomainScene, makeTerrain, matchSuikaTierByRadius, maxGrade, measureAssemblyCalibration, measureNaturalSceneSpanM, measureNormalizedSceneCalibration, measureSelection, mirrorCutterId, mirrorTriangles, mountPS2WorldMeshes, mulberry32, normalToMinusZQuaternion, normalizeGlbBuffer, normalizeSceneToSi, normalizeSeed8, parseImportedGlbBuffer, parseImportedSuikaGlbBuffer, parseKolmoGlbBuffer, parseSand3dSource, peelIslandSelection, pilotedVehicleQuery, planCar, planDirtSpurs, planIslandWorld, planLauncher, planSettlement, populateMoonletMatrices, poseEq, poseFromJSON, poseToFloat, poseToJSON, previewLoopPolyline, publishWorldSpawn, quantizeFloatingOrigin192, readActiveKolmoBotInput, readFloatingOriginAnchorXZ, recordKolmoBotAction, refineMeshAlongLoop, registerKolmoExternalTelemetry, registerSand3dStarterFactory, remapIslandIds, removeWardrobePieceFromHost, resetKolmoTouchInput, resetKolmoTouchStick, resetWardrobePiece, resolveSand3dAssembly, resolveVaultCarSelection, resolveWardrobeCatalogUrl, roadFromPoints, routeMacroKnightAStar, s3d, sampleHeightfield, seedFrom, selectCanLod, selectFacesByClick, selectFacesByLoop, separateVehicleMeshes, setKolmoBotDriveInput, shiftFloatingOriginEntities, sliceCarWheelCylinders, sliceMeshTriangles, snapCuttersAxles, snapMetersToC12, snapPose, snapshotKolmoLiveTelemetry, snapshotKolmoTouchInput, socketFor, spawnSuikaOrb, splitObjectIntoShards, splitSheetSceneIntoJunkIslands, stampKolmoNodesIntoGlb, stepLauncher, subscribeKolmoBotJournal, suggestCarAxles, summarizeBotToolCall, syncRetroUniforms, syncRetroViewport, toggleIslandSelection, togglePropJoint, triangleCorners, tripoWardrobeUrl, tuckInnerBodyUnderClothing, updateWheelCutter, useActiveKolmoWorld, useChopShopController, useGateStore, useImporterWebMcp, useIsKolmoCustomGravity, useKolmoDriveWebMcp, useKolmoGame, useKolmoInput, useOptionalKootaWorld, useSuikaStore, vToFloat, valueNoise2, vaultAssetUrl, vehicleSimQuery, worldSockets, wrapSingleMeshWithPaperShellProxy, wrapWebMcpToolWithJournal, writeEntityKinematics, writeKolmoTouchAction, writeVehicleTelemetry };
|
|
@@ -161,8 +161,8 @@ var DestructibleTarget = forwardRef(function DestructibleTarget({ spec, active =
|
|
|
161
161
|
position: spawnPosRef.current,
|
|
162
162
|
restitution: .18,
|
|
163
163
|
friction: .45,
|
|
164
|
-
linearDamping: isCustomGravity ?
|
|
165
|
-
angularDamping: isCustomGravity ?
|
|
164
|
+
linearDamping: isCustomGravity ? 0 : 1.2,
|
|
165
|
+
angularDamping: isCustomGravity ? .05 : 8,
|
|
166
166
|
userData,
|
|
167
167
|
children: [
|
|
168
168
|
spec.kind === "tin-can" && /* @__PURE__ */ jsx(CylinderCollider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DestructibleTarget.js","names":["_Fragment"],"sources":["../../src/junk/DestructibleTarget.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from \"react\";\nimport { useFrame } from \"@react-three/fiber\";\nimport { CuboidCollider, CylinderCollider, RigidBody, useRapier, type RapierRigidBody } from \"@react-three/rapier\";\nimport * as THREE from \"three\";\nimport { useCustomGravity } from \"@pinkaphant/ecctrl/gravity\";\nimport { FloatingBodyTrait, useActiveKolmoWorld } from \"../engine/kolmoStore.js\";\nimport { useIsKolmoCustomGravity } from \"../physics/index.js\";\nimport { selectCanLod, type ResolvedCanLod } from \"./junkGeometry.js\";\nimport type { ImportedGlbAsset } from \"./junkImporter.js\";\nimport type { BallisticHitEvent, DecalRecord, DestructibleTargetSpec, ShardSpec } from \"./junkTypes.js\";\nimport { ShardPieces } from \"./ShardPieces.js\";\nimport type { DestructibleTargetSnapshot, SpawnedShardState } from \"./targetHelpers.js\";\nimport { appendDecalBounded, buildTargetSnapshot, executeTargetHit, readTargetWorldPos, tagImportedMeshes } from \"./targetHitLogic.js\";\nimport { TargetDecals } from \"./TargetDecals.js\";\nimport { useTargetAssets } from \"./useTargetAssets.js\";\n\nexport interface DestructibleTargetHandle {\n applyHit: (hit: BallisticHitEvent) => void;\n getSnapshot: () => DestructibleTargetSnapshot;\n}\n\nexport interface DestructibleTargetProps {\n spec: DestructibleTargetSpec;\n active?: boolean;\n importedAsset?: ImportedGlbAsset | null;\n onHit?: (targetId: string, event: BallisticHitEvent, nextHp: number, decals: DecalRecord[]) => void;\n onShatter?: (targetId: string, shards: ShardSpec[], event: BallisticHitEvent) => void;\n onStateChange?: (snapshot: DestructibleTargetSnapshot) => void;\n registerTarget?: (id: string, handle: DestructibleTargetHandle | null) => void;\n}\n\nconst _lodPos = new THREE.Vector3();\n\nexport const DestructibleTarget = forwardRef<DestructibleTargetHandle, DestructibleTargetProps>(function DestructibleTarget(\n { spec, active = true, importedAsset, onHit, onShatter, onStateChange, registerTarget },\n ref,\n) {\n const activeWorld = useActiveKolmoWorld();\n const { world: rapierWorld } = useRapier();\n const isCustomGravity = useIsKolmoCustomGravity();\n const applyGravityField = useCustomGravity((s) => s.applyGravityField);\n const rbRef = useRef<RapierRigidBody | null>(null);\n const spawnPosRef = useRef<[number, number, number]>([...spec.position]);\n const groupRef = useRef<THREE.Group | null>(null);\n const meshRef = useRef<THREE.Mesh | null>(null);\n const decalMeshRefs = useRef(new Map<string, React.RefObject<THREE.Mesh>>());\n const lodRef = useRef<ResolvedCanLod>(selectCanLod(10, spec.canLodMode));\n if (spec.canLodMode !== \"auto\") lodRef.current = spec.canLodMode;\n\n const [alive, setAlive] = useState(true);\n const [hpState, setHpState] = useState(spec.hp);\n const [decals, setDecals] = useState<DecalRecord[]>([]);\n const [decalLodKey, setDecalLodKey] = useState<ResolvedCanLod>(lodRef.current);\n const [shards, setShards] = useState<SpawnedShardState[]>([]);\n const [shardMaterial, setShardMaterial] = useState<THREE.Material | null>(null);\n\n const aliveRef = useRef(true);\n const hpRef = useRef(spec.hp);\n const decalCounterRef = useRef(0);\n const decalsRef = useRef<DecalRecord[]>([]);\n const shardsRef = useRef<SpawnedShardState[]>([]);\n const lastPosRef = useRef<[number, number, number]>([...spec.position]);\n\n const assets = useTargetAssets(spec, importedAsset);\n const specRef = useRef(spec);\n specRef.current = spec;\n const assetsRef = useRef(assets);\n assetsRef.current = assets;\n const cbRef = useRef({ onHit, onShatter, onStateChange, registerTarget });\n cbRef.current = { onHit, onShatter, onStateChange, registerTarget };\n\n const getSnapshot = useCallback(\n () =>\n buildTargetSnapshot(\n specRef.current,\n assetsRef.current,\n rbRef.current,\n hpRef.current,\n aliveRef.current,\n decalsRef.current.length,\n shardsRef.current.length,\n lastPosRef.current,\n lodRef.current,\n ),\n [],\n );\n\n const applyHit = useCallback((hit: BallisticHitEvent) => {\n if (!aliveRef.current)\n return;\n const s = specRef.current;\n const res = executeTargetHit(\n s, assetsRef.current, rbRef.current, groupRef.current, meshRef.current,\n hpRef.current, `${s.id}-d-${++decalCounterRef.current}`, hit,\n );\n if (res.shattered && res.shardStates && res.shardMaterial) {\n if (res.shatterPos) lastPosRef.current = res.shatterPos;\n rbRef.current = null;\n aliveRef.current = false;\n hpRef.current = 0;\n decalsRef.current = [];\n shardsRef.current = res.shardStates;\n decalMeshRefs.current.clear();\n setHpState(0);\n setDecals([]);\n setShardMaterial(res.shardMaterial);\n setShards(res.shardStates);\n setAlive(false);\n cbRef.current.onShatter?.(s.id, res.shardSpecs ?? [], hit);\n } else {\n if (res.bodyPos) lastPosRef.current = res.bodyPos;\n hpRef.current = res.nextHp;\n setHpState(res.nextHp);\n if (res.newDecal) {\n const next = appendDecalBounded(decalsRef.current, res.newDecal, decalMeshRefs.current, res.newDecalMesh);\n decalsRef.current = next;\n setDecals(next);\n cbRef.current.onHit?.(s.id, hit, res.nextHp, next);\n } else {\n cbRef.current.onHit?.(s.id, hit, res.nextHp, decalsRef.current);\n }\n }\n }, []);\n\n const handle = useMemo<DestructibleTargetHandle>(() => ({ applyHit, getSnapshot }), [applyHit, getSnapshot]);\n useImperativeHandle(ref, () => handle, [handle]);\n\n useEffect(() => {\n cbRef.current.registerTarget?.(spec.id, handle);\n return () => cbRef.current.registerTarget?.(spec.id, null);\n }, [spec.id, handle]);\n\n useEffect(() => {\n cbRef.current.onStateChange?.(getSnapshot());\n }, [getSnapshot, alive, hpState, decals.length, shards.length, spec.canLodMode, assets.baseTriCount, assets.customLabelLoaded]);\n\n useEffect(() => {\n tagImportedMeshes(assets.importedRoot, spec.id, applyHit);\n }, [assets.importedRoot, spec.id, applyHit]);\n\n useFrame(({ camera }) => {\n if (active && aliveRef.current && isCustomGravity && rbRef.current) {\n applyGravityField(rbRef.current, rapierWorld.timestep);\n }\n if (!active || !aliveRef.current || spec.kind !== \"tin-can\" || spec.canLodMode !== \"auto\")\n return;\n if (!readTargetWorldPos(rbRef.current, groupRef.current, _lodPos))\n return;\n const nextLod = selectCanLod(camera.position.distanceTo(_lodPos), \"auto\");\n if (nextLod !== lodRef.current) {\n lodRef.current = nextLod;\n const nextGeo = nextLod === \"3-gon\" ? assets.can3Geo : assets.can12Geo;\n if (meshRef.current && nextGeo) meshRef.current.geometry = nextGeo;\n if (decalsRef.current.length > 0) setDecalLodKey(nextLod);\n cbRef.current.onStateChange?.(getSnapshot());\n }\n });\n\n useEffect(() => {\n if (!alive) return;\n const ent = activeWorld.spawn(FloatingBodyTrait({ id: spec.id, getBody: () => rbRef.current }));\n return () => { ent.destroy(); };\n }, [activeWorld, spec.id, alive]);\n\n const userData = useMemo(\n () => ({\n targetId: spec.id, toolgunId: spec.id, destructibleTarget: true, isDestructibleTarget: true,\n applyHit, ecctrl: { excludeCharacterRay: true },\n }),\n [spec.id, applyHit],\n );\n\n if (!alive) return <ShardPieces shards={shards} material={shardMaterial} />;\n\n const waitImported = spec.kind === \"imported-glb\" && !assets.importedHalfExtents;\n const renderLod = spec.canLodMode === \"auto\" ? lodRef.current : spec.canLodMode;\n\n return (\n <RigidBody\n ref={rbRef} type={waitImported ? \"fixed\" : \"dynamic\"} colliders={false}\n position={spawnPosRef.current} restitution={0.18} friction={0.45}\n linearDamping={isCustomGravity ? 0.35 : 1.2} angularDamping={isCustomGravity ? 1.5 : 8} userData={userData}\n >\n {spec.kind === \"tin-can\" && <CylinderCollider args={[0.125, 0.085]} density={180} />}\n {spec.kind === \"glass-bottle\" && <CylinderCollider args={[0.16, 0.055]} density={1200} />}\n {spec.kind === \"imported-glb\" && <CuboidCollider args={assets.importedHalfExtents ?? [0.2, 0.2, 0.2]} density={800} />}\n <group ref={groupRef} userData={userData}>\n {spec.kind === \"tin-can\" && assets.canMats && (\n <mesh\n ref={meshRef}\n geometry={(renderLod === \"3-gon\" ? assets.can3Geo : assets.can12Geo) ?? undefined}\n material={assets.canMats} castShadow receiveShadow userData={userData}\n >\n <TargetDecals decals={decals} lodKey={spec.canLodMode === \"auto\" ? decalLodKey : spec.canLodMode} />\n </mesh>\n )}\n {spec.kind === \"glass-bottle\" && assets.bottleGeo && assets.bottleMat && (\n <mesh ref={meshRef} geometry={assets.bottleGeo} material={assets.bottleMat} castShadow userData={userData}>\n <TargetDecals decals={decals} lodKey=\"bottle\" />\n </mesh>\n )}\n {spec.kind === \"imported-glb\" && assets.importedRoot && (\n <>\n <primitive object={assets.importedRoot} />\n <TargetDecals decals={decals} lodKey={assets.importedKey} meshRefMap={decalMeshRefs.current} />\n </>\n )}\n </group>\n </RigidBody>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;AA+BA,IAAM,UAAU,IAAI,MAAM,QAAQ;AAElC,IAAa,qBAAqB,WAA8D,SAAS,mBACrG,EAAE,MAAM,SAAS,MAAM,eAAe,OAAO,WAAW,eAAe,kBACvE,KACF;CACE,MAAM,cAAc,oBAAoB;CACxC,MAAM,EAAE,OAAO,gBAAgB,UAAU;CACzC,MAAM,kBAAkB,wBAAwB;CAChD,MAAM,oBAAoB,kBAAkB,MAAM,EAAE,iBAAiB;CACrE,MAAM,QAAQ,OAA+B,IAAI;CACjD,MAAM,cAAc,OAAiC,CAAC,GAAG,KAAK,QAAQ,CAAC;CACvE,MAAM,WAAW,OAA2B,IAAI;CAChD,MAAM,UAAU,OAA0B,IAAI;CAC9C,MAAM,gBAAgB,uBAAO,IAAI,IAAyC,CAAC;CAC3E,MAAM,SAAS,OAAuB,aAAa,IAAI,KAAK,UAAU,CAAC;CACvE,IAAI,KAAK,eAAe,QAAQ,OAAO,UAAU,KAAK;CAEtD,MAAM,CAAC,OAAO,YAAY,SAAS,IAAI;CACvC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK,EAAE;CAC9C,MAAM,CAAC,QAAQ,aAAa,SAAwB,CAAC,CAAC;CACtD,MAAM,CAAC,aAA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UAAA;GAKK,KAAK,SAAS,aAAa,oBAAC,kBAAD;IAAkB,MAAM,CAAC,MAAO,IAAK;IAAG,SAAS;GAAM,CAAA;GAClF,KAAK,SAAS,kBAAkB,oBAAC,kBAAD;IAAkB,MAAM,CAAC,KAAM,IAAK;IAAG,SAAS;GAAO,CAAA;GACvF,KAAK,SAAS,kBAAkB,oBAAC,gBAAD;IAAgB,MAAM,OAAO,uBAAuB;KAAC;KAAK;KAAK;IAAG;IAAG,SAAS;GAAM,CAAA;GACrH,qBAAC,SAAD;IAAO,KAAK;IAAoB;IAAhC,UAAA;KACK,KAAK,SAAS,aAAa,OAAO,WAC/B,oBAAC,QAAD;MACI,KAAK;MACL,WAAW,cAAc,UAAU,OAAO,UAAU,OAAO,aAAa,KAAA;MACxE,UAAU,OAAO;MAAS,YAAA;MAAW,eAAA;MAAwB;MAE7D,UAAA,oBAAC,cAAD;OAAsB;OAAQ,QAAQ,KAAK,eAAe,SAAS,cAAc,KAAK;MAAa,CAAA;KACjG,CAAA;KAET,KAAK,SAAS,kBAAkB,OAAO,aAAa,OAAO,aACxD,oBAAC,QAAD;MAAM,KAAK;MAAS,UAAU,OAAO;MAAW,UAAU,OAAO;MAAW,YAAA;MAAqB;MAC7F,UAAA,oBAAC,cAAD;OAAsB;OAAQ,QAAO;MAAU,CAAA;KAC7C,CAAA;KAET,KAAK,SAAS,kBAAkB,OAAO,gBACpC,qBAAAA,UAAA,EAAA,UAAA,CACI,oBAAC,aAAD,EAAW,QAAQ,OAAO,aAAe,CAAA,GACzC,oBAAC,cAAD;MAAsB;MAAQ,QAAQ,OAAO;MAAa,YAAY,cAAc;KAAU,CAAA,CAChG,EAAA,CAAA;IAEH;;EACA;;AAEnB,CAAC"}
|
|
1
|
+
{"version":3,"file":"DestructibleTarget.js","names":["_Fragment"],"sources":["../../src/junk/DestructibleTarget.tsx"],"sourcesContent":["import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from \"react\";\nimport { useFrame } from \"@react-three/fiber\";\nimport { CuboidCollider, CylinderCollider, RigidBody, useRapier, type RapierRigidBody } from \"@react-three/rapier\";\nimport * as THREE from \"three\";\nimport { useCustomGravity } from \"@pinkaphant/ecctrl/gravity\";\nimport { FloatingBodyTrait, useActiveKolmoWorld } from \"../engine/kolmoStore.js\";\nimport { useIsKolmoCustomGravity } from \"../physics/index.js\";\nimport { selectCanLod, type ResolvedCanLod } from \"./junkGeometry.js\";\nimport type { ImportedGlbAsset } from \"./junkImporter.js\";\nimport type { BallisticHitEvent, DecalRecord, DestructibleTargetSpec, ShardSpec } from \"./junkTypes.js\";\nimport { ShardPieces } from \"./ShardPieces.js\";\nimport type { DestructibleTargetSnapshot, SpawnedShardState } from \"./targetHelpers.js\";\nimport { appendDecalBounded, buildTargetSnapshot, executeTargetHit, readTargetWorldPos, tagImportedMeshes } from \"./targetHitLogic.js\";\nimport { TargetDecals } from \"./TargetDecals.js\";\nimport { useTargetAssets } from \"./useTargetAssets.js\";\n\nexport interface DestructibleTargetHandle {\n applyHit: (hit: BallisticHitEvent) => void;\n getSnapshot: () => DestructibleTargetSnapshot;\n}\n\nexport interface DestructibleTargetProps {\n spec: DestructibleTargetSpec;\n active?: boolean;\n importedAsset?: ImportedGlbAsset | null;\n onHit?: (targetId: string, event: BallisticHitEvent, nextHp: number, decals: DecalRecord[]) => void;\n onShatter?: (targetId: string, shards: ShardSpec[], event: BallisticHitEvent) => void;\n onStateChange?: (snapshot: DestructibleTargetSnapshot) => void;\n registerTarget?: (id: string, handle: DestructibleTargetHandle | null) => void;\n}\n\nconst _lodPos = new THREE.Vector3();\n\nexport const DestructibleTarget = forwardRef<DestructibleTargetHandle, DestructibleTargetProps>(function DestructibleTarget(\n { spec, active = true, importedAsset, onHit, onShatter, onStateChange, registerTarget },\n ref,\n) {\n const activeWorld = useActiveKolmoWorld();\n const { world: rapierWorld } = useRapier();\n const isCustomGravity = useIsKolmoCustomGravity();\n const applyGravityField = useCustomGravity((s) => s.applyGravityField);\n const rbRef = useRef<RapierRigidBody | null>(null);\n const spawnPosRef = useRef<[number, number, number]>([...spec.position]);\n const groupRef = useRef<THREE.Group | null>(null);\n const meshRef = useRef<THREE.Mesh | null>(null);\n const decalMeshRefs = useRef(new Map<string, React.RefObject<THREE.Mesh>>());\n const lodRef = useRef<ResolvedCanLod>(selectCanLod(10, spec.canLodMode));\n if (spec.canLodMode !== \"auto\") lodRef.current = spec.canLodMode;\n\n const [alive, setAlive] = useState(true);\n const [hpState, setHpState] = useState(spec.hp);\n const [decals, setDecals] = useState<DecalRecord[]>([]);\n const [decalLodKey, setDecalLodKey] = useState<ResolvedCanLod>(lodRef.current);\n const [shards, setShards] = useState<SpawnedShardState[]>([]);\n const [shardMaterial, setShardMaterial] = useState<THREE.Material | null>(null);\n\n const aliveRef = useRef(true);\n const hpRef = useRef(spec.hp);\n const decalCounterRef = useRef(0);\n const decalsRef = useRef<DecalRecord[]>([]);\n const shardsRef = useRef<SpawnedShardState[]>([]);\n const lastPosRef = useRef<[number, number, number]>([...spec.position]);\n\n const assets = useTargetAssets(spec, importedAsset);\n const specRef = useRef(spec);\n specRef.current = spec;\n const assetsRef = useRef(assets);\n assetsRef.current = assets;\n const cbRef = useRef({ onHit, onShatter, onStateChange, registerTarget });\n cbRef.current = { onHit, onShatter, onStateChange, registerTarget };\n\n const getSnapshot = useCallback(\n () =>\n buildTargetSnapshot(\n specRef.current,\n assetsRef.current,\n rbRef.current,\n hpRef.current,\n aliveRef.current,\n decalsRef.current.length,\n shardsRef.current.length,\n lastPosRef.current,\n lodRef.current,\n ),\n [],\n );\n\n const applyHit = useCallback((hit: BallisticHitEvent) => {\n if (!aliveRef.current)\n return;\n const s = specRef.current;\n const res = executeTargetHit(\n s, assetsRef.current, rbRef.current, groupRef.current, meshRef.current,\n hpRef.current, `${s.id}-d-${++decalCounterRef.current}`, hit,\n );\n if (res.shattered && res.shardStates && res.shardMaterial) {\n if (res.shatterPos) lastPosRef.current = res.shatterPos;\n rbRef.current = null;\n aliveRef.current = false;\n hpRef.current = 0;\n decalsRef.current = [];\n shardsRef.current = res.shardStates;\n decalMeshRefs.current.clear();\n setHpState(0);\n setDecals([]);\n setShardMaterial(res.shardMaterial);\n setShards(res.shardStates);\n setAlive(false);\n cbRef.current.onShatter?.(s.id, res.shardSpecs ?? [], hit);\n } else {\n if (res.bodyPos) lastPosRef.current = res.bodyPos;\n hpRef.current = res.nextHp;\n setHpState(res.nextHp);\n if (res.newDecal) {\n const next = appendDecalBounded(decalsRef.current, res.newDecal, decalMeshRefs.current, res.newDecalMesh);\n decalsRef.current = next;\n setDecals(next);\n cbRef.current.onHit?.(s.id, hit, res.nextHp, next);\n } else {\n cbRef.current.onHit?.(s.id, hit, res.nextHp, decalsRef.current);\n }\n }\n }, []);\n\n const handle = useMemo<DestructibleTargetHandle>(() => ({ applyHit, getSnapshot }), [applyHit, getSnapshot]);\n useImperativeHandle(ref, () => handle, [handle]);\n\n useEffect(() => {\n cbRef.current.registerTarget?.(spec.id, handle);\n return () => cbRef.current.registerTarget?.(spec.id, null);\n }, [spec.id, handle]);\n\n useEffect(() => {\n cbRef.current.onStateChange?.(getSnapshot());\n }, [getSnapshot, alive, hpState, decals.length, shards.length, spec.canLodMode, assets.baseTriCount, assets.customLabelLoaded]);\n\n useEffect(() => {\n tagImportedMeshes(assets.importedRoot, spec.id, applyHit);\n }, [assets.importedRoot, spec.id, applyHit]);\n\n useFrame(({ camera }) => {\n if (active && aliveRef.current && isCustomGravity && rbRef.current) {\n applyGravityField(rbRef.current, rapierWorld.timestep);\n }\n if (!active || !aliveRef.current || spec.kind !== \"tin-can\" || spec.canLodMode !== \"auto\")\n return;\n if (!readTargetWorldPos(rbRef.current, groupRef.current, _lodPos))\n return;\n const nextLod = selectCanLod(camera.position.distanceTo(_lodPos), \"auto\");\n if (nextLod !== lodRef.current) {\n lodRef.current = nextLod;\n const nextGeo = nextLod === \"3-gon\" ? assets.can3Geo : assets.can12Geo;\n if (meshRef.current && nextGeo) meshRef.current.geometry = nextGeo;\n if (decalsRef.current.length > 0) setDecalLodKey(nextLod);\n cbRef.current.onStateChange?.(getSnapshot());\n }\n });\n\n useEffect(() => {\n if (!alive) return;\n const ent = activeWorld.spawn(FloatingBodyTrait({ id: spec.id, getBody: () => rbRef.current }));\n return () => { ent.destroy(); };\n }, [activeWorld, spec.id, alive]);\n\n const userData = useMemo(\n () => ({\n targetId: spec.id, toolgunId: spec.id, destructibleTarget: true, isDestructibleTarget: true,\n applyHit, ecctrl: { excludeCharacterRay: true },\n }),\n [spec.id, applyHit],\n );\n\n if (!alive) return <ShardPieces shards={shards} material={shardMaterial} />;\n\n const waitImported = spec.kind === \"imported-glb\" && !assets.importedHalfExtents;\n const renderLod = spec.canLodMode === \"auto\" ? lodRef.current : spec.canLodMode;\n\n return (\n <RigidBody\n ref={rbRef} type={waitImported ? \"fixed\" : \"dynamic\"} colliders={false}\n position={spawnPosRef.current} restitution={0.18} friction={0.45}\n linearDamping={isCustomGravity ? 0 : 1.2} angularDamping={isCustomGravity ? 0.05 : 8} userData={userData}\n >\n {spec.kind === \"tin-can\" && <CylinderCollider args={[0.125, 0.085]} density={180} />}\n {spec.kind === \"glass-bottle\" && <CylinderCollider args={[0.16, 0.055]} density={1200} />}\n {spec.kind === \"imported-glb\" && <CuboidCollider args={assets.importedHalfExtents ?? [0.2, 0.2, 0.2]} density={800} />}\n <group ref={groupRef} userData={userData}>\n {spec.kind === \"tin-can\" && assets.canMats && (\n <mesh\n ref={meshRef}\n geometry={(renderLod === \"3-gon\" ? assets.can3Geo : assets.can12Geo) ?? undefined}\n material={assets.canMats} castShadow receiveShadow userData={userData}\n >\n <TargetDecals decals={decals} lodKey={spec.canLodMode === \"auto\" ? decalLodKey : spec.canLodMode} />\n </mesh>\n )}\n {spec.kind === \"glass-bottle\" && assets.bottleGeo && assets.bottleMat && (\n <mesh ref={meshRef} geometry={assets.bottleGeo} material={assets.bottleMat} castShadow userData={userData}>\n <TargetDecals decals={decals} lodKey=\"bottle\" />\n </mesh>\n )}\n {spec.kind === \"imported-glb\" && assets.importedRoot && (\n <>\n <primitive object={assets.importedRoot} />\n <TargetDecals decals={decals} lodKey={assets.importedKey} meshRefMap={decalMeshRefs.current} />\n </>\n )}\n </group>\n </RigidBody>\n );\n});\n"],"mappings":";;;;;;;;;;;;;;AA+BA,IAAM,UAAU,IAAI,MAAM,QAAQ;AAElC,IAAa,qBAAqB,WAA8D,SAAS,mBACrG,EAAE,MAAM,SAAS,MAAM,eAAe,OAAO,WAAW,eAAe,kBACvE,KACF;CACE,MAAM,cAAc,oBAAoB;CACxC,MAAM,EAAE,OAAO,gBAAgB,UAAU;CACzC,MAAM,kBAAkB,wBAAwB;CAChD,MAAM,oBAAoB,kBAAkB,MAAM,EAAE,iBAAiB;CACrE,MAAM,QAAQ,OAA+B,IAAI;CACjD,MAAM,cAAc,OAAiC,CAAC,GAAG,KAAK,QAAQ,CAAC;CACvE,MAAM,WAAW,OAA2B,IAAI;CAChD,MAAM,UAAU,OAA0B,IAAI;CAC9C,MAAM,gBAAgB,uBAAO,IAAI,IAAyC,CAAC;CAC3E,MAAM,SAAS,OAAuB,aAAa,IAAI,KAAK,UAAU,CAAC;CACvE,IAAI,KAAK,eAAe,QAAQ,OAAO,UAAU,KAAK;CAEtD,MAAM,CAAC,OAAO,YAAY,SAAS,IAAI;CACvC,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK,EAAE;CAC9C,MAAM,CAAC,QAAQ,aAAa,SAAwB,CAAC,CAAC;CACtD,MAAM,CAAC,aAAa,kBAAkB,SAAyB,OAAO,OAAO;CAC7E,MAAM,CAAC,QAAQ,aAAa,SAA8B,CAAC,CAAC;CAC5D,MAAM,CAAC,eAAe,oBAAoB,SAAgC,IAAI;CAE9E,MAAM,WAAW,OAAO,IAAI;CAC5B,MAAM,QAAQ,OAAO,KAAK,EAAE;CAC5B,MAAM,kBAAkB,OAAO,CAAC;CAChC,MAAM,YAAY,OAAsB,CAAC,CAAC;CAC1C,MAAM,YAAY,OA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AG,SAAS;GAAM,CAAA;GACrH,qBAAC,SAAD;IAAO,KAAK;IAAoB;IAAhC,UAAA;KACK,KAAK,SAAS,aAAa,OAAO,WAC/B,oBAAC,QAAD;MACI,KAAK;MACL,WAAW,cAAc,UAAU,OAAO,UAAU,OAAO,aAAa,KAAA;MACxE,UAAU,OAAO;MAAS,YAAA;MAAW,eAAA;MAAwB;MAE7D,UAAA,oBAAC,cAAD;OAAsB;OAAQ,QAAQ,KAAK,eAAe,SAAS,cAAc,KAAK;MAAa,CAAA;KACjG,CAAA;KAET,KAAK,SAAS,kBAAkB,OAAO,aAAa,OAAO,aACxD,oBAAC,QAAD;MAAM,KAAK;MAAS,UAAU,OAAO;MAAW,UAAU,OAAO;MAAW,YAAA;MAAqB;MAC7F,UAAA,oBAAC,cAAD;OAAsB;OAAQ,QAAO;MAAU,CAAA;KAC7C,CAAA;KAET,KAAK,SAAS,kBAAkB,OAAO,gBACpC,qBAAAA,UAAA,EAAA,UAAA,CACI,oBAAC,aAAD,EAAW,QAAQ,OAAO,aAAe,CAAA,GACzC,oBAAC,cAAD;MAAsB;MAAQ,QAAQ,OAAO;MAAa,YAAY,cAAc;KAAU,CAAA,CAChG,EAAA,CAAA;IAEH;;EACA;;AAEnB,CAAC"}
|
package/dist/junk/ShardPieces.js
CHANGED
|
@@ -60,8 +60,8 @@ function ShardPieceBody({ item, material }) {
|
|
|
60
60
|
quaternion: spawnPoseRef.current.quat,
|
|
61
61
|
restitution: .18,
|
|
62
62
|
friction: .8,
|
|
63
|
-
linearDamping: .45,
|
|
64
|
-
angularDamping: .45,
|
|
63
|
+
linearDamping: isCustomGravity ? 0 : .45,
|
|
64
|
+
angularDamping: isCustomGravity ? .05 : .45,
|
|
65
65
|
userData,
|
|
66
66
|
children: [/* @__PURE__ */ jsx(CuboidCollider, {
|
|
67
67
|
args: halfExtents,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShardPieces.js","names":[],"sources":["../../src/junk/ShardPieces.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport * as THREE from \"three\";\nimport { createPortal, useFrame, useThree } from \"@react-three/fiber\";\nimport { CuboidCollider, RigidBody, useRapier, type RapierRigidBody } from \"@react-three/rapier\";\nimport { useCustomGravity } from \"@pinkaphant/ecctrl/gravity\";\nimport { FloatingBodyTrait, useActiveKolmoWorld } from \"../engine/kolmoStore.js\";\nimport { useIsKolmoCustomGravity } from \"../physics/index.js\";\nimport { SHARD_COLLIDER_INSET, type SpawnedShardState } from \"./targetHelpers.js\";\n\nexport interface ShardPiecesProps {\n readonly shards: ReadonlyArray<SpawnedShardState>;\n readonly material: THREE.Material | null;\n}\n\nfunction ShardPieceBody({\n item,\n material,\n}: {\n item: SpawnedShardState;\n material: THREE.Material;\n}): React.JSX.Element {\n const activeWorld = useActiveKolmoWorld();\n const { world: rapierWorld } = useRapier();\n const isCustomGravity = useIsKolmoCustomGravity();\n const applyGravityField = useCustomGravity((s) => s.applyGravityField);\n const rbRef = useRef<RapierRigidBody | null>(null);\n const spawnPoseRef = useRef({ pos: item.worldPos, quat: item.worldQuat });\n\n useFrame(() => {\n if (isCustomGravity && rbRef.current) {\n applyGravityField(rbRef.current, rapierWorld.timestep);\n }\n });\n\n useEffect(() => {\n const entity = activeWorld.spawn(\n FloatingBodyTrait({\n id: item.spec.id,\n getBody: () => rbRef.current,\n }),\n );\n const rb = rbRef.current;\n if (rb) {\n rb.setLinvel({ x: item.linvel[0], y: item.linvel[1], z: item.linvel[2] }, true);\n rb.setAngvel({ x: item.angvel[0], y: item.angvel[1], z: item.angvel[2] }, true);\n }\n return () => {\n entity.destroy();\n };\n }, [activeWorld, item]);\n\n const halfExtents: [number, number, number] = [\n Math.max(0.01, item.spec.halfExtents[0] * SHARD_COLLIDER_INSET),\n Math.max(0.01, item.spec.halfExtents[1] * SHARD_COLLIDER_INSET),\n Math.max(0.01, item.spec.halfExtents[2] * SHARD_COLLIDER_INSET),\n ];\n\n const userData = useMemo(\n () => ({\n toolgunId: item.spec.id,\n ecctrl: { excludeCharacterRay: true },\n }),\n [item.spec.id],\n );\n\n return (\n <RigidBody\n ref={rbRef}\n type=\"dynamic\"\n colliders={false}\n position={spawnPoseRef.current.pos}\n quaternion={spawnPoseRef.current.quat}\n restitution={0.18}\n friction={0.8}\n linearDamping={0.45}\n angularDamping={0.45}\n userData={userData}\n >\n <CuboidCollider args={halfExtents} density={item.density} />\n <mesh geometry={item.spec.geometry} material={material} castShadow receiveShadow />\n </RigidBody>\n );\n}\n\n/**\n * Portals dynamic Rapier shatter fragments directly into the root `THREE.Scene` so world-space\n * `worldPos`/`worldQuat` are never double-transformed by translated or rotated parent `<group>`s,\n * and registers `FloatingBodyTrait` for zero-drift floating-origin rebasing.\n */\nexport function ShardPieces({ shards, material }: ShardPiecesProps): React.JSX.Element | null {\n const scene = useThree((s) => s.scene);\n\n useEffect(\n () => () => {\n for (const s of shards)\n s.spec.geometry.dispose();\n },\n [shards],\n );\n\n useEffect(\n () => () => {\n material?.dispose();\n },\n [material],\n );\n\n if (!material || shards.length === 0)\n return null;\n\n return createPortal(\n <group name=\"Kolmo_WorldShardPieces\">\n {shards.map((item) => (\n <ShardPieceBody key={item.spec.id} item={item} material={material} />\n ))}\n </group>,\n scene,\n );\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAS,eAAe,EACpB,MACA,YAIkB;CAClB,MAAM,cAAc,oBAAoB;CACxC,MAAM,EAAE,OAAO,gBAAgB,UAAU;CACzC,MAAM,kBAAkB,wBAAwB;CAChD,MAAM,oBAAoB,kBAAkB,MAAM,EAAE,iBAAiB;CACrE,MAAM,QAAQ,OAA+B,IAAI;CACjD,MAAM,eAAe,OAAO;EAAE,KAAK,KAAK;EAAU,MAAM,KAAK;CAAU,CAAC;CAExE,eAAe;EACX,IAAI,mBAAmB,MAAM,SACzB,kBAAkB,MAAM,SAAS,YAAY,QAAQ;CAE7D,CAAC;CAED,gBAAgB;EACZ,MAAM,SAAS,YAAY,MACvB,kBAAkB;GACd,IAAI,KAAK,KAAK;GACd,eAAe,MAAM;EACzB,CAAC,CACL;EACA,MAAM,KAAK,MAAM;EACjB,IAAI,IAAI;GACJ,GAAG,UAAU;IAAE,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,OAAO;GAAG,GAAG,IAAI;GAC9E,GAAG,UAAU;IAAE,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,OAAO;GAAG,GAAG,IAAI;EAClF;EACA,aAAa;GACT,OAAO,QAAQ;EACnB;CACJ,GAAG,CAAC,aAAa,IAAI,CAAC;CAEtB,MAAM,cAAwC;EAC1C,KAAK,IAAI,KAAM,KAAK,KAAK,YAAY,KAAK,oBAAoB;EAC9D,KAAK,IAAI,KAAM,KAAK,KAAK,YAAY,KAAK,oBAAoB;EAC9D,KAAK,IAAI,KAAM,KAAK,KAAK,YAAY,KAAK,oBAAoB;CAClE;CAEA,MAAM,WAAW,eACN;EACH,WAAW,KAAK,KAAK;EACrB,QAAQ,EAAE,qBAAqB,KAAK;CACxC,IACA,CAAC,KAAK,KAAK,EAAE,CACjB;CAEA,OACI,qBAAC,WAAD;EACI,KAAK;EACL,MAAK;EACL,WAAW;EACX,UAAU,aAAa,QAAQ;EAC/B,YAAY,aAAa,QAAQ;EACjC,aAAa;EACb,UAAU;EACV,eAAe;
|
|
1
|
+
{"version":3,"file":"ShardPieces.js","names":[],"sources":["../../src/junk/ShardPieces.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useRef } from \"react\";\nimport * as THREE from \"three\";\nimport { createPortal, useFrame, useThree } from \"@react-three/fiber\";\nimport { CuboidCollider, RigidBody, useRapier, type RapierRigidBody } from \"@react-three/rapier\";\nimport { useCustomGravity } from \"@pinkaphant/ecctrl/gravity\";\nimport { FloatingBodyTrait, useActiveKolmoWorld } from \"../engine/kolmoStore.js\";\nimport { useIsKolmoCustomGravity } from \"../physics/index.js\";\nimport { SHARD_COLLIDER_INSET, type SpawnedShardState } from \"./targetHelpers.js\";\n\nexport interface ShardPiecesProps {\n readonly shards: ReadonlyArray<SpawnedShardState>;\n readonly material: THREE.Material | null;\n}\n\nfunction ShardPieceBody({\n item,\n material,\n}: {\n item: SpawnedShardState;\n material: THREE.Material;\n}): React.JSX.Element {\n const activeWorld = useActiveKolmoWorld();\n const { world: rapierWorld } = useRapier();\n const isCustomGravity = useIsKolmoCustomGravity();\n const applyGravityField = useCustomGravity((s) => s.applyGravityField);\n const rbRef = useRef<RapierRigidBody | null>(null);\n const spawnPoseRef = useRef({ pos: item.worldPos, quat: item.worldQuat });\n\n useFrame(() => {\n if (isCustomGravity && rbRef.current) {\n applyGravityField(rbRef.current, rapierWorld.timestep);\n }\n });\n\n useEffect(() => {\n const entity = activeWorld.spawn(\n FloatingBodyTrait({\n id: item.spec.id,\n getBody: () => rbRef.current,\n }),\n );\n const rb = rbRef.current;\n if (rb) {\n rb.setLinvel({ x: item.linvel[0], y: item.linvel[1], z: item.linvel[2] }, true);\n rb.setAngvel({ x: item.angvel[0], y: item.angvel[1], z: item.angvel[2] }, true);\n }\n return () => {\n entity.destroy();\n };\n }, [activeWorld, item]);\n\n const halfExtents: [number, number, number] = [\n Math.max(0.01, item.spec.halfExtents[0] * SHARD_COLLIDER_INSET),\n Math.max(0.01, item.spec.halfExtents[1] * SHARD_COLLIDER_INSET),\n Math.max(0.01, item.spec.halfExtents[2] * SHARD_COLLIDER_INSET),\n ];\n\n const userData = useMemo(\n () => ({\n toolgunId: item.spec.id,\n ecctrl: { excludeCharacterRay: true },\n }),\n [item.spec.id],\n );\n\n return (\n <RigidBody\n ref={rbRef}\n type=\"dynamic\"\n colliders={false}\n position={spawnPoseRef.current.pos}\n quaternion={spawnPoseRef.current.quat}\n restitution={0.18}\n friction={0.8}\n linearDamping={isCustomGravity ? 0 : 0.45}\n angularDamping={isCustomGravity ? 0.05 : 0.45}\n userData={userData}\n >\n <CuboidCollider args={halfExtents} density={item.density} />\n <mesh geometry={item.spec.geometry} material={material} castShadow receiveShadow />\n </RigidBody>\n );\n}\n\n/**\n * Portals dynamic Rapier shatter fragments directly into the root `THREE.Scene` so world-space\n * `worldPos`/`worldQuat` are never double-transformed by translated or rotated parent `<group>`s,\n * and registers `FloatingBodyTrait` for zero-drift floating-origin rebasing.\n */\nexport function ShardPieces({ shards, material }: ShardPiecesProps): React.JSX.Element | null {\n const scene = useThree((s) => s.scene);\n\n useEffect(\n () => () => {\n for (const s of shards)\n s.spec.geometry.dispose();\n },\n [shards],\n );\n\n useEffect(\n () => () => {\n material?.dispose();\n },\n [material],\n );\n\n if (!material || shards.length === 0)\n return null;\n\n return createPortal(\n <group name=\"Kolmo_WorldShardPieces\">\n {shards.map((item) => (\n <ShardPieceBody key={item.spec.id} item={item} material={material} />\n ))}\n </group>,\n scene,\n );\n}\n"],"mappings":";;;;;;;;;;AAcA,SAAS,eAAe,EACpB,MACA,YAIkB;CAClB,MAAM,cAAc,oBAAoB;CACxC,MAAM,EAAE,OAAO,gBAAgB,UAAU;CACzC,MAAM,kBAAkB,wBAAwB;CAChD,MAAM,oBAAoB,kBAAkB,MAAM,EAAE,iBAAiB;CACrE,MAAM,QAAQ,OAA+B,IAAI;CACjD,MAAM,eAAe,OAAO;EAAE,KAAK,KAAK;EAAU,MAAM,KAAK;CAAU,CAAC;CAExE,eAAe;EACX,IAAI,mBAAmB,MAAM,SACzB,kBAAkB,MAAM,SAAS,YAAY,QAAQ;CAE7D,CAAC;CAED,gBAAgB;EACZ,MAAM,SAAS,YAAY,MACvB,kBAAkB;GACd,IAAI,KAAK,KAAK;GACd,eAAe,MAAM;EACzB,CAAC,CACL;EACA,MAAM,KAAK,MAAM;EACjB,IAAI,IAAI;GACJ,GAAG,UAAU;IAAE,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,OAAO;GAAG,GAAG,IAAI;GAC9E,GAAG,UAAU;IAAE,GAAG,KAAK,OAAO;IAAI,GAAG,KAAK,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K,EAAqC,CACvE;CACE,CAAA,GACP,KACJ;AACJ"}
|
package/dist/junk/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { collectValidTris, type ShardTri } from "./bvhTriCollector.js";
|
|
|
7
7
|
export { BOTTLE_HEIGHT, CAN_LOD_THRESHOLD_M, TIN_CAN_HEIGHT, TIN_CAN_RADIUS, buildGlassBottleGeometry, buildTinCanGeometry, countGeometryTriangles, createGlassBottleMaterial, createTinCanMaterials, selectCanLod, type ResolvedCanLod, } from "./junkGeometry.js";
|
|
8
8
|
export { disposeImportedRoot, ensureMeshAttributes } from "./junkImportSanitize.js";
|
|
9
9
|
export { applySegmentsToImportedRoot, loadImportedGlbUrl, parseImportedGlbBuffer, type ImportedGlbAsset } from "./junkImporter.js";
|
|
10
|
+
export { SUBSTRATE_DENSITY_KG_M3, splitSheetSceneIntoJunkIslands, type SplitJunkIsland, } from "./junkSheetSplitter.js";
|
|
10
11
|
export { getProceduralLabelTexture, loadCustomLabelTexture } from "./junkLabels.js";
|
|
11
12
|
export { JUNK_PROCEDURAL_RECIPES, buildProceduralJunkScene, type JunkProceduralRecipe, type JunkProceduralRecipeId, } from "./junkProceduralScenes.js";
|
|
12
13
|
export type { DestructibleTargetSnapshot, SpawnedShardState } from "./targetHelpers.js";
|
package/dist/junk/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { collectValidTris } from "./bvhTriCollector.js";
|
|
|
7
7
|
import { BOTTLE_HEIGHT, CAN_LOD_THRESHOLD_M, TIN_CAN_HEIGHT, TIN_CAN_RADIUS, buildGlassBottleGeometry, buildTinCanGeometry, countGeometryTriangles, createGlassBottleMaterial, createTinCanMaterials, selectCanLod } from "./junkGeometry.js";
|
|
8
8
|
import { disposeImportedRoot, ensureMeshAttributes } from "./junkImportSanitize.js";
|
|
9
9
|
import { applySegmentsToImportedRoot, loadImportedGlbUrl, parseImportedGlbBuffer } from "./junkImporter.js";
|
|
10
|
+
import { SUBSTRATE_DENSITY_KG_M3, splitSheetSceneIntoJunkIslands } from "./junkSheetSplitter.js";
|
|
10
11
|
import { getProceduralLabelTexture, loadCustomLabelTexture } from "./junkLabels.js";
|
|
11
12
|
import { JUNK_PROCEDURAL_RECIPES, buildProceduralJunkScene } from "./junkProceduralScenes.js";
|
|
12
|
-
export { BOTTLE_HEIGHT, CAN_LOD_THRESHOLD_M, DestructibleTarget, JUNK_PROCEDURAL_RECIPES, KolmoJunk, ShardPieces, TIN_CAN_HEIGHT, TIN_CAN_RADIUS, TargetDecals, applySegmentsToImportedRoot, buildGlassBottleGeometry, buildProceduralJunkScene, buildTinCanGeometry, collectValidTris, countGeometryTriangles, createGlassBottleMaterial, createTinCanMaterials, disposeImportedRoot, ensureMeshAttributes, getBulletHoleTexture, getProceduralLabelTexture, loadCustomLabelTexture, loadImportedGlbUrl, parseImportedGlbBuffer, selectCanLod, splitObjectIntoShards };
|
|
13
|
+
export { BOTTLE_HEIGHT, CAN_LOD_THRESHOLD_M, DestructibleTarget, JUNK_PROCEDURAL_RECIPES, KolmoJunk, SUBSTRATE_DENSITY_KG_M3, ShardPieces, TIN_CAN_HEIGHT, TIN_CAN_RADIUS, TargetDecals, applySegmentsToImportedRoot, buildGlassBottleGeometry, buildProceduralJunkScene, buildTinCanGeometry, collectValidTris, countGeometryTriangles, createGlassBottleMaterial, createTinCanMaterials, disposeImportedRoot, ensureMeshAttributes, getBulletHoleTexture, getProceduralLabelTexture, loadCustomLabelTexture, loadImportedGlbUrl, parseImportedGlbBuffer, selectCanLod, splitObjectIntoShards, splitSheetSceneIntoJunkIslands };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { createKolmoGltfLoader } from "../engine/kolmoGltfLoader.js";
|
|
1
2
|
import { disposeImportedRoot, ensureMeshAttributes, isMeshNode } from "./junkImportSanitize.js";
|
|
2
3
|
import * as THREE from "three";
|
|
3
|
-
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
4
|
// src/junk/junkImporter.ts
|
|
5
5
|
var STATIC_ANCHOR_RE = /(base|stand|pedestal|mount|anchor|frame)/i;
|
|
6
6
|
var round4 = (v) => Math.round(v * 1e4) / 1e4;
|
|
@@ -24,7 +24,7 @@ function applySegmentsToImportedRoot(root, segments) {
|
|
|
24
24
|
}
|
|
25
25
|
async function parseImportedGlbBuffer(buffer, fileName = "imported.glb") {
|
|
26
26
|
if (!buffer || buffer.byteLength === 0) throw new Error(`Cannot import "${fileName}": file is empty (0 bytes).`);
|
|
27
|
-
const loader =
|
|
27
|
+
const loader = createKolmoGltfLoader();
|
|
28
28
|
let gltfScene;
|
|
29
29
|
try {
|
|
30
30
|
gltfScene = (await loader.parseAsync(buffer.slice(0), "")).scene;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"junkImporter.js","names":[],"sources":["../../src/junk/junkImporter.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport {
|
|
1
|
+
{"version":3,"file":"junkImporter.js","names":[],"sources":["../../src/junk/junkImporter.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { createKolmoGltfLoader } from \"../engine/kolmoGltfLoader.js\";\nimport { disposeImportedRoot, ensureMeshAttributes, isMeshNode } from \"./junkImportSanitize.js\";\nimport type { ImportedJunkSegment } from \"./junkTypes.js\";\n\nconst STATIC_ANCHOR_RE = /(base|stand|pedestal|mount|anchor|frame)/i;\n\nconst round4 = (v: number): number => Math.round(v * 1e4) / 1e4;\n\nfunction triCount(geo: THREE.BufferGeometry): number {\n if (geo.index)\n return Math.floor(geo.index.count / 3);\n const pos = geo.attributes.position;\n return pos ? Math.floor(pos.count / 3) : 0;\n}\n\nexport interface ImportedGlbAsset {\n root: THREE.Group;\n fileName: string;\n segments: ImportedJunkSegment[];\n bboxSizeM: [number, number, number];\n normalizedExtent: number;\n halfExtents: [number, number, number];\n dispose: () => void;\n}\n\nexport function applySegmentsToImportedRoot(root: THREE.Object3D, segments: readonly ImportedJunkSegment[]): void {\n const map = new Map(segments.map((s) => [s.segmentId, s]));\n root.traverse((obj) => {\n if (!isMeshNode(obj))\n return;\n const id = obj.userData.segmentId as string | undefined;\n if (!id)\n return;\n const seg = map.get(id);\n if (seg) {\n obj.userData.destructible = seg.destructible;\n obj.userData.customName = seg.customName;\n }\n });\n}\n\nexport async function parseImportedGlbBuffer(buffer: ArrayBuffer, fileName = \"imported.glb\"): Promise<ImportedGlbAsset> {\n if (!buffer || buffer.byteLength === 0) {\n throw new Error(`Cannot import \"${fileName}\": file is empty (0 bytes).`);\n }\n const loader = createKolmoGltfLoader();\n let gltfScene: THREE.Group;\n try {\n const gltf = await loader.parseAsync(buffer.slice(0), \"\");\n gltfScene = gltf.scene;\n }\n catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`Failed to parse GLB \"${fileName}\": ${msg}`);\n }\n\n const meshes: THREE.Mesh[] = [];\n try {\n gltfScene.traverse((obj) => {\n if (isMeshNode(obj) && obj.geometry?.attributes?.position) {\n ensureMeshAttributes(obj, fileName);\n meshes.push(obj);\n }\n });\n }\n catch (err) {\n disposeImportedRoot(gltfScene);\n throw err;\n }\n\n if (meshes.length === 0) {\n disposeImportedRoot(gltfScene);\n throw new Error(`GLB \"${fileName}\" contains no valid renderable meshes.`);\n }\n\n gltfScene.updateMatrixWorld(true);\n const rawBox = new THREE.Box3().setFromObject(gltfScene);\n const rawSize = rawBox.getSize(new THREE.Vector3());\n const maxDim = Math.max(rawSize.x, rawSize.y, rawSize.z);\n if (!Number.isFinite(maxDim) || maxDim <= 1e-6) {\n disposeImportedRoot(gltfScene);\n throw new Error(`GLB \"${fileName}\" has invalid or zero-size bounds.`);\n }\n\n let scale = maxDim > 1.2 || maxDim < 0.25 ? 0.55 / maxDim : 1;\n const scaledDim = maxDim * scale;\n if (scaledDim < 0.1) scale = 0.1 / maxDim;\n if (scaledDim > 2.5) scale = 2.5 / maxDim;\n gltfScene.scale.multiplyScalar(scale);\n gltfScene.updateMatrixWorld(true);\n\n const normBox = new THREE.Box3().setFromObject(gltfScene);\n const center = normBox.getCenter(new THREE.Vector3());\n const normSize = normBox.getSize(new THREE.Vector3());\n gltfScene.position.sub(center);\n\n const root = new THREE.Group();\n root.name = fileName;\n root.add(gltfScene);\n root.updateMatrixWorld(true);\n\n const anyNonStatic = meshes.some((m) => !STATIC_ANCHOR_RE.test(m.name || m.parent?.name || \"\"));\n const segBox = new THREE.Box3();\n const segSize = new THREE.Vector3();\n const segments: ImportedJunkSegment[] = meshes.map((m, idx) => {\n const segmentId = `seg_${idx}`;\n const originalName = m.name?.trim() || m.parent?.name?.trim() || `Segment ${idx + 1}`;\n const destructible = !anyNonStatic || !STATIC_ANCHOR_RE.test(originalName);\n segBox.setFromObject(m);\n segBox.getSize(segSize);\n m.userData.segmentId = segmentId;\n m.userData.destructible = destructible;\n m.userData.customName = originalName;\n return {\n segmentId,\n originalName,\n customName: originalName,\n destructible,\n triCount: triCount(m.geometry),\n bboxSizeM: [round4(Math.max(0.002, segSize.x)), round4(Math.max(0.002, segSize.y)), round4(Math.max(0.002, segSize.z))],\n };\n });\n\n const bboxSizeM: [number, number, number] = [\n round4(Math.max(0.02, normSize.x)),\n round4(Math.max(0.02, normSize.y)),\n round4(Math.max(0.02, normSize.z)),\n ];\n return {\n root,\n fileName,\n segments,\n bboxSizeM,\n normalizedExtent: round4(Math.max(...bboxSizeM)),\n halfExtents: [Math.max(0.015, bboxSizeM[0] * 0.5), Math.max(0.015, bboxSizeM[1] * 0.5), Math.max(0.015, bboxSizeM[2] * 0.5)],\n dispose: () => disposeImportedRoot(root),\n };\n}\n\nexport async function loadImportedGlbUrl(url: string, fileName = \"imported.glb\"): Promise<ImportedGlbAsset> {\n if (!url)\n throw new Error(\"No GLB URL provided.\");\n const res = await fetch(url);\n if (!res.ok)\n throw new Error(`Failed to fetch GLB \"${fileName}\" (${res.status}).`);\n return parseImportedGlbBuffer(await res.arrayBuffer(), fileName);\n}\n"],"mappings":";;;;AAKA,IAAM,mBAAmB;AAEzB,IAAM,UAAU,MAAsB,KAAK,MAAM,I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
+
/** Bulk SI material densities (kg / m^3) for celestial and structural junk substrates. */
|
|
3
|
+
export declare const SUBSTRATE_DENSITY_KG_M3: Readonly<{
|
|
4
|
+
readonly silicateRock: 2700;
|
|
5
|
+
readonly waterIce: 917;
|
|
6
|
+
readonly ironNickel: 7800;
|
|
7
|
+
readonly aluminumAlloy: 2710;
|
|
8
|
+
}>;
|
|
9
|
+
export interface SplitJunkIsland {
|
|
10
|
+
readonly index: number;
|
|
11
|
+
readonly geometry: THREE.BufferGeometry;
|
|
12
|
+
readonly material: THREE.Material;
|
|
13
|
+
/** Original centroid offset in the parent sheet scene (meters). */
|
|
14
|
+
readonly sheetOffset: readonly [number, number, number];
|
|
15
|
+
/** Axis-aligned size of the centered island geometry (meters). */
|
|
16
|
+
readonly sizeMeters: readonly [number, number, number];
|
|
17
|
+
/** Bounding sphere radius around local origin (meters). */
|
|
18
|
+
readonly boundingRadiusM: number;
|
|
19
|
+
/** Signed closed-mesh volume (or 0.52 * AABB fallback for open shells) in m^3. */
|
|
20
|
+
readonly volumeM3: number;
|
|
21
|
+
/** Physical mass m = density * volume (kg). */
|
|
22
|
+
readonly massKg: number;
|
|
23
|
+
/** Standard gravitational parameter mu = G * m (m^3 / s^2). */
|
|
24
|
+
readonly mu: number;
|
|
25
|
+
/** Deduplicated local vertex positions for Rapier `ConvexHullCollider`. */
|
|
26
|
+
readonly hullVertices: Float32Array;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Splits a multi-part sheet `.glb` scene (such as `asteroid_shrapnel.glb`) into independent,
|
|
30
|
+
* origin-centered physical `KolmoJunk` islands with exact SI volume, mass, convex-hull
|
|
31
|
+
* vertices, and self-gravity `mu`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function splitSheetSceneIntoJunkIslands(root: THREE.Object3D, options?: {
|
|
34
|
+
readonly densityKgPerM3?: number;
|
|
35
|
+
readonly scaleMultiplier?: number;
|
|
36
|
+
readonly minTriangles?: number;
|
|
37
|
+
readonly gravitationalConstant?: number;
|
|
38
|
+
}): SplitJunkIsland[];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { extractMeshIslands } from "../importer/meshIslands.js";
|
|
2
|
+
import "../physics/nBodyGravity.js";
|
|
3
|
+
import * as THREE from "three";
|
|
4
|
+
// src/junk/junkSheetSplitter.ts
|
|
5
|
+
/** Bulk SI material densities (kg / m^3) for celestial and structural junk substrates. */
|
|
6
|
+
var SUBSTRATE_DENSITY_KG_M3 = Object.freeze({
|
|
7
|
+
silicateRock: 2700,
|
|
8
|
+
waterIce: 917,
|
|
9
|
+
ironNickel: 7800,
|
|
10
|
+
aluminumAlloy: 2710
|
|
11
|
+
});
|
|
12
|
+
function computeSignedGeometryVolume(geo) {
|
|
13
|
+
const pos = geo.getAttribute("position");
|
|
14
|
+
if (!pos || pos.count < 3) return 0;
|
|
15
|
+
const idx = geo.getIndex();
|
|
16
|
+
const triCount = idx ? Math.floor(idx.count / 3) : Math.floor(pos.count / 3);
|
|
17
|
+
let vol6 = 0;
|
|
18
|
+
for (let t = 0; t < triCount; t++) {
|
|
19
|
+
const i0 = idx ? idx.getX(t * 3) : t * 3;
|
|
20
|
+
const i1 = idx ? idx.getX(t * 3 + 1) : t * 3 + 1;
|
|
21
|
+
const i2 = idx ? idx.getX(t * 3 + 2) : t * 3 + 2;
|
|
22
|
+
const ax = pos.getX(i0), ay = pos.getY(i0), az = pos.getZ(i0);
|
|
23
|
+
const bx = pos.getX(i1), by = pos.getY(i1), bz = pos.getZ(i1);
|
|
24
|
+
const cx = pos.getX(i2), cy = pos.getY(i2), cz = pos.getZ(i2);
|
|
25
|
+
vol6 += ax * (by * cz - bz * cy) + ay * (bz * cx - bx * cz) + az * (bx * cy - by * cx);
|
|
26
|
+
}
|
|
27
|
+
return Math.abs(vol6) / 6;
|
|
28
|
+
}
|
|
29
|
+
function sampleHullVertices(geo, maxVerts = 96) {
|
|
30
|
+
const pos = geo.getAttribute("position");
|
|
31
|
+
if (!pos || pos.count === 0) return /* @__PURE__ */ new Float32Array(0);
|
|
32
|
+
const step = Math.max(1, Math.ceil(pos.count / maxVerts));
|
|
33
|
+
const out = [];
|
|
34
|
+
for (let i = 0; i < pos.count; i += step) out.push(pos.getX(i), pos.getY(i), pos.getZ(i));
|
|
35
|
+
return new Float32Array(out);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Splits a multi-part sheet `.glb` scene (such as `asteroid_shrapnel.glb`) into independent,
|
|
39
|
+
* origin-centered physical `KolmoJunk` islands with exact SI volume, mass, convex-hull
|
|
40
|
+
* vertices, and self-gravity `mu`.
|
|
41
|
+
*/
|
|
42
|
+
function splitSheetSceneIntoJunkIslands(root, options) {
|
|
43
|
+
const density = Math.max(1, options?.densityKgPerM3 ?? SUBSTRATE_DENSITY_KG_M3.silicateRock);
|
|
44
|
+
const scaleMult = Math.max(1e-4, options?.scaleMultiplier ?? 1);
|
|
45
|
+
const minTris = Math.max(4, options?.minTriangles ?? 8);
|
|
46
|
+
const gConst = options?.gravitationalConstant ?? 66743e-15;
|
|
47
|
+
let firstMat = null;
|
|
48
|
+
root.traverse((obj) => {
|
|
49
|
+
if (firstMat) return;
|
|
50
|
+
const m = obj;
|
|
51
|
+
if (m.isMesh && m.material) firstMat = Array.isArray(m.material) ? m.material[0] : m.material;
|
|
52
|
+
});
|
|
53
|
+
const baseMaterial = firstMat ?? new THREE.MeshStandardMaterial({
|
|
54
|
+
color: "#8b95a5",
|
|
55
|
+
roughness: .86,
|
|
56
|
+
flatShading: true
|
|
57
|
+
});
|
|
58
|
+
const rawIslands = extractMeshIslands(root);
|
|
59
|
+
const results = [];
|
|
60
|
+
for (const isl of rawIslands) {
|
|
61
|
+
if (isl.triangleIndices.length < minTris) {
|
|
62
|
+
isl.geometry.dispose();
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const geo = isl.geometry;
|
|
66
|
+
if (scaleMult !== 1) geo.scale(scaleMult, scaleMult, scaleMult);
|
|
67
|
+
geo.computeBoundingBox();
|
|
68
|
+
const box = geo.boundingBox;
|
|
69
|
+
const center = box.getCenter(new THREE.Vector3());
|
|
70
|
+
const size = box.getSize(new THREE.Vector3());
|
|
71
|
+
geo.translate(-center.x, -center.y, -center.z);
|
|
72
|
+
geo.computeVertexNormals();
|
|
73
|
+
geo.computeBoundingSphere();
|
|
74
|
+
const signedVol = computeSignedGeometryVolume(geo);
|
|
75
|
+
const aabbVol = Math.max(1e-6, size.x * size.y * size.z * .52);
|
|
76
|
+
const volumeM3 = signedVol > aabbVol * .05 ? signedVol : aabbVol;
|
|
77
|
+
const massKg = volumeM3 * density;
|
|
78
|
+
const boundingRadiusM = geo.boundingSphere?.radius ?? Math.hypot(size.x, size.y, size.z) * .5;
|
|
79
|
+
results.push({
|
|
80
|
+
index: results.length,
|
|
81
|
+
geometry: geo,
|
|
82
|
+
material: baseMaterial.clone(),
|
|
83
|
+
sheetOffset: [
|
|
84
|
+
center.x,
|
|
85
|
+
center.y,
|
|
86
|
+
center.z
|
|
87
|
+
],
|
|
88
|
+
sizeMeters: [
|
|
89
|
+
size.x,
|
|
90
|
+
size.y,
|
|
91
|
+
size.z
|
|
92
|
+
],
|
|
93
|
+
boundingRadiusM,
|
|
94
|
+
volumeM3,
|
|
95
|
+
massKg,
|
|
96
|
+
mu: massKg * gConst,
|
|
97
|
+
hullVertices: sampleHullVertices(geo, 96)
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
export { SUBSTRATE_DENSITY_KG_M3, splitSheetSceneIntoJunkIslands };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=junkSheetSplitter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junkSheetSplitter.js","names":[],"sources":["../../src/junk/junkSheetSplitter.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { extractMeshIslands } from \"../importer/meshIslands.js\";\nimport { G_SI } from \"../physics/nBodyGravity.js\";\n\n/** Bulk SI material densities (kg / m^3) for celestial and structural junk substrates. */\nexport const SUBSTRATE_DENSITY_KG_M3 = Object.freeze({\n silicateRock: 2700,\n waterIce: 917,\n ironNickel: 7800,\n aluminumAlloy: 2710,\n} as const);\n\nexport interface SplitJunkIsland {\n readonly index: number;\n readonly geometry: THREE.BufferGeometry;\n readonly material: THREE.Material;\n /** Original centroid offset in the parent sheet scene (meters). */\n readonly sheetOffset: readonly [number, number, number];\n /** Axis-aligned size of the centered island geometry (meters). */\n readonly sizeMeters: readonly [number, number, number];\n /** Bounding sphere radius around local origin (meters). */\n readonly boundingRadiusM: number;\n /** Signed closed-mesh volume (or 0.52 * AABB fallback for open shells) in m^3. */\n readonly volumeM3: number;\n /** Physical mass m = density * volume (kg). */\n readonly massKg: number;\n /** Standard gravitational parameter mu = G * m (m^3 / s^2). */\n readonly mu: number;\n /** Deduplicated local vertex positions for Rapier `ConvexHullCollider`. */\n readonly hullVertices: Float32Array;\n}\n\nfunction computeSignedGeometryVolume(geo: THREE.BufferGeometry): number {\n const pos = geo.getAttribute(\"position\");\n if (!pos || pos.count < 3) return 0;\n const idx = geo.getIndex();\n const triCount = idx ? Math.floor(idx.count / 3) : Math.floor(pos.count / 3);\n let vol6 = 0;\n for (let t = 0; t < triCount; t++) {\n const i0 = idx ? idx.getX(t * 3) : t * 3;\n const i1 = idx ? idx.getX(t * 3 + 1) : t * 3 + 1;\n const i2 = idx ? idx.getX(t * 3 + 2) : t * 3 + 2;\n const ax = pos.getX(i0), ay = pos.getY(i0), az = pos.getZ(i0);\n const bx = pos.getX(i1), by = pos.getY(i1), bz = pos.getZ(i1);\n const cx = pos.getX(i2), cy = pos.getY(i2), cz = pos.getZ(i2);\n vol6 += ax * (by * cz - bz * cy) + ay * (bz * cx - bx * cz) + az * (bx * cy - by * cx);\n }\n return Math.abs(vol6) / 6;\n}\n\nfunction sampleHullVertices(geo: THREE.BufferGeometry, maxVerts = 96): Float32Array {\n const pos = geo.getAttribute(\"position\");\n if (!pos || pos.count === 0) return new Float32Array(0);\n const step = Math.max(1, Math.ceil(pos.count / maxVerts));\n const out: number[] = [];\n for (let i = 0; i < pos.count; i += step) {\n out.push(pos.getX(i), pos.getY(i), pos.getZ(i));\n }\n return new Float32Array(out);\n}\n\n/**\n * Splits a multi-part sheet `.glb` scene (such as `asteroid_shrapnel.glb`) into independent,\n * origin-centered physical `KolmoJunk` islands with exact SI volume, mass, convex-hull\n * vertices, and self-gravity `mu`.\n */\nexport function splitSheetSceneIntoJunkIslands(\n root: THREE.Object3D,\n options?: {\n readonly densityKgPerM3?: number;\n readonly scaleMultiplier?: number;\n readonly minTriangles?: number;\n readonly gravitationalConstant?: number;\n },\n): SplitJunkIsland[] {\n const density = Math.max(1, options?.densityKgPerM3 ?? SUBSTRATE_DENSITY_KG_M3.silicateRock);\n const scaleMult = Math.max(1e-4, options?.scaleMultiplier ?? 1);\n const minTris = Math.max(4, options?.minTriangles ?? 8);\n const gConst = options?.gravitationalConstant ?? G_SI;\n\n let firstMat: THREE.Material | null = null;\n root.traverse((obj) => {\n if (firstMat) return;\n const m = obj as THREE.Mesh;\n if (m.isMesh && m.material) {\n firstMat = Array.isArray(m.material) ? m.material[0] : m.material;\n }\n });\n const baseMaterial = firstMat ?? new THREE.MeshStandardMaterial({ color: \"#8b95a5\", roughness: 0.86, flatShading: true });\n\n const rawIslands = extractMeshIslands(root);\n const results: SplitJunkIsland[] = [];\n for (const isl of rawIslands) {\n if (isl.triangleIndices.length < minTris) {\n isl.geometry.dispose();\n continue;\n }\n const geo = isl.geometry;\n if (scaleMult !== 1) geo.scale(scaleMult, scaleMult, scaleMult);\n geo.computeBoundingBox();\n const box = geo.boundingBox!;\n const center = box.getCenter(new THREE.Vector3());\n const size = box.getSize(new THREE.Vector3());\n geo.translate(-center.x, -center.y, -center.z);\n geo.computeVertexNormals();\n geo.computeBoundingSphere();\n\n const signedVol = computeSignedGeometryVolume(geo);\n const aabbVol = Math.max(1e-6, size.x * size.y * size.z * 0.52);\n const volumeM3 = signedVol > aabbVol * 0.05 ? signedVol : aabbVol;\n const massKg = volumeM3 * density;\n const boundingRadiusM = geo.boundingSphere?.radius ?? Math.hypot(size.x, size.y, size.z) * 0.5;\n\n results.push({\n index: results.length,\n geometry: geo,\n material: baseMaterial.clone(),\n sheetOffset: [center.x, center.y, center.z],\n sizeMeters: [size.x, size.y, size.z],\n boundingRadiusM,\n volumeM3,\n massKg,\n mu: massKg * gConst,\n hullVertices: sampleHullVertices(geo, 96),\n });\n }\n return results;\n}\n"],"mappings":";;;;;AAKA,IAAa,0BAA0B,OAAO,OAAO;CACjD,cAAc;CACd,UAAU;CACV,YAAY;CACZ,eAAe;AACnB,CAAU;AAsBV,SAAS,4BAA4B,KAAmC;CACpE,MAAM,MAAM,IAAI,aAAa,UAAU;CACvC,IAAI,CAAC,OAAO,IAAI,QAAQ,GAAG,OAAO;CAClC,MAAM,MAAM,IAAI,SAAS;CACzB,MAAM,WAAW,MAAM,KAAK,MAAM,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,IAAI,QAAQ,CAAC;CAC3E,IAAI,OAAO;CACX,KAAK,IAAI,IAAI,GAAG,IAAI,UAAU,KAAK;EAC/B,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI;EACvC,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI;EAC/C,MAAM,KAAK,MAAM,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI;EAC/C,MAAM,KAAK,IAAI,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE;EAC5D,MAAM,KAAK,IAAI,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE;EAC5D,MAAM,KAAK,IAAI,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,EAAE;EAC5D,QAAQ,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AS,QAAQ;GACrB;EACJ;EACA,MAAM,MAAM,IAAI;EAChB,IAAI,cAAc,GAAG,IAAI,MAAM,WAAW,WAAW,SAAS;EAC9D,IAAI,mBAAmB;EACvB,MAAM,MAAM,IAAI;EAChB,MAAM,SAAS,IAAI,UAAU,IAAI,MAAM,QAAQ,CAAC;EAChD,MAAM,OAAO,IAAI,QAAQ,IAAI,MAAM,QAAQ,CAAC;EAC5C,IAAI,UAAU,CAAC,OAAO,GAAG,CAAC,OAAO,GAAG,CAAC,OAAO,CAAC;EAC7C,IAAI,qBAAqB;EACzB,IAAI,sBAAsB;EAE1B,MAAM,YAAY,4BAA4B,GAAG;EACjD,MAAM,UAAU,KAAK,IAAI,MAAM,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,GAAI;EAC9D,MAAM,WAAW,YAAY,UAAU,MAAO,YAAY;EAC1D,MAAM,SAAS,WAAW;EAC1B,MAAM,kBAAkB,IAAI,gBAAgB,UAAU,KAAK,MAAM,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,IAAI;EAE3F,QAAQ,KAAK;GACT,OAAO,QAAQ;GACf,UAAU;GACV,UAAU,aAAa,MAAM;GAC7B,aAAa;IAAC,OAAO;IAAG,OAAO;IAAG,OAAO;GAAC;GAC1C,YAAY;IAAC,KAAK;IAAG,KAAK;IAAG,KAAK;GAAC;GACnC;GACA;GACA;GACA,IAAI,SAAS;GACb,cAAc,mBAAmB,KAAK,EAAE;EAC5C,CAAC;CACL;CACA,OAAO;AACX"}
|
package/dist/physics/index.d.ts
CHANGED
|
@@ -2,15 +2,18 @@ import React, { type ReactNode, type RefObject } from "react";
|
|
|
2
2
|
import * as THREE from "three";
|
|
3
3
|
import { type PhysicsWorldProps } from "@khr3/core";
|
|
4
4
|
import { type World } from "koota";
|
|
5
|
+
import { G_SI, computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity, resolveAttractorMu, type KolmoGravityAttractor, type KolmoNBodyGravity } from "./nBodyGravity.js";
|
|
6
|
+
export { G_SI, computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity, resolveAttractorMu, type KolmoGravityAttractor, type KolmoNBodyGravity, };
|
|
5
7
|
export type KolmoTimeControlValue = number | RefObject<number>;
|
|
6
8
|
export type KolmoPointGravity = {
|
|
7
9
|
readonly kind: "point";
|
|
8
10
|
readonly center: readonly [number, number, number];
|
|
9
11
|
readonly surfaceG: number;
|
|
10
12
|
readonly radius: number;
|
|
13
|
+
readonly inverseSquare?: boolean;
|
|
11
14
|
};
|
|
12
15
|
export type KolmoGravityCallback = (pos: THREE.Vector3, out: THREE.Vector3) => THREE.Vector3;
|
|
13
|
-
export type KolmoGravitySpec = "planar" | "zero" | "custom" | readonly [number, number, number] | KolmoPointGravity | KolmoGravityCallback;
|
|
16
|
+
export type KolmoGravitySpec = "planar" | "zero" | "custom" | readonly [number, number, number] | KolmoPointGravity | KolmoNBodyGravity | KolmoGravityCallback;
|
|
14
17
|
export declare const KolmoGravityContext: React.Context<boolean>;
|
|
15
18
|
export declare function useOptionalKootaWorld(): World | null;
|
|
16
19
|
export interface KolmoPhysicsProps extends Omit<PhysicsWorldProps, "gravity" | "debug" | "timeScale" | "maxDelta" | "children"> {
|
package/dist/physics/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { kolmoWorld } from "../engine/kolmoTraits.js";
|
|
2
|
+
import { G_SI, computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity, resolveAttractorMu } from "./nBodyGravity.js";
|
|
2
3
|
import { Suspense, createContext, useContext, useLayoutEffect, useMemo } from "react";
|
|
3
4
|
import * as THREE from "three";
|
|
4
5
|
import "koota";
|
|
@@ -21,6 +22,9 @@ function isGravityTuple(g) {
|
|
|
21
22
|
function isPointGravity(g) {
|
|
22
23
|
return typeof g === "object" && !Array.isArray(g) && "kind" in g && g.kind === "point";
|
|
23
24
|
}
|
|
25
|
+
function isNBodyGravity(g) {
|
|
26
|
+
return typeof g === "object" && !Array.isArray(g) && "kind" in g && g.kind === "nbody";
|
|
27
|
+
}
|
|
24
28
|
var _gravTmp = new THREE.Vector3();
|
|
25
29
|
function KolmoPhysics({ gravity = "planar", paused = false, timeScale = 1, maxDelta, physicsDebug = false, world = null, children, ...physicsProps }) {
|
|
26
30
|
const outerWorld = useOptionalKootaWorld();
|
|
@@ -29,15 +33,19 @@ function KolmoPhysics({ gravity = "planar", paused = false, timeScale = 1, maxDe
|
|
|
29
33
|
const isTuple = isGravityTuple(gravity);
|
|
30
34
|
const isCustomLiteral = gravity === "custom";
|
|
31
35
|
const isPoint = isPointGravity(gravity);
|
|
32
|
-
const
|
|
36
|
+
const isNBody = isNBodyGravity(gravity);
|
|
37
|
+
const isCustomGravity = isCallback || isPoint || isNBody || isCustomLiteral;
|
|
33
38
|
const gx = isTuple ? gravity[0] : 0;
|
|
34
39
|
const gy = isTuple ? gravity[1] : -9.81;
|
|
35
40
|
const gz = isTuple ? gravity[2] : 0;
|
|
36
41
|
const cx = isPoint ? gravity.center[0] : 0;
|
|
37
42
|
const cy = isPoint ? gravity.center[1] : 0;
|
|
38
43
|
const cz = isPoint ? gravity.center[2] : 0;
|
|
44
|
+
const pointRadius = isPoint ? gravity.radius : 1;
|
|
45
|
+
const pointInverseSq = isPoint ? Boolean(gravity.inverseSquare) : false;
|
|
39
46
|
const surfaceG = isPoint ? gravity.surfaceG : gravity === "zero" ? 0 : 9.81;
|
|
40
47
|
const gravityFn = isCallback ? gravity : null;
|
|
48
|
+
const nBodySpec = isNBody ? gravity : null;
|
|
41
49
|
const rapierGravity = useMemo(() => isTuple ? [
|
|
42
50
|
gx,
|
|
43
51
|
gy,
|
|
@@ -59,22 +67,40 @@ function KolmoPhysics({ gravity = "planar", paused = false, timeScale = 1, maxDe
|
|
|
59
67
|
gravity === "zero"
|
|
60
68
|
]);
|
|
61
69
|
useLayoutEffect(() => {
|
|
62
|
-
if (isCustomLiteral || !isCallback && !isPoint) return;
|
|
70
|
+
if (isCustomLiteral || !isCallback && !isPoint && !isNBody) return;
|
|
63
71
|
const setField = useCustomGravity.getState().setGravityField;
|
|
64
72
|
if (gravityFn) setField((pos) => gravityFn(pos, _gravTmp));
|
|
65
|
-
else if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
else if (nBodySpec) setField((pos) => evaluateNBodyGravity(pos, nBodySpec.attractors, _gravTmp, nBodySpec.gravitationalConstant));
|
|
74
|
+
else if (isPoint) {
|
|
75
|
+
if (pointInverseSq) {
|
|
76
|
+
const single = [{
|
|
77
|
+
position: [
|
|
78
|
+
cx,
|
|
79
|
+
cy,
|
|
80
|
+
cz
|
|
81
|
+
],
|
|
82
|
+
surfaceG,
|
|
83
|
+
radius: pointRadius
|
|
84
|
+
}];
|
|
85
|
+
setField((pos) => evaluateNBodyGravity(pos, single, _gravTmp));
|
|
86
|
+
} else setField((pos) => {
|
|
87
|
+
_gravTmp.set(pos.x - cx, pos.y - cy, pos.z - cz);
|
|
88
|
+
const lenSq = _gravTmp.lengthSq();
|
|
89
|
+
return lenSq < 1e-8 ? _gravTmp.set(0, -surfaceG, 0) : _gravTmp.multiplyScalar(-surfaceG / Math.sqrt(lenSq));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
70
92
|
}, [
|
|
71
93
|
isCustomLiteral,
|
|
72
94
|
isCallback,
|
|
73
95
|
isPoint,
|
|
96
|
+
isNBody,
|
|
74
97
|
gravityFn,
|
|
98
|
+
nBodySpec,
|
|
75
99
|
cx,
|
|
76
100
|
cy,
|
|
77
101
|
cz,
|
|
102
|
+
pointRadius,
|
|
103
|
+
pointInverseSq,
|
|
78
104
|
surfaceG
|
|
79
105
|
]);
|
|
80
106
|
const content = /* @__PURE__ */ jsx(KolmoGravityContext.Provider, {
|
|
@@ -100,6 +126,6 @@ function KolmoPhysics({ gravity = "planar", paused = false, timeScale = 1, maxDe
|
|
|
100
126
|
function useIsKolmoCustomGravity() {
|
|
101
127
|
return useContext(KolmoGravityContext);
|
|
102
128
|
}
|
|
103
|
-
export { KolmoGravityContext, KolmoPhysics, useIsKolmoCustomGravity, useOptionalKootaWorld };
|
|
129
|
+
export { G_SI, KolmoGravityContext, KolmoPhysics, computeCircularOrbitSpeed, createNBodyGravityField, evaluateNBodyGravity, resolveAttractorMu, useIsKolmoCustomGravity, useOptionalKootaWorld };
|
|
104
130
|
|
|
105
131
|
//# sourceMappingURL=index.js.map
|