@pinkaphant/kolmo 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +36 -36
- package/bin/kolmo.mjs +11 -5
- package/dist/engine/causewayBridge.d.ts +14 -0
- package/dist/engine/causewayBridge.js +166 -0
- package/dist/engine/causewayBridge.js.map +1 -0
- package/dist/engine/index.d.ts +6 -4
- package/dist/engine/index.js +19 -12
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/islandSettlementMesh.d.ts +26 -0
- package/dist/engine/islandSettlementMesh.js +166 -0
- package/dist/engine/islandSettlementMesh.js.map +1 -0
- package/dist/engine/kolmoActions.d.ts +23 -0
- package/dist/engine/kolmoActions.js +164 -0
- package/dist/engine/kolmoActions.js.map +1 -0
- package/dist/engine/kolmoActor.js +241 -206
- package/dist/engine/kolmoActor.js.map +1 -0
- package/dist/engine/kolmoFloatingOrigin.d.ts +17 -0
- package/dist/engine/kolmoFloatingOrigin.js +98 -0
- package/dist/engine/kolmoFloatingOrigin.js.map +1 -0
- package/dist/engine/kolmoGame.d.ts +27 -0
- package/dist/engine/kolmoGame.js +80 -0
- package/dist/engine/kolmoGame.js.map +1 -0
- package/dist/engine/kolmoHud.d.ts +23 -0
- package/dist/engine/kolmoHud.js +195 -0
- package/dist/engine/kolmoHud.js.map +1 -0
- package/dist/engine/kolmoInput.d.ts +1 -1
- package/dist/engine/kolmoInput.js +57 -30
- package/dist/engine/kolmoInput.js.map +1 -0
- package/dist/engine/kolmoIsland.d.ts +5 -10
- package/dist/engine/kolmoIsland.js +182 -250
- package/dist/engine/kolmoIsland.js.map +1 -0
- package/dist/engine/kolmoLongDrive.d.ts +3 -4
- package/dist/engine/kolmoLongDrive.js +139 -249
- package/dist/engine/kolmoLongDrive.js.map +1 -0
- package/dist/engine/kolmoPilotMesh.d.ts +2 -0
- package/dist/engine/kolmoPilotMesh.js +64 -0
- package/dist/engine/kolmoPilotMesh.js.map +1 -0
- package/dist/engine/kolmoProcedural.d.ts +13 -0
- package/dist/engine/kolmoProcedural.js +101 -0
- package/dist/engine/kolmoProcedural.js.map +1 -0
- package/dist/engine/kolmoRigs.d.ts +1 -1
- package/dist/engine/kolmoRigs.js +88 -47
- package/dist/engine/kolmoRigs.js.map +1 -0
- package/dist/engine/kolmoStore.d.ts +3 -101
- package/dist/engine/kolmoSurface.d.ts +2 -2
- package/dist/engine/kolmoSurface.js +150 -134
- package/dist/engine/kolmoSurface.js.map +1 -0
- package/dist/engine/kolmoTraits.d.ts +128 -0
- package/dist/engine/kolmoTraits.js +140 -0
- package/dist/engine/kolmoTraits.js.map +1 -0
- package/dist/engine/kolmoVehicle.d.ts +3 -33
- package/dist/engine/kolmoVehicle.js +66 -253
- package/dist/engine/kolmoVehicle.js.map +1 -0
- package/dist/engine/kolmoVehicleConfig.d.ts +54 -0
- package/dist/engine/kolmoVehicleConfig.js +80 -0
- package/dist/engine/kolmoVehicleConfig.js.map +1 -0
- package/dist/engine/kolmoVehicleDriver.d.ts +8 -13
- package/dist/engine/kolmoVehicleDriver.js +116 -42
- package/dist/engine/kolmoVehicleDriver.js.map +1 -0
- package/dist/engine/kolmoVehicleInner.d.ts +7 -0
- package/dist/engine/kolmoVehicleInner.js +261 -0
- package/dist/engine/kolmoVehicleInner.js.map +1 -0
- package/dist/engine/kolmoWorld.d.ts +6 -4
- package/dist/engine/kolmoWorld.js +134 -136
- package/dist/engine/kolmoWorld.js.map +1 -0
- package/dist/engine/longDriveKit.d.ts +5 -12
- package/dist/engine/longDriveKit.js +121 -233
- package/dist/engine/longDriveKit.js.map +1 -0
- package/dist/engine/longDriveRoadside.d.ts +16 -0
- package/dist/engine/longDriveRoadside.js +171 -0
- package/dist/engine/longDriveRoadside.js.map +1 -0
- package/dist/engine/macroCellBuilder.d.ts +34 -0
- package/dist/engine/macroCellBuilder.js +145 -0
- package/dist/engine/macroCellBuilder.js.map +1 -0
- package/dist/engine/mainlandMacroCell.d.ts +2 -2
- package/dist/engine/mainlandMacroCell.js +77 -165
- package/dist/engine/mainlandMacroCell.js.map +1 -0
- package/dist/engine/shiftedFixedBody.d.ts +1 -1
- package/dist/engine/shiftedFixedBody.js +55 -28
- package/dist/engine/shiftedFixedBody.js.map +1 -0
- package/dist/importer/ChopShopPanel.d.ts +10 -32
- package/dist/importer/ChopShopPanel.js +320 -470
- package/dist/importer/ChopShopPanel.js.map +1 -0
- package/dist/importer/DomainWorkshopPanel.d.ts +2 -1
- package/dist/importer/DomainWorkshopPanel.js +172 -242
- package/dist/importer/DomainWorkshopPanel.js.map +1 -0
- package/dist/importer/GateHudBar.d.ts +8 -3
- package/dist/importer/GateHudBar.js +289 -284
- package/dist/importer/GateHudBar.js.map +1 -0
- package/dist/importer/GlbImportGate.d.ts +2 -1
- package/dist/importer/GlbImportGate.js +252 -261
- package/dist/importer/GlbImportGate.js.map +1 -0
- package/dist/importer/ImperativeVehicleRig.d.ts +2 -2
- package/dist/importer/ImperativeVehicleRig.js +223 -284
- package/dist/importer/ImperativeVehicleRig.js.map +1 -0
- package/dist/importer/LiveDrivePads.d.ts +20 -0
- package/dist/importer/LiveDrivePads.js +169 -0
- package/dist/importer/LiveDrivePads.js.map +1 -0
- package/dist/importer/PaperShellDebrisRig.d.ts +25 -0
- package/dist/importer/PaperShellDebrisRig.js +143 -0
- package/dist/importer/PaperShellDebrisRig.js.map +1 -0
- package/dist/importer/R2VaultDrawer.d.ts +12 -0
- package/dist/importer/R2VaultDrawer.js +90 -0
- package/dist/importer/R2VaultDrawer.js.map +1 -0
- package/dist/importer/Step1CalibrationPlinth.d.ts +23 -15
- package/dist/importer/Step1CalibrationPlinth.js +180 -313
- package/dist/importer/Step1CalibrationPlinth.js.map +1 -0
- package/dist/importer/Step1ExplodedIslands.d.ts +31 -0
- package/dist/importer/Step1ExplodedIslands.js +144 -0
- package/dist/importer/Step1ExplodedIslands.js.map +1 -0
- package/dist/importer/Step2UniversalPad.d.ts +7 -14
- package/dist/importer/Step2UniversalPad.js +54 -197
- package/dist/importer/Step2UniversalPad.js.map +1 -0
- package/dist/importer/VfxEmitterPool.js +59 -86
- package/dist/importer/VfxEmitterPool.js.map +1 -0
- package/dist/importer/WheelRingHandles3D.d.ts +11 -0
- package/dist/importer/WheelRingHandles3D.js +318 -0
- package/dist/importer/WheelRingHandles3D.js.map +1 -0
- package/dist/importer/archLinerGeom.d.ts +2 -0
- package/dist/importer/archLinerGeom.js +51 -0
- package/dist/importer/archLinerGeom.js.map +1 -0
- package/dist/importer/{vehiclePanelAnim.d.ts → chopHingeHelpers.d.ts} +0 -10
- package/dist/importer/chopHingeHelpers.js +193 -0
- package/dist/importer/chopHingeHelpers.js.map +1 -0
- package/dist/importer/chopShopActions.d.ts +20 -32
- package/dist/importer/chopShopActions.js +138 -238
- package/dist/importer/chopShopActions.js.map +1 -0
- package/dist/importer/chopShopHandlers.d.ts +26 -0
- package/dist/importer/chopShopHandlers.js +276 -0
- package/dist/importer/chopShopHandlers.js.map +1 -0
- package/dist/importer/chopShopIoActions.d.ts +15 -0
- package/dist/importer/chopShopIoActions.js +137 -0
- package/dist/importer/chopShopIoActions.js.map +1 -0
- package/dist/importer/chopShopMcpAction.d.ts +18 -0
- package/dist/importer/chopShopMcpAction.js +58 -0
- package/dist/importer/chopShopMcpAction.js.map +1 -0
- package/dist/importer/cylinderBooleanSlice.d.ts +14 -0
- package/dist/importer/cylinderBooleanSlice.js +110 -0
- package/dist/importer/cylinderBooleanSlice.js.map +1 -0
- package/dist/importer/cylinderSliceMath.d.ts +14 -0
- package/dist/importer/cylinderSliceMath.js +251 -0
- package/dist/importer/cylinderSliceMath.js.map +1 -0
- package/dist/importer/fusedWheelDetect.d.ts +4 -0
- package/dist/importer/fusedWheelDetect.js +175 -0
- package/dist/importer/fusedWheelDetect.js.map +1 -0
- package/dist/importer/fusedWheelFit.d.ts +13 -0
- package/dist/importer/fusedWheelFit.js +138 -0
- package/dist/importer/fusedWheelFit.js.map +1 -0
- package/dist/importer/gateStore.d.ts +3 -6
- package/dist/importer/gateStore.js +36 -30
- package/dist/importer/gateStore.js.map +1 -0
- package/dist/importer/glbNormalizer.d.ts +1 -10
- package/dist/importer/glbNormalizer.js +120 -146
- package/dist/importer/glbNormalizer.js.map +1 -0
- package/dist/importer/importerWebMcp.d.ts +4 -3
- package/dist/importer/importerWebMcp.js +41 -339
- package/dist/importer/importerWebMcp.js.map +1 -0
- package/dist/importer/importerWebMcpTools.d.ts +2 -0
- package/dist/importer/importerWebMcpTools.js +340 -0
- package/dist/importer/importerWebMcpTools.js.map +1 -0
- package/dist/importer/index.d.ts +6 -4
- package/dist/importer/index.js +32 -25
- package/dist/importer/index.js.map +1 -0
- package/dist/importer/khrCarPlanHelpers.d.ts +28 -0
- package/dist/importer/khrCarPlanHelpers.js +221 -0
- package/dist/importer/khrCarPlanHelpers.js.map +1 -0
- package/dist/importer/khrCarPlanner.d.ts +7 -0
- package/dist/importer/khrCarPlanner.js +279 -0
- package/dist/importer/khrCarPlanner.js.map +1 -0
- package/dist/importer/khrCompiler.d.ts +4 -41
- package/dist/importer/khrCompiler.js +56 -673
- package/dist/importer/khrCompiler.js.map +1 -0
- package/dist/importer/khrCraftPropCompiler.d.ts +40 -0
- package/dist/importer/khrCraftPropCompiler.js +250 -0
- package/dist/importer/khrCraftPropCompiler.js.map +1 -0
- package/dist/importer/launcherBake.js +76 -39
- package/dist/importer/launcherBake.js.map +1 -0
- package/dist/importer/meshIslands.d.ts +4 -50
- package/dist/importer/meshIslands.js +84 -288
- package/dist/importer/meshIslands.js.map +1 -0
- package/dist/importer/meshSliceBuffers.d.ts +15 -0
- package/dist/importer/meshSliceBuffers.js +159 -0
- package/dist/importer/meshSliceBuffers.js.map +1 -0
- package/dist/importer/polygonEarClipYZ.d.ts +3 -0
- package/dist/importer/polygonEarClipYZ.js +67 -0
- package/dist/importer/polygonEarClipYZ.js.map +1 -0
- package/dist/importer/sceneSiNormalize.d.ts +19 -0
- package/dist/importer/sceneSiNormalize.js +138 -0
- package/dist/importer/sceneSiNormalize.js.map +1 -0
- package/dist/importer/starterScene.d.ts +3 -0
- package/dist/importer/starterScene.js +76 -0
- package/dist/importer/starterScene.js.map +1 -0
- package/dist/importer/surfaceCutter.d.ts +5 -25
- package/dist/importer/surfaceCutter.js +70 -334
- package/dist/importer/surfaceCutter.js.map +1 -0
- package/dist/importer/surfaceGeodesic.d.ts +7 -0
- package/dist/importer/surfaceGeodesic.js +130 -0
- package/dist/importer/surfaceGeodesic.js.map +1 -0
- package/dist/importer/surfaceLoopRefine.d.ts +6 -0
- package/dist/importer/surfaceLoopRefine.js +171 -0
- package/dist/importer/surfaceLoopRefine.js.map +1 -0
- package/dist/importer/surfacePeel.d.ts +11 -0
- package/dist/importer/surfacePeel.js +119 -0
- package/dist/importer/surfacePeel.js.map +1 -0
- package/dist/importer/surfaceTopology.d.ts +4 -19
- package/dist/importer/surfaceTopology.js +92 -160
- package/dist/importer/surfaceTopology.js.map +1 -0
- package/dist/importer/universalGateBake.d.ts +7 -9
- package/dist/importer/universalGateBake.js +104 -109
- package/dist/importer/universalGateBake.js.map +1 -0
- package/dist/importer/usdPhysicsSpecs.d.ts +3 -0
- package/dist/importer/usdPhysicsSpecs.js +245 -0
- package/dist/importer/usdPhysicsSpecs.js.map +1 -0
- package/dist/importer/usdTextParse.d.ts +12 -0
- package/dist/importer/usdTextParse.js +118 -0
- package/dist/importer/usdTextParse.js.map +1 -0
- package/dist/importer/usdToGlb.d.ts +3 -2
- package/dist/importer/usdToGlb.js +80 -292
- package/dist/importer/usdToGlb.js.map +1 -0
- package/dist/importer/useChopShopController.d.ts +51 -74
- package/dist/importer/useChopShopController.js +157 -453
- package/dist/importer/useChopShopController.js.map +1 -0
- package/dist/importer/useChopShopState.d.ts +103 -0
- package/dist/importer/useChopShopState.js +319 -0
- package/dist/importer/useChopShopState.js.map +1 -0
- package/dist/importer/useWasdKeyRef.d.ts +9 -0
- package/dist/importer/useWasdKeyRef.js +35 -0
- package/dist/importer/useWasdKeyRef.js.map +1 -0
- package/dist/importer/vehiclePartSplit.d.ts +33 -0
- package/dist/importer/vehiclePartSplit.js +178 -0
- package/dist/importer/vehiclePartSplit.js.map +1 -0
- package/dist/importer/wheelAxlePairing.d.ts +1 -3
- package/dist/importer/wheelAxlePairing.js +106 -119
- package/dist/importer/wheelAxlePairing.js.map +1 -0
- package/dist/importer/wheelCutterHelpers.d.ts +42 -0
- package/dist/importer/wheelCutterHelpers.js +178 -0
- package/dist/importer/wheelCutterHelpers.js.map +1 -0
- package/dist/importer/wheelRingHandleMath.d.ts +20 -0
- package/dist/importer/wheelRingHandleMath.js +66 -0
- package/dist/importer/wheelRingHandleMath.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +90 -69
- package/dist/index.js.map +1 -0
- package/dist/junk/DestructibleTarget.d.ts +3 -3
- package/dist/junk/DestructibleTarget.js +177 -114
- package/dist/junk/DestructibleTarget.js.map +1 -0
- package/dist/junk/KolmoJunk.js +55 -44
- package/dist/junk/KolmoJunk.js.map +1 -0
- package/dist/junk/ShardPieces.d.ts +2 -1
- package/dist/junk/ShardPieces.js +80 -61
- package/dist/junk/ShardPieces.js.map +1 -0
- package/dist/junk/TargetDecals.d.ts +6 -15
- package/dist/junk/TargetDecals.js +66 -40
- package/dist/junk/TargetDecals.js.map +1 -0
- package/dist/junk/bvhShatter.d.ts +2 -6
- package/dist/junk/bvhShatter.js +89 -43
- package/dist/junk/bvhShatter.js.map +1 -0
- package/dist/junk/bvhTriCollector.d.ts +2 -6
- package/dist/junk/bvhTriCollector.js +111 -62
- package/dist/junk/bvhTriCollector.js.map +1 -0
- package/dist/junk/index.d.ts +2 -2
- package/dist/junk/index.js +11 -11
- package/dist/junk/index.js.map +1 -0
- package/dist/junk/junkGeometry.d.ts +5 -26
- package/dist/junk/junkGeometry.js +61 -43
- package/dist/junk/junkGeometry.js.map +1 -0
- package/dist/junk/junkImportSanitize.d.ts +4 -5
- package/dist/junk/junkImportSanitize.js +57 -37
- package/dist/junk/junkImportSanitize.js.map +1 -0
- package/dist/junk/junkImporter.d.ts +2 -13
- package/dist/junk/junkImporter.js +105 -76
- package/dist/junk/junkImporter.js.map +1 -0
- package/dist/junk/junkLabelCanvas.d.ts +1 -6
- package/dist/junk/junkLabelCanvas.js +147 -29
- package/dist/junk/junkLabelCanvas.js.map +1 -0
- package/dist/junk/junkLabels.d.ts +4 -26
- package/dist/junk/junkLabels.js +42 -28
- package/dist/junk/junkLabels.js.map +1 -0
- package/dist/junk/targetHelpers.d.ts +3 -4
- package/dist/junk/targetHelpers.js +121 -67
- package/dist/junk/targetHelpers.js.map +1 -0
- package/dist/junk/targetHitLogic.d.ts +8 -8
- package/dist/junk/targetHitLogic.js +131 -95
- package/dist/junk/targetHitLogic.js.map +1 -0
- package/dist/junk/useTargetAssets.d.ts +9 -14
- package/dist/junk/useTargetAssets.js +113 -85
- package/dist/junk/useTargetAssets.js.map +1 -0
- package/dist/physics/index.d.ts +1 -8
- package/dist/physics/index.js +80 -85
- package/dist/physics/index.js.map +1 -0
- package/dist/schema/kolmoSchema.d.ts +3 -64
- package/dist/schema/kolmoSchema.js +75 -149
- package/dist/schema/kolmoSchema.js.map +1 -0
- package/dist/schema/kolmoStamp.d.ts +6 -0
- package/dist/schema/kolmoStamp.js +71 -0
- package/dist/schema/kolmoStamp.js.map +1 -0
- package/dist/schema/kolmoTypes.d.ts +63 -0
- package/dist/schema/kolmoTypes.js +66 -0
- package/dist/schema/kolmoTypes.js.map +1 -0
- package/dist/shaders/celestialBackdrop.d.ts +2 -10
- package/dist/shaders/celestialBackdrop.js +128 -291
- package/dist/shaders/celestialBackdrop.js.map +1 -0
- package/dist/shaders/emitterShaders.d.ts +9 -0
- package/dist/shaders/emitterShaders.js +114 -0
- package/dist/shaders/emitterShaders.js.map +1 -0
- package/dist/shaders/index.d.ts +1 -1
- package/dist/shaders/index.js +12 -9
- package/dist/shaders/index.js.map +1 -0
- package/dist/shaders/plumeAndSparkle.d.ts +2 -4
- package/dist/shaders/plumeAndSparkle.js +152 -191
- package/dist/shaders/plumeAndSparkle.js.map +1 -0
- package/dist/shaders/ps2GlslShared.js +29 -2
- package/dist/shaders/ps2GlslShared.js.map +1 -0
- package/dist/shaders/ps2MaterialsTSL.js +132 -51
- package/dist/shaders/ps2MaterialsTSL.js.map +1 -0
- package/dist/shaders/ps2MaterialsWebGL.js +45 -28
- package/dist/shaders/ps2MaterialsWebGL.js.map +1 -0
- package/dist/shaders/ps2RoadWebGL.js +69 -32
- package/dist/shaders/ps2RoadWebGL.js.map +1 -0
- package/dist/shaders/ps2TerrainWebGL.js +107 -30
- package/dist/shaders/ps2TerrainWebGL.js.map +1 -0
- package/dist/shaders/ps2Textures.d.ts +1 -1
- package/dist/shaders/ps2Textures.js +116 -41
- package/dist/shaders/ps2Textures.js.map +1 -0
- package/dist/shaders/retroPalettes.d.ts +1 -1
- package/dist/shaders/retroPalettes.js +90 -57
- package/dist/shaders/retroPalettes.js.map +1 -0
- package/dist/shaders/retroShader.d.ts +2 -86
- package/dist/shaders/retroShader.js +65 -196
- package/dist/shaders/retroShader.js.map +1 -0
- package/dist/shaders/retroUniforms.d.ts +60 -0
- package/dist/shaders/retroUniforms.js +215 -0
- package/dist/shaders/retroUniforms.js.map +1 -0
- package/dist/shaders/skyboxShaders.d.ts +16 -0
- package/dist/shaders/skyboxShaders.js +266 -0
- package/dist/shaders/skyboxShaders.js.map +1 -0
- package/dist/shaders/tsl.d.ts +1 -1
- package/dist/shaders/tsl.js.map +1 -0
- package/dist/vite/index.js +39 -23
- package/dist/vite/index.js.map +1 -0
- package/dist/world/frontage.js +25 -21
- package/dist/world/frontage.js.map +1 -0
- package/dist/world/index.d.ts +4 -4
- package/dist/world/index.js +12 -11
- package/dist/world/index.js.map +1 -0
- package/dist/world/infiniteWorld2D.d.ts +0 -5
- package/dist/world/infiniteWorld2D.js +175 -200
- package/dist/world/infiniteWorld2D.js.map +1 -0
- package/dist/world/island.js +81 -166
- package/dist/world/island.js.map +1 -0
- package/dist/world/islandPathing.d.ts +6 -0
- package/dist/world/islandPathing.js +166 -0
- package/dist/world/islandPathing.js.map +1 -0
- package/dist/world/macroCellSchema.js +15 -8
- package/dist/world/macroCellSchema.js.map +1 -0
- package/dist/world/macroKnightAStar.js +140 -71
- package/dist/world/macroKnightAStar.js.map +1 -0
- package/dist/world/macroSettlementZones.d.ts +9 -0
- package/dist/world/macroSettlementZones.js +108 -0
- package/dist/world/macroSettlementZones.js.map +1 -0
- package/dist/world/random.js +50 -24
- package/dist/world/random.js.map +1 -0
- package/dist/world/road.js +152 -90
- package/dist/world/road.js.map +1 -0
- package/dist/world/roadRibbon.d.ts +4 -19
- package/dist/world/roadRibbon.js +129 -124
- package/dist/world/roadRibbon.js.map +1 -0
- package/dist/world/terrain.d.ts +1 -1
- package/dist/world/terrain.js +111 -65
- package/dist/world/terrain.js.map +1 -0
- package/dist/world/terrainGeometry.d.ts +14 -0
- package/dist/world/terrainGeometry.js +76 -0
- package/dist/world/terrainGeometry.js.map +1 -0
- package/dist/world/worldTypes.d.ts +3 -3
- package/dist/world/worldTypes.js +133 -67
- package/dist/world/worldTypes.js.map +1 -0
- package/docs/api-reference.md +187 -0
- package/package.json +58 -32
- package/dist/engine/kolmoStore.js +0 -247
- package/dist/importer/CabinPreviewRig.d.ts +0 -13
- package/dist/importer/CabinPreviewRig.js +0 -138
- package/dist/importer/CabinStepSection.d.ts +0 -17
- package/dist/importer/CabinStepSection.js +0 -222
- package/dist/importer/ImporterPlinthUikitTags.d.ts +0 -20
- package/dist/importer/ImporterPlinthUikitTags.js +0 -119
- package/dist/importer/cabinMeshBuilders.d.ts +0 -13
- package/dist/importer/cabinMeshBuilders.js +0 -104
- package/dist/importer/cabinMixamoRig.d.ts +0 -53
- package/dist/importer/cabinMixamoRig.js +0 -150
- package/dist/importer/chopShopUiComponents.d.ts +0 -22
- package/dist/importer/chopShopUiComponents.js +0 -91
- package/dist/importer/vehiclePanelAnim.js +0 -214
|
@@ -1,95 +1,124 @@
|
|
|
1
|
-
import { disposeImportedRoot
|
|
2
|
-
import * as
|
|
3
|
-
import { GLTFLoader
|
|
1
|
+
import { disposeImportedRoot, ensureMeshAttributes, isMeshNode } from "./junkImportSanitize.js";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
4
|
// src/junk/junkImporter.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var STATIC_ANCHOR_RE = /(base|stand|pedestal|mount|anchor|frame)/i;
|
|
6
|
+
var round4 = (v) => Math.round(v * 1e4) / 1e4;
|
|
7
|
+
function triCount(geo) {
|
|
8
|
+
if (geo.index) return Math.floor(geo.index.count / 3);
|
|
9
|
+
const pos = geo.attributes.position;
|
|
10
|
+
return pos ? Math.floor(pos.count / 3) : 0;
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let i = r.get(t);
|
|
21
|
-
i && (e.userData.destructible = i.destructible, e.userData.customName = i.customName);
|
|
12
|
+
function applySegmentsToImportedRoot(root, segments) {
|
|
13
|
+
const map = new Map(segments.map((s) => [s.segmentId, s]));
|
|
14
|
+
root.traverse((obj) => {
|
|
15
|
+
if (!isMeshNode(obj)) return;
|
|
16
|
+
const id = obj.userData.segmentId;
|
|
17
|
+
if (!id) return;
|
|
18
|
+
const seg = map.get(id);
|
|
19
|
+
if (seg) {
|
|
20
|
+
obj.userData.destructible = seg.destructible;
|
|
21
|
+
obj.userData.customName = seg.customName;
|
|
22
|
+
}
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
async function
|
|
25
|
-
if (!
|
|
26
|
-
|
|
25
|
+
async function parseImportedGlbBuffer(buffer, fileName = "imported.glb") {
|
|
26
|
+
if (!buffer || buffer.byteLength === 0) throw new Error(`Cannot import "${fileName}": file is empty (0 bytes).`);
|
|
27
|
+
const loader = new GLTFLoader();
|
|
28
|
+
let gltfScene;
|
|
27
29
|
try {
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
|
|
31
|
-
throw Error(`Failed to parse GLB "${
|
|
30
|
+
gltfScene = (await loader.parseAsync(buffer.slice(0), "")).scene;
|
|
31
|
+
} catch (err) {
|
|
32
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
33
|
+
throw new Error(`Failed to parse GLB "${fileName}": ${msg}`);
|
|
32
34
|
}
|
|
33
|
-
|
|
35
|
+
const meshes = [];
|
|
34
36
|
try {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
gltfScene.traverse((obj) => {
|
|
38
|
+
if (isMeshNode(obj) && obj.geometry?.attributes?.position) {
|
|
39
|
+
ensureMeshAttributes(obj, fileName);
|
|
40
|
+
meshes.push(obj);
|
|
41
|
+
}
|
|
37
42
|
});
|
|
38
|
-
} catch (
|
|
39
|
-
|
|
43
|
+
} catch (err) {
|
|
44
|
+
disposeImportedRoot(gltfScene);
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
if (meshes.length === 0) {
|
|
48
|
+
disposeImportedRoot(gltfScene);
|
|
49
|
+
throw new Error(`GLB "${fileName}" contains no valid renderable meshes.`);
|
|
40
50
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
gltfScene.updateMatrixWorld(true);
|
|
52
|
+
const rawSize = new THREE.Box3().setFromObject(gltfScene).getSize(new THREE.Vector3());
|
|
53
|
+
const maxDim = Math.max(rawSize.x, rawSize.y, rawSize.z);
|
|
54
|
+
if (!Number.isFinite(maxDim) || maxDim <= 1e-6) {
|
|
55
|
+
disposeImportedRoot(gltfScene);
|
|
56
|
+
throw new Error(`GLB "${fileName}" has invalid or zero-size bounds.`);
|
|
57
|
+
}
|
|
58
|
+
let scale = maxDim > 1.2 || maxDim < .25 ? .55 / maxDim : 1;
|
|
59
|
+
const scaledDim = maxDim * scale;
|
|
60
|
+
if (scaledDim < .1) scale = .1 / maxDim;
|
|
61
|
+
if (scaledDim > 2.5) scale = 2.5 / maxDim;
|
|
62
|
+
gltfScene.scale.multiplyScalar(scale);
|
|
63
|
+
gltfScene.updateMatrixWorld(true);
|
|
64
|
+
const normBox = new THREE.Box3().setFromObject(gltfScene);
|
|
65
|
+
const center = normBox.getCenter(new THREE.Vector3());
|
|
66
|
+
const normSize = normBox.getSize(new THREE.Vector3());
|
|
67
|
+
gltfScene.position.sub(center);
|
|
68
|
+
const root = new THREE.Group();
|
|
69
|
+
root.name = fileName;
|
|
70
|
+
root.add(gltfScene);
|
|
71
|
+
root.updateMatrixWorld(true);
|
|
72
|
+
const anyNonStatic = meshes.some((m) => !STATIC_ANCHOR_RE.test(m.name || m.parent?.name || ""));
|
|
73
|
+
const segBox = new THREE.Box3();
|
|
74
|
+
const segSize = new THREE.Vector3();
|
|
75
|
+
const segments = meshes.map((m, idx) => {
|
|
76
|
+
const segmentId = `seg_${idx}`;
|
|
77
|
+
const originalName = m.name?.trim() || m.parent?.name?.trim() || `Segment ${idx + 1}`;
|
|
78
|
+
const destructible = !anyNonStatic || !STATIC_ANCHOR_RE.test(originalName);
|
|
79
|
+
segBox.setFromObject(m);
|
|
80
|
+
segBox.getSize(segSize);
|
|
81
|
+
m.userData.segmentId = segmentId;
|
|
82
|
+
m.userData.destructible = destructible;
|
|
83
|
+
m.userData.customName = originalName;
|
|
84
|
+
return {
|
|
85
|
+
segmentId,
|
|
86
|
+
originalName,
|
|
87
|
+
customName: originalName,
|
|
88
|
+
destructible,
|
|
89
|
+
triCount: triCount(m.geometry),
|
|
64
90
|
bboxSizeM: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
round4(Math.max(.002, segSize.x)),
|
|
92
|
+
round4(Math.max(.002, segSize.y)),
|
|
93
|
+
round4(Math.max(.002, segSize.z))
|
|
68
94
|
]
|
|
69
95
|
};
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
96
|
+
});
|
|
97
|
+
const bboxSizeM = [
|
|
98
|
+
round4(Math.max(.02, normSize.x)),
|
|
99
|
+
round4(Math.max(.02, normSize.y)),
|
|
100
|
+
round4(Math.max(.02, normSize.z))
|
|
74
101
|
];
|
|
75
102
|
return {
|
|
76
|
-
root
|
|
77
|
-
fileName
|
|
78
|
-
segments
|
|
79
|
-
bboxSizeM
|
|
80
|
-
normalizedExtent:
|
|
103
|
+
root,
|
|
104
|
+
fileName,
|
|
105
|
+
segments,
|
|
106
|
+
bboxSizeM,
|
|
107
|
+
normalizedExtent: round4(Math.max(...bboxSizeM)),
|
|
81
108
|
halfExtents: [
|
|
82
|
-
Math.max(.015,
|
|
83
|
-
Math.max(.015,
|
|
84
|
-
Math.max(.015,
|
|
109
|
+
Math.max(.015, bboxSizeM[0] * .5),
|
|
110
|
+
Math.max(.015, bboxSizeM[1] * .5),
|
|
111
|
+
Math.max(.015, bboxSizeM[2] * .5)
|
|
85
112
|
],
|
|
86
|
-
dispose: () =>
|
|
113
|
+
dispose: () => disposeImportedRoot(root)
|
|
87
114
|
};
|
|
88
115
|
}
|
|
89
|
-
async function
|
|
90
|
-
if (!
|
|
91
|
-
|
|
92
|
-
if (!
|
|
93
|
-
return
|
|
116
|
+
async function loadImportedGlbUrl(url, fileName = "imported.glb") {
|
|
117
|
+
if (!url) throw new Error("No GLB URL provided.");
|
|
118
|
+
const res = await fetch(url);
|
|
119
|
+
if (!res.ok) throw new Error(`Failed to fetch GLB "${fileName}" (${res.status}).`);
|
|
120
|
+
return parseImportedGlbBuffer(await res.arrayBuffer(), fileName);
|
|
94
121
|
}
|
|
95
|
-
export {
|
|
122
|
+
export { applySegmentsToImportedRoot, loadImportedGlbUrl, parseImportedGlbBuffer };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=junkImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junkImporter.js","names":[],"sources":["../../src/junk/junkImporter.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { GLTFLoader } from \"three/examples/jsm/loaders/GLTFLoader.js\";\nimport { disposeImportedRoot, ensureMeshAttributes, isMeshNode } from \"./junkImportSanitize.js\";\nimport type { ImportedJunkSegment } from \"./junkTypes.js\";\n\nconst STATIC_ANCHOR_RE = /(base|stand|pedestal|mount|anchor|frame)/i;\n\nconst round4 = (v: number): number => Math.round(v * 1e4) / 1e4;\n\nfunction triCount(geo: THREE.BufferGeometry): number {\n if (geo.index)\n return Math.floor(geo.index.count / 3);\n const pos = geo.attributes.position;\n return pos ? Math.floor(pos.count / 3) : 0;\n}\n\nexport interface ImportedGlbAsset {\n root: THREE.Group;\n fileName: string;\n segments: ImportedJunkSegment[];\n bboxSizeM: [number, number, number];\n normalizedExtent: number;\n halfExtents: [number, number, number];\n dispose: () => void;\n}\n\nexport function applySegmentsToImportedRoot(root: THREE.Object3D, segments: readonly ImportedJunkSegment[]): void {\n const map = new Map(segments.map((s) => [s.segmentId, s]));\n root.traverse((obj) => {\n if (!isMeshNode(obj))\n return;\n const id = obj.userData.segmentId as string | undefined;\n if (!id)\n return;\n const seg = map.get(id);\n if (seg) {\n obj.userData.destructible = seg.destructible;\n obj.userData.customName = seg.customName;\n }\n });\n}\n\nexport async function parseImportedGlbBuffer(buffer: ArrayBuffer, fileName = \"imported.glb\"): Promise<ImportedGlbAsset> {\n if (!buffer || buffer.byteLength === 0) {\n throw new Error(`Cannot import \"${fileName}\": file is empty (0 bytes).`);\n }\n const loader = new GLTFLoader();\n let gltfScene: THREE.Group;\n try {\n const gltf = await loader.parseAsync(buffer.slice(0), \"\");\n gltfScene = gltf.scene;\n }\n catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`Failed to parse GLB \"${fileName}\": ${msg}`);\n }\n\n const meshes: THREE.Mesh[] = [];\n try {\n gltfScene.traverse((obj) => {\n if (isMeshNode(obj) && obj.geometry?.attributes?.position) {\n ensureMeshAttributes(obj, fileName);\n meshes.push(obj);\n }\n });\n }\n catch (err) {\n disposeImportedRoot(gltfScene);\n throw err;\n }\n\n if (meshes.length === 0) {\n disposeImportedRoot(gltfScene);\n throw new Error(`GLB \"${fileName}\" contains no valid renderable meshes.`);\n }\n\n gltfScene.updateMatrixWorld(true);\n const rawBox = new THREE.Box3().setFromObject(gltfScene);\n const rawSize = rawBox.getSize(new THREE.Vector3());\n const maxDim = Math.max(rawSize.x, rawSize.y, rawSize.z);\n if (!Number.isFinite(maxDim) || maxDim <= 1e-6) {\n disposeImportedRoot(gltfScene);\n throw new Error(`GLB \"${fileName}\" has invalid or zero-size bounds.`);\n }\n\n let scale = maxDim > 1.2 || maxDim < 0.25 ? 0.55 / maxDim : 1;\n const scaledDim = maxDim * scale;\n if (scaledDim < 0.1) scale = 0.1 / maxDim;\n if (scaledDim > 2.5) scale = 2.5 / maxDim;\n gltfScene.scale.multiplyScalar(scale);\n gltfScene.updateMatrixWorld(true);\n\n const normBox = new THREE.Box3().setFromObject(gltfScene);\n const center = normBox.getCenter(new THREE.Vector3());\n const normSize = normBox.getSize(new THREE.Vector3());\n gltfScene.position.sub(center);\n\n const root = new THREE.Group();\n root.name = fileName;\n root.add(gltfScene);\n root.updateMatrixWorld(true);\n\n const anyNonStatic = meshes.some((m) => !STATIC_ANCHOR_RE.test(m.name || m.parent?.name || \"\"));\n const segBox = new THREE.Box3();\n const segSize = new THREE.Vector3();\n const segments: ImportedJunkSegment[] = meshes.map((m, idx) => {\n const segmentId = `seg_${idx}`;\n const originalName = m.name?.trim() || m.parent?.name?.trim() || `Segment ${idx + 1}`;\n const destructible = !anyNonStatic || !STATIC_ANCHOR_RE.test(originalName);\n segBox.setFromObject(m);\n segBox.getSize(segSize);\n m.userData.segmentId = segmentId;\n m.userData.destructible = destructible;\n m.userData.customName = originalName;\n return {\n segmentId,\n originalName,\n customName: originalName,\n destructible,\n triCount: triCount(m.geometry),\n bboxSizeM: [round4(Math.max(0.002, segSize.x)), round4(Math.max(0.002, segSize.y)), round4(Math.max(0.002, segSize.z))],\n };\n });\n\n const bboxSizeM: [number, number, number] = [\n round4(Math.max(0.02, normSize.x)),\n round4(Math.max(0.02, normSize.y)),\n round4(Math.max(0.02, normSize.z)),\n ];\n return {\n root,\n fileName,\n segments,\n bboxSizeM,\n normalizedExtent: round4(Math.max(...bboxSizeM)),\n halfExtents: [Math.max(0.015, bboxSizeM[0] * 0.5), Math.max(0.015, bboxSizeM[1] * 0.5), Math.max(0.015, bboxSizeM[2] * 0.5)],\n dispose: () => disposeImportedRoot(root),\n };\n}\n\nexport async function loadImportedGlbUrl(url: string, fileName = \"imported.glb\"): Promise<ImportedGlbAsset> {\n if (!url)\n throw new Error(\"No GLB URL provided.\");\n const res = await fetch(url);\n if (!res.ok)\n throw new Error(`Failed to fetch GLB \"${fileName}\" (${res.status}).`);\n return parseImportedGlbBuffer(await res.arrayBuffer(), fileName);\n}\n"],"mappings":";;;;AAKA,IAAM,mBAAmB;AAEzB,IAAM,UAAU,MAAsB,KAAK,MAAM,IAAI,GAAG,IAAI;AAE5D,SAAS,SAAS,KAAmC;CACjD,IAAI,IAAI,OACJ,OAAO,KAAK,MAAM,IAAI,MAAM,QAAQ,CAAC;CACzC,MAAM,MAAM,IAAI,WAAW;CAC3B,OAAO,MAAM,KAAK,MAAM,IAAI,QAAQ,CAAC,IAAI;AAC7C;AAYA,SAAgB,4BAA4B,MAAsB,UAAgD;CAC9G,MAAM,MAAM,IAAI,IAAI,SAAS,KAAK,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;CACzD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CAAC,CAAC;IAAG,OAAO,KAAK,IAAI,MAAO,QAAQ,CAAC,CAAC;IAAG,OAAO,KAAK,IAAI,MAAO,QAAQ,CAAC,CAAC;GAAC;EAC1H;CACJ,CAAC;CAED,MAAM,YAAsC;EACxC,OAAO,KAAK,IAAI,KAAM,SAAS,CAAC,CAAC;EACjC,OAAO,KAAK,IAAI,KAAM,SAAS,CAAC,CAAC;EACjC,OAAO,KAAK,IAAI,KAAM,SAAS,CAAC,CAAC;CACrC;CACA,OAAO;EACH;EACA;EACA;EACA;EACA,kBAAkB,OAAO,KAAK,IAAI,GAAG,SAAS,CAAC;EAC/C,aAAa;GAAC,KAAK,IAAI,MAAO,UAAU,KAAK,EAAG;GAAG,KAAK,IAAI,MAAO,UAAU,KAAK,EAAG;GAAG,KAAK,IAAI,MAAO,UAAU,KAAK,EAAG;EAAC;EAC3H,eAAe,oBAAoB,IAAI;CAC3C;AACJ;AAEA,eAAsB,mBAAmB,KAAa,WAAW,gBAA2C;CACxG,IAAI,CAAC,KACD,MAAM,IAAI,MAAM,sBAAsB;CAC1C,MAAM,MAAM,MAAM,MAAM,GAAG;CAC3B,IAAI,CAAC,IAAI,IACL,MAAM,IAAI,MAAM,wBAAwB,SAAS,KAAK,IAAI,OAAO,GAAG;CACxE,OAAO,uBAAuB,MAAM,IAAI,YAAY,GAAG,QAAQ;AACnE"}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
import type { ProceduralLabelId } from "./junkTypes.js";
|
|
2
|
-
export declare
|
|
3
|
-
export declare const LABEL_CANVAS_HEIGHT = 256;
|
|
4
|
-
/**
|
|
5
|
-
* Draws one of the 4 built-in procedural labels onto a 2D canvas context.
|
|
6
|
-
*/
|
|
7
|
-
export declare function renderProceduralLabelCanvas(ctx: CanvasRenderingContext2D, labelId: Exclude<ProceduralLabelId, 'custom'>, width?: number, height?: number): void;
|
|
2
|
+
export declare function renderProceduralLabelCanvas(ctx: CanvasRenderingContext2D, id: ProceduralLabelId, w?: number, h?: number): void;
|
|
@@ -1,26 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// src/junk/junkLabelCanvas.ts
|
|
2
|
+
function drawTargetLabel(ctx, w, h) {
|
|
3
|
+
ctx.fillStyle = "#f8fafc";
|
|
4
|
+
ctx.fillRect(0, 0, w, h);
|
|
5
|
+
ctx.fillStyle = "#0f172a";
|
|
6
|
+
ctx.fillRect(0, 0, w * .14, h);
|
|
7
|
+
ctx.fillRect(w * .86, 0, w * .14, h);
|
|
8
|
+
const cx = w * .5;
|
|
9
|
+
const cy = h * .5;
|
|
10
|
+
for (const [r, col] of [
|
|
5
11
|
[108, "#0f172a"],
|
|
6
12
|
[86, "#f8fafc"],
|
|
7
13
|
[64, "#dc2626"],
|
|
8
14
|
[42, "#f8fafc"],
|
|
9
15
|
[22, "#ef4444"],
|
|
10
16
|
[9, "#facc15"]
|
|
11
|
-
])
|
|
12
|
-
|
|
17
|
+
]) {
|
|
18
|
+
ctx.beginPath();
|
|
19
|
+
ctx.arc(cx, cy, r, 0, Math.PI * 2);
|
|
20
|
+
ctx.fillStyle = col;
|
|
21
|
+
ctx.fill();
|
|
22
|
+
}
|
|
23
|
+
ctx.strokeStyle = "#0f172a";
|
|
24
|
+
ctx.lineWidth = 3;
|
|
25
|
+
ctx.beginPath();
|
|
26
|
+
ctx.moveTo(cx - 118, cy);
|
|
27
|
+
ctx.lineTo(cx - 90, cy);
|
|
28
|
+
ctx.moveTo(cx + 90, cy);
|
|
29
|
+
ctx.lineTo(cx + 118, cy);
|
|
30
|
+
ctx.moveTo(cx, cy - 118);
|
|
31
|
+
ctx.lineTo(cx, cy - 90);
|
|
32
|
+
ctx.moveTo(cx, cy + 90);
|
|
33
|
+
ctx.lineTo(cx, cy + 118);
|
|
34
|
+
ctx.stroke();
|
|
13
35
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
36
|
+
function drawGoofyEmojiLabel(ctx, w, h) {
|
|
37
|
+
ctx.fillStyle = "#facc15";
|
|
38
|
+
ctx.fillRect(0, 0, w, h);
|
|
39
|
+
ctx.fillStyle = "#eab308";
|
|
40
|
+
for (let x = 24; x < w; x += 48) for (let y = 24; y < h; y += 48) {
|
|
41
|
+
ctx.beginPath();
|
|
42
|
+
ctx.arc(x, y, 8, 0, Math.PI * 2);
|
|
43
|
+
ctx.fill();
|
|
44
|
+
}
|
|
45
|
+
const cx = w * .5;
|
|
46
|
+
const cy = h * .5;
|
|
47
|
+
ctx.beginPath();
|
|
48
|
+
ctx.arc(cx, cy, 96, 0, Math.PI * 2);
|
|
49
|
+
ctx.fillStyle = "#fde047";
|
|
50
|
+
ctx.fill();
|
|
51
|
+
ctx.lineWidth = 7;
|
|
52
|
+
ctx.strokeStyle = "#18181b";
|
|
53
|
+
ctx.stroke();
|
|
54
|
+
ctx.fillStyle = "#ffffff";
|
|
55
|
+
ctx.beginPath();
|
|
56
|
+
ctx.arc(cx - 34, cy - 22, 24, 0, Math.PI * 2);
|
|
57
|
+
ctx.arc(cx + 34, cy - 26, 17, 0, Math.PI * 2);
|
|
58
|
+
ctx.fill();
|
|
59
|
+
ctx.stroke();
|
|
60
|
+
ctx.fillStyle = "#18181b";
|
|
61
|
+
ctx.beginPath();
|
|
62
|
+
ctx.arc(cx - 26, cy - 18, 9, 0, Math.PI * 2);
|
|
63
|
+
ctx.arc(cx + 38, cy - 30, 8, 0, Math.PI * 2);
|
|
64
|
+
ctx.fill();
|
|
65
|
+
ctx.beginPath();
|
|
66
|
+
ctx.arc(cx, cy + 12, 52, .1 * Math.PI, .9 * Math.PI);
|
|
67
|
+
ctx.fillStyle = "#7f1d1d";
|
|
68
|
+
ctx.fill();
|
|
69
|
+
ctx.stroke();
|
|
70
|
+
ctx.fillStyle = "#fb7185";
|
|
71
|
+
ctx.beginPath();
|
|
72
|
+
ctx.ellipse(cx + 12, cy + 56, 20, 24, .12, 0, Math.PI * 2);
|
|
73
|
+
ctx.fill();
|
|
74
|
+
ctx.stroke();
|
|
75
|
+
ctx.fillStyle = "#ffffff";
|
|
76
|
+
ctx.fillRect(cx - 22, cy + 16, 16, 14);
|
|
77
|
+
ctx.fillRect(cx + 4, cy + 16, 16, 14);
|
|
19
78
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
79
|
+
function drawTrisSodaLabel(ctx, w, h) {
|
|
80
|
+
const grad = ctx.createLinearGradient(0, 0, w, h);
|
|
81
|
+
grad.addColorStop(0, "#0284c7");
|
|
82
|
+
grad.addColorStop(.5, "#06b6d4");
|
|
83
|
+
grad.addColorStop(1, "#2563eb");
|
|
84
|
+
ctx.fillStyle = grad;
|
|
85
|
+
ctx.fillRect(0, 0, w, h);
|
|
86
|
+
ctx.fillStyle = "#ec4899";
|
|
87
|
+
ctx.beginPath();
|
|
88
|
+
ctx.moveTo(0, h * .72);
|
|
89
|
+
ctx.lineTo(w, h * .25);
|
|
90
|
+
ctx.lineTo(w, h * .42);
|
|
91
|
+
ctx.lineTo(0, h * .89);
|
|
92
|
+
ctx.closePath();
|
|
93
|
+
ctx.fill();
|
|
94
|
+
ctx.fillStyle = "#fde047";
|
|
95
|
+
ctx.fillRect(0, 14, w, 14);
|
|
96
|
+
ctx.fillRect(0, h - 28, w, 14);
|
|
97
|
+
ctx.fillStyle = "rgba(255,255,255,0.45)";
|
|
98
|
+
for (const [x, y, r] of [
|
|
24
99
|
[
|
|
25
100
|
130,
|
|
26
101
|
70,
|
|
@@ -41,27 +116,70 @@ function n(e, t, n) {
|
|
|
41
116
|
185,
|
|
42
117
|
9
|
|
43
118
|
]
|
|
44
|
-
])
|
|
45
|
-
|
|
46
|
-
|
|
119
|
+
]) {
|
|
120
|
+
ctx.beginPath();
|
|
121
|
+
ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
122
|
+
ctx.fill();
|
|
123
|
+
}
|
|
124
|
+
const cx = w * .5;
|
|
125
|
+
const cy = h * .5;
|
|
126
|
+
ctx.fillStyle = "#0f172a";
|
|
127
|
+
ctx.fillRect(cx - 122, cy - 48, 244, 96);
|
|
128
|
+
ctx.strokeStyle = "#fde047";
|
|
129
|
+
ctx.lineWidth = 5;
|
|
130
|
+
ctx.strokeRect(cx - 122, cy - 48, 244, 96);
|
|
131
|
+
ctx.textAlign = "center";
|
|
132
|
+
ctx.textBaseline = "middle";
|
|
133
|
+
ctx.fillStyle = "#fde047";
|
|
134
|
+
ctx.font = "bold 34px sans-serif";
|
|
135
|
+
ctx.fillText("TRIS' SODA", cx, cy - 12);
|
|
136
|
+
ctx.fillStyle = "#67e8f9";
|
|
137
|
+
ctx.font = "bold 18px monospace";
|
|
138
|
+
ctx.fillText("DREAMCAST FIZZ", cx, cy + 24);
|
|
47
139
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
140
|
+
function drawGarysBeansLabel(ctx, w, h) {
|
|
141
|
+
ctx.fillStyle = "#fef3c7";
|
|
142
|
+
ctx.fillRect(0, 0, w, h);
|
|
143
|
+
ctx.fillStyle = "#b91c1c";
|
|
144
|
+
ctx.fillRect(0, 0, w, h * .46);
|
|
145
|
+
ctx.fillStyle = "#1e3a8a";
|
|
146
|
+
ctx.fillRect(0, h * .8, w, h * .2);
|
|
147
|
+
ctx.fillStyle = "#f59e0b";
|
|
148
|
+
ctx.fillRect(0, h * .45, w, 10);
|
|
149
|
+
const cx = w * .5;
|
|
150
|
+
ctx.beginPath();
|
|
151
|
+
ctx.ellipse(cx, h * .62, 62, 34, 0, 0, Math.PI * 2);
|
|
152
|
+
ctx.fillStyle = "#78350f";
|
|
153
|
+
ctx.fill();
|
|
154
|
+
ctx.lineWidth = 4;
|
|
155
|
+
ctx.strokeStyle = "#f59e0b";
|
|
156
|
+
ctx.stroke();
|
|
157
|
+
ctx.textAlign = "center";
|
|
158
|
+
ctx.textBaseline = "middle";
|
|
159
|
+
ctx.fillStyle = "#fef3c7";
|
|
160
|
+
ctx.font = "bold 36px serif";
|
|
161
|
+
ctx.fillText("GARY'S", cx, 46);
|
|
162
|
+
ctx.fillStyle = "#fde047";
|
|
163
|
+
ctx.font = "bold 28px sans-serif";
|
|
164
|
+
ctx.fillText("BEANS", cx, 88);
|
|
165
|
+
ctx.fillStyle = "#fef3c7";
|
|
166
|
+
ctx.font = "bold 18px sans-serif";
|
|
167
|
+
ctx.fillText("BAKED IN SAUCE", cx, h * .62);
|
|
52
168
|
}
|
|
53
|
-
function
|
|
54
|
-
switch (
|
|
169
|
+
function renderProceduralLabelCanvas(ctx, id, w = 512, h = 256) {
|
|
170
|
+
switch (id) {
|
|
55
171
|
case "target":
|
|
56
|
-
|
|
172
|
+
drawTargetLabel(ctx, w, h);
|
|
57
173
|
break;
|
|
58
174
|
case "goofy-emoji":
|
|
59
|
-
|
|
175
|
+
drawGoofyEmojiLabel(ctx, w, h);
|
|
60
176
|
break;
|
|
61
177
|
case "tris-soda":
|
|
62
|
-
|
|
178
|
+
drawTrisSodaLabel(ctx, w, h);
|
|
63
179
|
break;
|
|
64
|
-
case "garys-beans":
|
|
180
|
+
case "garys-beans": drawGarysBeansLabel(ctx, w, h);
|
|
65
181
|
}
|
|
66
182
|
}
|
|
67
|
-
export {
|
|
183
|
+
export { renderProceduralLabelCanvas };
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=junkLabelCanvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junkLabelCanvas.js","names":[],"sources":["../../src/junk/junkLabelCanvas.ts"],"sourcesContent":["import type { ProceduralLabelId } from \"./junkTypes.js\";\n\nfunction drawTargetLabel(ctx: CanvasRenderingContext2D, w: number, h: number): void {\n ctx.fillStyle = \"#f8fafc\";\n ctx.fillRect(0, 0, w, h);\n ctx.fillStyle = \"#0f172a\";\n ctx.fillRect(0, 0, w * 0.14, h);\n ctx.fillRect(w * 0.86, 0, w * 0.14, h);\n const cx = w * 0.5;\n const cy = h * 0.5;\n for (const [r, col] of [\n [108, \"#0f172a\"],\n [86, \"#f8fafc\"],\n [64, \"#dc2626\"],\n [42, \"#f8fafc\"],\n [22, \"#ef4444\"],\n [9, \"#facc15\"],\n ] as const) {\n ctx.beginPath();\n ctx.arc(cx, cy, r, 0, Math.PI * 2);\n ctx.fillStyle = col;\n ctx.fill();\n }\n ctx.strokeStyle = \"#0f172a\";\n ctx.lineWidth = 3;\n ctx.beginPath();\n ctx.moveTo(cx - 118, cy);\n ctx.lineTo(cx - 90, cy);\n ctx.moveTo(cx + 90, cy);\n ctx.lineTo(cx + 118, cy);\n ctx.moveTo(cx, cy - 118);\n ctx.lineTo(cx, cy - 90);\n ctx.moveTo(cx, cy + 90);\n ctx.lineTo(cx, cy + 118);\n ctx.stroke();\n}\n\nfunction drawGoofyEmojiLabel(ctx: CanvasRenderingContext2D, w: number, h: number): void {\n ctx.fillStyle = \"#facc15\";\n ctx.fillRect(0, 0, w, h);\n ctx.fillStyle = \"#eab308\";\n for (let x = 24; x < w; x += 48) {\n for (let y = 24; y < h; y += 48) {\n ctx.beginPath();\n ctx.arc(x, y, 8, 0, Math.PI * 2);\n ctx.fill();\n }\n }\n const cx = w * 0.5;\n const cy = h * 0.5;\n ctx.beginPath();\n ctx.arc(cx, cy, 96, 0, Math.PI * 2);\n ctx.fillStyle = \"#fde047\";\n ctx.fill();\n ctx.lineWidth = 7;\n ctx.strokeStyle = \"#18181b\";\n ctx.stroke();\n ctx.fillStyle = \"#ffffff\";\n ctx.beginPath();\n ctx.arc(cx - 34, cy - 22, 24, 0, Math.PI * 2);\n ctx.arc(cx + 34, cy - 26, 17, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n ctx.fillStyle = \"#18181b\";\n ctx.beginPath();\n ctx.arc(cx - 26, cy - 18, 9, 0, Math.PI * 2);\n ctx.arc(cx + 38, cy - 30, 8, 0, Math.PI * 2);\n ctx.fill();\n ctx.beginPath();\n ctx.arc(cx, cy + 12, 52, 0.1 * Math.PI, 0.9 * Math.PI);\n ctx.fillStyle = \"#7f1d1d\";\n ctx.fill();\n ctx.stroke();\n ctx.fillStyle = \"#fb7185\";\n ctx.beginPath();\n ctx.ellipse(cx + 12, cy + 56, 20, 24, 0.12, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n ctx.fillStyle = \"#ffffff\";\n ctx.fillRect(cx - 22, cy + 16, 16, 14);\n ctx.fillRect(cx + 4, cy + 16, 16, 14);\n}\n\nfunction drawTrisSodaLabel(ctx: CanvasRenderingContext2D, w: number, h: number): void {\n const grad = ctx.createLinearGradient(0, 0, w, h);\n grad.addColorStop(0, \"#0284c7\");\n grad.addColorStop(0.5, \"#06b6d4\");\n grad.addColorStop(1, \"#2563eb\");\n ctx.fillStyle = grad;\n ctx.fillRect(0, 0, w, h);\n ctx.fillStyle = \"#ec4899\";\n ctx.beginPath();\n ctx.moveTo(0, h * 0.72);\n ctx.lineTo(w, h * 0.25);\n ctx.lineTo(w, h * 0.42);\n ctx.lineTo(0, h * 0.89);\n ctx.closePath();\n ctx.fill();\n ctx.fillStyle = \"#fde047\";\n ctx.fillRect(0, 14, w, 14);\n ctx.fillRect(0, h - 28, w, 14);\n ctx.fillStyle = \"rgba(255,255,255,0.45)\";\n for (const [x, y, r] of [\n [130, 70, 10],\n [165, 190, 14],\n [350, 62, 12],\n [380, 185, 9],\n ] as const) {\n ctx.beginPath();\n ctx.arc(x, y, r, 0, Math.PI * 2);\n ctx.fill();\n }\n const cx = w * 0.5;\n const cy = h * 0.5;\n ctx.fillStyle = \"#0f172a\";\n ctx.fillRect(cx - 122, cy - 48, 244, 96);\n ctx.strokeStyle = \"#fde047\";\n ctx.lineWidth = 5;\n ctx.strokeRect(cx - 122, cy - 48, 244, 96);\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = \"#fde047\";\n ctx.font = \"bold 34px sans-serif\";\n ctx.fillText(\"TRIS' SODA\", cx, cy - 12);\n ctx.fillStyle = \"#67e8f9\";\n ctx.font = \"bold 18px monospace\";\n ctx.fillText(\"DREAMCAST FIZZ\", cx, cy + 24);\n}\n\nfunction drawGarysBeansLabel(ctx: CanvasRenderingContext2D, w: number, h: number): void {\n ctx.fillStyle = \"#fef3c7\";\n ctx.fillRect(0, 0, w, h);\n ctx.fillStyle = \"#b91c1c\";\n ctx.fillRect(0, 0, w, h * 0.46);\n ctx.fillStyle = \"#1e3a8a\";\n ctx.fillRect(0, h * 0.8, w, h * 0.2);\n ctx.fillStyle = \"#f59e0b\";\n ctx.fillRect(0, h * 0.45, w, 10);\n const cx = w * 0.5;\n ctx.beginPath();\n ctx.ellipse(cx, h * 0.62, 62, 34, 0, 0, Math.PI * 2);\n ctx.fillStyle = \"#78350f\";\n ctx.fill();\n ctx.lineWidth = 4;\n ctx.strokeStyle = \"#f59e0b\";\n ctx.stroke();\n ctx.textAlign = \"center\";\n ctx.textBaseline = \"middle\";\n ctx.fillStyle = \"#fef3c7\";\n ctx.font = \"bold 36px serif\";\n ctx.fillText(\"GARY'S\", cx, 46);\n ctx.fillStyle = \"#fde047\";\n ctx.font = \"bold 28px sans-serif\";\n ctx.fillText(\"BEANS\", cx, 88);\n ctx.fillStyle = \"#fef3c7\";\n ctx.font = \"bold 18px sans-serif\";\n ctx.fillText(\"BAKED IN SAUCE\", cx, h * 0.62);\n}\n\nexport function renderProceduralLabelCanvas(\n ctx: CanvasRenderingContext2D,\n id: ProceduralLabelId,\n w = 512,\n h = 256,\n): void {\n switch (id) {\n case \"target\":\n drawTargetLabel(ctx, w, h);\n break;\n case \"goofy-emoji\":\n drawGoofyEmojiLabel(ctx, w, h);\n break;\n case \"tris-soda\":\n drawTrisSodaLabel(ctx, w, h);\n break;\n case \"garys-beans\":\n drawGarysBeansLabel(ctx, w, h);\n break;\n }\n}\n"],"mappings":";AAEA,SAAS,gBAAgB,KAA+B,GAAW,GAAiB;CAChF,IAAI,YAAY;CAChB,IAAI,SAAS,GAAG,GAAG,GAAG,CAAC;CACvB,IAAI,YAAY;CAChB,IAAI,SAAS,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nC,IAAI,YAAY;CAChB,IAAI,SAAS,GAAG,IAAI,KAAM,GAAG,EAAE;CAC/B,MAAM,KAAK,IAAI;CACf,IAAI,UAAU;CACd,IAAI,QAAQ,IAAI,IAAI,KAAM,IAAI,IAAI,GAAG,GAAG,KAAK,KAAK,CAAC;CACnD,IAAI,YAAY;CAChB,IAAI,KAAK;CACT,IAAI,YAAY;CAChB,IAAI,cAAc;CAClB,IAAI,OAAO;CACX,IAAI,YAAY;CAChB,IAAI,eAAe;CACnB,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAI,SAAS,UAAU,IAAI,EAAE;CAC7B,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAI,SAAS,SAAS,IAAI,EAAE;CAC5B,IAAI,YAAY;CAChB,IAAI,OAAO;CACX,IAAI,SAAS,kBAAkB,IAAI,IAAI,GAAI;AAC/C;AAEA,SAAgB,4BACZ,KACA,IACA,IAAI,KACJ,IAAI,KACA;CACJ,QAAQ,IAAR;EACI,KAAK;GACD,gBAAgB,KAAK,GAAG,CAAC;GACzB;EACJ,KAAK;GACD,oBAAoB,KAAK,GAAG,CAAC;GAC7B;EACJ,KAAK;GACD,kBAAkB,KAAK,GAAG,CAAC;GAC3B;EACJ,KAAK,eACD,oBAAoB,KAAK,GAAG,CAAC;CAErC;AACJ"}
|
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
import * as THREE from
|
|
1
|
+
import * as THREE from "three";
|
|
2
2
|
import type { ProceduralLabelId } from "./junkTypes.js";
|
|
3
|
-
export declare
|
|
4
|
-
/**
|
|
5
|
-
* Generates or retrieves a cached deterministic CanvasTexture for built-in labels.
|
|
6
|
-
* Returns null safely in non-DOM SSR environments.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getProceduralLabelTexture(labelId: ProceduralLabelId, options?: {
|
|
3
|
+
export declare function getProceduralLabelTexture(id: ProceduralLabelId, opts?: {
|
|
9
4
|
cache?: boolean;
|
|
10
5
|
}): THREE.CanvasTexture | null;
|
|
11
|
-
|
|
12
|
-
* Validates an uploaded image File before creating a custom label texture.
|
|
13
|
-
* Returns null if valid, or a descriptive error message if invalid.
|
|
14
|
-
*/
|
|
15
|
-
export declare function validateLabelImageFile(file: File): string | null;
|
|
16
|
-
export interface LoadedCustomLabel {
|
|
6
|
+
export declare function loadCustomLabelTexture(url: string): Promise<{
|
|
17
7
|
texture: THREE.Texture;
|
|
18
8
|
dispose: () => void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Loads a custom albedo texture from a URL or DataURL with SRGBColorSpace and cleanup handle.
|
|
22
|
-
*/
|
|
23
|
-
export declare function loadCustomLabelTexture(url: string): Promise<LoadedCustomLabel>;
|
|
24
|
-
/**
|
|
25
|
-
* Validates that an image URL decodes cleanly in the browser before applying it as a label.
|
|
26
|
-
*/
|
|
27
|
-
export declare function decodeLabelImageUrl(url: string): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Disposes all module-cached procedural label textures.
|
|
30
|
-
*/
|
|
31
|
-
export declare function disposeCachedLabelTextures(): void;
|
|
9
|
+
}>;
|
package/dist/junk/junkLabels.js
CHANGED
|
@@ -1,35 +1,49 @@
|
|
|
1
|
-
import { renderProceduralLabelCanvas
|
|
2
|
-
import * as
|
|
1
|
+
import { renderProceduralLabelCanvas } from "./junkLabelCanvas.js";
|
|
2
|
+
import * as THREE from "three";
|
|
3
3
|
// src/junk/junkLabels.ts
|
|
4
|
-
var
|
|
5
|
-
function
|
|
6
|
-
|
|
4
|
+
var labelCache = /* @__PURE__ */ new Map();
|
|
5
|
+
function configureTex(tex) {
|
|
6
|
+
tex.colorSpace = THREE.SRGBColorSpace;
|
|
7
|
+
tex.wrapS = THREE.RepeatWrapping;
|
|
8
|
+
tex.wrapT = THREE.ClampToEdgeWrapping;
|
|
9
|
+
tex.flipY = true;
|
|
10
|
+
tex.anisotropy = 1;
|
|
11
|
+
tex.needsUpdate = true;
|
|
12
|
+
return tex;
|
|
7
13
|
}
|
|
8
|
-
function
|
|
9
|
-
if (typeof document
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
function getProceduralLabelTexture(id, opts) {
|
|
15
|
+
if (typeof document === "undefined") return null;
|
|
16
|
+
const key = id === "custom" ? "target" : id;
|
|
17
|
+
const useCache = opts?.cache !== false;
|
|
18
|
+
if (useCache) {
|
|
19
|
+
const hit = labelCache.get(key);
|
|
20
|
+
if (hit) return hit;
|
|
14
21
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const canvas = document.createElement("canvas");
|
|
23
|
+
canvas.width = 512;
|
|
24
|
+
canvas.height = 256;
|
|
25
|
+
const ctx = canvas.getContext("2d");
|
|
26
|
+
if (!ctx) return null;
|
|
27
|
+
renderProceduralLabelCanvas(ctx, key, canvas.width, canvas.height);
|
|
28
|
+
const tex = configureTex(new THREE.CanvasTexture(canvas));
|
|
29
|
+
if (useCache) labelCache.set(key, tex);
|
|
30
|
+
return tex;
|
|
22
31
|
}
|
|
23
|
-
function
|
|
24
|
-
return new Promise((
|
|
25
|
-
!
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
function loadCustomLabelTexture(url) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
if (!url || typeof url !== "string") {
|
|
35
|
+
reject(/* @__PURE__ */ new Error("Invalid custom label URL."));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
new THREE.TextureLoader().load(url, (tex) => {
|
|
39
|
+
configureTex(tex);
|
|
40
|
+
resolve({
|
|
41
|
+
texture: tex,
|
|
42
|
+
dispose: () => tex.dispose()
|
|
29
43
|
});
|
|
30
|
-
}, void 0, () =>
|
|
31
|
-
i(/* @__PURE__ */ Error("Failed to decode custom label image from URL."));
|
|
32
|
-
});
|
|
44
|
+
}, void 0, () => reject(/* @__PURE__ */ new Error("Failed to decode custom label image from URL.")));
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
|
-
export {
|
|
47
|
+
export { getProceduralLabelTexture, loadCustomLabelTexture };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=junkLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"junkLabels.js","names":[],"sources":["../../src/junk/junkLabels.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport { renderProceduralLabelCanvas } from \"./junkLabelCanvas.js\";\nimport type { ProceduralLabelId } from \"./junkTypes.js\";\n\nconst labelCache = new Map<ProceduralLabelId, THREE.CanvasTexture>();\n\nfunction configureTex<T extends THREE.Texture>(tex: T): T {\n tex.colorSpace = THREE.SRGBColorSpace;\n tex.wrapS = THREE.RepeatWrapping;\n tex.wrapT = THREE.ClampToEdgeWrapping;\n tex.flipY = true;\n tex.anisotropy = 1;\n tex.needsUpdate = true;\n return tex;\n}\n\nexport function getProceduralLabelTexture(\n id: ProceduralLabelId,\n opts?: { cache?: boolean },\n): THREE.CanvasTexture | null {\n if (typeof document === \"undefined\")\n return null;\n const key: ProceduralLabelId = id === \"custom\" ? \"target\" : id;\n const useCache = opts?.cache !== false;\n if (useCache) {\n const hit = labelCache.get(key);\n if (hit)\n return hit;\n }\n const canvas = document.createElement(\"canvas\");\n canvas.width = 512;\n canvas.height = 256;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx)\n return null;\n renderProceduralLabelCanvas(ctx, key, canvas.width, canvas.height);\n const tex = configureTex(new THREE.CanvasTexture(canvas));\n if (useCache)\n labelCache.set(key, tex);\n return tex;\n}\n\nexport function loadCustomLabelTexture(url: string): Promise<{ texture: THREE.Texture; dispose: () => void }> {\n return new Promise((resolve, reject) => {\n if (!url || typeof url !== \"string\") {\n reject(new Error(\"Invalid custom label URL.\"));\n return;\n }\n new THREE.TextureLoader().load(\n url,\n (tex) => {\n configureTex(tex);\n resolve({ texture: tex, dispose: () => tex.dispose() });\n },\n undefined,\n () => reject(new Error(\"Failed to decode custom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ShardSpec } from "./junkTypes.js";
|
|
3
|
-
import type { BallisticHitEvent } from "./junkTypes.js";
|
|
1
|
+
import * as THREE from "three";
|
|
4
2
|
import { type ResolvedCanLod } from "./junkGeometry.js";
|
|
3
|
+
import type { BallisticHitEvent, CanLodMode, JunkKind, ProceduralLabelId, ShardSpec } from "./junkTypes.js";
|
|
5
4
|
export declare const SHARD_COLLIDER_INSET = 0.65;
|
|
6
5
|
export declare function getTargetDensity(kind: JunkKind): number;
|
|
7
6
|
export interface SpawnedShardState {
|
|
@@ -33,7 +32,7 @@ export interface DestructibleTargetSnapshot {
|
|
|
33
32
|
linearVelocity: [number, number, number];
|
|
34
33
|
}
|
|
35
34
|
/**
|
|
36
|
-
* Computes target-mesh local-space position & Euler XYZ rotation for a
|
|
35
|
+
* Computes target-mesh local-space position & Euler XYZ rotation for a `<Decal>`.
|
|
37
36
|
*/
|
|
38
37
|
export declare function computeLocalDecalTransform(mesh: THREE.Mesh, worldPoint: [number, number, number], worldNormal: [number, number, number]): {
|
|
39
38
|
position: [number, number, number];
|