@pinkaphant/kolmo 0.1.2 → 0.2.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.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -14
  3. package/bin/kolmo.mjs +22 -54
  4. package/dist/body/HeldItem.js +171 -0
  5. package/dist/body/KhrBody.js +171 -0
  6. package/dist/body/bodySi.d.ts +0 -11
  7. package/dist/body/bodySi.js +52 -0
  8. package/dist/body/index.d.ts +1 -1
  9. package/dist/body/index.js +4 -1
  10. package/dist/engine/index.d.ts +4 -4
  11. package/dist/engine/index.js +12 -3
  12. package/dist/engine/kolmoActor.d.ts +11 -4
  13. package/dist/engine/kolmoActor.js +197 -0
  14. package/dist/engine/kolmoInput.d.ts +17 -0
  15. package/dist/engine/kolmoInput.js +78 -0
  16. package/dist/engine/kolmoIsland.d.ts +3 -1
  17. package/dist/engine/kolmoIsland.js +311 -0
  18. package/dist/engine/kolmoLongDrive.js +223 -0
  19. package/dist/engine/kolmoRigs.js +59 -0
  20. package/dist/engine/kolmoStore.d.ts +53 -27
  21. package/dist/engine/kolmoStore.js +211 -0
  22. package/dist/engine/kolmoSurface.d.ts +1 -1
  23. package/dist/engine/kolmoSurface.js +182 -0
  24. package/dist/engine/kolmoVehicle.d.ts +3 -1
  25. package/dist/engine/kolmoVehicle.js +250 -0
  26. package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
  27. package/dist/engine/kolmoVehicleDriver.js +29 -0
  28. package/dist/engine/kolmoWorld.d.ts +7 -15
  29. package/dist/engine/kolmoWorld.js +139 -0
  30. package/dist/engine/longDriveKit.d.ts +4 -2
  31. package/dist/engine/longDriveKit.js +254 -0
  32. package/dist/engine/mainlandMacroCell.d.ts +3 -7
  33. package/dist/engine/mainlandMacroCell.js +247 -0
  34. package/dist/engine/shiftedFixedBody.d.ts +13 -0
  35. package/dist/engine/shiftedFixedBody.js +64 -0
  36. package/dist/importer/ChopShopPanel.js +465 -0
  37. package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
  38. package/dist/importer/DomainWorkshopPanel.js +385 -0
  39. package/dist/importer/GateHudBar.js +312 -0
  40. package/dist/importer/GlbImportGate.js +250 -0
  41. package/dist/importer/ImperativeVehicleRig.js +336 -0
  42. package/dist/importer/ImporterPlinthUikitTags.js +112 -0
  43. package/dist/importer/Step1CalibrationPlinth.js +275 -0
  44. package/dist/importer/Step2UniversalPad.js +244 -0
  45. package/dist/importer/VfxEmitterPool.js +91 -0
  46. package/dist/importer/chopShopActions.d.ts +22 -2
  47. package/dist/importer/chopShopActions.js +232 -0
  48. package/dist/importer/gateStore.d.ts +1 -1
  49. package/dist/importer/gateStore.js +92 -0
  50. package/dist/importer/glbNormalizer.js +133 -0
  51. package/dist/importer/importerWebMcp.d.ts +17 -6
  52. package/dist/importer/importerWebMcp.js +343 -0
  53. package/dist/importer/index.js +22 -3
  54. package/dist/importer/khrCompiler.d.ts +1 -1
  55. package/dist/importer/khrCompiler.js +434 -0
  56. package/dist/importer/launcherBake.js +51 -0
  57. package/dist/importer/meshIslands.d.ts +1 -1
  58. package/dist/importer/meshIslands.js +301 -0
  59. package/dist/importer/surfaceCutter.js +254 -0
  60. package/dist/importer/surfaceTopology.js +183 -0
  61. package/dist/importer/universalGateBake.js +162 -0
  62. package/dist/importer/usdToGlb.js +294 -0
  63. package/dist/importer/useChopShopController.d.ts +11 -2
  64. package/dist/importer/useChopShopController.js +364 -0
  65. package/dist/importer/vehiclePanelAnim.js +214 -0
  66. package/dist/importer/wheelAxlePairing.d.ts +1 -2
  67. package/dist/importer/wheelAxlePairing.js +102 -0
  68. package/dist/index.d.ts +1 -1
  69. package/dist/index.js +69 -13
  70. package/dist/junk/DestructibleTarget.js +154 -0
  71. package/dist/junk/KolmoJunk.js +65 -0
  72. package/dist/junk/ShardPieces.d.ts +6 -4
  73. package/dist/junk/ShardPieces.js +74 -0
  74. package/dist/junk/TargetDecals.js +51 -0
  75. package/dist/junk/bvhShatter.js +55 -0
  76. package/dist/junk/bvhTriCollector.js +78 -0
  77. package/dist/junk/index.js +11 -1
  78. package/dist/junk/junkGeometry.js +69 -0
  79. package/dist/junk/junkImportSanitize.js +54 -0
  80. package/dist/junk/junkImporter.js +95 -0
  81. package/dist/junk/junkLabelCanvas.js +67 -0
  82. package/dist/junk/junkLabels.js +35 -0
  83. package/dist/junk/targetHelpers.js +103 -0
  84. package/dist/junk/targetHitLogic.js +128 -0
  85. package/dist/junk/useTargetAssets.js +102 -0
  86. package/dist/physics/index.d.ts +26 -0
  87. package/dist/physics/index.js +84 -0
  88. package/dist/schema/kolmoSchema.d.ts +2 -1
  89. package/dist/schema/kolmoSchema.js +184 -0
  90. package/dist/shaders/celestialBackdrop.d.ts +1 -1
  91. package/dist/shaders/celestialBackdrop.js +344 -0
  92. package/dist/shaders/index.d.ts +0 -1
  93. package/dist/shaders/index.js +9 -1
  94. package/dist/shaders/plumeAndSparkle.js +271 -0
  95. package/dist/shaders/ps2GlslShared.d.ts +1 -1
  96. package/dist/shaders/ps2GlslShared.js +3 -0
  97. package/dist/shaders/ps2MaterialsTSL.js +65 -0
  98. package/dist/shaders/ps2MaterialsWebGL.js +40 -0
  99. package/dist/shaders/ps2RoadWebGL.js +101 -0
  100. package/dist/shaders/ps2TerrainWebGL.js +54 -0
  101. package/dist/shaders/ps2Textures.js +224 -0
  102. package/dist/shaders/retroPalettes.js +188 -0
  103. package/dist/shaders/retroShader.d.ts +31 -3
  104. package/dist/shaders/retroShader.js +249 -0
  105. package/dist/shaders/tsl.d.ts +1 -0
  106. package/dist/shaders/tsl.js +1 -0
  107. package/dist/vite/index.d.ts +15 -0
  108. package/dist/vite/index.js +90 -0
  109. package/dist/world/frontage.js +32 -0
  110. package/dist/world/index.d.ts +1 -1
  111. package/dist/world/index.js +11 -3
  112. package/dist/world/infiniteWorld2D.js +244 -0
  113. package/dist/world/island.js +201 -0
  114. package/dist/world/macroCellSchema.js +27 -0
  115. package/dist/world/macroKnightAStar.js +171 -0
  116. package/dist/world/random.js +33 -0
  117. package/dist/world/road.js +136 -0
  118. package/dist/world/roadRibbon.d.ts +6 -6
  119. package/dist/world/roadRibbon.js +161 -0
  120. package/dist/world/terrain.js +87 -0
  121. package/dist/world/worldTypes.js +111 -0
  122. package/package.json +32 -18
  123. package/dist/body-B7FTf67o.js +0 -362
  124. package/dist/engine-BeKvBM8d.js +0 -1745
  125. package/dist/importer-B2-S-N_e.js +0 -5113
  126. package/dist/junk-B4bC1zAl.js +0 -1049
  127. package/dist/kolmoSurface-DTnrFXH0.js +0 -558
  128. package/dist/shaders-GS71Ek1A.js +0 -1383
  129. package/dist/world-PRWPYrlx.js +0 -947
  130. package/dist/worldTypes-Z0KfdCd0.js +0 -226
