@pinkaphant/kolmo 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +16 -14
- package/bin/kolmo.mjs +19 -54
- package/dist/body/HeldItem.d.ts +22 -0
- package/dist/body/HeldItem.js +171 -0
- package/dist/body/KhrBody.d.ts +26 -0
- package/dist/body/KhrBody.js +179 -0
- package/dist/body/bodySi.d.ts +59 -0
- package/dist/body/bodySi.js +61 -0
- package/dist/body/index.d.ts +3 -0
- package/dist/body/index.js +4 -0
- package/dist/engine/index.d.ts +4 -4
- package/dist/engine/index.js +12 -3
- package/dist/engine/kolmoActor.d.ts +11 -4
- package/dist/engine/kolmoActor.js +197 -0
- package/dist/engine/kolmoInput.d.ts +12 -0
- package/dist/engine/kolmoInput.js +80 -0
- package/dist/engine/kolmoIsland.d.ts +3 -1
- package/dist/engine/kolmoIsland.js +311 -0
- package/dist/engine/kolmoLongDrive.js +223 -0
- package/dist/engine/kolmoRigs.js +59 -0
- package/dist/engine/kolmoStore.d.ts +53 -27
- package/dist/engine/kolmoStore.js +211 -0
- package/dist/engine/kolmoSurface.d.ts +1 -1
- package/dist/engine/kolmoSurface.js +182 -0
- package/dist/engine/kolmoVehicle.d.ts +2 -1
- package/dist/engine/kolmoVehicle.js +244 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +30 -0
- package/dist/engine/kolmoVehicleDriver.js +38 -0
- package/dist/engine/kolmoWorld.d.ts +7 -15
- package/dist/engine/kolmoWorld.js +136 -0
- package/dist/engine/longDriveKit.d.ts +4 -2
- package/dist/engine/longDriveKit.js +254 -0
- package/dist/engine/mainlandMacroCell.d.ts +3 -7
- package/dist/engine/mainlandMacroCell.js +247 -0
- package/dist/engine/shiftedFixedBody.d.ts +13 -0
- package/dist/engine/shiftedFixedBody.js +64 -0
- package/dist/importer/ChopShopPanel.js +465 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +9 -4
- package/dist/importer/DomainWorkshopPanel.js +385 -0
- package/dist/importer/GateHudBar.js +312 -0
- package/dist/importer/GlbImportGate.js +250 -0
- package/dist/importer/ImperativeVehicleRig.js +336 -0
- package/dist/importer/ImporterPlinthUikitTags.js +112 -0
- package/dist/importer/Step1CalibrationPlinth.js +275 -0
- package/dist/importer/Step2UniversalPad.js +244 -0
- package/dist/importer/VfxEmitterPool.js +91 -0
- package/dist/importer/chopShopActions.d.ts +22 -2
- package/dist/importer/chopShopActions.js +232 -0
- package/dist/importer/gateStore.d.ts +1 -1
- package/dist/importer/gateStore.js +92 -0
- package/dist/importer/glbNormalizer.js +133 -0
- package/dist/importer/importerWebMcp.d.ts +17 -6
- package/dist/importer/importerWebMcp.js +343 -0
- package/dist/importer/index.js +22 -3
- package/dist/importer/khrCompiler.d.ts +1 -1
- package/dist/importer/khrCompiler.js +434 -0
- package/dist/importer/launcherBake.js +51 -0
- package/dist/importer/meshIslands.d.ts +1 -1
- package/dist/importer/meshIslands.js +301 -0
- package/dist/importer/surfaceCutter.js +254 -0
- package/dist/importer/surfaceTopology.js +183 -0
- package/dist/importer/universalGateBake.js +162 -0
- package/dist/importer/usdToGlb.js +294 -0
- package/dist/importer/useChopShopController.d.ts +11 -2
- package/dist/importer/useChopShopController.js +364 -0
- package/dist/importer/vehiclePanelAnim.js +214 -0
- package/dist/importer/wheelAxlePairing.d.ts +1 -2
- package/dist/importer/wheelAxlePairing.js +102 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +69 -14
- package/dist/junk/DestructibleTarget.js +154 -0
- package/dist/junk/KolmoJunk.js +65 -0
- package/dist/junk/ShardPieces.d.ts +6 -4
- package/dist/junk/ShardPieces.js +74 -0
- package/dist/junk/TargetDecals.js +51 -0
- package/dist/junk/bvhShatter.js +55 -0
- package/dist/junk/bvhTriCollector.js +78 -0
- package/dist/junk/index.js +11 -1
- package/dist/junk/junkGeometry.js +69 -0
- package/dist/junk/junkImportSanitize.js +54 -0
- package/dist/junk/junkImporter.js +95 -0
- package/dist/junk/junkLabelCanvas.js +67 -0
- package/dist/junk/junkLabels.js +35 -0
- package/dist/junk/targetHelpers.js +103 -0
- package/dist/junk/targetHitLogic.js +128 -0
- package/dist/junk/useTargetAssets.js +102 -0
- package/dist/physics/index.d.ts +26 -0
- package/dist/physics/index.js +84 -0
- package/dist/schema/kolmoSchema.d.ts +2 -1
- package/dist/schema/kolmoSchema.js +184 -0
- package/dist/shaders/celestialBackdrop.d.ts +1 -1
- package/dist/shaders/celestialBackdrop.js +344 -0
- package/dist/shaders/index.d.ts +0 -1
- package/dist/shaders/index.js +9 -1
- package/dist/shaders/plumeAndSparkle.js +271 -0
- package/dist/shaders/ps2GlslShared.d.ts +1 -1
- package/dist/shaders/ps2GlslShared.js +3 -0
- package/dist/shaders/ps2MaterialsTSL.js +65 -0
- package/dist/shaders/ps2MaterialsWebGL.js +40 -0
- package/dist/shaders/ps2RoadWebGL.js +101 -0
- package/dist/shaders/ps2TerrainWebGL.js +54 -0
- package/dist/shaders/ps2Textures.js +224 -0
- package/dist/shaders/retroPalettes.js +188 -0
- package/dist/shaders/retroShader.d.ts +31 -3
- package/dist/shaders/retroShader.js +249 -0
- package/dist/shaders/tsl.d.ts +1 -0
- package/dist/shaders/tsl.js +1 -0
- package/dist/vite/index.d.ts +15 -0
- package/dist/vite/index.js +90 -0
- package/dist/world/frontage.js +32 -0
- package/dist/world/index.d.ts +1 -1
- package/dist/world/index.js +11 -3
- package/dist/world/infiniteWorld2D.js +244 -0
- package/dist/world/island.js +201 -0
- package/dist/world/macroCellSchema.js +27 -0
- package/dist/world/macroKnightAStar.js +171 -0
- package/dist/world/random.js +33 -0
- package/dist/world/road.js +136 -0
- package/dist/world/roadRibbon.d.ts +6 -6
- package/dist/world/roadRibbon.js +161 -0
- package/dist/world/terrain.js +87 -0
- package/dist/world/worldTypes.js +111 -0
- package/package.json +36 -19
- package/dist/engine-BeKvBM8d.js +0 -1745
- package/dist/importer-D9bdcGTh.js +0 -5113
- package/dist/junk-B4bC1zAl.js +0 -1049
- package/dist/kolmoSurface-DTnrFXH0.js +0 -558
- package/dist/shaders-GS71Ek1A.js +0 -1383
- package/dist/world-PRWPYrlx.js +0 -947
- package/dist/worldTypes-Z0KfdCd0.js +0 -226
package/dist/index.js
CHANGED
|
@@ -1,14 +1,69 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
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_MOVE_TUNE as rn, BODY_SI as an, BODY_SOCKET_IDS as on, bodyEyeOffsetY as sn, bodyRestCenterY as cn, bodySpawnPosition as ln, bodyStandingHeight as un, stepCameraSync as dn, withExcludeCharacterRay as fn } from "./body/bodySi.js";
|
|
48
|
+
import { KhrBody as pn } from "./body/KhrBody.js";
|
|
49
|
+
import { HeldItem as mn } from "./body/HeldItem.js";
|
|
50
|
+
import { bakeArticulatedLauncherGlb as hn, buildLauncherSceneFromPlan as gn } from "./importer/launcherBake.js";
|
|
51
|
+
import { DomainWorkshopPanel as _n, enforceRetroPersonMaterials as vn } from "./importer/DomainWorkshopPanel.js";
|
|
52
|
+
import { DAMP_ZETA as yn, FREQ_HZ as bn, gateTelemetry as xn, isGateStep1Unlocked as Sn, useGateStore as Cn } from "./importer/gateStore.js";
|
|
53
|
+
import { GateHudBar as wn } from "./importer/GateHudBar.js";
|
|
54
|
+
import { buildImporterWebMcpTools as Tn, getNavigatorModelContext as En, useImporterWebMcp as Dn } from "./importer/importerWebMcp.js";
|
|
55
|
+
import { makeStarterDomainScene as On } from "./importer/ImporterPlinthUikitTags.js";
|
|
56
|
+
import { compileKhrAssetGlb as kn } from "./importer/khrCompiler.js";
|
|
57
|
+
import { Step1CalibrationPlinth as An } from "./importer/Step1CalibrationPlinth.js";
|
|
58
|
+
import { C12_TICK_M as jn, UNIFIED_ANCHOR_NAMES as Mn, computeC12Metrics as Nn, defaultTargetMeters as Pn, detectSceneAnchors as Fn, khrBoxToRapierHalfExtents as In, measureAssemblyCalibration as Ln, measureNormalizedSceneCalibration as Rn, snapMetersToC12 as zn, wrapSingleMeshWithPaperShellProxy as Bn } from "./importer/glbNormalizer.js";
|
|
59
|
+
import { ImperativeVehicleRig as Vn } from "./importer/ImperativeVehicleRig.js";
|
|
60
|
+
import { Step2UniversalPad as Hn } from "./importer/Step2UniversalPad.js";
|
|
61
|
+
import { VfxEmitterPool as Un } from "./importer/VfxEmitterPool.js";
|
|
62
|
+
import { convertUsdToGlb as Wn, isUsdFileName as Gn } from "./importer/usdToGlb.js";
|
|
63
|
+
import { bakeUniversalGateGlb as Kn } from "./importer/universalGateBake.js";
|
|
64
|
+
import { GlbImportGate as $ } from "./importer/GlbImportGate.js";
|
|
65
|
+
import { DOOR_HINGE_SPEC as qn, Ex as Jn, ROOT3 as Yn, buildFootprint as Xn, canPlace as Zn, instanceBatches as Qn, latticePose as $n, planSettlement as er, poseEq as tr, poseFromJSON as nr, poseToFloat as rr, poseToJSON as ir, snapPose as ar, socketFor as or, triangleCorners as sr, vToFloat as cr, worldSockets as lr } from "@khr3/c12";
|
|
66
|
+
import { DEFAULT_VAULT_URL as ur, KOLMO_ASSETS_URL as dr, VAULT_CARS as fr, VAULT_CATALOG as pr, VAULT_CITY as mr, VAULT_WEAPONS as hr, createAssetVault as gr, inspectGlbBuffer as _r, normalizeGlbBuffer as vr, vaultAssetUrl as yr } from "@khr3/assets";
|
|
67
|
+
import { CARBINE_556 as br, LAUNCHER_RECIPES as xr, PISTOL_9MM as Sr, SHOTGUN_12G as Cr, attachModule as wr, createLauncherState as Tr, detachModule as Er, findLauncherRecipe as Dr, planLauncher as Or, stepLauncher as kr } from "@khr3/launchers";
|
|
68
|
+
import { COUPE_2DOOR as Ar, FLEET as jr, SEDAN_4DOOR as Mr, VEHICLE_DOMAINS as Nr, VEHICLE_DOMAIN_SPECS as Pr, carUrl as Fr, findCar as Ir, fleetByDomain as Lr, planCar as Rr } from "@khr3/vehicles";
|
|
69
|
+
export { qe as ATMO_FRAG, Je as ATMO_VERT, z as Actor, w as ActorTrait, rn as BODY_MOVE_TUNE, an as BODY_SI, on as BODY_SOCKET_IDS, rt as BOTTLE_HEIGHT, Fe as C12TileKind, jn as C12_TICK_M, Ie as C12_TILE_M, it as CAN_LOD_THRESHOLD_M, br as CARBINE_556, Ht as CHOP_ROLES, Ar as COUPE_2DOOR, e as Canvas, nn as ChopShopPanel, yn as DAMP_ZETA, ur as DEFAULT_VAULT_URL, qn as DOOR_HINGE_SPEC, Tt as DestructibleTarget, _n as DomainWorkshopPanel, v as EMPTY_KOLMO_INPUT, X as EmitterRig, Jn as Ex, J as Exoplanet, jr as FLEET, Le as FLOATING_ORIGIN_STEP_M, bn as FREQ_HZ, T as FloatingBodyTrait, ie as GLSL_BAYER_RGB555, ae as GLSL_RETRO_QUANTIZE, wn as GateHudBar, $ as GlbImportGate, mn as HeldItem, Vn as ImperativeVehicleRig, $ as ImporterWorkbench, Ve as InfiniteLongDrivePlanner, E as InteractableTrait, K as Island, Q as Junk, Ye as KEY_SUN_DIRECTION, dr as KOLMO_ASSETS_URL, At as KOLMO_EXTENSION_NAME, y as KOLMO_KEY_MAP, pn 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, xr 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, Sr 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, Yn as ROOT3, x as RetroViewportSync, S as RoomEnvRig, Mr as SEDAN_4DOOR, Cr 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, An as Step1CalibrationPlinth, Hn as Step2UniversalPad, G as Surface, ze as TILES_PER_MACRO, at as TIN_CAN_HEIGHT, ot as TIN_CAN_RADIUS, gt as TargetDecals, Mn as UNIFIED_ANCHOR_NAMES, fr as VAULT_CARS, pr as VAULT_CATALOG, mr as VAULT_CITY, hr as VAULT_WEAPONS, Nr as VEHICLE_DOMAINS, Pr as VEHICLE_DOMAIN_SPECS, R as Vehicle, O as VehicleTrait, Un 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, wr as attachModule, hn as bakeArticulatedLauncherGlb, Kn as bakeUniversalGateGlb, je as bakeWorldSplatMaps, sn as bodyEyeOffsetY, cn as bodyRestCenterY, ln as bodySpawnPosition, un as bodyStandingHeight, He as buildCarvedTerrainGeometry, Ne as buildDodecagonalCivicHub, Xn as buildFootprint, st as buildGlassBottleGeometry, Ue as buildHighwayAsphaltTexture, Tn as buildImporterWebMcpTools, gn as buildLauncherSceneFromPlan, ee as buildPaletteLutData, B as buildPatchPreviewEmitters, We as buildRoadRibbonGeometry, qt as buildSelectionOverlayGeometry, Ut as buildSurfaceTopology, ct as buildTinCanGeometry, Zn as canPlace, Fr as carUrl, me as childSeed, ye as closedRoadFromPoints, pt as collectValidTris, kn as compileKhrAssetGlb, Nn as computeC12Metrics, V as computeChopPartHinge, ue as computeIslandSpawnPose, fe as computeLongDriveBridgeheadSpawn, pe as computeLongDriveMainlandSpawn, te as computeRetroDpr, Wn as convertUsdToGlb, lt as countGeometryTriangles, gr as createAssetVault, Z as createDefaultSignals, Jt as createFleet12GonWheelGroup, ut as createGlassBottleMaterial, Tr as createLauncherState, tt as createPS2RoadMaterialWebGL, nt as createPS2TerrainMaterialWebGL, $e as createPS2WorldTextures, dt as createTinCanMaterials, H as createVehiclePanelAnimator, jt as decodeKolmoRig, Pn as defaultTargetMeters, Er as detachModule, Fn as detectSceneAnchors, vt as disposeImportedRoot, vn as enforceRetroPersonMaterials, yt as ensureMeshAttributes, A as ensureWorldSession, Rt as extractMeshIslands, he as fbm2, Ir as findCar, Dr as findLauncherRecipe, Yt as findMirrorIslandId, Lr as fleetByDomain, Wt as floodFillByCrease, Ee as frontage, xn as gateTelemetry, et as generatePS2DetailSlices, _t as getBulletHoleTexture, de as getCachedIslandPlan, ne as getColorQuantVector, Gt as getIslandTopology, En as getNavigatorModelContext, re as getPaletteLutTexture, Ct as getProceduralLabelTexture, u as getRetroPreset, d as getRetroShaderUniforms, be as growRoad, Me as hashSeed, Mt as inferKolmoSocketRole, _r as inspectGlbBuffer, Qn as instanceBatches, Sn as isGateStep1Unlocked, Gn as isUsdFileName, In as khrBoxToRapierHalfExtents, j as kolmoActions, M as kolmoTelemetry, N as kolmoWorld, $n as latticePose, wt as loadCustomLabelTexture, xt as loadImportedGlbUrl, De as makeIslandHeightfn, On as makeStarterDomainScene, we as makeTerrain, xe as maxGrade, Ln as measureAssemblyCalibration, Rn as measureNormalizedSceneCalibration, Ft as measureSelection, Kt as mirrorTriangles, Pt as mountPS2WorldMeshes, ge as mulberry32, U as normalToMinusZQuaternion, vr as normalizeGlbBuffer, zt as normalizeSceneToSi, St as parseImportedGlbBuffer, Xt as peelIslandSelection, Rr as planCar, Ge as planDirtSpurs, Oe as planIslandWorld, Or as planLauncher, er as planSettlement, Ze as populateMoonletMatrices, tr as poseEq, nr as poseFromJSON, rr as poseToFloat, ir 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, zn as snapMetersToC12, ar as snapPose, or as socketFor, mt as splitObjectIntoShards, Nt as stampKolmoNodesIntoGlb, dn as stepCameraSync, kr as stepLauncher, It as suggestCarAxles, f as syncRetroUniforms, p as syncRetroViewport, Lt as toggleIslandSelection, le as togglePropJoint, sr as triangleCorners, I as useActiveKolmoWorld, Cn as useGateStore, Dn as useImporterWebMcp, g as useIsKolmoCustomGravity, b as useKolmoInput, _ as useOptionalKootaWorld, L as useWorldTrait, cr as vToFloat, ve as valueNoise2, yr as vaultAssetUrl, fn as withExcludeCharacterRay, lr as worldSockets, Bn 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
|
|
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
|
-
*
|
|
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 };
|
package/dist/junk/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
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 };
|