mesheditor 0.0.0-stage → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +853 -2
- package/dist-lib/esm/AIAgentService.d.ts +106 -0
- package/dist-lib/esm/AIAgentService.js +1471 -0
- package/dist-lib/esm/MeshEditorApp.d.ts +412 -0
- package/dist-lib/esm/MeshEditorApp.js +9092 -0
- package/dist-lib/esm/MeshEditorService.d.ts +459 -0
- package/dist-lib/esm/MeshEditorService.js +7083 -0
- package/dist-lib/esm/Neural3DGeneratorService.d.ts +88 -0
- package/dist-lib/esm/Neural3DGeneratorService.js +1397 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts +16 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.js +25 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts +32 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.js +336 -0
- package/dist-lib/esm/adapters/HostAppAdapter.d.ts +54 -0
- package/dist-lib/esm/adapters/HostAppAdapter.js +75 -0
- package/dist-lib/esm/adapters/PlatformAdapter.d.ts +98 -0
- package/dist-lib/esm/adapters/PlatformAdapter.js +1 -0
- package/dist-lib/esm/adapters/index.d.ts +13 -0
- package/dist-lib/esm/adapters/index.js +15 -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 +84 -0
- package/dist-lib/esm/baking/TextureBaker.js +709 -0
- package/dist-lib/esm/builtInSkills.d.ts +19 -0
- package/dist-lib/esm/builtInSkills.js +186 -0
- package/dist-lib/esm/compression/ModelCompressor.d.ts +87 -0
- package/dist-lib/esm/compression/ModelCompressor.js +553 -0
- package/dist-lib/esm/decals/DecalController.d.ts +147 -0
- package/dist-lib/esm/decals/DecalController.js +1031 -0
- package/dist-lib/esm/decals/decalAssetUrls.d.ts +1 -0
- package/dist-lib/esm/decals/decalAssetUrls.js +16 -0
- package/dist-lib/esm/geometry/architecture.d.ts +114 -0
- package/dist-lib/esm/geometry/architecture.js +832 -0
- package/dist-lib/esm/geometry/bevelModifier.d.ts +59 -0
- package/dist-lib/esm/geometry/bevelModifier.js +345 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts +127 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.js +676 -0
- package/dist-lib/esm/geometry/roundedBox.d.ts +15 -0
- package/dist-lib/esm/geometry/roundedBox.js +133 -0
- package/dist-lib/esm/index.d.ts +21 -0
- package/dist-lib/esm/index.js +50 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts +59 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.js +483 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts +76 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js +1792 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.d.ts +95 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.js +627 -0
- package/dist-lib/esm/pathExtrusion/index.d.ts +4 -0
- package/dist-lib/esm/pathExtrusion/index.js +4 -0
- package/dist-lib/esm/pathExtrusion/types.d.ts +50 -0
- package/dist-lib/esm/pathExtrusion/types.js +1 -0
- package/dist-lib/esm/plugin.d.ts +250 -0
- package/dist-lib/esm/plugin.js +144 -0
- package/dist-lib/esm/rigging/WeightPaintController.d.ts +162 -0
- package/dist-lib/esm/rigging/WeightPaintController.js +1421 -0
- package/dist-lib/esm/sculpting/SculptController.d.ts +146 -0
- package/dist-lib/esm/sculpting/SculptController.js +2038 -0
- package/dist-lib/esm/sdf/index.d.ts +2 -0
- package/dist-lib/esm/sdf/index.js +2 -0
- package/dist-lib/esm/sdf/sdfPrimitives.d.ts +97 -0
- package/dist-lib/esm/sdf/sdfPrimitives.js +402 -0
- package/dist-lib/esm/sdf/surfaceNets.d.ts +29 -0
- package/dist-lib/esm/sdf/surfaceNets.js +399 -0
- package/dist-lib/esm/styles.d.ts +11 -0
- package/dist-lib/esm/styles.js +32 -0
- package/dist-lib/esm/template.d.ts +12 -0
- package/dist-lib/esm/template.js +19 -0
- package/dist-lib/esm/textMesh/TextMeshController.d.ts +61 -0
- package/dist-lib/esm/textMesh/TextMeshController.js +405 -0
- package/dist-lib/esm/textures/AITextureGenerator.d.ts +119 -0
- package/dist-lib/esm/textures/AITextureGenerator.js +945 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts +62 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.js +879 -0
- package/dist-lib/esm/tools/AbstractTool.d.ts +68 -0
- package/dist-lib/esm/tools/AbstractTool.js +128 -0
- package/dist-lib/esm/tools/ToolExecutionContext.d.ts +40 -0
- package/dist-lib/esm/tools/ToolExecutionContext.js +1 -0
- package/dist-lib/esm/tools/ToolInterface.d.ts +104 -0
- package/dist-lib/esm/tools/ToolInterface.js +1 -0
- package/dist-lib/esm/tools/ToolRegistry.d.ts +43 -0
- package/dist-lib/esm/tools/ToolRegistry.js +115 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts +34 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js +48 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts +34 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js +54 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts +42 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.js +81 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts +51 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.js +86 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts +78 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js +170 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts +75 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.js +115 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts +118 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.js +89 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts +114 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.js +105 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts +87 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.js +60 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts +114 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.js +212 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts +120 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.js +95 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts +162 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js +302 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts +120 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.js +108 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts +101 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js +79 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts +224 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js +238 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts +135 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.js +119 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts +94 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js +131 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts +87 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.js +59 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts +145 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.js +124 -0
- package/dist-lib/esm/tools/builtin/DecalTool.d.ts +76 -0
- package/dist-lib/esm/tools/builtin/DecalTool.js +143 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts +20 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.js +42 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts +21 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js +96 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts +114 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js +77 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts +104 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js +68 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts +36 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.js +57 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts +30 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js +49 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts +30 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js +49 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts +34 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.js +55 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts +131 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js +455 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts +87 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.js +216 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts +11 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js +12 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts +28 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.js +56 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts +87 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.js +155 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts +50 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js +116 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts +55 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.js +139 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts +138 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.js +255 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts +21 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.js +31 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts +30 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js +57 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts +66 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js +105 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts +23 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.js +37 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts +23 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js +39 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts +78 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.js +69 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts +48 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.js +107 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts +60 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.js +153 -0
- package/dist-lib/esm/tools/builtin/index.d.ts +44 -0
- package/dist-lib/esm/tools/builtin/index.js +44 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.js +43 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts +15 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.js +28 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts +29 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.js +56 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js +29 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts +21 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.js +44 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts +20 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.js +42 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts +20 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.js +48 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js +36 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.js +36 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts +23 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.js +80 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.js +43 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js +37 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.js +34 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts +26 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js +72 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts +27 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.js +66 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js +35 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts +28 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.js +70 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts +16 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.js +30 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js +28 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts +27 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js +70 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts +26 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js +68 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts +30 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.js +228 -0
- package/dist-lib/esm/tools/editor/index.d.ts +32 -0
- package/dist-lib/esm/tools/editor/index.js +54 -0
- package/dist-lib/esm/tools/editor/toolViews.d.ts +10 -0
- package/dist-lib/esm/tools/editor/toolViews.js +53 -0
- package/dist-lib/esm/tools/editorTools.d.ts +5 -0
- package/dist-lib/esm/tools/editorTools.js +5 -0
- package/dist-lib/esm/tools/index.d.ts +8 -0
- package/dist-lib/esm/tools/index.js +8 -0
- package/dist-lib/esm/tools/textureUtils.d.ts +18 -0
- package/dist-lib/esm/tools/textureUtils.js +288 -0
- package/dist-lib/esm/types.d.ts +164 -0
- package/dist-lib/esm/types.js +1 -0
- package/dist-lib/esm/uv/UVUnwrapController.d.ts +108 -0
- package/dist-lib/esm/uv/UVUnwrapController.js +1022 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts +15 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.js +169 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.d.ts +54 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.js +630 -0
- package/dist-lib/esm/voxel/VoxelPainterController.d.ts +100 -0
- package/dist-lib/esm/voxel/VoxelPainterController.js +671 -0
- package/dist-lib/esm/voxel/index.d.ts +4 -0
- package/dist-lib/esm/voxel/index.js +4 -0
- package/dist-lib/esm/voxel/types.d.ts +78 -0
- package/dist-lib/esm/voxel/types.js +1 -0
- package/dist-lib/esm/web-component/MeshEditorElement.d.ts +103 -0
- package/dist-lib/esm/web-component/MeshEditorElement.js +246 -0
- package/dist-lib/esm/web-component/index.d.ts +1 -0
- package/dist-lib/esm/web-component/index.js +1 -0
- package/dist-lib/index.umd.js +3 -0
- package/dist-lib/mesheditor.css +2 -0
- package/dist-lib/mesheditor.css.map +1 -0
- package/dist-lib/standalone/mesheditor-element.bundle.js +3 -0
- package/package.json +114 -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,68 @@
|
|
|
1
|
+
import { Mesh, PBRMaterial, Vector3 } from '@babylonjs/core';
|
|
2
|
+
import { ToolExecutionContext } from './ToolExecutionContext';
|
|
3
|
+
import { OpenAIToolDefinition, ToolInterface } from './ToolInterface';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract base class for self-contained tools.
|
|
6
|
+
* Provides standard parameter schema wrapping and convenient helper utilities
|
|
7
|
+
* so subclasses only need to specify their metadata and execute() implementation.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class AbstractTool implements ToolInterface {
|
|
10
|
+
abstract readonly name: string;
|
|
11
|
+
abstract readonly description: string;
|
|
12
|
+
readonly helpText?: string;
|
|
13
|
+
readonly icon?: string;
|
|
14
|
+
readonly dialogId?: string;
|
|
15
|
+
readonly triggerButtonId?: string;
|
|
16
|
+
readonly menuId?: string;
|
|
17
|
+
readonly menuLabel?: string;
|
|
18
|
+
readonly isExclusive3DTool?: boolean;
|
|
19
|
+
readonly defaultOpen?: boolean;
|
|
20
|
+
order?: number;
|
|
21
|
+
readonly viewTemplate?: string;
|
|
22
|
+
abstract readonly parameters: Record<string, any>;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the HTML/EJS view template markup for this tool dialog.
|
|
25
|
+
*/
|
|
26
|
+
getViewTemplate(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Mounts or retrieves the tool's dialog DOM element.
|
|
29
|
+
* If the dialog element is not already present in the DOM, mounts it from `viewTemplate`.
|
|
30
|
+
*/
|
|
31
|
+
renderView(container?: HTMLElement): HTMLElement | null;
|
|
32
|
+
/**
|
|
33
|
+
* Generates standard OpenAI tool schema definition.
|
|
34
|
+
*/
|
|
35
|
+
getDefinition(): OpenAIToolDefinition;
|
|
36
|
+
/**
|
|
37
|
+
* Abstract execution method to be implemented by each concrete tool.
|
|
38
|
+
*/
|
|
39
|
+
abstract execute(args: any, context: ToolExecutionContext): Promise<string> | string;
|
|
40
|
+
/**
|
|
41
|
+
* Parses a 3D vector from an array `[x, y, z]` or object `{x, y, z}`.
|
|
42
|
+
*/
|
|
43
|
+
protected parseVec3(v: any, defaultVal?: number): Vector3;
|
|
44
|
+
/**
|
|
45
|
+
* Parses a 2D or 3D point into a Vector3 suitable for polygon builders.
|
|
46
|
+
*/
|
|
47
|
+
protected parsePolygonPoint(p: any): Vector3;
|
|
48
|
+
/**
|
|
49
|
+
* Normalizes hex color values to `#RRGGBB` format.
|
|
50
|
+
*/
|
|
51
|
+
protected normalizeHex(hex: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* Helper to look up an active mesh in the scene by name or id.
|
|
54
|
+
*/
|
|
55
|
+
protected findMesh(identifier: string, context: ToolExecutionContext): Mesh | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Helper to register a newly created mesh into the editor's scene index.
|
|
58
|
+
*/
|
|
59
|
+
protected registerMesh(mesh: Mesh, context: ToolExecutionContext): void;
|
|
60
|
+
/**
|
|
61
|
+
* Helper to apply standard transform arguments (position, rotation, scaling) to a mesh.
|
|
62
|
+
*/
|
|
63
|
+
protected applyTransform(mesh: Mesh, args: any, context: ToolExecutionContext): void;
|
|
64
|
+
/**
|
|
65
|
+
* Helper to get an existing material by name or create a new PBRMaterial.
|
|
66
|
+
*/
|
|
67
|
+
protected getOrCreateMaterial(context: ToolExecutionContext, materialName?: string, colorHex?: string, roughness?: number, metallic?: number, fallbackName?: string): PBRMaterial;
|
|
68
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Vector3 } from '@babylonjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract base class for self-contained tools.
|
|
4
|
+
* Provides standard parameter schema wrapping and convenient helper utilities
|
|
5
|
+
* so subclasses only need to specify their metadata and execute() implementation.
|
|
6
|
+
*/
|
|
7
|
+
export class AbstractTool {
|
|
8
|
+
helpText;
|
|
9
|
+
icon;
|
|
10
|
+
dialogId;
|
|
11
|
+
triggerButtonId;
|
|
12
|
+
menuId;
|
|
13
|
+
menuLabel;
|
|
14
|
+
isExclusive3DTool;
|
|
15
|
+
defaultOpen;
|
|
16
|
+
order;
|
|
17
|
+
viewTemplate;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the HTML/EJS view template markup for this tool dialog.
|
|
20
|
+
*/
|
|
21
|
+
getViewTemplate() {
|
|
22
|
+
return this.viewTemplate || '';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Mounts or retrieves the tool's dialog DOM element.
|
|
26
|
+
* If the dialog element is not already present in the DOM, mounts it from `viewTemplate`.
|
|
27
|
+
*/
|
|
28
|
+
renderView(container) {
|
|
29
|
+
if (typeof document === 'undefined')
|
|
30
|
+
return null;
|
|
31
|
+
if (this.dialogId) {
|
|
32
|
+
const existing = document.getElementById(this.dialogId);
|
|
33
|
+
if (existing)
|
|
34
|
+
return existing;
|
|
35
|
+
}
|
|
36
|
+
const template = this.getViewTemplate();
|
|
37
|
+
if (!template)
|
|
38
|
+
return null;
|
|
39
|
+
const target = container || document.getElementById('stackpanelRightSidebar') || document.body;
|
|
40
|
+
const wrapper = document.createElement('div');
|
|
41
|
+
wrapper.innerHTML = template.trim();
|
|
42
|
+
const element = wrapper.firstElementChild;
|
|
43
|
+
if (element && target) {
|
|
44
|
+
target.appendChild(element);
|
|
45
|
+
return element;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Generates standard OpenAI tool schema definition.
|
|
51
|
+
*/
|
|
52
|
+
getDefinition() {
|
|
53
|
+
return {
|
|
54
|
+
type: 'function',
|
|
55
|
+
function: {
|
|
56
|
+
name: this.name,
|
|
57
|
+
description: this.description,
|
|
58
|
+
parameters: this.parameters,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Parses a 3D vector from an array `[x, y, z]` or object `{x, y, z}`.
|
|
64
|
+
*/
|
|
65
|
+
parseVec3(v, defaultVal = 0) {
|
|
66
|
+
if (Array.isArray(v)) {
|
|
67
|
+
return new Vector3(Number(v[0] ?? defaultVal) || 0, Number(v[1] ?? defaultVal) || 0, Number(v[2] ?? defaultVal) || 0);
|
|
68
|
+
}
|
|
69
|
+
return new Vector3(Number(v?.x ?? defaultVal) || 0, Number(v?.y ?? defaultVal) || 0, Number(v?.z ?? defaultVal) || 0);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Parses a 2D or 3D point into a Vector3 suitable for polygon builders.
|
|
73
|
+
*/
|
|
74
|
+
parsePolygonPoint(p) {
|
|
75
|
+
if (Array.isArray(p)) {
|
|
76
|
+
if (p.length === 2) {
|
|
77
|
+
return new Vector3(Number(p[0]) || 0, 0, Number(p[1]) || 0);
|
|
78
|
+
}
|
|
79
|
+
return new Vector3(Number(p[0]) || 0, Number(p[1]) || 0, Number(p[2]) || 0);
|
|
80
|
+
}
|
|
81
|
+
return new Vector3(Number(p?.x) || 0, Number(p?.y) || 0, Number(p?.z) || 0);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Normalizes hex color values to `#RRGGBB` format.
|
|
85
|
+
*/
|
|
86
|
+
normalizeHex(hex) {
|
|
87
|
+
if (!hex || typeof hex !== 'string')
|
|
88
|
+
return '#58a6ff';
|
|
89
|
+
const trimmed = hex.trim();
|
|
90
|
+
if (/^#[0-9a-fA-F]{6}$/.test(trimmed))
|
|
91
|
+
return trimmed;
|
|
92
|
+
if (/^#[0-9a-fA-F]{3}$/.test(trimmed)) {
|
|
93
|
+
return ('#' +
|
|
94
|
+
trimmed
|
|
95
|
+
.slice(1)
|
|
96
|
+
.split('')
|
|
97
|
+
.map((c) => c + c)
|
|
98
|
+
.join(''));
|
|
99
|
+
}
|
|
100
|
+
if (/^[0-9a-fA-F]{6}$/.test(trimmed))
|
|
101
|
+
return '#' + trimmed;
|
|
102
|
+
return '#58a6ff';
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Helper to look up an active mesh in the scene by name or id.
|
|
106
|
+
*/
|
|
107
|
+
findMesh(identifier, context) {
|
|
108
|
+
return context.findMeshByNameOrId(identifier);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Helper to register a newly created mesh into the editor's scene index.
|
|
112
|
+
*/
|
|
113
|
+
registerMesh(mesh, context) {
|
|
114
|
+
context.registerCreatedMesh(mesh);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Helper to apply standard transform arguments (position, rotation, scaling) to a mesh.
|
|
118
|
+
*/
|
|
119
|
+
applyTransform(mesh, args, context) {
|
|
120
|
+
context.applyTransformArgs(mesh, args);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Helper to get an existing material by name or create a new PBRMaterial.
|
|
124
|
+
*/
|
|
125
|
+
getOrCreateMaterial(context, materialName, colorHex, roughness, metallic, fallbackName = 'Mat') {
|
|
126
|
+
return context.getOrCreateMaterial(materialName, colorHex, roughness, metallic, fallbackName);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Mesh, PBRMaterial, Scene, Vector3 } from '@babylonjs/core';
|
|
2
|
+
import type { MeshEditorService } from '../MeshEditorService';
|
|
3
|
+
import type { AIAgentService } from '../AIAgentService';
|
|
4
|
+
/**
|
|
5
|
+
* Execution context provided to tools when executed by the tool registry.
|
|
6
|
+
* Provides direct access to the live scene, editor service, mesh finding,
|
|
7
|
+
* material caching, and transform utilities.
|
|
8
|
+
*/
|
|
9
|
+
export interface ToolExecutionContext {
|
|
10
|
+
/** The core 3D mesh editor service */
|
|
11
|
+
service: MeshEditorService;
|
|
12
|
+
/** The live Babylon.js scene */
|
|
13
|
+
scene: Scene;
|
|
14
|
+
/** The AI agent service instance if running within an agent session */
|
|
15
|
+
aiAgent?: AIAgentService;
|
|
16
|
+
/** Reference images (data URLs or HTTP URLs) attached to the current agent request */
|
|
17
|
+
attachedImages?: string[];
|
|
18
|
+
/** Optional abort signal for long-running async tools */
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
/** Optional status callback for long-running async tools */
|
|
21
|
+
onStatus?: (statusText: string) => void;
|
|
22
|
+
/** Cached materials by name */
|
|
23
|
+
materialRegistry: Map<string, PBRMaterial>;
|
|
24
|
+
/** Finds an active, non-editor mesh by name or ID */
|
|
25
|
+
findMeshByNameOrId(identifier: string): Mesh | undefined;
|
|
26
|
+
/** Gets an existing material or creates a new PBRMaterial */
|
|
27
|
+
getOrCreateMaterial(materialName?: string, colorHex?: string, roughness?: number, metallic?: number, fallbackName?: string): PBRMaterial;
|
|
28
|
+
/** Applies position, rotation (Euler or degrees), and scaling from arguments */
|
|
29
|
+
applyTransformArgs(mesh: Mesh, args: any): void;
|
|
30
|
+
/** Registers a newly created mesh with selection and tracking */
|
|
31
|
+
registerCreatedMesh(mesh: Mesh): void;
|
|
32
|
+
/** Normalizes hex color string to #RRGGBB */
|
|
33
|
+
normalizeHex(hex: string): string;
|
|
34
|
+
/** Parses a 3D vector from an array or object */
|
|
35
|
+
parseVec3(v: any, defaultVal?: number): Vector3;
|
|
36
|
+
/** Parses a 2D or 3D point into a Vector3 for polygon builder */
|
|
37
|
+
parsePolygonPoint(p: any): Vector3;
|
|
38
|
+
/** Builds a JSON-serializable summary of the active scene */
|
|
39
|
+
buildSceneSummary(): Record<string, any>;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ToolExecutionContext } from './ToolExecutionContext';
|
|
2
|
+
/**
|
|
3
|
+
* OpenAI-compatible function calling definition structure.
|
|
4
|
+
*/
|
|
5
|
+
export interface OpenAIToolDefinition {
|
|
6
|
+
type: 'function';
|
|
7
|
+
function: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Common tool interface for modular, self-contained 3D editor & AI agent tools.
|
|
15
|
+
* Enables rapid implementation and registration of new tools, UI panels, and AI actions.
|
|
16
|
+
*/
|
|
17
|
+
export interface ToolInterface {
|
|
18
|
+
/** Unique identifier for the tool (e.g. 'modeler_create_primitive' or 'tool_voxel_painter') */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Human- and LLM-readable summary description of what this tool does */
|
|
21
|
+
readonly description: string;
|
|
22
|
+
/**
|
|
23
|
+
* Comprehensive user-facing guide and help text explaining the tool's purpose,
|
|
24
|
+
* features, keyboard/mouse controls, and workflow tips. Rendered in the tool help popup.
|
|
25
|
+
*/
|
|
26
|
+
readonly helpText?: string;
|
|
27
|
+
/** Lucide icon identifier (e.g. 'brush', 'route', 'bot', 'box', 'palette', 'help-circle') */
|
|
28
|
+
readonly icon?: string;
|
|
29
|
+
/** DOM element ID of the tool's floating dialog window (e.g. 'dialog-voxel-painter') */
|
|
30
|
+
readonly dialogId?: string;
|
|
31
|
+
/** DOM element ID of the primary trigger button in menus (e.g. 'btnToggleVoxelPainter') */
|
|
32
|
+
readonly triggerButtonId?: string;
|
|
33
|
+
/** Menu identifier where this tool should appear (e.g. 'menuTools' or 'tools') */
|
|
34
|
+
readonly menuId?: string;
|
|
35
|
+
/** Human-readable menu item and panel title label (e.g. 'Voxel Painter') */
|
|
36
|
+
readonly menuLabel?: string;
|
|
37
|
+
/**
|
|
38
|
+
* HTML/EJS view template markup for this tool's floating dialog or panel.
|
|
39
|
+
*/
|
|
40
|
+
readonly viewTemplate?: string;
|
|
41
|
+
/**
|
|
42
|
+
* If true, this tool takes exclusive control of 3D scene pointer clicks (e.g. voxel painting or path curve editing).
|
|
43
|
+
* Multiple exclusive tool dialogs can remain open simultaneously, but only the active tool edits 3D viewport state.
|
|
44
|
+
* Activating one exclusive tool automatically deactivates 3D editing on other exclusive tools without closing their dialogs.
|
|
45
|
+
*/
|
|
46
|
+
readonly isExclusive3DTool?: boolean;
|
|
47
|
+
/** Whether this tool dialog should be open and expanded by default on initial profile load */
|
|
48
|
+
readonly defaultOpen?: boolean;
|
|
49
|
+
/** JSON Schema describing the input parameters for AI function calling */
|
|
50
|
+
readonly parameters?: Record<string, any>;
|
|
51
|
+
/** Optional sorting order priority in dropdown menus and stackpanel sidebar */
|
|
52
|
+
order?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the HTML/EJS view template markup for this tool.
|
|
55
|
+
*/
|
|
56
|
+
getViewTemplate?(): string;
|
|
57
|
+
/**
|
|
58
|
+
* Mounts or retrieves the tool's dialog DOM element.
|
|
59
|
+
* If the dialog element is not already present in the DOM, mounts it from `viewTemplate`.
|
|
60
|
+
*/
|
|
61
|
+
renderView?(container?: HTMLElement): HTMLElement | null;
|
|
62
|
+
/** Formats the tool specification for OpenAI-compatible function calling */
|
|
63
|
+
getDefinition?(): OpenAIToolDefinition;
|
|
64
|
+
/**
|
|
65
|
+
* Executes the tool logic against the live scene and editor context.
|
|
66
|
+
*
|
|
67
|
+
* @param args Parsed input arguments matching `parameters` schema
|
|
68
|
+
* @param context Scene, service, and utility context
|
|
69
|
+
* @returns String result (usually JSON) sent back to the LLM or caller
|
|
70
|
+
*/
|
|
71
|
+
execute?(args: any, context: ToolExecutionContext): Promise<string> | string;
|
|
72
|
+
/**
|
|
73
|
+
* Dynamic check returning whether this tool is currently active in the editor.
|
|
74
|
+
*/
|
|
75
|
+
isActive?(app?: any): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Lifecycle hook invoked when an interactive 3D tool becomes active for 3D state editing.
|
|
78
|
+
*/
|
|
79
|
+
onActivate?(app: any): void;
|
|
80
|
+
/**
|
|
81
|
+
* Lifecycle hook invoked when an interactive 3D tool is deactivated from 3D state editing (without closing its dialog).
|
|
82
|
+
*/
|
|
83
|
+
onDeactivate?(app: any): void;
|
|
84
|
+
/**
|
|
85
|
+
* Lifecycle hook invoked when the tool dialog/panel is opened or displayed.
|
|
86
|
+
*/
|
|
87
|
+
onOpen?(app: any): void;
|
|
88
|
+
/**
|
|
89
|
+
* Lifecycle hook invoked when the tool dialog/panel is closed or deactivated.
|
|
90
|
+
*/
|
|
91
|
+
onClose?(app: any): void;
|
|
92
|
+
/**
|
|
93
|
+
* Lifecycle hook invoked when the tool dialog is collapsed / minimized.
|
|
94
|
+
*/
|
|
95
|
+
onMinimize?(app: any): void;
|
|
96
|
+
/**
|
|
97
|
+
* Lifecycle hook invoked when the tool dialog is expanded / maximized.
|
|
98
|
+
*/
|
|
99
|
+
onMaximize?(app: any): void;
|
|
100
|
+
/**
|
|
101
|
+
* Lifecycle hook invoked when the editor UI needs to re-synchronize state.
|
|
102
|
+
*/
|
|
103
|
+
onUpdateUI?(app: any): void;
|
|
104
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ToolExecutionContext } from './ToolExecutionContext';
|
|
2
|
+
import { OpenAIToolDefinition, ToolInterface } from './ToolInterface';
|
|
3
|
+
/**
|
|
4
|
+
* Registry managing available modeling & AI tools.
|
|
5
|
+
* Handles tool lookup, OpenAI schema aggregation, and safe execution dispatch.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ToolRegistry {
|
|
8
|
+
private tools;
|
|
9
|
+
constructor(initialTools?: ToolInterface[]);
|
|
10
|
+
/**
|
|
11
|
+
* Registers a tool instance into the registry.
|
|
12
|
+
* If a tool with the same name exists, it will be overwritten.
|
|
13
|
+
*/
|
|
14
|
+
register(tool: ToolInterface): void;
|
|
15
|
+
/**
|
|
16
|
+
* Unregisters a tool by name.
|
|
17
|
+
*/
|
|
18
|
+
unregister(toolName: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves a tool by its unique name.
|
|
21
|
+
*/
|
|
22
|
+
get(toolName: string): ToolInterface | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Checks whether a tool is registered.
|
|
25
|
+
*/
|
|
26
|
+
has(toolName: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Returns all currently registered tools.
|
|
29
|
+
*/
|
|
30
|
+
getAll(): ToolInterface[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns an array of OpenAI function tool specifications for all registered tools.
|
|
33
|
+
*/
|
|
34
|
+
getOpenAITools(): OpenAIToolDefinition[];
|
|
35
|
+
/**
|
|
36
|
+
* Executes a registered tool by name with arguments and context.
|
|
37
|
+
*/
|
|
38
|
+
execute(toolName: string, rawArgs: any, context: ToolExecutionContext): Promise<string>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Factory helper creating a new ToolRegistry populated with all 37 built-in Babylon.js modeling tools.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createDefaultToolRegistry(): ToolRegistry;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ApplyMaterialTool, AutoUVMappingTool, BooleanOperationTool, BuildVoxelMeshTool, CloneArrayTool, CreateLatheTool, CreateMaterialTool, CreatePrimitiveTool, CreateTubeTool, DeleteMeshTool, ExecuteBabylonCodeTool, ExtrudePolygonTool, ExtrudeShapeTool, GetSceneInfoTool, MergeMeshesTool, SeparateMeshTool, TransformMeshTool, VoxelPainterTool, SolidifyMeshTool, SubdivideMeshTool, SubDSmoothTool, FacetExtrudeTool, FacetInsetTool, FacetArcTool, FacetCutThroughTool, SpawnBaseMeshTool, RetopologizeMeshTool, SculptMeshTool, CreateSdfMeshTool, CreateRoundedBoxTool, CreateWallTool, CreateArchTool, CreateColumnTool, CreateMoldingTool, CreateStairsTool, CreateRoofTool, PlanModelTool, GenerateNeuralMeshTool, UVUnwrapTool, BakeTexturesTool, RigWeightTool, GenerateTextureTool, CreateTextMeshTool, DecalTool, } from './builtin';
|
|
2
|
+
/**
|
|
3
|
+
* Registry managing available modeling & AI tools.
|
|
4
|
+
* Handles tool lookup, OpenAI schema aggregation, and safe execution dispatch.
|
|
5
|
+
*/
|
|
6
|
+
export class ToolRegistry {
|
|
7
|
+
tools = new Map();
|
|
8
|
+
constructor(initialTools = []) {
|
|
9
|
+
for (const tool of initialTools) {
|
|
10
|
+
this.register(tool);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Registers a tool instance into the registry.
|
|
15
|
+
* If a tool with the same name exists, it will be overwritten.
|
|
16
|
+
*/
|
|
17
|
+
register(tool) {
|
|
18
|
+
if (!tool || !tool.name) {
|
|
19
|
+
throw new Error('Invalid tool provided: must have a valid "name".');
|
|
20
|
+
}
|
|
21
|
+
this.tools.set(tool.name, tool);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Unregisters a tool by name.
|
|
25
|
+
*/
|
|
26
|
+
unregister(toolName) {
|
|
27
|
+
return this.tools.delete(toolName);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves a tool by its unique name.
|
|
31
|
+
*/
|
|
32
|
+
get(toolName) {
|
|
33
|
+
return this.tools.get(toolName);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Checks whether a tool is registered.
|
|
37
|
+
*/
|
|
38
|
+
has(toolName) {
|
|
39
|
+
return this.tools.has(toolName);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns all currently registered tools.
|
|
43
|
+
*/
|
|
44
|
+
getAll() {
|
|
45
|
+
return Array.from(this.tools.values());
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns an array of OpenAI function tool specifications for all registered tools.
|
|
49
|
+
*/
|
|
50
|
+
getOpenAITools() {
|
|
51
|
+
return Array.from(this.tools.values()).map((tool) => tool.getDefinition());
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Executes a registered tool by name with arguments and context.
|
|
55
|
+
*/
|
|
56
|
+
async execute(toolName, rawArgs, context) {
|
|
57
|
+
const tool = this.tools.get(toolName);
|
|
58
|
+
if (!tool) {
|
|
59
|
+
throw new Error(`Unknown tool: ${toolName}`);
|
|
60
|
+
}
|
|
61
|
+
const args = typeof rawArgs === 'string' ? JSON.parse(rawArgs || '{}') : rawArgs || {};
|
|
62
|
+
return await tool.execute(args, context);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Factory helper creating a new ToolRegistry populated with all 37 built-in Babylon.js modeling tools.
|
|
67
|
+
*/
|
|
68
|
+
export function createDefaultToolRegistry() {
|
|
69
|
+
return new ToolRegistry([
|
|
70
|
+
new GetSceneInfoTool(),
|
|
71
|
+
new PlanModelTool(),
|
|
72
|
+
new CreatePrimitiveTool(),
|
|
73
|
+
new CreateRoundedBoxTool(),
|
|
74
|
+
new CreateSdfMeshTool(),
|
|
75
|
+
new ExtrudePolygonTool(),
|
|
76
|
+
new ExtrudeShapeTool(),
|
|
77
|
+
new CreateLatheTool(),
|
|
78
|
+
new CreateTubeTool(),
|
|
79
|
+
new BooleanOperationTool(),
|
|
80
|
+
new CreateWallTool(),
|
|
81
|
+
new CreateArchTool(),
|
|
82
|
+
new CreateColumnTool(),
|
|
83
|
+
new CreateMoldingTool(),
|
|
84
|
+
new CreateStairsTool(),
|
|
85
|
+
new CreateRoofTool(),
|
|
86
|
+
new CreateMaterialTool(),
|
|
87
|
+
new ApplyMaterialTool(),
|
|
88
|
+
new AutoUVMappingTool(),
|
|
89
|
+
new TransformMeshTool(),
|
|
90
|
+
new CloneArrayTool(),
|
|
91
|
+
new MergeMeshesTool(),
|
|
92
|
+
new SeparateMeshTool(),
|
|
93
|
+
new DeleteMeshTool(),
|
|
94
|
+
new BuildVoxelMeshTool(),
|
|
95
|
+
new ExecuteBabylonCodeTool(),
|
|
96
|
+
new VoxelPainterTool(),
|
|
97
|
+
new SolidifyMeshTool(),
|
|
98
|
+
new SubdivideMeshTool(),
|
|
99
|
+
new SubDSmoothTool(),
|
|
100
|
+
new FacetExtrudeTool(),
|
|
101
|
+
new FacetInsetTool(),
|
|
102
|
+
new FacetArcTool(),
|
|
103
|
+
new FacetCutThroughTool(),
|
|
104
|
+
new SpawnBaseMeshTool(),
|
|
105
|
+
new RetopologizeMeshTool(),
|
|
106
|
+
new SculptMeshTool(),
|
|
107
|
+
new GenerateNeuralMeshTool(),
|
|
108
|
+
new UVUnwrapTool(),
|
|
109
|
+
new BakeTexturesTool(),
|
|
110
|
+
new RigWeightTool(),
|
|
111
|
+
new GenerateTextureTool(),
|
|
112
|
+
new CreateTextMeshTool(),
|
|
113
|
+
new DecalTool(),
|
|
114
|
+
]);
|
|
115
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class ApplyMaterialTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_apply_material";
|
|
5
|
+
readonly description = "Applies a created material (or inline color/PBR settings) to one or more meshes by name.";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
meshName: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
materialName: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
albedoColor: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
roughness: {
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
metallic: {
|
|
25
|
+
type: string;
|
|
26
|
+
};
|
|
27
|
+
alpha: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
required: string[];
|
|
32
|
+
};
|
|
33
|
+
execute(args: any, context: ToolExecutionContext): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
export class ApplyMaterialTool extends AbstractTool {
|
|
3
|
+
name = 'modeler_apply_material';
|
|
4
|
+
description = 'Applies a created material (or inline color/PBR settings) to one or more meshes by name.';
|
|
5
|
+
parameters = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
meshName: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Target mesh name (or comma-separated names, or "*" for all meshes).',
|
|
11
|
+
},
|
|
12
|
+
materialName: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
description: 'Name of the material created with modeler_create_material.',
|
|
15
|
+
},
|
|
16
|
+
albedoColor: { type: 'string', description: 'Optional direct hex color if creating inline material.' },
|
|
17
|
+
roughness: { type: 'number' },
|
|
18
|
+
metallic: { type: 'number' },
|
|
19
|
+
alpha: { type: 'number' },
|
|
20
|
+
},
|
|
21
|
+
required: ['meshName'],
|
|
22
|
+
};
|
|
23
|
+
execute(args, context) {
|
|
24
|
+
const meshTarget = String(args.meshName || args.meshId || '');
|
|
25
|
+
const matName = args.materialName || args.materialId;
|
|
26
|
+
const targetMeshes = meshTarget === '*'
|
|
27
|
+
? context.service.importedMeshes.filter((m) => !context.service.isEditorHelper(m) && !m.isDisposed())
|
|
28
|
+
: meshTarget
|
|
29
|
+
.split(',')
|
|
30
|
+
.map((n) => context.findMeshByNameOrId(n.trim()))
|
|
31
|
+
.filter((m) => !!m);
|
|
32
|
+
if (targetMeshes.length === 0) {
|
|
33
|
+
throw new Error(`No mesh matching "${meshTarget}" found.`);
|
|
34
|
+
}
|
|
35
|
+
const mat = context.getOrCreateMaterial(matName, args.albedoColor, args.roughness, args.metallic, targetMeshes[0].name);
|
|
36
|
+
if (args.alpha !== undefined) {
|
|
37
|
+
mat.alpha = Number(args.alpha);
|
|
38
|
+
}
|
|
39
|
+
for (const m of targetMeshes) {
|
|
40
|
+
m.material = mat;
|
|
41
|
+
}
|
|
42
|
+
return JSON.stringify({
|
|
43
|
+
status: 'ok',
|
|
44
|
+
appliedTo: targetMeshes.map((m) => m.name),
|
|
45
|
+
materialName: mat.name,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class AutoUVMappingTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_auto_uv_mapping";
|
|
5
|
+
readonly description = "Applies automatic box/triplanar UV mapping (or planar projection) to a mesh so textures tile cleanly after CSG or extrusions without breaking subMeshes.";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
meshName: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
projection: {
|
|
14
|
+
type: string;
|
|
15
|
+
enum: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
scale: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
uScale: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
vScale: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
required: string[];
|
|
32
|
+
};
|
|
33
|
+
execute(args: any, context: ToolExecutionContext): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
export class AutoUVMappingTool extends AbstractTool {
|
|
3
|
+
name = 'modeler_auto_uv_mapping';
|
|
4
|
+
description = 'Applies automatic box/triplanar UV mapping (or planar projection) to a mesh so textures tile cleanly after CSG or extrusions without breaking subMeshes.';
|
|
5
|
+
parameters = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
meshName: { type: 'string', description: 'Name of the mesh (or "*" for all meshes).' },
|
|
9
|
+
projection: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
enum: ['triplanar', 'top', 'front', 'side', 'cylindrical'],
|
|
12
|
+
description: 'Projection mode (default "triplanar").',
|
|
13
|
+
},
|
|
14
|
+
scale: { type: 'number', description: 'Uniform UV tiling scale factor (default 1.0).' },
|
|
15
|
+
uScale: { type: 'number', description: 'Horizontal UV scale factor (defaults to scale or 1.0).' },
|
|
16
|
+
vScale: { type: 'number', description: 'Vertical UV scale factor (defaults to scale or 1.0).' },
|
|
17
|
+
},
|
|
18
|
+
required: ['meshName'],
|
|
19
|
+
};
|
|
20
|
+
execute(args, context) {
|
|
21
|
+
const meshTarget = String(args.meshName || args.meshId || '*');
|
|
22
|
+
const projection = args.projection || 'triplanar';
|
|
23
|
+
const scale = args.scale !== undefined ? Number(args.scale) : 1.0;
|
|
24
|
+
const uScale = args.uScale !== undefined ? Number(args.uScale) : scale;
|
|
25
|
+
const vScale = args.vScale !== undefined ? Number(args.vScale) : scale;
|
|
26
|
+
const targets = meshTarget === '*'
|
|
27
|
+
? context.service.importedMeshes.filter((m) => !context.service.isEditorHelper(m) && !m.isDisposed())
|
|
28
|
+
: [context.findMeshByNameOrId(meshTarget)].filter((m) => !!m);
|
|
29
|
+
if (targets.length === 0) {
|
|
30
|
+
throw new Error(`Mesh "${meshTarget}" not found for UV mapping.`);
|
|
31
|
+
}
|
|
32
|
+
const prevSelected = context.service.selectedMesh;
|
|
33
|
+
for (const m of targets) {
|
|
34
|
+
context.service.selectedMesh = m;
|
|
35
|
+
if (projection === 'top' || projection === 'front' || projection === 'side') {
|
|
36
|
+
context.service.applyPlanarUVs(projection, uScale, vScale);
|
|
37
|
+
}
|
|
38
|
+
else if (projection === 'cylindrical') {
|
|
39
|
+
context.service.applyCylindricalUVs(uScale, vScale);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
context.service.applyTriplanarUVs(uScale, vScale);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
context.service.selectedMesh = prevSelected;
|
|
46
|
+
return JSON.stringify({
|
|
47
|
+
status: 'ok',
|
|
48
|
+
mappedMeshes: targets.map((m) => m.name),
|
|
49
|
+
projection,
|
|
50
|
+
uScale,
|
|
51
|
+
vScale,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|