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,59 @@
|
|
|
1
|
+
import { Mesh } from '@babylonjs/core';
|
|
2
|
+
export interface BevelModifierOptions {
|
|
3
|
+
/** Bevel width / radius in world units (0 = disabled, e.g. 0.01 to 0.5) */
|
|
4
|
+
width: number;
|
|
5
|
+
/** Number of bevel segments (1 = flat chamfer, 2..4 = rounded fillet) */
|
|
6
|
+
segments: number;
|
|
7
|
+
/** Minimum dihedral angle in degrees between adjacent faces to consider an edge sharp (default 30) */
|
|
8
|
+
angleThresholdDeg?: number;
|
|
9
|
+
/** Whether non-destructive base geometry should be preserved on the mesh */
|
|
10
|
+
nonDestructive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SerializedVertexSnapshot {
|
|
13
|
+
positions: number[];
|
|
14
|
+
indices: number[];
|
|
15
|
+
normals?: number[];
|
|
16
|
+
uvs?: number[];
|
|
17
|
+
colors?: number[];
|
|
18
|
+
subMeshes?: Array<{
|
|
19
|
+
materialIndex: number;
|
|
20
|
+
verticesStart: number;
|
|
21
|
+
verticesCount: number;
|
|
22
|
+
indexStart: number;
|
|
23
|
+
indexCount: number;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
26
|
+
export interface NonDestructiveCSGMetadata {
|
|
27
|
+
isNonDestructive: boolean;
|
|
28
|
+
operation?: 'subtract' | 'union' | 'intersect' | 'bevel_only';
|
|
29
|
+
targetMeshName?: string;
|
|
30
|
+
toolMeshName?: string;
|
|
31
|
+
/** Snapshot of the original target mesh before the boolean / modifier */
|
|
32
|
+
originalTargetSnapshot?: SerializedVertexSnapshot;
|
|
33
|
+
/** Snapshot of the un-beveled boolean result (or original mesh if bevel_only) */
|
|
34
|
+
unbeveledBaseSnapshot: SerializedVertexSnapshot;
|
|
35
|
+
/** Active bevel modifier parameters */
|
|
36
|
+
bevel: {
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
width: number;
|
|
39
|
+
segments: number;
|
|
40
|
+
angleThresholdDeg: number;
|
|
41
|
+
sharpEdgeCount: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Captures a serializable deep copy of a mesh's VertexData and SubMesh layout.
|
|
46
|
+
*/
|
|
47
|
+
export declare function captureMeshSnapshot(mesh: Mesh): SerializedVertexSnapshot;
|
|
48
|
+
/**
|
|
49
|
+
* Restores a captured VertexData and SubMesh snapshot onto a target mesh in-place.
|
|
50
|
+
*/
|
|
51
|
+
export declare function restoreMeshSnapshot(mesh: Mesh, snapshot: SerializedVertexSnapshot): void;
|
|
52
|
+
/**
|
|
53
|
+
* Computes topological sharp edges and applies a non-destructive Chamfer / Fillet Bevel modifier
|
|
54
|
+
* to a mesh snapshot, returning a new SerializedVertexSnapshot and the detected sharpEdgeCount.
|
|
55
|
+
*/
|
|
56
|
+
export declare function computeBeveledSnapshot(baseSnapshot: SerializedVertexSnapshot, options: BevelModifierOptions): {
|
|
57
|
+
snapshot: SerializedVertexSnapshot;
|
|
58
|
+
sharpEdgeCount: number;
|
|
59
|
+
};
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { SubMesh, Vector3, VertexBuffer, VertexData, } from '@babylonjs/core';
|
|
2
|
+
/**
|
|
3
|
+
* Captures a serializable deep copy of a mesh's VertexData and SubMesh layout.
|
|
4
|
+
*/
|
|
5
|
+
export function captureMeshSnapshot(mesh) {
|
|
6
|
+
const positions = Array.from(mesh.getVerticesData(VertexBuffer.PositionKind) || []);
|
|
7
|
+
const indices = Array.from(mesh.getIndices() || []);
|
|
8
|
+
const normalsRaw = mesh.getVerticesData(VertexBuffer.NormalKind);
|
|
9
|
+
const uvsRaw = mesh.getVerticesData(VertexBuffer.UVKind);
|
|
10
|
+
const colorsRaw = mesh.getVerticesData(VertexBuffer.ColorKind);
|
|
11
|
+
const subMeshes = mesh.subMeshes && mesh.subMeshes.length > 0
|
|
12
|
+
? mesh.subMeshes.map((sm) => ({
|
|
13
|
+
materialIndex: sm.materialIndex,
|
|
14
|
+
verticesStart: sm.verticesStart,
|
|
15
|
+
verticesCount: sm.verticesCount,
|
|
16
|
+
indexStart: sm.indexStart,
|
|
17
|
+
indexCount: sm.indexCount,
|
|
18
|
+
}))
|
|
19
|
+
: undefined;
|
|
20
|
+
return {
|
|
21
|
+
positions,
|
|
22
|
+
indices,
|
|
23
|
+
normals: normalsRaw ? Array.from(normalsRaw) : undefined,
|
|
24
|
+
uvs: uvsRaw ? Array.from(uvsRaw) : undefined,
|
|
25
|
+
colors: colorsRaw ? Array.from(colorsRaw) : undefined,
|
|
26
|
+
subMeshes,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Restores a captured VertexData and SubMesh snapshot onto a target mesh in-place.
|
|
31
|
+
*/
|
|
32
|
+
export function restoreMeshSnapshot(mesh, snapshot) {
|
|
33
|
+
const vd = new VertexData();
|
|
34
|
+
vd.positions = snapshot.positions.slice();
|
|
35
|
+
vd.indices = snapshot.indices.slice();
|
|
36
|
+
if (snapshot.normals && snapshot.normals.length === snapshot.positions.length) {
|
|
37
|
+
vd.normals = snapshot.normals.slice();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const computedNormals = [];
|
|
41
|
+
VertexData.ComputeNormals(vd.positions, vd.indices, computedNormals);
|
|
42
|
+
vd.normals = computedNormals;
|
|
43
|
+
}
|
|
44
|
+
if (snapshot.uvs && snapshot.uvs.length === (snapshot.positions.length / 3) * 2) {
|
|
45
|
+
vd.uvs = snapshot.uvs.slice();
|
|
46
|
+
}
|
|
47
|
+
if (snapshot.colors && snapshot.colors.length === (snapshot.positions.length / 3) * 4) {
|
|
48
|
+
vd.colors = snapshot.colors.slice();
|
|
49
|
+
}
|
|
50
|
+
vd.applyToMesh(mesh, true);
|
|
51
|
+
if (snapshot.subMeshes && snapshot.subMeshes.length > 1) {
|
|
52
|
+
mesh.subMeshes = [];
|
|
53
|
+
for (const sm of snapshot.subMeshes) {
|
|
54
|
+
new SubMesh(sm.materialIndex, sm.verticesStart, sm.verticesCount, sm.indexStart, sm.indexCount, mesh);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
mesh.refreshBoundingInfo();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Computes topological sharp edges and applies a non-destructive Chamfer / Fillet Bevel modifier
|
|
61
|
+
* to a mesh snapshot, returning a new SerializedVertexSnapshot and the detected sharpEdgeCount.
|
|
62
|
+
*/
|
|
63
|
+
export function computeBeveledSnapshot(baseSnapshot, options) {
|
|
64
|
+
const width = Math.max(0, Math.min(options.width || 0, 1.0));
|
|
65
|
+
const segments = Math.max(1, Math.min(Math.round(options.segments || 1), 4));
|
|
66
|
+
const angleThresholdDeg = options.angleThresholdDeg ?? 30;
|
|
67
|
+
if (width <= 0.0001 || baseSnapshot.positions.length < 9 || baseSnapshot.indices.length < 3) {
|
|
68
|
+
return {
|
|
69
|
+
snapshot: {
|
|
70
|
+
positions: baseSnapshot.positions.slice(),
|
|
71
|
+
indices: baseSnapshot.indices.slice(),
|
|
72
|
+
normals: baseSnapshot.normals ? baseSnapshot.normals.slice() : undefined,
|
|
73
|
+
uvs: baseSnapshot.uvs ? baseSnapshot.uvs.slice() : undefined,
|
|
74
|
+
colors: baseSnapshot.colors ? baseSnapshot.colors.slice() : undefined,
|
|
75
|
+
subMeshes: baseSnapshot.subMeshes ? baseSnapshot.subMeshes.map((s) => ({ ...s })) : undefined,
|
|
76
|
+
},
|
|
77
|
+
sharpEdgeCount: 0,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
// Step 1: Weld spatial vertices to build topological connectivity
|
|
81
|
+
const pos = baseSnapshot.positions;
|
|
82
|
+
const ind = baseSnapshot.indices;
|
|
83
|
+
const uvs = baseSnapshot.uvs;
|
|
84
|
+
const colors = baseSnapshot.colors;
|
|
85
|
+
const quantScale = 10000;
|
|
86
|
+
const canonMap = new Map();
|
|
87
|
+
const canonPositions = [];
|
|
88
|
+
const vertToCanon = new Int32Array(pos.length / 3);
|
|
89
|
+
for (let i = 0; i < pos.length / 3; i++) {
|
|
90
|
+
const x = pos[i * 3];
|
|
91
|
+
const y = pos[i * 3 + 1];
|
|
92
|
+
const z = pos[i * 3 + 2];
|
|
93
|
+
const key = `${Math.round(x * quantScale)},${Math.round(y * quantScale)},${Math.round(z * quantScale)}`;
|
|
94
|
+
let cIdx = canonMap.get(key);
|
|
95
|
+
if (cIdx === undefined) {
|
|
96
|
+
cIdx = canonPositions.length;
|
|
97
|
+
canonMap.set(key, cIdx);
|
|
98
|
+
canonPositions.push(new Vector3(x, y, z));
|
|
99
|
+
}
|
|
100
|
+
vertToCanon[i] = cIdx;
|
|
101
|
+
}
|
|
102
|
+
const numTris = Math.floor(ind.length / 3);
|
|
103
|
+
const faceNormals = new Array(numTris);
|
|
104
|
+
const faceCenters = new Array(numTris);
|
|
105
|
+
const edgeToFaces = new Map();
|
|
106
|
+
const makeEdgeKey = (a, b) => (a < b ? `${a}_${b}` : `${b}_${a}`);
|
|
107
|
+
for (let f = 0; f < numTris; f++) {
|
|
108
|
+
const i0 = ind[f * 3];
|
|
109
|
+
const i1 = ind[f * 3 + 1];
|
|
110
|
+
const i2 = ind[f * 3 + 2];
|
|
111
|
+
const c0 = vertToCanon[i0];
|
|
112
|
+
const c1 = vertToCanon[i1];
|
|
113
|
+
const c2 = vertToCanon[i2];
|
|
114
|
+
const p0 = canonPositions[c0];
|
|
115
|
+
const p1 = canonPositions[c1];
|
|
116
|
+
const p2 = canonPositions[c2];
|
|
117
|
+
const e1 = p1.subtract(p0);
|
|
118
|
+
const e2 = p2.subtract(p0);
|
|
119
|
+
const n = Vector3.Cross(e1, e2);
|
|
120
|
+
if (n.lengthSquared() > 1e-12) {
|
|
121
|
+
n.normalize();
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
n.set(0, 1, 0);
|
|
125
|
+
}
|
|
126
|
+
faceNormals[f] = n;
|
|
127
|
+
faceCenters[f] = p0.add(p1).add(p2).scaleInPlace(1 / 3);
|
|
128
|
+
if (c0 !== c1 && c1 !== c2 && c2 !== c0) {
|
|
129
|
+
const k01 = makeEdgeKey(c0, c1);
|
|
130
|
+
const k12 = makeEdgeKey(c1, c2);
|
|
131
|
+
const k20 = makeEdgeKey(c2, c0);
|
|
132
|
+
if (!edgeToFaces.has(k01))
|
|
133
|
+
edgeToFaces.set(k01, []);
|
|
134
|
+
if (!edgeToFaces.has(k12))
|
|
135
|
+
edgeToFaces.set(k12, []);
|
|
136
|
+
if (!edgeToFaces.has(k20))
|
|
137
|
+
edgeToFaces.set(k20, []);
|
|
138
|
+
edgeToFaces.get(k01).push(f);
|
|
139
|
+
edgeToFaces.get(k12).push(f);
|
|
140
|
+
edgeToFaces.get(k20).push(f);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Step 2: Detect sharp edges based on dihedral angle threshold
|
|
144
|
+
const cosThreshold = Math.cos((angleThresholdDeg * Math.PI) / 180);
|
|
145
|
+
const sharpEdges = new Set();
|
|
146
|
+
const sharpCanonVerts = new Set();
|
|
147
|
+
const canonAdjSharpNormals = new Map();
|
|
148
|
+
for (const [edgeKey, faces] of edgeToFaces.entries()) {
|
|
149
|
+
if (faces.length >= 2) {
|
|
150
|
+
const nA = faceNormals[faces[0]];
|
|
151
|
+
const nB = faceNormals[faces[1]];
|
|
152
|
+
const dot = Vector3.Dot(nA, nB);
|
|
153
|
+
if (dot <= cosThreshold) {
|
|
154
|
+
sharpEdges.add(edgeKey);
|
|
155
|
+
const [aStr, bStr] = edgeKey.split('_');
|
|
156
|
+
const ca = Number(aStr);
|
|
157
|
+
const cb = Number(bStr);
|
|
158
|
+
sharpCanonVerts.add(ca);
|
|
159
|
+
sharpCanonVerts.add(cb);
|
|
160
|
+
if (!canonAdjSharpNormals.has(ca))
|
|
161
|
+
canonAdjSharpNormals.set(ca, []);
|
|
162
|
+
if (!canonAdjSharpNormals.has(cb))
|
|
163
|
+
canonAdjSharpNormals.set(cb, []);
|
|
164
|
+
canonAdjSharpNormals.get(ca).push(nA, nB);
|
|
165
|
+
canonAdjSharpNormals.get(cb).push(nA, nB);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const sharpEdgeCount = sharpEdges.size;
|
|
170
|
+
if (sharpEdgeCount === 0) {
|
|
171
|
+
return {
|
|
172
|
+
snapshot: {
|
|
173
|
+
positions: baseSnapshot.positions.slice(),
|
|
174
|
+
indices: baseSnapshot.indices.slice(),
|
|
175
|
+
normals: baseSnapshot.normals ? baseSnapshot.normals.slice() : undefined,
|
|
176
|
+
uvs: baseSnapshot.uvs ? baseSnapshot.uvs.slice() : undefined,
|
|
177
|
+
colors: baseSnapshot.colors ? baseSnapshot.colors.slice() : undefined,
|
|
178
|
+
subMeshes: baseSnapshot.subMeshes ? baseSnapshot.subMeshes.map((s) => ({ ...s })) : undefined,
|
|
179
|
+
},
|
|
180
|
+
sharpEdgeCount: 0,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
// Step 3: Build chamfered / beveled geometry along sharp edges & corners
|
|
184
|
+
// For each face that touches at least one sharp edge or sharp vertex, we inset its corner vertices
|
|
185
|
+
// slightly toward the face center and bridge the chamfer gap with smooth fillet strips!
|
|
186
|
+
const outPositions = [];
|
|
187
|
+
const outNormals = [];
|
|
188
|
+
const outUVs = [];
|
|
189
|
+
const outColors = [];
|
|
190
|
+
const outIndices = [];
|
|
191
|
+
const hasUVs = !!(uvs && uvs.length >= (pos.length / 3) * 2);
|
|
192
|
+
const hasColors = !!(colors && colors.length >= (pos.length / 3) * 4);
|
|
193
|
+
// Compute average sharp normal per canonical vertex for smooth fillet normal blending
|
|
194
|
+
const canonSmoothNormal = new Map();
|
|
195
|
+
for (const [cIdx, nList] of canonAdjSharpNormals.entries()) {
|
|
196
|
+
const avg = new Vector3(0, 0, 0);
|
|
197
|
+
for (const n of nList)
|
|
198
|
+
avg.addInPlace(n);
|
|
199
|
+
if (avg.lengthSquared() > 1e-8) {
|
|
200
|
+
avg.normalize();
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
avg.set(0, 1, 0);
|
|
204
|
+
}
|
|
205
|
+
canonSmoothNormal.set(cIdx, avg);
|
|
206
|
+
}
|
|
207
|
+
// Compute canonical vertex neighbor centroids along sharp edges for tangential rounding
|
|
208
|
+
const canonNeighbors = new Map();
|
|
209
|
+
for (const edgeKey of sharpEdges) {
|
|
210
|
+
const [aStr, bStr] = edgeKey.split('_');
|
|
211
|
+
const ca = Number(aStr);
|
|
212
|
+
const cb = Number(bStr);
|
|
213
|
+
if (!canonNeighbors.has(ca))
|
|
214
|
+
canonNeighbors.set(ca, new Set());
|
|
215
|
+
if (!canonNeighbors.has(cb))
|
|
216
|
+
canonNeighbors.set(cb, new Set());
|
|
217
|
+
canonNeighbors.get(ca).add(cb);
|
|
218
|
+
canonNeighbors.get(cb).add(ca);
|
|
219
|
+
}
|
|
220
|
+
const pushVertex = (p, n, u, v, r, g, b, a) => {
|
|
221
|
+
const idx = outPositions.length / 3;
|
|
222
|
+
outPositions.push(p.x, p.y, p.z);
|
|
223
|
+
outNormals.push(n.x, n.y, n.z);
|
|
224
|
+
if (hasUVs)
|
|
225
|
+
outUVs.push(u, v);
|
|
226
|
+
if (hasColors)
|
|
227
|
+
outColors.push(r, g, b, a);
|
|
228
|
+
return idx;
|
|
229
|
+
};
|
|
230
|
+
for (let f = 0; f < numTris; f++) {
|
|
231
|
+
const i0 = ind[f * 3];
|
|
232
|
+
const i1 = ind[f * 3 + 1];
|
|
233
|
+
const i2 = ind[f * 3 + 2];
|
|
234
|
+
const origVerts = [i0, i1, i2];
|
|
235
|
+
const cVerts = [vertToCanon[i0], vertToCanon[i1], vertToCanon[i2]];
|
|
236
|
+
const fNormal = faceNormals[f];
|
|
237
|
+
const fCenter = faceCenters[f];
|
|
238
|
+
const touchesSharp = sharpCanonVerts.has(cVerts[0]) ||
|
|
239
|
+
sharpCanonVerts.has(cVerts[1]) ||
|
|
240
|
+
sharpCanonVerts.has(cVerts[2]);
|
|
241
|
+
const getUV = (vi) => hasUVs ? [uvs[vi * 2], uvs[vi * 2 + 1]] : [0, 0];
|
|
242
|
+
const getCol = (vi) => hasColors
|
|
243
|
+
? [colors[vi * 4], colors[vi * 4 + 1], colors[vi * 4 + 2], colors[vi * 4 + 3]]
|
|
244
|
+
: [1, 1, 1, 1];
|
|
245
|
+
if (!touchesSharp) {
|
|
246
|
+
const newTri = [];
|
|
247
|
+
for (let k = 0; k < 3; k++) {
|
|
248
|
+
const vi = origVerts[k];
|
|
249
|
+
const p = new Vector3(pos[vi * 3], pos[vi * 3 + 1], pos[vi * 3 + 2]);
|
|
250
|
+
const [u, v] = getUV(vi);
|
|
251
|
+
const [r, g, b, a] = getCol(vi);
|
|
252
|
+
newTri.push(pushVertex(p, fNormal, u, v, r, g, b, a));
|
|
253
|
+
}
|
|
254
|
+
outIndices.push(newTri[0], newTri[1], newTri[2]);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
// Face touches at least one sharp edge:
|
|
258
|
+
// Create inset inner triangle + N-segment rounded bevel transition rings to the shared sharp boundary
|
|
259
|
+
const ringCount = segments;
|
|
260
|
+
const rings = [];
|
|
261
|
+
// Ring 0 = outer boundary (smoothed onto the fillet crest)
|
|
262
|
+
// Ring `ringCount` = inner flat face boundary
|
|
263
|
+
for (let s = 0; s <= ringCount; s++) {
|
|
264
|
+
const t = s / ringCount; // 0 = outer crest, 1 = inner flat face
|
|
265
|
+
const ringIndices = [];
|
|
266
|
+
for (let k = 0; k < 3; k++) {
|
|
267
|
+
const vi = origVerts[k];
|
|
268
|
+
const cIdx = cVerts[k];
|
|
269
|
+
const baseP = canonPositions[cIdx];
|
|
270
|
+
const [u0, v0] = getUV(vi);
|
|
271
|
+
const [r, g, b, a] = getCol(vi);
|
|
272
|
+
if (!sharpCanonVerts.has(cIdx)) {
|
|
273
|
+
// Non-sharp vertex stays anchored on the flat face
|
|
274
|
+
ringIndices.push(pushVertex(baseP, fNormal, u0, v0, r, g, b, a));
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
const smoothN = canonSmoothNormal.get(cIdx) || fNormal;
|
|
278
|
+
const toCenter = fCenter.subtract(baseP);
|
|
279
|
+
const edgeLen = toCenter.length();
|
|
280
|
+
const maxInset = Math.min(width, edgeLen * 0.42);
|
|
281
|
+
const insetDir = edgeLen > 1e-6 ? toCenter.scale(1 / edgeLen) : new Vector3(0, 0, 0);
|
|
282
|
+
// Compute neighbor-averaged crest point for smooth corner rounding
|
|
283
|
+
let crestP = baseP.subtract(smoothN.scale(maxInset * 0.32));
|
|
284
|
+
const nbrs = canonNeighbors.get(cIdx);
|
|
285
|
+
if (nbrs && nbrs.size > 0) {
|
|
286
|
+
const nbrAvg = new Vector3(0, 0, 0);
|
|
287
|
+
for (const nIdx of nbrs) {
|
|
288
|
+
nbrAvg.addInPlace(canonPositions[nIdx]);
|
|
289
|
+
}
|
|
290
|
+
nbrAvg.scaleInPlace(1 / nbrs.size);
|
|
291
|
+
crestP = Vector3.Lerp(crestP, nbrAvg, Math.min(0.35, width * 0.8));
|
|
292
|
+
}
|
|
293
|
+
// Inner point on the flat face
|
|
294
|
+
const innerP = baseP.add(insetDir.scale(maxInset));
|
|
295
|
+
// Circular arc / quadratic Bezier interpolation between crestP (s=0) and innerP (s=1)
|
|
296
|
+
// Control point is baseP lifted slightly along blended normal for rounded fillet profile
|
|
297
|
+
const filletLift = segments > 1 ? Math.sin(t * Math.PI) * maxInset * 0.22 : 0;
|
|
298
|
+
const blendedN = Vector3.Lerp(smoothN, fNormal, t).normalize();
|
|
299
|
+
const posOnArc = Vector3.Lerp(crestP, innerP, t).addInPlace(blendedN.scale(filletLift));
|
|
300
|
+
// Interpolate UV slightly toward face UV centroid
|
|
301
|
+
const [uc0, vc0] = getUV(origVerts[0]);
|
|
302
|
+
const [uc1, vc1] = getUV(origVerts[1]);
|
|
303
|
+
const [uc2, vc2] = getUV(origVerts[2]);
|
|
304
|
+
const uCenter = (uc0 + uc1 + uc2) / 3;
|
|
305
|
+
const vCenter = (vc0 + vc1 + vc2) / 3;
|
|
306
|
+
const uvInsetFactor = edgeLen > 1e-6 ? (maxInset / edgeLen) * t * 0.5 : 0;
|
|
307
|
+
const u = u0 + (uCenter - u0) * uvInsetFactor;
|
|
308
|
+
const v = v0 + (vCenter - v0) * uvInsetFactor;
|
|
309
|
+
ringIndices.push(pushVertex(posOnArc, blendedN, u, v, r, g, b, a));
|
|
310
|
+
}
|
|
311
|
+
rings.push(ringIndices);
|
|
312
|
+
}
|
|
313
|
+
// Stitch consecutive rings with quad strips (2 triangles per edge per ring step)
|
|
314
|
+
for (let s = 0; s < ringCount; s++) {
|
|
315
|
+
const outerRing = rings[s];
|
|
316
|
+
const innerRing = rings[s + 1];
|
|
317
|
+
for (let k = 0; k < 3; k++) {
|
|
318
|
+
const kNext = (k + 1) % 3;
|
|
319
|
+
const o0 = outerRing[k];
|
|
320
|
+
const o1 = outerRing[kNext];
|
|
321
|
+
const in0 = innerRing[k];
|
|
322
|
+
const in1 = innerRing[kNext];
|
|
323
|
+
if (o0 !== in0 || o1 !== in1) {
|
|
324
|
+
outIndices.push(o0, o1, in1);
|
|
325
|
+
outIndices.push(o0, in1, in0);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
// Emit the innermost flat triangle
|
|
330
|
+
const coreRing = rings[ringCount];
|
|
331
|
+
outIndices.push(coreRing[0], coreRing[1], coreRing[2]);
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
snapshot: {
|
|
335
|
+
positions: outPositions,
|
|
336
|
+
indices: outIndices,
|
|
337
|
+
normals: outNormals,
|
|
338
|
+
uvs: hasUVs ? outUVs : undefined,
|
|
339
|
+
colors: hasColors ? outColors : undefined,
|
|
340
|
+
// Single unified geometry buffer after beveling
|
|
341
|
+
subMeshes: undefined,
|
|
342
|
+
},
|
|
343
|
+
sharpEdgeCount,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Material, Mesh, Vector3 } from '@babylonjs/core';
|
|
2
|
+
export interface FacetCornerUV {
|
|
3
|
+
vertexIndex: number;
|
|
4
|
+
u: number;
|
|
5
|
+
v: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FacetUVInfo {
|
|
8
|
+
faceIds: number[];
|
|
9
|
+
isQuad: boolean;
|
|
10
|
+
corners: FacetCornerUV[];
|
|
11
|
+
uMin: number;
|
|
12
|
+
uMax: number;
|
|
13
|
+
vMin: number;
|
|
14
|
+
vMax: number;
|
|
15
|
+
hasUVs: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface FacetMaterialInfo {
|
|
18
|
+
materialIndex: number;
|
|
19
|
+
material: Material | null;
|
|
20
|
+
materialName: string;
|
|
21
|
+
totalSlots: number;
|
|
22
|
+
subMeshIndex: number;
|
|
23
|
+
}
|
|
24
|
+
export interface SubMeshDescriptor {
|
|
25
|
+
materialIndex: number;
|
|
26
|
+
verticesStart: number;
|
|
27
|
+
verticesCount: number;
|
|
28
|
+
indexStart: number;
|
|
29
|
+
indexCount: number;
|
|
30
|
+
}
|
|
31
|
+
export interface MeshSurfaceSnapshot {
|
|
32
|
+
buffers: Record<string, number[]>;
|
|
33
|
+
indices: number[];
|
|
34
|
+
material: Material | null;
|
|
35
|
+
multiSubMaterials?: (Material | null)[];
|
|
36
|
+
subMeshes: SubMeshDescriptor[];
|
|
37
|
+
}
|
|
38
|
+
export interface FacetUVProjectionOptions {
|
|
39
|
+
uMin?: number;
|
|
40
|
+
uMax?: number;
|
|
41
|
+
vMin?: number;
|
|
42
|
+
vMax?: number;
|
|
43
|
+
scaleU?: number;
|
|
44
|
+
scaleV?: number;
|
|
45
|
+
offsetU?: number;
|
|
46
|
+
offsetV?: number;
|
|
47
|
+
rotationDeg?: number;
|
|
48
|
+
flipU?: boolean;
|
|
49
|
+
flipV?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface FacetUVTransformOptions {
|
|
52
|
+
rotateDeg?: number;
|
|
53
|
+
flipU?: boolean;
|
|
54
|
+
flipV?: boolean;
|
|
55
|
+
scaleU?: number;
|
|
56
|
+
scaleV?: number;
|
|
57
|
+
offsetU?: number;
|
|
58
|
+
offsetV?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Captures a complete geometry, UV, material, and SubMesh snapshot for Undo/Redo.
|
|
62
|
+
*/
|
|
63
|
+
export declare function captureMeshSurfaceSnapshot(mesh: Mesh): MeshSurfaceSnapshot;
|
|
64
|
+
/**
|
|
65
|
+
* Restores a previously captured geometry, UV, material, and SubMesh snapshot.
|
|
66
|
+
*/
|
|
67
|
+
export declare function restoreMeshSurfaceSnapshot(mesh: Mesh, snap: MeshSurfaceSnapshot): void;
|
|
68
|
+
/**
|
|
69
|
+
* Returns the SubMesh materialIndex per triangle for the given mesh.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getFaceTriangleMaterialIndices(mesh: Mesh): number[];
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the SubMesh slot and active Material assigned to a specific triangle faceId.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getFacetMaterialInfo(mesh: Mesh, faceId: number): FacetMaterialInfo;
|
|
76
|
+
/**
|
|
77
|
+
* Resolves the active material list indexed by slot on the mesh.
|
|
78
|
+
*/
|
|
79
|
+
export declare function getMeshSlotMaterials(mesh: Mesh): (Material | null)[];
|
|
80
|
+
/**
|
|
81
|
+
* Rebuilds mesh indices and SubMeshes grouped by material slot, compacting unused slots
|
|
82
|
+
* and collapsing back to a single Material when only one material remains.
|
|
83
|
+
*/
|
|
84
|
+
export declare function rebuildMeshSubMeshes(mesh: Mesh, triMaterials: number[], slotMaterials: (Material | null)[], preserveSingleOrder?: boolean): {
|
|
85
|
+
faceIdMap: Int32Array;
|
|
86
|
+
collapsedToSingle: boolean;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Ensures any vertices shared between targetFaceIds and other faces are duplicated
|
|
90
|
+
* so facet-level UV modifications never distort neighboring faces.
|
|
91
|
+
* Also initializes UVKind if missing on the mesh.
|
|
92
|
+
*/
|
|
93
|
+
export declare function isolateFacetVertices(mesh: Mesh, targetFaceIds: number[]): void;
|
|
94
|
+
/**
|
|
95
|
+
* Computes an orthonormal tangent/bitangent basis on a facet plane from its outward normal.
|
|
96
|
+
*/
|
|
97
|
+
export declare function computeFacetLocalBasis(normal: Vector3): {
|
|
98
|
+
tangentU: Vector3;
|
|
99
|
+
bitangentV: Vector3;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Reads corner UVs and overall UV bounds for a target triangle or quad facet.
|
|
103
|
+
*/
|
|
104
|
+
export declare function getFacetUVInfo(mesh: Mesh, faceIds: number[], orderedCornerPositions: Vector3[], isQuad: boolean): FacetUVInfo | null;
|
|
105
|
+
/**
|
|
106
|
+
* Projects UV coordinates onto a facet using either normalized '[0..1]' Fit or world-scale Planar mapping.
|
|
107
|
+
*/
|
|
108
|
+
export declare function applyFacetUVProjection(mesh: Mesh, faceIds: number[], normal: Vector3, mode: 'fit' | 'planar', options?: FacetUVProjectionOptions): void;
|
|
109
|
+
/**
|
|
110
|
+
* Remaps the facet's existing UV bounding box (or planar fit if degenerate) into [targetUMin..targetUMax, targetVMin..targetVMax].
|
|
111
|
+
*/
|
|
112
|
+
export declare function remapFacetUVRect(mesh: Mesh, faceIds: number[], normal: Vector3, targetUMin: number, targetUMax: number, targetVMin: number, targetVMax: number): void;
|
|
113
|
+
/**
|
|
114
|
+
* Applies rotation, flip, scale, or offset transforms to a facet's isolated UVs around its UV center.
|
|
115
|
+
*/
|
|
116
|
+
export declare function transformFacetUVs(mesh: Mesh, faceIds: number[], options: FacetUVTransformOptions): void;
|
|
117
|
+
/**
|
|
118
|
+
* Sets explicit UV coordinates for each ordered corner of the target facet.
|
|
119
|
+
*/
|
|
120
|
+
export declare function setFacetCornerUVs(mesh: Mesh, faceIds: number[], cornerPositions: Vector3[], cornerUVs: Array<{
|
|
121
|
+
u: number;
|
|
122
|
+
v: number;
|
|
123
|
+
}>): void;
|
|
124
|
+
/**
|
|
125
|
+
* Ensures a mesh has a valid base material before multi-material splitting.
|
|
126
|
+
*/
|
|
127
|
+
export declare function ensureBaseMaterial(mesh: Mesh): Material;
|