mesheditor 0.0.0-stage → 1.0.2
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 +107 -0
- package/dist-lib/esm/AIAgentService.d.ts.map +1 -0
- package/dist-lib/esm/AIAgentService.js +1471 -0
- package/dist-lib/esm/AIAgentService.js.map +1 -0
- package/dist-lib/esm/MeshEditorApp.d.ts +413 -0
- package/dist-lib/esm/MeshEditorApp.d.ts.map +1 -0
- package/dist-lib/esm/MeshEditorApp.js +9093 -0
- package/dist-lib/esm/MeshEditorApp.js.map +1 -0
- package/dist-lib/esm/MeshEditorService.d.ts +460 -0
- package/dist-lib/esm/MeshEditorService.d.ts.map +1 -0
- package/dist-lib/esm/MeshEditorService.js +7084 -0
- package/dist-lib/esm/MeshEditorService.js.map +1 -0
- package/dist-lib/esm/Neural3DGeneratorService.d.ts +89 -0
- package/dist-lib/esm/Neural3DGeneratorService.d.ts.map +1 -0
- package/dist-lib/esm/Neural3DGeneratorService.js +1398 -0
- package/dist-lib/esm/Neural3DGeneratorService.js.map +1 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts +17 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.js +26 -0
- package/dist-lib/esm/adapters/BrowserPlatformAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts +33 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.js +337 -0
- package/dist-lib/esm/adapters/ElectronPlatformAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/HostAppAdapter.d.ts +55 -0
- package/dist-lib/esm/adapters/HostAppAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/HostAppAdapter.js +76 -0
- package/dist-lib/esm/adapters/HostAppAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/PlatformAdapter.d.ts +99 -0
- package/dist-lib/esm/adapters/PlatformAdapter.d.ts.map +1 -0
- package/dist-lib/esm/adapters/PlatformAdapter.js +2 -0
- package/dist-lib/esm/adapters/PlatformAdapter.js.map +1 -0
- package/dist-lib/esm/adapters/index.d.ts +14 -0
- package/dist-lib/esm/adapters/index.d.ts.map +1 -0
- package/dist-lib/esm/adapters/index.js +16 -0
- package/dist-lib/esm/adapters/index.js.map +1 -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 +85 -0
- package/dist-lib/esm/baking/TextureBaker.d.ts.map +1 -0
- package/dist-lib/esm/baking/TextureBaker.js +710 -0
- package/dist-lib/esm/baking/TextureBaker.js.map +1 -0
- package/dist-lib/esm/builtInSkills.d.ts +20 -0
- package/dist-lib/esm/builtInSkills.d.ts.map +1 -0
- package/dist-lib/esm/builtInSkills.js +187 -0
- package/dist-lib/esm/builtInSkills.js.map +1 -0
- package/dist-lib/esm/compression/ModelCompressor.d.ts +88 -0
- package/dist-lib/esm/compression/ModelCompressor.d.ts.map +1 -0
- package/dist-lib/esm/compression/ModelCompressor.js +554 -0
- package/dist-lib/esm/compression/ModelCompressor.js.map +1 -0
- package/dist-lib/esm/decals/DecalController.d.ts +148 -0
- package/dist-lib/esm/decals/DecalController.d.ts.map +1 -0
- package/dist-lib/esm/decals/DecalController.js +1032 -0
- package/dist-lib/esm/decals/DecalController.js.map +1 -0
- package/dist-lib/esm/decals/decalAssetUrls.d.ts +2 -0
- package/dist-lib/esm/decals/decalAssetUrls.d.ts.map +1 -0
- package/dist-lib/esm/decals/decalAssetUrls.js +17 -0
- package/dist-lib/esm/decals/decalAssetUrls.js.map +1 -0
- package/dist-lib/esm/geometry/architecture.d.ts +115 -0
- package/dist-lib/esm/geometry/architecture.d.ts.map +1 -0
- package/dist-lib/esm/geometry/architecture.js +832 -0
- package/dist-lib/esm/geometry/architecture.js.map +1 -0
- package/dist-lib/esm/geometry/bevelModifier.d.ts +60 -0
- package/dist-lib/esm/geometry/bevelModifier.d.ts.map +1 -0
- package/dist-lib/esm/geometry/bevelModifier.js +346 -0
- package/dist-lib/esm/geometry/bevelModifier.js.map +1 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts +128 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.d.ts.map +1 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.js +677 -0
- package/dist-lib/esm/geometry/facetSurfaceUtils.js.map +1 -0
- package/dist-lib/esm/geometry/roundedBox.d.ts +16 -0
- package/dist-lib/esm/geometry/roundedBox.d.ts.map +1 -0
- package/dist-lib/esm/geometry/roundedBox.js +134 -0
- package/dist-lib/esm/geometry/roundedBox.js.map +1 -0
- package/dist-lib/esm/index.d.ts +22 -0
- package/dist-lib/esm/index.d.ts.map +1 -0
- package/dist-lib/esm/index.js +51 -0
- package/dist-lib/esm/index.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts +60 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.js +484 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionController.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts +77 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js +1793 -0
- package/dist-lib/esm/pathExtrusion/PathExtrusionStudio.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.d.ts +96 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.js +628 -0
- package/dist-lib/esm/pathExtrusion/PathFactory.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/index.d.ts +5 -0
- package/dist-lib/esm/pathExtrusion/index.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/index.js +5 -0
- package/dist-lib/esm/pathExtrusion/index.js.map +1 -0
- package/dist-lib/esm/pathExtrusion/types.d.ts +51 -0
- package/dist-lib/esm/pathExtrusion/types.d.ts.map +1 -0
- package/dist-lib/esm/pathExtrusion/types.js +2 -0
- package/dist-lib/esm/pathExtrusion/types.js.map +1 -0
- package/dist-lib/esm/plugin.d.ts +251 -0
- package/dist-lib/esm/plugin.d.ts.map +1 -0
- package/dist-lib/esm/plugin.js +145 -0
- package/dist-lib/esm/plugin.js.map +1 -0
- package/dist-lib/esm/rigging/WeightPaintController.d.ts +163 -0
- package/dist-lib/esm/rigging/WeightPaintController.d.ts.map +1 -0
- package/dist-lib/esm/rigging/WeightPaintController.js +1422 -0
- package/dist-lib/esm/rigging/WeightPaintController.js.map +1 -0
- package/dist-lib/esm/sculpting/SculptController.d.ts +147 -0
- package/dist-lib/esm/sculpting/SculptController.d.ts.map +1 -0
- package/dist-lib/esm/sculpting/SculptController.js +2039 -0
- package/dist-lib/esm/sculpting/SculptController.js.map +1 -0
- package/dist-lib/esm/sdf/index.d.ts +3 -0
- package/dist-lib/esm/sdf/index.d.ts.map +1 -0
- package/dist-lib/esm/sdf/index.js +3 -0
- package/dist-lib/esm/sdf/index.js.map +1 -0
- package/dist-lib/esm/sdf/sdfPrimitives.d.ts +98 -0
- package/dist-lib/esm/sdf/sdfPrimitives.d.ts.map +1 -0
- package/dist-lib/esm/sdf/sdfPrimitives.js +403 -0
- package/dist-lib/esm/sdf/sdfPrimitives.js.map +1 -0
- package/dist-lib/esm/sdf/surfaceNets.d.ts +30 -0
- package/dist-lib/esm/sdf/surfaceNets.d.ts.map +1 -0
- package/dist-lib/esm/sdf/surfaceNets.js +400 -0
- package/dist-lib/esm/sdf/surfaceNets.js.map +1 -0
- package/dist-lib/esm/styles.d.ts +12 -0
- package/dist-lib/esm/styles.d.ts.map +1 -0
- package/dist-lib/esm/styles.js +33 -0
- package/dist-lib/esm/styles.js.map +1 -0
- package/dist-lib/esm/template.d.ts +13 -0
- package/dist-lib/esm/template.d.ts.map +1 -0
- package/dist-lib/esm/template.js +20 -0
- package/dist-lib/esm/template.js.map +1 -0
- package/dist-lib/esm/textMesh/TextMeshController.d.ts +62 -0
- package/dist-lib/esm/textMesh/TextMeshController.d.ts.map +1 -0
- package/dist-lib/esm/textMesh/TextMeshController.js +405 -0
- package/dist-lib/esm/textMesh/TextMeshController.js.map +1 -0
- package/dist-lib/esm/textures/AITextureGenerator.d.ts +120 -0
- package/dist-lib/esm/textures/AITextureGenerator.d.ts.map +1 -0
- package/dist-lib/esm/textures/AITextureGenerator.js +946 -0
- package/dist-lib/esm/textures/AITextureGenerator.js.map +1 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts +63 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.d.ts.map +1 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.js +880 -0
- package/dist-lib/esm/textures/ExternalImageGeneratorService.js.map +1 -0
- package/dist-lib/esm/tools/AbstractTool.d.ts +69 -0
- package/dist-lib/esm/tools/AbstractTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/AbstractTool.js +129 -0
- package/dist-lib/esm/tools/AbstractTool.js.map +1 -0
- package/dist-lib/esm/tools/ToolExecutionContext.d.ts +41 -0
- package/dist-lib/esm/tools/ToolExecutionContext.d.ts.map +1 -0
- package/dist-lib/esm/tools/ToolExecutionContext.js +2 -0
- package/dist-lib/esm/tools/ToolExecutionContext.js.map +1 -0
- package/dist-lib/esm/tools/ToolInterface.d.ts +105 -0
- package/dist-lib/esm/tools/ToolInterface.d.ts.map +1 -0
- package/dist-lib/esm/tools/ToolInterface.js +2 -0
- package/dist-lib/esm/tools/ToolInterface.js.map +1 -0
- package/dist-lib/esm/tools/ToolRegistry.d.ts +44 -0
- package/dist-lib/esm/tools/ToolRegistry.d.ts.map +1 -0
- package/dist-lib/esm/tools/ToolRegistry.js +116 -0
- package/dist-lib/esm/tools/ToolRegistry.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts +35 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js +49 -0
- package/dist-lib/esm/tools/builtin/ApplyMaterialTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts +35 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js +55 -0
- package/dist-lib/esm/tools/builtin/AutoUVMappingTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts +43 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.js +82 -0
- package/dist-lib/esm/tools/builtin/BakeTexturesTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts +52 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.js +87 -0
- package/dist-lib/esm/tools/builtin/BooleanOperationTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts +79 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js +171 -0
- package/dist-lib/esm/tools/builtin/BuildVoxelMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts +76 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.js +116 -0
- package/dist-lib/esm/tools/builtin/CloneArrayTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts +119 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.js +90 -0
- package/dist-lib/esm/tools/builtin/CreateArchTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts +115 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.js +106 -0
- package/dist-lib/esm/tools/builtin/CreateColumnTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.js +61 -0
- package/dist-lib/esm/tools/builtin/CreateLatheTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts +115 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.js +213 -0
- package/dist-lib/esm/tools/builtin/CreateMaterialTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts +121 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.js +96 -0
- package/dist-lib/esm/tools/builtin/CreateMoldingTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts +163 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js +303 -0
- package/dist-lib/esm/tools/builtin/CreatePrimitiveTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts +121 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.js +109 -0
- package/dist-lib/esm/tools/builtin/CreateRoofTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts +102 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js +80 -0
- package/dist-lib/esm/tools/builtin/CreateRoundedBoxTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts +225 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js +239 -0
- package/dist-lib/esm/tools/builtin/CreateSdfMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts +136 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.js +120 -0
- package/dist-lib/esm/tools/builtin/CreateStairsTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts +95 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js +132 -0
- package/dist-lib/esm/tools/builtin/CreateTextMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.js +60 -0
- package/dist-lib/esm/tools/builtin/CreateTubeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts +146 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.js +125 -0
- package/dist-lib/esm/tools/builtin/CreateWallTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/DecalTool.d.ts +77 -0
- package/dist-lib/esm/tools/builtin/DecalTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/DecalTool.js +144 -0
- package/dist-lib/esm/tools/builtin/DecalTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts +21 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.js +43 -0
- package/dist-lib/esm/tools/builtin/DeleteMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts +22 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js +96 -0
- package/dist-lib/esm/tools/builtin/ExecuteBabylonCodeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts +115 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js +77 -0
- package/dist-lib/esm/tools/builtin/ExtrudePolygonTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts +105 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js +69 -0
- package/dist-lib/esm/tools/builtin/ExtrudeShapeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts +37 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.js +58 -0
- package/dist-lib/esm/tools/builtin/FacetArcTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts +31 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js +50 -0
- package/dist-lib/esm/tools/builtin/FacetCutThroughTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts +31 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js +50 -0
- package/dist-lib/esm/tools/builtin/FacetExtrudeTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts +35 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.js +56 -0
- package/dist-lib/esm/tools/builtin/FacetInsetTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts +132 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js +456 -0
- package/dist-lib/esm/tools/builtin/GenerateNeuralMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.js +217 -0
- package/dist-lib/esm/tools/builtin/GenerateTextureTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts +12 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js +13 -0
- package/dist-lib/esm/tools/builtin/GetSceneInfoTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts +29 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.js +57 -0
- package/dist-lib/esm/tools/builtin/MergeMeshesTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts +88 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.js +156 -0
- package/dist-lib/esm/tools/builtin/PlanModelTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts +51 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js +117 -0
- package/dist-lib/esm/tools/builtin/RetopologizeMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts +56 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.js +140 -0
- package/dist-lib/esm/tools/builtin/RigWeightTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts +139 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.js +256 -0
- package/dist-lib/esm/tools/builtin/SculptMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts +22 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.js +32 -0
- package/dist-lib/esm/tools/builtin/SeparateMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts +31 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js +58 -0
- package/dist-lib/esm/tools/builtin/SolidifyMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts +67 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js +106 -0
- package/dist-lib/esm/tools/builtin/SpawnBaseMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts +24 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.js +38 -0
- package/dist-lib/esm/tools/builtin/SubDSmoothTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts +24 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js +40 -0
- package/dist-lib/esm/tools/builtin/SubdivideMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts +79 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.js +70 -0
- package/dist-lib/esm/tools/builtin/TransformMeshTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts +49 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.js +108 -0
- package/dist-lib/esm/tools/builtin/UVUnwrapTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts +61 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.js +154 -0
- package/dist-lib/esm/tools/builtin/VoxelPainterTool.js.map +1 -0
- package/dist-lib/esm/tools/builtin/index.d.ts +45 -0
- package/dist-lib/esm/tools/builtin/index.d.ts.map +1 -0
- package/dist-lib/esm/tools/builtin/index.js +45 -0
- package/dist-lib/esm/tools/builtin/index.js.map +1 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts +19 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.js +44 -0
- package/dist-lib/esm/tools/editor/AIAgentEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts +16 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.js +29 -0
- package/dist-lib/esm/tools/editor/AITextureEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts +30 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.js +57 -0
- package/dist-lib/esm/tools/editor/AbstractEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js +30 -0
- package/dist-lib/esm/tools/editor/AnimationPlayerEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts +22 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.js +45 -0
- package/dist-lib/esm/tools/editor/BakingEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts +21 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.js +43 -0
- package/dist-lib/esm/tools/editor/CSGEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts +21 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.js +49 -0
- package/dist-lib/esm/tools/editor/CompressModelEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js +37 -0
- package/dist-lib/esm/tools/editor/CreatePrimitiveEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.js +37 -0
- package/dist-lib/esm/tools/editor/DecalEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts +24 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.js +81 -0
- package/dist-lib/esm/tools/editor/FacetEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts +19 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.js +44 -0
- package/dist-lib/esm/tools/editor/MaterialEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js +38 -0
- package/dist-lib/esm/tools/editor/MeshPropertiesEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.js +35 -0
- package/dist-lib/esm/tools/editor/OutlinerEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts +27 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js +73 -0
- package/dist-lib/esm/tools/editor/PathExtrusionEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts +28 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.js +67 -0
- package/dist-lib/esm/tools/editor/RiggingEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js +36 -0
- package/dist-lib/esm/tools/editor/SceneEnvironmentEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts +29 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.js +71 -0
- package/dist-lib/esm/tools/editor/SculptEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts +17 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.js +31 -0
- package/dist-lib/esm/tools/editor/TextMeshEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts +18 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js +29 -0
- package/dist-lib/esm/tools/editor/TextureOptimizerEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts +28 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js +71 -0
- package/dist-lib/esm/tools/editor/UVUnwrapEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts +27 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js +69 -0
- package/dist-lib/esm/tools/editor/VoxelPainterEditorTool.js.map +1 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts +31 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.js +229 -0
- package/dist-lib/esm/tools/editor/aiQuickPrompts.js.map +1 -0
- package/dist-lib/esm/tools/editor/index.d.ts +33 -0
- package/dist-lib/esm/tools/editor/index.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/index.js +55 -0
- package/dist-lib/esm/tools/editor/index.js.map +1 -0
- package/dist-lib/esm/tools/editor/toolViews.d.ts +11 -0
- package/dist-lib/esm/tools/editor/toolViews.d.ts.map +1 -0
- package/dist-lib/esm/tools/editor/toolViews.js +54 -0
- package/dist-lib/esm/tools/editor/toolViews.js.map +1 -0
- package/dist-lib/esm/tools/editorTools.d.ts +6 -0
- package/dist-lib/esm/tools/editorTools.d.ts.map +1 -0
- package/dist-lib/esm/tools/editorTools.js +6 -0
- package/dist-lib/esm/tools/editorTools.js.map +1 -0
- package/dist-lib/esm/tools/index.d.ts +9 -0
- package/dist-lib/esm/tools/index.d.ts.map +1 -0
- package/dist-lib/esm/tools/index.js +9 -0
- package/dist-lib/esm/tools/index.js.map +1 -0
- package/dist-lib/esm/tools/textureUtils.d.ts +19 -0
- package/dist-lib/esm/tools/textureUtils.d.ts.map +1 -0
- package/dist-lib/esm/tools/textureUtils.js +289 -0
- package/dist-lib/esm/tools/textureUtils.js.map +1 -0
- package/dist-lib/esm/types.d.ts +165 -0
- package/dist-lib/esm/types.d.ts.map +1 -0
- package/dist-lib/esm/types.js +2 -0
- package/dist-lib/esm/types.js.map +1 -0
- package/dist-lib/esm/uv/UVUnwrapController.d.ts +109 -0
- package/dist-lib/esm/uv/UVUnwrapController.d.ts.map +1 -0
- package/dist-lib/esm/uv/UVUnwrapController.js +1023 -0
- package/dist-lib/esm/uv/UVUnwrapController.js.map +1 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts +16 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.d.ts.map +1 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.js +170 -0
- package/dist-lib/esm/voxel/CustomVoxelMesher.js.map +1 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.d.ts +55 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.d.ts.map +1 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.js +631 -0
- package/dist-lib/esm/voxel/TextureAtlasManager.js.map +1 -0
- package/dist-lib/esm/voxel/VoxelPainterController.d.ts +101 -0
- package/dist-lib/esm/voxel/VoxelPainterController.d.ts.map +1 -0
- package/dist-lib/esm/voxel/VoxelPainterController.js +672 -0
- package/dist-lib/esm/voxel/VoxelPainterController.js.map +1 -0
- package/dist-lib/esm/voxel/index.d.ts +5 -0
- package/dist-lib/esm/voxel/index.d.ts.map +1 -0
- package/dist-lib/esm/voxel/index.js +5 -0
- package/dist-lib/esm/voxel/index.js.map +1 -0
- package/dist-lib/esm/voxel/types.d.ts +79 -0
- package/dist-lib/esm/voxel/types.d.ts.map +1 -0
- package/dist-lib/esm/voxel/types.js +2 -0
- package/dist-lib/esm/voxel/types.js.map +1 -0
- package/dist-lib/esm/web-component/MeshEditorElement.d.ts +104 -0
- package/dist-lib/esm/web-component/MeshEditorElement.d.ts.map +1 -0
- package/dist-lib/esm/web-component/MeshEditorElement.js +247 -0
- package/dist-lib/esm/web-component/MeshEditorElement.js.map +1 -0
- package/dist-lib/esm/web-component/index.d.ts +2 -0
- package/dist-lib/esm/web-component/index.d.ts.map +1 -0
- package/dist-lib/esm/web-component/index.js +2 -0
- package/dist-lib/esm/web-component/index.js.map +1 -0
- package/dist-lib/index.umd.js +3 -0
- package/dist-lib/mesheditor.css +2 -0
- package/dist-lib/standalone/mesheditor-element.bundle.js +3 -0
- package/package.json +113 -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,880 @@
|
|
|
1
|
+
export const IMAGE_GENERATOR_STORAGE_KEY = 'mesheditor_image_generator_config';
|
|
2
|
+
export const IMAGE_GENERATOR_PROTOCOL_DEFAULTS = {
|
|
3
|
+
pollinations: {
|
|
4
|
+
pollinations: {
|
|
5
|
+
endpointUrl: 'https://image.pollinations.ai/prompt',
|
|
6
|
+
modelId: 'flux',
|
|
7
|
+
requiresKey: false,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
openai: {
|
|
11
|
+
openai: {
|
|
12
|
+
endpointUrl: 'https://api.openai.com/v1/images/generations',
|
|
13
|
+
modelId: 'dall-e-3',
|
|
14
|
+
requiresKey: true,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
imagen: {
|
|
18
|
+
imagen: {
|
|
19
|
+
endpointUrl: 'https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent',
|
|
20
|
+
modelId: 'gemini-3-pro-image-preview',
|
|
21
|
+
requiresKey: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
fal: {
|
|
25
|
+
fal: {
|
|
26
|
+
endpointUrl: 'https://fal.run/fal-ai/flux/schnell',
|
|
27
|
+
modelId: 'fal-ai/flux/schnell',
|
|
28
|
+
requiresKey: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
replicate: {
|
|
32
|
+
replicate: {
|
|
33
|
+
endpointUrl: 'https://api.replicate.com/v1/predictions',
|
|
34
|
+
modelId: 'black-forest-labs/flux-schnell',
|
|
35
|
+
requiresKey: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
sd_webui: {
|
|
39
|
+
sd_webui: {
|
|
40
|
+
endpointUrl: 'http://127.0.0.1:7860/sdapi/v1/txt2img',
|
|
41
|
+
modelId: 'v1-5-pruned',
|
|
42
|
+
requiresKey: false,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
comfyui: {
|
|
46
|
+
comfyui: {
|
|
47
|
+
endpointUrl: 'http://127.0.0.1:8188',
|
|
48
|
+
modelId: 'ComfyUI-Workflow',
|
|
49
|
+
requiresKey: false,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
custom: {
|
|
53
|
+
custom_rest: {
|
|
54
|
+
endpointUrl: 'http://localhost:8000/v1/images/generations',
|
|
55
|
+
modelId: 'local-image-model',
|
|
56
|
+
requiresKey: false,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
export function createDefaultImageGeneratorProviders() {
|
|
61
|
+
return {
|
|
62
|
+
pollinations: {
|
|
63
|
+
id: 'pollinations',
|
|
64
|
+
name: 'Pollinations.ai (Free Cloud AI)',
|
|
65
|
+
enabled: true,
|
|
66
|
+
protocol: 'pollinations',
|
|
67
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.pollinations.pollinations.endpointUrl,
|
|
68
|
+
apiKey: '',
|
|
69
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.pollinations.pollinations.modelId,
|
|
70
|
+
},
|
|
71
|
+
openai: {
|
|
72
|
+
id: 'openai',
|
|
73
|
+
name: 'OpenAI (DALL-E 3 / DALL-E 2)',
|
|
74
|
+
enabled: false,
|
|
75
|
+
protocol: 'openai',
|
|
76
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.openai.openai.endpointUrl,
|
|
77
|
+
apiKey: '',
|
|
78
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.openai.openai.modelId,
|
|
79
|
+
},
|
|
80
|
+
imagen: {
|
|
81
|
+
id: 'imagen',
|
|
82
|
+
name: 'Google Imagen 3 / Banana Pro',
|
|
83
|
+
enabled: false,
|
|
84
|
+
protocol: 'imagen',
|
|
85
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.imagen.imagen.endpointUrl,
|
|
86
|
+
apiKey: '',
|
|
87
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.imagen.imagen.modelId,
|
|
88
|
+
},
|
|
89
|
+
fal: {
|
|
90
|
+
id: 'fal',
|
|
91
|
+
name: 'Fal.ai (Flux Schnell / SDXL)',
|
|
92
|
+
enabled: false,
|
|
93
|
+
protocol: 'fal',
|
|
94
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.fal.fal.endpointUrl,
|
|
95
|
+
apiKey: '',
|
|
96
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.fal.fal.modelId,
|
|
97
|
+
},
|
|
98
|
+
replicate: {
|
|
99
|
+
id: 'replicate',
|
|
100
|
+
name: 'Replicate (Flux / SDXL)',
|
|
101
|
+
enabled: false,
|
|
102
|
+
protocol: 'replicate',
|
|
103
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.replicate.replicate.endpointUrl,
|
|
104
|
+
apiKey: '',
|
|
105
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.replicate.replicate.modelId,
|
|
106
|
+
},
|
|
107
|
+
sd_webui: {
|
|
108
|
+
id: 'sd_webui',
|
|
109
|
+
name: 'Stable Diffusion / Draw Things (Local)',
|
|
110
|
+
enabled: false,
|
|
111
|
+
protocol: 'sd_webui',
|
|
112
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.sd_webui.sd_webui.endpointUrl,
|
|
113
|
+
apiKey: '',
|
|
114
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.sd_webui.sd_webui.modelId,
|
|
115
|
+
},
|
|
116
|
+
comfyui: {
|
|
117
|
+
id: 'comfyui',
|
|
118
|
+
name: 'ComfyUI (Local)',
|
|
119
|
+
enabled: false,
|
|
120
|
+
protocol: 'comfyui',
|
|
121
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.comfyui.comfyui.endpointUrl,
|
|
122
|
+
apiKey: '',
|
|
123
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.comfyui.comfyui.modelId,
|
|
124
|
+
},
|
|
125
|
+
custom: {
|
|
126
|
+
id: 'custom',
|
|
127
|
+
name: 'Custom OpenAI-Compatible / REST',
|
|
128
|
+
enabled: false,
|
|
129
|
+
protocol: 'custom_rest',
|
|
130
|
+
endpointUrl: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.custom.custom_rest.endpointUrl,
|
|
131
|
+
apiKey: '',
|
|
132
|
+
modelId: IMAGE_GENERATOR_PROTOCOL_DEFAULTS.custom.custom_rest.modelId,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
export function normalizeImageGeneratorProviders(raw) {
|
|
137
|
+
const defaults = createDefaultImageGeneratorProviders();
|
|
138
|
+
if (!raw || typeof raw !== 'object') {
|
|
139
|
+
return defaults;
|
|
140
|
+
}
|
|
141
|
+
const ids = [
|
|
142
|
+
'pollinations',
|
|
143
|
+
'openai',
|
|
144
|
+
'imagen',
|
|
145
|
+
'fal',
|
|
146
|
+
'replicate',
|
|
147
|
+
'sd_webui',
|
|
148
|
+
'comfyui',
|
|
149
|
+
'custom',
|
|
150
|
+
];
|
|
151
|
+
for (const id of ids) {
|
|
152
|
+
const item = raw[id];
|
|
153
|
+
if (item && typeof item === 'object') {
|
|
154
|
+
const defaultProtocol = defaults[id].protocol;
|
|
155
|
+
const protocol = item.protocol || defaultProtocol;
|
|
156
|
+
const preset = IMAGE_GENERATOR_PROTOCOL_DEFAULTS[id]?.[protocol] ||
|
|
157
|
+
IMAGE_GENERATOR_PROTOCOL_DEFAULTS[id]?.[defaultProtocol];
|
|
158
|
+
defaults[id] = {
|
|
159
|
+
id,
|
|
160
|
+
name: defaults[id].name,
|
|
161
|
+
enabled: typeof item.enabled === 'boolean' ? item.enabled : defaults[id].enabled,
|
|
162
|
+
protocol: item.protocol || defaultProtocol,
|
|
163
|
+
endpointUrl: typeof item.endpointUrl === 'string' && item.endpointUrl.trim()
|
|
164
|
+
? item.endpointUrl.trim()
|
|
165
|
+
: preset?.endpointUrl || defaults[id].endpointUrl,
|
|
166
|
+
apiKey: typeof item.apiKey === 'string' ? item.apiKey : '',
|
|
167
|
+
modelId: typeof item.modelId === 'string' && item.modelId.trim()
|
|
168
|
+
? item.modelId.trim()
|
|
169
|
+
: preset?.modelId || defaults[id].modelId,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return defaults;
|
|
174
|
+
}
|
|
175
|
+
export class ExternalImageGeneratorService {
|
|
176
|
+
activeBackend = 'procedural';
|
|
177
|
+
providers = createDefaultImageGeneratorProviders();
|
|
178
|
+
enhancePrompt = true;
|
|
179
|
+
constructor() {
|
|
180
|
+
this.loadConfig();
|
|
181
|
+
}
|
|
182
|
+
getActiveBackend() {
|
|
183
|
+
return this.activeBackend;
|
|
184
|
+
}
|
|
185
|
+
setActiveBackend(backend) {
|
|
186
|
+
this.activeBackend = backend;
|
|
187
|
+
this.saveConfig();
|
|
188
|
+
}
|
|
189
|
+
getProviders() {
|
|
190
|
+
return { ...this.providers };
|
|
191
|
+
}
|
|
192
|
+
getProvider(id) {
|
|
193
|
+
return this.providers[id] || createDefaultImageGeneratorProviders()[id];
|
|
194
|
+
}
|
|
195
|
+
updateProvider(id, partial) {
|
|
196
|
+
if (!this.providers[id])
|
|
197
|
+
return;
|
|
198
|
+
this.providers[id] = {
|
|
199
|
+
...this.providers[id],
|
|
200
|
+
...partial,
|
|
201
|
+
};
|
|
202
|
+
this.saveConfig();
|
|
203
|
+
}
|
|
204
|
+
isPromptEnhanceEnabled() {
|
|
205
|
+
return this.enhancePrompt;
|
|
206
|
+
}
|
|
207
|
+
setPromptEnhance(enabled) {
|
|
208
|
+
this.enhancePrompt = enabled;
|
|
209
|
+
this.saveConfig();
|
|
210
|
+
}
|
|
211
|
+
loadConfig() {
|
|
212
|
+
if (typeof localStorage === 'undefined')
|
|
213
|
+
return;
|
|
214
|
+
try {
|
|
215
|
+
const raw = localStorage.getItem(IMAGE_GENERATOR_STORAGE_KEY);
|
|
216
|
+
if (!raw)
|
|
217
|
+
return;
|
|
218
|
+
const parsed = JSON.parse(raw);
|
|
219
|
+
if (parsed.activeBackend) {
|
|
220
|
+
this.activeBackend = parsed.activeBackend;
|
|
221
|
+
}
|
|
222
|
+
if (parsed.providers) {
|
|
223
|
+
this.providers = normalizeImageGeneratorProviders(parsed.providers);
|
|
224
|
+
}
|
|
225
|
+
if (typeof parsed.enhancePrompt === 'boolean') {
|
|
226
|
+
this.enhancePrompt = parsed.enhancePrompt;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
// Ignore JSON parse errors and keep defaults
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
saveConfig() {
|
|
234
|
+
if (typeof localStorage === 'undefined')
|
|
235
|
+
return;
|
|
236
|
+
try {
|
|
237
|
+
const payload = {
|
|
238
|
+
activeBackend: this.activeBackend,
|
|
239
|
+
providers: this.providers,
|
|
240
|
+
enhancePrompt: this.enhancePrompt,
|
|
241
|
+
};
|
|
242
|
+
localStorage.setItem(IMAGE_GENERATOR_STORAGE_KEY, JSON.stringify(payload));
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// Ignore storage errors (e.g. quota exceeded)
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Enhances a natural language texture prompt with orthogonal framing,
|
|
250
|
+
* flat diffused lighting, and seamless tileable modifiers for diffusion models.
|
|
251
|
+
*/
|
|
252
|
+
enhancePromptForTexture(prompt, seamless = true) {
|
|
253
|
+
const trimmed = prompt.trim();
|
|
254
|
+
if (!trimmed)
|
|
255
|
+
return 'Seamless tileable stone texture, top-down view, evenly lit texture map';
|
|
256
|
+
const hasSeamless = /seamless|tileable|repeating pattern/i.test(trimmed);
|
|
257
|
+
const hasTopDown = /top-down|flat view|orthogonal|texture map/i.test(trimmed);
|
|
258
|
+
const parts = [];
|
|
259
|
+
if (seamless && !hasSeamless) {
|
|
260
|
+
parts.push('seamless tileable texture of');
|
|
261
|
+
}
|
|
262
|
+
parts.push(trimmed);
|
|
263
|
+
if (!hasTopDown) {
|
|
264
|
+
parts.push('top-down orthogonal view, diffused even studio lighting, high resolution PBR texture map, game asset, 8k');
|
|
265
|
+
}
|
|
266
|
+
if (seamless && !hasSeamless) {
|
|
267
|
+
parts.push('continuous repeating pattern without seams, flat surface, no perspective distortion');
|
|
268
|
+
}
|
|
269
|
+
return parts.join(', ');
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Tests connection to a specific image generator provider.
|
|
273
|
+
*/
|
|
274
|
+
async testProvider(id, override) {
|
|
275
|
+
const config = {
|
|
276
|
+
...this.getProvider(id),
|
|
277
|
+
...(override || {}),
|
|
278
|
+
};
|
|
279
|
+
const endpoint = (config.endpointUrl || '').trim();
|
|
280
|
+
if (!endpoint) {
|
|
281
|
+
return { ok: false, message: `Missing endpoint URL for ${config.name}.` };
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
switch (id) {
|
|
285
|
+
case 'pollinations': {
|
|
286
|
+
const testUrl = `${endpoint.replace(/\/+$/, '')}/test_ping?width=64&height=64&nologo=true`;
|
|
287
|
+
const res = await fetch(testUrl, { method: 'HEAD', mode: 'cors' }).catch(() => fetch(testUrl, { method: 'GET', mode: 'cors' }));
|
|
288
|
+
if (res.ok || res.status === 200 || res.status === 304) {
|
|
289
|
+
return { ok: true, message: 'Connected to Pollinations.ai successfully.' };
|
|
290
|
+
}
|
|
291
|
+
return { ok: false, message: `Pollinations returned status ${res.status}.` };
|
|
292
|
+
}
|
|
293
|
+
case 'openai': {
|
|
294
|
+
if (!config.apiKey) {
|
|
295
|
+
return { ok: false, message: 'API key is required for OpenAI.' };
|
|
296
|
+
}
|
|
297
|
+
// Test by querying /v1/models if standard OpenAI endpoint, or verify URL
|
|
298
|
+
const baseUrl = endpoint.replace(/\/images\/generations\/?$/, '');
|
|
299
|
+
const modelsUrl = baseUrl.endsWith('/v1') ? `${baseUrl}/models` : `${baseUrl}/v1/models`;
|
|
300
|
+
const res = await fetch(modelsUrl, {
|
|
301
|
+
headers: { Authorization: `Bearer ${config.apiKey}` },
|
|
302
|
+
});
|
|
303
|
+
if (res.ok) {
|
|
304
|
+
return { ok: true, message: 'Connected to OpenAI endpoint successfully.' };
|
|
305
|
+
}
|
|
306
|
+
const errData = await res.json().catch(() => ({}));
|
|
307
|
+
const errMsg = errData?.error?.message || `HTTP ${res.status} (${res.statusText})`;
|
|
308
|
+
return { ok: false, message: `OpenAI connection failed: ${errMsg}` };
|
|
309
|
+
}
|
|
310
|
+
case 'imagen': {
|
|
311
|
+
if (!config.apiKey) {
|
|
312
|
+
return { ok: false, message: 'Google Gemini API key is required for Imagen 3 / Banana Pro.' };
|
|
313
|
+
}
|
|
314
|
+
const testUrl = `https://generativelanguage.googleapis.com/v1beta/models?key=${config.apiKey}`;
|
|
315
|
+
const res = await fetch(testUrl).catch(() => null);
|
|
316
|
+
if (res && res.ok) {
|
|
317
|
+
return { ok: true, message: 'Connected to Google AI Studio / Imagen API successfully.' };
|
|
318
|
+
}
|
|
319
|
+
return { ok: false, message: 'Google Imagen connection failed. Verify your Google Gemini API key.' };
|
|
320
|
+
}
|
|
321
|
+
case 'sd_webui': {
|
|
322
|
+
const resolvedEndpoint = this.resolveEndpointUrl(endpoint);
|
|
323
|
+
const endpointsToTest = [];
|
|
324
|
+
const addCandidates = (url) => {
|
|
325
|
+
const base = url.replace(/\/sdapi\/v1\/.+$/, '').replace(/\/+$/, '');
|
|
326
|
+
// 1. /sdapi/v1/options is supported by Draw Things, Automatic1111, SD.Next, and Forge
|
|
327
|
+
const optUrl = `${base}/sdapi/v1/options`;
|
|
328
|
+
if (!endpointsToTest.includes(optUrl))
|
|
329
|
+
endpointsToTest.push(optUrl);
|
|
330
|
+
// 2. Root / returns model config JSON on Draw Things
|
|
331
|
+
const rootUrl = `${base}/`;
|
|
332
|
+
if (!endpointsToTest.includes(rootUrl))
|
|
333
|
+
endpointsToTest.push(rootUrl);
|
|
334
|
+
// 3. /sdapi/v1/progress is supported on Automatic1111/Forge
|
|
335
|
+
const progUrl = `${base}/sdapi/v1/progress`;
|
|
336
|
+
if (!endpointsToTest.includes(progUrl))
|
|
337
|
+
endpointsToTest.push(progUrl);
|
|
338
|
+
};
|
|
339
|
+
addCandidates(resolvedEndpoint);
|
|
340
|
+
if (resolvedEndpoint !== endpoint) {
|
|
341
|
+
addCandidates(endpoint);
|
|
342
|
+
}
|
|
343
|
+
let lastErrorMessage = '';
|
|
344
|
+
for (const testUrl of endpointsToTest) {
|
|
345
|
+
try {
|
|
346
|
+
const res = await fetch(testUrl, { method: 'GET' });
|
|
347
|
+
if (res.ok) {
|
|
348
|
+
const data = typeof res.json === 'function' ? await res.json().catch(() => null) : null;
|
|
349
|
+
const activeModel = data?.model ||
|
|
350
|
+
data?.sd_model_checkpoint ||
|
|
351
|
+
(typeof data === 'object' && data?.sampler ? 'Draw Things Model' : null);
|
|
352
|
+
const modelInfo = activeModel ? ` (Model: ${activeModel})` : '';
|
|
353
|
+
return {
|
|
354
|
+
ok: true,
|
|
355
|
+
message: `Connected to Stable Diffusion WebUI / Draw Things successfully${modelInfo}.`,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
catch (err) {
|
|
360
|
+
lastErrorMessage = err?.message || 'Network error';
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return {
|
|
364
|
+
ok: false,
|
|
365
|
+
message: lastErrorMessage
|
|
366
|
+
? `Could not reach SD WebUI / Draw Things: ${lastErrorMessage}. Ensure Draw Things or WebUI is running with API Server enabled.`
|
|
367
|
+
: 'WebUI responded with an error. Ensure API Server mode is active (Port 7860).',
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
case 'fal': {
|
|
371
|
+
if (!config.apiKey) {
|
|
372
|
+
return { ok: false, message: 'API key is required for Fal.ai.' };
|
|
373
|
+
}
|
|
374
|
+
const res = await fetch(endpoint, {
|
|
375
|
+
method: 'OPTIONS',
|
|
376
|
+
headers: { Authorization: `Key ${config.apiKey}` },
|
|
377
|
+
}).catch(() => null);
|
|
378
|
+
return {
|
|
379
|
+
ok: true,
|
|
380
|
+
message: 'Fal.ai endpoint configured. Credentials ready for generation.',
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
case 'replicate': {
|
|
384
|
+
if (!config.apiKey) {
|
|
385
|
+
return { ok: false, message: 'API token is required for Replicate.' };
|
|
386
|
+
}
|
|
387
|
+
const res = await fetch('https://api.replicate.com/v1/models', {
|
|
388
|
+
headers: { Authorization: `Bearer ${config.apiKey}` },
|
|
389
|
+
});
|
|
390
|
+
if (res.ok) {
|
|
391
|
+
return { ok: true, message: 'Connected to Replicate API successfully.' };
|
|
392
|
+
}
|
|
393
|
+
return { ok: false, message: `Replicate returned HTTP ${res.status}. Check API token.` };
|
|
394
|
+
}
|
|
395
|
+
case 'comfyui': {
|
|
396
|
+
const baseUrl = endpoint.replace(/\/+$/, '');
|
|
397
|
+
const res = await fetch(`${baseUrl}/system_stats`).catch(() => null);
|
|
398
|
+
if (res && res.ok) {
|
|
399
|
+
return { ok: true, message: 'Connected to ComfyUI server.' };
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
ok: false,
|
|
403
|
+
message: `Could not reach ComfyUI on ${endpoint}. Make sure ComfyUI is running.`,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
case 'custom':
|
|
407
|
+
default: {
|
|
408
|
+
const res = await fetch(endpoint, {
|
|
409
|
+
method: 'HEAD',
|
|
410
|
+
headers: config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {},
|
|
411
|
+
}).catch(() => null);
|
|
412
|
+
if (res && (res.ok || res.status === 405 || res.status === 404)) {
|
|
413
|
+
return { ok: true, message: 'Custom endpoint reached successfully.' };
|
|
414
|
+
}
|
|
415
|
+
return { ok: false, message: `Could not connect to custom endpoint ${endpoint}.` };
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
catch (err) {
|
|
420
|
+
return { ok: false, message: `Connection test failed: ${err?.message || 'Network error'}` };
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Generates a 2D image from natural language using the configured external image provider.
|
|
425
|
+
*/
|
|
426
|
+
async generateImage(request) {
|
|
427
|
+
const backendId = request.backend && request.backend !== 'auto'
|
|
428
|
+
? request.backend
|
|
429
|
+
: this.activeBackend !== 'procedural'
|
|
430
|
+
? this.activeBackend
|
|
431
|
+
: 'pollinations';
|
|
432
|
+
const provider = this.getProvider(backendId);
|
|
433
|
+
const size = this.normalizeResolution(request.size ?? 512);
|
|
434
|
+
const seamless = request.seamless !== false;
|
|
435
|
+
const shouldEnhance = request.enhancePrompt !== false && this.enhancePrompt;
|
|
436
|
+
const finalPrompt = shouldEnhance ? this.enhancePromptForTexture(request.prompt, seamless) : request.prompt;
|
|
437
|
+
const seed = request.seed ?? Math.floor(Math.random() * 1000000);
|
|
438
|
+
let dataUrl;
|
|
439
|
+
switch (backendId) {
|
|
440
|
+
case 'pollinations':
|
|
441
|
+
dataUrl = await this.generateWithPollinations(provider, finalPrompt, size, seed, request.signal);
|
|
442
|
+
break;
|
|
443
|
+
case 'openai':
|
|
444
|
+
dataUrl = await this.generateWithOpenAI(provider, finalPrompt, size, request.signal);
|
|
445
|
+
break;
|
|
446
|
+
case 'imagen':
|
|
447
|
+
dataUrl = await this.generateWithGoogleImagen(provider, finalPrompt, size, request.signal);
|
|
448
|
+
break;
|
|
449
|
+
case 'sd_webui':
|
|
450
|
+
dataUrl = await this.generateWithSDWebUI(provider, finalPrompt, size, seed, seamless, request.signal);
|
|
451
|
+
break;
|
|
452
|
+
case 'fal':
|
|
453
|
+
dataUrl = await this.generateWithFal(provider, finalPrompt, size, seed, request.signal);
|
|
454
|
+
break;
|
|
455
|
+
case 'replicate':
|
|
456
|
+
dataUrl = await this.generateWithReplicate(provider, finalPrompt, size, seed, request.signal);
|
|
457
|
+
break;
|
|
458
|
+
case 'custom':
|
|
459
|
+
default:
|
|
460
|
+
dataUrl = await this.generateWithCustom(provider, finalPrompt, size, seed, seamless, request.signal);
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
return {
|
|
464
|
+
providerId: backendId,
|
|
465
|
+
providerName: provider.name,
|
|
466
|
+
dataUrl,
|
|
467
|
+
width: size,
|
|
468
|
+
height: size,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
normalizeResolution(size) {
|
|
472
|
+
if (size <= 256)
|
|
473
|
+
return 256;
|
|
474
|
+
if (size <= 512)
|
|
475
|
+
return 512;
|
|
476
|
+
if (size <= 1024)
|
|
477
|
+
return 1024;
|
|
478
|
+
return 2048;
|
|
479
|
+
}
|
|
480
|
+
async generateWithPollinations(provider, prompt, size, seed, signal) {
|
|
481
|
+
const endpoint = (provider.endpointUrl || IMAGE_GENERATOR_PROTOCOL_DEFAULTS.pollinations.pollinations.endpointUrl).replace(/\/+$/, '');
|
|
482
|
+
const model = provider.modelId || 'flux';
|
|
483
|
+
const encodedPrompt = encodeURIComponent(prompt);
|
|
484
|
+
const url = `${endpoint}/${encodedPrompt}?width=${size}&height=${size}&seed=${seed}&model=${encodeURIComponent(model)}&nologo=true`;
|
|
485
|
+
const res = await fetch(url, { signal, mode: 'cors' });
|
|
486
|
+
if (!res.ok) {
|
|
487
|
+
throw new Error(`Pollinations.ai generation failed with HTTP status ${res.status}.`);
|
|
488
|
+
}
|
|
489
|
+
const blob = await res.blob();
|
|
490
|
+
return await this.blobToDataUrl(blob);
|
|
491
|
+
}
|
|
492
|
+
async generateWithOpenAI(provider, prompt, size, signal) {
|
|
493
|
+
const endpoint = provider.endpointUrl || IMAGE_GENERATOR_PROTOCOL_DEFAULTS.openai.openai.endpointUrl;
|
|
494
|
+
if (!provider.apiKey && endpoint.includes('api.openai.com')) {
|
|
495
|
+
throw new Error('OpenAI API Key is required. Please set it in AI Texture Generator settings.');
|
|
496
|
+
}
|
|
497
|
+
const model = provider.modelId || 'dall-e-3';
|
|
498
|
+
// DALL-E 3 requires 1024x1024 minimum
|
|
499
|
+
const openAISize = model.includes('dall-e-3')
|
|
500
|
+
? '1024x1024'
|
|
501
|
+
: size <= 256
|
|
502
|
+
? '256x256'
|
|
503
|
+
: size <= 512
|
|
504
|
+
? '512x512'
|
|
505
|
+
: '1024x1024';
|
|
506
|
+
const headers = {
|
|
507
|
+
'Content-Type': 'application/json',
|
|
508
|
+
};
|
|
509
|
+
if (provider.apiKey) {
|
|
510
|
+
headers.Authorization = `Bearer ${provider.apiKey}`;
|
|
511
|
+
}
|
|
512
|
+
const body = {
|
|
513
|
+
prompt,
|
|
514
|
+
model,
|
|
515
|
+
n: 1,
|
|
516
|
+
size: openAISize,
|
|
517
|
+
response_format: 'b64_json',
|
|
518
|
+
};
|
|
519
|
+
const res = await fetch(endpoint, {
|
|
520
|
+
method: 'POST',
|
|
521
|
+
headers,
|
|
522
|
+
body: JSON.stringify(body),
|
|
523
|
+
signal,
|
|
524
|
+
});
|
|
525
|
+
if (!res.ok) {
|
|
526
|
+
const errData = await res.json().catch(() => ({}));
|
|
527
|
+
const msg = errData?.error?.message || `HTTP ${res.status} (${res.statusText})`;
|
|
528
|
+
throw new Error(`OpenAI image generation failed: ${msg}`);
|
|
529
|
+
}
|
|
530
|
+
const data = await res.json();
|
|
531
|
+
const item = data?.data?.[0];
|
|
532
|
+
if (item?.b64_json) {
|
|
533
|
+
return `data:image/png;base64,${item.b64_json}`;
|
|
534
|
+
}
|
|
535
|
+
if (item?.url) {
|
|
536
|
+
return await this.fetchImageUrlAsDataUrl(item.url, signal);
|
|
537
|
+
}
|
|
538
|
+
throw new Error('No image data returned from OpenAI endpoint.');
|
|
539
|
+
}
|
|
540
|
+
async generateWithGoogleImagen(provider, prompt, size, signal) {
|
|
541
|
+
if (!provider.apiKey) {
|
|
542
|
+
throw new Error('Google Gemini API Key is required for Imagen 3 / Banana Pro. Please set it in settings.');
|
|
543
|
+
}
|
|
544
|
+
const rawEndpoint = (provider.endpointUrl || '').trim();
|
|
545
|
+
const model = (provider.modelId || 'gemini-3-pro-image-preview').trim();
|
|
546
|
+
// Determine target URL and mode (Native Gemini generateContent vs legacy :predict)
|
|
547
|
+
let url = rawEndpoint || `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`;
|
|
548
|
+
if (!url.includes(':generateContent') && !url.includes(':predict')) {
|
|
549
|
+
url = `${url.replace(/\/+$/, '')}/${model}:generateContent`;
|
|
550
|
+
}
|
|
551
|
+
url = url.includes('key=') ? url : `${url}${url.includes('?') ? '&' : '?'}key=${encodeURIComponent(provider.apiKey)}`;
|
|
552
|
+
const isPredictEndpoint = url.includes(':predict');
|
|
553
|
+
const body = isPredictEndpoint
|
|
554
|
+
? {
|
|
555
|
+
instances: [{ prompt }],
|
|
556
|
+
parameters: {
|
|
557
|
+
sampleCount: 1,
|
|
558
|
+
aspectRatio: '1:1',
|
|
559
|
+
outputOptions: {
|
|
560
|
+
mimeType: 'image/png',
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
}
|
|
564
|
+
: {
|
|
565
|
+
contents: [
|
|
566
|
+
{
|
|
567
|
+
parts: [{ text: prompt }],
|
|
568
|
+
},
|
|
569
|
+
],
|
|
570
|
+
generationConfig: {
|
|
571
|
+
responseModalities: ['TEXT', 'IMAGE'],
|
|
572
|
+
imageConfig: {
|
|
573
|
+
imageSize: size >= 1024 ? '1K' : '0.5K',
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
};
|
|
577
|
+
const res = await fetch(url, {
|
|
578
|
+
method: 'POST',
|
|
579
|
+
headers: {
|
|
580
|
+
'Content-Type': 'application/json',
|
|
581
|
+
},
|
|
582
|
+
body: JSON.stringify(body),
|
|
583
|
+
signal,
|
|
584
|
+
});
|
|
585
|
+
if (!res.ok) {
|
|
586
|
+
const errData = await res.json().catch(() => ({}));
|
|
587
|
+
const msg = errData?.error?.message || `HTTP ${res.status} (${res.statusText})`;
|
|
588
|
+
if (res.status === 402 || msg.includes('credits are depleted') || msg.includes('RESOURCE_EXHAUSTED')) {
|
|
589
|
+
throw new Error('Google AI Studio: Prepayment credits are depleted on this project. Manage billing at https://ai.studio/projects or switch to free Pollinations.ai / local SD WebUI.');
|
|
590
|
+
}
|
|
591
|
+
if (res.status === 404) {
|
|
592
|
+
throw new Error(`Google model not found (404). Active Gemini image models: "gemini-3-pro-image-preview" (Banana Pro) or "gemini-3.1-flash-image-preview".`);
|
|
593
|
+
}
|
|
594
|
+
throw new Error(`Google Imagen / Banana Pro generation failed: ${msg}`);
|
|
595
|
+
}
|
|
596
|
+
const data = await res.json();
|
|
597
|
+
// 1. Try modern generateContent candidates[].content.parts[].inlineData format
|
|
598
|
+
const parts = data?.candidates?.[0]?.content?.parts || [];
|
|
599
|
+
for (const part of parts) {
|
|
600
|
+
if (part?.inlineData?.data) {
|
|
601
|
+
const mime = part.inlineData.mimeType || 'image/png';
|
|
602
|
+
return `data:${mime};base64,${part.inlineData.data}`;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
// 2. Try legacy :predict predictions[].bytesBase64Encoded format
|
|
606
|
+
const b64 = data?.predictions?.[0]?.bytesBase64Encoded;
|
|
607
|
+
if (b64) {
|
|
608
|
+
return `data:image/png;base64,${b64}`;
|
|
609
|
+
}
|
|
610
|
+
throw new Error('No image bytes returned from Google Gemini / Imagen API.');
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* Resolves an endpoint URL, mapping local SD WebUI / Draw Things endpoints to
|
|
614
|
+
* same-origin proxy URLs if running in a web browser to prevent browser CORS blocks.
|
|
615
|
+
*/
|
|
616
|
+
resolveEndpointUrl(rawUrl) {
|
|
617
|
+
const trimmed = (rawUrl || '').trim();
|
|
618
|
+
if (typeof window === 'undefined' || !window.location) {
|
|
619
|
+
return trimmed;
|
|
620
|
+
}
|
|
621
|
+
try {
|
|
622
|
+
// If endpoint is targeted at 127.0.0.1:7860 or localhost:7860,
|
|
623
|
+
// and the web application is running on localhost/127.0.0.1 on another port (e.g. 8080):
|
|
624
|
+
if ((trimmed.startsWith('http://127.0.0.1:7860') || trimmed.startsWith('http://localhost:7860')) &&
|
|
625
|
+
(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1')) {
|
|
626
|
+
const parsed = new URL(trimmed);
|
|
627
|
+
return `${window.location.origin}${parsed.pathname}${parsed.search}`;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
catch {
|
|
631
|
+
// fallback to original
|
|
632
|
+
}
|
|
633
|
+
return trimmed;
|
|
634
|
+
}
|
|
635
|
+
async generateWithSDWebUI(provider, prompt, size, seed, tiling, signal) {
|
|
636
|
+
const rawEndpoint = provider.endpointUrl || IMAGE_GENERATOR_PROTOCOL_DEFAULTS.sd_webui.sd_webui.endpointUrl;
|
|
637
|
+
const resolvedEndpoint = this.resolveEndpointUrl(rawEndpoint);
|
|
638
|
+
// Prepare candidate target URLs (same-origin proxy first, then direct if different)
|
|
639
|
+
const targetUrls = [resolvedEndpoint];
|
|
640
|
+
if (resolvedEndpoint !== rawEndpoint) {
|
|
641
|
+
targetUrls.push(rawEndpoint);
|
|
642
|
+
}
|
|
643
|
+
const headers = {
|
|
644
|
+
'Content-Type': 'application/json',
|
|
645
|
+
};
|
|
646
|
+
if (provider.apiKey) {
|
|
647
|
+
headers.Authorization = `Bearer ${provider.apiKey}`;
|
|
648
|
+
}
|
|
649
|
+
// Try payload variants:
|
|
650
|
+
// 1. Standard Automatic1111 payload (with `tiling: boolean`)
|
|
651
|
+
// 2. Draw Things payload (Draw Things rejects unrecognized `tiling` key, but accepts `tiled_diffusion: boolean`)
|
|
652
|
+
const payloadsToTry = [
|
|
653
|
+
{
|
|
654
|
+
prompt,
|
|
655
|
+
negative_prompt: 'blurry, low quality, distorted, perspective, watermark, logo, text',
|
|
656
|
+
steps: 22,
|
|
657
|
+
width: size,
|
|
658
|
+
height: size,
|
|
659
|
+
tiling,
|
|
660
|
+
seed,
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
prompt: tiling ? `${prompt}, seamless texture, tileable pattern` : prompt,
|
|
664
|
+
negative_prompt: 'blurry, low quality, distorted, perspective, watermark, logo, text',
|
|
665
|
+
steps: 22,
|
|
666
|
+
width: size,
|
|
667
|
+
height: size,
|
|
668
|
+
tiled_diffusion: tiling,
|
|
669
|
+
seed,
|
|
670
|
+
},
|
|
671
|
+
];
|
|
672
|
+
let lastError = null;
|
|
673
|
+
for (const targetUrl of targetUrls) {
|
|
674
|
+
for (const payload of payloadsToTry) {
|
|
675
|
+
try {
|
|
676
|
+
const res = await fetch(targetUrl, {
|
|
677
|
+
method: 'POST',
|
|
678
|
+
headers,
|
|
679
|
+
body: JSON.stringify(payload),
|
|
680
|
+
signal,
|
|
681
|
+
});
|
|
682
|
+
if (!res.ok) {
|
|
683
|
+
const errJson = await res.json().catch(() => null);
|
|
684
|
+
const errDetail = errJson?.detail || errJson?.error?.message || (typeof errJson === 'string' ? errJson : '');
|
|
685
|
+
// If the failure is due to unrecognized key "tiling", try next payload immediately
|
|
686
|
+
if (typeof errDetail === 'string' && errDetail.includes('tiling')) {
|
|
687
|
+
continue;
|
|
688
|
+
}
|
|
689
|
+
throw new Error(`Stable Diffusion WebUI / Draw Things returned HTTP ${res.status}${errDetail ? `: ${errDetail}` : ''}`);
|
|
690
|
+
}
|
|
691
|
+
const data = await res.json();
|
|
692
|
+
const firstImg = data?.images?.[0];
|
|
693
|
+
if (!firstImg) {
|
|
694
|
+
throw new Error('Stable Diffusion WebUI / Draw Things did not return an image in response.');
|
|
695
|
+
}
|
|
696
|
+
return firstImg.startsWith('data:image/') ? firstImg : `data:image/png;base64,${firstImg}`;
|
|
697
|
+
}
|
|
698
|
+
catch (err) {
|
|
699
|
+
lastError = err;
|
|
700
|
+
// If aborted, do not retry
|
|
701
|
+
if (signal?.aborted) {
|
|
702
|
+
throw err;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
throw (lastError ||
|
|
708
|
+
new Error('Failed to generate image with Stable Diffusion WebUI / Draw Things. Verify that Draw Things or WebUI is running.'));
|
|
709
|
+
}
|
|
710
|
+
async generateWithFal(provider, prompt, size, seed, signal) {
|
|
711
|
+
const endpoint = provider.endpointUrl || IMAGE_GENERATOR_PROTOCOL_DEFAULTS.fal.fal.endpointUrl;
|
|
712
|
+
if (!provider.apiKey) {
|
|
713
|
+
throw new Error('Fal.ai API Key is required. Please set it in AI Texture Generator settings.');
|
|
714
|
+
}
|
|
715
|
+
const payload = {
|
|
716
|
+
prompt,
|
|
717
|
+
image_size: size >= 1024 ? 'square_hd' : 'square',
|
|
718
|
+
num_images: 1,
|
|
719
|
+
seed,
|
|
720
|
+
};
|
|
721
|
+
const res = await fetch(endpoint, {
|
|
722
|
+
method: 'POST',
|
|
723
|
+
headers: {
|
|
724
|
+
'Content-Type': 'application/json',
|
|
725
|
+
Authorization: `Key ${provider.apiKey}`,
|
|
726
|
+
},
|
|
727
|
+
body: JSON.stringify(payload),
|
|
728
|
+
signal,
|
|
729
|
+
});
|
|
730
|
+
if (!res.ok) {
|
|
731
|
+
const err = await res.json().catch(() => ({}));
|
|
732
|
+
throw new Error(`Fal.ai generation failed: ${err?.detail || res.statusText}`);
|
|
733
|
+
}
|
|
734
|
+
const data = await res.json();
|
|
735
|
+
const imgUrl = data?.images?.[0]?.url;
|
|
736
|
+
if (!imgUrl) {
|
|
737
|
+
throw new Error('No image URL returned from Fal.ai.');
|
|
738
|
+
}
|
|
739
|
+
return await this.fetchImageUrlAsDataUrl(imgUrl, signal);
|
|
740
|
+
}
|
|
741
|
+
async generateWithReplicate(provider, prompt, size, seed, signal) {
|
|
742
|
+
const endpoint = provider.endpointUrl || IMAGE_GENERATOR_PROTOCOL_DEFAULTS.replicate.replicate.endpointUrl;
|
|
743
|
+
if (!provider.apiKey) {
|
|
744
|
+
throw new Error('Replicate API Token is required. Please set it in AI Texture Generator settings.');
|
|
745
|
+
}
|
|
746
|
+
const modelId = provider.modelId || IMAGE_GENERATOR_PROTOCOL_DEFAULTS.replicate.replicate.modelId;
|
|
747
|
+
const isModelEndpoint = endpoint.includes('/models/');
|
|
748
|
+
const payload = isModelEndpoint
|
|
749
|
+
? {
|
|
750
|
+
input: {
|
|
751
|
+
prompt,
|
|
752
|
+
width: size,
|
|
753
|
+
height: size,
|
|
754
|
+
seed,
|
|
755
|
+
},
|
|
756
|
+
}
|
|
757
|
+
: {
|
|
758
|
+
version: modelId,
|
|
759
|
+
input: {
|
|
760
|
+
prompt,
|
|
761
|
+
width: size,
|
|
762
|
+
height: size,
|
|
763
|
+
seed,
|
|
764
|
+
},
|
|
765
|
+
};
|
|
766
|
+
const res = await fetch(endpoint, {
|
|
767
|
+
method: 'POST',
|
|
768
|
+
headers: {
|
|
769
|
+
'Content-Type': 'application/json',
|
|
770
|
+
Authorization: `Bearer ${provider.apiKey}`,
|
|
771
|
+
Prefer: 'wait',
|
|
772
|
+
},
|
|
773
|
+
body: JSON.stringify(payload),
|
|
774
|
+
signal,
|
|
775
|
+
});
|
|
776
|
+
if (!res.ok) {
|
|
777
|
+
const err = await res.json().catch(() => ({}));
|
|
778
|
+
throw new Error(`Replicate failed: ${err?.detail || res.statusText}`);
|
|
779
|
+
}
|
|
780
|
+
const data = await res.json();
|
|
781
|
+
let imgUrl = Array.isArray(data?.output) ? data.output[0] : typeof data?.output === 'string' ? data.output : null;
|
|
782
|
+
// If still processing, poll prediction URL
|
|
783
|
+
if (!imgUrl && data?.urls?.get) {
|
|
784
|
+
imgUrl = await this.pollReplicateResult(data.urls.get, provider.apiKey, signal);
|
|
785
|
+
}
|
|
786
|
+
if (!imgUrl) {
|
|
787
|
+
throw new Error('Replicate prediction did not return an image URL.');
|
|
788
|
+
}
|
|
789
|
+
return await this.fetchImageUrlAsDataUrl(imgUrl, signal);
|
|
790
|
+
}
|
|
791
|
+
async pollReplicateResult(getUrl, apiKey, signal) {
|
|
792
|
+
for (let i = 0; i < 30; i++) {
|
|
793
|
+
if (signal?.aborted)
|
|
794
|
+
throw new Error('Generation cancelled.');
|
|
795
|
+
await new Promise((r) => setTimeout(r, 1500));
|
|
796
|
+
const res = await fetch(getUrl, {
|
|
797
|
+
headers: { Authorization: `Bearer ${apiKey}` },
|
|
798
|
+
signal,
|
|
799
|
+
});
|
|
800
|
+
if (!res.ok)
|
|
801
|
+
continue;
|
|
802
|
+
const data = await res.json();
|
|
803
|
+
if (data?.status === 'succeeded') {
|
|
804
|
+
const out = Array.isArray(data.output) ? data.output[0] : data.output;
|
|
805
|
+
if (out)
|
|
806
|
+
return out;
|
|
807
|
+
}
|
|
808
|
+
if (data?.status === 'failed' || data?.status === 'canceled') {
|
|
809
|
+
throw new Error(`Replicate generation ${data.status}: ${data.error || 'Unknown error'}`);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
throw new Error('Replicate generation timed out.');
|
|
813
|
+
}
|
|
814
|
+
async generateWithCustom(provider, prompt, size, seed, seamless, signal) {
|
|
815
|
+
const endpoint = provider.endpointUrl;
|
|
816
|
+
if (!endpoint) {
|
|
817
|
+
throw new Error('Custom generator endpoint URL is not configured.');
|
|
818
|
+
}
|
|
819
|
+
const headers = {
|
|
820
|
+
'Content-Type': 'application/json',
|
|
821
|
+
};
|
|
822
|
+
if (provider.apiKey) {
|
|
823
|
+
headers.Authorization = `Bearer ${provider.apiKey}`;
|
|
824
|
+
}
|
|
825
|
+
// Attempt OpenAI-compatible /v1/images/generations payload format
|
|
826
|
+
const body = {
|
|
827
|
+
prompt,
|
|
828
|
+
model: provider.modelId || 'default',
|
|
829
|
+
size: `${size}x${size}`,
|
|
830
|
+
n: 1,
|
|
831
|
+
seed,
|
|
832
|
+
seamless,
|
|
833
|
+
response_format: 'b64_json',
|
|
834
|
+
};
|
|
835
|
+
const res = await fetch(endpoint, {
|
|
836
|
+
method: 'POST',
|
|
837
|
+
headers,
|
|
838
|
+
body: JSON.stringify(body),
|
|
839
|
+
signal,
|
|
840
|
+
});
|
|
841
|
+
if (!res.ok) {
|
|
842
|
+
throw new Error(`Custom endpoint returned HTTP ${res.status} (${res.statusText}).`);
|
|
843
|
+
}
|
|
844
|
+
const data = await res.json().catch(() => null);
|
|
845
|
+
if (data?.data?.[0]?.b64_json) {
|
|
846
|
+
return `data:image/png;base64,${data.data[0].b64_json}`;
|
|
847
|
+
}
|
|
848
|
+
if (data?.data?.[0]?.url) {
|
|
849
|
+
return await this.fetchImageUrlAsDataUrl(data.data[0].url, signal);
|
|
850
|
+
}
|
|
851
|
+
if (data?.image) {
|
|
852
|
+
return data.image.startsWith('data:image/') ? data.image : `data:image/png;base64,${data.image}`;
|
|
853
|
+
}
|
|
854
|
+
if (data?.images?.[0]) {
|
|
855
|
+
const img = data.images[0];
|
|
856
|
+
return img.startsWith('data:image/') ? img : `data:image/png;base64,${img}`;
|
|
857
|
+
}
|
|
858
|
+
if (data?.url) {
|
|
859
|
+
return await this.fetchImageUrlAsDataUrl(data.url, signal);
|
|
860
|
+
}
|
|
861
|
+
throw new Error('Custom endpoint response did not contain image data or URL.');
|
|
862
|
+
}
|
|
863
|
+
async fetchImageUrlAsDataUrl(url, signal) {
|
|
864
|
+
const res = await fetch(url, { signal, mode: 'cors' });
|
|
865
|
+
if (!res.ok) {
|
|
866
|
+
throw new Error(`Failed to download image from ${url} (HTTP ${res.status}).`);
|
|
867
|
+
}
|
|
868
|
+
const blob = await res.blob();
|
|
869
|
+
return await this.blobToDataUrl(blob);
|
|
870
|
+
}
|
|
871
|
+
blobToDataUrl(blob) {
|
|
872
|
+
return new Promise((resolve, reject) => {
|
|
873
|
+
const reader = new FileReader();
|
|
874
|
+
reader.onload = () => resolve(reader.result);
|
|
875
|
+
reader.onerror = () => reject(new Error('Failed to read image blob data.'));
|
|
876
|
+
reader.readAsDataURL(blob);
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
//# sourceMappingURL=ExternalImageGeneratorService.js.map
|