@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,347 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { edgeKey, edgeLength, edgeWeight, mirrorTriangles, shortestEdgePath, snapToVertex } from "./surfaceGeodesic.js";
|
|
2
|
+
import { CHOP_ROLES, buildSurfaceTopology, floodFillByCrease, floodTriangles, getIslandTopology } from "./surfaceTopology.js";
|
|
3
|
+
import { refineMeshAlongLoop } from "./surfaceLoopRefine.js";
|
|
4
|
+
import { buildSelectionOverlayGeometry, createFleet12GonWheelGroup, findMirrorIslandId, peelIslandSelection, remapIslandIds } from "./surfacePeel.js";
|
|
5
5
|
// src/importer/surfaceCutter.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return
|
|
14
|
-
n / 3,
|
|
15
|
-
r / 3,
|
|
16
|
-
i / 3
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
function S(e, t, n, r, i, a, o, s) {
|
|
20
|
-
y.set(t, n, r);
|
|
21
|
-
let c = -1, l = s;
|
|
22
|
-
for (let t = 0; t < e.triangleCount; t++) {
|
|
23
|
-
let n = t * 3;
|
|
24
|
-
if (i * e.normals[n] + a * e.normals[n + 1] + o * e.normals[n + 2] < .5) continue;
|
|
25
|
-
let r = e.corners[n] * 3, s = e.corners[n + 1] * 3, u = e.corners[n + 2] * 3;
|
|
26
|
-
v.a.set(e.points[r], e.points[r + 1], e.points[r + 2]), v.b.set(e.points[s], e.points[s + 1], e.points[s + 2]), v.c.set(e.points[u], e.points[u + 1], e.points[u + 2]);
|
|
27
|
-
let d = v.closestPointToPoint(y, b).distanceTo(y);
|
|
28
|
-
d <= l && (l = d, c = t);
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
t: c,
|
|
32
|
-
d: l
|
|
33
|
-
};
|
|
6
|
+
function meanSelectionX(topo, tris) {
|
|
7
|
+
let sumX = 0, totalArea = 0;
|
|
8
|
+
for (const tri of tris) {
|
|
9
|
+
const area = topo.areas[tri];
|
|
10
|
+
for (let k = 0; k < 3; k++) sumX += topo.points[topo.corners[tri * 3 + k] * 3] * area / 3;
|
|
11
|
+
totalArea += area;
|
|
12
|
+
}
|
|
13
|
+
return totalArea > 0 ? sumX / totalArea : 0;
|
|
34
14
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
r || (r = /* @__PURE__ */ new Set(), s.set(t, r)), r.add(n);
|
|
40
|
-
};
|
|
41
|
-
if (n) {
|
|
42
|
-
let t = .035;
|
|
43
|
-
for (let [n, s] of e) {
|
|
44
|
-
let e = o.get(n);
|
|
45
|
-
if (!e || s.length === 0) continue;
|
|
46
|
-
let l = d(e), u = s.filter((e) => Math.abs(x(l, e)[0]) > r);
|
|
47
|
-
if (u.length === 0) continue;
|
|
48
|
-
let p = e.min[0] < -.08 && e.max[0] > .08 ? f(l, u, t) : [];
|
|
49
|
-
for (let e of p) c(n, e);
|
|
50
|
-
if (p.length < u.length) {
|
|
51
|
-
let e = i.filter((e) => !a?.has(e.id));
|
|
52
|
-
for (let r of u) {
|
|
53
|
-
let [i, a, o] = x(l, r), s = -i, u = -l.normals[r * 3], f = l.normals[r * 3 + 1], p = l.normals[r * 3 + 2], m = -1, h = -1, g = t;
|
|
54
|
-
for (let i of e) {
|
|
55
|
-
if (s < i.min[0] - t || s > i.max[0] + t || a < i.min[1] - t || a > i.max[1] + t || o < i.min[2] - t || o > i.max[2] + t) continue;
|
|
56
|
-
let e = S(d(i), s, a, o, u, f, p, g);
|
|
57
|
-
e.t >= 0 && e.d <= g && (i.id !== n || e.t !== r) && (g = e.d, m = i.id, h = e.t);
|
|
58
|
-
}
|
|
59
|
-
m >= 0 && h >= 0 && c(m, h);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
let l = [];
|
|
65
|
-
for (let t of [.../* @__PURE__ */ new Set([...e.keys(), ...s.keys()])].sort((e, t) => e - t)) {
|
|
66
|
-
let n = [...new Set(e.get(t) ?? [])].sort((e, t) => e - t), r = [...s.get(t) ?? []].filter((e) => !n.includes(e)).sort((e, t) => e - t);
|
|
67
|
-
(n.length > 0 || r.length > 0) && l.push({
|
|
68
|
-
islandId: t,
|
|
69
|
-
triangles: n,
|
|
70
|
-
mirrored: r
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
let u = l.find((e) => e.islandId === t) ?? l[0];
|
|
15
|
+
function finalizeSelection(island, tris, mirrorX) {
|
|
16
|
+
const topo = getIslandTopology(island);
|
|
17
|
+
const uniqueSorted = [...new Set(tris)].sort((a, b) => a - b);
|
|
18
|
+
const mirrored = mirrorX && Math.abs(meanSelectionX(topo, uniqueSorted)) > .08 ? mirrorTriangles(topo, uniqueSorted) : [];
|
|
74
19
|
return {
|
|
75
|
-
islandId:
|
|
76
|
-
triangles:
|
|
77
|
-
mirrored
|
|
78
|
-
entries: l
|
|
20
|
+
islandId: island.id,
|
|
21
|
+
triangles: uniqueSorted,
|
|
22
|
+
mirrored
|
|
79
23
|
};
|
|
80
24
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
for (
|
|
86
|
-
|
|
25
|
+
function selectFacesByClick(island, faceIndex, mode, opts) {
|
|
26
|
+
const topo = getIslandTopology(island);
|
|
27
|
+
const patch = mode === "crease" ? floodFillByCrease(topo, faceIndex, opts.creaseDeg) : [faceIndex];
|
|
28
|
+
const next = opts.current?.islandId === island.id ? new Set(opts.current.triangles) : /* @__PURE__ */ new Set();
|
|
29
|
+
for (const tri of patch) if (opts.remove) next.delete(tri);
|
|
30
|
+
else next.add(tri);
|
|
31
|
+
return finalizeSelection(island, [...next], opts.mirrorX);
|
|
87
32
|
}
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
33
|
+
function previewLoopPolyline(island, dots) {
|
|
34
|
+
if (dots.length < 2) return dots.map((p) => [
|
|
35
|
+
p[0],
|
|
36
|
+
p[1],
|
|
37
|
+
p[2]
|
|
93
38
|
]);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
39
|
+
const topo = getIslandTopology(island);
|
|
40
|
+
const verts = dots.map((pt) => snapToVertex(topo, pt));
|
|
41
|
+
const poly = [];
|
|
42
|
+
const segCount = dots.length >= 3 ? verts.length : verts.length - 1;
|
|
43
|
+
for (let i = 0; i < segCount; i++) {
|
|
44
|
+
const path = shortestEdgePath(topo, verts[i], verts[(i + 1) % verts.length]) ?? [verts[i], verts[(i + 1) % verts.length]];
|
|
45
|
+
const stop = i === segCount - 1 && dots.length < 3 ? void 0 : -1;
|
|
46
|
+
for (const vid of path.slice(0, stop)) poly.push([
|
|
47
|
+
topo.points[vid * 3],
|
|
48
|
+
topo.points[vid * 3 + 1],
|
|
49
|
+
topo.points[vid * 3 + 2]
|
|
101
50
|
]);
|
|
102
51
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
function E(e, t, n) {
|
|
106
|
-
if (t.length < 3) throw Error("Place at least 3 seam dots around the panel first.");
|
|
107
|
-
let r = d(e), i = t.map((e) => h(r, e));
|
|
108
|
-
if (new Set(i).size !== i.length) throw Error("Two dots snapped to the same vertex — spread dots apart or enable Split Coarse Edges.");
|
|
109
|
-
let a = [], l = /* @__PURE__ */ new Set();
|
|
110
|
-
for (let e = 0; e < i.length; e++) {
|
|
111
|
-
let t = m(r, i[e], i[(e + 1) % i.length], l, n.exact ? s : c);
|
|
112
|
-
if (!t) throw Error(`No mesh edge path connects dot ${e + 1} to dot ${(e + 1) % i.length + 1}.`);
|
|
113
|
-
for (let e of t.slice(0, -1)) a.push(e), l.add(e);
|
|
114
|
-
}
|
|
115
|
-
let f = /* @__PURE__ */ new Set();
|
|
116
|
-
for (let e = 0; e < a.length; e++) f.add(o(a[e], a[(e + 1) % a.length]));
|
|
117
|
-
let p = [...f].map((e) => r.edgeTriangles.get(e) ?? []).find((e) => e.length === 2);
|
|
118
|
-
if (!p) throw Error("Loop runs only along open mesh border — nothing enclosed to peel.");
|
|
119
|
-
let g = u(r, p[0], (e) => !f.has(e));
|
|
120
|
-
if (new Set(g).has(p[1])) throw Error("Loop didn't enclose an isolated patch — add another dot along the shutline.");
|
|
121
|
-
let _ = u(r, p[1], (e) => !f.has(e)), v = (e) => e.reduce((e, t) => e + r.areas[t], 0), y = v(g) <= v(_) ? g : _;
|
|
122
|
-
return C(/* @__PURE__ */ new Map([[e.id, y]]), e.id, n.mirrorX, n.allIslands?.length ? n.allIslands : [e], n.excludeMirrorIds);
|
|
123
|
-
}
|
|
124
|
-
function D(e, t, n = .28) {
|
|
125
|
-
let r = e.index ? e.toNonIndexed() : e.clone(), a = Object.keys(r.attributes), s = a.map((e) => r.getAttribute(e).itemSize), c = a.slice(0, a.indexOf("position")).reduce((e, t, n) => e + s[n], 0), l = r.getAttribute("position").count, u = (e) => {
|
|
126
|
-
let t = [];
|
|
127
|
-
return a.forEach((n, i) => {
|
|
128
|
-
let a = r.getAttribute(n);
|
|
129
|
-
for (let n = 0; n < s[i]; n++) t.push(a.getComponent(e, n));
|
|
130
|
-
}), t;
|
|
131
|
-
}, d = [];
|
|
132
|
-
for (let e = 0; e * 3 + 2 < l; e++) d.push([
|
|
133
|
-
u(e * 3),
|
|
134
|
-
u(e * 3 + 1),
|
|
135
|
-
u(e * 3 + 2)
|
|
136
|
-
]);
|
|
137
|
-
let f = d.length, p = (e) => new _.Vector3(e[c], e[c + 1], e[c + 2]), m = (e, t, n) => e.map((e, r) => e + (t[r] - e) * n), h = i(r);
|
|
138
|
-
for (let e = 0; e < t.length; e++) {
|
|
139
|
-
let r = new _.Vector3(...t[e]), i = new _.Vector3(...t[(e + 1) % t.length]), a = i.clone().sub(r), s = a.length();
|
|
140
|
-
if (s < 1e-7) continue;
|
|
141
|
-
a.divideScalar(s);
|
|
142
|
-
let c = r.clone().add(i).multiplyScalar(.5), l = new _.Vector3(), u = new _.Vector3();
|
|
143
|
-
for (let e = 0; e < h.triangleCount; e++) {
|
|
144
|
-
u.set(0, 0, 0);
|
|
145
|
-
for (let t = 0; t < 3; t++) u.add(new _.Vector3().fromArray(h.points, h.corners[e * 3 + t] * 3));
|
|
146
|
-
u.multiplyScalar(1 / 3).distanceTo(c) <= Math.max(s, .25) && l.addScaledVector(new _.Vector3().fromArray(h.normals, e * 3), h.areas[e]);
|
|
147
|
-
}
|
|
148
|
-
let f = l.lengthSq() > 0 ? l.normalize() : new _.Vector3(0, 1, 0), v = new _.Vector3().crossVectors(a, f);
|
|
149
|
-
if (v.lengthSq() < 1e-12) continue;
|
|
150
|
-
v.normalize();
|
|
151
|
-
let y = (e) => v.dot(e) - v.dot(r), b = 1e-6, x = /* @__PURE__ */ new Map(), S = (e) => {
|
|
152
|
-
let t = p(e), n = g(t.x, t.y, t.z), r = x.get(n);
|
|
153
|
-
return r === void 0 && (r = x.size, x.set(n, r)), r;
|
|
154
|
-
}, C = d.map((e) => {
|
|
155
|
-
let t = e.map((e) => y(p(e))), n = t.filter((e) => e > b).length, r = t.filter((e) => e < -1e-6).length;
|
|
156
|
-
if (n === 0 || r === 0) return null;
|
|
157
|
-
let i = n === 1 ? t.findIndex((e) => e > b) : t.findIndex((e) => e < -1e-6), [a, s, c] = [
|
|
158
|
-
0,
|
|
159
|
-
1,
|
|
160
|
-
2
|
|
161
|
-
].map((t) => e[(i + t) % 3]), [l, u, d] = [
|
|
162
|
-
0,
|
|
163
|
-
1,
|
|
164
|
-
2
|
|
165
|
-
].map((e) => t[(i + e) % 3]), f = Math.abs(u) <= b ? null : m(a, s, l / (l - u)), h = Math.abs(d) <= b ? null : m(a, c, l / (l - d));
|
|
166
|
-
return {
|
|
167
|
-
c0: a,
|
|
168
|
-
c1: s,
|
|
169
|
-
c2: c,
|
|
170
|
-
p01: f,
|
|
171
|
-
p02: h,
|
|
172
|
-
k01: f ? o(S(a), S(s)) : -1,
|
|
173
|
-
k02: h ? o(S(a), S(c)) : -1,
|
|
174
|
-
chord: [f ?? s, h ?? c]
|
|
175
|
-
};
|
|
176
|
-
}), w = /* @__PURE__ */ new Set();
|
|
177
|
-
for (let e of C) {
|
|
178
|
-
if (!e) continue;
|
|
179
|
-
let t = Infinity, i = -Infinity, o = Infinity;
|
|
180
|
-
for (let n of e.chord) {
|
|
181
|
-
let e = p(n).sub(r), s = e.dot(a);
|
|
182
|
-
t = Math.min(t, s), i = Math.max(i, s), o = Math.min(o, Math.abs(e.dot(f)));
|
|
183
|
-
}
|
|
184
|
-
i >= -1e-6 && t <= s + b && o <= n && (e.p01 && w.add(e.k01), e.p02 && w.add(e.k02));
|
|
185
|
-
}
|
|
186
|
-
let T = [];
|
|
187
|
-
d.forEach((e, t) => {
|
|
188
|
-
let n = C[t], r = n?.p01 && w.has(n.k01) ? n.p01 : null, i = n?.p02 && w.has(n.k02) ? n.p02 : null;
|
|
189
|
-
if (!n || !r && !i) {
|
|
190
|
-
T.push(e);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
let { c0: a, c1: o, c2: s } = n;
|
|
194
|
-
r && i ? T.push([
|
|
195
|
-
a,
|
|
196
|
-
r,
|
|
197
|
-
i
|
|
198
|
-
], [
|
|
199
|
-
r,
|
|
200
|
-
o,
|
|
201
|
-
s
|
|
202
|
-
], [
|
|
203
|
-
r,
|
|
204
|
-
s,
|
|
205
|
-
i
|
|
206
|
-
]) : r ? T.push([
|
|
207
|
-
a,
|
|
208
|
-
r,
|
|
209
|
-
s
|
|
210
|
-
], [
|
|
211
|
-
r,
|
|
212
|
-
o,
|
|
213
|
-
s
|
|
214
|
-
]) : T.push([
|
|
215
|
-
a,
|
|
216
|
-
o,
|
|
217
|
-
i
|
|
218
|
-
], [
|
|
219
|
-
i,
|
|
220
|
-
o,
|
|
221
|
-
s
|
|
222
|
-
]);
|
|
223
|
-
}), d = T;
|
|
224
|
-
}
|
|
225
|
-
let v = new _.BufferGeometry(), y = 0;
|
|
226
|
-
return a.forEach((e, t) => {
|
|
227
|
-
let n = s[t], i = new Float32Array(d.length * 3 * n);
|
|
228
|
-
d.forEach((e, t) => {
|
|
229
|
-
for (let r = 0; r < 3; r++) for (let a = 0; a < n; a++) i[(t * 3 + r) * n + a] = e[r][y + a];
|
|
230
|
-
}), v.setAttribute(e, new _.BufferAttribute(i, n, r.getAttribute(e).normalized)), y += n;
|
|
231
|
-
}), v.getAttribute("normal") || v.computeVertexNormals(), v.computeBoundingBox(), v.computeBoundingSphere(), {
|
|
232
|
-
geometry: v,
|
|
233
|
-
added: d.length - f
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function O(e) {
|
|
237
|
-
if (e.length === 0) return new _.BufferGeometry();
|
|
238
|
-
if (e.length === 1) return e[0];
|
|
239
|
-
let t = Object.keys(e[0].attributes).filter((t) => e.every((e) => !!e.getAttribute(t))), n = e.reduce((e, t) => e + (t.getAttribute("position")?.count ?? 0), 0), r = new _.BufferGeometry();
|
|
240
|
-
for (let i of t) {
|
|
241
|
-
let t = e[0].getAttribute(i).itemSize, a = new Float32Array(n * t), o = 0;
|
|
242
|
-
for (let n of e) {
|
|
243
|
-
let e = n.getAttribute(i);
|
|
244
|
-
for (let n = 0; n < e.count; n++) for (let r = 0; r < t; r++) a[(o + n) * t + r] = e.getComponent(n, r);
|
|
245
|
-
o += e.count;
|
|
246
|
-
}
|
|
247
|
-
r.setAttribute(i, new _.BufferAttribute(a, t));
|
|
248
|
-
}
|
|
249
|
-
for (let t of e) t.dispose();
|
|
250
|
-
return r.getAttribute("normal") || r.computeVertexNormals(), r.computeBoundingBox(), r.computeBoundingSphere(), r;
|
|
52
|
+
if (dots.length >= 3 && poly.length > 0) poly.push([...poly[0]]);
|
|
53
|
+
return poly;
|
|
251
54
|
}
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
for (let t of e.mirrored) r.add(n.triangleIndices[t]);
|
|
267
|
-
e.triangles.length > 0 && f(u, n.material, t(n.geometry, e.triangles)), e.mirrored.length > 0 && f(d, n.material, t(n.geometry, e.mirrored));
|
|
268
|
-
}
|
|
269
|
-
let m = [], h = (e, t) => {
|
|
270
|
-
let n = 0;
|
|
271
|
-
for (let [r, i] of e) {
|
|
272
|
-
let e = new _.Mesh(O(i), r);
|
|
273
|
-
e.name = n === 0 ? t : `${t}_${n}`, c.add(e), m.push(e), n++;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
h(u, r), h(d, `${r}_mirror`);
|
|
277
|
-
let g = /* @__PURE__ */ new Map();
|
|
278
|
-
for (let [e, n] of l) {
|
|
279
|
-
let r = e.geometry, i = r.getAttribute("position"), a = r.getIndex(), o = i ? Math.floor((a ? a.count : i.count) / 3) : 0;
|
|
280
|
-
g.set(e, r);
|
|
281
|
-
let s = [];
|
|
282
|
-
for (let e = 0; e < o; e++) n.has(e) || s.push(e);
|
|
283
|
-
e.geometry = s.length > 0 ? t(r, s) : new _.BufferGeometry();
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
286
|
-
mintedMeshes: m,
|
|
287
|
-
undo: () => {
|
|
288
|
-
for (let [e, t] of g) e.geometry.dispose(), e.geometry = t;
|
|
289
|
-
for (let e of m) e.removeFromParent(), e.geometry.dispose();
|
|
55
|
+
function selectFacesByLoop(island, dots, opts) {
|
|
56
|
+
if (dots.length < 3) throw new Error("Place at least 3 seam dots around the panel first.");
|
|
57
|
+
const topo = getIslandTopology(island);
|
|
58
|
+
const verts = dots.map((pt) => snapToVertex(topo, pt));
|
|
59
|
+
if (new Set(verts).size !== verts.length) throw new Error("Two dots snapped to the same vertex — spread dots apart or enable Split Coarse Edges.");
|
|
60
|
+
const loopVerts = [];
|
|
61
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
62
|
+
const weightFn = opts.exact ? edgeLength : edgeWeight;
|
|
63
|
+
for (let i = 0; i < verts.length; i++) {
|
|
64
|
+
const path = shortestEdgePath(topo, verts[i], verts[(i + 1) % verts.length], blocked, weightFn);
|
|
65
|
+
if (!path) throw new Error(`No mesh edge path connects dot ${i + 1} to dot ${(i + 1) % verts.length + 1}.`);
|
|
66
|
+
for (const vid of path.slice(0, -1)) {
|
|
67
|
+
loopVerts.push(vid);
|
|
68
|
+
blocked.add(vid);
|
|
290
69
|
}
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
function A(e, t, n) {
|
|
294
|
-
return k([e], t, n);
|
|
295
|
-
}
|
|
296
|
-
function j(e, t) {
|
|
297
|
-
let n = (e) => `${e.mesh.uuid}|${e.triangleIndices.length}|${e.center.map((e) => e.toFixed(4)).join(",")}`, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
|
|
298
|
-
for (let e of t) {
|
|
299
|
-
let t = n(e), i = r.get(t);
|
|
300
|
-
i ? i.push(e.id) : r.set(t, [e.id]);
|
|
301
|
-
}
|
|
302
|
-
for (let t of e) {
|
|
303
|
-
let e = r.get(n(t))?.shift() ?? null;
|
|
304
|
-
e !== null && i.add(e), a.set(t.id, e);
|
|
305
|
-
}
|
|
306
|
-
for (let n of e) {
|
|
307
|
-
if (a.get(n.id) !== null) continue;
|
|
308
|
-
let e = null, r = .03;
|
|
309
|
-
for (let a of t) {
|
|
310
|
-
if (i.has(a.id) || a.mesh.uuid !== n.mesh.uuid) continue;
|
|
311
|
-
let t = Math.hypot(a.center[0] - n.center[0], a.center[1] - n.center[1], a.center[2] - n.center[2]) + Math.hypot(a.size[0] - n.size[0], a.size[1] - n.size[1], a.size[2] - n.size[2]);
|
|
312
|
-
t <= r && (r = t, e = a.id);
|
|
313
|
-
}
|
|
314
|
-
e !== null && (i.add(e), a.set(n.id, e));
|
|
315
|
-
}
|
|
316
|
-
return a;
|
|
317
|
-
}
|
|
318
|
-
function M(e, t, n) {
|
|
319
|
-
let r = e.find((e) => e.id === t);
|
|
320
|
-
if (!r || Math.abs(r.center[0]) <= .08) return null;
|
|
321
|
-
let i = Math.max(...r.size, .15), a = null, o = .55;
|
|
322
|
-
for (let s of e) {
|
|
323
|
-
if (s.id === t || n?.has(s.id)) continue;
|
|
324
|
-
let e = Math.hypot(s.center[0] + r.center[0], s.center[1] - r.center[1], s.center[2] - r.center[2]) / i, c = (Math.abs(s.size[0] - r.size[0]) + Math.abs(s.size[1] - r.size[1]) + Math.abs(s.size[2] - r.size[2])) / (r.size[0] + r.size[1] + r.size[2] + 1e-5);
|
|
325
|
-
e + c < o && (o = e + c, a = s.id);
|
|
326
|
-
}
|
|
327
|
-
return a;
|
|
328
|
-
}
|
|
329
|
-
function N(e, n, r = .004) {
|
|
330
|
-
let i = t(e, n), a = i.getAttribute("position"), o = i.getAttribute("normal");
|
|
331
|
-
if (a && o) {
|
|
332
|
-
for (let e = 0; e < a.count; e++) a.setXYZ(e, a.getX(e) + o.getX(e) * r, a.getY(e) + o.getY(e) * r, a.getZ(e) + o.getZ(e) * r);
|
|
333
|
-
a.needsUpdate = !0;
|
|
334
|
-
}
|
|
335
|
-
return i;
|
|
336
|
-
}
|
|
337
|
-
function P(e, t, n, r = .0045) {
|
|
338
|
-
let i = p(t);
|
|
339
|
-
if (i.length === 0) return null;
|
|
340
|
-
let a = new Map(e.map((e) => [e.id, e])), o = [];
|
|
341
|
-
for (let e of i) {
|
|
342
|
-
let t = e[n], i = a.get(e.islandId);
|
|
343
|
-
i && t.length > 0 && o.push(N(i.geometry, t, r));
|
|
344
70
|
}
|
|
345
|
-
|
|
71
|
+
const seamEdges = /* @__PURE__ */ new Set();
|
|
72
|
+
for (let i = 0; i < loopVerts.length; i++) seamEdges.add(edgeKey(loopVerts[i], loopVerts[(i + 1) % loopVerts.length]));
|
|
73
|
+
const interiorPair = [...seamEdges].map((ek) => topo.edgeTriangles.get(ek) ?? []).find((tris) => tris.length === 2);
|
|
74
|
+
if (!interiorPair) throw new Error("Loop runs only along open mesh border — nothing enclosed to peel.");
|
|
75
|
+
const sideA = floodTriangles(topo, interiorPair[0], (edge) => !seamEdges.has(edge));
|
|
76
|
+
if (new Set(sideA).has(interiorPair[1])) throw new Error("Loop didn't enclose an isolated patch — add another dot along the shutline.");
|
|
77
|
+
const sideB = floodTriangles(topo, interiorPair[1], (edge) => !seamEdges.has(edge));
|
|
78
|
+
const areaOf = (list) => list.reduce((acc, tri) => acc + topo.areas[tri], 0);
|
|
79
|
+
return finalizeSelection(island, areaOf(sideA) <= areaOf(sideB) ? sideA : sideB, opts.mirrorX);
|
|
346
80
|
}
|
|
347
|
-
export {
|
|
81
|
+
export { CHOP_ROLES, buildSelectionOverlayGeometry, buildSurfaceTopology, createFleet12GonWheelGroup, findMirrorIslandId, floodFillByCrease, getIslandTopology, mirrorTriangles, peelIslandSelection, previewLoopPolyline, refineMeshAlongLoop, remapIslandIds, selectFacesByClick, selectFacesByLoop };
|
|
82
|
+
|
|
83
|
+
//# sourceMappingURL=surfaceCutter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surfaceCutter.js","names":[],"sources":["../../src/importer/surfaceCutter.ts"],"sourcesContent":["import type { MeshIsland } from \"./meshIslands.js\";\nimport { refineMeshAlongLoop } from \"./surfaceLoopRefine.js\";\nimport {\n buildSelectionOverlayGeometry,\n createFleet12GonWheelGroup,\n findMirrorIslandId,\n peelIslandSelection,\n remapIslandIds,\n} from \"./surfacePeel.js\";\nimport {\n CHOP_ROLES,\n MIRROR_OFF_CENTER_M,\n buildSurfaceTopology,\n edgeKey,\n edgeLength,\n edgeWeight,\n floodFillByCrease,\n floodTriangles,\n getIslandTopology,\n mirrorTriangles,\n shortestEdgePath,\n snapToVertex,\n type ActiveChopRole,\n type ChopPartRole,\n type CutVec3,\n type FaceSelection,\n type SurfaceSelectMode,\n type SurfaceTopology,\n} from \"./surfaceTopology.js\";\n\nexport {\n CHOP_ROLES,\n buildSelectionOverlayGeometry,\n buildSurfaceTopology,\n createFleet12GonWheelGroup,\n findMirrorIslandId,\n floodFillByCrease,\n getIslandTopology,\n mirrorTriangles,\n peelIslandSelection,\n refineMeshAlongLoop,\n remapIslandIds,\n type ActiveChopRole,\n type ChopPartRole,\n type CutVec3,\n type FaceSelection,\n type SurfaceSelectMode,\n type SurfaceTopology,\n};\n\nfunction meanSelectionX(topo: SurfaceTopology, tris: readonly number[]): number {\n let sumX = 0, totalArea = 0;\n for (const tri of tris) {\n const area = topo.areas[tri];\n for (let k = 0; k < 3; k++) sumX += (topo.points[topo.corners[tri * 3 + k] * 3] * area) / 3;\n totalArea += area;\n }\n return totalArea > 0 ? sumX / totalArea : 0;\n}\n\nfunction finalizeSelection(island: MeshIsland, tris: number[], mirrorX: boolean): FaceSelection {\n const topo = getIslandTopology(island);\n const uniqueSorted = [...new Set(tris)].sort((a, b) => a - b);\n const mirrored =\n mirrorX && Math.abs(meanSelectionX(topo, uniqueSorted)) > MIRROR_OFF_CENTER_M\n ? mirrorTriangles(topo, uniqueSorted)\n : [];\n return { islandId: island.id, triangles: uniqueSorted, mirrored };\n}\n\nexport function selectFacesByClick(\n island: MeshIsland,\n faceIndex: number,\n mode: Exclude<SurfaceSelectMode, \"island\" | \"loop\">,\n opts: { creaseDeg: number; mirrorX: boolean; current: FaceSelection | null; remove?: boolean },\n): FaceSelection {\n const topo = getIslandTopology(island);\n const patch = mode === \"crease\" ? floodFillByCrease(topo, faceIndex, opts.creaseDeg) : [faceIndex];\n const next = opts.current?.islandId === island.id ? new Set(opts.current.triangles) : new Set<number>();\n for (const tri of patch) {\n if (opts.remove) next.delete(tri);\n else next.add(tri);\n }\n return finalizeSelection(island, [...next], opts.mirrorX);\n}\n\nexport function previewLoopPolyline(island: MeshIsland, dots: readonly CutVec3[]): [number, number, number][] {\n if (dots.length < 2) return dots.map((p) => [p[0], p[1], p[2]]);\n const topo = getIslandTopology(island);\n const verts = dots.map((pt) => snapToVertex(topo, pt));\n const poly: [number, number, number][] = [];\n const segCount = dots.length >= 3 ? verts.length : verts.length - 1;\n\n for (let i = 0; i < segCount; i++) {\n const path = shortestEdgePath(topo, verts[i], verts[(i + 1) % verts.length]) ?? [verts[i], verts[(i + 1) % verts.length]];\n const stop = i === segCount - 1 && dots.length < 3 ? undefined : -1;\n for (const vid of path.slice(0, stop))\n poly.push([topo.points[vid * 3], topo.points[vid * 3 + 1], topo.points[vid * 3 + 2]]);\n }\n if (dots.length >= 3 && poly.length > 0) poly.push([...poly[0]]);\n return poly;\n}\n\nexport function selectFacesByLoop(\n island: MeshIsland,\n dots: readonly CutVec3[],\n opts: { mirrorX: boolean; exact?: boolean },\n): FaceSelection {\n if (dots.length < 3) throw new Error(\"Place at least 3 seam dots around the panel first.\");\n const topo = getIslandTopology(island);\n const verts = dots.map((pt) => snapToVertex(topo, pt));\n if (new Set(verts).size !== verts.length)\n throw new Error(\"Two dots snapped to the same vertex — spread dots apart or enable Split Coarse Edges.\");\n\n const loopVerts: number[] = [];\n const blocked = new Set<number>();\n const weightFn = opts.exact ? edgeLength : edgeWeight;\n\n for (let i = 0; i < verts.length; i++) {\n const path = shortestEdgePath(topo, verts[i], verts[(i + 1) % verts.length], blocked, weightFn);\n if (!path) throw new Error(`No mesh edge path connects dot ${i + 1} to dot ${((i + 1) % verts.length) + 1}.`);\n for (const vid of path.slice(0, -1)) {\n loopVerts.push(vid);\n blocked.add(vid);\n }\n }\n\n const seamEdges = new Set<number>();\n for (let i = 0; i < loopVerts.length; i++) seamEdges.add(edgeKey(loopVerts[i], loopVerts[(i + 1) % loopVerts.length]));\n\n const interiorPair = [...seamEdges].map((ek) => topo.edgeTriangles.get(ek) ?? []).find((tris) => tris.length === 2);\n if (!interiorPair) throw new Error(\"Loop runs only along open mesh border — nothing enclosed to peel.\");\n\n const sideA = floodTriangles(topo, interiorPair[0], (edge) => !seamEdges.has(edge));\n if (new Set(sideA).has(interiorPair[1]))\n throw new Error(\"Loop didn't enclose an isolated patch — add another dot along the shutline.\");\n\n const sideB = floodTriangles(topo, interiorPair[1], (edge) => !seamEdges.has(edge));\n const areaOf = (list: number[]): number => list.reduce((acc, tri) => acc + topo.areas[tri], 0);\n return finalizeSelection(island, areaOf(sideA) <= areaOf(sideB) ? sideA : sideB, opts.mirrorX);\n}\n"],"mappings":";;;;;AAkDA,SAAS,eAAe,MAAuB,MAAiC;CAC5E,IAAI,OAAO,GAAG,YAAY;CAC1B,KAAK,MAAM,OAAO,MAAM;EACpB,MAAM,OAAO,KAAK,MAAM;EACxB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,QAAS,KAAK,OAAO,KAAK,QAAQ,MAAM,IAAI,KAAK,KAAK,OAAQ;EAC1F,aAAa;CACjB;CACA,OAAO,YAAY,IAAI,OAAO,YAAY;AAC9C;AAEA,SAAS,kBAAkB,QAAoB,MAAgB,SAAiC;CAC5F,MAAM,OAAO,kBAAkB,MAAM;CACrC,MAAM,eAAe,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC;CAC5D,MAAM,WACF,WAAW,KAAK,IAAI,eAAe,MAAM,YAAY,CAAC,IAAA,MAChD,gBAAgB,MAAM,YAAY,IAClC,CAAC;CACX,OAAO;EAAE,UAAU,OAAO;EAAI,WAAW;EAAc;CAAS;AACpE;AAEA,SAAgB,mBACZ,QACA,WACA,MACA,MACa;CACb,MAAM,OAAO,kBAAkB,MAAM;CACrC,MAAM,QAAQ,SAAS,WAAW,kBAAkB,MAAM,WAAW,KAAK,SAAS,IAAI,CAAC,SAAS;CACjG,MAAM,OAAO,KAAK,SAAS,aAAa,OAAO,KAAK,IAAI,IAAI,KAAK,QAAQ,SAAS,oBAAI,IAAI,IAAY;CACtG,KAAK,MAAM,OAAO,OACd,IAAI,KAAK,QAAQ,KAAK,OAAO,GAAG;MAC3B,KAAK,IAAI,GAAG;CAEr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+
import type { CutVec3, SurfaceTopology } from "./surfaceTopology.js";
|
|
2
|
+
export declare const edgeKey: (a: number, b: number) => number;
|
|
3
|
+
export declare function mirrorTriangles(topo: SurfaceTopology, triangles: Iterable<number>, tolerance?: number): number[];
|
|
4
|
+
export declare function edgeLength(topo: SurfaceTopology, a: number, b: number): number;
|
|
5
|
+
export declare function edgeWeight(topo: SurfaceTopology, a: number, b: number): number;
|
|
6
|
+
export declare function snapToVertex(topo: SurfaceTopology, pt: CutVec3): number;
|
|
7
|
+
export declare function shortestEdgePath(topo: SurfaceTopology, from: number, to: number, blocked?: ReadonlySet<number>, weight?: (tp: SurfaceTopology, a: number, b: number) => number): number[] | null;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// src/importer/surfaceGeodesic.ts
|
|
2
|
+
var EDGE_STRIDE = 2 ** 26;
|
|
3
|
+
var SEAM_BIAS = .65;
|
|
4
|
+
var edgeKey = (a, b) => a < b ? a * EDGE_STRIDE + b : b * EDGE_STRIDE + a;
|
|
5
|
+
function mirrorTriangles(topo, triangles, tolerance = .03) {
|
|
6
|
+
const cellSize = Math.max(tolerance, 1e-4);
|
|
7
|
+
const cellKey = (x, y, z) => `${Math.floor(x / cellSize)},${Math.floor(y / cellSize)},${Math.floor(z / cellSize)}`;
|
|
8
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
9
|
+
const centroids = new Float32Array(topo.triangleCount * 3);
|
|
10
|
+
for (let t = 0; t < topo.triangleCount; t++) {
|
|
11
|
+
let cx = 0, cy = 0, cz = 0;
|
|
12
|
+
for (let i = 0; i < 3; i++) {
|
|
13
|
+
const pOff = topo.corners[t * 3 + i] * 3;
|
|
14
|
+
cx += topo.points[pOff];
|
|
15
|
+
cy += topo.points[pOff + 1];
|
|
16
|
+
cz += topo.points[pOff + 2];
|
|
17
|
+
}
|
|
18
|
+
cx /= 3;
|
|
19
|
+
cy /= 3;
|
|
20
|
+
cz /= 3;
|
|
21
|
+
centroids[t * 3] = cx;
|
|
22
|
+
centroids[t * 3 + 1] = cy;
|
|
23
|
+
centroids[t * 3 + 2] = cz;
|
|
24
|
+
const key = cellKey(cx, cy, cz);
|
|
25
|
+
let list = buckets.get(key);
|
|
26
|
+
if (!list) {
|
|
27
|
+
list = [];
|
|
28
|
+
buckets.set(key, list);
|
|
29
|
+
}
|
|
30
|
+
list.push(t);
|
|
31
|
+
}
|
|
32
|
+
const srcSet = new Set(triangles);
|
|
33
|
+
const mirrored = /* @__PURE__ */ new Set();
|
|
34
|
+
for (const tri of srcSet) {
|
|
35
|
+
const mx = -centroids[tri * 3], my = centroids[tri * 3 + 1], mz = centroids[tri * 3 + 2];
|
|
36
|
+
let bestTri = -1, bestDist = tolerance;
|
|
37
|
+
for (let dx = -1; dx <= 1; dx++) for (let dy = -1; dy <= 1; dy++) for (let dz = -1; dz <= 1; dz++) for (const cand of buckets.get(cellKey(mx + dx * cellSize, my + dy * cellSize, mz + dz * cellSize)) ?? []) {
|
|
38
|
+
if (cand === tri || srcSet.has(cand)) continue;
|
|
39
|
+
const dist = Math.hypot(centroids[cand * 3] - mx, centroids[cand * 3 + 1] - my, centroids[cand * 3 + 2] - mz);
|
|
40
|
+
if (dist <= bestDist) {
|
|
41
|
+
bestDist = dist;
|
|
42
|
+
bestTri = cand;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (bestTri >= 0) mirrored.add(bestTri);
|
|
46
|
+
}
|
|
47
|
+
return [...mirrored].sort((a, b) => a - b);
|
|
48
|
+
}
|
|
49
|
+
function edgeLength(topo, a, b) {
|
|
50
|
+
const p = topo.points;
|
|
51
|
+
return Math.hypot(p[a * 3] - p[b * 3], p[a * 3 + 1] - p[b * 3 + 1], p[a * 3 + 2] - p[b * 3 + 2]);
|
|
52
|
+
}
|
|
53
|
+
function edgeWeight(topo, a, b) {
|
|
54
|
+
const tris = topo.edgeTriangles.get(edgeKey(a, b));
|
|
55
|
+
let creaseFactor = 1;
|
|
56
|
+
if (tris && tris.length === 2) {
|
|
57
|
+
const n = topo.normals, t0 = tris[0], t1 = tris[1];
|
|
58
|
+
const dot = n[t0 * 3] * n[t1 * 3] + n[t0 * 3 + 1] * n[t1 * 3 + 1] + n[t0 * 3 + 2] * n[t1 * 3 + 2];
|
|
59
|
+
creaseFactor = Math.min(1, Math.acos(Math.max(-1, Math.min(1, dot))) / (Math.PI / 2));
|
|
60
|
+
}
|
|
61
|
+
return edgeLength(topo, a, b) * (1 - SEAM_BIAS * creaseFactor);
|
|
62
|
+
}
|
|
63
|
+
function snapToVertex(topo, pt) {
|
|
64
|
+
let best = 0, bestD2 = Infinity;
|
|
65
|
+
for (let i = 0; i < topo.vertexCount; i++) {
|
|
66
|
+
const d2 = (topo.points[i * 3] - pt[0]) ** 2 + (topo.points[i * 3 + 1] - pt[1]) ** 2 + (topo.points[i * 3 + 2] - pt[2]) ** 2;
|
|
67
|
+
if (d2 < bestD2) {
|
|
68
|
+
bestD2 = d2;
|
|
69
|
+
best = i;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return best;
|
|
73
|
+
}
|
|
74
|
+
function shortestEdgePath(topo, from, to, blocked, weight = edgeWeight) {
|
|
75
|
+
if (from === to) return [from];
|
|
76
|
+
const dist = new Float64Array(topo.vertexCount).fill(Infinity);
|
|
77
|
+
const prev = new Int32Array(topo.vertexCount).fill(-1);
|
|
78
|
+
const heap = [[0, from]];
|
|
79
|
+
dist[from] = 0;
|
|
80
|
+
const push = (item) => {
|
|
81
|
+
heap.push(item);
|
|
82
|
+
for (let i = heap.length - 1; i > 0;) {
|
|
83
|
+
const p = i - 1 >> 1;
|
|
84
|
+
if (heap[p][0] <= heap[i][0]) break;
|
|
85
|
+
[heap[p], heap[i]] = [heap[i], heap[p]];
|
|
86
|
+
i = p;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const pop = () => {
|
|
90
|
+
const top = heap[0];
|
|
91
|
+
const last = heap.pop();
|
|
92
|
+
if (heap.length > 0) {
|
|
93
|
+
heap[0] = last;
|
|
94
|
+
for (let i = 0;;) {
|
|
95
|
+
const l = i * 2 + 1, r = l + 1;
|
|
96
|
+
let s = i;
|
|
97
|
+
if (l < heap.length && heap[l][0] < heap[s][0]) s = l;
|
|
98
|
+
if (r < heap.length && heap[r][0] < heap[s][0]) s = r;
|
|
99
|
+
if (s === i) break;
|
|
100
|
+
[heap[s], heap[i]] = [heap[i], heap[s]];
|
|
101
|
+
i = s;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return top;
|
|
105
|
+
};
|
|
106
|
+
while (heap.length > 0) {
|
|
107
|
+
const [d, u] = pop();
|
|
108
|
+
if (d > dist[u]) continue;
|
|
109
|
+
if (u === to) break;
|
|
110
|
+
for (const v of topo.neighbors[u]) {
|
|
111
|
+
if (v !== to && blocked?.has(v)) continue;
|
|
112
|
+
const alt = d + weight(topo, u, v);
|
|
113
|
+
if (alt < dist[v]) {
|
|
114
|
+
dist[v] = alt;
|
|
115
|
+
prev[v] = u;
|
|
116
|
+
push([alt, v]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (!Number.isFinite(dist[to])) return null;
|
|
121
|
+
const path = [to];
|
|
122
|
+
for (let v = to; v !== from;) {
|
|
123
|
+
v = prev[v];
|
|
124
|
+
path.push(v);
|
|
125
|
+
}
|
|
126
|
+
return path.reverse();
|
|
127
|
+
}
|
|
128
|
+
export { edgeKey, edgeLength, edgeWeight, mirrorTriangles, shortestEdgePath, snapToVertex };
|
|
129
|
+
|
|
130
|
+
//# sourceMappingURL=surfaceGeodesic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surfaceGeodesic.js","names":[],"sources":["../../src/importer/surfaceGeodesic.ts"],"sourcesContent":["import type { CutVec3, SurfaceTopology } from \"./surfaceTopology.js\";\n\nconst EDGE_STRIDE = 2 ** 26;\nconst SEAM_BIAS = 0.65;\n\nexport const edgeKey = (a: number, b: number): number =>\n a < b ? a * EDGE_STRIDE + b : b * EDGE_STRIDE + a;\n\nexport function mirrorTriangles(\n topo: SurfaceTopology,\n triangles: Iterable<number>,\n tolerance = 0.03,\n): number[] {\n const cellSize = Math.max(tolerance, 1e-4);\n const cellKey = (x: number, y: number, z: number): string =>\n `${Math.floor(x / cellSize)},${Math.floor(y / cellSize)},${Math.floor(z / cellSize)}`;\n const buckets = new Map<string, number[]>();\n const centroids = new Float32Array(topo.triangleCount * 3);\n\n for (let t = 0; t < topo.triangleCount; t++) {\n let cx = 0, cy = 0, cz = 0;\n for (let i = 0; i < 3; i++) {\n const pOff = topo.corners[t * 3 + i] * 3;\n cx += topo.points[pOff];\n cy += topo.points[pOff + 1];\n cz += topo.points[pOff + 2];\n }\n cx /= 3; cy /= 3; cz /= 3;\n centroids[t * 3] = cx;\n centroids[t * 3 + 1] = cy;\n centroids[t * 3 + 2] = cz;\n const key = cellKey(cx, cy, cz);\n let list = buckets.get(key);\n if (!list) { list = []; buckets.set(key, list); }\n list.push(t);\n }\n\n const srcSet = new Set(triangles);\n const mirrored = new Set<number>();\n for (const tri of srcSet) {\n const mx = -centroids[tri * 3], my = centroids[tri * 3 + 1], mz = centroids[tri * 3 + 2];\n let bestTri = -1, bestDist = tolerance;\n for (let dx = -1; dx <= 1; dx++) {\n for (let dy = -1; dy <= 1; dy++) {\n for (let dz = -1; dz <= 1; dz++) {\n for (const cand of buckets.get(cellKey(mx + dx * cellSize, my + dy * cellSize, mz + dz * cellSize)) ?? []) {\n if (cand === tri || srcSet.has(cand)) continue;\n const dist = Math.hypot(centroids[cand * 3] - mx, centroids[cand * 3 + 1] - my, centroids[cand * 3 + 2] - mz);\n if (dist <= bestDist) { bestDist = dist; bestTri = cand; }\n }\n }\n }\n }\n if (bestTri >= 0) mirrored.add(bestTri);\n }\n return [...mirrored].sort((a, b) => a - b);\n}\n\nexport function edgeLength(topo: SurfaceTopology, a: number, b: number): number {\n const p = topo.points;\n return Math.hypot(p[a * 3] - p[b * 3], p[a * 3 + 1] - p[b * 3 + 1], p[a * 3 + 2] - p[b * 3 + 2]);\n}\n\nexport function edgeWeight(topo: SurfaceTopology, a: number, b: number): number {\n const tris = topo.edgeTriangles.get(edgeKey(a, b));\n let creaseFactor = 1;\n if (tris && tris.length === 2) {\n const n = topo.normals, t0 = tris[0], t1 = tris[1];\n const dot = n[t0 * 3] * n[t1 * 3] + n[t0 * 3 + 1] * n[t1 * 3 + 1] + n[t0 * 3 + 2] * n[t1 * 3 + 2];\n creaseFactor = Math.min(1, Math.acos(Math.max(-1, Math.min(1, dot))) / (Math.PI / 2));\n }\n return edgeLength(topo, a, b) * (1 - SEAM_BIAS * creaseFactor);\n}\n\nexport function snapToVertex(topo: SurfaceTopology, pt: CutVec3): number {\n let best = 0, bestD2 = Infinity;\n for (let i = 0; i < topo.vertexCount; i++) {\n const d2 = (topo.points[i * 3] - pt[0]) ** 2 + (topo.points[i * 3 + 1] - pt[1]) ** 2 + (topo.points[i * 3 + 2] - pt[2]) ** 2;\n if (d2 < bestD2) { bestD2 = d2; best = i; }\n }\n return best;\n}\n\nexport function shortestEdgePath(\n topo: SurfaceTopology,\n from: number,\n to: number,\n blocked?: ReadonlySet<number>,\n weight: (tp: SurfaceTopology, a: number, b: number) => number = edgeWeight,\n): number[] | null {\n if (from === to) return [from];\n const dist = new Float64Array(topo.vertexCount).fill(Infinity);\n const prev = new Int32Array(topo.vertexCount).fill(-1);\n const heap: [number, number][] = [[0, from]];\n dist[from] = 0;\n\n const push = (item: [number, number]): void => {\n heap.push(item);\n for (let i = heap.length - 1; i > 0; ) {\n const p = (i - 1) >> 1;\n if (heap[p][0] <= heap[i][0]) break;\n [heap[p], heap[i]] = [heap[i], heap[p]];\n i = p;\n }\n };\n\n const pop = (): [number, number] => {\n const top = heap[0];\n const last = heap.pop()!;\n if (heap.length > 0) {\n heap[0] = last;\n for (let i = 0; ; ) {\n const l = i * 2 + 1, r = l + 1;\n let s = i;\n if (l < heap.length && heap[l][0] < heap[s][0]) s = l;\n if (r < heap.length && heap[r][0] < heap[s][0]) s = r;\n if (s === i) break;\n [heap[s], heap[i]] = [heap[i], heap[s]];\n i = s;\n }\n }\n return top;\n };\n\n while (heap.length > 0) {\n const [d, u] = pop();\n if (d > dist[u]) continue;\n if (u === to) break;\n for (const v of topo.neighbors[u]) {\n if (v !== to && blocked?.has(v)) continue;\n const alt = d + weight(topo, u, v);\n if (alt < dist[v]) { dist[v] = alt; prev[v] = u; push([alt, v]); }\n }\n }\n if (!Number.isFinite(dist[to])) return null;\n const path = [to];\n for (let v = to; v !== from; ) { v = prev[v]; path.push(v); }\n return path.reverse();\n}\n"],"mappings":";AAEA,IAAM,cAAc,KAAK;AACzB,IAAM,YAAY;AAElB,IAAa,WAAW,GAAW,MAC/B,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI,cAAc;AAEpD,SAAgB,gBACZ,MACA,WACA,YAAY,KACJ;CACR,MAAM,WAAW,KAAK,IAAI,WAAW,IAAI;CACzC,MAAM,WAAW,GAAW,GAAW,MACnC,GAAG,KAAK,MAAM,IAAI,QAAQ,EAAE,GAAG,KAAK,MAAM,IAAI,QAAQ,EAAE,GAAG,KAAK,MAAM,IAAI,QAAQ;CACtF,MAAM,0BAAU,IAAI,IAAsB;CAC1C,MAAM,YAAY,IAAI,aAAa,KAAK,gBAAgB,CAAC;CAEzD,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,eAAe,KAAK;EACzC,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK;EACzB,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;GACxB,MAAM,OAAO,KAAK,QAAQ,IAAI,IAAI,KAAK;GACvC,MAAM,KAAK,OAAO;GAClB,MAAM,KAAK,OAAO,OAAO;GACzB,MAAM,KAAK,OAAO,OAAO;EAC7B;EACA,MAAM;EAAG,MAAM;EAAG,MAAM;EACxB,UAAU,IAAI,KAAK;EACnB,UAAU,IAAI,IAAI,KAAK;EACvB,UAAU,IAAI,IAAI,KAAK;EACvB,MAAM,MAAM,QAAQ,I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