mesheditor 0.0.0-stage → 1.0.2
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 +201 -0
- package/README.md +853 -2
- package/dist-lib/esm/AIAgentService.d.ts +107 -0
- package/dist-lib/esm/AIAgentService.d.ts.map +1 -0
- package/dist-lib/esm/AIAgentService.js +1471 -0
- package/dist-lib/esm/AIAgentService.js.map +1 -0
- package/dist-lib/esm/MeshEditorApp.d.ts +413 -0
- package/dist-lib/esm/MeshEditorApp.d.ts.map +1 -0
- package/dist-lib/esm/MeshEditorApp.js +9093 -0
- package/dist-lib/esm/MeshEditorApp.js.map +1 -0
- package/dist-lib/esm/MeshEditorService.d.ts +460 -0
- package/dist-lib/esm/MeshEditorService.d.ts.map +1 -0
- package/dist-lib/esm/MeshEditorService.js +7084 -0
- package/dist-lib/esm/MeshEditorService.js.map +1 -0
- package/dist-lib/esm/Neural3DGeneratorService.d.ts +89 -0
- package/dist-lib/esm/Neural3DGeneratorService.d.ts.map +1 -0
- package/dist-lib/esm/Neural3DGeneratorService.js +1398 -0
- package/dist-lib/esm/Neural3DGeneratorService.js.map +1 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts +17 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.js +26 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts +33 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.js +337 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/HostAppAdapter.d.ts +55 -0
- package/dist-lib/esm/adapters/HostAppAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/HostAppAdapter.js +76 -0
- package/dist-lib/esm/adapters/HostAppAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/PlatformAdapter.d.ts +99 -0
- package/dist-lib/esm/adapters/PlatformAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/PlatformAdapter.js +2 -0
- package/dist-lib/esm/adapters/PlatformAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/index.d.ts +14 -0
- package/dist-lib/esm/adapters/index.d.ts.map +1 -0
- package/dist-lib/esm/adapters/index.js +16 -0
- package/dist-lib/esm/adapters/index.js.map +1 -0
- package/dist-lib/esm/assets/fonts/Droid_Sans_Bold.json +1 -0
- package/dist-lib/esm/assets/fonts/Droid_Sans_Regular.json +1 -0
- package/dist-lib/esm/assets/fonts/Kenney_Future_Regular.json +1 -0
- package/dist-lib/esm/baking/TextureBaker.d.ts +85 -0
- package/dist-lib/esm/baking/TextureBaker.d.ts.map +1 -0
- package/dist-lib/esm/baking/TextureBaker.js +710 -0
- package/dist-lib/esm/baking/TextureBaker.js.map +1 -0
- package/dist-lib/esm/builtInSkills.d.ts +20 -0
- package/dist-lib/esm/builtInSkills.d.ts.map +1 -0
- package/dist-lib/esm/builtInSkills.js +187 -0
- package/dist-lib/esm/builtInSkills.js.map +1 -0
- package/dist-lib/esm/compression/ModelCompressor.d.ts +88 -0
- package/dist-lib/esm/compression/ModelCompressor.d.ts.map +1 -0
- package/dist-lib/esm/compression/ModelCompressor.js +554 -0
- package/dist-lib/esm/compression/ModelCompressor.js.map +1 -0
- package/dist-lib/esm/decals/DecalController.d.ts +148 -0
- package/dist-lib/esm/decals/DecalController.d.ts.map +1 -0
- package/dist-lib/esm/decals/DecalController.js +1032 -0
- package/dist-lib/esm/decals/DecalController.js.map +1 -0
- package/dist-lib/esm/decals/decalAssetUrls.d.ts +2 -0
- package/dist-lib/esm/decals/decalAssetUrls.d.ts.map +1 -0
- package/dist-lib/esm/decals/decalAssetUrls.js +17 -0
- package/dist-lib/esm/decals/decalAssetUrls.js.map +1 -0
- package/dist-lib/esm/geometry/architecture.d.ts +115 -0
- package/dist-lib/esm/geometry/architecture.d.ts.map +1 -0
- package/dist-lib/esm/geometry/architecture.js +832 -0
- package/dist-lib/esm/geometry/architecture.js.map +1 -0
- package/dist-lib/esm/geometry/bevelModifier.d.ts +60 -0
- package/dist-lib/esm/geometry/bevelModifier.d.ts.map +1 -0
- package/dist-lib/esm/geometry/bevelModifier.js +346 -0
- package/dist-lib/esm/geometry/bevelModifier.js.map +1 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts +128 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts.map +1 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.js +677 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.js.map +1 -0
- package/dist-lib/esm/geometry/roundedBox.d.ts +16 -0
- package/dist-lib/esm/geometry/roundedBox.d.ts.map +1 -0
- package/dist-lib/esm/geometry/roundedBox.js +134 -0
- package/dist-lib/esm/geometry/roundedBox.js.map +1 -0
- package/dist-lib/esm/index.d.ts +22 -0
- package/dist-lib/esm/index.d.ts.map +1 -0
- package/dist-lib/esm/index.js +51 -0
- package/dist-lib/esm/index.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts +60 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.js +484 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts +77 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js +1793 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.d.ts +96 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.js +628 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/index.d.ts +5 -0
- package/dist-lib/esm/pathExtrusion/index.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/index.js +5 -0
- package/dist-lib/esm/pathExtrusion/index.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/types.d.ts +51 -0
- package/dist-lib/esm/pathExtrusion/types.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/types.js +2 -0
- package/dist-lib/esm/pathExtrusion/types.js.map +1 -0
- package/dist-lib/esm/plugin.d.ts +251 -0
- package/dist-lib/esm/plugin.d.ts.map +1 -0
- package/dist-lib/esm/plugin.js +145 -0
- package/dist-lib/esm/plugin.js.map +1 -0
- package/dist-lib/esm/rigging/WeightPaintController.d.ts +163 -0
- package/dist-lib/esm/rigging/WeightPaintController.d.ts.map +1 -0
- package/dist-lib/esm/rigging/WeightPaintController.js +1422 -0
- package/dist-lib/esm/rigging/WeightPaintController.js.map +1 -0
- package/dist-lib/esm/sculpting/SculptController.d.ts +147 -0
- package/dist-lib/esm/sculpting/SculptController.d.ts.map +1 -0
- package/dist-lib/esm/sculpting/SculptController.js +2039 -0
- package/dist-lib/esm/sculpting/SculptController.js.map +1 -0
- package/dist-lib/esm/sdf/index.d.ts +3 -0
- package/dist-lib/esm/sdf/index.d.ts.map +1 -0
- package/dist-lib/esm/sdf/index.js +3 -0
- package/dist-lib/esm/sdf/index.js.map +1 -0
- package/dist-lib/esm/sdf/sdfPrimitives.d.ts +98 -0
- package/dist-lib/esm/sdf/sdfPrimitives.d.ts.map +1 -0
- package/dist-lib/esm/sdf/sdfPrimitives.js +403 -0
- package/dist-lib/esm/sdf/sdfPrimitives.js.map +1 -0
- package/dist-lib/esm/sdf/surfaceNets.d.ts +30 -0
- package/dist-lib/esm/sdf/surfaceNets.d.ts.map +1 -0
- package/dist-lib/esm/sdf/surfaceNets.js +400 -0
- package/dist-lib/esm/sdf/surfaceNets.js.map +1 -0
- package/dist-lib/esm/styles.d.ts +12 -0
- package/dist-lib/esm/styles.d.ts.map +1 -0
- package/dist-lib/esm/styles.js +33 -0
- package/dist-lib/esm/styles.js.map +1 -0
- package/dist-lib/esm/template.d.ts +13 -0
- package/dist-lib/esm/template.d.ts.map +1 -0
- package/dist-lib/esm/template.js +20 -0
- package/dist-lib/esm/template.js.map +1 -0
- package/dist-lib/esm/textMesh/TextMeshController.d.ts +62 -0
- package/dist-lib/esm/textMesh/TextMeshController.d.ts.map +1 -0
- package/dist-lib/esm/textMesh/TextMeshController.js +405 -0
- package/dist-lib/esm/textMesh/TextMeshController.js.map +1 -0
- package/dist-lib/esm/textures/AITextureGenerator.d.ts +120 -0
- package/dist-lib/esm/textures/AITextureGenerator.d.ts.map +1 -0
- package/dist-lib/esm/textures/AITextureGenerator.js +946 -0
- package/dist-lib/esm/textures/AITextureGenerator.js.map +1 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts +63 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts.map +1 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.js +880 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.js.map +1 -0
- package/dist-lib/esm/tools/AbstractTool.d.ts +69 -0
- package/dist-lib/esm/tools/AbstractTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/AbstractTool.js +129 -0
- package/dist-lib/esm/tools/AbstractTool.js.map +1 -0
- package/dist-lib/esm/tools/ToolExecutionContext.d.ts +41 -0
- package/dist-lib/esm/tools/ToolExecutionContext.d.ts.map +1 -0
- package/dist-lib/esm/tools/ToolExecutionContext.js +2 -0
- package/dist-lib/esm/tools/ToolExecutionContext.js.map +1 -0
- package/dist-lib/esm/tools/ToolInterface.d.ts +105 -0
- package/dist-lib/esm/tools/ToolInterface.d.ts.map +1 -0
- package/dist-lib/esm/tools/ToolInterface.js +2 -0
- package/dist-lib/esm/tools/ToolInterface.js.map +1 -0
- package/dist-lib/esm/tools/ToolRegistry.d.ts +44 -0
- package/dist-lib/esm/tools/ToolRegistry.d.ts.map +1 -0
- package/dist-lib/esm/tools/ToolRegistry.js +116 -0
- package/dist-lib/esm/tools/ToolRegistry.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts +35 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js +49 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts +35 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js +55 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts +43 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.js +82 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts +52 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.js +87 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts +79 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js +171 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts +76 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.js +116 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts +119 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.js +90 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts +115 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.js +106 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.js +61 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts +115 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.js +213 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts +121 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.js +96 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts +163 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js +303 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts +121 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.js +109 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts +102 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js +80 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts +225 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js +239 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts +136 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.js +120 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts +95 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js +132 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.js +60 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts +146 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.js +125 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/DecalTool.d.ts +77 -0
- package/dist-lib/esm/tools/builtin/DecalTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/DecalTool.js +144 -0
- package/dist-lib/esm/tools/builtin/DecalTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts +21 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.js +43 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts +22 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js +96 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts +115 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js +77 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts +105 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js +69 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts +37 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.js +58 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts +31 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js +50 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts +31 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js +50 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts +35 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.js +56 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts +132 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js +456 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.js +217 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts +12 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js +13 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts +29 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.js +57 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.js +156 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts +51 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js +117 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts +56 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.js +140 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts +139 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.js +256 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts +22 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.js +32 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts +31 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js +58 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts +67 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js +106 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts +24 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.js +38 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts +24 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js +40 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts +79 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.js +70 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts +49 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.js +108 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts +61 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.js +154 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/index.d.ts +45 -0
- package/dist-lib/esm/tools/builtin/index.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/index.js +45 -0
- package/dist-lib/esm/tools/builtin/index.js.map +1 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts +19 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.js +44 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts +16 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.js +29 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts +30 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.js +57 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js +30 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts +22 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.js +45 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts +21 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.js +43 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts +21 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.js +49 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js +37 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.js +37 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts +24 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.js +81 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts +19 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.js +44 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js +38 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.js +35 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts +27 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js +73 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts +28 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.js +67 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js +36 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts +29 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.js +71 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.js +31 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js +29 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts +28 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js +71 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts +27 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js +69 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts +31 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.js +229 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.js.map +1 -0
- package/dist-lib/esm/tools/editor/index.d.ts +33 -0
- package/dist-lib/esm/tools/editor/index.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/index.js +55 -0
- package/dist-lib/esm/tools/editor/index.js.map +1 -0
- package/dist-lib/esm/tools/editor/toolViews.d.ts +11 -0
- package/dist-lib/esm/tools/editor/toolViews.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/toolViews.js +54 -0
- package/dist-lib/esm/tools/editor/toolViews.js.map +1 -0
- package/dist-lib/esm/tools/editorTools.d.ts +6 -0
- package/dist-lib/esm/tools/editorTools.d.ts.map +1 -0
- package/dist-lib/esm/tools/editorTools.js +6 -0
- package/dist-lib/esm/tools/editorTools.js.map +1 -0
- package/dist-lib/esm/tools/index.d.ts +9 -0
- package/dist-lib/esm/tools/index.d.ts.map +1 -0
- package/dist-lib/esm/tools/index.js +9 -0
- package/dist-lib/esm/tools/index.js.map +1 -0
- package/dist-lib/esm/tools/textureUtils.d.ts +19 -0
- package/dist-lib/esm/tools/textureUtils.d.ts.map +1 -0
- package/dist-lib/esm/tools/textureUtils.js +289 -0
- package/dist-lib/esm/tools/textureUtils.js.map +1 -0
- package/dist-lib/esm/types.d.ts +165 -0
- package/dist-lib/esm/types.d.ts.map +1 -0
- package/dist-lib/esm/types.js +2 -0
- package/dist-lib/esm/types.js.map +1 -0
- package/dist-lib/esm/uv/UVUnwrapController.d.ts +109 -0
- package/dist-lib/esm/uv/UVUnwrapController.d.ts.map +1 -0
- package/dist-lib/esm/uv/UVUnwrapController.js +1023 -0
- package/dist-lib/esm/uv/UVUnwrapController.js.map +1 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts +16 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts.map +1 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.js +170 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.js.map +1 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.d.ts +55 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.d.ts.map +1 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.js +631 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.js.map +1 -0
- package/dist-lib/esm/voxel/VoxelPainterController.d.ts +101 -0
- package/dist-lib/esm/voxel/VoxelPainterController.d.ts.map +1 -0
- package/dist-lib/esm/voxel/VoxelPainterController.js +672 -0
- package/dist-lib/esm/voxel/VoxelPainterController.js.map +1 -0
- package/dist-lib/esm/voxel/index.d.ts +5 -0
- package/dist-lib/esm/voxel/index.d.ts.map +1 -0
- package/dist-lib/esm/voxel/index.js +5 -0
- package/dist-lib/esm/voxel/index.js.map +1 -0
- package/dist-lib/esm/voxel/types.d.ts +79 -0
- package/dist-lib/esm/voxel/types.d.ts.map +1 -0
- package/dist-lib/esm/voxel/types.js +2 -0
- package/dist-lib/esm/voxel/types.js.map +1 -0
- package/dist-lib/esm/web-component/MeshEditorElement.d.ts +104 -0
- package/dist-lib/esm/web-component/MeshEditorElement.d.ts.map +1 -0
- package/dist-lib/esm/web-component/MeshEditorElement.js +247 -0
- package/dist-lib/esm/web-component/MeshEditorElement.js.map +1 -0
- package/dist-lib/esm/web-component/index.d.ts +2 -0
- package/dist-lib/esm/web-component/index.d.ts.map +1 -0
- package/dist-lib/esm/web-component/index.js +2 -0
- package/dist-lib/esm/web-component/index.js.map +1 -0
- package/dist-lib/index.umd.js +3 -0
- package/dist-lib/mesheditor.css +2 -0
- package/dist-lib/standalone/mesheditor-element.bundle.js +3 -0
- package/package.json +113 -4
- package/skills/README.md +48 -0
- package/skills/figure-sculptor.md +297 -0
- package/skills/image-to-mesh.md +18 -0
- package/skills/mesh-updater.md +27 -0
- package/skills/neural-3d-generator.md +53 -0
- package/skills/procedural-modeler.md +267 -0
- package/skills/voxel-painter.md +21 -0
- package/src/mesheditor.css +6477 -0
|
@@ -0,0 +1,672 @@
|
|
|
1
|
+
import { Color3, Matrix, MeshBuilder, Plane, PointerEventTypes, StandardMaterial, Texture, Vector3, Vector4, } from '@babylonjs/core';
|
|
2
|
+
import { CustomVoxelMesher } from './CustomVoxelMesher';
|
|
3
|
+
export class VoxelPainterController {
|
|
4
|
+
service;
|
|
5
|
+
scene;
|
|
6
|
+
atlasManager;
|
|
7
|
+
isActive = false;
|
|
8
|
+
mode = 'paint';
|
|
9
|
+
voxelSize = 1.0;
|
|
10
|
+
paintIntervalMs = 150;
|
|
11
|
+
blocks = new Map();
|
|
12
|
+
palette = new Map();
|
|
13
|
+
currentPaletteId = 'stone';
|
|
14
|
+
currentAtlasId = null;
|
|
15
|
+
get currentAtlas() {
|
|
16
|
+
if (!this.currentAtlasId)
|
|
17
|
+
return null;
|
|
18
|
+
return this.atlasManager.getAtlas(this.currentAtlasId) || null;
|
|
19
|
+
}
|
|
20
|
+
// Live preview meshes
|
|
21
|
+
baseMeshes = new Map();
|
|
22
|
+
highlightBox = null;
|
|
23
|
+
isPointerDown = false;
|
|
24
|
+
lastPaintedKey = null;
|
|
25
|
+
lastPickInfo = null;
|
|
26
|
+
paintTimer = null;
|
|
27
|
+
renderDirty = false;
|
|
28
|
+
// Listeners
|
|
29
|
+
onPaletteChanged;
|
|
30
|
+
onBlocksChanged;
|
|
31
|
+
onModeChanged;
|
|
32
|
+
onAtlasChanged;
|
|
33
|
+
constructor(service, atlasManager) {
|
|
34
|
+
this.service = service;
|
|
35
|
+
this.scene = service.scene;
|
|
36
|
+
this.atlasManager = atlasManager;
|
|
37
|
+
this.initDefaultPalette();
|
|
38
|
+
this.initHighlightBox();
|
|
39
|
+
this.initPointerHandling();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Initializes default voxel palette with standard terrain/block textures.
|
|
43
|
+
*/
|
|
44
|
+
initDefaultPalette() {
|
|
45
|
+
const defaults = [
|
|
46
|
+
{ id: 'stone', name: 'Stone', color: '#888c94' },
|
|
47
|
+
{ id: 'dirt', name: 'Dirt', color: '#865439' },
|
|
48
|
+
{ id: 'grass', name: 'Grass', color: '#4f8a10' },
|
|
49
|
+
{ id: 'sand', name: 'Sand', color: '#d9c077' },
|
|
50
|
+
{ id: 'wood', name: 'Wood Planks', color: '#966236' },
|
|
51
|
+
{ id: 'brick', name: 'Red Bricks', color: '#a64232' },
|
|
52
|
+
{ id: 'water', name: 'Water', color: '#2980b9', isLiquid: true },
|
|
53
|
+
{ id: 'glass', name: 'Glass', color: '#aed6f1' },
|
|
54
|
+
{ id: 'gold', name: 'Gold Block', color: '#f1c40f' },
|
|
55
|
+
{ id: 'obsidian', name: 'Obsidian', color: '#201b2d' },
|
|
56
|
+
];
|
|
57
|
+
for (const item of defaults) {
|
|
58
|
+
this.palette.set(item.id, item);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates cursor highlight wireframe box showing active placement target.
|
|
63
|
+
*/
|
|
64
|
+
initHighlightBox() {
|
|
65
|
+
if (this.highlightBox)
|
|
66
|
+
return;
|
|
67
|
+
this.highlightBox = MeshBuilder.CreateBox('editor_voxel_highlight', { size: 1.0 }, this.scene);
|
|
68
|
+
const mat = new StandardMaterial('editor_mat_voxel_highlight', this.scene);
|
|
69
|
+
mat.wireframe = true;
|
|
70
|
+
mat.emissiveColor = new Color3(1, 0.85, 0.1);
|
|
71
|
+
mat.disableLighting = true;
|
|
72
|
+
this.highlightBox.material = mat;
|
|
73
|
+
this.highlightBox.isPickable = false;
|
|
74
|
+
this.highlightBox.isVisible = false;
|
|
75
|
+
this.highlightBox.metadata = { isEditorHelper: true };
|
|
76
|
+
this.highlightBox.scaling.set(this.voxelSize * 1.02, this.voxelSize * 1.02, this.voxelSize * 1.02);
|
|
77
|
+
}
|
|
78
|
+
initPointerHandling() {
|
|
79
|
+
this.scene.onPointerObservable.add((pointerInfo) => {
|
|
80
|
+
if (!this.isActive)
|
|
81
|
+
return;
|
|
82
|
+
switch (pointerInfo.type) {
|
|
83
|
+
case PointerEventTypes.POINTERMOVE:
|
|
84
|
+
this.lastPickInfo = pointerInfo.pickInfo;
|
|
85
|
+
this.handlePointerMove(pointerInfo.pickInfo);
|
|
86
|
+
if (this.isPointerDown) {
|
|
87
|
+
this.performAction(pointerInfo.pickInfo);
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
case PointerEventTypes.POINTERDOWN:
|
|
91
|
+
// Left mouse button only for painting
|
|
92
|
+
if (pointerInfo.event.button === 0) {
|
|
93
|
+
this.isPointerDown = true;
|
|
94
|
+
this.lastPaintedKey = null;
|
|
95
|
+
this.lastPickInfo = pointerInfo.pickInfo;
|
|
96
|
+
this.performAction(pointerInfo.pickInfo);
|
|
97
|
+
if (this.paintTimer)
|
|
98
|
+
clearInterval(this.paintTimer);
|
|
99
|
+
this.paintTimer = setInterval(() => {
|
|
100
|
+
if (this.isPointerDown) {
|
|
101
|
+
this.lastPaintedKey = null;
|
|
102
|
+
this.performAction(this.lastPickInfo);
|
|
103
|
+
}
|
|
104
|
+
}, this.paintIntervalMs);
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case PointerEventTypes.POINTERUP:
|
|
108
|
+
if (pointerInfo.event.button === 0) {
|
|
109
|
+
this.isPointerDown = false;
|
|
110
|
+
if (this.paintTimer) {
|
|
111
|
+
clearInterval(this.paintTimer);
|
|
112
|
+
this.paintTimer = null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
// Check dirty state on render loop
|
|
119
|
+
this.scene.onBeforeRenderObservable.add(() => {
|
|
120
|
+
if (this.renderDirty) {
|
|
121
|
+
this.updateThinInstances();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
setActive(active) {
|
|
126
|
+
this.isActive = active;
|
|
127
|
+
if (this.highlightBox) {
|
|
128
|
+
this.highlightBox.isVisible = false;
|
|
129
|
+
}
|
|
130
|
+
const canvas = this.service.canvas;
|
|
131
|
+
if (canvas) {
|
|
132
|
+
canvas.style.cursor = active ? 'crosshair' : 'default';
|
|
133
|
+
}
|
|
134
|
+
if (active) {
|
|
135
|
+
if (this.service.pathExtrusion?.isActive) {
|
|
136
|
+
this.service.pathExtrusion.setActive(false);
|
|
137
|
+
}
|
|
138
|
+
this.scene.constantlyUpdateMeshUnderPointer = true;
|
|
139
|
+
this.service.gizmoManager?.attachToMesh(null);
|
|
140
|
+
this.renderDirty = true;
|
|
141
|
+
this.updateThinInstances();
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
if (this.paintTimer) {
|
|
145
|
+
clearInterval(this.paintTimer);
|
|
146
|
+
this.paintTimer = null;
|
|
147
|
+
}
|
|
148
|
+
this.isPointerDown = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
setMode(mode) {
|
|
152
|
+
this.mode = mode;
|
|
153
|
+
if (this.highlightBox && this.highlightBox.material instanceof StandardMaterial) {
|
|
154
|
+
if (mode === 'erase') {
|
|
155
|
+
this.highlightBox.material.emissiveColor = new Color3(1, 0.2, 0.2);
|
|
156
|
+
}
|
|
157
|
+
else if (mode === 'pick') {
|
|
158
|
+
this.highlightBox.material.emissiveColor = new Color3(0.2, 0.7, 1);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
this.highlightBox.material.emissiveColor = new Color3(1, 0.85, 0.1);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
this.onModeChanged?.(mode);
|
|
165
|
+
}
|
|
166
|
+
setVoxelSize(size) {
|
|
167
|
+
this.voxelSize = Math.max(0.1, size);
|
|
168
|
+
if (this.highlightBox) {
|
|
169
|
+
this.highlightBox.scaling.set(this.voxelSize * 1.02, this.voxelSize * 1.02, this.voxelSize * 1.02);
|
|
170
|
+
}
|
|
171
|
+
this.renderDirty = true;
|
|
172
|
+
this.updateThinInstances();
|
|
173
|
+
}
|
|
174
|
+
setPaletteItem(paletteId) {
|
|
175
|
+
if (this.palette.has(paletteId)) {
|
|
176
|
+
this.currentPaletteId = paletteId;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
addPaletteItem(item) {
|
|
180
|
+
this.palette.set(item.id, item);
|
|
181
|
+
this.onPaletteChanged?.(Array.from(this.palette.values()));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Adds an individual/normal texture to the voxel palette and selects it.
|
|
185
|
+
*/
|
|
186
|
+
addTexturePaletteItem(name, textureUrl, texture) {
|
|
187
|
+
const palId = `tex_${Date.now().toString().slice(-4)}_${Math.floor(Math.random() * 1000)}`;
|
|
188
|
+
const item = {
|
|
189
|
+
id: palId,
|
|
190
|
+
name,
|
|
191
|
+
color: '#ffffff',
|
|
192
|
+
textureUrl,
|
|
193
|
+
texture,
|
|
194
|
+
};
|
|
195
|
+
this.palette.set(palId, item);
|
|
196
|
+
this.currentPaletteId = palId;
|
|
197
|
+
this.onPaletteChanged?.(Array.from(this.palette.values()));
|
|
198
|
+
this.renderDirty = true;
|
|
199
|
+
this.updateThinInstances();
|
|
200
|
+
return item;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Applies an active TextureAtlas to the Voxel Painter.
|
|
204
|
+
* Loads all atlas frames into the selectable palette!
|
|
205
|
+
*/
|
|
206
|
+
useTextureAtlas(atlasId) {
|
|
207
|
+
this.currentAtlasId = atlasId;
|
|
208
|
+
// Dispose old base meshes so new ones with the atlas texture and UVs are built
|
|
209
|
+
for (const m of this.baseMeshes.values()) {
|
|
210
|
+
m.dispose();
|
|
211
|
+
}
|
|
212
|
+
this.baseMeshes.clear();
|
|
213
|
+
if (!atlasId) {
|
|
214
|
+
this.onAtlasChanged?.(null);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const atlas = this.atlasManager.getAtlas(atlasId);
|
|
218
|
+
if (!atlas)
|
|
219
|
+
return;
|
|
220
|
+
// Clean previous atlas tiles from palette so only the active atlas's tiles are shown
|
|
221
|
+
for (const [key, item] of this.palette.entries()) {
|
|
222
|
+
if (item.atlasId && item.atlasId !== atlas.id) {
|
|
223
|
+
this.palette.delete(key);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const frame of atlas.frames) {
|
|
227
|
+
const palId = `atlas_${atlas.id}_${frame.id}`;
|
|
228
|
+
this.palette.set(palId, {
|
|
229
|
+
id: palId,
|
|
230
|
+
name: frame.name,
|
|
231
|
+
color: '#ffffff',
|
|
232
|
+
atlasId: atlas.id,
|
|
233
|
+
atlasTile: frame,
|
|
234
|
+
textureUrl: frame.thumbnailDataUrl,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
// Default to the first tile of this atlas
|
|
238
|
+
if (atlas.frames.length > 0) {
|
|
239
|
+
this.currentPaletteId = `atlas_${atlas.id}_${atlas.frames[0].id}`;
|
|
240
|
+
}
|
|
241
|
+
this.onAtlasChanged?.(atlas.id);
|
|
242
|
+
this.onPaletteChanged?.(Array.from(this.palette.values()));
|
|
243
|
+
this.renderDirty = true;
|
|
244
|
+
this.updateThinInstances();
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns palette items belonging to the currently active texture atlas,
|
|
248
|
+
* or all custom items if no atlas is selected.
|
|
249
|
+
*/
|
|
250
|
+
getActivePaletteItems() {
|
|
251
|
+
const all = Array.from(this.palette.values());
|
|
252
|
+
if (this.currentAtlasId) {
|
|
253
|
+
return all.filter((p) => !p.atlasId || p.atlasId === this.currentAtlasId);
|
|
254
|
+
}
|
|
255
|
+
return all;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Ray-cast slab method to find target voxel intersection.
|
|
259
|
+
*/
|
|
260
|
+
getTargetBlock(pickInfo, isErase = this.mode === 'erase', customRay) {
|
|
261
|
+
const ray = customRay ||
|
|
262
|
+
(this.scene.activeCamera
|
|
263
|
+
? this.scene.createPickingRay(this.scene.pointerX, this.scene.pointerY, Matrix.Identity(), this.scene.activeCamera)
|
|
264
|
+
: null);
|
|
265
|
+
if (!ray)
|
|
266
|
+
return null;
|
|
267
|
+
let closestT = Infinity;
|
|
268
|
+
let closestBlock = null;
|
|
269
|
+
let closestNormal = null;
|
|
270
|
+
// 1. Ray-cast against existing voxel blocks
|
|
271
|
+
for (const block of this.blocks.values()) {
|
|
272
|
+
const hit = this.rayBlockIntersect(ray, block.x, block.y, block.z);
|
|
273
|
+
if (hit !== null && hit.t < closestT && hit.t > 0) {
|
|
274
|
+
closestT = hit.t;
|
|
275
|
+
closestBlock = block;
|
|
276
|
+
closestNormal = hit.normal;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (closestBlock && closestNormal) {
|
|
280
|
+
if (isErase || this.mode === 'pick') {
|
|
281
|
+
return { x: closestBlock.x, y: closestBlock.y, z: closestBlock.z };
|
|
282
|
+
}
|
|
283
|
+
return {
|
|
284
|
+
x: closestBlock.x + closestNormal.x,
|
|
285
|
+
y: closestBlock.y + closestNormal.y,
|
|
286
|
+
z: closestBlock.z + closestNormal.z,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
// In erase or pick mode, do not target ground or meshes if no voxel block was intersected
|
|
290
|
+
if (isErase || this.mode === 'pick') {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
// 2. Check if ray hits an imported 3D mesh in the scene
|
|
294
|
+
const meshPick = this.scene.pickWithRay(ray, (m) => !this.service.isEditorHelper(m) && m.isPickable && m.isVisible);
|
|
295
|
+
if (meshPick && meshPick.hit && meshPick.pickedPoint) {
|
|
296
|
+
const norm = meshPick.getNormal(true) || Vector3.Up();
|
|
297
|
+
const pt = meshPick.pickedPoint.add(norm.scale(this.voxelSize * 0.5));
|
|
298
|
+
return {
|
|
299
|
+
x: Math.round(pt.x / this.voxelSize),
|
|
300
|
+
y: Math.max(0, Math.round(pt.y / this.voxelSize)),
|
|
301
|
+
z: Math.round(pt.z / this.voxelSize),
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
// 3. Fallback: mathematical ground plane at Y = 0
|
|
305
|
+
const groundPlane = Plane.FromPositionAndNormal(new Vector3(0, 0, 0), Vector3.Up());
|
|
306
|
+
const dist = ray.intersectsPlane(groundPlane);
|
|
307
|
+
if (dist !== null && dist > 0 && dist < 500) {
|
|
308
|
+
const pt = ray.origin.add(ray.direction.scale(dist));
|
|
309
|
+
return {
|
|
310
|
+
x: Math.round(pt.x / this.voxelSize),
|
|
311
|
+
y: 0,
|
|
312
|
+
z: Math.round(pt.z / this.voxelSize),
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Slab ray vs AABB block intersection.
|
|
319
|
+
*/
|
|
320
|
+
rayBlockIntersect(ray, bx, by, bz) {
|
|
321
|
+
const s = this.voxelSize;
|
|
322
|
+
const ox = ray.origin.x;
|
|
323
|
+
const oy = ray.origin.y;
|
|
324
|
+
const oz = ray.origin.z;
|
|
325
|
+
const dx = ray.direction.x;
|
|
326
|
+
const dy = ray.direction.y;
|
|
327
|
+
const dz = ray.direction.z;
|
|
328
|
+
let tmin = -Infinity;
|
|
329
|
+
let tmax = Infinity;
|
|
330
|
+
let normalAxis = 0;
|
|
331
|
+
let normalSign = 1;
|
|
332
|
+
const centers = [bx * s, by * s, bz * s];
|
|
333
|
+
const origins = [ox, oy, oz];
|
|
334
|
+
const dirs = [dx, dy, dz];
|
|
335
|
+
const half = s * 0.5;
|
|
336
|
+
for (let i = 0; i < 3; i++) {
|
|
337
|
+
const o = origins[i];
|
|
338
|
+
const d = dirs[i];
|
|
339
|
+
const b = centers[i];
|
|
340
|
+
if (Math.abs(d) < 1e-10) {
|
|
341
|
+
if (o < b - half || o > b + half)
|
|
342
|
+
return null;
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
let t1 = (b - half - o) / d;
|
|
346
|
+
let t2 = (b + half - o) / d;
|
|
347
|
+
if (t1 > t2) {
|
|
348
|
+
const tmp = t1;
|
|
349
|
+
t1 = t2;
|
|
350
|
+
t2 = tmp;
|
|
351
|
+
}
|
|
352
|
+
if (t1 > tmin) {
|
|
353
|
+
tmin = t1;
|
|
354
|
+
normalAxis = i;
|
|
355
|
+
normalSign = -Math.sign(d);
|
|
356
|
+
}
|
|
357
|
+
tmax = Math.min(tmax, t2);
|
|
358
|
+
if (tmin > tmax)
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
if (tmax < 0 || tmin < 0)
|
|
362
|
+
return null;
|
|
363
|
+
const normal = { x: 0, y: 0, z: 0 };
|
|
364
|
+
if (normalAxis === 0)
|
|
365
|
+
normal.x = normalSign;
|
|
366
|
+
else if (normalAxis === 1)
|
|
367
|
+
normal.y = normalSign;
|
|
368
|
+
else
|
|
369
|
+
normal.z = normalSign;
|
|
370
|
+
return { t: tmin, normal };
|
|
371
|
+
}
|
|
372
|
+
handlePointerMove(pickInfo) {
|
|
373
|
+
if (!this.highlightBox)
|
|
374
|
+
return;
|
|
375
|
+
const isErase = this.mode === 'erase';
|
|
376
|
+
const target = this.getTargetBlock(pickInfo, isErase);
|
|
377
|
+
if (!target) {
|
|
378
|
+
this.highlightBox.isVisible = false;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
this.highlightBox.position.set(target.x * this.voxelSize, target.y * this.voxelSize, target.z * this.voxelSize);
|
|
382
|
+
this.highlightBox.isVisible = true;
|
|
383
|
+
}
|
|
384
|
+
performAction(pickInfo) {
|
|
385
|
+
const isErase = this.mode === 'erase';
|
|
386
|
+
const target = this.getTargetBlock(pickInfo, isErase);
|
|
387
|
+
if (!target)
|
|
388
|
+
return;
|
|
389
|
+
const key = `${target.x},${target.y},${target.z}`;
|
|
390
|
+
if (key === this.lastPaintedKey)
|
|
391
|
+
return;
|
|
392
|
+
this.lastPaintedKey = key;
|
|
393
|
+
if (this.mode === 'pick') {
|
|
394
|
+
const block = this.blocks.get(key);
|
|
395
|
+
if (block) {
|
|
396
|
+
this.setPaletteItem(block.paletteId);
|
|
397
|
+
this.setMode('paint');
|
|
398
|
+
}
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (!isErase) {
|
|
402
|
+
if (!this.blocks.has(key)) {
|
|
403
|
+
this.blocks.set(key, {
|
|
404
|
+
x: target.x,
|
|
405
|
+
y: target.y,
|
|
406
|
+
z: target.z,
|
|
407
|
+
paletteId: this.currentPaletteId,
|
|
408
|
+
});
|
|
409
|
+
this.renderDirty = true;
|
|
410
|
+
this.onBlocksChanged?.(this.blocks.size);
|
|
411
|
+
this.updateThinInstances();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
if (this.blocks.has(key)) {
|
|
416
|
+
this.blocks.delete(key);
|
|
417
|
+
this.renderDirty = true;
|
|
418
|
+
this.onBlocksChanged?.(this.blocks.size);
|
|
419
|
+
this.updateThinInstances();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
setBlock(x, y, z, paletteId) {
|
|
424
|
+
const palId = paletteId || this.currentPaletteId;
|
|
425
|
+
const key = `${x},${y},${z}`;
|
|
426
|
+
this.blocks.set(key, { x, y, z, paletteId: palId });
|
|
427
|
+
this.renderDirty = true;
|
|
428
|
+
this.onBlocksChanged?.(this.blocks.size);
|
|
429
|
+
this.updateThinInstances();
|
|
430
|
+
}
|
|
431
|
+
getBlock(x, y, z) {
|
|
432
|
+
return this.blocks.get(`${x},${y},${z}`);
|
|
433
|
+
}
|
|
434
|
+
removeBlock(x, y, z) {
|
|
435
|
+
const key = `${x},${y},${z}`;
|
|
436
|
+
const deleted = this.blocks.delete(key);
|
|
437
|
+
if (deleted) {
|
|
438
|
+
this.renderDirty = true;
|
|
439
|
+
this.onBlocksChanged?.(this.blocks.size);
|
|
440
|
+
this.updateThinInstances();
|
|
441
|
+
}
|
|
442
|
+
return deleted;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Updates Thin Instances live in the scene for 60fps painting.
|
|
446
|
+
*/
|
|
447
|
+
updateThinInstances() {
|
|
448
|
+
this.renderDirty = false;
|
|
449
|
+
// Group blocks by palette
|
|
450
|
+
const grouped = new Map();
|
|
451
|
+
for (const b of this.blocks.values()) {
|
|
452
|
+
let list = grouped.get(b.paletteId);
|
|
453
|
+
if (!list) {
|
|
454
|
+
list = [];
|
|
455
|
+
grouped.set(b.paletteId, list);
|
|
456
|
+
}
|
|
457
|
+
list.push(b);
|
|
458
|
+
}
|
|
459
|
+
const s = this.voxelSize;
|
|
460
|
+
// Build or update base meshes
|
|
461
|
+
for (const [palId, palItem] of this.palette.entries()) {
|
|
462
|
+
let baseMesh = this.baseMeshes.get(palId);
|
|
463
|
+
if (!baseMesh) {
|
|
464
|
+
let faceUV;
|
|
465
|
+
const mat = new StandardMaterial(`editor_vox_mat_${palId}`, this.scene);
|
|
466
|
+
if (palItem.atlasTile && palItem.atlasId) {
|
|
467
|
+
const atlas = this.atlasManager.getAtlas(palItem.atlasId);
|
|
468
|
+
if (atlas) {
|
|
469
|
+
mat.diffuseTexture = atlas.texture;
|
|
470
|
+
mat.emissiveColor = new Color3(0.25, 0.25, 0.25);
|
|
471
|
+
const t = palItem.atlasTile;
|
|
472
|
+
const uvVec = new Vector4(t.uMin, t.vMin, t.uMax, t.vMax);
|
|
473
|
+
faceUV = [uvVec, uvVec, uvVec, uvVec, uvVec, uvVec];
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
else if (palItem.texture) {
|
|
477
|
+
mat.diffuseTexture = palItem.texture;
|
|
478
|
+
mat.emissiveColor = new Color3(0.25, 0.25, 0.25);
|
|
479
|
+
}
|
|
480
|
+
else if (palItem.textureUrl) {
|
|
481
|
+
mat.diffuseTexture = new Texture(palItem.textureUrl, this.scene);
|
|
482
|
+
mat.emissiveColor = new Color3(0.25, 0.25, 0.25);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
mat.diffuseColor = Color3.FromHexString(palItem.color || '#888c94');
|
|
486
|
+
mat.emissiveColor = Color3.FromHexString(palItem.color || '#888c94').scale(0.3);
|
|
487
|
+
}
|
|
488
|
+
mat.specularColor = new Color3(0.1, 0.1, 0.1);
|
|
489
|
+
mat.backFaceCulling = false;
|
|
490
|
+
baseMesh = MeshBuilder.CreateBox(`editor_vox_base_${palId}`, { size: 1.0, faceUV, wrap: true }, this.scene);
|
|
491
|
+
baseMesh.material = mat;
|
|
492
|
+
baseMesh.isPickable = false;
|
|
493
|
+
baseMesh.isVisible = false;
|
|
494
|
+
baseMesh.metadata = { isEditorHelper: true };
|
|
495
|
+
baseMesh.thinInstanceSetBuffer('matrix', new Float32Array(0), 16, false);
|
|
496
|
+
this.baseMeshes.set(palId, baseMesh);
|
|
497
|
+
}
|
|
498
|
+
baseMesh.scaling.set(1, 1, 1);
|
|
499
|
+
baseMesh.position.set(0, 0, 0);
|
|
500
|
+
const list = grouped.get(palId);
|
|
501
|
+
if (!list || list.length === 0) {
|
|
502
|
+
baseMesh.thinInstanceCount = 0;
|
|
503
|
+
baseMesh.isVisible = false;
|
|
504
|
+
continue;
|
|
505
|
+
}
|
|
506
|
+
baseMesh.isVisible = true;
|
|
507
|
+
const matrixData = new Float32Array(list.length * 16);
|
|
508
|
+
for (let i = 0; i < list.length; i++) {
|
|
509
|
+
const b = list[i];
|
|
510
|
+
matrixData[i * 16 + 0] = s;
|
|
511
|
+
matrixData[i * 16 + 5] = s;
|
|
512
|
+
matrixData[i * 16 + 10] = s;
|
|
513
|
+
matrixData[i * 16 + 15] = 1.0;
|
|
514
|
+
matrixData[i * 16 + 12] = b.x * s;
|
|
515
|
+
matrixData[i * 16 + 13] = b.y * s;
|
|
516
|
+
matrixData[i * 16 + 14] = b.z * s;
|
|
517
|
+
}
|
|
518
|
+
baseMesh.thinInstanceSetBuffer('matrix', matrixData, 16, false);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Bakes the painted voxels into an optimized, editable 3D mesh in the active scene.
|
|
523
|
+
*/
|
|
524
|
+
bakeToMesh(name = 'Voxel_Model') {
|
|
525
|
+
if (this.blocks.size === 0) {
|
|
526
|
+
this.service.events.onToast?.('No voxels to bake. Paint some blocks first!', 'warning');
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
const blocksArray = Array.from(this.blocks.values());
|
|
530
|
+
const atlas = this.currentAtlasId ? this.atlasManager.getAtlas(this.currentAtlasId) : undefined;
|
|
531
|
+
const mesh = CustomVoxelMesher.build(this.scene, blocksArray, this.palette, {
|
|
532
|
+
voxelSize: this.voxelSize,
|
|
533
|
+
meshName: name,
|
|
534
|
+
atlas,
|
|
535
|
+
});
|
|
536
|
+
if (!mesh) {
|
|
537
|
+
this.service.events.onToast?.('Failed to build voxel mesh geometry.', 'error');
|
|
538
|
+
return null;
|
|
539
|
+
}
|
|
540
|
+
this.service.importedMeshes.push(mesh);
|
|
541
|
+
this.service.centerMeshPivot(mesh);
|
|
542
|
+
this.service.selectMesh(mesh);
|
|
543
|
+
// Register Undo / Redo action
|
|
544
|
+
this.service.recordAction({
|
|
545
|
+
name: `Bake Voxel Mesh "${mesh.name}"`,
|
|
546
|
+
undo: () => {
|
|
547
|
+
const idx = this.service.importedMeshes.indexOf(mesh);
|
|
548
|
+
if (idx !== -1)
|
|
549
|
+
this.service.importedMeshes.splice(idx, 1);
|
|
550
|
+
mesh.dispose();
|
|
551
|
+
this.service.events.onSceneModified?.();
|
|
552
|
+
},
|
|
553
|
+
redo: () => {
|
|
554
|
+
// Re-build
|
|
555
|
+
const recreated = CustomVoxelMesher.build(this.scene, blocksArray, this.palette, {
|
|
556
|
+
voxelSize: this.voxelSize,
|
|
557
|
+
meshName: name,
|
|
558
|
+
atlas,
|
|
559
|
+
});
|
|
560
|
+
if (recreated) {
|
|
561
|
+
this.service.importedMeshes.push(recreated);
|
|
562
|
+
this.service.selectMesh(recreated);
|
|
563
|
+
this.service.events.onSceneModified?.();
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
this.service.events.onToast?.(`Successfully baked ${this.blocks.size} voxels into mesh "${mesh.name}" (${mesh.getTotalVertices()} vertices).`, 'success');
|
|
568
|
+
this.service.events.onSceneModified?.();
|
|
569
|
+
return mesh;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Loads voxel data from RLE runs or standard coordinates (platformia3d compatible).
|
|
573
|
+
*/
|
|
574
|
+
loadVoxelData(data) {
|
|
575
|
+
this.clear();
|
|
576
|
+
const filePalette = data.palette || [];
|
|
577
|
+
const runs = data.runs || [];
|
|
578
|
+
if (runs.length > 0) {
|
|
579
|
+
// Parse Run-Length Encoded format
|
|
580
|
+
for (let i = 0; i < runs.length; i += 5) {
|
|
581
|
+
const x = runs[i];
|
|
582
|
+
const startY = runs[i + 1];
|
|
583
|
+
const z = runs[i + 2];
|
|
584
|
+
const len = runs[i + 3];
|
|
585
|
+
const palIdx = runs[i + 4];
|
|
586
|
+
const palId = filePalette[palIdx] || this.currentPaletteId;
|
|
587
|
+
for (let y = startY; y < startY + len; y++) {
|
|
588
|
+
this.blocks.set(`${x},${y},${z}`, { x, y, z, paletteId: palId });
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
else if (Array.isArray(data.voxels)) {
|
|
593
|
+
for (const v of data.voxels) {
|
|
594
|
+
const x = Math.round(Number(v.x) || 0);
|
|
595
|
+
const y = Math.round(Number(v.y) || 0);
|
|
596
|
+
const z = Math.round(Number(v.z) || 0);
|
|
597
|
+
const palId = String(v.palette || v.paletteId || this.currentPaletteId);
|
|
598
|
+
this.blocks.set(`${x},${y},${z}`, { x, y, z, paletteId: palId });
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
this.renderDirty = true;
|
|
602
|
+
this.onBlocksChanged?.(this.blocks.size);
|
|
603
|
+
return this.blocks.size;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Exports painted blocks into the platformia3d RLE VoxelData JSON format.
|
|
607
|
+
*/
|
|
608
|
+
exportVoxelData() {
|
|
609
|
+
const usedPalette = [];
|
|
610
|
+
const paletteMap = new Map();
|
|
611
|
+
const allBlocks = Array.from(this.blocks.values());
|
|
612
|
+
allBlocks.sort((a, b) => {
|
|
613
|
+
if (a.x !== b.x)
|
|
614
|
+
return a.x - b.x;
|
|
615
|
+
if (a.z !== b.z)
|
|
616
|
+
return a.z - b.z;
|
|
617
|
+
return a.y - b.y;
|
|
618
|
+
});
|
|
619
|
+
const runs = [];
|
|
620
|
+
let currentRun = null;
|
|
621
|
+
for (const b of allBlocks) {
|
|
622
|
+
if (!paletteMap.has(b.paletteId)) {
|
|
623
|
+
paletteMap.set(b.paletteId, usedPalette.length);
|
|
624
|
+
usedPalette.push(b.paletteId);
|
|
625
|
+
}
|
|
626
|
+
const palIdx = paletteMap.get(b.paletteId);
|
|
627
|
+
if (currentRun &&
|
|
628
|
+
currentRun.x === b.x &&
|
|
629
|
+
currentRun.z === b.z &&
|
|
630
|
+
currentRun.palIdx === palIdx &&
|
|
631
|
+
currentRun.y + currentRun.len === b.y) {
|
|
632
|
+
currentRun.len++;
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
if (currentRun) {
|
|
636
|
+
runs.push(currentRun.x, currentRun.y, currentRun.z, currentRun.len, currentRun.palIdx);
|
|
637
|
+
}
|
|
638
|
+
currentRun = { x: b.x, y: b.y, z: b.z, len: 1, palIdx };
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
if (currentRun) {
|
|
642
|
+
runs.push(currentRun.x, currentRun.y, currentRun.z, currentRun.len, currentRun.palIdx);
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
version: 1,
|
|
646
|
+
palette: usedPalette,
|
|
647
|
+
runs,
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
clear() {
|
|
651
|
+
this.blocks.clear();
|
|
652
|
+
for (const base of this.baseMeshes.values()) {
|
|
653
|
+
base.thinInstanceCount = 0;
|
|
654
|
+
base.isVisible = false;
|
|
655
|
+
}
|
|
656
|
+
this.renderDirty = true;
|
|
657
|
+
this.onBlocksChanged?.(0);
|
|
658
|
+
}
|
|
659
|
+
dispose() {
|
|
660
|
+
this.setActive(false);
|
|
661
|
+
this.clear();
|
|
662
|
+
for (const base of this.baseMeshes.values()) {
|
|
663
|
+
base.dispose();
|
|
664
|
+
}
|
|
665
|
+
this.baseMeshes.clear();
|
|
666
|
+
if (this.highlightBox) {
|
|
667
|
+
this.highlightBox.dispose();
|
|
668
|
+
this.highlightBox = null;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
//# sourceMappingURL=VoxelPainterController.js.map
|