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,162 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
/**
|
|
4
|
+
* Computes size-adaptive and budget-aware segment/tessellation counts when not explicitly provided.
|
|
5
|
+
* Prevents tiny tertiary details (such as eyeballs, buttons, or bolts) from consuming more polygons
|
|
6
|
+
* than primary structural volumes (such as a torso or hull).
|
|
7
|
+
*/
|
|
8
|
+
export declare function computeAdaptiveTessellation(shapeType: string, maxWorldDimension: number, maxPolygonBudget?: number, detailTier?: string): number;
|
|
9
|
+
export declare class CreatePrimitiveTool extends AbstractTool {
|
|
10
|
+
readonly name = "modeler_create_primitive";
|
|
11
|
+
readonly description = "Creates a 3D primitive mesh (box, sphere, cylinder, cone, capsule, torus, torusKnot, plane, disc, ground, polyhedron) in the live Babylon.js scene. Automatically adapts segment density to part size and polygon budget so tiny details (like eyes or bolts) stay lightweight while primary volumes stay smooth. Supports optional bevelRadius on boxes.";
|
|
12
|
+
readonly parameters: {
|
|
13
|
+
type: string;
|
|
14
|
+
properties: {
|
|
15
|
+
name: {
|
|
16
|
+
type: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
type: {
|
|
20
|
+
type: string;
|
|
21
|
+
enum: string[];
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
detailTier: {
|
|
25
|
+
type: string;
|
|
26
|
+
enum: string[];
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
bevelRadius: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
options: {
|
|
34
|
+
type: string;
|
|
35
|
+
description: string;
|
|
36
|
+
properties: {
|
|
37
|
+
width: {
|
|
38
|
+
type: string;
|
|
39
|
+
};
|
|
40
|
+
height: {
|
|
41
|
+
type: string;
|
|
42
|
+
};
|
|
43
|
+
depth: {
|
|
44
|
+
type: string;
|
|
45
|
+
};
|
|
46
|
+
size: {
|
|
47
|
+
type: string;
|
|
48
|
+
};
|
|
49
|
+
diameter: {
|
|
50
|
+
type: string;
|
|
51
|
+
};
|
|
52
|
+
diameterTop: {
|
|
53
|
+
type: string;
|
|
54
|
+
};
|
|
55
|
+
diameterBottom: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
thickness: {
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
tessellation: {
|
|
62
|
+
type: string;
|
|
63
|
+
};
|
|
64
|
+
segments: {
|
|
65
|
+
type: string;
|
|
66
|
+
};
|
|
67
|
+
subdivisions: {
|
|
68
|
+
type: string;
|
|
69
|
+
};
|
|
70
|
+
polyType: {
|
|
71
|
+
type: string;
|
|
72
|
+
};
|
|
73
|
+
arc: {
|
|
74
|
+
type: string;
|
|
75
|
+
};
|
|
76
|
+
slice: {
|
|
77
|
+
type: string;
|
|
78
|
+
};
|
|
79
|
+
bevelRadius: {
|
|
80
|
+
type: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
position: {
|
|
85
|
+
type: string;
|
|
86
|
+
properties: {
|
|
87
|
+
x: {
|
|
88
|
+
type: string;
|
|
89
|
+
};
|
|
90
|
+
y: {
|
|
91
|
+
type: string;
|
|
92
|
+
};
|
|
93
|
+
z: {
|
|
94
|
+
type: string;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
rotationDegrees: {
|
|
99
|
+
type: string;
|
|
100
|
+
description: string;
|
|
101
|
+
properties: {
|
|
102
|
+
x: {
|
|
103
|
+
type: string;
|
|
104
|
+
};
|
|
105
|
+
y: {
|
|
106
|
+
type: string;
|
|
107
|
+
};
|
|
108
|
+
z: {
|
|
109
|
+
type: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
rotation: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
properties: {
|
|
117
|
+
x: {
|
|
118
|
+
type: string;
|
|
119
|
+
};
|
|
120
|
+
y: {
|
|
121
|
+
type: string;
|
|
122
|
+
};
|
|
123
|
+
z: {
|
|
124
|
+
type: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
scaling: {
|
|
129
|
+
type: string;
|
|
130
|
+
properties: {
|
|
131
|
+
x: {
|
|
132
|
+
type: string;
|
|
133
|
+
};
|
|
134
|
+
y: {
|
|
135
|
+
type: string;
|
|
136
|
+
};
|
|
137
|
+
z: {
|
|
138
|
+
type: string;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
color: {
|
|
143
|
+
type: string;
|
|
144
|
+
description: string;
|
|
145
|
+
};
|
|
146
|
+
roughness: {
|
|
147
|
+
type: string;
|
|
148
|
+
description: string;
|
|
149
|
+
};
|
|
150
|
+
metallic: {
|
|
151
|
+
type: string;
|
|
152
|
+
description: string;
|
|
153
|
+
};
|
|
154
|
+
materialName: {
|
|
155
|
+
type: string;
|
|
156
|
+
description: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
required: string[];
|
|
160
|
+
};
|
|
161
|
+
execute(args: any, context: ToolExecutionContext): string;
|
|
162
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { MeshBuilder } from '@babylonjs/core';
|
|
2
|
+
import { createRoundedBoxMesh } from '../../geometry/roundedBox';
|
|
3
|
+
import { AbstractTool } from '../AbstractTool';
|
|
4
|
+
/**
|
|
5
|
+
* Computes size-adaptive and budget-aware segment/tessellation counts when not explicitly provided.
|
|
6
|
+
* Prevents tiny tertiary details (such as eyeballs, buttons, or bolts) from consuming more polygons
|
|
7
|
+
* than primary structural volumes (such as a torso or hull).
|
|
8
|
+
*/
|
|
9
|
+
export function computeAdaptiveTessellation(shapeType, maxWorldDimension, maxPolygonBudget = 5000, detailTier) {
|
|
10
|
+
const tier = (detailTier || '').toLowerCase();
|
|
11
|
+
const budgetScale = maxPolygonBudget >= 20000 ? 1.35 : maxPolygonBudget <= 1500 ? 0.75 : 1.0;
|
|
12
|
+
if (shapeType === 'sphere') {
|
|
13
|
+
let baseSegs;
|
|
14
|
+
if (tier === 'tertiary' || maxWorldDimension <= 0.08) {
|
|
15
|
+
baseSegs = 4; // 144 triangles for tiny eyeballs, rivets, beads
|
|
16
|
+
}
|
|
17
|
+
else if (maxWorldDimension <= 0.18) {
|
|
18
|
+
baseSegs = 6; // 256 triangles for small spheres/joints
|
|
19
|
+
}
|
|
20
|
+
else if (tier === 'secondary' || maxWorldDimension <= 0.45) {
|
|
21
|
+
baseSegs = 12; // 784 triangles for medium volumes (heads, shoulders)
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
baseSegs = 16; // 1,296 triangles for large primary volumes
|
|
25
|
+
}
|
|
26
|
+
return Math.max(4, Math.min(32, Math.round(baseSegs * budgetScale)));
|
|
27
|
+
}
|
|
28
|
+
if (shapeType === 'torus' || shapeType === 'disc') {
|
|
29
|
+
let baseTess;
|
|
30
|
+
if (tier === 'tertiary' || maxWorldDimension <= 0.12) {
|
|
31
|
+
baseTess = 12;
|
|
32
|
+
}
|
|
33
|
+
else if (tier === 'secondary' || maxWorldDimension <= 0.45) {
|
|
34
|
+
baseTess = 18;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
baseTess = 24;
|
|
38
|
+
}
|
|
39
|
+
return Math.max(8, Math.min(48, Math.round(baseTess * budgetScale)));
|
|
40
|
+
}
|
|
41
|
+
// cylinder, cone, capsule
|
|
42
|
+
let baseTess;
|
|
43
|
+
if (tier === 'tertiary' || maxWorldDimension <= 0.1) {
|
|
44
|
+
baseTess = 8;
|
|
45
|
+
}
|
|
46
|
+
else if (maxWorldDimension <= 0.25) {
|
|
47
|
+
baseTess = 12;
|
|
48
|
+
}
|
|
49
|
+
else if (tier === 'secondary' || maxWorldDimension <= 0.6) {
|
|
50
|
+
baseTess = 16;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
baseTess = 20;
|
|
54
|
+
}
|
|
55
|
+
return Math.max(6, Math.min(36, Math.round(baseTess * budgetScale)));
|
|
56
|
+
}
|
|
57
|
+
export class CreatePrimitiveTool extends AbstractTool {
|
|
58
|
+
name = 'modeler_create_primitive';
|
|
59
|
+
description = 'Creates a 3D primitive mesh (box, sphere, cylinder, cone, capsule, torus, torusKnot, plane, disc, ground, polyhedron) in the live Babylon.js scene. Automatically adapts segment density to part size and polygon budget so tiny details (like eyes or bolts) stay lightweight while primary volumes stay smooth. Supports optional bevelRadius on boxes.';
|
|
60
|
+
parameters = {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
name: { type: 'string', description: 'Descriptive name for the mesh.' },
|
|
64
|
+
type: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
enum: [
|
|
67
|
+
'box',
|
|
68
|
+
'sphere',
|
|
69
|
+
'cylinder',
|
|
70
|
+
'cone',
|
|
71
|
+
'capsule',
|
|
72
|
+
'torus',
|
|
73
|
+
'torusKnot',
|
|
74
|
+
'plane',
|
|
75
|
+
'disc',
|
|
76
|
+
'ground',
|
|
77
|
+
'polyhedron',
|
|
78
|
+
],
|
|
79
|
+
description: 'Primitive geometry type.',
|
|
80
|
+
},
|
|
81
|
+
detailTier: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
enum: ['primary', 'secondary', 'tertiary'],
|
|
84
|
+
description: 'Optional hierarchy tier: "primary" (torso, main body, building shell), "secondary" (limbs, medium parts), or "tertiary" (eyes, buttons, rivets, small trim). Controls automatic segment allocation.',
|
|
85
|
+
},
|
|
86
|
+
bevelRadius: {
|
|
87
|
+
type: 'number',
|
|
88
|
+
description: 'Optional edge bevel/rounding radius in meters for type="box" (e.g. 0.03) so edges catch specular highlights instead of looking razor-sharp.',
|
|
89
|
+
},
|
|
90
|
+
options: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
description: 'Babylon.js MeshBuilder options: width, height, depth, size, diameter, diameterTop, diameterBottom, thickness, tessellation, segments, subdivisions, polyType (0-4), arc, slice, bevelRadius.',
|
|
93
|
+
properties: {
|
|
94
|
+
width: { type: 'number' },
|
|
95
|
+
height: { type: 'number' },
|
|
96
|
+
depth: { type: 'number' },
|
|
97
|
+
size: { type: 'number' },
|
|
98
|
+
diameter: { type: 'number' },
|
|
99
|
+
diameterTop: { type: 'number' },
|
|
100
|
+
diameterBottom: { type: 'number' },
|
|
101
|
+
thickness: { type: 'number' },
|
|
102
|
+
tessellation: { type: 'number' },
|
|
103
|
+
segments: { type: 'number' },
|
|
104
|
+
subdivisions: { type: 'number' },
|
|
105
|
+
polyType: { type: 'number' },
|
|
106
|
+
arc: { type: 'number' },
|
|
107
|
+
slice: { type: 'number' },
|
|
108
|
+
bevelRadius: { type: 'number' },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
position: {
|
|
112
|
+
type: 'object',
|
|
113
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
114
|
+
},
|
|
115
|
+
rotationDegrees: {
|
|
116
|
+
type: 'object',
|
|
117
|
+
description: 'Rotation in degrees { x, y, z }.',
|
|
118
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
119
|
+
},
|
|
120
|
+
rotation: {
|
|
121
|
+
type: 'object',
|
|
122
|
+
description: 'Optional rotation in radians { x, y, z } if rotationDegrees is not used.',
|
|
123
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
124
|
+
},
|
|
125
|
+
scaling: {
|
|
126
|
+
type: 'object',
|
|
127
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
128
|
+
},
|
|
129
|
+
color: { type: 'string', description: 'Hex color string, e.g. "#4f8cf6".' },
|
|
130
|
+
roughness: { type: 'number', description: 'PBR roughness (0.0 to 1.0).' },
|
|
131
|
+
metallic: { type: 'number', description: 'PBR metallic (0.0 to 1.0).' },
|
|
132
|
+
materialName: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'Optional name of an existing material created via modeler_create_material.',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
required: ['type'],
|
|
138
|
+
};
|
|
139
|
+
execute(args, context) {
|
|
140
|
+
const type = String(args.type || args.shape || 'box').toLowerCase();
|
|
141
|
+
const opts = { ...args, ...(args.options || {}) };
|
|
142
|
+
const baseName = (args.name || type).replace(/\s+/g, '_');
|
|
143
|
+
const uniqueName = context.findMeshByNameOrId(baseName)
|
|
144
|
+
? `${baseName}_${Date.now().toString().slice(-4)}`
|
|
145
|
+
: baseName;
|
|
146
|
+
// Determine effective world scale to drive size-adaptive tessellation
|
|
147
|
+
const sc = args.scaling
|
|
148
|
+
? Array.isArray(args.scaling)
|
|
149
|
+
? [Number(args.scaling[0] ?? 1) || 1, Number(args.scaling[1] ?? 1) || 1, Number(args.scaling[2] ?? 1) || 1]
|
|
150
|
+
: [Number(args.scaling.x ?? 1) || 1, Number(args.scaling.y ?? 1) || 1, Number(args.scaling.z ?? 1) || 1]
|
|
151
|
+
: [1, 1, 1];
|
|
152
|
+
const maxScale = Math.max(Math.abs(sc[0]), Math.abs(sc[1]), Math.abs(sc[2]));
|
|
153
|
+
const budget = context.aiAgent?.config?.maxPolygons ?? 5000;
|
|
154
|
+
const detailTier = opts.detailTier;
|
|
155
|
+
let mesh;
|
|
156
|
+
switch (type) {
|
|
157
|
+
case 'sphere': {
|
|
158
|
+
const diam = opts.diameter ?? opts.size ?? 1;
|
|
159
|
+
const dx = opts.width ?? diam;
|
|
160
|
+
const dy = opts.height ?? diam;
|
|
161
|
+
const dz = opts.depth ?? diam;
|
|
162
|
+
const maxWorldDim = Math.max(dx * Math.abs(sc[0]), dy * Math.abs(sc[1]), dz * Math.abs(sc[2]));
|
|
163
|
+
const adaptiveSegs = computeAdaptiveTessellation('sphere', maxWorldDim, budget, detailTier);
|
|
164
|
+
mesh = MeshBuilder.CreateSphere(uniqueName, {
|
|
165
|
+
diameter: diam,
|
|
166
|
+
diameterX: opts.width,
|
|
167
|
+
diameterY: opts.height,
|
|
168
|
+
diameterZ: opts.depth,
|
|
169
|
+
segments: opts.segments ?? opts.tessellation ?? adaptiveSegs,
|
|
170
|
+
arc: opts.arc,
|
|
171
|
+
slice: opts.slice,
|
|
172
|
+
}, context.scene);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case 'cylinder': {
|
|
176
|
+
const diam = opts.diameter ?? opts.size ?? 1;
|
|
177
|
+
const dTop = opts.diameterTop ?? diam;
|
|
178
|
+
const dBot = opts.diameterBottom ?? diam;
|
|
179
|
+
const maxRadiusDim = Math.max(dTop, dBot) * maxScale;
|
|
180
|
+
const adaptiveTess = computeAdaptiveTessellation('cylinder', maxRadiusDim, budget, detailTier);
|
|
181
|
+
mesh = MeshBuilder.CreateCylinder(uniqueName, {
|
|
182
|
+
height: opts.height ?? 2,
|
|
183
|
+
diameter: diam,
|
|
184
|
+
diameterTop: opts.diameterTop,
|
|
185
|
+
diameterBottom: opts.diameterBottom,
|
|
186
|
+
tessellation: opts.tessellation ?? opts.segments ?? adaptiveTess,
|
|
187
|
+
arc: opts.arc,
|
|
188
|
+
}, context.scene);
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case 'cone': {
|
|
192
|
+
const dBot = opts.diameterBottom ?? opts.diameter ?? opts.size ?? 1;
|
|
193
|
+
const adaptiveTess = computeAdaptiveTessellation('cone', dBot * maxScale, budget, detailTier);
|
|
194
|
+
mesh = MeshBuilder.CreateCylinder(uniqueName, {
|
|
195
|
+
height: opts.height ?? 2,
|
|
196
|
+
diameterTop: opts.diameterTop ?? 0,
|
|
197
|
+
diameterBottom: dBot,
|
|
198
|
+
tessellation: opts.tessellation ?? opts.segments ?? adaptiveTess,
|
|
199
|
+
}, context.scene);
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
case 'capsule': {
|
|
203
|
+
const diam = opts.diameter ?? opts.size ?? 1;
|
|
204
|
+
const adaptiveTess = computeAdaptiveTessellation('capsule', diam * maxScale, budget, detailTier);
|
|
205
|
+
mesh = MeshBuilder.CreateCapsule(uniqueName, {
|
|
206
|
+
height: opts.height ?? 2,
|
|
207
|
+
radius: diam * 0.5,
|
|
208
|
+
tessellation: opts.tessellation ?? opts.segments ?? adaptiveTess,
|
|
209
|
+
}, context.scene);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
case 'torus': {
|
|
213
|
+
const diam = opts.diameter ?? opts.size ?? 1;
|
|
214
|
+
const adaptiveTess = computeAdaptiveTessellation('torus', diam * maxScale, budget, detailTier);
|
|
215
|
+
mesh = MeshBuilder.CreateTorus(uniqueName, {
|
|
216
|
+
diameter: diam,
|
|
217
|
+
thickness: opts.thickness ?? diam * 0.25,
|
|
218
|
+
tessellation: opts.tessellation ?? opts.segments ?? adaptiveTess,
|
|
219
|
+
}, context.scene);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case 'torusknot':
|
|
223
|
+
mesh = MeshBuilder.CreateTorusKnot(uniqueName, {
|
|
224
|
+
radius: (opts.diameter ?? opts.size ?? 1) * 0.4,
|
|
225
|
+
tube: opts.thickness ?? 0.12,
|
|
226
|
+
radialSegments: opts.tessellation ?? 48,
|
|
227
|
+
}, context.scene);
|
|
228
|
+
break;
|
|
229
|
+
case 'plane':
|
|
230
|
+
mesh = MeshBuilder.CreatePlane(uniqueName, {
|
|
231
|
+
width: opts.width ?? opts.size ?? 1,
|
|
232
|
+
height: opts.height ?? opts.size ?? 1,
|
|
233
|
+
}, context.scene);
|
|
234
|
+
break;
|
|
235
|
+
case 'disc': {
|
|
236
|
+
const diam = opts.diameter ?? opts.size ?? 1;
|
|
237
|
+
const adaptiveTess = computeAdaptiveTessellation('disc', diam * maxScale, budget, detailTier);
|
|
238
|
+
mesh = MeshBuilder.CreateDisc(uniqueName, {
|
|
239
|
+
radius: diam * 0.5,
|
|
240
|
+
tessellation: opts.tessellation ?? opts.segments ?? adaptiveTess,
|
|
241
|
+
}, context.scene);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
case 'ground':
|
|
245
|
+
mesh = MeshBuilder.CreateGround(uniqueName, {
|
|
246
|
+
width: opts.width ?? opts.size ?? 4,
|
|
247
|
+
height: opts.depth ?? opts.height ?? opts.size ?? 4,
|
|
248
|
+
subdivisions: opts.subdivisions ?? 4,
|
|
249
|
+
}, context.scene);
|
|
250
|
+
break;
|
|
251
|
+
case 'polyhedron':
|
|
252
|
+
mesh = MeshBuilder.CreatePolyhedron(uniqueName, {
|
|
253
|
+
type: opts.polyType ?? 1,
|
|
254
|
+
size: (opts.size ?? opts.diameter ?? 1) * 0.5,
|
|
255
|
+
}, context.scene);
|
|
256
|
+
break;
|
|
257
|
+
case 'box':
|
|
258
|
+
default: {
|
|
259
|
+
const bevelRadius = Number(opts.bevelRadius ?? opts.rounding ?? 0);
|
|
260
|
+
if (bevelRadius > 0) {
|
|
261
|
+
mesh = createRoundedBoxMesh(uniqueName, {
|
|
262
|
+
width: opts.width ?? opts.size ?? 1,
|
|
263
|
+
height: opts.height ?? opts.size ?? 1,
|
|
264
|
+
depth: opts.depth ?? opts.size ?? 1,
|
|
265
|
+
radius: bevelRadius,
|
|
266
|
+
segments: opts.segments ?? 2,
|
|
267
|
+
}, context.scene);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
mesh = MeshBuilder.CreateBox(uniqueName, {
|
|
271
|
+
width: opts.width ?? opts.size ?? 1,
|
|
272
|
+
height: opts.height ?? opts.size ?? 1,
|
|
273
|
+
depth: opts.depth ?? opts.size ?? 1,
|
|
274
|
+
}, context.scene);
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
mesh.material = context.getOrCreateMaterial(args.materialName, args.color, args.roughness, args.metallic, uniqueName);
|
|
280
|
+
context.applyTransformArgs(mesh, args);
|
|
281
|
+
context.registerCreatedMesh(mesh);
|
|
282
|
+
const bb = mesh.getBoundingInfo().boundingBox;
|
|
283
|
+
return JSON.stringify({
|
|
284
|
+
status: 'ok',
|
|
285
|
+
meshName: mesh.name,
|
|
286
|
+
vertices: mesh.getTotalVertices(),
|
|
287
|
+
triangles: Math.floor(mesh.getTotalIndices() / 3),
|
|
288
|
+
bounds: {
|
|
289
|
+
min: {
|
|
290
|
+
x: Number(bb.minimumWorld.x.toFixed(3)),
|
|
291
|
+
y: Number(bb.minimumWorld.y.toFixed(3)),
|
|
292
|
+
z: Number(bb.minimumWorld.z.toFixed(3)),
|
|
293
|
+
},
|
|
294
|
+
max: {
|
|
295
|
+
x: Number(bb.maximumWorld.x.toFixed(3)),
|
|
296
|
+
y: Number(bb.maximumWorld.y.toFixed(3)),
|
|
297
|
+
z: Number(bb.maximumWorld.z.toFixed(3)),
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class CreateRoofTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_create_roof";
|
|
5
|
+
readonly description = "Creates a parametric architectural roof (gable, hip, pyramid, shed, or dome) with real fascia slab thickness, eaves overhang, ridge cap beam, and triangular gable end walls. Base sits at local Y = 0, so set position.y to the wall top height.";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
name: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
style: {
|
|
14
|
+
type: string;
|
|
15
|
+
enum: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
width: {
|
|
19
|
+
type: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
depth: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
height: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
pitchDegrees: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
overhang: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
thickness: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
ridgeCap: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
gableWall: {
|
|
47
|
+
type: string;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
position: {
|
|
51
|
+
type: string;
|
|
52
|
+
description: string;
|
|
53
|
+
properties: {
|
|
54
|
+
x: {
|
|
55
|
+
type: string;
|
|
56
|
+
};
|
|
57
|
+
y: {
|
|
58
|
+
type: string;
|
|
59
|
+
};
|
|
60
|
+
z: {
|
|
61
|
+
type: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
rotationDegrees: {
|
|
66
|
+
type: string;
|
|
67
|
+
properties: {
|
|
68
|
+
x: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
71
|
+
y: {
|
|
72
|
+
type: string;
|
|
73
|
+
};
|
|
74
|
+
z: {
|
|
75
|
+
type: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
scaling: {
|
|
80
|
+
type: string;
|
|
81
|
+
properties: {
|
|
82
|
+
x: {
|
|
83
|
+
type: string;
|
|
84
|
+
};
|
|
85
|
+
y: {
|
|
86
|
+
type: string;
|
|
87
|
+
};
|
|
88
|
+
z: {
|
|
89
|
+
type: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
color: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
roughness: {
|
|
98
|
+
type: string;
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
metallic: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
};
|
|
105
|
+
materialName: {
|
|
106
|
+
type: string;
|
|
107
|
+
description: string;
|
|
108
|
+
};
|
|
109
|
+
texturePrompt: {
|
|
110
|
+
type: string;
|
|
111
|
+
description: string;
|
|
112
|
+
};
|
|
113
|
+
uvScale: {
|
|
114
|
+
type: string;
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
execute(args: any, context: ToolExecutionContext): string;
|
|
120
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { buildRoofMesh } from '../../geometry/architecture';
|
|
2
|
+
import { AbstractTool } from '../AbstractTool';
|
|
3
|
+
export class CreateRoofTool extends AbstractTool {
|
|
4
|
+
name = 'modeler_create_roof';
|
|
5
|
+
description = 'Creates a parametric architectural roof (gable, hip, pyramid, shed, or dome) with real fascia slab thickness, eaves overhang, ridge cap beam, and triangular gable end walls. Base sits at local Y = 0, so set position.y to the wall top height.';
|
|
6
|
+
parameters = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
name: { type: 'string', description: 'Descriptive name for the roof mesh.' },
|
|
10
|
+
style: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
enum: ['gable', 'hip', 'pyramid', 'shed', 'dome'],
|
|
13
|
+
description: 'Roof style: "gable" (pitched with triangular gable ends), "hip" (4-sloped), "pyramid", "shed" (single slope), or "dome". Default: "gable".',
|
|
14
|
+
},
|
|
15
|
+
width: { type: 'number', description: 'Building footprint width along X-axis in meters (default: 4.0).' },
|
|
16
|
+
depth: { type: 'number', description: 'Building footprint depth along Z-axis in meters (default: 4.0).' },
|
|
17
|
+
height: { type: 'number', description: 'Roof peak height above the eaves in meters (default: 1.4).' },
|
|
18
|
+
pitchDegrees: { type: 'number', description: 'Optional slope pitch angle in degrees (5 to 75) if height is omitted.' },
|
|
19
|
+
overhang: { type: 'number', description: 'Eaves overhang beyond the walls in meters (default: 0.25).' },
|
|
20
|
+
thickness: { type: 'number', description: 'Roof slab / fascia thickness in meters (default: 0.14).' },
|
|
21
|
+
ridgeCap: { type: 'boolean', description: 'Whether to include a ridge cap beam along the apex (default: true).' },
|
|
22
|
+
gableWall: { type: 'boolean', description: 'Whether to include triangular gable infill walls for style="gable" (default: true).' },
|
|
23
|
+
position: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
description: 'Eaves base center position { x, y, z } in meters (set y equal to the wall height).',
|
|
26
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
27
|
+
},
|
|
28
|
+
rotationDegrees: {
|
|
29
|
+
type: 'object',
|
|
30
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
31
|
+
},
|
|
32
|
+
scaling: {
|
|
33
|
+
type: 'object',
|
|
34
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
35
|
+
},
|
|
36
|
+
color: { type: 'string', description: 'Hex color string, e.g. "#8b3a2b".' },
|
|
37
|
+
roughness: { type: 'number', description: 'PBR roughness (default: 0.75).' },
|
|
38
|
+
metallic: { type: 'number', description: 'PBR metallic (default: 0.05).' },
|
|
39
|
+
materialName: { type: 'string', description: 'Optional existing material name.' },
|
|
40
|
+
texturePrompt: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
description: 'Optional natural language prompt to generate and apply an AI PBR texture (e.g. "Aged terracotta clay roof tiles", "Weathered slate roof shingles").',
|
|
43
|
+
},
|
|
44
|
+
uvScale: {
|
|
45
|
+
type: 'number',
|
|
46
|
+
description: 'Texture UV tiling scale factor (default: 3.0).',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
execute(args, context) {
|
|
51
|
+
const baseName = String(args.name || 'arch_roof').replace(/\s+/g, '_');
|
|
52
|
+
const uniqueName = context.findMeshByNameOrId(baseName)
|
|
53
|
+
? `${baseName}_${Date.now().toString().slice(-4)}`
|
|
54
|
+
: baseName;
|
|
55
|
+
const mesh = buildRoofMesh(context.scene, uniqueName, {
|
|
56
|
+
style: args.style,
|
|
57
|
+
width: args.width,
|
|
58
|
+
depth: args.depth,
|
|
59
|
+
height: args.height,
|
|
60
|
+
pitchDegrees: args.pitchDegrees,
|
|
61
|
+
overhang: args.overhang,
|
|
62
|
+
thickness: args.thickness,
|
|
63
|
+
ridgeCap: args.ridgeCap,
|
|
64
|
+
gableWall: args.gableWall,
|
|
65
|
+
});
|
|
66
|
+
mesh.material = context.getOrCreateMaterial(args.materialName, args.color || '#8b3a2b', args.roughness ?? 0.75, args.metallic ?? 0.05, uniqueName);
|
|
67
|
+
context.applyTransformArgs(mesh, args);
|
|
68
|
+
context.registerCreatedMesh(mesh);
|
|
69
|
+
if (args.texturePrompt && context.service.aiTextureGenerator) {
|
|
70
|
+
context.service.aiTextureGenerator
|
|
71
|
+
.generateTexture({
|
|
72
|
+
prompt: args.texturePrompt,
|
|
73
|
+
applyToMesh: mesh.name,
|
|
74
|
+
uvScale: typeof args.uvScale === 'number' ? args.uvScale : 3.0,
|
|
75
|
+
useAI: true,
|
|
76
|
+
fallbackToProcedural: true,
|
|
77
|
+
})
|
|
78
|
+
.catch((err) => {
|
|
79
|
+
console.warn(`Texture generation for ${mesh.name} failed:`, err);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const bb = mesh.getBoundingInfo().boundingBox;
|
|
83
|
+
return JSON.stringify({
|
|
84
|
+
status: 'ok',
|
|
85
|
+
meshName: mesh.name,
|
|
86
|
+
style: args.style || 'gable',
|
|
87
|
+
vertices: mesh.getTotalVertices(),
|
|
88
|
+
triangles: Math.floor(mesh.getTotalIndices() / 3),
|
|
89
|
+
bounds: {
|
|
90
|
+
min: {
|
|
91
|
+
x: Number(bb.minimumWorld.x.toFixed(3)),
|
|
92
|
+
y: Number(bb.minimumWorld.y.toFixed(3)),
|
|
93
|
+
z: Number(bb.minimumWorld.z.toFixed(3)),
|
|
94
|
+
},
|
|
95
|
+
max: {
|
|
96
|
+
x: Number(bb.maximumWorld.x.toFixed(3)),
|
|
97
|
+
y: Number(bb.maximumWorld.y.toFixed(3)),
|
|
98
|
+
z: Number(bb.maximumWorld.z.toFixed(3)),
|
|
99
|
+
},
|
|
100
|
+
size: {
|
|
101
|
+
x: Number((bb.maximumWorld.x - bb.minimumWorld.x).toFixed(3)),
|
|
102
|
+
y: Number((bb.maximumWorld.y - bb.minimumWorld.y).toFixed(3)),
|
|
103
|
+
z: Number((bb.maximumWorld.z - bb.minimumWorld.z).toFixed(3)),
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|