package/dist/index.js CHANGED
@@ -1,13 +1,69 @@
1
- import { C as ee, D as te, E as e, S as t, T as n, _ as ne, a as r, b as i, c as a, d as o, f as re, g as ie, h as ae, i as oe, l as s, m as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h, v as g, w as _, x as v, y } from "./engine-BeKvBM8d.js";
2
- import { a as b, c as x, d as S, f as C, i as w, l as T, n as E, o as D, r as O, s as k, t as A, u as j } from "./worldTypes-Z0KfdCd0.js";
3
- import { a as M, c as N, d as P, i as F, l as I, n as L, o as R, r as z, s as B, t as V, u as H } from "./kolmoSurface-DTnrFXH0.js";
4
- import { A as U, B as W, C as G, D as K, E as q, F as se, I as ce, L as le, M as ue, N as de, O as fe, P as pe, R as me, S as he, T as ge, V as _e, _ as ve, a as ye, b as be, c as xe, d as Se, f as J, g as Y, h as Ce, i as we, j as Te, k as Ee, l as De, m as Oe, n as ke, o as Ae, p as X, r as je, s as Me, t as Ne, u as Pe, v as Fe, w as Ie, x as Le, y as Re, z as ze } from "./shaders-GS71Ek1A.js";
5
- import { $ as Be, A as Ve, B as He, C as Ue, D as We, E as Ge, F as Ke, G as qe, H as Je, I as Ye, J as Xe, K as Ze, L as Qe, M as $e, N as et, O as tt, P as nt, Q as rt, R as it, S as at, T as ot, U as st, V as ct, W as lt, X as ut, Y as dt, Z as ft, _ as pt, a as mt, b as ht, c as gt, d as _t, et as vt, f as yt, g as bt, h as xt, i as St, j as Ct, k as wt, l as Tt, m as Et, n as Dt, nt as Ot, o as kt, p as At, q as Z, r as jt, s as Mt, t as Q, tt as Nt, u as Pt, v as Ft, w as It, x as Lt, y as Rt, z as zt } from "./importer-B2-S-N_e.js";
6
- import { _ as Bt, a as Vt, b as Ht, c as Ut, d as Wt, f as Gt, g as Kt, h as qt, i as Jt, l as Yt, m as Xt, n as Zt, o as Qt, p as $t, r as en, s as tn, t as nn, u as rn, v as an, y as on } from "./world-PRWPYrlx.js";
7
- import { C as sn, S as cn, _ as ln, a as un, b as dn, c as fn, d as pn, f as mn, g as hn, h as gn, i as _n, l as vn, m as yn, n as bn, o as xn, p as Sn, r as Cn, s as wn, t as $, u as Tn, v as En, w as Dn, x as On, y as kn } from "./junk-B4bC1zAl.js";
8
- import { a as An, c as jn, d as Mn, i as Nn, l as Pn, n as Fn, o as In, r as Ln, s as Rn, t as zn, u as Bn } from "./body-B7FTf67o.js";
9
- import { DOOR_HINGE_SPEC as Vn, Ex as Hn, ROOT3 as Un, buildFootprint as Wn, canPlace as Gn, instanceBatches as Kn, latticePose as qn, planSettlement as Jn, poseEq as Yn, poseFromJSON as Xn, poseToFloat as Zn, poseToJSON as Qn, snapPose as $n, socketFor as er, triangleCorners as tr, vToFloat as nr, worldSockets as rr } from "@khr3/c12";
10
- import { DEFAULT_VAULT_URL as ir, KOLMO_ASSETS_URL as ar, VAULT_CARS as or, VAULT_CATALOG as sr, VAULT_CITY as cr, VAULT_WEAPONS as lr, createAssetVault as ur, inspectGlbBuffer as dr, normalizeGlbBuffer as fr, vaultAssetUrl as pr } from "@khr3/assets";
11
- import { CARBINE_556 as mr, LAUNCHER_RECIPES as hr, PISTOL_9MM as gr, SHOTGUN_12G as _r, attachModule as vr, createLauncherState as yr, detachModule as br, findLauncherRecipe as xr, planLauncher as Sr, stepLauncher as Cr } from "@khr3/launchers";
12
- import { COUPE_2DOOR as wr, FLEET as Tr, SEDAN_4DOOR as Er, VEHICLE_DOMAINS as Dr, VEHICLE_DOMAIN_SPECS as Or, carUrl as kr, findCar as Ar, fleetByDomain as jr, planCar as Mr } from "@khr3/vehicles";
13
- export { De as ATMO_FRAG, Pe as ATMO_VERT, a as Actor, a as KolmoActor, c as ActorTrait, Ln as BODY_MOVE_TUNE, Nn as BODY_SI, An as BODY_SOCKET_IDS, gn as BOTTLE_HEIGHT, Qt as C12TileKind, gt as C12_TICK_M, tn as C12_TILE_M, hn as CAN_LOD_THRESHOLD_M, mr as CARBINE_556, lt as CHOP_ROLES, wr as COUPE_2DOOR, o as Canvas, o as KolmoCanvas, et as ChopShopPanel, It as DAMP_ZETA, ir as DEFAULT_VAULT_URL, Vn as DOOR_HINGE_SPEC, bn as DestructibleTarget, wt as DomainWorkshopPanel, Y as EmitterRig, Y as KolmoEmitterRig, Hn as Ex, J as Exoplanet, J as KolmoExoplanet, Tr as FLEET, Ut as FLOATING_ORIGIN_STEP_M, ot as FREQ_HZ, ae as FloatingBodyTrait, Le as GLSL_BAYER_RGB555, he as GLSL_RETRO_QUANTIZE, Ue as GateHudBar, Q as GlbImportGate, Q as ImporterWorkbench, zn as HeldItem, Mt as ImperativeVehicleRig, Vt as InfiniteLongDrivePlanner, ie as InteractableTrait, r as Island, r as KolmoIsland, $ as Junk, $ as KolmoJunk, Se as KEY_SUN_DIRECTION, ar as KOLMO_ASSETS_URL, N as KOLMO_EXTENSION_NAME, h as KOLMO_KEY_MAP, Fn as KhrBody, re as KolmoGravityContext, m as KolmoLongDrive, m as LongDrive, V as KolmoProp, V as Prop, X as KolmoSkybox, X as Skybox, L as KolmoSurface, L as Surface, s as KolmoVehicle, s as Vehicle, d as KolmoWorld, d as World, hr as LAUNCHER_RECIPES, Yt as MACRO_SIZE_M, de as PALETTE_CRUNCHY_16, pe as PALETTE_CRUNCHY_64, ve as PARTICLE_FRAG, Fe as PARTICLE_VERT, gr as PISTOL_9MM, Re as PLUME_FRAG, be as PLUME_VERT, G as PS1_SNAP_RESOLUTION, ne as PilotLink, se as RETRO_COLOR_MODES, Ie as RETRO_PRESETS, ge as RETRO_UNIFORMS, Oe as RING_MOONLET_COUNT, Un as ROOT3, n as RetroViewportSync, e as RoomEnvRig, Er as SEDAN_4DOOR, _r as SHOTGUN_12G, b as SHOULDER_K, Ae as SPLAT_LAYER, A as SeededSimplex2D, te as ShadowSnapRig, mn as ShardPieces, oe as ShiftedFixedBody, E as SplitMix32, Ft as Step1CalibrationPlinth, kt as Step2UniversalPad, rn as TILES_PER_MACRO, ln as TIN_CAN_HEIGHT, En as TIN_CAN_RADIUS, Tn as TargetDecals, Tt as UNIFIED_ANCHOR_NAMES, or as VAULT_CARS, sr as VAULT_CATALOG, cr as VAULT_CITY, lr as VAULT_WEAPONS, Dr as VEHICLE_DOMAINS, Or as VEHICLE_DOMAIN_SPECS, g as VehicleTrait, mt as VfxEmitterPool, y as WorldSessionTrait, q as applyPs1Material, ce as applyRetroFilteringToMaterial, K as applyRetroMaterial, le as applyRetroTextureFiltering, fe as applySceneRetroMaterials, un as applySegmentsToImportedRoot, vr as attachModule, Ct as bakeArticulatedLauncherGlb, Dt as bakeUniversalGateGlb, O as bakeWorldSplatMaps, In as bodyEyeOffsetY, Rn as bodyRestCenterY, jn as bodySpawnPosition, Pn as bodyStandingHeight, nn as buildCarvedTerrainGeometry, Gt as buildDodecagonalCivicHub, Wn as buildFootprint, kn as buildGlassBottleGeometry, Zt as buildHighwayAsphaltTexture, ht as buildImporterWebMcpTools, $e as buildLauncherSceneFromPlan, me as buildPaletteLutData, F as buildPatchPreviewEmitters, en as buildRoadRibbonGeometry, Ke as buildSelectionOverlayGeometry, qe as buildSurfaceTopology, dn as buildTinCanGeometry, Gn as canPlace, kr as carUrl, x as childSeed, Bt as closedRoadFromPoints, yn as collectValidTris, nt as compileKhrAssetGlb, Pt as computeC12Metrics, M as computeChopPartHinge, u as computeIslandSpawnPose, l as computeLongDriveBridgeheadSpawn, f as computeLongDriveMainlandSpawn, ze as computeRetroDpr, jt as convertUsdToGlb, On as countGeometryTriangles, ur as createAssetVault, I as createDefaultSignals, Ye as createFleet12GonWheelGroup, cn as createGlassBottleMaterial, yr as createLauncherState, Ne as createPS2RoadMaterialTSL, ye as createPS2RoadMaterialWebGL, ke as createPS2TerrainMaterialTSL, we as createPS2TerrainMaterialWebGL, Me as createPS2WorldTextures, sn as createTinCanMaterials, R as createVehiclePanelAnimator, H as decodeKolmoRig, _t as defaultTargetMeters, br as detachModule, yt as detectSceneAnchors, fn as disposeImportedRoot, Ve as enforceRetroPersonMaterials, vn as ensureMeshAttributes, i as ensureWorldSession, dt as extractMeshIslands, T as fbm2, Ar as findCar, xr as findLauncherRecipe, Qe as findMirrorIslandId, jr as fleetByDomain, Ze as floodFillByCrease, Kt as frontage, Ge as gateTelemetry, xe as generatePS2DetailSlices, pn as getBulletHoleTexture, p as getCachedIslandPlan, W as getColorQuantVector, Z as getIslandTopology, Lt as getNavigatorModelContext, _e as getPaletteLutTexture, Cn as getProceduralLabelTexture, Ee as getRetroPreset, U as getRetroShaderUniforms, an as growRoad, w as hashSeed, dr as inspectGlbBuffer, Kn as instanceBatches, We as isGateStep1Unlocked, St as isUsdFileName, At as khrBoxToRapierHalfExtents, v as kolmoActions, t as kolmoTelemetry, ee as kolmoWorld, qn as latticePose, _n as loadCustomLabelTexture, xn as loadImportedGlbUrl, Xt as makeIslandHeightfn, Rt as makeStarterDomainScene, D as makeTerrain, on as maxGrade, Et as measureAssemblyCalibration, xt as measureNormalizedSceneCalibration, Be as measureSelection, Xe as mirrorTriangles, je as mountPS2WorldMeshes, j as mulberry32, B as normalToMinusZQuaternion, fr as normalizeGlbBuffer, ut as normalizeSceneToSi, wn as parseImportedGlbBuffer, it as peelIslandSelection, Mr as planCar, Jt as planDirtSpurs, qt as planIslandWorld, Sr as planLauncher, Jn as planSettlement, Ce as populateMoonletMatrices, Yn as poseEq, Xn as poseFromJSON, Zn as poseToFloat, Qn as poseToJSON, zt as previewLoopPolyline, Wt as quantizeFloatingOrigin192, He as refineMeshAlongLoop, ct as remapIslandIds, Ht as roadFromPoints, $t as routeMacroKnightAStar, k as sampleHeightfield, S as seedFrom, Dn as selectCanLod, Je as selectFacesByClick, st as selectFacesByLoop, ft as separateVehicleMeshes, rt as sliceMeshTriangles, bt as snapMetersToC12, $n as snapPose, er as socketFor, Sn as splitObjectIntoShards, P as stampKolmoNodesIntoGlb, Bn as stepCameraSync, Cr as stepLauncher, vt as suggestCarAxles, Nt as suggestMotorcycleWheels, Te as syncRetroUniforms, ue as syncRetroViewport, Ot as toggleIslandSelection, z as togglePropJoint, tr as triangleCorners, _ as useActiveKolmoWorld, tt as useGateStore, at as useImporterWebMcp, nr as vToFloat, C as valueNoise2, pr as vaultAssetUrl, Mn as withExcludeCharacterRay, rr as worldSockets, pt as wrapSingleMeshWithPaperShellProxy };
1
+ import { KolmoCanvas as e, KolmoWorld as t } from "./engine/kolmoWorld.js";
2
+ import { PALETTE_CRUNCHY_16 as n, PALETTE_CRUNCHY_64 as r, RETRO_COLOR_MODES as i, applyRetroFilteringToMaterial as a, applyRetroTextureFiltering as o, buildPaletteLutData as ee, computeRetroDpr as te, getColorQuantVector as ne, getPaletteLutTexture as re } from "./shaders/retroPalettes.js";
3
+ import { GLSL_BAYER_RGB555 as ie, GLSL_RETRO_QUANTIZE as ae, PS1_SNAP_RESOLUTION as oe, RETRO_PRESETS as se, RETRO_UNIFORMS as ce, applyPs1Material as s, applyRetroMaterial as c, applySceneRetroMaterials as l, getRetroPreset as u, getRetroShaderUniforms as d, syncRetroUniforms as f, syncRetroViewport as p } from "./shaders/retroShader.js";
4
+ import { KolmoGravityContext as m, KolmoPhysics as h, useIsKolmoCustomGravity as g, useOptionalKootaWorld as _ } from "./physics/index.js";
5
+ import { EMPTY_KOLMO_INPUT as v, KOLMO_KEY_MAP as y, useKolmoInput as b } from "./engine/kolmoInput.js";
6
+ import { RetroViewportSync as x, RoomEnvRig as S, ShadowSnapRig as C } from "./engine/kolmoRigs.js";
7
+ import { ActorTrait as w, FloatingBodyTrait as T, InteractableTrait as E, PilotLink as D, VehicleTrait as O, WorldSessionTrait as k, ensureWorldSession as A, kolmoActions as j, kolmoTelemetry as M, kolmoWorld as N, readFloatingOriginAnchorXZ as P, shiftFloatingOriginEntities as F, useActiveKolmoWorld as I, useWorldTrait as L } from "./engine/kolmoStore.js";
8
+ import { KolmoVehicle as R } from "./engine/kolmoVehicle.js";
9
+ import { KolmoActor as z } from "./engine/kolmoActor.js";
10
+ import { buildPatchPreviewEmitters as B, computeChopPartHinge as V, createVehiclePanelAnimator as H, normalToMinusZQuaternion as U } from "./importer/vehiclePanelAnim.js";
11
+ import { KolmoProp as W, KolmoSurface as G, togglePropJoint as le } from "./engine/kolmoSurface.js";
12
+ import { KolmoIsland as K, computeIslandSpawnPose as ue, getCachedIslandPlan as de } from "./engine/kolmoIsland.js";
13
+ import { KolmoLongDrive as q, computeLongDriveBridgeheadSpawn as fe, computeLongDriveMainlandSpawn as pe } from "./engine/kolmoLongDrive.js";
14
+ import { childSeed as me, fbm2 as he, mulberry32 as ge, seedFrom as _e, valueNoise2 as ve } from "./world/random.js";
15
+ import { closedRoadFromPoints as ye, growRoad as be, maxGrade as xe, roadFromPoints as Se } from "./world/road.js";
16
+ import { SHOULDER_K as Ce, makeTerrain as we, sampleHeightfield as Te } from "./world/terrain.js";
17
+ import { frontage as Ee } from "./world/frontage.js";
18
+ import { makeIslandHeightfn as De, planIslandWorld as Oe } from "./world/island.js";
19
+ import { SeededSimplex2D as ke, SplitMix32 as Ae, bakeWorldSplatMaps as je, hashSeed as Me } from "./world/worldTypes.js";
20
+ import { buildDodecagonalCivicHub as Ne, routeMacroKnightAStar as Pe } from "./world/macroKnightAStar.js";
21
+ import { C12TileKind as Fe, C12_TILE_M as Ie, FLOATING_ORIGIN_STEP_M as Le, MACRO_SIZE_M as Re, TILES_PER_MACRO as ze, quantizeFloatingOrigin192 as Be } from "./world/macroCellSchema.js";
22
+ import { InfiniteLongDrivePlanner as Ve } from "./world/infiniteWorld2D.js";
23
+ import { buildCarvedTerrainGeometry as He, buildHighwayAsphaltTexture as Ue, buildRoadRibbonGeometry as We, planDirtSpurs as Ge } from "./world/roadRibbon.js";
24
+ import { ShiftedFixedBody as Ke } from "./engine/shiftedFixedBody.js";
25
+ import { ATMO_FRAG as qe, ATMO_VERT as Je, KEY_SUN_DIRECTION as Ye, KolmoExoplanet as J, KolmoSkybox as Y, RING_MOONLET_COUNT as Xe, populateMoonletMatrices as Ze } from "./shaders/celestialBackdrop.js";
26
+ import { SPLAT_LAYER as Qe, createPS2WorldTextures as $e, generatePS2DetailSlices as et } from "./shaders/ps2Textures.js";
27
+ import { createPS2RoadMaterialWebGL as tt } from "./shaders/ps2RoadWebGL.js";
28
+ import { createPS2TerrainMaterialWebGL as nt } from "./shaders/ps2TerrainWebGL.js";
29
+ import { BOTTLE_HEIGHT as rt, CAN_LOD_THRESHOLD_M as it, TIN_CAN_HEIGHT as at, TIN_CAN_RADIUS as ot, buildGlassBottleGeometry as st, buildTinCanGeometry as ct, countGeometryTriangles as lt, createGlassBottleMaterial as ut, createTinCanMaterials as dt, selectCanLod as ft } from "./junk/junkGeometry.js";
30
+ import { collectValidTris as pt } from "./junk/bvhTriCollector.js";
31
+ import { splitObjectIntoShards as mt } from "./junk/bvhShatter.js";
32
+ import { ShardPieces as ht } from "./junk/ShardPieces.js";
33
+ import { TargetDecals as gt, getBulletHoleTexture as _t } from "./junk/TargetDecals.js";
34
+ import { disposeImportedRoot as vt, ensureMeshAttributes as yt } from "./junk/junkImportSanitize.js";
35
+ import { applySegmentsToImportedRoot as bt, loadImportedGlbUrl as xt, parseImportedGlbBuffer as St } from "./junk/junkImporter.js";
36
+ import { getProceduralLabelTexture as Ct, loadCustomLabelTexture as wt } from "./junk/junkLabels.js";
37
+ import { DestructibleTarget as Tt } from "./junk/DestructibleTarget.js";
38
+ import { KolmoEmitterRig as X, PARTICLE_FRAG as Et, PARTICLE_VERT as Dt, PLUME_FRAG as Ot, PLUME_VERT as kt } from "./shaders/plumeAndSparkle.js";
39
+ import { KOLMO_EXTENSION_NAME as At, createDefaultSignals as Z, decodeKolmoRig as jt, inferKolmoSocketRole as Mt, stampKolmoNodesIntoGlb as Nt } from "./schema/kolmoSchema.js";
40
+ import { KolmoJunk as Q } from "./junk/KolmoJunk.js";
41
+ import { mountPS2WorldMeshes as Pt } from "./shaders/ps2MaterialsWebGL.js";
42
+ import { measureSelection as Ft, suggestCarAxles as It, toggleIslandSelection as Lt } from "./importer/wheelAxlePairing.js";
43
+ import { extractMeshIslands as Rt, normalizeSceneToSi as zt, separateVehicleMeshes as Bt, sliceMeshTriangles as Vt } from "./importer/meshIslands.js";
44
+ import { CHOP_ROLES as Ht, buildSurfaceTopology as Ut, floodFillByCrease as Wt, getIslandTopology as Gt, mirrorTriangles as Kt } from "./importer/surfaceTopology.js";
45
+ import { buildSelectionOverlayGeometry as qt, createFleet12GonWheelGroup as Jt, findMirrorIslandId as Yt, peelIslandSelection as Xt, previewLoopPolyline as Zt, refineMeshAlongLoop as Qt, remapIslandIds as $t, selectFacesByClick as en, selectFacesByLoop as tn } from "./importer/surfaceCutter.js";
46
+ import { ChopShopPanel as nn } from "./importer/ChopShopPanel.js";
47
+ import { BODY_SI as rn, BODY_SOCKET_IDS as an, bodyEyeOffsetY as on, bodyRestCenterY as sn, bodySpawnPosition as cn, bodyStandingHeight as ln, stepCameraSync as un, withExcludeCharacterRay as dn } from "./body/bodySi.js";
48
+ import { KhrBody as fn } from "./body/KhrBody.js";
49
+ import { HeldItem as pn } from "./body/HeldItem.js";
50
+ import { bakeArticulatedLauncherGlb as mn, buildLauncherSceneFromPlan as hn } from "./importer/launcherBake.js";
51
+ import { DomainWorkshopPanel as gn, enforceRetroPersonMaterials as _n } from "./importer/DomainWorkshopPanel.js";
52
+ import { DAMP_ZETA as vn, FREQ_HZ as yn, gateTelemetry as bn, isGateStep1Unlocked as xn, useGateStore as Sn } from "./importer/gateStore.js";
53
+ import { GateHudBar as Cn } from "./importer/GateHudBar.js";
54
+ import { buildImporterWebMcpTools as wn, getNavigatorModelContext as Tn, useImporterWebMcp as En } from "./importer/importerWebMcp.js";
55
+ import { makeStarterDomainScene as Dn } from "./importer/ImporterPlinthUikitTags.js";
56
+ import { compileKhrAssetGlb as On } from "./importer/khrCompiler.js";
57
+ import { Step1CalibrationPlinth as kn } from "./importer/Step1CalibrationPlinth.js";
58
+ import { C12_TICK_M as An, UNIFIED_ANCHOR_NAMES as jn, computeC12Metrics as Mn, defaultTargetMeters as Nn, detectSceneAnchors as Pn, khrBoxToRapierHalfExtents as Fn, measureAssemblyCalibration as In, measureNormalizedSceneCalibration as Ln, snapMetersToC12 as Rn, wrapSingleMeshWithPaperShellProxy as zn } from "./importer/glbNormalizer.js";
59
+ import { ImperativeVehicleRig as Bn } from "./importer/ImperativeVehicleRig.js";
60
+ import { Step2UniversalPad as Vn } from "./importer/Step2UniversalPad.js";
61
+ import { VfxEmitterPool as Hn } from "./importer/VfxEmitterPool.js";
62
+ import { convertUsdToGlb as Un, isUsdFileName as Wn } from "./importer/usdToGlb.js";
63
+ import { bakeUniversalGateGlb as Gn } from "./importer/universalGateBake.js";
64
+ import { GlbImportGate as $ } from "./importer/GlbImportGate.js";
65
+ import { DOOR_HINGE_SPEC as Kn, Ex as qn, ROOT3 as Jn, buildFootprint as Yn, canPlace as Xn, instanceBatches as Zn, latticePose as Qn, planSettlement as $n, poseEq as er, poseFromJSON as tr, poseToFloat as nr, poseToJSON as rr, snapPose as ir, socketFor as ar, triangleCorners as or, vToFloat as sr, worldSockets as cr } from "@khr3/c12";
66
+ import { DEFAULT_VAULT_URL as lr, KOLMO_ASSETS_URL as ur, VAULT_CARS as dr, VAULT_CATALOG as fr, VAULT_CITY as pr, VAULT_WEAPONS as mr, createAssetVault as hr, inspectGlbBuffer as gr, normalizeGlbBuffer as _r, vaultAssetUrl as vr } from "@khr3/assets";
67
+ import { CARBINE_556 as yr, LAUNCHER_RECIPES as br, PISTOL_9MM as xr, SHOTGUN_12G as Sr, attachModule as Cr, createLauncherState as wr, detachModule as Tr, findLauncherRecipe as Er, planLauncher as Dr, stepLauncher as Or } from "@khr3/launchers";
68
+ import { COUPE_2DOOR as kr, FLEET as Ar, SEDAN_4DOOR as jr, VEHICLE_DOMAINS as Mr, VEHICLE_DOMAIN_SPECS as Nr, carUrl as Pr, findCar as Fr, fleetByDomain as Ir, planCar as Lr } from "@khr3/vehicles";
69
+ export { qe as ATMO_FRAG, Je as ATMO_VERT, z as Actor, w as ActorTrait, rn as BODY_SI, an as BODY_SOCKET_IDS, rt as BOTTLE_HEIGHT, Fe as C12TileKind, An as C12_TICK_M, Ie as C12_TILE_M, it as CAN_LOD_THRESHOLD_M, yr as CARBINE_556, Ht as CHOP_ROLES, kr as COUPE_2DOOR, e as Canvas, nn as ChopShopPanel, vn as DAMP_ZETA, lr as DEFAULT_VAULT_URL, Kn as DOOR_HINGE_SPEC, Tt as DestructibleTarget, gn as DomainWorkshopPanel, v as EMPTY_KOLMO_INPUT, X as EmitterRig, qn as Ex, J as Exoplanet, Ar as FLEET, Le as FLOATING_ORIGIN_STEP_M, yn as FREQ_HZ, T as FloatingBodyTrait, ie as GLSL_BAYER_RGB555, ae as GLSL_RETRO_QUANTIZE, Cn as GateHudBar, $ as GlbImportGate, pn as HeldItem, Bn as ImperativeVehicleRig, $ as ImporterWorkbench, Ve as InfiniteLongDrivePlanner, E as InteractableTrait, K as Island, Q as Junk, Ye as KEY_SUN_DIRECTION, ur as KOLMO_ASSETS_URL, At as KOLMO_EXTENSION_NAME, y as KOLMO_KEY_MAP, fn as KhrBody, z as KolmoActor, e as KolmoCanvas, X as KolmoEmitterRig, J as KolmoExoplanet, m as KolmoGravityContext, K as KolmoIsland, Q as KolmoJunk, q as KolmoLongDrive, h as KolmoPhysics, W as KolmoProp, Y as KolmoSkybox, G as KolmoSurface, R as KolmoVehicle, t as KolmoWorld, br as LAUNCHER_RECIPES, q as LongDrive, Re as MACRO_SIZE_M, n as PALETTE_CRUNCHY_16, r as PALETTE_CRUNCHY_64, Et as PARTICLE_FRAG, Dt as PARTICLE_VERT, xr as PISTOL_9MM, Ot as PLUME_FRAG, kt as PLUME_VERT, oe as PS1_SNAP_RESOLUTION, h as Physics, D as PilotLink, W as Prop, i as RETRO_COLOR_MODES, se as RETRO_PRESETS, ce as RETRO_UNIFORMS, Xe as RING_MOONLET_COUNT, Jn as ROOT3, x as RetroViewportSync, S as RoomEnvRig, jr as SEDAN_4DOOR, Sr as SHOTGUN_12G, Ce as SHOULDER_K, Qe as SPLAT_LAYER, ke as SeededSimplex2D, C as ShadowSnapRig, ht as ShardPieces, Ke as ShiftedFixedBody, Y as Skybox, Ae as SplitMix32, kn as Step1CalibrationPlinth, Vn as Step2UniversalPad, G as Surface, ze as TILES_PER_MACRO, at as TIN_CAN_HEIGHT, ot as TIN_CAN_RADIUS, gt as TargetDecals, jn as UNIFIED_ANCHOR_NAMES, dr as VAULT_CARS, fr as VAULT_CATALOG, pr as VAULT_CITY, mr as VAULT_WEAPONS, Mr as VEHICLE_DOMAINS, Nr as VEHICLE_DOMAIN_SPECS, R as Vehicle, O as VehicleTrait, Hn as VfxEmitterPool, t as World, k as WorldSessionTrait, s as applyPs1Material, a as applyRetroFilteringToMaterial, c as applyRetroMaterial, o as applyRetroTextureFiltering, l as applySceneRetroMaterials, bt as applySegmentsToImportedRoot, Cr as attachModule, mn as bakeArticulatedLauncherGlb, Gn as bakeUniversalGateGlb, je as bakeWorldSplatMaps, on as bodyEyeOffsetY, sn as bodyRestCenterY, cn as bodySpawnPosition, ln as bodyStandingHeight, He as buildCarvedTerrainGeometry, Ne as buildDodecagonalCivicHub, Yn as buildFootprint, st as buildGlassBottleGeometry, Ue as buildHighwayAsphaltTexture, wn as buildImporterWebMcpTools, hn as buildLauncherSceneFromPlan, ee as buildPaletteLutData, B as buildPatchPreviewEmitters, We as buildRoadRibbonGeometry, qt as buildSelectionOverlayGeometry, Ut as buildSurfaceTopology, ct as buildTinCanGeometry, Xn as canPlace, Pr as carUrl, me as childSeed, ye as closedRoadFromPoints, pt as collectValidTris, On as compileKhrAssetGlb, Mn as computeC12Metrics, V as computeChopPartHinge, ue as computeIslandSpawnPose, fe as computeLongDriveBridgeheadSpawn, pe as computeLongDriveMainlandSpawn, te as computeRetroDpr, Un as convertUsdToGlb, lt as countGeometryTriangles, hr as createAssetVault, Z as createDefaultSignals, Jt as createFleet12GonWheelGroup, ut as createGlassBottleMaterial, wr as createLauncherState, tt as createPS2RoadMaterialWebGL, nt as createPS2TerrainMaterialWebGL, $e as createPS2WorldTextures, dt as createTinCanMaterials, H as createVehiclePanelAnimator, jt as decodeKolmoRig, Nn as defaultTargetMeters, Tr as detachModule, Pn as detectSceneAnchors, vt as disposeImportedRoot, _n as enforceRetroPersonMaterials, yt as ensureMeshAttributes, A as ensureWorldSession, Rt as extractMeshIslands, he as fbm2, Fr as findCar, Er as findLauncherRecipe, Yt as findMirrorIslandId, Ir as fleetByDomain, Wt as floodFillByCrease, Ee as frontage, bn as gateTelemetry, et as generatePS2DetailSlices, _t as getBulletHoleTexture, de as getCachedIslandPlan, ne as getColorQuantVector, Gt as getIslandTopology, Tn as getNavigatorModelContext, re as getPaletteLutTexture, Ct as getProceduralLabelTexture, u as getRetroPreset, d as getRetroShaderUniforms, be as growRoad, Me as hashSeed, Mt as inferKolmoSocketRole, gr as inspectGlbBuffer, Zn as instanceBatches, xn as isGateStep1Unlocked, Wn as isUsdFileName, Fn as khrBoxToRapierHalfExtents, j as kolmoActions, M as kolmoTelemetry, N as kolmoWorld, Qn as latticePose, wt as loadCustomLabelTexture, xt as loadImportedGlbUrl, De as makeIslandHeightfn, Dn as makeStarterDomainScene, we as makeTerrain, xe as maxGrade, In as measureAssemblyCalibration, Ln as measureNormalizedSceneCalibration, Ft as measureSelection, Kt as mirrorTriangles, Pt as mountPS2WorldMeshes, ge as mulberry32, U as normalToMinusZQuaternion, _r as normalizeGlbBuffer, zt as normalizeSceneToSi, St as parseImportedGlbBuffer, Xt as peelIslandSelection, Lr as planCar, Ge as planDirtSpurs, Oe as planIslandWorld, Dr as planLauncher, $n as planSettlement, Ze as populateMoonletMatrices, er as poseEq, tr as poseFromJSON, nr as poseToFloat, rr as poseToJSON, Zt as previewLoopPolyline, Be as quantizeFloatingOrigin192, P as readFloatingOriginAnchorXZ, Qt as refineMeshAlongLoop, $t as remapIslandIds, Se as roadFromPoints, Pe as routeMacroKnightAStar, Te as sampleHeightfield, _e as seedFrom, ft as selectCanLod, en as selectFacesByClick, tn as selectFacesByLoop, Bt as separateVehicleMeshes, F as shiftFloatingOriginEntities, Vt as sliceMeshTriangles, Rn as snapMetersToC12, ir as snapPose, ar as socketFor, mt as splitObjectIntoShards, Nt as stampKolmoNodesIntoGlb, un as stepCameraSync, Or as stepLauncher, It as suggestCarAxles, f as syncRetroUniforms, p as syncRetroViewport, Lt as toggleIslandSelection, le as togglePropJoint, or as triangleCorners, I as useActiveKolmoWorld, Sn as useGateStore, En as useImporterWebMcp, g as useIsKolmoCustomGravity, b as useKolmoInput, _ as useOptionalKootaWorld, L as useWorldTrait, sr as vToFloat, ve as valueNoise2, vr as vaultAssetUrl, dn as withExcludeCharacterRay, cr as worldSockets, zn as wrapSingleMeshWithPaperShellProxy };
@@ -0,0 +1,154 @@
1
+ import { FloatingBodyTrait as e, useActiveKolmoWorld as t } from "../engine/kolmoStore.js";
2
+ import { selectCanLod as n } from "./junkGeometry.js";
3
+ import { ShardPieces as r } from "./ShardPieces.js";
4
+ import { TargetDecals as i } from "./TargetDecals.js";
5
+ import { appendDecalBounded as a, buildTargetSnapshot as ee, executeTargetHit as o, readTargetWorldPos as te, tagImportedMeshes as s } from "./targetHitLogic.js";
6
+ import { useTargetAssets as ne } from "./useTargetAssets.js";
7
+ import { forwardRef as c, useCallback as l, useEffect as u, useImperativeHandle as d, useMemo as f, useRef as p, useState as m } from "react";
8
+ import * as h from "three";
9
+ import { useFrame as re } from "@react-three/fiber";
10
+ import { Fragment as ie, jsx as g, jsxs as _ } from "react/jsx-runtime";
11
+ import { CuboidCollider as v, CylinderCollider as y, RigidBody as b } from "@react-three/rapier";
12
+ // src/junk/DestructibleTarget.tsx
13
+ var x = new h.Vector3(), S = c(function({ spec: c, active: h = !0, importedAsset: S, onHit: C, onShatter: w, onStateChange: T, registerTarget: E }, ae) {
14
+ let D = t(), O = p(null), oe = p([...c.position]), k = p(null), A = p(null), j = p(/* @__PURE__ */ new Map()), [M, se] = m(!0), [ce, N] = m(c.hp), [P, F] = m([]), [I, L] = m([]), [R, z] = m(null), B = p(!0), V = p(c.hp), H = p(0), U = p([]), W = p([]), G = p([...c.position]), K = ne(c, S), q = p(c);
15
+ q.current = c;
16
+ let J = p(K);
17
+ J.current = K;
18
+ let Y = p({
19
+ onHit: C,
20
+ onShatter: w,
21
+ onStateChange: T,
22
+ registerTarget: E
23
+ });
24
+ Y.current = {
25
+ onHit: C,
26
+ onShatter: w,
27
+ onStateChange: T,
28
+ registerTarget: E
29
+ };
30
+ let X = l(() => ee(q.current, J.current, O.current, V.current, B.current, U.current.length, W.current.length, G.current), []), Z = l((e) => {
31
+ if (!B.current) return;
32
+ let t = q.current, n = o(t, J.current, O.current, k.current, A.current, V.current, `${t.id}-d-${++H.current}`, e);
33
+ if (n.shattered && n.shardStates && n.shardMaterial) n.shatterPos && (G.current = n.shatterPos), O.current = null, B.current = !1, V.current = 0, U.current = [], W.current = n.shardStates, j.current.clear(), N(0), F([]), z(n.shardMaterial), L(n.shardStates), se(!1), Y.current.onShatter?.(t.id, n.shardSpecs ?? [], e);
34
+ else if (n.bodyPos && (G.current = n.bodyPos), V.current = n.nextHp, N(n.nextHp), n.newDecal) {
35
+ let r = a(U.current, n.newDecal, j.current, n.newDecalMesh);
36
+ U.current = r, F(r), Y.current.onHit?.(t.id, e, n.nextHp, r);
37
+ } else Y.current.onHit?.(t.id, e, n.nextHp, U.current);
38
+ }, []), Q = f(() => ({
39
+ applyHit: Z,
40
+ getSnapshot: X
41
+ }), [Z, X]);
42
+ d(ae, () => Q, [Q]), u(() => (Y.current.registerTarget?.(c.id, Q), O.current?.recomputeMassPropertiesFromColliders?.(), () => Y.current.registerTarget?.(c.id, null)), [c.id, Q]), u(() => {
43
+ Y.current.onStateChange?.(X());
44
+ }, [
45
+ X,
46
+ M,
47
+ ce,
48
+ P.length,
49
+ I.length,
50
+ K.effectiveLod,
51
+ K.triCount,
52
+ K.customLabelLoaded
53
+ ]), u(() => {
54
+ s(K.importedRoot, c.id, Z);
55
+ }, [
56
+ K.importedRoot,
57
+ c.id,
58
+ Z
59
+ ]), re(({ camera: e }) => {
60
+ if (!h || !B.current || c.kind !== "tin-can" || c.canLodMode !== "auto" || !te(O.current, k.current, x)) return;
61
+ let t = n(e.position.distanceTo(x), "auto");
62
+ t !== K.effectiveLod && K.setActiveLod(t);
63
+ }), u(() => {
64
+ if (!M) return;
65
+ let t = D.spawn(e({
66
+ id: c.id,
67
+ getBody: () => O.current
68
+ }));
69
+ return () => {
70
+ t.destroy();
71
+ };
72
+ }, [
73
+ D,
74
+ c.id,
75
+ M
76
+ ]);
77
+ let $ = f(() => ({
78
+ targetId: c.id,
79
+ toolgunId: c.id,
80
+ destructibleTarget: !0,
81
+ isDestructibleTarget: !0,
82
+ applyHit: Z,
83
+ ecctrl: { excludeCharacterRay: !0 }
84
+ }), [c.id, Z]);
85
+ if (!M) return /* @__PURE__ */ g(r, {
86
+ shards: I,
87
+ material: R
88
+ });
89
+ let le = c.kind === "imported-glb" && !K.importedHalfExtents;
90
+ return /* @__PURE__ */ _(b, {
91
+ ref: O,
92
+ type: le ? "fixed" : "dynamic",
93
+ colliders: !1,
94
+ position: oe.current,
95
+ restitution: .18,
96
+ friction: .45,
97
+ linearDamping: 1.2,
98
+ angularDamping: 8,
99
+ userData: $,
100
+ children: [
101
+ c.kind === "tin-can" && /* @__PURE__ */ g(y, {
102
+ args: [.125, .085],
103
+ density: 180
104
+ }),
105
+ c.kind === "glass-bottle" && /* @__PURE__ */ g(y, {
106
+ args: [.16, .055],
107
+ density: 1200
108
+ }),
109
+ c.kind === "imported-glb" && /* @__PURE__ */ g(v, {
110
+ args: K.importedHalfExtents ?? [
111
+ .2,
112
+ .2,
113
+ .2
114
+ ],
115
+ density: 800
116
+ }),
117
+ /* @__PURE__ */ _("group", {
118
+ ref: k,
119
+ userData: $,
120
+ children: [
121
+ c.kind === "tin-can" && K.canMats && /* @__PURE__ */ g("mesh", {
122
+ ref: A,
123
+ geometry: (K.effectiveLod === "3-gon" ? K.can3Geo : K.can12Geo) ?? void 0,
124
+ material: K.canMats,
125
+ castShadow: !0,
126
+ receiveShadow: !0,
127
+ userData: $,
128
+ children: /* @__PURE__ */ g(i, {
129
+ decals: P,
130
+ lodKey: K.effectiveLod
131
+ })
132
+ }),
133
+ c.kind === "glass-bottle" && K.bottleGeo && K.bottleMat && /* @__PURE__ */ g("mesh", {
134
+ ref: A,
135
+ geometry: K.bottleGeo,
136
+ material: K.bottleMat,
137
+ castShadow: !0,
138
+ userData: $,
139
+ children: /* @__PURE__ */ g(i, {
140
+ decals: P,
141
+ lodKey: "bottle"
142
+ })
143
+ }),
144
+ c.kind === "imported-glb" && K.importedRoot && /* @__PURE__ */ _(ie, { children: [/* @__PURE__ */ g("primitive", { object: K.importedRoot }), /* @__PURE__ */ g(i, {
145
+ decals: P,
146
+ lodKey: K.importedKey,
147
+ meshRefMap: j.current
148
+ })] })
149
+ ]
150
+ })
151
+ ]
152
+ });
153
+ });
154
+ export { S as DestructibleTarget };
@@ -0,0 +1,65 @@
1
+ import { DestructibleTarget as e } from "./DestructibleTarget.js";
2
+ import { useMemo as t, useRef as n } from "react";
3
+ import * as r from "three";
4
+ import { jsx as i } from "react/jsx-runtime";
5
+ // src/junk/KolmoJunk.tsx
6
+ var a = new r.Matrix3(), o = new r.Vector3();
7
+ function s({ id: r, kind: s = "glass-bottle", labelId: c = "tris-soda", position: l = [
8
+ 0,
9
+ .4,
10
+ 0
11
+ ], hp: u = s === "glass-bottle" ? 25 : 60, fragile: d = s === "glass-bottle", shatterPieceCount: f = 7, canLodMode: p = "auto", importedUrl: m = null }) {
12
+ let h = n(null), g = t(() => ({
13
+ id: r,
14
+ kind: s,
15
+ labelId: c,
16
+ customAlbedoUrl: null,
17
+ canLodMode: p,
18
+ position: l,
19
+ hp: u,
20
+ maxHp: u,
21
+ fragile: d,
22
+ shatterPieceCount: f,
23
+ importedUrl: m
24
+ }), [
25
+ r,
26
+ s,
27
+ c,
28
+ p,
29
+ l,
30
+ u,
31
+ d,
32
+ f,
33
+ m
34
+ ]);
35
+ return /* @__PURE__ */ i("group", {
36
+ onClick: (e) => {
37
+ e.stopPropagation();
38
+ let t = e.point, n = e.ray.direction;
39
+ e.face ? (e.object.updateWorldMatrix(!0, !1), a.getNormalMatrix(e.object.matrixWorld), o.copy(e.face.normal).applyMatrix3(a).normalize(), o.dot(n) > 0 && o.negate()) : o.copy(n).negate(), h.current?.applyHit({
40
+ targetId: r,
41
+ point: [
42
+ t.x,
43
+ t.y,
44
+ t.z
45
+ ],
46
+ normal: [
47
+ o.x,
48
+ o.y,
49
+ o.z
50
+ ],
51
+ impulse: [
52
+ n.x * 3.2,
53
+ n.y * 3.2 + .9,
54
+ n.z * 3.2
55
+ ],
56
+ distance: e.distance
57
+ });
58
+ },
59
+ children: /* @__PURE__ */ i(e, {
60
+ ref: h,
61
+ spec: g
62
+ })
63
+ });
64
+ }
65
+ export { s as KolmoJunk };
@@ -1,10 +1,12 @@
1
- import * as THREE from 'three';
1
+ import * as THREE from "three";
2
2
  import { type SpawnedShardState } from "./targetHelpers.js";
