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,133 @@
|
|
|
1
|
+
import { Mesh, VertexData } from '@babylonjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* Generates an indexed VertexData for a beveled / rounded box where flat faces remain minimal quads
|
|
4
|
+
* and only edges and corners are subdivided with smooth bevel rings.
|
|
5
|
+
*/
|
|
6
|
+
export function createRoundedBoxVertexData(options = {}) {
|
|
7
|
+
const baseSize = options.size ?? 1.0;
|
|
8
|
+
const width = Math.max(0.002, Number(options.width ?? baseSize));
|
|
9
|
+
const height = Math.max(0.002, Number(options.height ?? baseSize));
|
|
10
|
+
const depth = Math.max(0.002, Number(options.depth ?? baseSize));
|
|
11
|
+
const hx = width * 0.5;
|
|
12
|
+
const hy = height * 0.5;
|
|
13
|
+
const hz = depth * 0.5;
|
|
14
|
+
const maxRadius = Math.min(hx, hy, hz) * 0.999;
|
|
15
|
+
const rawRadius = options.radius !== undefined ? Number(options.radius) : Math.min(hx, hy, hz) * 0.1;
|
|
16
|
+
const radius = Math.max(0, Math.min(maxRadius, rawRadius));
|
|
17
|
+
const segments = radius > 1e-5 ? Math.max(1, Math.min(12, Math.round(options.segments ?? 3))) : 0;
|
|
18
|
+
// Build 1D parameter grid along [-1, 1] where bevels live near the ends and the middle is a single span
|
|
19
|
+
// Using integer-indexed grid over (2 * segments + 2) steps if radius > 0, or 2 steps if radius == 0
|
|
20
|
+
const buildAxisCoords = (halfExtent) => {
|
|
21
|
+
const inner = Math.max(0, halfExtent - radius);
|
|
22
|
+
if (segments === 0 || radius <= 1e-5) {
|
|
23
|
+
return { pos: [-halfExtent, halfExtent], inner: halfExtent };
|
|
24
|
+
}
|
|
25
|
+
const coords = [];
|
|
26
|
+
// Negative bevel: angle from PI to PI/2
|
|
27
|
+
for (let i = 0; i <= segments; i++) {
|
|
28
|
+
const theta = (Math.PI * 0.5 * i) / segments;
|
|
29
|
+
coords.push(-inner - Math.cos(theta) * radius);
|
|
30
|
+
}
|
|
31
|
+
// Positive bevel: angle from PI/2 to 0
|
|
32
|
+
for (let i = 0; i <= segments; i++) {
|
|
33
|
+
const theta = (Math.PI * 0.5 * i) / segments;
|
|
34
|
+
coords.push(inner + Math.sin(theta) * radius);
|
|
35
|
+
}
|
|
36
|
+
return { pos: coords, inner };
|
|
37
|
+
};
|
|
38
|
+
const xGrid = buildAxisCoords(hx);
|
|
39
|
+
const yGrid = buildAxisCoords(hy);
|
|
40
|
+
const zGrid = buildAxisCoords(hz);
|
|
41
|
+
const positions = [];
|
|
42
|
+
const normals = [];
|
|
43
|
+
const uvs = [];
|
|
44
|
+
const indices = [];
|
|
45
|
+
const projectPointAndNormal = (x, y, z, fallbackNx, fallbackNy, fallbackNz) => {
|
|
46
|
+
if (segments === 0 || radius <= 1e-5) {
|
|
47
|
+
return { px: x, py: y, pz: z, nx: fallbackNx, ny: fallbackNy, nz: fallbackNz };
|
|
48
|
+
}
|
|
49
|
+
const cx = Math.max(-xGrid.inner, Math.min(xGrid.inner, x));
|
|
50
|
+
const cy = Math.max(-yGrid.inner, Math.min(yGrid.inner, y));
|
|
51
|
+
const cz = Math.max(-zGrid.inner, Math.min(zGrid.inner, z));
|
|
52
|
+
const dx = x - cx;
|
|
53
|
+
const dy = y - cy;
|
|
54
|
+
const dz = z - cz;
|
|
55
|
+
const len = Math.hypot(dx, dy, dz);
|
|
56
|
+
if (len < 1e-7) {
|
|
57
|
+
return {
|
|
58
|
+
px: cx + fallbackNx * radius,
|
|
59
|
+
py: cy + fallbackNy * radius,
|
|
60
|
+
pz: cz + fallbackNz * radius,
|
|
61
|
+
nx: fallbackNx,
|
|
62
|
+
ny: fallbackNy,
|
|
63
|
+
nz: fallbackNz,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const nx = dx / len;
|
|
67
|
+
const ny = dy / len;
|
|
68
|
+
const nz = dz / len;
|
|
69
|
+
return {
|
|
70
|
+
px: cx + nx * radius,
|
|
71
|
+
py: cy + ny * radius,
|
|
72
|
+
pz: cz + nz * radius,
|
|
73
|
+
nx,
|
|
74
|
+
ny,
|
|
75
|
+
nz,
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
const addPatch = (uCoords, vCoords, uSpan, vSpan, evalRaw, faceNormal, flipWinding) => {
|
|
79
|
+
const nu = uCoords.length;
|
|
80
|
+
const nv = vCoords.length;
|
|
81
|
+
const baseVert = positions.length / 3;
|
|
82
|
+
for (let iv = 0; iv < nv; iv++) {
|
|
83
|
+
const vVal = vCoords[iv];
|
|
84
|
+
for (let iu = 0; iu < nu; iu++) {
|
|
85
|
+
const uVal = uCoords[iu];
|
|
86
|
+
const [rx, ry, rz] = evalRaw(uVal, vVal);
|
|
87
|
+
const p = projectPointAndNormal(rx, ry, rz, faceNormal[0], faceNormal[1], faceNormal[2]);
|
|
88
|
+
positions.push(p.px, p.py, p.pz);
|
|
89
|
+
normals.push(p.nx, p.ny, p.nz);
|
|
90
|
+
uvs.push(uVal / uSpan + 0.5, vVal / vSpan + 0.5);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (let iv = 0; iv < nv - 1; iv++) {
|
|
94
|
+
for (let iu = 0; iu < nu - 1; iu++) {
|
|
95
|
+
const i00 = baseVert + iv * nu + iu;
|
|
96
|
+
const i10 = baseVert + iv * nu + (iu + 1);
|
|
97
|
+
const i01 = baseVert + (iv + 1) * nu + iu;
|
|
98
|
+
const i11 = baseVert + (iv + 1) * nu + (iu + 1);
|
|
99
|
+
// Note: in Babylon ComputeNormals, triangle (A, B, C) has normal (B-A) x_RH (C-A)
|
|
100
|
+
if (flipWinding) {
|
|
101
|
+
indices.push(i00, i10, i11, i00, i11, i01);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
indices.push(i00, i11, i10, i00, i01, i11);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
// +Z face: u = X (+right), v = Y (+up); (B-A)=+X, (C-A)=+Y -> +X x_RH +Y = +Z -> flipWinding = true
|
|
110
|
+
addPatch(xGrid.pos, yGrid.pos, width, height, (u, v) => [u, v, hz], [0, 0, 1], true);
|
|
111
|
+
// -Z face: u = X, v = Y; normal -Z -> flipWinding = false
|
|
112
|
+
addPatch(xGrid.pos, yGrid.pos, width, height, (u, v) => [u, v, -hz], [0, 0, -1], false);
|
|
113
|
+
// +X face: u = Z, v = Y; +Z x_RH +Y = -X -> for +X normal use flipWinding = false
|
|
114
|
+
addPatch(zGrid.pos, yGrid.pos, depth, height, (u, v) => [hx, v, u], [1, 0, 0], false);
|
|
115
|
+
// -X face: u = Z, v = Y; normal -X -> flipWinding = true
|
|
116
|
+
addPatch(zGrid.pos, yGrid.pos, depth, height, (u, v) => [-hx, v, u], [-1, 0, 0], true);
|
|
117
|
+
// +Y face: u = X, v = Z; +X x_RH +Z = -Y -> for +Y normal use flipWinding = false
|
|
118
|
+
addPatch(xGrid.pos, zGrid.pos, width, depth, (u, v) => [u, hy, v], [0, 1, 0], false);
|
|
119
|
+
// -Y face: u = X, v = Z; normal -Y -> flipWinding = true
|
|
120
|
+
addPatch(xGrid.pos, zGrid.pos, width, depth, (u, v) => [u, -hy, v], [0, -1, 0], true);
|
|
121
|
+
const vd = new VertexData();
|
|
122
|
+
vd.positions = new Float32Array(positions);
|
|
123
|
+
vd.normals = new Float32Array(normals);
|
|
124
|
+
vd.uvs = new Float32Array(uvs);
|
|
125
|
+
vd.indices = indices;
|
|
126
|
+
return vd;
|
|
127
|
+
}
|
|
128
|
+
export function createRoundedBoxMesh(name, options, scene) {
|
|
129
|
+
const mesh = new Mesh(name, scene);
|
|
130
|
+
const vd = createRoundedBoxVertexData(options);
|
|
131
|
+
vd.applyToMesh(mesh, true);
|
|
132
|
+
return mesh;
|
|
133
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './plugin';
|
|
3
|
+
export * from './adapters';
|
|
4
|
+
export * from './styles';
|
|
5
|
+
export * from './template';
|
|
6
|
+
export * from './builtInSkills';
|
|
7
|
+
export * from './voxel';
|
|
8
|
+
export * from './pathExtrusion';
|
|
9
|
+
export * from './compression/ModelCompressor';
|
|
10
|
+
export * from './geometry/bevelModifier';
|
|
11
|
+
export * from './uv/UVUnwrapController';
|
|
12
|
+
export * from './baking/TextureBaker';
|
|
13
|
+
export * from './rigging/WeightPaintController';
|
|
14
|
+
export * from './textures/AITextureGenerator';
|
|
15
|
+
export * from './textures/ExternalImageGeneratorService';
|
|
16
|
+
export * from './tools';
|
|
17
|
+
export * from './Neural3DGeneratorService';
|
|
18
|
+
export * from './AIAgentService';
|
|
19
|
+
export * from './MeshEditorService';
|
|
20
|
+
export * from './MeshEditorApp';
|
|
21
|
+
export * from './web-component';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { MeshEditorApp } from './MeshEditorApp';
|
|
2
|
+
import { registerMeshEditorElement } from './web-component';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export * from './plugin';
|
|
5
|
+
export * from './adapters';
|
|
6
|
+
export * from './styles';
|
|
7
|
+
export * from './template';
|
|
8
|
+
export * from './builtInSkills';
|
|
9
|
+
export * from './voxel';
|
|
10
|
+
export * from './pathExtrusion';
|
|
11
|
+
export * from './compression/ModelCompressor';
|
|
12
|
+
export * from './geometry/bevelModifier';
|
|
13
|
+
export * from './uv/UVUnwrapController';
|
|
14
|
+
export * from './baking/TextureBaker';
|
|
15
|
+
export * from './rigging/WeightPaintController';
|
|
16
|
+
export * from './textures/AITextureGenerator';
|
|
17
|
+
export * from './textures/ExternalImageGeneratorService';
|
|
18
|
+
export * from './tools';
|
|
19
|
+
export * from './Neural3DGeneratorService';
|
|
20
|
+
export * from './AIAgentService';
|
|
21
|
+
export * from './MeshEditorService';
|
|
22
|
+
export * from './MeshEditorApp';
|
|
23
|
+
export * from './web-component';
|
|
24
|
+
// Automatically register <mesh-editor> Web Component in browser environments
|
|
25
|
+
if (typeof window !== 'undefined' && typeof customElements !== 'undefined') {
|
|
26
|
+
registerMeshEditorElement();
|
|
27
|
+
}
|
|
28
|
+
// Auto-bootstrap standalone application when a top-level #renderCanvas is found in DOM
|
|
29
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
30
|
+
const bootstrap = () => {
|
|
31
|
+
const canvas = document.getElementById('renderCanvas');
|
|
32
|
+
// Only auto-bootstrap if #renderCanvas is not managed by a <mesh-editor> Web Component
|
|
33
|
+
const isInsideWebComponent = canvas?.closest('mesh-editor');
|
|
34
|
+
if (canvas && !isInsideWebComponent && !window.meshEditorApp) {
|
|
35
|
+
try {
|
|
36
|
+
const app = new MeshEditorApp();
|
|
37
|
+
window.meshEditorApp = app;
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error('[MeshEditor] Failed to bootstrap application:', err);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
if (document.readyState === 'loading') {
|
|
45
|
+
window.addEventListener('DOMContentLoaded', bootstrap);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
bootstrap();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Mesh, Vector3 } from '@babylonjs/core';
|
|
2
|
+
import type { MeshEditorService } from '../MeshEditorService';
|
|
3
|
+
import { PathExtrusionItem, ShapeConfig } from './types';
|
|
4
|
+
export declare class PathExtrusionController {
|
|
5
|
+
private service;
|
|
6
|
+
isActive: boolean;
|
|
7
|
+
paths: PathExtrusionItem[];
|
|
8
|
+
activePathId: string | null;
|
|
9
|
+
selectedPointIndex: number | null;
|
|
10
|
+
get pathways(): PathExtrusionItem[];
|
|
11
|
+
set pathways(v: PathExtrusionItem[]);
|
|
12
|
+
get activePathwayId(): string | null;
|
|
13
|
+
set activePathwayId(v: string | null);
|
|
14
|
+
get activePathway(): PathExtrusionItem | null;
|
|
15
|
+
private markerMeshes;
|
|
16
|
+
private previewMesh;
|
|
17
|
+
private previewMaterial;
|
|
18
|
+
private pointerObserver;
|
|
19
|
+
private gizmoObserver;
|
|
20
|
+
onStateChanged?: () => void;
|
|
21
|
+
constructor(service: MeshEditorService);
|
|
22
|
+
get activePath(): PathExtrusionItem | null;
|
|
23
|
+
getActivePathway(): PathExtrusionItem | undefined;
|
|
24
|
+
getActivePathwayIndex(): number;
|
|
25
|
+
selectPathwayIndex(index: number): void;
|
|
26
|
+
initDefaultPath(): void;
|
|
27
|
+
initDefaultPathway(): void;
|
|
28
|
+
setActive(active: boolean): void;
|
|
29
|
+
selectPath(id: string): void;
|
|
30
|
+
selectPathway(id: string): void;
|
|
31
|
+
addNewPath(name?: string): PathExtrusionItem;
|
|
32
|
+
addNewPathway(name?: string): PathExtrusionItem;
|
|
33
|
+
deletePath(id: string): void;
|
|
34
|
+
deletePathway(id: string): void;
|
|
35
|
+
deleteActivePathway(): void;
|
|
36
|
+
duplicatePath(id: string): PathExtrusionItem | null;
|
|
37
|
+
duplicatePathway(id: string): PathExtrusionItem | null;
|
|
38
|
+
duplicateActivePathway(): PathExtrusionItem | null;
|
|
39
|
+
addPoint(pos: Vector3): void;
|
|
40
|
+
removeSelectedPoint(): void;
|
|
41
|
+
clearPoints(): void;
|
|
42
|
+
updateShapeConfig(config: Partial<ShapeConfig>): void;
|
|
43
|
+
rebuildActivePathway(): void;
|
|
44
|
+
rebuildAll(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Bakes the current path extrusion into a permanent scene mesh.
|
|
47
|
+
*/
|
|
48
|
+
bakeMesh(pathId?: string): Mesh | null;
|
|
49
|
+
refreshScene(): void;
|
|
50
|
+
private clearMarkers;
|
|
51
|
+
private rebuildMarkers;
|
|
52
|
+
updatePreviewMesh(): void;
|
|
53
|
+
private setupPointerEvents;
|
|
54
|
+
private setupGizmoEvents;
|
|
55
|
+
private cleanupObservers;
|
|
56
|
+
exportState(): PathExtrusionItem[];
|
|
57
|
+
loadState(items: PathExtrusionItem[]): void;
|
|
58
|
+
clear(): void;
|
|
59
|
+
}
|