@nice2dev/ui-graphics 1.0.0
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/CHANGELOG.md +84 -0
- package/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/cjs/animation/AnimatedPerson.js +153 -0
- package/dist/cjs/animation/AnimatedPerson.js.map +1 -0
- package/dist/cjs/animation/AnimationEditor.js +106 -0
- package/dist/cjs/animation/AnimationEditor.js.map +1 -0
- package/dist/cjs/animation/Audience.js +59 -0
- package/dist/cjs/animation/Audience.js.map +1 -0
- package/dist/cjs/animation/BodyRenderer.js +33 -0
- package/dist/cjs/animation/BodyRenderer.js.map +1 -0
- package/dist/cjs/animation/animationHelper.js +272 -0
- package/dist/cjs/animation/animationHelper.js.map +1 -0
- package/dist/cjs/animation/characterTypes.js +75 -0
- package/dist/cjs/animation/characterTypes.js.map +1 -0
- package/dist/cjs/animation/choreoDSL.js +190 -0
- package/dist/cjs/animation/choreoDSL.js.map +1 -0
- package/dist/cjs/animation/choreography.js +41 -0
- package/dist/cjs/animation/choreography.js.map +1 -0
- package/dist/cjs/animation/karaokeIntegration.js +98 -0
- package/dist/cjs/animation/karaokeIntegration.js.map +1 -0
- package/dist/cjs/animation/lottieExport.js +128 -0
- package/dist/cjs/animation/lottieExport.js.map +1 -0
- package/dist/cjs/animation/motionPath.js +196 -0
- package/dist/cjs/animation/motionPath.js.map +1 -0
- package/dist/cjs/animation/physics.js +201 -0
- package/dist/cjs/animation/physics.js.map +1 -0
- package/dist/cjs/animation/rig/RigPlayer.js +63 -0
- package/dist/cjs/animation/rig/RigPlayer.js.map +1 -0
- package/dist/cjs/animation/rig/RiggedBody.js +30 -0
- package/dist/cjs/animation/rig/RiggedBody.js.map +1 -0
- package/dist/cjs/animation/rig/choreoRigBridge.js +63 -0
- package/dist/cjs/animation/rig/choreoRigBridge.js.map +1 -0
- package/dist/cjs/animation/rig/ik.js +22 -0
- package/dist/cjs/animation/rig/ik.js.map +1 -0
- package/dist/cjs/animation/rig/poseOps.js +49 -0
- package/dist/cjs/animation/rig/poseOps.js.map +1 -0
- package/dist/cjs/animation/rig/presets.js +60 -0
- package/dist/cjs/animation/rig/presets.js.map +1 -0
- package/dist/cjs/animation/rig/rigMath.js +41 -0
- package/dist/cjs/animation/rig/rigMath.js.map +1 -0
- package/dist/cjs/animation/rig/rigTypes.js +44 -0
- package/dist/cjs/animation/rig/rigTypes.js.map +1 -0
- package/dist/cjs/animation/shapes/arms.js +15 -0
- package/dist/cjs/animation/shapes/arms.js.map +1 -0
- package/dist/cjs/animation/shapes/eyes.js +52 -0
- package/dist/cjs/animation/shapes/eyes.js.map +1 -0
- package/dist/cjs/animation/shapes/hair.js +55 -0
- package/dist/cjs/animation/shapes/hair.js.map +1 -0
- package/dist/cjs/animation/shapes/heads.js +62 -0
- package/dist/cjs/animation/shapes/heads.js.map +1 -0
- package/dist/cjs/animation/shapes/headwear.js +44 -0
- package/dist/cjs/animation/shapes/headwear.js.map +1 -0
- package/dist/cjs/animation/shapes/legs.js +15 -0
- package/dist/cjs/animation/shapes/legs.js.map +1 -0
- package/dist/cjs/animation/shapes/mouths.js +53 -0
- package/dist/cjs/animation/shapes/mouths.js.map +1 -0
- package/dist/cjs/animation/shapes/noses.js +31 -0
- package/dist/cjs/animation/shapes/noses.js.map +1 -0
- package/dist/cjs/animation/shapes/outfits.js +43 -0
- package/dist/cjs/animation/shapes/outfits.js.map +1 -0
- package/dist/cjs/animation/shapes/torsos.js +13 -0
- package/dist/cjs/animation/shapes/torsos.js.map +1 -0
- package/dist/cjs/animation/spineExport.js +132 -0
- package/dist/cjs/animation/spineExport.js.map +1 -0
- package/dist/cjs/core/LocalUI.js +54 -0
- package/dist/cjs/core/LocalUI.js.map +1 -0
- package/dist/cjs/core/collaboration.js +259 -0
- package/dist/cjs/core/collaboration.js.map +1 -0
- package/dist/cjs/core/colorBlindness.js +97 -0
- package/dist/cjs/core/colorBlindness.js.map +1 -0
- package/dist/cjs/core/dragDrop.js +168 -0
- package/dist/cjs/core/dragDrop.js.map +1 -0
- package/dist/cjs/core/fixes.js +185 -0
- package/dist/cjs/core/fixes.js.map +1 -0
- package/dist/cjs/core/gridGuides.js +245 -0
- package/dist/cjs/core/gridGuides.js.map +1 -0
- package/dist/cjs/core/historyVisual.js +124 -0
- package/dist/cjs/core/historyVisual.js.map +1 -0
- package/dist/cjs/core/i18n.js +16 -0
- package/dist/cjs/core/i18n.js.map +1 -0
- package/dist/cjs/core/integrations.js +261 -0
- package/dist/cjs/core/integrations.js.map +1 -0
- package/dist/cjs/core/minimap.js +142 -0
- package/dist/cjs/core/minimap.js.map +1 -0
- package/dist/cjs/core/plugins.js +129 -0
- package/dist/cjs/core/plugins.js.map +1 -0
- package/dist/cjs/core/rtl.js +102 -0
- package/dist/cjs/core/rtl.js.map +1 -0
- package/dist/cjs/core/shortcuts.js +205 -0
- package/dist/cjs/core/shortcuts.js.map +1 -0
- package/dist/cjs/core/theme.js +171 -0
- package/dist/cjs/core/theme.js.map +1 -0
- package/dist/cjs/font/NiceFontEditor.js +193 -0
- package/dist/cjs/font/NiceFontEditor.js.map +1 -0
- package/dist/cjs/game/GameAsset2dEditor.js +371 -0
- package/dist/cjs/game/GameAsset2dEditor.js.map +1 -0
- package/dist/cjs/game/GameAsset2dEditor.module.css.js +6 -0
- package/dist/cjs/game/GameAsset2dEditor.module.css.js.map +1 -0
- package/dist/cjs/game/gameAssetTypes.js +20 -0
- package/dist/cjs/game/gameAssetTypes.js.map +1 -0
- package/dist/cjs/game/gameAssetUtils.js +475 -0
- package/dist/cjs/game/gameAssetUtils.js.map +1 -0
- package/dist/cjs/game/useGameAssetEditor.js +761 -0
- package/dist/cjs/game/useGameAssetEditor.js.map +1 -0
- package/dist/cjs/icon/NiceIconEditor.js +249 -0
- package/dist/cjs/icon/NiceIconEditor.js.map +1 -0
- package/dist/cjs/index.js +264 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/nice2dev-ui/dist/index.js +32070 -0
- package/dist/cjs/nice2dev-ui/dist/index.js.map +1 -0
- package/dist/cjs/nice2dev-ui-graphics.css +1 -0
- package/dist/cjs/photo/FilterThumb.js +29 -0
- package/dist/cjs/photo/FilterThumb.js.map +1 -0
- package/dist/cjs/photo/PhotoEditor.js +20 -0
- package/dist/cjs/photo/PhotoEditor.js.map +1 -0
- package/dist/cjs/photo/PhotoEditor.module.css.js +6 -0
- package/dist/cjs/photo/PhotoEditor.module.css.js.map +1 -0
- package/dist/cjs/photo/PhotoEditorCanvas.js +59 -0
- package/dist/cjs/photo/PhotoEditorCanvas.js.map +1 -0
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +174 -0
- package/dist/cjs/photo/PhotoEditorLeftPanel.js.map +1 -0
- package/dist/cjs/photo/PhotoEditorToolbar.js +15 -0
- package/dist/cjs/photo/PhotoEditorToolbar.js.map +1 -0
- package/dist/cjs/photo/photoEditorActions.js +80 -0
- package/dist/cjs/photo/photoEditorActions.js.map +1 -0
- package/dist/cjs/photo/photoEditorTypes.js +40 -0
- package/dist/cjs/photo/photoEditorTypes.js.map +1 -0
- package/dist/cjs/photo/photoFilters.js +880 -0
- package/dist/cjs/photo/photoFilters.js.map +1 -0
- package/dist/cjs/photo/photoOverlays.js +651 -0
- package/dist/cjs/photo/photoOverlays.js.map +1 -0
- package/dist/cjs/photo/photoSelection.js +547 -0
- package/dist/cjs/photo/photoSelection.js.map +1 -0
- package/dist/cjs/photo/usePhotoEditor.js +640 -0
- package/dist/cjs/photo/usePhotoEditor.js.map +1 -0
- package/dist/cjs/pixel/HSVPicker.js +173 -0
- package/dist/cjs/pixel/HSVPicker.js.map +1 -0
- package/dist/cjs/pixel/PixelEditor.js +28 -0
- package/dist/cjs/pixel/PixelEditor.js.map +1 -0
- package/dist/cjs/pixel/PixelEditor.module.css.js +6 -0
- package/dist/cjs/pixel/PixelEditor.module.css.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorCanvas.js +15 -0
- package/dist/cjs/pixel/PixelEditorCanvas.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorMenuBar.js +11 -0
- package/dist/cjs/pixel/PixelEditorMenuBar.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorRightPanel.js +15 -0
- package/dist/cjs/pixel/PixelEditorRightPanel.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorStatusBar.js +15 -0
- package/dist/cjs/pixel/PixelEditorStatusBar.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorTimeline.js +11 -0
- package/dist/cjs/pixel/PixelEditorTimeline.js.map +1 -0
- package/dist/cjs/pixel/PixelEditorToolbar.js +16 -0
- package/dist/cjs/pixel/PixelEditorToolbar.js.map +1 -0
- package/dist/cjs/pixel/asepriteFormat.js +512 -0
- package/dist/cjs/pixel/asepriteFormat.js.map +1 -0
- package/dist/cjs/pixel/pixelEditorExports.js +471 -0
- package/dist/cjs/pixel/pixelEditorExports.js.map +1 -0
- package/dist/cjs/pixel/pixelEditorTypes.js +102 -0
- package/dist/cjs/pixel/pixelEditorTypes.js.map +1 -0
- package/dist/cjs/pixel/pixelEditorUtils.js +664 -0
- package/dist/cjs/pixel/pixelEditorUtils.js.map +1 -0
- package/dist/cjs/pixel/usePixelEditor.js +1112 -0
- package/dist/cjs/pixel/usePixelEditor.js.map +1 -0
- package/dist/cjs/texture/Nice3DTexturePainter.js +236 -0
- package/dist/cjs/texture/Nice3DTexturePainter.js.map +1 -0
- package/dist/cjs/ui/NiceUIDesigner.js +191 -0
- package/dist/cjs/ui/NiceUIDesigner.js.map +1 -0
- package/dist/cjs/vector/VectorEditor.js +31 -0
- package/dist/cjs/vector/VectorEditor.js.map +1 -0
- package/dist/cjs/vector/VectorEditor.module.css.js +6 -0
- package/dist/cjs/vector/VectorEditor.module.css.js.map +1 -0
- package/dist/cjs/vector/VectorEditorMenuBar.js +16 -0
- package/dist/cjs/vector/VectorEditorMenuBar.js.map +1 -0
- package/dist/cjs/vector/VectorEditorRightPanel.js +126 -0
- package/dist/cjs/vector/VectorEditorRightPanel.js.map +1 -0
- package/dist/cjs/vector/VectorEditorShapeRenderer.js +55 -0
- package/dist/cjs/vector/VectorEditorShapeRenderer.js.map +1 -0
- package/dist/cjs/vector/VectorEditorStatusBar.js +14 -0
- package/dist/cjs/vector/VectorEditorStatusBar.js.map +1 -0
- package/dist/cjs/vector/useVectorEditor.js +613 -0
- package/dist/cjs/vector/useVectorEditor.js.map +1 -0
- package/dist/cjs/vector/vectorBooleanOps.js +511 -0
- package/dist/cjs/vector/vectorBooleanOps.js.map +1 -0
- package/dist/cjs/vector/vectorEditorExport.js +159 -0
- package/dist/cjs/vector/vectorEditorExport.js.map +1 -0
- package/dist/cjs/vector/vectorEditorImport.js +150 -0
- package/dist/cjs/vector/vectorEditorImport.js.map +1 -0
- package/dist/cjs/vector/vectorEditorTypes.js +72 -0
- package/dist/cjs/vector/vectorEditorTypes.js.map +1 -0
- package/dist/cjs/vector/vectorGradients.js +201 -0
- package/dist/cjs/vector/vectorGradients.js.map +1 -0
- package/dist/esm/animation/AnimatedPerson.js +151 -0
- package/dist/esm/animation/AnimatedPerson.js.map +1 -0
- package/dist/esm/animation/AnimationEditor.js +104 -0
- package/dist/esm/animation/AnimationEditor.js.map +1 -0
- package/dist/esm/animation/Audience.js +57 -0
- package/dist/esm/animation/Audience.js.map +1 -0
- package/dist/esm/animation/BodyRenderer.js +28 -0
- package/dist/esm/animation/BodyRenderer.js.map +1 -0
- package/dist/esm/animation/animationHelper.js +268 -0
- package/dist/esm/animation/animationHelper.js.map +1 -0
- package/dist/esm/animation/characterTypes.js +70 -0
- package/dist/esm/animation/characterTypes.js.map +1 -0
- package/dist/esm/animation/choreoDSL.js +182 -0
- package/dist/esm/animation/choreoDSL.js.map +1 -0
- package/dist/esm/animation/choreography.js +36 -0
- package/dist/esm/animation/choreography.js.map +1 -0
- package/dist/esm/animation/karaokeIntegration.js +91 -0
- package/dist/esm/animation/karaokeIntegration.js.map +1 -0
- package/dist/esm/animation/lottieExport.js +123 -0
- package/dist/esm/animation/lottieExport.js.map +1 -0
- package/dist/esm/animation/motionPath.js +185 -0
- package/dist/esm/animation/motionPath.js.map +1 -0
- package/dist/esm/animation/physics.js +192 -0
- package/dist/esm/animation/physics.js.map +1 -0
- package/dist/esm/animation/rig/RigPlayer.js +61 -0
- package/dist/esm/animation/rig/RigPlayer.js.map +1 -0
- package/dist/esm/animation/rig/RiggedBody.js +28 -0
- package/dist/esm/animation/rig/RiggedBody.js.map +1 -0
- package/dist/esm/animation/rig/choreoRigBridge.js +60 -0
- package/dist/esm/animation/rig/choreoRigBridge.js.map +1 -0
- package/dist/esm/animation/rig/ik.js +20 -0
- package/dist/esm/animation/rig/ik.js.map +1 -0
- package/dist/esm/animation/rig/poseOps.js +45 -0
- package/dist/esm/animation/rig/poseOps.js.map +1 -0
- package/dist/esm/animation/rig/presets.js +53 -0
- package/dist/esm/animation/rig/presets.js.map +1 -0
- package/dist/esm/animation/rig/rigMath.js +37 -0
- package/dist/esm/animation/rig/rigMath.js.map +1 -0
- package/dist/esm/animation/rig/rigTypes.js +40 -0
- package/dist/esm/animation/rig/rigTypes.js.map +1 -0
- package/dist/esm/animation/shapes/arms.js +13 -0
- package/dist/esm/animation/shapes/arms.js.map +1 -0
- package/dist/esm/animation/shapes/eyes.js +45 -0
- package/dist/esm/animation/shapes/eyes.js.map +1 -0
- package/dist/esm/animation/shapes/hair.js +46 -0
- package/dist/esm/animation/shapes/hair.js.map +1 -0
- package/dist/esm/animation/shapes/heads.js +52 -0
- package/dist/esm/animation/shapes/heads.js.map +1 -0
- package/dist/esm/animation/shapes/headwear.js +36 -0
- package/dist/esm/animation/shapes/headwear.js.map +1 -0
- package/dist/esm/animation/shapes/legs.js +13 -0
- package/dist/esm/animation/shapes/legs.js.map +1 -0
- package/dist/esm/animation/shapes/mouths.js +45 -0
- package/dist/esm/animation/shapes/mouths.js.map +1 -0
- package/dist/esm/animation/shapes/noses.js +23 -0
- package/dist/esm/animation/shapes/noses.js.map +1 -0
- package/dist/esm/animation/shapes/outfits.js +37 -0
- package/dist/esm/animation/shapes/outfits.js.map +1 -0
- package/dist/esm/animation/shapes/torsos.js +11 -0
- package/dist/esm/animation/shapes/torsos.js.map +1 -0
- package/dist/esm/animation/spineExport.js +128 -0
- package/dist/esm/animation/spineExport.js.map +1 -0
- package/dist/esm/core/LocalUI.js +50 -0
- package/dist/esm/core/LocalUI.js.map +1 -0
- package/dist/esm/core/collaboration.js +252 -0
- package/dist/esm/core/collaboration.js.map +1 -0
- package/dist/esm/core/colorBlindness.js +90 -0
- package/dist/esm/core/colorBlindness.js.map +1 -0
- package/dist/esm/core/dragDrop.js +165 -0
- package/dist/esm/core/dragDrop.js.map +1 -0
- package/dist/esm/core/fixes.js +179 -0
- package/dist/esm/core/fixes.js.map +1 -0
- package/dist/esm/core/gridGuides.js +232 -0
- package/dist/esm/core/gridGuides.js.map +1 -0
- package/dist/esm/core/historyVisual.js +121 -0
- package/dist/esm/core/historyVisual.js.map +1 -0
- package/dist/esm/core/i18n.js +13 -0
- package/dist/esm/core/i18n.js.map +1 -0
- package/dist/esm/core/integrations.js +254 -0
- package/dist/esm/core/integrations.js.map +1 -0
- package/dist/esm/core/minimap.js +139 -0
- package/dist/esm/core/minimap.js.map +1 -0
- package/dist/esm/core/plugins.js +124 -0
- package/dist/esm/core/plugins.js.map +1 -0
- package/dist/esm/core/rtl.js +95 -0
- package/dist/esm/core/rtl.js.map +1 -0
- package/dist/esm/core/shortcuts.js +200 -0
- package/dist/esm/core/shortcuts.js.map +1 -0
- package/dist/esm/core/theme.js +162 -0
- package/dist/esm/core/theme.js.map +1 -0
- package/dist/esm/font/NiceFontEditor.js +189 -0
- package/dist/esm/font/NiceFontEditor.js.map +1 -0
- package/dist/esm/game/GameAsset2dEditor.js +369 -0
- package/dist/esm/game/GameAsset2dEditor.js.map +1 -0
- package/dist/esm/game/GameAsset2dEditor.module.css.js +4 -0
- package/dist/esm/game/GameAsset2dEditor.module.css.js.map +1 -0
- package/dist/esm/game/gameAssetTypes.js +18 -0
- package/dist/esm/game/gameAssetTypes.js.map +1 -0
- package/dist/esm/game/gameAssetUtils.js +456 -0
- package/dist/esm/game/gameAssetUtils.js.map +1 -0
- package/dist/esm/game/useGameAssetEditor.js +759 -0
- package/dist/esm/game/useGameAssetEditor.js.map +1 -0
- package/dist/esm/icon/NiceIconEditor.js +246 -0
- package/dist/esm/icon/NiceIconEditor.js.map +1 -0
- package/dist/esm/index.js +59 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/nice2dev-ui/dist/index.js +31720 -0
- package/dist/esm/nice2dev-ui/dist/index.js.map +1 -0
- package/dist/esm/nice2dev-ui-graphics.css +1 -0
- package/dist/esm/photo/FilterThumb.js +27 -0
- package/dist/esm/photo/FilterThumb.js.map +1 -0
- package/dist/esm/photo/PhotoEditor.js +18 -0
- package/dist/esm/photo/PhotoEditor.js.map +1 -0
- package/dist/esm/photo/PhotoEditor.module.css.js +4 -0
- package/dist/esm/photo/PhotoEditor.module.css.js.map +1 -0
- package/dist/esm/photo/PhotoEditorCanvas.js +57 -0
- package/dist/esm/photo/PhotoEditorCanvas.js.map +1 -0
- package/dist/esm/photo/PhotoEditorLeftPanel.js +172 -0
- package/dist/esm/photo/PhotoEditorLeftPanel.js.map +1 -0
- package/dist/esm/photo/PhotoEditorToolbar.js +13 -0
- package/dist/esm/photo/PhotoEditorToolbar.js.map +1 -0
- package/dist/esm/photo/photoEditorActions.js +75 -0
- package/dist/esm/photo/photoEditorActions.js.map +1 -0
- package/dist/esm/photo/photoEditorTypes.js +36 -0
- package/dist/esm/photo/photoEditorTypes.js.map +1 -0
- package/dist/esm/photo/photoFilters.js +871 -0
- package/dist/esm/photo/photoFilters.js.map +1 -0
- package/dist/esm/photo/photoOverlays.js +636 -0
- package/dist/esm/photo/photoOverlays.js.map +1 -0
- package/dist/esm/photo/photoSelection.js +535 -0
- package/dist/esm/photo/photoSelection.js.map +1 -0
- package/dist/esm/photo/usePhotoEditor.js +638 -0
- package/dist/esm/photo/usePhotoEditor.js.map +1 -0
- package/dist/esm/pixel/HSVPicker.js +171 -0
- package/dist/esm/pixel/HSVPicker.js.map +1 -0
- package/dist/esm/pixel/PixelEditor.js +26 -0
- package/dist/esm/pixel/PixelEditor.js.map +1 -0
- package/dist/esm/pixel/PixelEditor.module.css.js +4 -0
- package/dist/esm/pixel/PixelEditor.module.css.js.map +1 -0
- package/dist/esm/pixel/PixelEditorCanvas.js +13 -0
- package/dist/esm/pixel/PixelEditorCanvas.js.map +1 -0
- package/dist/esm/pixel/PixelEditorMenuBar.js +9 -0
- package/dist/esm/pixel/PixelEditorMenuBar.js.map +1 -0
- package/dist/esm/pixel/PixelEditorRightPanel.js +13 -0
- package/dist/esm/pixel/PixelEditorRightPanel.js.map +1 -0
- package/dist/esm/pixel/PixelEditorStatusBar.js +13 -0
- package/dist/esm/pixel/PixelEditorStatusBar.js.map +1 -0
- package/dist/esm/pixel/PixelEditorTimeline.js +9 -0
- package/dist/esm/pixel/PixelEditorTimeline.js.map +1 -0
- package/dist/esm/pixel/PixelEditorToolbar.js +14 -0
- package/dist/esm/pixel/PixelEditorToolbar.js.map +1 -0
- package/dist/esm/pixel/asepriteFormat.js +505 -0
- package/dist/esm/pixel/asepriteFormat.js.map +1 -0
- package/dist/esm/pixel/pixelEditorExports.js +461 -0
- package/dist/esm/pixel/pixelEditorExports.js.map +1 -0
- package/dist/esm/pixel/pixelEditorTypes.js +90 -0
- package/dist/esm/pixel/pixelEditorTypes.js.map +1 -0
- package/dist/esm/pixel/pixelEditorUtils.js +631 -0
- package/dist/esm/pixel/pixelEditorUtils.js.map +1 -0
- package/dist/esm/pixel/usePixelEditor.js +1110 -0
- package/dist/esm/pixel/usePixelEditor.js.map +1 -0
- package/dist/esm/texture/Nice3DTexturePainter.js +233 -0
- package/dist/esm/texture/Nice3DTexturePainter.js.map +1 -0
- package/dist/esm/ui/NiceUIDesigner.js +187 -0
- package/dist/esm/ui/NiceUIDesigner.js.map +1 -0
- package/dist/esm/vector/VectorEditor.js +29 -0
- package/dist/esm/vector/VectorEditor.js.map +1 -0
- package/dist/esm/vector/VectorEditor.module.css.js +4 -0
- package/dist/esm/vector/VectorEditor.module.css.js.map +1 -0
- package/dist/esm/vector/VectorEditorMenuBar.js +14 -0
- package/dist/esm/vector/VectorEditorMenuBar.js.map +1 -0
- package/dist/esm/vector/VectorEditorRightPanel.js +124 -0
- package/dist/esm/vector/VectorEditorRightPanel.js.map +1 -0
- package/dist/esm/vector/VectorEditorShapeRenderer.js +53 -0
- package/dist/esm/vector/VectorEditorShapeRenderer.js.map +1 -0
- package/dist/esm/vector/VectorEditorStatusBar.js +12 -0
- package/dist/esm/vector/VectorEditorStatusBar.js.map +1 -0
- package/dist/esm/vector/useVectorEditor.js +611 -0
- package/dist/esm/vector/useVectorEditor.js.map +1 -0
- package/dist/esm/vector/vectorBooleanOps.js +507 -0
- package/dist/esm/vector/vectorBooleanOps.js.map +1 -0
- package/dist/esm/vector/vectorEditorExport.js +152 -0
- package/dist/esm/vector/vectorEditorExport.js.map +1 -0
- package/dist/esm/vector/vectorEditorImport.js +148 -0
- package/dist/esm/vector/vectorEditorImport.js.map +1 -0
- package/dist/esm/vector/vectorEditorTypes.js +63 -0
- package/dist/esm/vector/vectorEditorTypes.js.map +1 -0
- package/dist/esm/vector/vectorGradients.js +193 -0
- package/dist/esm/vector/vectorGradients.js.map +1 -0
- package/dist/types/__benchmarks__/bench.d.ts +13 -0
- package/dist/types/__tests__/setup.d.ts +4 -0
- package/dist/types/animation/AnimatedPerson.d.ts +14 -0
- package/dist/types/animation/AnimationEditor.d.ts +20 -0
- package/dist/types/animation/Audience.d.ts +11 -0
- package/dist/types/animation/BodyRenderer.d.ts +12 -0
- package/dist/types/animation/animationHelper.d.ts +28 -0
- package/dist/types/animation/characterTypes.d.ts +37 -0
- package/dist/types/animation/choreoDSL.d.ts +88 -0
- package/dist/types/animation/choreography.d.ts +8 -0
- package/dist/types/animation/karaokeIntegration.d.ts +31 -0
- package/dist/types/animation/lottieExport.d.ts +77 -0
- package/dist/types/animation/motionPath.d.ts +60 -0
- package/dist/types/animation/physics.d.ts +73 -0
- package/dist/types/animation/rig/RigPlayer.d.ts +32 -0
- package/dist/types/animation/rig/RiggedBody.d.ts +19 -0
- package/dist/types/animation/rig/choreoRigBridge.d.ts +9 -0
- package/dist/types/animation/rig/ik.d.ts +8 -0
- package/dist/types/animation/rig/poseOps.d.ts +14 -0
- package/dist/types/animation/rig/presets.d.ts +13 -0
- package/dist/types/animation/rig/rigMath.d.ts +7 -0
- package/dist/types/animation/rig/rigTypes.d.ts +38 -0
- package/dist/types/animation/shapes/arms.d.ts +10 -0
- package/dist/types/animation/shapes/eyes.d.ts +17 -0
- package/dist/types/animation/shapes/hair.d.ts +17 -0
- package/dist/types/animation/shapes/heads.d.ts +18 -0
- package/dist/types/animation/shapes/headwear.d.ts +16 -0
- package/dist/types/animation/shapes/legs.d.ts +10 -0
- package/dist/types/animation/shapes/mouths.d.ts +17 -0
- package/dist/types/animation/shapes/noses.d.ts +17 -0
- package/dist/types/animation/shapes/outfits.d.ts +14 -0
- package/dist/types/animation/shapes/torsos.d.ts +9 -0
- package/dist/types/animation/spineExport.d.ts +66 -0
- package/dist/types/core/LocalUI.d.ts +21 -0
- package/dist/types/core/collaboration.d.ts +164 -0
- package/dist/types/core/colorBlindness.d.ts +24 -0
- package/dist/types/core/dragDrop.d.ts +46 -0
- package/dist/types/core/fixes.d.ts +80 -0
- package/dist/types/core/gridGuides.d.ts +70 -0
- package/dist/types/core/historyVisual.d.ts +915 -0
- package/dist/types/core/i18n.d.ts +27 -0
- package/dist/types/core/integrations.d.ts +103 -0
- package/dist/types/core/minimap.d.ts +49 -0
- package/dist/types/core/plugins.d.ts +111 -0
- package/dist/types/core/rtl.d.ts +32 -0
- package/dist/types/core/shortcuts.d.ts +150 -0
- package/dist/types/core/theme.d.ts +78 -0
- package/dist/types/core/useGamepad.d.ts +64 -0
- package/dist/types/core/usePointerPressure.d.ts +88 -0
- package/dist/types/font/NiceFontEditor.d.ts +62 -0
- package/dist/types/game/AnimationPreviewPlayer.d.ts +29 -0
- package/dist/types/game/CollisionEditor.d.ts +101 -0
- package/dist/types/game/GameAsset2dEditor.d.ts +17 -0
- package/dist/types/game/GameAssetExportPanel.d.ts +20 -0
- package/dist/types/game/IsometricEditor.d.ts +22 -0
- package/dist/types/game/IsometricTilePanel.d.ts +18 -0
- package/dist/types/game/gameAssetExport.d.ts +160 -0
- package/dist/types/game/gameAssetTypes.d.ts +238 -0
- package/dist/types/game/gameAssetUtils.d.ts +23 -0
- package/dist/types/game/index.d.ts +8 -0
- package/dist/types/game/isometricTiles.d.ts +250 -0
- package/dist/types/game/useAnimationPreview.d.ts +63 -0
- package/dist/types/game/useCollisionEditor.d.ts +96 -0
- package/dist/types/game/useGameAssetEditor.d.ts +79 -0
- package/dist/types/game/useGameAssetExport.d.ts +82 -0
- package/dist/types/icon/NiceIconEditor.d.ts +79 -0
- package/dist/types/index.d.ts +85 -0
- package/dist/types/photo/BatchProcessingPanel.d.ts +13 -0
- package/dist/types/photo/FaceDetectionPanel.d.ts +18 -0
- package/dist/types/photo/FilterThumb.d.ts +14 -0
- package/dist/types/photo/PerspectiveCorrectionPanel.d.ts +17 -0
- package/dist/types/photo/PhotoEditor.d.ts +2 -0
- package/dist/types/photo/PhotoEditorCanvas.d.ts +14 -0
- package/dist/types/photo/PhotoEditorLeftPanel.d.ts +13 -0
- package/dist/types/photo/PhotoEditorToolbar.d.ts +13 -0
- package/dist/types/photo/RawFilePanel.d.ts +14 -0
- package/dist/types/photo/StyleTransferPanel.d.ts +15 -0
- package/dist/types/photo/aiStyleTransfer.d.ts +58 -0
- package/dist/types/photo/batchProcessing.d.ts +95 -0
- package/dist/types/photo/faceDetection.d.ts +103 -0
- package/dist/types/photo/index.d.ts +17 -0
- package/dist/types/photo/perspectiveCorrection.d.ts +134 -0
- package/dist/types/photo/photoEditorActions.d.ts +40 -0
- package/dist/types/photo/photoEditorTypes.d.ts +34 -0
- package/dist/types/photo/photoFilters.d.ts +55 -0
- package/dist/types/photo/photoOverlays.d.ts +126 -0
- package/dist/types/photo/photoSelection.d.ts +56 -0
- package/dist/types/photo/rawFileSupport.d.ts +124 -0
- package/dist/types/photo/usePhotoEditor.d.ts +123 -0
- package/dist/types/pixel/HSVPicker.d.ts +11 -0
- package/dist/types/pixel/PaletteExtractorPanel.d.ts +16 -0
- package/dist/types/pixel/PixelEditor.d.ts +17 -0
- package/dist/types/pixel/PixelEditorCanvas.d.ts +10 -0
- package/dist/types/pixel/PixelEditorMenuBar.d.ts +11 -0
- package/dist/types/pixel/PixelEditorRightPanel.d.ts +11 -0
- package/dist/types/pixel/PixelEditorStatusBar.d.ts +11 -0
- package/dist/types/pixel/PixelEditorTimeline.d.ts +11 -0
- package/dist/types/pixel/PixelEditorToolbar.d.ts +11 -0
- package/dist/types/pixel/TileMapPanel.d.ts +14 -0
- package/dist/types/pixel/asepriteFormat.d.ts +62 -0
- package/dist/types/pixel/paletteExtractor.d.ts +73 -0
- package/dist/types/pixel/pixelEditorExports.d.ts +31 -0
- package/dist/types/pixel/pixelEditorTypes.d.ts +51 -0
- package/dist/types/pixel/pixelEditorUtils.d.ts +136 -0
- package/dist/types/pixel/tileMapMode.d.ts +122 -0
- package/dist/types/pixel/usePixelEditor.d.ts +114 -0
- package/dist/types/texture/Nice3DTexturePainter.d.ts +55 -0
- package/dist/types/ui/NiceUIDesigner.d.ts +43 -0
- package/dist/types/vector/PathSimplificationPanel.d.ts +15 -0
- package/dist/types/vector/PdfExportPanel.d.ts +20 -0
- package/dist/types/vector/TextOnPathPanel.d.ts +26 -0
- package/dist/types/vector/VectorEditor.d.ts +32 -0
- package/dist/types/vector/VectorEditorMenuBar.d.ts +8 -0
- package/dist/types/vector/VectorEditorRightPanel.d.ts +7 -0
- package/dist/types/vector/VectorEditorShapeRenderer.d.ts +9 -0
- package/dist/types/vector/VectorEditorStatusBar.d.ts +9 -0
- package/dist/types/vector/VectorFilterPanel.d.ts +19 -0
- package/dist/types/vector/VectorPatternPanel.d.ts +21 -0
- package/dist/types/vector/pathSimplification.d.ts +135 -0
- package/dist/types/vector/pdfExport.d.ts +65 -0
- package/dist/types/vector/textOnPath.d.ts +145 -0
- package/dist/types/vector/useVectorEditor.d.ts +90 -0
- package/dist/types/vector/vectorBooleanOps.d.ts +22 -0
- package/dist/types/vector/vectorEditorExport.d.ts +8 -0
- package/dist/types/vector/vectorEditorImport.d.ts +7 -0
- package/dist/types/vector/vectorEditorTypes.d.ts +47 -0
- package/dist/types/vector/vectorGradients.d.ts +64 -0
- package/dist/types/vector/vectorPatternFills.d.ts +101 -0
- package/dist/types/vector/vectorSvgFilters.d.ts +134 -0
- package/package.json +93 -0
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
import { useState, useRef, useCallback } from 'react';
|
|
2
|
+
import { createEmptyProject, generateId, serializeProject, downloadJson, deserializeProject, createTileFromImage, dataUrlToImageData, createEmptyTileMap, createEmptyTileLayer, loadImage, autoSliceSpriteSheet, detectFrames, createSpriteAnimation, applyEffects, exportToTiledJson, downloadPng } from './gameAssetUtils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* useGameAssetEditor.ts — State and logic hook for GameAsset2dEditor
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_EDITOR_STATE = {
|
|
8
|
+
mode: 'tilemap',
|
|
9
|
+
tileMapTool: 'brush',
|
|
10
|
+
spriteSheetTool: 'select',
|
|
11
|
+
selectedTileId: null,
|
|
12
|
+
selectedFrameIds: [],
|
|
13
|
+
selectedStateId: null,
|
|
14
|
+
activeLayerId: null,
|
|
15
|
+
activeTileMapId: null,
|
|
16
|
+
activeSpriteSheetId: null,
|
|
17
|
+
activeStateMachineId: null,
|
|
18
|
+
zoom: 1,
|
|
19
|
+
panX: 0,
|
|
20
|
+
panY: 0,
|
|
21
|
+
showGrid: true,
|
|
22
|
+
showCollision: false,
|
|
23
|
+
snapToGrid: true,
|
|
24
|
+
};
|
|
25
|
+
const MAX_HISTORY = 50;
|
|
26
|
+
const useGameAssetEditor = (options = {}) => {
|
|
27
|
+
const { onSave, onExport } = options;
|
|
28
|
+
const [project, setProject] = useState(() => createEmptyProject('Untitled'));
|
|
29
|
+
const [editorState, setEditorState] = useState(DEFAULT_EDITOR_STATE);
|
|
30
|
+
const [history, setHistory] = useState([]);
|
|
31
|
+
const [historyIndex, setHistoryIndex] = useState(-1);
|
|
32
|
+
const [currentEffects, setCurrentEffects] = useState([]);
|
|
33
|
+
const canvasRef = useRef(null);
|
|
34
|
+
const fileInputRef = useRef(null);
|
|
35
|
+
// ─────────────────────────────────────────────────────────────
|
|
36
|
+
// History management
|
|
37
|
+
// ─────────────────────────────────────────────────────────────
|
|
38
|
+
const pushHistory = useCallback((description) => {
|
|
39
|
+
const entry = {
|
|
40
|
+
id: generateId('history'),
|
|
41
|
+
description,
|
|
42
|
+
timestamp: Date.now(),
|
|
43
|
+
snapshot: JSON.parse(JSON.stringify(project)),
|
|
44
|
+
};
|
|
45
|
+
setHistory(prev => {
|
|
46
|
+
const newHistory = prev.slice(0, historyIndex + 1);
|
|
47
|
+
newHistory.push(entry);
|
|
48
|
+
if (newHistory.length > MAX_HISTORY)
|
|
49
|
+
newHistory.shift();
|
|
50
|
+
return newHistory;
|
|
51
|
+
});
|
|
52
|
+
setHistoryIndex(prev => Math.min(prev + 1, MAX_HISTORY - 1));
|
|
53
|
+
}, [project, historyIndex]);
|
|
54
|
+
const undo = useCallback(() => {
|
|
55
|
+
if (historyIndex > 0) {
|
|
56
|
+
const entry = history[historyIndex - 1];
|
|
57
|
+
setProject(entry.snapshot);
|
|
58
|
+
setHistoryIndex(prev => prev - 1);
|
|
59
|
+
}
|
|
60
|
+
}, [history, historyIndex]);
|
|
61
|
+
const redo = useCallback(() => {
|
|
62
|
+
if (historyIndex < history.length - 1) {
|
|
63
|
+
const entry = history[historyIndex + 1];
|
|
64
|
+
setProject(entry.snapshot);
|
|
65
|
+
setHistoryIndex(prev => prev + 1);
|
|
66
|
+
}
|
|
67
|
+
}, [history, historyIndex]);
|
|
68
|
+
// ─────────────────────────────────────────────────────────────
|
|
69
|
+
// Project operations
|
|
70
|
+
// ─────────────────────────────────────────────────────────────
|
|
71
|
+
const newProject = useCallback((name) => {
|
|
72
|
+
const newProj = createEmptyProject(name);
|
|
73
|
+
setProject(newProj);
|
|
74
|
+
setEditorState(DEFAULT_EDITOR_STATE);
|
|
75
|
+
setHistory([]);
|
|
76
|
+
setHistoryIndex(-1);
|
|
77
|
+
}, []);
|
|
78
|
+
const saveProject = useCallback(() => {
|
|
79
|
+
const data = serializeProject(project);
|
|
80
|
+
downloadJson(JSON.parse(data), `${project.name}.json`);
|
|
81
|
+
onSave === null || onSave === void 0 ? void 0 : onSave(project);
|
|
82
|
+
}, [project, onSave]);
|
|
83
|
+
const loadProject = useCallback(async (file) => {
|
|
84
|
+
const text = await file.text();
|
|
85
|
+
const loaded = await deserializeProject(text);
|
|
86
|
+
setProject(loaded);
|
|
87
|
+
setEditorState(DEFAULT_EDITOR_STATE);
|
|
88
|
+
setHistory([]);
|
|
89
|
+
setHistoryIndex(-1);
|
|
90
|
+
}, []);
|
|
91
|
+
// ─────────────────────────────────────────────────────────────
|
|
92
|
+
// Editor state operations
|
|
93
|
+
// ─────────────────────────────────────────────────────────────
|
|
94
|
+
const setMode = useCallback((mode) => {
|
|
95
|
+
setEditorState(prev => ({ ...prev, mode }));
|
|
96
|
+
}, []);
|
|
97
|
+
const setTileMapTool = useCallback((tool) => {
|
|
98
|
+
setEditorState(prev => ({ ...prev, tileMapTool: tool }));
|
|
99
|
+
}, []);
|
|
100
|
+
const setSpriteSheetTool = useCallback((tool) => {
|
|
101
|
+
setEditorState(prev => ({ ...prev, spriteSheetTool: tool }));
|
|
102
|
+
}, []);
|
|
103
|
+
const setZoom = useCallback((zoom) => {
|
|
104
|
+
setEditorState(prev => ({ ...prev, zoom: Math.max(0.1, Math.min(10, zoom)) }));
|
|
105
|
+
}, []);
|
|
106
|
+
const setPan = useCallback((x, y) => {
|
|
107
|
+
setEditorState(prev => ({ ...prev, panX: x, panY: y }));
|
|
108
|
+
}, []);
|
|
109
|
+
const toggleGrid = useCallback(() => {
|
|
110
|
+
setEditorState(prev => ({ ...prev, showGrid: !prev.showGrid }));
|
|
111
|
+
}, []);
|
|
112
|
+
const toggleCollision = useCallback(() => {
|
|
113
|
+
setEditorState(prev => ({ ...prev, showCollision: !prev.showCollision }));
|
|
114
|
+
}, []);
|
|
115
|
+
const toggleSnap = useCallback(() => {
|
|
116
|
+
setEditorState(prev => ({ ...prev, snapToGrid: !prev.snapToGrid }));
|
|
117
|
+
}, []);
|
|
118
|
+
// ─────────────────────────────────────────────────────────────
|
|
119
|
+
// Tile set operations
|
|
120
|
+
// ─────────────────────────────────────────────────────────────
|
|
121
|
+
const addTile = useCallback((imageData, name) => {
|
|
122
|
+
const tile = createTileFromImage(imageData, name);
|
|
123
|
+
setProject(prev => ({ ...prev, tileSets: [...prev.tileSets, tile] }));
|
|
124
|
+
pushHistory(`Add tile: ${name}`);
|
|
125
|
+
}, [pushHistory]);
|
|
126
|
+
const removeTile = useCallback((id) => {
|
|
127
|
+
setProject(prev => ({
|
|
128
|
+
...prev,
|
|
129
|
+
tileSets: prev.tileSets.filter(t => t.id !== id),
|
|
130
|
+
}));
|
|
131
|
+
pushHistory('Remove tile');
|
|
132
|
+
}, [pushHistory]);
|
|
133
|
+
const selectTile = useCallback((id) => {
|
|
134
|
+
setEditorState(prev => ({ ...prev, selectedTileId: id }));
|
|
135
|
+
}, []);
|
|
136
|
+
const importTileSet = useCallback(async (file) => {
|
|
137
|
+
const dataUrl = await new Promise((resolve) => {
|
|
138
|
+
const reader = new FileReader();
|
|
139
|
+
reader.onload = () => resolve(reader.result);
|
|
140
|
+
reader.readAsDataURL(file);
|
|
141
|
+
});
|
|
142
|
+
const imageData = await dataUrlToImageData(dataUrl);
|
|
143
|
+
const name = file.name.replace(/\.[^/.]+$/, '');
|
|
144
|
+
addTile(imageData, name);
|
|
145
|
+
}, [addTile]);
|
|
146
|
+
// ─────────────────────────────────────────────────────────────
|
|
147
|
+
// Tile map operations
|
|
148
|
+
// ─────────────────────────────────────────────────────────────
|
|
149
|
+
const createTileMap = useCallback((name, width, height) => {
|
|
150
|
+
const map = createEmptyTileMap(name, width, height, project.settings.defaultTileWidth, project.settings.defaultTileHeight);
|
|
151
|
+
setProject(prev => ({ ...prev, tileMaps: [...prev.tileMaps, map] }));
|
|
152
|
+
setEditorState(prev => ({
|
|
153
|
+
...prev,
|
|
154
|
+
activeTileMapId: map.id,
|
|
155
|
+
activeLayerId: map.layers[0].id,
|
|
156
|
+
}));
|
|
157
|
+
pushHistory(`Create tile map: ${name}`);
|
|
158
|
+
}, [project.settings, pushHistory]);
|
|
159
|
+
const removeTileMap = useCallback((id) => {
|
|
160
|
+
setProject(prev => ({
|
|
161
|
+
...prev,
|
|
162
|
+
tileMaps: prev.tileMaps.filter(m => m.id !== id),
|
|
163
|
+
}));
|
|
164
|
+
pushHistory('Remove tile map');
|
|
165
|
+
}, [pushHistory]);
|
|
166
|
+
const selectTileMap = useCallback((id) => {
|
|
167
|
+
setEditorState(prev => {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
const map = project.tileMaps.find(m => m.id === id);
|
|
170
|
+
return {
|
|
171
|
+
...prev,
|
|
172
|
+
activeTileMapId: id,
|
|
173
|
+
activeLayerId: (_b = (_a = map === null || map === void 0 ? void 0 : map.layers[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null,
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}, [project.tileMaps]);
|
|
177
|
+
const setTile = useCallback((layerId, x, y, tileId) => {
|
|
178
|
+
setProject(prev => ({
|
|
179
|
+
...prev,
|
|
180
|
+
tileMaps: prev.tileMaps.map(map => ({
|
|
181
|
+
...map,
|
|
182
|
+
layers: map.layers.map(layer => {
|
|
183
|
+
if (layer.id !== layerId)
|
|
184
|
+
return layer;
|
|
185
|
+
const newTiles = layer.tiles.map(row => [...row]);
|
|
186
|
+
if (y >= 0 && y < newTiles.length && x >= 0 && x < newTiles[0].length) {
|
|
187
|
+
newTiles[y][x] = tileId;
|
|
188
|
+
}
|
|
189
|
+
return { ...layer, tiles: newTiles };
|
|
190
|
+
}),
|
|
191
|
+
})),
|
|
192
|
+
}));
|
|
193
|
+
}, []);
|
|
194
|
+
const fillTiles = useCallback((layerId, startX, startY, newTileId) => {
|
|
195
|
+
setProject(prev => {
|
|
196
|
+
var _a;
|
|
197
|
+
const map = prev.tileMaps.find(m => m.layers.some(l => l.id === layerId));
|
|
198
|
+
if (!map)
|
|
199
|
+
return prev;
|
|
200
|
+
const layer = map.layers.find(l => l.id === layerId);
|
|
201
|
+
if (!layer)
|
|
202
|
+
return prev;
|
|
203
|
+
const targetId = (_a = layer.tiles[startY]) === null || _a === void 0 ? void 0 : _a[startX];
|
|
204
|
+
if (targetId === newTileId)
|
|
205
|
+
return prev;
|
|
206
|
+
const newTiles = layer.tiles.map(row => [...row]);
|
|
207
|
+
const stack = [[startX, startY]];
|
|
208
|
+
const visited = new Set();
|
|
209
|
+
while (stack.length > 0) {
|
|
210
|
+
const [x, y] = stack.pop();
|
|
211
|
+
const key = `${x},${y}`;
|
|
212
|
+
if (visited.has(key))
|
|
213
|
+
continue;
|
|
214
|
+
if (y < 0 || y >= newTiles.length || x < 0 || x >= newTiles[0].length)
|
|
215
|
+
continue;
|
|
216
|
+
if (newTiles[y][x] !== targetId)
|
|
217
|
+
continue;
|
|
218
|
+
visited.add(key);
|
|
219
|
+
newTiles[y][x] = newTileId;
|
|
220
|
+
stack.push([x + 1, y], [x - 1, y], [x, y + 1], [x, y - 1]);
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
...prev,
|
|
224
|
+
tileMaps: prev.tileMaps.map(m => m.id === map.id
|
|
225
|
+
? { ...m, layers: m.layers.map(l => (l.id === layerId ? { ...l, tiles: newTiles } : l)) }
|
|
226
|
+
: m),
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
pushHistory('Fill tiles');
|
|
230
|
+
}, [pushHistory]);
|
|
231
|
+
const addLayer = useCallback(() => {
|
|
232
|
+
const map = project.tileMaps.find(m => m.id === editorState.activeTileMapId);
|
|
233
|
+
if (!map)
|
|
234
|
+
return;
|
|
235
|
+
const newLayer = createEmptyTileLayer(`Layer ${map.layers.length + 1}`, map.width, map.height);
|
|
236
|
+
setProject(prev => ({
|
|
237
|
+
...prev,
|
|
238
|
+
tileMaps: prev.tileMaps.map(m => m.id === map.id ? { ...m, layers: [...m.layers, newLayer] } : m),
|
|
239
|
+
}));
|
|
240
|
+
setEditorState(prev => ({ ...prev, activeLayerId: newLayer.id }));
|
|
241
|
+
pushHistory('Add layer');
|
|
242
|
+
}, [project.tileMaps, editorState.activeTileMapId, pushHistory]);
|
|
243
|
+
const removeLayer = useCallback((id) => {
|
|
244
|
+
setProject(prev => ({
|
|
245
|
+
...prev,
|
|
246
|
+
tileMaps: prev.tileMaps.map(m => ({
|
|
247
|
+
...m,
|
|
248
|
+
layers: m.layers.filter(l => l.id !== id),
|
|
249
|
+
})),
|
|
250
|
+
}));
|
|
251
|
+
pushHistory('Remove layer');
|
|
252
|
+
}, [pushHistory]);
|
|
253
|
+
const selectLayer = useCallback((id) => {
|
|
254
|
+
setEditorState(prev => ({ ...prev, activeLayerId: id }));
|
|
255
|
+
}, []);
|
|
256
|
+
const toggleLayerVisibility = useCallback((id) => {
|
|
257
|
+
setProject(prev => ({
|
|
258
|
+
...prev,
|
|
259
|
+
tileMaps: prev.tileMaps.map(m => ({
|
|
260
|
+
...m,
|
|
261
|
+
layers: m.layers.map(l => (l.id === id ? { ...l, visible: !l.visible } : l)),
|
|
262
|
+
})),
|
|
263
|
+
}));
|
|
264
|
+
}, []);
|
|
265
|
+
const setLayerOpacity = useCallback((id, opacity) => {
|
|
266
|
+
setProject(prev => ({
|
|
267
|
+
...prev,
|
|
268
|
+
tileMaps: prev.tileMaps.map(m => ({
|
|
269
|
+
...m,
|
|
270
|
+
layers: m.layers.map(l => (l.id === id ? { ...l, opacity } : l)),
|
|
271
|
+
})),
|
|
272
|
+
}));
|
|
273
|
+
}, []);
|
|
274
|
+
const moveLayer = useCallback((id, direction) => {
|
|
275
|
+
setProject(prev => ({
|
|
276
|
+
...prev,
|
|
277
|
+
tileMaps: prev.tileMaps.map(m => {
|
|
278
|
+
const idx = m.layers.findIndex(l => l.id === id);
|
|
279
|
+
if (idx === -1)
|
|
280
|
+
return m;
|
|
281
|
+
const newIdx = direction === 'up' ? idx - 1 : idx + 1;
|
|
282
|
+
if (newIdx < 0 || newIdx >= m.layers.length)
|
|
283
|
+
return m;
|
|
284
|
+
const newLayers = [...m.layers];
|
|
285
|
+
[newLayers[idx], newLayers[newIdx]] = [newLayers[newIdx], newLayers[idx]];
|
|
286
|
+
return { ...m, layers: newLayers };
|
|
287
|
+
}),
|
|
288
|
+
}));
|
|
289
|
+
pushHistory(`Move layer ${direction}`);
|
|
290
|
+
}, [pushHistory]);
|
|
291
|
+
// ─────────────────────────────────────────────────────────────
|
|
292
|
+
// Sprite sheet operations
|
|
293
|
+
// ─────────────────────────────────────────────────────────────
|
|
294
|
+
const importSpriteSheet = useCallback(async (file) => {
|
|
295
|
+
const dataUrl = await new Promise((resolve) => {
|
|
296
|
+
const reader = new FileReader();
|
|
297
|
+
reader.onload = () => resolve(reader.result);
|
|
298
|
+
reader.readAsDataURL(file);
|
|
299
|
+
});
|
|
300
|
+
const image = await loadImage(dataUrl);
|
|
301
|
+
const canvas = document.createElement('canvas');
|
|
302
|
+
canvas.width = image.width;
|
|
303
|
+
canvas.height = image.height;
|
|
304
|
+
const ctx = canvas.getContext('2d');
|
|
305
|
+
ctx.drawImage(image, 0, 0);
|
|
306
|
+
const imageData = ctx.getImageData(0, 0, image.width, image.height);
|
|
307
|
+
const sheet = {
|
|
308
|
+
id: generateId('sheet'),
|
|
309
|
+
name: file.name.replace(/\.[^/.]+$/, ''),
|
|
310
|
+
image,
|
|
311
|
+
imageData,
|
|
312
|
+
dataUrl,
|
|
313
|
+
width: image.width,
|
|
314
|
+
height: image.height,
|
|
315
|
+
frames: [],
|
|
316
|
+
animations: [],
|
|
317
|
+
};
|
|
318
|
+
setProject(prev => ({ ...prev, spriteSheets: [...prev.spriteSheets, sheet] }));
|
|
319
|
+
setEditorState(prev => ({ ...prev, activeSpriteSheetId: sheet.id }));
|
|
320
|
+
pushHistory(`Import sprite sheet: ${sheet.name}`);
|
|
321
|
+
}, [pushHistory]);
|
|
322
|
+
const removeSpriteSheet = useCallback((id) => {
|
|
323
|
+
setProject(prev => ({
|
|
324
|
+
...prev,
|
|
325
|
+
spriteSheets: prev.spriteSheets.filter(s => s.id !== id),
|
|
326
|
+
}));
|
|
327
|
+
pushHistory('Remove sprite sheet');
|
|
328
|
+
}, [pushHistory]);
|
|
329
|
+
const selectSpriteSheet = useCallback((id) => {
|
|
330
|
+
setEditorState(prev => ({ ...prev, activeSpriteSheetId: id, selectedFrameIds: [] }));
|
|
331
|
+
}, []);
|
|
332
|
+
const autoSlice = useCallback((frameWidth, frameHeight) => {
|
|
333
|
+
const sheet = project.spriteSheets.find(s => s.id === editorState.activeSpriteSheetId);
|
|
334
|
+
if (!(sheet === null || sheet === void 0 ? void 0 : sheet.imageData))
|
|
335
|
+
return;
|
|
336
|
+
const frames = autoSliceSpriteSheet(sheet.imageData, frameWidth, frameHeight);
|
|
337
|
+
setProject(prev => ({
|
|
338
|
+
...prev,
|
|
339
|
+
spriteSheets: prev.spriteSheets.map(s => s.id === sheet.id ? { ...s, frames } : s),
|
|
340
|
+
}));
|
|
341
|
+
pushHistory('Auto-slice sprite sheet');
|
|
342
|
+
}, [project.spriteSheets, editorState.activeSpriteSheetId, pushHistory]);
|
|
343
|
+
const detectSprites = useCallback(() => {
|
|
344
|
+
const sheet = project.spriteSheets.find(s => s.id === editorState.activeSpriteSheetId);
|
|
345
|
+
if (!(sheet === null || sheet === void 0 ? void 0 : sheet.imageData))
|
|
346
|
+
return;
|
|
347
|
+
const frames = detectFrames(sheet.imageData);
|
|
348
|
+
setProject(prev => ({
|
|
349
|
+
...prev,
|
|
350
|
+
spriteSheets: prev.spriteSheets.map(s => s.id === sheet.id ? { ...s, frames } : s),
|
|
351
|
+
}));
|
|
352
|
+
pushHistory('Detect sprites');
|
|
353
|
+
}, [project.spriteSheets, editorState.activeSpriteSheetId, pushHistory]);
|
|
354
|
+
const addFrame = useCallback((frame) => {
|
|
355
|
+
const newFrame = { ...frame, id: generateId('frame') };
|
|
356
|
+
setProject(prev => ({
|
|
357
|
+
...prev,
|
|
358
|
+
spriteSheets: prev.spriteSheets.map(s => s.id === editorState.activeSpriteSheetId
|
|
359
|
+
? { ...s, frames: [...s.frames, newFrame] }
|
|
360
|
+
: s),
|
|
361
|
+
}));
|
|
362
|
+
pushHistory('Add frame');
|
|
363
|
+
}, [editorState.activeSpriteSheetId, pushHistory]);
|
|
364
|
+
const updateFrame = useCallback((id, updates) => {
|
|
365
|
+
setProject(prev => ({
|
|
366
|
+
...prev,
|
|
367
|
+
spriteSheets: prev.spriteSheets.map(s => ({
|
|
368
|
+
...s,
|
|
369
|
+
frames: s.frames.map(f => (f.id === id ? { ...f, ...updates } : f)),
|
|
370
|
+
})),
|
|
371
|
+
}));
|
|
372
|
+
}, []);
|
|
373
|
+
const removeFrame = useCallback((id) => {
|
|
374
|
+
setProject(prev => ({
|
|
375
|
+
...prev,
|
|
376
|
+
spriteSheets: prev.spriteSheets.map(s => ({
|
|
377
|
+
...s,
|
|
378
|
+
frames: s.frames.filter(f => f.id !== id),
|
|
379
|
+
})),
|
|
380
|
+
}));
|
|
381
|
+
pushHistory('Remove frame');
|
|
382
|
+
}, [pushHistory]);
|
|
383
|
+
const selectFrames = useCallback((ids) => {
|
|
384
|
+
setEditorState(prev => ({ ...prev, selectedFrameIds: ids }));
|
|
385
|
+
}, []);
|
|
386
|
+
// ─────────────────────────────────────────────────────────────
|
|
387
|
+
// Animation operations
|
|
388
|
+
// ─────────────────────────────────────────────────────────────
|
|
389
|
+
const createAnimation = useCallback((name, frameIds) => {
|
|
390
|
+
const animation = createSpriteAnimation(name, frameIds);
|
|
391
|
+
setProject(prev => ({
|
|
392
|
+
...prev,
|
|
393
|
+
spriteSheets: prev.spriteSheets.map(s => s.id === editorState.activeSpriteSheetId
|
|
394
|
+
? { ...s, animations: [...s.animations, animation] }
|
|
395
|
+
: s),
|
|
396
|
+
}));
|
|
397
|
+
pushHistory(`Create animation: ${name}`);
|
|
398
|
+
}, [editorState.activeSpriteSheetId, pushHistory]);
|
|
399
|
+
const removeAnimation = useCallback((id) => {
|
|
400
|
+
setProject(prev => ({
|
|
401
|
+
...prev,
|
|
402
|
+
spriteSheets: prev.spriteSheets.map(s => ({
|
|
403
|
+
...s,
|
|
404
|
+
animations: s.animations.filter(a => a.id !== id),
|
|
405
|
+
})),
|
|
406
|
+
}));
|
|
407
|
+
pushHistory('Remove animation');
|
|
408
|
+
}, [pushHistory]);
|
|
409
|
+
const updateAnimation = useCallback((id, updates) => {
|
|
410
|
+
setProject(prev => ({
|
|
411
|
+
...prev,
|
|
412
|
+
spriteSheets: prev.spriteSheets.map(s => ({
|
|
413
|
+
...s,
|
|
414
|
+
animations: s.animations.map(a => (a.id === id ? { ...a, ...updates } : a)),
|
|
415
|
+
})),
|
|
416
|
+
}));
|
|
417
|
+
}, []);
|
|
418
|
+
// ─────────────────────────────────────────────────────────────
|
|
419
|
+
// State machine operations
|
|
420
|
+
// ─────────────────────────────────────────────────────────────
|
|
421
|
+
const createStateMachine = useCallback((name) => {
|
|
422
|
+
const sm = {
|
|
423
|
+
id: generateId('sm'),
|
|
424
|
+
name,
|
|
425
|
+
states: [],
|
|
426
|
+
transitions: [],
|
|
427
|
+
parameters: [],
|
|
428
|
+
entryStateId: '',
|
|
429
|
+
anyStateTransitions: [],
|
|
430
|
+
};
|
|
431
|
+
setProject(prev => ({ ...prev, stateMachines: [...prev.stateMachines, sm] }));
|
|
432
|
+
setEditorState(prev => ({ ...prev, activeStateMachineId: sm.id }));
|
|
433
|
+
pushHistory(`Create state machine: ${name}`);
|
|
434
|
+
}, [pushHistory]);
|
|
435
|
+
const removeStateMachine = useCallback((id) => {
|
|
436
|
+
setProject(prev => ({
|
|
437
|
+
...prev,
|
|
438
|
+
stateMachines: prev.stateMachines.filter(sm => sm.id !== id),
|
|
439
|
+
}));
|
|
440
|
+
pushHistory('Remove state machine');
|
|
441
|
+
}, [pushHistory]);
|
|
442
|
+
const selectStateMachine = useCallback((id) => {
|
|
443
|
+
setEditorState(prev => ({ ...prev, activeStateMachineId: id, selectedStateId: null }));
|
|
444
|
+
}, []);
|
|
445
|
+
const addState = useCallback((name, animationId) => {
|
|
446
|
+
const state = {
|
|
447
|
+
id: generateId('state'),
|
|
448
|
+
name,
|
|
449
|
+
animationId,
|
|
450
|
+
speed: 1,
|
|
451
|
+
loop: true,
|
|
452
|
+
position: { x: Math.random() * 400, y: Math.random() * 300 },
|
|
453
|
+
};
|
|
454
|
+
setProject(prev => ({
|
|
455
|
+
...prev,
|
|
456
|
+
stateMachines: prev.stateMachines.map(sm => sm.id === editorState.activeStateMachineId
|
|
457
|
+
? {
|
|
458
|
+
...sm,
|
|
459
|
+
states: [...sm.states, state],
|
|
460
|
+
entryStateId: sm.entryStateId || state.id,
|
|
461
|
+
}
|
|
462
|
+
: sm),
|
|
463
|
+
}));
|
|
464
|
+
pushHistory(`Add state: ${name}`);
|
|
465
|
+
}, [editorState.activeStateMachineId, pushHistory]);
|
|
466
|
+
const removeState = useCallback((id) => {
|
|
467
|
+
setProject(prev => ({
|
|
468
|
+
...prev,
|
|
469
|
+
stateMachines: prev.stateMachines.map(sm => ({
|
|
470
|
+
...sm,
|
|
471
|
+
states: sm.states.filter(s => s.id !== id),
|
|
472
|
+
transitions: sm.transitions.filter(t => t.fromStateId !== id && t.toStateId !== id),
|
|
473
|
+
})),
|
|
474
|
+
}));
|
|
475
|
+
pushHistory('Remove state');
|
|
476
|
+
}, [pushHistory]);
|
|
477
|
+
const selectState = useCallback((id) => {
|
|
478
|
+
setEditorState(prev => ({ ...prev, selectedStateId: id }));
|
|
479
|
+
}, []);
|
|
480
|
+
const updateState = useCallback((id, updates) => {
|
|
481
|
+
setProject(prev => ({
|
|
482
|
+
...prev,
|
|
483
|
+
stateMachines: prev.stateMachines.map(sm => ({
|
|
484
|
+
...sm,
|
|
485
|
+
states: sm.states.map(s => (s.id === id ? { ...s, ...updates } : s)),
|
|
486
|
+
})),
|
|
487
|
+
}));
|
|
488
|
+
}, []);
|
|
489
|
+
const addTransition = useCallback((fromId, toId) => {
|
|
490
|
+
const transition = {
|
|
491
|
+
id: generateId('trans'),
|
|
492
|
+
fromStateId: fromId,
|
|
493
|
+
toStateId: toId,
|
|
494
|
+
condition: { type: 'trigger', paramName: '' },
|
|
495
|
+
duration: 0.1,
|
|
496
|
+
priority: 0,
|
|
497
|
+
};
|
|
498
|
+
setProject(prev => ({
|
|
499
|
+
...prev,
|
|
500
|
+
stateMachines: prev.stateMachines.map(sm => sm.id === editorState.activeStateMachineId
|
|
501
|
+
? { ...sm, transitions: [...sm.transitions, transition] }
|
|
502
|
+
: sm),
|
|
503
|
+
}));
|
|
504
|
+
pushHistory('Add transition');
|
|
505
|
+
}, [editorState.activeStateMachineId, pushHistory]);
|
|
506
|
+
const removeTransition = useCallback((id) => {
|
|
507
|
+
setProject(prev => ({
|
|
508
|
+
...prev,
|
|
509
|
+
stateMachines: prev.stateMachines.map(sm => ({
|
|
510
|
+
...sm,
|
|
511
|
+
transitions: sm.transitions.filter(t => t.id !== id),
|
|
512
|
+
})),
|
|
513
|
+
}));
|
|
514
|
+
pushHistory('Remove transition');
|
|
515
|
+
}, [pushHistory]);
|
|
516
|
+
const addParameter = useCallback((name, type) => {
|
|
517
|
+
const param = {
|
|
518
|
+
id: generateId('param'),
|
|
519
|
+
name,
|
|
520
|
+
type,
|
|
521
|
+
defaultValue: type === 'bool' ? false : 0,
|
|
522
|
+
};
|
|
523
|
+
setProject(prev => ({
|
|
524
|
+
...prev,
|
|
525
|
+
stateMachines: prev.stateMachines.map(sm => sm.id === editorState.activeStateMachineId
|
|
526
|
+
? { ...sm, parameters: [...sm.parameters, param] }
|
|
527
|
+
: sm),
|
|
528
|
+
}));
|
|
529
|
+
pushHistory(`Add parameter: ${name}`);
|
|
530
|
+
}, [editorState.activeStateMachineId, pushHistory]);
|
|
531
|
+
const removeParameter = useCallback((id) => {
|
|
532
|
+
setProject(prev => ({
|
|
533
|
+
...prev,
|
|
534
|
+
stateMachines: prev.stateMachines.map(sm => ({
|
|
535
|
+
...sm,
|
|
536
|
+
parameters: sm.parameters.filter(p => p.id !== id),
|
|
537
|
+
})),
|
|
538
|
+
}));
|
|
539
|
+
pushHistory('Remove parameter');
|
|
540
|
+
}, [pushHistory]);
|
|
541
|
+
// ─────────────────────────────────────────────────────────────
|
|
542
|
+
// Effects operations
|
|
543
|
+
// ─────────────────────────────────────────────────────────────
|
|
544
|
+
const addEffect = useCallback((type) => {
|
|
545
|
+
const defaultParams = {
|
|
546
|
+
'outline': { color: '#000000', thickness: 1 },
|
|
547
|
+
'shadow': { color: '#00000080', offsetX: 2, offsetY: 2, blur: 0 },
|
|
548
|
+
'glow': { color: '#ffffff', size: 4, intensity: 0.8 },
|
|
549
|
+
'palette-swap': { from: '#ffffff', to: '#ff0000' },
|
|
550
|
+
'pixelate': { size: 4 },
|
|
551
|
+
'blur': { radius: 2 },
|
|
552
|
+
'brightness': { value: 0 },
|
|
553
|
+
'contrast': { value: 0 },
|
|
554
|
+
'saturation': { value: 0 },
|
|
555
|
+
'hue-shift': { degrees: 0 },
|
|
556
|
+
'invert': {},
|
|
557
|
+
'tint': { color: '#ffffff', amount: 0.5 },
|
|
558
|
+
};
|
|
559
|
+
const effect = {
|
|
560
|
+
id: generateId('effect'),
|
|
561
|
+
type,
|
|
562
|
+
enabled: true,
|
|
563
|
+
params: { ...defaultParams[type] },
|
|
564
|
+
};
|
|
565
|
+
setCurrentEffects(prev => [...prev, effect]);
|
|
566
|
+
}, []);
|
|
567
|
+
const removeEffect = useCallback((id) => {
|
|
568
|
+
setCurrentEffects(prev => prev.filter(e => e.id !== id));
|
|
569
|
+
}, []);
|
|
570
|
+
const updateEffect = useCallback((id, updates) => {
|
|
571
|
+
setCurrentEffects(prev => prev.map(e => (e.id === id ? { ...e, ...updates } : e)));
|
|
572
|
+
}, []);
|
|
573
|
+
const toggleEffect = useCallback((id) => {
|
|
574
|
+
setCurrentEffects(prev => prev.map(e => (e.id === id ? { ...e, enabled: !e.enabled } : e)));
|
|
575
|
+
}, []);
|
|
576
|
+
const saveEffectPreset = useCallback((name) => {
|
|
577
|
+
const preset = {
|
|
578
|
+
id: generateId('preset'),
|
|
579
|
+
name,
|
|
580
|
+
effects: currentEffects.map(e => ({ ...e, id: generateId('effect') })),
|
|
581
|
+
};
|
|
582
|
+
setProject(prev => ({ ...prev, effectPresets: [...prev.effectPresets, preset] }));
|
|
583
|
+
pushHistory(`Save effect preset: ${name}`);
|
|
584
|
+
}, [currentEffects, pushHistory]);
|
|
585
|
+
const loadEffectPreset = useCallback((id) => {
|
|
586
|
+
const preset = project.effectPresets.find(p => p.id === id);
|
|
587
|
+
if (preset) {
|
|
588
|
+
setCurrentEffects(preset.effects.map(e => ({ ...e, id: generateId('effect') })));
|
|
589
|
+
}
|
|
590
|
+
}, [project.effectPresets]);
|
|
591
|
+
const previewEffects = useCallback((imageData) => {
|
|
592
|
+
return applyEffects(imageData, currentEffects);
|
|
593
|
+
}, [currentEffects]);
|
|
594
|
+
// ─────────────────────────────────────────────────────────────
|
|
595
|
+
// Export operations
|
|
596
|
+
// ─────────────────────────────────────────────────────────────
|
|
597
|
+
const exportTileMap = useCallback((format) => {
|
|
598
|
+
var _a;
|
|
599
|
+
const map = project.tileMaps.find(m => m.id === editorState.activeTileMapId);
|
|
600
|
+
if (!map)
|
|
601
|
+
return;
|
|
602
|
+
if (format === 'json') {
|
|
603
|
+
downloadJson(map, `${map.name}.json`);
|
|
604
|
+
}
|
|
605
|
+
else if (format === 'tiled-json') {
|
|
606
|
+
const tiledData = exportToTiledJson(map, project.tileSets);
|
|
607
|
+
downloadJson(tiledData, `${map.name}.tmj`);
|
|
608
|
+
}
|
|
609
|
+
else if (format === 'png') {
|
|
610
|
+
// Render map to canvas and export
|
|
611
|
+
const canvas = document.createElement('canvas');
|
|
612
|
+
canvas.width = map.width * map.tileWidth;
|
|
613
|
+
canvas.height = map.height * map.tileHeight;
|
|
614
|
+
const ctx = canvas.getContext('2d');
|
|
615
|
+
ctx.fillStyle = map.backgroundColor;
|
|
616
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
617
|
+
for (const layer of map.layers.filter(l => l.visible)) {
|
|
618
|
+
ctx.globalAlpha = layer.opacity;
|
|
619
|
+
for (let y = 0; y < map.height; y++) {
|
|
620
|
+
for (let x = 0; x < map.width; x++) {
|
|
621
|
+
const tileId = (_a = layer.tiles[y]) === null || _a === void 0 ? void 0 : _a[x];
|
|
622
|
+
if (tileId) {
|
|
623
|
+
const tile = project.tileSets.find(t => t.id === tileId);
|
|
624
|
+
if (tile === null || tile === void 0 ? void 0 : tile.image) {
|
|
625
|
+
const tempCanvas = document.createElement('canvas');
|
|
626
|
+
tempCanvas.width = tile.image.width;
|
|
627
|
+
tempCanvas.height = tile.image.height;
|
|
628
|
+
tempCanvas.getContext('2d').putImageData(tile.image, 0, 0);
|
|
629
|
+
ctx.drawImage(tempCanvas, x * map.tileWidth, y * map.tileHeight);
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
downloadPng(canvas, `${map.name}.png`);
|
|
636
|
+
}
|
|
637
|
+
onExport === null || onExport === void 0 ? void 0 : onExport(JSON.stringify(map), format);
|
|
638
|
+
}, [project, editorState.activeTileMapId, onExport]);
|
|
639
|
+
const exportSpriteSheet = useCallback((format) => {
|
|
640
|
+
const sheet = project.spriteSheets.find(s => s.id === editorState.activeSpriteSheetId);
|
|
641
|
+
if (!sheet)
|
|
642
|
+
return;
|
|
643
|
+
if (format === 'json') {
|
|
644
|
+
const exportData = {
|
|
645
|
+
name: sheet.name,
|
|
646
|
+
width: sheet.width,
|
|
647
|
+
height: sheet.height,
|
|
648
|
+
frames: sheet.frames,
|
|
649
|
+
animations: sheet.animations,
|
|
650
|
+
};
|
|
651
|
+
downloadJson(exportData, `${sheet.name}.json`);
|
|
652
|
+
}
|
|
653
|
+
else if (format === 'atlas') {
|
|
654
|
+
// TexturePacker-compatible format
|
|
655
|
+
const framesObj = {};
|
|
656
|
+
for (const f of sheet.frames) {
|
|
657
|
+
framesObj[f.name] = {
|
|
658
|
+
frame: { x: f.x, y: f.y, w: f.width, h: f.height },
|
|
659
|
+
pivot: { x: f.pivotX, y: f.pivotY },
|
|
660
|
+
sourceSize: { w: f.width, h: f.height },
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
const atlas = {
|
|
664
|
+
frames: framesObj,
|
|
665
|
+
meta: {
|
|
666
|
+
app: 'GameAsset2dEditor',
|
|
667
|
+
version: '1.0',
|
|
668
|
+
image: `${sheet.name}.png`,
|
|
669
|
+
size: { w: sheet.width, h: sheet.height },
|
|
670
|
+
},
|
|
671
|
+
};
|
|
672
|
+
downloadJson(atlas, `${sheet.name}.atlas.json`);
|
|
673
|
+
}
|
|
674
|
+
onExport === null || onExport === void 0 ? void 0 : onExport(JSON.stringify(sheet), format);
|
|
675
|
+
}, [project.spriteSheets, editorState.activeSpriteSheetId, onExport]);
|
|
676
|
+
const exportStateMachine = useCallback((format) => {
|
|
677
|
+
const sm = project.stateMachines.find(s => s.id === editorState.activeStateMachineId);
|
|
678
|
+
if (!sm)
|
|
679
|
+
return;
|
|
680
|
+
downloadJson(sm, `${sm.name}.statemachine.json`);
|
|
681
|
+
onExport === null || onExport === void 0 ? void 0 : onExport(JSON.stringify(sm), format);
|
|
682
|
+
}, [project.stateMachines, editorState.activeStateMachineId, onExport]);
|
|
683
|
+
// ─────────────────────────────────────────────────────────────
|
|
684
|
+
// Return API
|
|
685
|
+
// ─────────────────────────────────────────────────────────────
|
|
686
|
+
return {
|
|
687
|
+
project,
|
|
688
|
+
setProject,
|
|
689
|
+
newProject,
|
|
690
|
+
saveProject,
|
|
691
|
+
loadProject,
|
|
692
|
+
editorState,
|
|
693
|
+
setMode,
|
|
694
|
+
setTileMapTool,
|
|
695
|
+
setSpriteSheetTool,
|
|
696
|
+
setZoom,
|
|
697
|
+
setPan,
|
|
698
|
+
toggleGrid,
|
|
699
|
+
toggleCollision,
|
|
700
|
+
toggleSnap,
|
|
701
|
+
addTile,
|
|
702
|
+
removeTile,
|
|
703
|
+
selectTile,
|
|
704
|
+
importTileSet,
|
|
705
|
+
createTileMap,
|
|
706
|
+
removeTileMap,
|
|
707
|
+
selectTileMap,
|
|
708
|
+
setTile,
|
|
709
|
+
fillTiles,
|
|
710
|
+
addLayer,
|
|
711
|
+
removeLayer,
|
|
712
|
+
selectLayer,
|
|
713
|
+
toggleLayerVisibility,
|
|
714
|
+
setLayerOpacity,
|
|
715
|
+
moveLayer,
|
|
716
|
+
importSpriteSheet,
|
|
717
|
+
removeSpriteSheet,
|
|
718
|
+
selectSpriteSheet,
|
|
719
|
+
autoSlice,
|
|
720
|
+
detectSprites,
|
|
721
|
+
addFrame,
|
|
722
|
+
updateFrame,
|
|
723
|
+
removeFrame,
|
|
724
|
+
selectFrames,
|
|
725
|
+
createAnimation,
|
|
726
|
+
removeAnimation,
|
|
727
|
+
updateAnimation,
|
|
728
|
+
createStateMachine,
|
|
729
|
+
removeStateMachine,
|
|
730
|
+
selectStateMachine,
|
|
731
|
+
addState,
|
|
732
|
+
removeState,
|
|
733
|
+
selectState,
|
|
734
|
+
updateState,
|
|
735
|
+
addTransition,
|
|
736
|
+
removeTransition,
|
|
737
|
+
addParameter,
|
|
738
|
+
removeParameter,
|
|
739
|
+
addEffect,
|
|
740
|
+
removeEffect,
|
|
741
|
+
updateEffect,
|
|
742
|
+
toggleEffect,
|
|
743
|
+
saveEffectPreset,
|
|
744
|
+
loadEffectPreset,
|
|
745
|
+
previewEffects,
|
|
746
|
+
undo,
|
|
747
|
+
redo,
|
|
748
|
+
canUndo: historyIndex > 0,
|
|
749
|
+
canRedo: historyIndex < history.length - 1,
|
|
750
|
+
exportTileMap,
|
|
751
|
+
exportSpriteSheet,
|
|
752
|
+
exportStateMachine,
|
|
753
|
+
canvasRef,
|
|
754
|
+
fileInputRef,
|
|
755
|
+
};
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
export { useGameAssetEditor };
|
|
759
|
+
//# sourceMappingURL=useGameAssetEditor.js.map
|