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,255 @@
|
|
|
1
|
+
import { Mesh, Vector3, VertexBuffer } from '@babylonjs/core';
|
|
2
|
+
import { AbstractTool } from '../AbstractTool';
|
|
3
|
+
function parseStrokeVec(v) {
|
|
4
|
+
if (Array.isArray(v) && v.length >= 3) {
|
|
5
|
+
const x = Number(v[0]);
|
|
6
|
+
const y = Number(v[1]);
|
|
7
|
+
const z = Number(v[2]);
|
|
8
|
+
if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {
|
|
9
|
+
return new Vector3(x, y, z);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (v && typeof v === 'object') {
|
|
13
|
+
const x = Number(v.x);
|
|
14
|
+
const y = Number(v.y);
|
|
15
|
+
const z = Number(v.z);
|
|
16
|
+
if (Number.isFinite(x) && Number.isFinite(y) && Number.isFinite(z)) {
|
|
17
|
+
return new Vector3(x, y, z);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Estimates the outward world-space surface normal on `mesh` nearest to `worldPt`.
|
|
24
|
+
*/
|
|
25
|
+
function estimateSurfaceNormal(mesh, worldPt) {
|
|
26
|
+
mesh.computeWorldMatrix(true);
|
|
27
|
+
const bb = mesh.getBoundingInfo()?.boundingBox;
|
|
28
|
+
const center = bb?.centerWorld || mesh.position;
|
|
29
|
+
const positions = mesh.getVerticesData(VertexBuffer.PositionKind);
|
|
30
|
+
const normals = mesh.getVerticesData(VertexBuffer.NormalKind);
|
|
31
|
+
if (positions && normals && positions.length >= 3) {
|
|
32
|
+
const invWorld = mesh.getWorldMatrix().clone().invert();
|
|
33
|
+
const localPt = Vector3.TransformCoordinates(worldPt, invWorld);
|
|
34
|
+
let bestDistSq = Infinity;
|
|
35
|
+
let bestIdx = 0;
|
|
36
|
+
const step = positions.length > 6000 ? 6 : 3;
|
|
37
|
+
for (let i = 0; i < positions.length; i += step) {
|
|
38
|
+
const dx = positions[i] - localPt.x;
|
|
39
|
+
const dy = positions[i + 1] - localPt.y;
|
|
40
|
+
const dz = positions[i + 2] - localPt.z;
|
|
41
|
+
const dSq = dx * dx + dy * dy + dz * dz;
|
|
42
|
+
if (dSq < bestDistSq) {
|
|
43
|
+
bestDistSq = dSq;
|
|
44
|
+
bestIdx = i;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const localNorm = new Vector3(normals[bestIdx] || 0, normals[bestIdx + 1] || 1, normals[bestIdx + 2] || 0);
|
|
48
|
+
const worldNorm = Vector3.TransformNormal(localNorm, mesh.getWorldMatrix());
|
|
49
|
+
if (worldNorm.lengthSquared() > 1e-6) {
|
|
50
|
+
return worldNorm.normalize();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const radial = worldPt.subtract(center);
|
|
54
|
+
if (radial.lengthSquared() > 1e-6) {
|
|
55
|
+
return radial.normalize();
|
|
56
|
+
}
|
|
57
|
+
return Vector3.Up();
|
|
58
|
+
}
|
|
59
|
+
export class SculptMeshTool extends AbstractTool {
|
|
60
|
+
name = 'modeler_sculpt_mesh';
|
|
61
|
+
description = 'Applies digital clay sculpting brush deformations ("clay", "grab", "inflate", "pinch", "flatten", "smooth") to a 3D mesh (such as a clay sphere spawned via modeler_spawn_base_mesh with type="sculpt_sphere", an SDF mesh, or any character/prop mesh). Supports both single contact points (x,y,z) and continuous directional stroke paths (from -> to or delta) for pulling out volumes, sculpting muscles, carving eye sockets, flattening planes, and smoothing seams.';
|
|
62
|
+
parameters = {
|
|
63
|
+
type: 'object',
|
|
64
|
+
properties: {
|
|
65
|
+
meshName: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
description: 'Name or ID of the mesh in the scene to sculpt.',
|
|
68
|
+
},
|
|
69
|
+
brush: {
|
|
70
|
+
type: 'string',
|
|
71
|
+
enum: ['clay', 'grab', 'smooth', 'flatten', 'inflate', 'pinch'],
|
|
72
|
+
description: 'Sculpting brush mode: "clay" (builds up or carves clay strips along surface normals), "grab" (pulls/drags a region of clay from "from" to "to" or by "delta" to shape silhouettes, jaws, noses, limbs, or horns), "inflate" (expands/deflates volume along vertex normals), "pinch" (sharpens creases, lips, eyelids, or edges), "flatten" (planes off anatomical/architectural surfaces), or "smooth" (relaxes surface bumps). Default: "clay".',
|
|
73
|
+
},
|
|
74
|
+
strokes: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
items: {
|
|
77
|
+
type: 'object',
|
|
78
|
+
properties: {
|
|
79
|
+
x: { type: 'number', description: 'Contact point X (or start X if delta/to is used).' },
|
|
80
|
+
y: { type: 'number', description: 'Contact point Y (or start Y if delta/to is used).' },
|
|
81
|
+
z: { type: 'number', description: 'Contact point Z (or start Z if delta/to is used).' },
|
|
82
|
+
from: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
description: 'Optional start point { x, y, z } for a continuous brush drag or grab stroke.',
|
|
85
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
86
|
+
},
|
|
87
|
+
to: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
description: 'Optional end point { x, y, z } for a continuous brush drag or grab stroke.',
|
|
90
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
91
|
+
},
|
|
92
|
+
delta: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
description: 'Optional displacement vector { x, y, z } added to (x,y,z) or "from" (especially useful for "grab" brush).',
|
|
95
|
+
properties: { x: { type: 'number' }, y: { type: 'number' }, z: { type: 'number' } },
|
|
96
|
+
},
|
|
97
|
+
steps: {
|
|
98
|
+
type: 'integer',
|
|
99
|
+
minimum: 1,
|
|
100
|
+
maximum: 32,
|
|
101
|
+
description: 'Interpolation steps along a from->to stroke path (default: 8).',
|
|
102
|
+
},
|
|
103
|
+
radius: { type: 'number', description: 'Brush influence radius in meters (default: 0.35).' },
|
|
104
|
+
strength: { type: 'number', description: 'Deformation strength from 0.05 to 1.0 (default: 0.55).' },
|
|
105
|
+
invert: {
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
description: 'Invert brush direction (e.g. carve inward / excavate eye sockets instead of building outward).',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
description: 'Array of 3D brush strokes. Each stroke can specify a point {x, y, z} or a continuous path {from: {x,y,z}, to: {x,y,z}}.',
|
|
112
|
+
},
|
|
113
|
+
symmetryX: {
|
|
114
|
+
type: 'boolean',
|
|
115
|
+
description: 'Mirror strokes across the X = 0 symmetry plane (default: true).',
|
|
116
|
+
},
|
|
117
|
+
subdivideIfCoarse: {
|
|
118
|
+
type: 'boolean',
|
|
119
|
+
description: 'Automatically subdivide the target mesh before sculpting if it has fewer than 600 vertices so clay strokes deform smoothly (default: true).',
|
|
120
|
+
},
|
|
121
|
+
remeshTargetFaces: {
|
|
122
|
+
type: 'integer',
|
|
123
|
+
minimum: 300,
|
|
124
|
+
maximum: 100000,
|
|
125
|
+
description: 'Optional target triangle count to retopologize/clean up topology after sculpting.',
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
required: ['meshName', 'strokes'],
|
|
129
|
+
};
|
|
130
|
+
async execute(args, context) {
|
|
131
|
+
const meshName = String(args.meshName || '').trim();
|
|
132
|
+
const mesh = context.findMeshByNameOrId(meshName);
|
|
133
|
+
if (!mesh || !(mesh instanceof Mesh)) {
|
|
134
|
+
throw new Error(`Mesh "${meshName}" not found in scene.`);
|
|
135
|
+
}
|
|
136
|
+
const sculptCtrl = context.service.sculptController;
|
|
137
|
+
if (!sculptCtrl) {
|
|
138
|
+
throw new Error('SculptController is not available on MeshEditorService.');
|
|
139
|
+
}
|
|
140
|
+
// Automatically subdivide coarse meshes (such as a basic box or low-segment sphere) so clay brushes have vertices to move
|
|
141
|
+
let autoSubdivided = false;
|
|
142
|
+
if (args.subdivideIfCoarse !== false && mesh.getTotalVertices() < 600) {
|
|
143
|
+
const iters = mesh.getTotalVertices() < 150 ? 2 : 1;
|
|
144
|
+
for (let i = 0; i < iters; i++) {
|
|
145
|
+
context.service.subdivideMesh(mesh);
|
|
146
|
+
}
|
|
147
|
+
autoSubdivided = true;
|
|
148
|
+
}
|
|
149
|
+
const brush = String(args.brush || 'clay').toLowerCase();
|
|
150
|
+
const strokes = Array.isArray(args.strokes) ? args.strokes : [];
|
|
151
|
+
const symmetryX = args.symmetryX !== false;
|
|
152
|
+
const prevBrush = sculptCtrl.brushType;
|
|
153
|
+
const prevRadius = sculptCtrl.radius;
|
|
154
|
+
const prevStrength = sculptCtrl.strength;
|
|
155
|
+
const prevSymmetry = sculptCtrl.symmetryX;
|
|
156
|
+
const prevInvert = sculptCtrl.invert;
|
|
157
|
+
sculptCtrl.brushType = brush;
|
|
158
|
+
sculptCtrl.symmetryX = symmetryX;
|
|
159
|
+
let appliedCount = 0;
|
|
160
|
+
let totalSamples = 0;
|
|
161
|
+
try {
|
|
162
|
+
for (const stroke of strokes) {
|
|
163
|
+
const startPt = parseStrokeVec(stroke.from) ||
|
|
164
|
+
(typeof stroke.x === 'number' && typeof stroke.y === 'number' && typeof stroke.z === 'number'
|
|
165
|
+
? new Vector3(stroke.x, stroke.y, stroke.z)
|
|
166
|
+
: null);
|
|
167
|
+
if (!startPt)
|
|
168
|
+
continue;
|
|
169
|
+
const deltaVec = parseStrokeVec(stroke.delta);
|
|
170
|
+
const endPt = parseStrokeVec(stroke.to) ||
|
|
171
|
+
(deltaVec ? startPt.add(deltaVec) : null);
|
|
172
|
+
sculptCtrl.radius =
|
|
173
|
+
typeof stroke.radius === 'number' ? Math.max(0.02, stroke.radius) : prevRadius;
|
|
174
|
+
sculptCtrl.strength =
|
|
175
|
+
typeof stroke.strength === 'number' ? Math.max(0.01, stroke.strength) : prevStrength;
|
|
176
|
+
sculptCtrl.invert = !!stroke.invert;
|
|
177
|
+
const explicitNormal = parseStrokeVec(stroke.normal);
|
|
178
|
+
if (endPt && Vector3.DistanceSquared(startPt, endPt) > 1e-6) {
|
|
179
|
+
const steps = Math.max(2, Math.min(32, Number(stroke.steps) ||
|
|
180
|
+
Math.ceil(Vector3.Distance(startPt, endPt) / Math.max(0.03, sculptCtrl.radius * 0.35))));
|
|
181
|
+
// Reset lastLocalPick at start of path so grab brush drags cleanly along startPt -> endPt
|
|
182
|
+
sculptCtrl.lastLocalPick = null;
|
|
183
|
+
for (let s = 0; s <= steps; s++) {
|
|
184
|
+
const t = s / steps;
|
|
185
|
+
const pt = Vector3.Lerp(startPt, endPt, t);
|
|
186
|
+
const norm = explicitNormal || estimateSurfaceNormal(mesh, pt);
|
|
187
|
+
sculptCtrl.applyBrushStroke(mesh, pt, norm);
|
|
188
|
+
totalSamples++;
|
|
189
|
+
}
|
|
190
|
+
sculptCtrl.lastLocalPick = null;
|
|
191
|
+
appliedCount++;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const norm = explicitNormal || estimateSurfaceNormal(mesh, startPt);
|
|
195
|
+
if (brush === 'grab') {
|
|
196
|
+
// If grab was called with a single point and no delta/to, pull slightly along outward normal
|
|
197
|
+
sculptCtrl.lastLocalPick = null;
|
|
198
|
+
const pullDir = norm.scale((sculptCtrl.invert ? -1 : 1) * sculptCtrl.radius * 0.35 * sculptCtrl.strength);
|
|
199
|
+
sculptCtrl.applyBrushStroke(mesh, startPt, norm);
|
|
200
|
+
sculptCtrl.applyBrushStroke(mesh, startPt.add(pullDir), norm);
|
|
201
|
+
sculptCtrl.lastLocalPick = null;
|
|
202
|
+
totalSamples += 2;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
sculptCtrl.applyBrushStroke(mesh, startPt, norm);
|
|
206
|
+
totalSamples++;
|
|
207
|
+
}
|
|
208
|
+
appliedCount++;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
sculptCtrl.brushType = prevBrush;
|
|
214
|
+
sculptCtrl.radius = prevRadius;
|
|
215
|
+
sculptCtrl.strength = prevStrength;
|
|
216
|
+
sculptCtrl.symmetryX = prevSymmetry;
|
|
217
|
+
sculptCtrl.invert = prevInvert;
|
|
218
|
+
sculptCtrl.lastLocalPick = null;
|
|
219
|
+
}
|
|
220
|
+
if (typeof args.remeshTargetFaces === 'number' &&
|
|
221
|
+
args.remeshTargetFaces >= 300 &&
|
|
222
|
+
Math.floor(mesh.getTotalIndices() / 3) > args.remeshTargetFaces) {
|
|
223
|
+
await sculptCtrl.retopologizeMesh(mesh, Math.round(args.remeshTargetFaces));
|
|
224
|
+
}
|
|
225
|
+
mesh.computeWorldMatrix(true);
|
|
226
|
+
mesh.refreshBoundingInfo();
|
|
227
|
+
context.service.updateStats();
|
|
228
|
+
context.service.events.onSceneModified?.();
|
|
229
|
+
const bb = mesh.getBoundingInfo().boundingBox;
|
|
230
|
+
return JSON.stringify({
|
|
231
|
+
status: 'ok',
|
|
232
|
+
meshName: mesh.name,
|
|
233
|
+
brush,
|
|
234
|
+
strokesApplied: appliedCount,
|
|
235
|
+
samplesApplied: totalSamples,
|
|
236
|
+
symmetryX,
|
|
237
|
+
autoSubdivided,
|
|
238
|
+
totalVertices: mesh.getTotalVertices(),
|
|
239
|
+
totalTriangles: Math.floor(mesh.getTotalIndices() / 3),
|
|
240
|
+
totalIndices: mesh.getTotalIndices(),
|
|
241
|
+
bounds: {
|
|
242
|
+
min: {
|
|
243
|
+
x: Number(bb.minimumWorld.x.toFixed(3)),
|
|
244
|
+
y: Number(bb.minimumWorld.y.toFixed(3)),
|
|
245
|
+
z: Number(bb.minimumWorld.z.toFixed(3)),
|
|
246
|
+
},
|
|
247
|
+
max: {
|
|
248
|
+
x: Number(bb.maximumWorld.x.toFixed(3)),
|
|
249
|
+
y: Number(bb.maximumWorld.y.toFixed(3)),
|
|
250
|
+
z: Number(bb.maximumWorld.z.toFixed(3)),
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class SeparateMeshTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_separate_mesh";
|
|
5
|
+
readonly description = "Separates a mesh into disconnected loose parts or splits it by subMeshes so individual components can be edited separately.";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
meshName: {
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
mode: {
|
|
13
|
+
type: string;
|
|
14
|
+
enum: string[];
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
required: string[];
|
|
19
|
+
};
|
|
20
|
+
execute(args: any, context: ToolExecutionContext): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
export class SeparateMeshTool extends AbstractTool {
|
|
3
|
+
name = 'modeler_separate_mesh';
|
|
4
|
+
description = 'Separates a mesh into disconnected loose parts or splits it by subMeshes so individual components can be edited separately.';
|
|
5
|
+
parameters = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
meshName: { type: 'string' },
|
|
9
|
+
mode: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
enum: ['loose_parts', 'submeshes'],
|
|
12
|
+
description: 'Separation mode (default "loose_parts").',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
required: ['meshName'],
|
|
16
|
+
};
|
|
17
|
+
execute(args, context) {
|
|
18
|
+
const mesh = context.findMeshByNameOrId(args.meshName);
|
|
19
|
+
if (!mesh) {
|
|
20
|
+
throw new Error(`Mesh "${args.meshName}" not found.`);
|
|
21
|
+
}
|
|
22
|
+
context.service.selectMesh(mesh);
|
|
23
|
+
const parts = args.mode === 'submeshes'
|
|
24
|
+
? context.service.separateSelectedSubMeshes()
|
|
25
|
+
: context.service.separateSelectedLooseParts();
|
|
26
|
+
return JSON.stringify({
|
|
27
|
+
status: 'ok',
|
|
28
|
+
parts: parts.map((p) => p.name),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class SolidifyMeshTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_solidify_mesh";
|
|
5
|
+
readonly description = "Gives real physical wall thickness to an open surface sheet or hollow mesh (ideal for hollow vessels, cups, bowls, helmets, armor, pipes, or architectural walls).";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
meshName: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
thickness: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
direction: {
|
|
18
|
+
type: string;
|
|
19
|
+
enum: string[];
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
faceId: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
required: string[];
|
|
28
|
+
};
|
|
29
|
+
execute(args: any, context: ToolExecutionContext): Promise<string>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
export class SolidifyMeshTool extends AbstractTool {
|
|
3
|
+
name = 'modeler_solidify_mesh';
|
|
4
|
+
description = 'Gives real physical wall thickness to an open surface sheet or hollow mesh (ideal for hollow vessels, cups, bowls, helmets, armor, pipes, or architectural walls).';
|
|
5
|
+
parameters = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
meshName: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Name or ID of the mesh in the scene to solidify.',
|
|
11
|
+
},
|
|
12
|
+
thickness: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
description: 'Thickness of the wall (default: 0.2).',
|
|
15
|
+
},
|
|
16
|
+
direction: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
enum: ['top', 'bottom', 'front', 'back', 'left', 'right'],
|
|
19
|
+
description: 'Optional: If specified, solidifies only the facet facing this direction instead of the whole mesh.',
|
|
20
|
+
},
|
|
21
|
+
faceId: {
|
|
22
|
+
type: 'number',
|
|
23
|
+
description: 'Optional: Specific face index to solidify (if solidifying single facet).',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: ['meshName'],
|
|
27
|
+
};
|
|
28
|
+
async execute(args, context) {
|
|
29
|
+
const meshName = String(args.meshName || '').trim();
|
|
30
|
+
const mesh = context.findMeshByNameOrId(meshName);
|
|
31
|
+
if (!mesh) {
|
|
32
|
+
throw new Error(`Mesh "${meshName}" not found in scene.`);
|
|
33
|
+
}
|
|
34
|
+
const thickness = typeof args.thickness === 'number' ? args.thickness : 0.2;
|
|
35
|
+
const isSingleFace = args.direction !== undefined || args.faceId !== undefined;
|
|
36
|
+
if (isSingleFace) {
|
|
37
|
+
const fid = context.service.selectFaceByQuery(mesh, {
|
|
38
|
+
direction: args.direction,
|
|
39
|
+
faceId: args.faceId,
|
|
40
|
+
});
|
|
41
|
+
if (fid === null) {
|
|
42
|
+
throw new Error(`Could not find specified face on mesh "${mesh.name}".`);
|
|
43
|
+
}
|
|
44
|
+
context.service.solidifyMeshOrFacet(thickness, true, mesh);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
context.service.solidifyMeshOrFacet(thickness, false, mesh);
|
|
48
|
+
}
|
|
49
|
+
return JSON.stringify({
|
|
50
|
+
status: 'ok',
|
|
51
|
+
meshName: mesh.name,
|
|
52
|
+
thickness,
|
|
53
|
+
totalVertices: mesh.getTotalVertices(),
|
|
54
|
+
totalIndices: mesh.getTotalIndices(),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class SpawnBaseMeshTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_spawn_base_mesh";
|
|
5
|
+
readonly description = "Spawns an anatomically proportioned character base-mesh (Humanoid Loomis 8-head mannequin, Quadruped animal with digitigrade/unguligrade joints, Facial Head Bust, or Sculpt Sphere) with deformation-ready joint loops.";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
type: {
|
|
10
|
+
type: string;
|
|
11
|
+
enum: string[];
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
style: {
|
|
15
|
+
type: string;
|
|
16
|
+
enum: string[];
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
canon: {
|
|
20
|
+
type: string;
|
|
21
|
+
enum: string[];
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
pose: {
|
|
25
|
+
type: string;
|
|
26
|
+
enum: string[];
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
materialStyle: {
|
|
30
|
+
type: string;
|
|
31
|
+
enum: string[];
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
name: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
scale: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
locomotion: {
|
|
43
|
+
type: string;
|
|
44
|
+
enum: string[];
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
position: {
|
|
48
|
+
type: string;
|
|
49
|
+
properties: {
|
|
50
|
+
x: {
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
53
|
+
y: {
|
|
54
|
+
type: string;
|
|
55
|
+
};
|
|
56
|
+
z: {
|
|
57
|
+
type: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
description: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
required: string[];
|
|
64
|
+
};
|
|
65
|
+
execute(args: any, context: ToolExecutionContext): Promise<string>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Vector3 } from '@babylonjs/core';
|
|
2
|
+
import { AbstractTool } from '../AbstractTool';
|
|
3
|
+
export class SpawnBaseMeshTool extends AbstractTool {
|
|
4
|
+
name = 'modeler_spawn_base_mesh';
|
|
5
|
+
description = 'Spawns an anatomically proportioned character base-mesh (Humanoid Loomis 8-head mannequin, Quadruped animal with digitigrade/unguligrade joints, Facial Head Bust, or Sculpt Sphere) with deformation-ready joint loops.';
|
|
6
|
+
parameters = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
type: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
enum: ['humanoid', 'chibi', 'creature', 'quadruped', 'head_bust', 'sculpt_sphere'],
|
|
12
|
+
description: 'Base mesh archetype: "creature" (stylized organic creature / chibi demon with seamless pear body, continuous curved tubular limbs, claws, horns, bat wings, halo, and eyes — ideal for monsters and soft organic characters), "chibi" (3.5-head cartoon/stylized character with potbelly, continuous limbs, and boots/gloves — ideal for Mario, toon characters, dwarves), "humanoid" (standard 8-head standing character), "quadruped" (4-legged beast), "head_bust", or "sculpt_sphere".',
|
|
13
|
+
},
|
|
14
|
+
style: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
enum: ['organic', 'mannequin'],
|
|
17
|
+
description: 'Mesh construction style: "organic" (creates continuous, soft, flowing tubular limbs and seamless rounded body volumes — default, recommended for cartoon characters and creatures) or "mannequin" (classic wooden artist puppet with separated joint spheres).',
|
|
18
|
+
},
|
|
19
|
+
canon: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
enum: ['heroic', 'chibi', 'stylized'],
|
|
22
|
+
description: 'Proportional canon for humanoid: "heroic" (8-head realistic), "chibi" (3.5-head cartoon/Mario), or "stylized" (6-head).',
|
|
23
|
+
},
|
|
24
|
+
pose: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
enum: ['t_pose', 'a_pose'],
|
|
27
|
+
description: 'Resting pose for character arms: "t_pose" (arms horizontally outstretched at 90 degrees — recommended for rigging and animation) or "a_pose" (arms angled down at 45 degrees). Default: "t_pose".',
|
|
28
|
+
},
|
|
29
|
+
materialStyle: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
enum: ['colored', 'clay'],
|
|
32
|
+
description: 'Material style: "colored" (applies skin, clothing, glove, and boot color zones) or "clay" (monochromatic sculpting clay). Default: "colored".',
|
|
33
|
+
},
|
|
34
|
+
name: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Optional custom mesh name (e.g. "Hero_BaseMesh").',
|
|
37
|
+
},
|
|
38
|
+
scale: {
|
|
39
|
+
type: 'number',
|
|
40
|
+
description: 'Uniform scaling factor (default: 1.0).',
|
|
41
|
+
},
|
|
42
|
+
locomotion: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
enum: ['digitigrade', 'unguligrade'],
|
|
45
|
+
description: 'Locomotion leg mechanics for quadruped ("digitigrade" for cats/dogs/wolves with raised hock, "unguligrade" for horses/deer).',
|
|
46
|
+
},
|
|
47
|
+
position: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
x: { type: 'number' },
|
|
51
|
+
y: { type: 'number' },
|
|
52
|
+
z: { type: 'number' },
|
|
53
|
+
},
|
|
54
|
+
description: 'World placement position (default: [0, 0, 0]).',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
required: ['type'],
|
|
58
|
+
};
|
|
59
|
+
async execute(args, context) {
|
|
60
|
+
const type = String(args.type || 'humanoid').toLowerCase();
|
|
61
|
+
const name = args.name ? String(args.name).trim() : undefined;
|
|
62
|
+
const scale = Number(args.scale) || 1.0;
|
|
63
|
+
const canon = args.canon;
|
|
64
|
+
const pose = (args.pose === 'a_pose' ? 'a_pose' : 't_pose');
|
|
65
|
+
const materialStyle = (args.materialStyle === 'clay' ? 'clay' : 'colored');
|
|
66
|
+
const locomotion = (args.locomotion === 'unguligrade' ? 'unguligrade' : 'digitigrade');
|
|
67
|
+
const style = (args.style === 'mannequin' ? 'mannequin' : 'organic');
|
|
68
|
+
let pos;
|
|
69
|
+
if (args.position) {
|
|
70
|
+
pos = new Vector3(Number(args.position.x) || 0, Number(args.position.y) || 0, Number(args.position.z) || 0);
|
|
71
|
+
}
|
|
72
|
+
const sculptCtrl = context.service.sculptController;
|
|
73
|
+
let mesh;
|
|
74
|
+
switch (type) {
|
|
75
|
+
case 'creature':
|
|
76
|
+
mesh = sculptCtrl.spawnOrganicCreatureBaseMesh({ name, scale, materialStyle, position: pos });
|
|
77
|
+
break;
|
|
78
|
+
case 'chibi':
|
|
79
|
+
mesh = sculptCtrl.spawnChibiBaseMesh({ name, scale, pose, materialStyle, style, position: pos });
|
|
80
|
+
break;
|
|
81
|
+
case 'quadruped':
|
|
82
|
+
mesh = sculptCtrl.spawnQuadrupedBaseMesh({ name, scale, locomotion, position: pos });
|
|
83
|
+
break;
|
|
84
|
+
case 'head_bust':
|
|
85
|
+
mesh = sculptCtrl.spawnHeadBust({ name, scale, position: pos });
|
|
86
|
+
break;
|
|
87
|
+
case 'sculpt_sphere':
|
|
88
|
+
mesh = sculptCtrl.spawnSculptSphere({ name, scale, position: pos });
|
|
89
|
+
break;
|
|
90
|
+
case 'humanoid':
|
|
91
|
+
default:
|
|
92
|
+
mesh = sculptCtrl.spawnHumanoidBaseMesh({ name, scale, canon, pose, materialStyle, position: pos });
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
context.service.selectMesh(mesh);
|
|
96
|
+
return JSON.stringify({
|
|
97
|
+
status: 'ok',
|
|
98
|
+
meshName: mesh.name,
|
|
99
|
+
meshId: mesh.id,
|
|
100
|
+
totalVertices: mesh.getTotalVertices(),
|
|
101
|
+
totalTriangles: mesh.getTotalIndices() / 3,
|
|
102
|
+
position: { x: mesh.position.x, y: mesh.position.y, z: mesh.position.z },
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class SubDSmoothTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_subd_smooth";
|
|
5
|
+
readonly description = "Applies organic subdivision surface (Sub-D) smoothing using midpoint subdivision and Laplacian vertex relaxation. Turns low-poly blockout cages into smooth, rounded shapes (rocks, cushions, organic assets, curved bodies).";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
meshName: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
iterations: {
|
|
14
|
+
type: string;
|
|
15
|
+
minimum: number;
|
|
16
|
+
maximum: number;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
required: string[];
|
|
21
|
+
};
|
|
22
|
+
execute(args: any, context: ToolExecutionContext): Promise<string>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
export class SubDSmoothTool extends AbstractTool {
|
|
3
|
+
name = 'modeler_subd_smooth';
|
|
4
|
+
description = 'Applies organic subdivision surface (Sub-D) smoothing using midpoint subdivision and Laplacian vertex relaxation. Turns low-poly blockout cages into smooth, rounded shapes (rocks, cushions, organic assets, curved bodies).';
|
|
5
|
+
parameters = {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
meshName: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
description: 'Name or ID of the mesh in the scene to smooth.',
|
|
11
|
+
},
|
|
12
|
+
iterations: {
|
|
13
|
+
type: 'integer',
|
|
14
|
+
minimum: 1,
|
|
15
|
+
maximum: 3,
|
|
16
|
+
description: 'Smoothing iterations (default: 1, max: 3).',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ['meshName'],
|
|
20
|
+
};
|
|
21
|
+
async execute(args, context) {
|
|
22
|
+
const meshName = String(args.meshName || '').trim();
|
|
23
|
+
const mesh = context.findMeshByNameOrId(meshName);
|
|
24
|
+
if (!mesh) {
|
|
25
|
+
throw new Error(`Mesh "${meshName}" not found in scene.`);
|
|
26
|
+
}
|
|
27
|
+
const iters = Math.max(1, Math.min(Number(args.iterations) || 1, 3));
|
|
28
|
+
context.service.subDSmoothMeshOrFacet(iters, mesh);
|
|
29
|
+
return JSON.stringify({
|
|
30
|
+
status: 'ok',
|
|
31
|
+
meshName: mesh.name,
|
|
32
|
+
iterations: iters,
|
|
33
|
+
totalVertices: mesh.getTotalVertices(),
|
|
34
|
+
totalIndices: mesh.getTotalIndices(),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { AbstractTool } from '../AbstractTool';
|
|
2
|
+
import { ToolExecutionContext } from '../ToolExecutionContext';
|
|
3
|
+
export declare class SubdivideMeshTool extends AbstractTool {
|
|
4
|
+
readonly name = "modeler_subdivide_mesh";
|
|
5
|
+
readonly description = "Subdivides each triangle of the mesh into 4 smaller subtriangles, increasing geometric resolution uniformly.";
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
meshName: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
iterations: {
|
|
14
|
+
type: string;
|
|
15
|
+
minimum: number;
|
|
16
|
+
maximum: number;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
required: string[];
|
|
21
|
+
};
|
|
22
|
+
execute(args: any, context: ToolExecutionContext): Promise<string>;
|
|
23
|
+
}
|