3
3
  export interface ShardPiecesProps {
4
- shards: ReadonlyArray<SpawnedShardState>;
5
- material: THREE.Material | null;
4
+ readonly shards: ReadonlyArray<SpawnedShardState>;
5
+ readonly material: THREE.Material | null;
6
6
  }
7
7
  /**
8
- * Renders independent dynamic Rapier RigidBodies for BVH shatter fragments.
8
+ * Portals dynamic Rapier shatter fragments directly into the root `THREE.Scene` so world-space
9
+ * `worldPos`/`worldQuat` are never double-transformed by translated or rotated parent `<group>`s,
10
+ * and registers `FloatingBodyTrait` for zero-drift floating-origin rebasing.
9
11
  */
10
12
  export declare function ShardPieces({ shards, material }: ShardPiecesProps): import("react").JSX.Element | null;
@@ -0,0 +1,74 @@
1
+ import { FloatingBodyTrait as e, useActiveKolmoWorld as t } from "../engine/kolmoStore.js";
2
+ import { SHARD_COLLIDER_INSET as n } from "./targetHelpers.js";
3
+ import { useEffect as r, useMemo as i, useRef as a } from "react";
4
+ import { createPortal as o, useThree as s } from "@react-three/fiber";
5
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ import { CuboidCollider as u, RigidBody as d } from "@react-three/rapier";
7
+ // src/junk/ShardPieces.tsx
8
+ function f({ item: o, material: s }) {
9
+ let f = t(), p = a(null), m = a({
10
+ pos: o.worldPos,
11
+ quat: o.worldQuat
12
+ });
13
+ r(() => {
14
+ let t = f.spawn(e({
15
+ id: o.spec.id,
16
+ getBody: () => p.current
17
+ })), n = p.current;
18
+ return n && (n.setLinvel({
19
+ x: o.linvel[0],
20
+ y: o.linvel[1],
21
+ z: o.linvel[2]
22
+ }, !0), n.setAngvel({
23
+ x: o.angvel[0],
24
+ y: o.angvel[1],
25
+ z: o.angvel[2]
26
+ }, !0)), () => {
27
+ t.destroy();
28
+ };
29
+ }, [f, o]);
30
+ let h = [
31
+ Math.max(.01, o.spec.halfExtents[0] * n),
32
+ Math.max(.01, o.spec.halfExtents[1] * n),
33
+ Math.max(.01, o.spec.halfExtents[2] * n)
34
+ ], g = i(() => ({
35
+ toolgunId: o.spec.id,
36
+ ecctrl: { excludeCharacterRay: !0 }
37
+ }), [o.spec.id]);
38
+ return /* @__PURE__ */ l(d, {
39
+ ref: p,
40
+ type: "dynamic",
41
+ colliders: !1,
42
+ position: m.current.pos,
43
+ quaternion: m.current.quat,
44
+ restitution: .18,
45
+ friction: .8,
46
+ linearDamping: .45,
47
+ angularDamping: .45,
48
+ userData: g,
49
+ children: [/* @__PURE__ */ c(u, {
50
+ args: h,
51
+ density: o.density
52
+ }), /* @__PURE__ */ c("mesh", {
53
+ geometry: o.spec.geometry,
54
+ material: s,
55
+ castShadow: !0,
56
+ receiveShadow: !0
57
+ })]
58
+ });
59
+ }
60
+ function p({ shards: e, material: t }) {
61
+ let n = s((e) => e.scene);
62
+ return r(() => () => {
63
+ for (let t of e) t.spec.geometry.dispose();
64
+ }, [e]), r(() => () => {
65
+ t?.dispose();
66
+ }, [t]), !t || e.length === 0 ? null : o(/* @__PURE__ */ c("group", {
67
+ name: "Kolmo_WorldShardPieces",
68
+ children: e.map((e) => /* @__PURE__ */ c(f, {
69
+ item: e,
70
+ material: t
71
+ }, e.spec.id))
72
+ }), n);
73
+ }
74
+ export { p as ShardPieces };
@@ -0,0 +1,51 @@
1
+ import { Fragment as e, useMemo as t } from "react";
2
+ import * as n from "three";
3
+ import { createPortal as r } from "@react-three/fiber";
4
+ import { Decal as i } from "@react-three/drei";
5
+ import { Fragment as a, jsx as o } from "react/jsx-runtime";
6
+ // src/junk/TargetDecals.tsx
7
+ var s = null;
8
+ function c() {
9
+ if (typeof document > "u") return null;
10
+ if (s) return s;
11
+ let e = document.createElement("canvas");
12
+ e.width = 128, e.height = 128;
13
+ let t = e.getContext("2d");
14
+ if (!t) return null;
15
+ t.clearRect(0, 0, 128, 128);
16
+ let r = t.createRadialGradient(64, 64, 8, 64, 64, 54);
17
+ r.addColorStop(0, "rgba(15, 15, 18, 0.92)"), r.addColorStop(.45, "rgba(39, 39, 42, 0.55)"), r.addColorStop(1, "rgba(24, 24, 27, 0)"), t.fillStyle = r, t.beginPath(), t.arc(64, 64, 54, 0, Math.PI * 2), t.fill(), t.strokeStyle = "rgba(24, 24, 27, 0.85)", t.lineWidth = 2.5;
18
+ for (let e = 0; e < 8; e++) {
19
+ let n = e / 8 * Math.PI * 2 + .25;
20
+ t.beginPath(), t.moveTo(64 + Math.cos(n) * 16, 64 + Math.sin(n) * 16), t.lineTo(64 + Math.cos(n) * 44, 64 + Math.sin(n) * 44), t.stroke();
21
+ }
22
+ t.beginPath(), t.arc(64, 64, 21, 0, Math.PI * 2), t.fillStyle = "#94a3b8", t.fill(), t.beginPath(), t.arc(64, 64, 15, 0, Math.PI * 2), t.fillStyle = "#09090b", t.fill();
23
+ let i = new n.CanvasTexture(e);
24
+ return i.colorSpace = n.SRGBColorSpace, i.flipY = !0, i.needsUpdate = !0, s = i, i;
25
+ }
26
+ function l({ decals: n, lodKey: s = "default", meshRefMap: l }) {
27
+ let u = t(() => c(), []);
28
+ return n.length === 0 ? null : /* @__PURE__ */ o(a, { children: n.map((t) => {
29
+ let n = /* @__PURE__ */ o(i, {
30
+ position: t.position,
31
+ rotation: t.rotation,
32
+ scale: [
33
+ t.scale,
34
+ t.scale,
35
+ t.scale * 1.4
36
+ ],
37
+ depthTest: !0,
38
+ polygonOffsetFactor: -4,
39
+ "material-depthWrite": !1,
40
+ raycast: () => null,
41
+ userData: { isDecal: !0 },
42
+ map: u ?? void 0
43
+ });
44
+ if (l) {
45
+ let i = l.get(t.id)?.current;
46
+ return i ? /* @__PURE__ */ o(e, { children: r(n, i) }, `${t.id}-${s}`) : null;
47
+ }
48
+ return /* @__PURE__ */ o(e, { children: n }, `${t.id}-${s}`);
49
+ }) });
50
+ }
51
+ export { l as TargetDecals, c as getBulletHoleTexture };
@@ -0,0 +1,55 @@
1
+ import { collectValidTris as e } from "./bvhTriCollector.js";
2
+ import * as t from "three";
3
+ // src/junk/bvhShatter.ts
4
+ var n = .015;
5
+ function r(e, t, n, i) {
6
+ if (i <= 1 || n <= 1) return [[t, n]];
7
+ let a = Infinity, o = Infinity, s = Infinity, c = -Infinity, l = -Infinity, u = -Infinity;
8
+ for (let r = t; r < t + n; r++) {
9
+ let t = e[r];
10
+ t.minX < a && (a = t.minX), t.minY < o && (o = t.minY), t.minZ < s && (s = t.minZ), t.maxX > c && (c = t.maxX), t.maxY > l && (l = t.maxY), t.maxZ > u && (u = t.maxZ);
11
+ }
12
+ let d = c - a, f = l - o, p = u - s, m = d >= f && d >= p ? 0 : f >= p ? 1 : 2, h = e.slice(t, t + n);
13
+ h.sort((e, t) => m === 0 ? e.cx - t.cx : m === 1 ? e.cy - t.cy : e.cz - t.cz);
14
+ for (let r = 0; r < n; r++) e[t + r] = h[r];
15
+ let g = Math.floor(i / 2), _ = i - g, v = Math.max(1, Math.min(n - 1, Math.round(g / i * n)));
16
+ return [...r(e, t, v, g), ...r(e, t + v, n - v, _)];
17
+ }
18
+ function i(i, a) {
19
+ let o = e(i);
20
+ if (o.length === 0) return [];
21
+ let s = Math.max(1, Math.min(Math.round(Number.isFinite(a) ? a : 6), o.length)), c = r(o, 0, o.length, s), l = [], u = 0, d = c.map(([e, r], i) => {
22
+ let a = Infinity, s = Infinity, d = Infinity, f = -Infinity, p = -Infinity, m = -Infinity;
23
+ for (let t = e; t < e + r; t++) {
24
+ let e = o[t];
25
+ e.minX < a && (a = e.minX), e.minY < s && (s = e.minY), e.minZ < d && (d = e.minZ), e.maxX > f && (f = e.maxX), e.maxY > p && (p = e.maxY), e.maxZ > m && (m = e.maxZ);
26
+ }
27
+ let h = (a + f) * .5, g = (s + p) * .5, _ = (d + m) * .5, v = new Float32Array(r * 9), y = new Float32Array(r * 9), b = new Float32Array(r * 6);
28
+ for (let t = 0; t < r; t++) {
29
+ let n = o[e + t], r = t * 9;
30
+ for (let e = 0; e < 3; e++) v[r + e * 3] = n.p[e * 3] - h, v[r + e * 3 + 1] = n.p[e * 3 + 1] - g, v[r + e * 3 + 2] = n.p[e * 3 + 2] - _, y[r + e * 3] = n.n[e * 3], y[r + e * 3 + 1] = n.n[e * 3 + 1], y[r + e * 3 + 2] = n.n[e * 3 + 2];
31
+ b.set(n.uv, t * 6);
32
+ }
33
+ let x = new t.BufferGeometry();
34
+ x.setAttribute("position", new t.Float32BufferAttribute(v, 3)), x.setAttribute("normal", new t.Float32BufferAttribute(y, 3)), x.setAttribute("uv", new t.Float32BufferAttribute(b, 2)), x.computeBoundingBox(), x.computeBoundingSphere();
35
+ let S = Math.max(n, (f - a) * .5), C = Math.max(n, (p - s) * .5), w = Math.max(n, (m - d) * .5), T = 8 * S * C * w;
36
+ return l.push(T), u += T, {
37
+ id: `shard_${i}`,
38
+ geometry: x,
39
+ centroid: [
40
+ h,
41
+ g,
42
+ _
43
+ ],
44
+ halfExtents: [
45
+ S,
46
+ C,
47
+ w
48
+ ],
49
+ volumeFraction: 1 / c.length
50
+ };
51
+ });
52
+ if (u > 0) for (let e = 0; e < d.length; e++) d[e].volumeFraction = l[e] / u;
53
+ return d;
54
+ }
55
+ export { i as splitObjectIntoShards };
@@ -0,0 +1,78 @@
1
+ import * as e from "three";
2
+ // src/junk/bvhTriCollector.ts
3
+ var t = 1e-10;
4
+ function n(...e) {
5
+ for (let t = 0; t < e.length; t++) if (!Number.isFinite(e[t])) return !1;
6
+ return !0;
7
+ }
8
+ function r(r) {
9
+ r.updateMatrixWorld(!0);
10
+ let i = new e.Matrix4().copy(r.matrixWorld).invert(), a = new e.Matrix4(), o = new e.Matrix3(), s = [];
11
+ r.traverse((t) => {
12
+ t instanceof e.Mesh && (t.userData.isDecal || t.userData.isGizmo || t.material instanceof e.ShaderMaterial || Array.isArray(t.material) && t.material.every((t) => t instanceof e.ShaderMaterial) || t.geometry?.attributes?.position && s.push(t));
13
+ });
14
+ let c = s.some((e) => e.userData.destructible !== !1), l = [], u = new e.Vector3(), d = new e.Vector3(), f = new e.Vector3(), p = new e.Vector3(), m = new e.Vector3(), h = new e.Vector3(), g = new e.Vector3(), _ = new e.Vector3(), v = new e.Vector3();
15
+ for (let e of s) {
16
+ if (c && e.userData.destructible === !1) continue;
17
+ let r = e.geometry, s = r.index !== null, y = s ? r.toNonIndexed() : r;
18
+ try {
19
+ let r = y.attributes.position, s = y.attributes.normal, c = y.attributes.uv, b = Math.floor(r.count / 3);
20
+ if (b <= 0) continue;
21
+ a.multiplyMatrices(i, e.matrixWorld), o.getNormalMatrix(a);
22
+ for (let e = 0; e < b; e++) {
23
+ let i = e * 3;
24
+ if (u.fromBufferAttribute(r, i).applyMatrix4(a), d.fromBufferAttribute(r, i + 1).applyMatrix4(a), f.fromBufferAttribute(r, i + 2).applyMatrix4(a), !n(u.x, u.y, u.z, d.x, d.y, d.z, f.x, f.y, f.z)) continue;
25
+ p.subVectors(d, u), m.subVectors(f, u), h.crossVectors(p, m);
26
+ let y = h.length();
27
+ if (!Number.isFinite(y) || y < t) continue;
28
+ h.divideScalar(y), s ? (g.fromBufferAttribute(s, i).applyMatrix3(o), _.fromBufferAttribute(s, i + 1).applyMatrix3(o), v.fromBufferAttribute(s, i + 2).applyMatrix3(o), g.lengthSq() > 1e-10 ? g.normalize() : g.copy(h), _.lengthSq() > 1e-10 ? _.normalize() : _.copy(h), v.lengthSq() > 1e-10 ? v.normalize() : v.copy(h)) : (g.copy(h), _.copy(h), v.copy(h));
29
+ let b = c ? c.getX(i) : 0, x = c ? c.getY(i) : 0, S = c ? c.getX(i + 1) : 0, C = c ? c.getY(i + 1) : 0, w = c ? c.getX(i + 2) : 0, T = c ? c.getY(i + 2) : 0;
30
+ l.push({
31
+ p: [
32
+ u.x,
33
+ u.y,
34
+ u.z,
35
+ d.x,
36
+ d.y,
37
+ d.z,
38
+ f.x,
39
+ f.y,
40
+ f.z
41
+ ],
42
+ n: [
43
+ g.x,
44
+ g.y,
45
+ g.z,
46
+ _.x,
47
+ _.y,
48
+ _.z,
49
+ v.x,
50
+ v.y,
51
+ v.z
52
+ ],
53
+ uv: [
54
+ Number.isFinite(b) ? b : 0,
55
+ Number.isFinite(x) ? x : 0,
56
+ Number.isFinite(S) ? S : 0,
57
+ Number.isFinite(C) ? C : 0,
58
+ Number.isFinite(w) ? w : 0,
59
+ Number.isFinite(T) ? T : 0
60
+ ],
61
+ cx: (u.x + d.x + f.x) / 3,
62
+ cy: (u.y + d.y + f.y) / 3,
63
+ cz: (u.z + d.z + f.z) / 3,
64
+ minX: Math.min(u.x, d.x, f.x),
65
+ minY: Math.min(u.y, d.y, f.y),
66
+ minZ: Math.min(u.z, d.z, f.z),
67
+ maxX: Math.max(u.x, d.x, f.x),
68
+ maxY: Math.max(u.y, d.y, f.y),
69
+ maxZ: Math.max(u.z, d.z, f.z)
70
+ });
71
+ }
72
+ } finally {
73
+ s && y.dispose();
74
+ }
75
+ }
76
+ return l;
77
+ }
78
+ export { r as collectValidTris };
@@ -1 +1,11 @@
1
- export { h as BOTTLE_HEIGHT, g as CAN_LOD_THRESHOLD_M, n as DestructibleTarget, t as KolmoJunk, f as ShardPieces, _ as TIN_CAN_HEIGHT, v as TIN_CAN_RADIUS, u as TargetDecals, a as applySegmentsToImportedRoot, y as buildGlassBottleGeometry, b as buildTinCanGeometry, m as collectValidTris, x as countGeometryTriangles, S as createGlassBottleMaterial, C as createTinCanMaterials, c as disposeImportedRoot, l as ensureMeshAttributes, d as getBulletHoleTexture, r as getProceduralLabelTexture, i as loadCustomLabelTexture, o as loadImportedGlbUrl, s as parseImportedGlbBuffer, w as selectCanLod, p as splitObjectIntoShards } from "../junk-B4bC1zAl.js";
1
+ import { DestructibleTarget as e } from "./DestructibleTarget.js";
2
+ import { KolmoJunk as t } from "./KolmoJunk.js";
3
+ import { ShardPieces as n } from "./ShardPieces.js";
4
+ import { TargetDecals as r, getBulletHoleTexture as i } from "./TargetDecals.js";
5
+ import { splitObjectIntoShards as a } from "./bvhShatter.js";
6
+ import { collectValidTris as o } from "./bvhTriCollector.js";
7
+ import { BOTTLE_HEIGHT as s, CAN_LOD_THRESHOLD_M as c, TIN_CAN_HEIGHT as l, TIN_CAN_RADIUS as u, buildGlassBottleGeometry as d, buildTinCanGeometry as f, countGeometryTriangles as p, createGlassBottleMaterial as m, createTinCanMaterials as h, selectCanLod as g } from "./junkGeometry.js";
8
+ import { disposeImportedRoot as _, ensureMeshAttributes as v } from "./junkImportSanitize.js";
9
+ import { applySegmentsToImportedRoot as y, loadImportedGlbUrl as b, parseImportedGlbBuffer as x } from "./junkImporter.js";
10
+ import { getProceduralLabelTexture as S, loadCustomLabelTexture as C } from "./junkLabels.js";
11
+ export { s as BOTTLE_HEIGHT, c as CAN_LOD_THRESHOLD_M, e as DestructibleTarget, t as KolmoJunk, n as ShardPieces, l as TIN_CAN_HEIGHT, u as TIN_CAN_RADIUS, r as TargetDecals, y as applySegmentsToImportedRoot, d as buildGlassBottleGeometry, f as buildTinCanGeometry, o as collectValidTris, p as countGeometryTriangles, m as createGlassBottleMaterial, h as createTinCanMaterials, _ as disposeImportedRoot, v as ensureMeshAttributes, i as getBulletHoleTexture, S as getProceduralLabelTexture, C as loadCustomLabelTexture, b as loadImportedGlbUrl, x as parseImportedGlbBuffer, g as selectCanLod, a as splitObjectIntoShards };