@fleox/agent3d 0.0.0-stage → 0.2.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/LICENSE +143 -0
- package/README.md +172 -2
- package/changelog.json +56 -0
- package/dist/agent/agent3d.mjs +11242 -0
- package/dist/agent/chunks/assets-BUUM9TUB.mjs +2448 -0
- package/dist/agent/chunks/browser-t_JL_B82.mjs +226 -0
- package/dist/agent/chunks/cdp-CaKRRzMX.mjs +177 -0
- package/dist/agent/chunks/check-CBO3Ekx1.mjs +971 -0
- package/dist/agent/chunks/export-BCI8vKw8.mjs +1130 -0
- package/dist/agent/chunks/gif-DQznzHTL.mjs +319 -0
- package/dist/agent/chunks/gltf-f_f0-OiV.mjs +207 -0
- package/dist/agent/chunks/imageCodec-BpDU9Lsq.mjs +101 -0
- package/dist/agent/chunks/jsonPath-DUCe1JpS.mjs +155 -0
- package/dist/agent/chunks/meshoptimizer-C-tN9jn5.mjs +1165 -0
- package/dist/agent/chunks/mp4-aOALfp3s.mjs +130 -0
- package/dist/agent/chunks/objects-DBAws7uf.mjs +53 -0
- package/dist/agent/chunks/optimizeSizing-CkZ3fZRp.mjs +540 -0
- package/dist/agent/chunks/package-Ck7_Nszg.mjs +75 -0
- package/dist/agent/chunks/png-DXfSGJZt.mjs +91 -0
- package/dist/agent/chunks/render-Cbuhz5uW.mjs +1511 -0
- package/dist/agent/chunks/rolldown-runtime-ebOQtxsr.mjs +18 -0
- package/dist/agent/chunks/scene-BgajNvBf.mjs +444 -0
- package/dist/agent/chunks/server-CACCerkZ.mjs +237 -0
- package/dist/agent/chunks/suggest-Cpcgv1RP.mjs +46 -0
- package/dist/agent/chunks/tools-DT2tetIK.mjs +1412 -0
- package/dist/agent/chunks/tree-BrNYGui2.mjs +75 -0
- package/dist/agent/chunks/webpAnim-qaq9YgKl.mjs +132 -0
- package/dist/runtime/agent3d-runtime.js +373 -0
- package/dist/runtime/agent3d-runtime.single.js +7360 -0
- package/dist/runtime/chunks/BufferGeometryUtils-Re3wQkXp.js +1 -0
- package/dist/runtime/chunks/EXRLoader-Bzm84si5.js +1 -0
- package/dist/runtime/chunks/FontLoader-BocwqK8V.js +2 -0
- package/dist/runtime/chunks/GLTFLoader-DHp1wv6J.js +1 -0
- package/dist/runtime/chunks/GroundedSkybox-esvlRCO0.js +1 -0
- package/dist/runtime/chunks/HDRLoader-DHrHp8fs.js +5 -0
- package/dist/runtime/chunks/OrbitControls-sjN2MF0e.js +1 -0
- package/dist/runtime/chunks/RectAreaLightUniformsLib-_mZ62yWn.js +1 -0
- package/dist/runtime/chunks/RoomEnvironment-CL4UR6ZW.js +1 -0
- package/dist/runtime/chunks/RoundedBoxGeometry-x-ot8ZSh.js +1 -0
- package/dist/runtime/chunks/SVGLoader-hRF0EwD-.js +1 -0
- package/dist/runtime/chunks/SkeletonUtils-DHlReJx3.js +1 -0
- package/dist/runtime/chunks/Sky-BrLN9Fk5.js +243 -0
- package/dist/runtime/chunks/audio-DbVNbf-r.js +1 -0
- package/dist/runtime/chunks/catalog-DL6sgPay.js +1 -0
- package/dist/runtime/chunks/easing-CXSz2e6P.js +1 -0
- package/dist/runtime/chunks/extrude-m04mghOS.js +1 -0
- package/dist/runtime/chunks/game-BoG2S6g4.js +20 -0
- package/dist/runtime/chunks/generators-OHhFCc2E.js +331 -0
- package/dist/runtime/chunks/materials-C2uffFEd.js +107 -0
- package/dist/runtime/chunks/meshGradient.glsl-BMatplLA.js +88 -0
- package/dist/runtime/chunks/meshopt_decoder.module-DXTYc6wn.js +1 -0
- package/dist/runtime/chunks/model-D-4xZz21.js +1 -0
- package/dist/runtime/chunks/params-DdApDOBw.js +1 -0
- package/dist/runtime/chunks/physicsHost-DPaVdM0R.js +1 -0
- package/dist/runtime/chunks/postfx-BpBXjLX3.js +1527 -0
- package/dist/runtime/chunks/postfx-i_J5Vf-l.js +1 -0
- package/dist/runtime/chunks/random-eeej60NW.js +1 -0
- package/dist/runtime/chunks/shaders-CmeJRio1.js +443 -0
- package/dist/runtime/chunks/svg-B3nZaQFD.js +1 -0
- package/dist/runtime/chunks/text-CmkU-b0C.js +2 -0
- package/dist/runtime/chunks/three.module-W4hp4qHb.js +4225 -0
- package/dist/runtime/chunks/toon-B5Jhf37V.js +6 -0
- package/dist/runtime/chunks/util-THUewKBk.js +1 -0
- package/dist/studio/assets/BufferGeometryUtils-wW9vV1l2.js +1 -0
- package/dist/studio/assets/EXRLoader-f8U8jnlr.js +1 -0
- package/dist/studio/assets/FontLoader-9sHudKzD.js +2 -0
- package/dist/studio/assets/GLTFLoader-C3C_3K62.js +1 -0
- package/dist/studio/assets/GroundedSkybox-BTqmv4fv.js +1 -0
- package/dist/studio/assets/HDRLoader-CkQyrTWY.js +5 -0
- package/dist/studio/assets/OrbitControls-fcOgB96a.js +1 -0
- package/dist/studio/assets/RectAreaLightUniformsLib-CZHWO9xf.js +1 -0
- package/dist/studio/assets/RoomEnvironment-BsISzuCp.js +1 -0
- package/dist/studio/assets/SVGLoader-BIkQDT66.js +1 -0
- package/dist/studio/assets/SkeletonUtils-CG5akqME.js +1 -0
- package/dist/studio/assets/Sky-C282PFL1.js +243 -0
- package/dist/studio/assets/audio-JD1kyX0A.js +1 -0
- package/dist/studio/assets/camera-BhKdE9ej.js +2 -0
- package/dist/studio/assets/editor-BgY_RoRd.js +1 -0
- package/dist/studio/assets/extrude-CnayHczh.js +1 -0
- package/dist/studio/assets/game-Dv5s4eMN.js +19 -0
- package/dist/studio/assets/generators-DVX3bAxe.js +331 -0
- package/dist/studio/assets/index-BQT0otii.css +1 -0
- package/dist/studio/assets/index-Dh-2Y34U.js +479 -0
- package/dist/studio/assets/meshopt_decoder.module-DXTYc6wn.js +1 -0
- package/dist/studio/assets/meshoptimizer-BCSwHBL3.js +1 -0
- package/dist/studio/assets/model-XZSP52pV.js +2 -0
- package/dist/studio/assets/physicsHost-C84FddIe.js +1 -0
- package/dist/studio/assets/postfx-BWWXb8i8.js +1527 -0
- package/dist/studio/assets/runtime-k_MFerbJ.js +572 -0
- package/dist/studio/assets/shaders-BEznGIct.js +443 -0
- package/dist/studio/assets/svg-DT8kx37i.js +2 -0
- package/dist/studio/assets/text-5DsJJHcj.js +3 -0
- package/dist/studio/assets/three.module-ByMn_ZTv.js +4225 -0
- package/dist/studio/index.html +16 -0
- package/library/LICENSES.md +77 -0
- package/library/fonts/LICENSES.md +42 -0
- package/library/fonts/anton.typeface.json +1 -0
- package/library/fonts/bebas-neue.typeface.json +1 -0
- package/library/fonts/display.typeface.json +1 -0
- package/library/fonts/inter-black.typeface.json +1 -0
- package/library/fonts/lobster.typeface.json +1 -0
- package/library/fonts/mono.typeface.json +1 -0
- package/library/fonts/montserrat-extrabold.typeface.json +1 -0
- package/library/fonts/pacifico.typeface.json +1 -0
- package/library/fonts/sans-bold.typeface.json +1 -0
- package/library/fonts/sans.typeface.json +1 -0
- package/library/fonts/serif-bold.typeface.json +1 -0
- package/library/fonts/serif.typeface.json +1 -0
- package/library/fonts/space-grotesk-bold.typeface.json +1 -0
- package/library/hdri/beach.hdr +0 -0
- package/library/hdri/beach.jpg +0 -0
- package/library/hdri/city.hdr +0 -0
- package/library/hdri/city.jpg +0 -0
- package/library/hdri/forest.hdr +0 -0
- package/library/hdri/forest.jpg +0 -0
- package/library/hdri/night-city.hdr +0 -0
- package/library/hdri/night-city.jpg +0 -0
- package/library/hdri/night.hdr +0 -0
- package/library/hdri/night.jpg +0 -0
- package/library/hdri/sky.hdr +0 -0
- package/library/hdri/sky.jpg +0 -0
- package/library/hdri/softbox.hdr +0 -0
- package/library/hdri/softbox.jpg +0 -0
- package/library/hdri/studio.hdr +0 -0
- package/library/hdri/studio.jpg +0 -0
- package/library/hdri/sunset.hdr +0 -0
- package/library/hdri/sunset.jpg +0 -0
- package/library/hdri/warehouse.hdr +0 -0
- package/library/hdri/warehouse.jpg +0 -0
- package/library/index.json +5510 -0
- package/library/models/animals/fish.glb +0 -0
- package/library/models/animals/fox.glb +0 -0
- package/library/models/buildings/castle.glb +0 -0
- package/library/models/buildings/house.glb +0 -0
- package/library/models/buildings/market.glb +0 -0
- package/library/models/buildings/tavern.glb +0 -0
- package/library/models/buildings/tower.glb +0 -0
- package/library/models/buildings/windmill.glb +0 -0
- package/library/models/characters/barbarian.glb +0 -0
- package/library/models/characters/knight.glb +0 -0
- package/library/models/characters/mage.glb +0 -0
- package/library/models/characters/mini-soldier.glb +0 -0
- package/library/models/characters/platformer-hero.glb +0 -0
- package/library/models/characters/robot.glb +0 -0
- package/library/models/characters/rogue.glb +0 -0
- package/library/models/characters/skeleton.glb +0 -0
- package/library/models/city/building-a.glb +0 -0
- package/library/models/city/building-b.glb +0 -0
- package/library/models/city/building-tall.glb +0 -0
- package/library/models/city/fire-hydrant.glb +0 -0
- package/library/models/city/road-corner.glb +0 -0
- package/library/models/city/road-crossing.glb +0 -0
- package/library/models/city/road-junction.glb +0 -0
- package/library/models/city/road-straight.glb +0 -0
- package/library/models/city/streetlight.glb +0 -0
- package/library/models/city/suburban-house.glb +0 -0
- package/library/models/city/traffic-light.glb +0 -0
- package/library/models/city/water-tower.glb +0 -0
- package/library/models/food/apple.glb +0 -0
- package/library/models/food/avocado.glb +0 -0
- package/library/models/food/baguette.glb +0 -0
- package/library/models/food/bread-loaf.glb +0 -0
- package/library/models/food/burger.glb +0 -0
- package/library/models/food/carrot.glb +0 -0
- package/library/models/food/cheese.glb +0 -0
- package/library/models/food/cookie.glb +0 -0
- package/library/models/food/croissant.glb +0 -0
- package/library/models/food/cupcake.glb +0 -0
- package/library/models/food/dinner-plate.glb +0 -0
- package/library/models/food/donut.glb +0 -0
- package/library/models/food/ketchup.glb +0 -0
- package/library/models/food/mug.glb +0 -0
- package/library/models/food/pain-au-chocolat.glb +0 -0
- package/library/models/food/stew.glb +0 -0
- package/library/models/food/tomato.glb +0 -0
- package/library/models/food/veggie-burger.glb +0 -0
- package/library/models/nature/bush.glb +0 -0
- package/library/models/nature/cactus.glb +0 -0
- package/library/models/nature/cloud.glb +0 -0
- package/library/models/nature/fir-tree.glb +0 -0
- package/library/models/nature/forest-patch.glb +0 -0
- package/library/models/nature/grass-small.glb +0 -0
- package/library/models/nature/grass.glb +0 -0
- package/library/models/nature/hex-grass.glb +0 -0
- package/library/models/nature/hex-water.glb +0 -0
- package/library/models/nature/hills.glb +0 -0
- package/library/models/nature/mountain.glb +0 -0
- package/library/models/nature/pine-autumn.glb +0 -0
- package/library/models/nature/pine-tree.glb +0 -0
- package/library/models/nature/pumpkin.glb +0 -0
- package/library/models/nature/rock-flat.glb +0 -0
- package/library/models/nature/rock.glb +0 -0
- package/library/models/nature/tree-dead.glb +0 -0
- package/library/models/nature/tree-slim.glb +0 -0
- package/library/models/nature/trees-cluster.glb +0 -0
- package/library/models/nature/waterlily.glb +0 -0
- package/library/models/platformer/blaster.glb +0 -0
- package/library/models/platformer/block-coin.glb +0 -0
- package/library/models/platformer/brick.glb +0 -0
- package/library/models/platformer/coin.glb +0 -0
- package/library/models/platformer/enemy-flying.glb +0 -0
- package/library/models/platformer/flag.glb +0 -0
- package/library/models/platformer/platform-falling.glb +0 -0
- package/library/models/platformer/platform-grass-round.glb +0 -0
- package/library/models/platformer/platform-large.glb +0 -0
- package/library/models/platformer/platform-medium.glb +0 -0
- package/library/models/platformer/platform.glb +0 -0
- package/library/models/platformer/target.glb +0 -0
- package/library/models/platformer/track-corner.glb +0 -0
- package/library/models/platformer/track-straight.glb +0 -0
- package/library/models/platformer/wall-low.glb +0 -0
- package/library/models/products/boombox.glb +0 -0
- package/library/models/products/iridescent-lamp.glb +0 -0
- package/library/models/products/lantern.glb +0 -0
- package/library/models/products/lounge-chair.glb +0 -0
- package/library/models/products/sneaker.glb +0 -0
- package/library/models/products/velvet-sofa.glb +0 -0
- package/library/models/products/water-bottle.glb +0 -0
- package/library/models/props/alarm-clock.glb +0 -0
- package/library/models/props/armchair.glb +0 -0
- package/library/models/props/barrel.glb +0 -0
- package/library/models/props/bench.glb +0 -0
- package/library/models/props/brass-vase.glb +0 -0
- package/library/models/props/chest.glb +0 -0
- package/library/models/props/coffee-table.glb +0 -0
- package/library/models/props/coin-stack.glb +0 -0
- package/library/models/props/coin.glb +0 -0
- package/library/models/props/couch.glb +0 -0
- package/library/models/props/crate.glb +0 -0
- package/library/models/props/flag.glb +0 -0
- package/library/models/props/gravestone.glb +0 -0
- package/library/models/props/key.glb +0 -0
- package/library/models/props/lamp.glb +0 -0
- package/library/models/props/lantern.glb +0 -0
- package/library/models/props/marble-bust.glb +0 -0
- package/library/models/props/modern-armchair.glb +0 -0
- package/library/models/props/potted-succulent.glb +0 -0
- package/library/models/props/rubber-duck.glb +0 -0
- package/library/models/props/shield.glb +0 -0
- package/library/models/props/sword-shield.glb +0 -0
- package/library/models/props/sword.glb +0 -0
- package/library/models/props/table.glb +0 -0
- package/library/models/props/tent.glb +0 -0
- package/library/models/props/torch.glb +0 -0
- package/library/models/props/trophy.glb +0 -0
- package/library/models/space/base-module.glb +0 -0
- package/library/models/space/lander.glb +0 -0
- package/library/models/space/landing-pad.glb +0 -0
- package/library/models/space/rocks.glb +0 -0
- package/library/models/space/solar-panel.glb +0 -0
- package/library/models/space/space-truck.glb +0 -0
- package/library/models/space/wind-turbine.glb +0 -0
- package/library/models/vehicles/car.glb +0 -0
- package/library/models/vehicles/hatchback.glb +0 -0
- package/library/models/vehicles/motorcycle.glb +0 -0
- package/library/models/vehicles/police-car.glb +0 -0
- package/library/models/vehicles/taxi.glb +0 -0
- package/library/models/vehicles/truck.glb +0 -0
- package/library/sources.json +2856 -0
- package/library/textures/brick-color.jpg +0 -0
- package/library/textures/brick-normal.jpg +0 -0
- package/library/textures/brick-roughness.jpg +0 -0
- package/library/textures/concrete-color.jpg +0 -0
- package/library/textures/concrete-normal.jpg +0 -0
- package/library/textures/concrete-roughness.jpg +0 -0
- package/library/textures/fabric-color.jpg +0 -0
- package/library/textures/fabric-normal.jpg +0 -0
- package/library/textures/fabric-roughness.jpg +0 -0
- package/library/textures/grass-ground-color.jpg +0 -0
- package/library/textures/grass-ground-normal.jpg +0 -0
- package/library/textures/grass-ground-roughness.jpg +0 -0
- package/library/textures/rusty-metal-color.jpg +0 -0
- package/library/textures/rusty-metal-normal.jpg +0 -0
- package/library/textures/rusty-metal-roughness.jpg +0 -0
- package/library/textures/wood-planks-color.jpg +0 -0
- package/library/textures/wood-planks-normal.jpg +0 -0
- package/library/textures/wood-planks-roughness.jpg +0 -0
- package/package.json +67 -4
- package/plugin/.claude-plugin/plugin.json +19 -0
- package/plugin/skills/agent3d-assets/SKILL.md +140 -0
- package/plugin/skills/agent3d-assets/references/sources.md +33 -0
- package/plugin/skills/agent3d-create/SKILL.md +141 -0
- package/plugin/skills/agent3d-create/references/art-direction.md +144 -0
- package/plugin/skills/agent3d-create/references/recipes.md +1357 -0
- package/plugin/skills/agent3d-edit/SKILL.md +121 -0
- package/plugin/skills/agent3d-edit/references/patch-ops.md +278 -0
- package/plugin/skills/agent3d-game/SKILL.md +111 -0
- package/plugin/skills/agent3d-game/references/game-patterns.md +262 -0
- package/plugin/skills/agent3d-game/references/script-api.md +211 -0
- package/plugin/skills/agent3d-publish/SKILL.md +161 -0
- package/plugin/skills/agent3d-publish/references/integrations.md +221 -0
- package/templates/banner-aurora-night/README.md +15 -0
- package/templates/banner-aurora-night/agent3d.json +8 -0
- package/templates/banner-aurora-night/preview.png +0 -0
- package/templates/banner-aurora-night/scene.json +327 -0
- package/templates/banner-aurora-night/template.json +24 -0
- package/templates/banner-data-bars/README.md +15 -0
- package/templates/banner-data-bars/agent3d.json +8 -0
- package/templates/banner-data-bars/preview.png +0 -0
- package/templates/banner-data-bars/scene.json +222 -0
- package/templates/banner-data-bars/template.json +25 -0
- package/templates/banner-floating-shapes/README.md +15 -0
- package/templates/banner-floating-shapes/agent3d.json +8 -0
- package/templates/banner-floating-shapes/preview.png +0 -0
- package/templates/banner-floating-shapes/scene.json +703 -0
- package/templates/banner-floating-shapes/template.json +24 -0
- package/templates/banner-gradient-blob/README.md +16 -0
- package/templates/banner-gradient-blob/agent3d.json +8 -0
- package/templates/banner-gradient-blob/preview.png +0 -0
- package/templates/banner-gradient-blob/scene.json +330 -0
- package/templates/banner-gradient-blob/template.json +21 -0
- package/templates/banner-liquid-chrome/README.md +16 -0
- package/templates/banner-liquid-chrome/agent3d.json +8 -0
- package/templates/banner-liquid-chrome/preview.png +0 -0
- package/templates/banner-liquid-chrome/scene.json +290 -0
- package/templates/banner-liquid-chrome/template.json +24 -0
- package/templates/banner-logo-extrude/README.md +24 -0
- package/templates/banner-logo-extrude/agent3d.json +8 -0
- package/templates/banner-logo-extrude/assets/logo.svg +6 -0
- package/templates/banner-logo-extrude/assets/manifest.json +13 -0
- package/templates/banner-logo-extrude/preview.png +0 -0
- package/templates/banner-logo-extrude/scene.json +332 -0
- package/templates/banner-logo-extrude/template.json +22 -0
- package/templates/banner-neon-title/README.md +18 -0
- package/templates/banner-neon-title/agent3d.json +8 -0
- package/templates/banner-neon-title/preview.png +0 -0
- package/templates/banner-neon-title/scene.json +494 -0
- package/templates/banner-neon-title/template.json +25 -0
- package/templates/banner-wave-grid/README.md +18 -0
- package/templates/banner-wave-grid/agent3d.json +8 -0
- package/templates/banner-wave-grid/preview.png +0 -0
- package/templates/banner-wave-grid/scene.json +217 -0
- package/templates/banner-wave-grid/template.json +23 -0
- package/templates/card-hover-3d/README.md +16 -0
- package/templates/card-hover-3d/agent3d.json +8 -0
- package/templates/card-hover-3d/preview.png +0 -0
- package/templates/card-hover-3d/scene.json +359 -0
- package/templates/card-hover-3d/template.json +21 -0
- package/templates/card-product-tilt/README.md +14 -0
- package/templates/card-product-tilt/agent3d.json +8 -0
- package/templates/card-product-tilt/preview.png +0 -0
- package/templates/card-product-tilt/scene.json +296 -0
- package/templates/card-product-tilt/template.json +23 -0
- package/templates/character-mascot-hero/README.md +19 -0
- package/templates/character-mascot-hero/agent3d.json +8 -0
- package/templates/character-mascot-hero/preview.png +0 -0
- package/templates/character-mascot-hero/scene.json +512 -0
- package/templates/character-mascot-hero/template.json +8 -0
- package/templates/character-showcase/README.md +27 -0
- package/templates/character-showcase/agent3d.json +8 -0
- package/templates/character-showcase/preview.png +0 -0
- package/templates/character-showcase/scene.json +440 -0
- package/templates/character-showcase/template.json +24 -0
- package/templates/diorama-city/README.md +21 -0
- package/templates/diorama-city/agent3d.json +8 -0
- package/templates/diorama-city/preview.png +0 -0
- package/templates/diorama-city/scene.json +432 -0
- package/templates/diorama-city/template.json +21 -0
- package/templates/game-basket/README.md +25 -0
- package/templates/game-basket/agent3d.json +8 -0
- package/templates/game-basket/preview.png +0 -0
- package/templates/game-basket/scene.json +640 -0
- package/templates/game-basket/scripts/basket.js +176 -0
- package/templates/game-basket/template.json +8 -0
- package/templates/game-coin-collector/README.md +28 -0
- package/templates/game-coin-collector/agent3d.json +8 -0
- package/templates/game-coin-collector/preview.png +0 -0
- package/templates/game-coin-collector/scene.json +900 -0
- package/templates/game-coin-collector/scripts/collector.js +210 -0
- package/templates/game-coin-collector/template.json +19 -0
- package/templates/game-maze/README.md +24 -0
- package/templates/game-maze/agent3d.json +8 -0
- package/templates/game-maze/preview.png +0 -0
- package/templates/game-maze/scene.json +315 -0
- package/templates/game-maze/scripts/maze.js +168 -0
- package/templates/game-maze/template.json +18 -0
- package/templates/game-physics-playground/README.md +30 -0
- package/templates/game-physics-playground/agent3d.json +8 -0
- package/templates/game-physics-playground/preview.png +0 -0
- package/templates/game-physics-playground/scene.json +1712 -0
- package/templates/game-physics-playground/scripts/playground.js +151 -0
- package/templates/game-physics-playground/template.json +19 -0
- package/templates/game-platformer/README.md +26 -0
- package/templates/game-platformer/agent3d.json +8 -0
- package/templates/game-platformer/preview.png +0 -0
- package/templates/game-platformer/scene.json +1063 -0
- package/templates/game-platformer/scripts/platformer.js +222 -0
- package/templates/game-platformer/template.json +8 -0
- package/templates/game-runner/README.md +30 -0
- package/templates/game-runner/agent3d.json +8 -0
- package/templates/game-runner/preview.png +0 -0
- package/templates/game-runner/scene.json +1317 -0
- package/templates/game-runner/scripts/runner.js +263 -0
- package/templates/game-runner/template.json +18 -0
- package/templates/game-tap-targets/README.md +21 -0
- package/templates/game-tap-targets/agent3d.json +8 -0
- package/templates/game-tap-targets/preview.png +0 -0
- package/templates/game-tap-targets/scene.json +924 -0
- package/templates/game-tap-targets/scripts/targets.js +159 -0
- package/templates/game-tap-targets/template.json +19 -0
- package/templates/hero-floating-island/README.md +18 -0
- package/templates/hero-floating-island/agent3d.json +8 -0
- package/templates/hero-floating-island/preview.png +0 -0
- package/templates/hero-floating-island/scene.json +658 -0
- package/templates/hero-floating-island/template.json +8 -0
- package/templates/hero-perfume-luxury/README.md +18 -0
- package/templates/hero-perfume-luxury/agent3d.json +8 -0
- package/templates/hero-perfume-luxury/preview.png +0 -0
- package/templates/hero-perfume-luxury/scene.json +529 -0
- package/templates/hero-perfume-luxury/template.json +27 -0
- package/templates/hero-product-turntable/README.md +16 -0
- package/templates/hero-product-turntable/agent3d.json +8 -0
- package/templates/hero-product-turntable/preview.png +0 -0
- package/templates/hero-product-turntable/scene.json +225 -0
- package/templates/hero-product-turntable/template.json +21 -0
- package/templates/hero-saas-globe/README.md +16 -0
- package/templates/hero-saas-globe/agent3d.json +8 -0
- package/templates/hero-saas-globe/preview.png +0 -0
- package/templates/hero-saas-globe/scene.json +318 -0
- package/templates/hero-saas-globe/template.json +24 -0
- package/templates/hero-scroll-story/README.md +26 -0
- package/templates/hero-scroll-story/agent3d.json +8 -0
- package/templates/hero-scroll-story/preview.png +0 -0
- package/templates/hero-scroll-story/scene.json +642 -0
- package/templates/hero-scroll-story/template.json +22 -0
- package/templates/hero-sneaker-showcase/README.md +19 -0
- package/templates/hero-sneaker-showcase/agent3d.json +8 -0
- package/templates/hero-sneaker-showcase/preview.png +0 -0
- package/templates/hero-sneaker-showcase/scene.json +523 -0
- package/templates/hero-sneaker-showcase/template.json +23 -0
- package/templates/hero-space-planet/README.md +17 -0
- package/templates/hero-space-planet/agent3d.json +8 -0
- package/templates/hero-space-planet/preview.png +0 -0
- package/templates/hero-space-planet/scene.json +330 -0
- package/templates/hero-space-planet/template.json +21 -0
- package/templates/landscape-island/README.md +21 -0
- package/templates/landscape-island/agent3d.json +8 -0
- package/templates/landscape-island/preview.png +0 -0
- package/templates/landscape-island/scene.json +716 -0
- package/templates/landscape-island/template.json +24 -0
- package/templates/landscape-night-galaxy/README.md +25 -0
- package/templates/landscape-night-galaxy/agent3d.json +8 -0
- package/templates/landscape-night-galaxy/preview.png +0 -0
- package/templates/landscape-night-galaxy/scene.json +403 -0
- package/templates/landscape-night-galaxy/template.json +8 -0
- package/templates/landscape-valley-sunset/README.md +20 -0
- package/templates/landscape-valley-sunset/agent3d.json +8 -0
- package/templates/landscape-valley-sunset/preview.png +0 -0
- package/templates/landscape-valley-sunset/scene.json +265 -0
- package/templates/landscape-valley-sunset/template.json +22 -0
- package/templates/scene-cozy-room/README.md +21 -0
- package/templates/scene-cozy-room/agent3d.json +8 -0
- package/templates/scene-cozy-room/preview.png +0 -0
- package/templates/scene-cozy-room/scene.json +728 -0
- package/templates/scene-cozy-room/template.json +8 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire as __a3dRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __a3dPath } from "node:url";
|
|
3
|
+
import { dirname as __a3dDirname } from "node:path";
|
|
4
|
+
__a3dRequire(import.meta.url);
|
|
5
|
+
const __filename = __a3dPath(import.meta.url);
|
|
6
|
+
__a3dDirname(__filename);
|
|
7
|
+
// \0rolldown/runtime.js
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __exportAll = (all, no_symbols) => {
|
|
10
|
+
let target = {};
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
export { __exportAll as t };
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { createRequire as __a3dRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __a3dPath } from "node:url";
|
|
3
|
+
import { dirname as __a3dDirname } from "node:path";
|
|
4
|
+
__a3dRequire(import.meta.url);
|
|
5
|
+
const __filename = __a3dPath(import.meta.url);
|
|
6
|
+
__a3dDirname(__filename);
|
|
7
|
+
import { t as __exportAll } from "./rolldown-runtime-ebOQtxsr.mjs";
|
|
8
|
+
import { c as removeAt, i as getAt, l as setAt, n as clone, o as mergePatch, r as deepEqual, s as parsePath, t as PathError } from "./jsonPath-DUCe1JpS.mjs";
|
|
9
|
+
import { A as hasErrors, E as isValidId, d as saveScene, g as validateScene, k as OpsError, u as readSceneFile } from "../agent3d.mjs";
|
|
10
|
+
import { t as closest } from "./suggest-Cpcgv1RP.mjs";
|
|
11
|
+
import { a as objectDetail, i as isDescendant, n as findObject, o as walkObjects, t as allObjectIds } from "./tree-BrNYGui2.mjs";
|
|
12
|
+
// src/ops/scene.ts
|
|
13
|
+
var scene_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
PATCH_OPS: () => PATCH_OPS,
|
|
15
|
+
applyPatchOps: () => applyPatchOps,
|
|
16
|
+
applyScene: () => applyScene,
|
|
17
|
+
diffScenes: () => diffScenes,
|
|
18
|
+
getScene: () => getScene,
|
|
19
|
+
patchScene: () => patchScene,
|
|
20
|
+
replacedCollections: () => replacedCollections,
|
|
21
|
+
summarizeScene: () => summarizeScene
|
|
22
|
+
});
|
|
23
|
+
async function getScene(fs) {
|
|
24
|
+
return readSceneFile(fs);
|
|
25
|
+
}
|
|
26
|
+
function backgroundText(bg) {
|
|
27
|
+
if (typeof bg === "string") return bg;
|
|
28
|
+
if (bg && typeof bg === "object") {
|
|
29
|
+
const b = bg;
|
|
30
|
+
if (Array.isArray(b.gradient)) return `gradient(${b.gradient.join(", ")})`;
|
|
31
|
+
if (Array.isArray(b.radial)) return `radial(${b.radial.join(", ")})`;
|
|
32
|
+
if (b.sky) return "sky";
|
|
33
|
+
if (typeof b.hdri === "string") return `hdri ${b.hdri}`;
|
|
34
|
+
}
|
|
35
|
+
return "?";
|
|
36
|
+
}
|
|
37
|
+
function summarizeScene(scene) {
|
|
38
|
+
let objects = 0;
|
|
39
|
+
let behaviours = 0;
|
|
40
|
+
const node = (o) => {
|
|
41
|
+
objects++;
|
|
42
|
+
behaviours += o.behaviours?.length ?? 0;
|
|
43
|
+
return {
|
|
44
|
+
id: o.id,
|
|
45
|
+
kind: o.kind,
|
|
46
|
+
detail: objectDetail(o),
|
|
47
|
+
...o.position ? { position: o.position } : {},
|
|
48
|
+
...o.behaviours?.length ? { behaviours: o.behaviours.map((b) => b.type) } : {},
|
|
49
|
+
...o.visible === false ? { hidden: true } : {},
|
|
50
|
+
...o.children?.length ? { children: o.children.map(node) } : {}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const tree = (scene.objects ?? []).filter((o) => o && typeof o === "object").map(node);
|
|
54
|
+
const lighting = scene.environment?.lighting;
|
|
55
|
+
return {
|
|
56
|
+
id: scene.id,
|
|
57
|
+
title: scene.title,
|
|
58
|
+
target: {
|
|
59
|
+
kind: scene.target?.kind,
|
|
60
|
+
aspect: scene.target?.aspect,
|
|
61
|
+
...scene.target?.budgetKb ? { budgetKb: scene.target.budgetKb } : {}
|
|
62
|
+
},
|
|
63
|
+
camera: {
|
|
64
|
+
type: scene.camera?.type,
|
|
65
|
+
position: scene.camera?.position,
|
|
66
|
+
...scene.camera?.target ? { target: scene.camera.target } : {},
|
|
67
|
+
...scene.camera?.fov !== void 0 ? { fov: scene.camera.fov } : {},
|
|
68
|
+
...scene.camera?.controls ? { controls: scene.camera.controls } : {}
|
|
69
|
+
},
|
|
70
|
+
background: backgroundText(scene.environment?.background),
|
|
71
|
+
...lighting ? { lighting: typeof lighting === "string" ? lighting : `hdri ${lighting.hdri}` } : {},
|
|
72
|
+
lights: (scene.lights ?? []).map((l) => ({
|
|
73
|
+
...l.id ? { id: l.id } : {},
|
|
74
|
+
type: l.type,
|
|
75
|
+
...l.intensity !== void 0 ? { intensity: l.intensity } : {},
|
|
76
|
+
...l.position ? { position: l.position } : {}
|
|
77
|
+
})),
|
|
78
|
+
objects: tree,
|
|
79
|
+
counts: {
|
|
80
|
+
objects,
|
|
81
|
+
lights: scene.lights?.length ?? 0,
|
|
82
|
+
tracks: scene.timeline?.tracks?.length ?? 0,
|
|
83
|
+
behaviours
|
|
84
|
+
},
|
|
85
|
+
...scene.timeline ? { timeline: {
|
|
86
|
+
duration: scene.timeline.duration,
|
|
87
|
+
...scene.timeline.loop !== void 0 ? { loop: scene.timeline.loop } : {},
|
|
88
|
+
...scene.timeline.trigger ? { trigger: scene.timeline.trigger } : {},
|
|
89
|
+
tracks: (scene.timeline.tracks ?? []).map((t) => ({
|
|
90
|
+
target: t.target,
|
|
91
|
+
keys: t.keys?.length ?? 0,
|
|
92
|
+
from: t.keys?.[0]?.[0] ?? 0,
|
|
93
|
+
to: t.keys?.[t.keys.length - 1]?.[0] ?? 0
|
|
94
|
+
}))
|
|
95
|
+
} } : {},
|
|
96
|
+
...scene.postfx?.length ? { postfx: scene.postfx.map((p) => p.type) } : {},
|
|
97
|
+
...scene.scripts?.length ? { scripts: scene.scripts } : {},
|
|
98
|
+
...scene.ui?.elements?.length ? { ui: scene.ui.elements.map((e) => e.id) } : {},
|
|
99
|
+
...scene.audio?.sounds ? { sounds: Object.keys(scene.audio.sounds) } : {}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function flatMap(scene) {
|
|
103
|
+
const map = /* @__PURE__ */ new Map();
|
|
104
|
+
const counters = /* @__PURE__ */ new Map();
|
|
105
|
+
walkObjects(scene?.objects, (o, parent) => {
|
|
106
|
+
const key = parent?.id ?? null;
|
|
107
|
+
const index = counters.get(key) ?? 0;
|
|
108
|
+
counters.set(key, index + 1);
|
|
109
|
+
if (typeof o.id !== "string") return;
|
|
110
|
+
const { children: _c, ...rest } = o;
|
|
111
|
+
map.set(o.id, {
|
|
112
|
+
object: rest,
|
|
113
|
+
parent: key,
|
|
114
|
+
index
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
return map;
|
|
118
|
+
}
|
|
119
|
+
function reorderedIds(a, b) {
|
|
120
|
+
const groups = /* @__PURE__ */ new Map();
|
|
121
|
+
for (const [id, nb] of b) {
|
|
122
|
+
const na = a.get(id);
|
|
123
|
+
if (!na || na.parent !== nb.parent) continue;
|
|
124
|
+
const list = groups.get(nb.parent) ?? [];
|
|
125
|
+
list.push(id);
|
|
126
|
+
groups.set(nb.parent, list);
|
|
127
|
+
}
|
|
128
|
+
const out = /* @__PURE__ */ new Set();
|
|
129
|
+
for (const ids of groups.values()) {
|
|
130
|
+
ids.sort((x, y) => b.get(x).index - b.get(y).index);
|
|
131
|
+
const seq = ids.map((id) => a.get(id).index);
|
|
132
|
+
const len = seq.map(() => 1);
|
|
133
|
+
const prev = seq.map(() => -1);
|
|
134
|
+
for (let i = 0; i < seq.length; i++) for (let j = 0; j < i; j++) if (seq[j] < seq[i] && len[j] + 1 > len[i]) {
|
|
135
|
+
len[i] = len[j] + 1;
|
|
136
|
+
prev[i] = j;
|
|
137
|
+
}
|
|
138
|
+
let best = -1;
|
|
139
|
+
for (let i = 0; i < seq.length; i++) if (best < 0 || len[i] > len[best]) best = i;
|
|
140
|
+
const keep = /* @__PURE__ */ new Set();
|
|
141
|
+
for (let i = best; i >= 0; i = prev[i]) keep.add(i);
|
|
142
|
+
ids.forEach((id, i) => {
|
|
143
|
+
if (!keep.has(i)) out.add(id);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
function diffScenes(before, after) {
|
|
149
|
+
const a = flatMap(before);
|
|
150
|
+
const b = flatMap(after);
|
|
151
|
+
const added = [...b.keys()].filter((id) => !a.has(id));
|
|
152
|
+
const removed = [...a.keys()].filter((id) => !b.has(id));
|
|
153
|
+
const changed = [];
|
|
154
|
+
const moved = [];
|
|
155
|
+
for (const [id, nb] of b) {
|
|
156
|
+
const na = a.get(id);
|
|
157
|
+
if (!na) continue;
|
|
158
|
+
const fields = [.../* @__PURE__ */ new Set([...Object.keys(na.object), ...Object.keys(nb.object)])].filter((k) => !deepEqual(na.object[k], nb.object[k])).sort();
|
|
159
|
+
if (fields.length) changed.push({
|
|
160
|
+
id,
|
|
161
|
+
fields
|
|
162
|
+
});
|
|
163
|
+
if (na.parent !== nb.parent) moved.push({
|
|
164
|
+
id,
|
|
165
|
+
from: na.parent,
|
|
166
|
+
to: nb.parent,
|
|
167
|
+
index: nb.index
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
for (const id of reorderedIds(a, b)) {
|
|
171
|
+
const nb = b.get(id);
|
|
172
|
+
moved.push({
|
|
173
|
+
id,
|
|
174
|
+
from: nb.parent,
|
|
175
|
+
to: nb.parent,
|
|
176
|
+
index: nb.index
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
const orderOf = (s) => {
|
|
180
|
+
const out = [];
|
|
181
|
+
walkObjects(s?.objects, (o) => void out.push(String(o.id)));
|
|
182
|
+
return out.join("|");
|
|
183
|
+
};
|
|
184
|
+
const reordered = !added.length && !removed.length && !moved.length && orderOf(before) !== orderOf(after);
|
|
185
|
+
const sections = [];
|
|
186
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(before ?? {}), ...Object.keys(after)]);
|
|
187
|
+
for (const k of [...keys].sort()) {
|
|
188
|
+
if (k === "objects") continue;
|
|
189
|
+
if (!deepEqual(before?.[k], after[k])) sections.push(k);
|
|
190
|
+
}
|
|
191
|
+
if (reordered) sections.push("objects (order)");
|
|
192
|
+
const empty = !added.length && !removed.length && !changed.length && !moved.length && !sections.length;
|
|
193
|
+
const parts = [];
|
|
194
|
+
if (added.length) parts.push(`add ${added.length} object${added.length > 1 ? "s" : ""} (${added.slice(0, 8).join(", ")}${added.length > 8 ? ", …" : ""})`);
|
|
195
|
+
if (removed.length) parts.push(`remove ${removed.length} (${removed.slice(0, 8).join(", ")}${removed.length > 8 ? ", …" : ""})`);
|
|
196
|
+
if (changed.length) parts.push(`change ${changed.length} (${changed.slice(0, 8).map((c) => c.id).join(", ")}${changed.length > 8 ? ", …" : ""})`);
|
|
197
|
+
if (moved.length) parts.push(`move ${moved.length}`);
|
|
198
|
+
if (sections.length) parts.push(`update ${sections.join(", ")}`);
|
|
199
|
+
return {
|
|
200
|
+
empty,
|
|
201
|
+
objects: {
|
|
202
|
+
added,
|
|
203
|
+
removed,
|
|
204
|
+
changed,
|
|
205
|
+
moved
|
|
206
|
+
},
|
|
207
|
+
sections,
|
|
208
|
+
summary: empty ? "No changes." : `${parts.join("; ")}.`
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
async function currentScene(fs) {
|
|
212
|
+
if (!await fs.exists("scene.json")) return null;
|
|
213
|
+
return readSceneFile(fs);
|
|
214
|
+
}
|
|
215
|
+
async function applyScene(fs, next, opts = {}) {
|
|
216
|
+
if (!next || typeof next !== "object" || Array.isArray(next)) throw new OpsError("invalid", "scene must be a JSON object (a full SceneDoc).", "Use scene_get to fetch the current scene, edit it, and pass the whole document; or use scene_patch for small edits.");
|
|
217
|
+
const before = await currentScene(fs);
|
|
218
|
+
const issues = validateScene(next);
|
|
219
|
+
const plan = diffScenes(before, next);
|
|
220
|
+
if (hasErrors(issues) || plan.empty || opts.dryRun) return {
|
|
221
|
+
plan,
|
|
222
|
+
issues,
|
|
223
|
+
applied: false
|
|
224
|
+
};
|
|
225
|
+
await saveScene(fs, next);
|
|
226
|
+
return {
|
|
227
|
+
plan,
|
|
228
|
+
issues,
|
|
229
|
+
applied: true
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
var PATCH_OPS = [
|
|
233
|
+
"set",
|
|
234
|
+
"merge",
|
|
235
|
+
"remove",
|
|
236
|
+
"addObject",
|
|
237
|
+
"updateObject",
|
|
238
|
+
"removeObject",
|
|
239
|
+
"moveObject",
|
|
240
|
+
"addBehaviour",
|
|
241
|
+
"addTrack",
|
|
242
|
+
"removeTrack"
|
|
243
|
+
];
|
|
244
|
+
function opError(i, op, message, hint) {
|
|
245
|
+
return new OpsError("invalid", `Patch op #${i} (${op?.op ?? "?"}) failed: ${message}`, hint, {
|
|
246
|
+
opIndex: i,
|
|
247
|
+
op
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
function requireObject(scene, id, i, op) {
|
|
251
|
+
if (typeof id !== "string") throw opError(i, op, "\"id\" must be an object id string.");
|
|
252
|
+
const loc = findObject(scene.objects, id);
|
|
253
|
+
if (!loc) {
|
|
254
|
+
const s = closest(id, allObjectIds(scene));
|
|
255
|
+
throw opError(i, op, `No object with id "${id}".`, `${s ? `Did you mean "${s}"? ` : ""}List ids with scene_summary / object_list.`);
|
|
256
|
+
}
|
|
257
|
+
return loc;
|
|
258
|
+
}
|
|
259
|
+
function replacedCollections(scene, ops) {
|
|
260
|
+
const out = [];
|
|
261
|
+
const isCollection = (v) => Array.isArray(v) && v.length > 0 && v.some((x) => x !== null && typeof x === "object" && !Array.isArray(x));
|
|
262
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
263
|
+
(Array.isArray(ops) ? ops : []).forEach((op, opIndex) => {
|
|
264
|
+
if (!op || op.op !== "set" && op.op !== "merge" && op.op !== "remove" || typeof op.path !== "string") return;
|
|
265
|
+
let current;
|
|
266
|
+
try {
|
|
267
|
+
current = getAt(scene, op.path);
|
|
268
|
+
} catch {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
const value = op.op === "remove" ? void 0 : op.value;
|
|
272
|
+
if (isCollection(current)) {
|
|
273
|
+
if (!same(current, value)) out.push({
|
|
274
|
+
opIndex,
|
|
275
|
+
path: op.path,
|
|
276
|
+
items: current.length
|
|
277
|
+
});
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!current || typeof current !== "object" || Array.isArray(current)) return;
|
|
281
|
+
for (const [k, v] of Object.entries(current)) {
|
|
282
|
+
if (!isCollection(v)) continue;
|
|
283
|
+
const next = value && typeof value === "object" && !Array.isArray(value) ? value[k] : void 0;
|
|
284
|
+
if (op.op === "merge" && value && typeof value === "object" && !Array.isArray(value) && !(k in value)) continue;
|
|
285
|
+
if (!same(v, next)) out.push({
|
|
286
|
+
opIndex,
|
|
287
|
+
path: `${op.path}.${k}`,
|
|
288
|
+
items: v.length
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return out;
|
|
293
|
+
}
|
|
294
|
+
function applyPatchOps(scene, ops) {
|
|
295
|
+
if (!Array.isArray(ops)) throw new OpsError("invalid", "ops must be an array of patch operations.", `Ops: ${PATCH_OPS.join(", ")}.`);
|
|
296
|
+
const s = clone(scene);
|
|
297
|
+
if (!Array.isArray(s.objects)) s.objects = [];
|
|
298
|
+
ops.forEach((op, i) => {
|
|
299
|
+
if (!op || typeof op !== "object" || !PATCH_OPS.includes(op.op)) {
|
|
300
|
+
const name = op?.op;
|
|
301
|
+
const sug = typeof name === "string" ? closest(name, PATCH_OPS) : void 0;
|
|
302
|
+
throw opError(i, op, `Unknown op ${JSON.stringify(name)}.`, `${sug ? `Did you mean "${sug}"? ` : ""}Valid ops: ${PATCH_OPS.join(", ")}.`);
|
|
303
|
+
}
|
|
304
|
+
try {
|
|
305
|
+
applyOne(s, op, i);
|
|
306
|
+
} catch (e) {
|
|
307
|
+
if (e instanceof PathError) throw opError(i, op, e.message, e.hint);
|
|
308
|
+
throw e;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
return s;
|
|
312
|
+
}
|
|
313
|
+
function applyOne(s, op, i) {
|
|
314
|
+
switch (op.op) {
|
|
315
|
+
case "set":
|
|
316
|
+
if (op.value === void 0) throw opError(i, op, "\"value\" is required (use op \"remove\" to delete).");
|
|
317
|
+
if (parsePath(op.path).length === 0) throw opError(i, op, "Empty path.");
|
|
318
|
+
setAt(s, op.path, clone(op.value));
|
|
319
|
+
return;
|
|
320
|
+
case "merge": {
|
|
321
|
+
let current;
|
|
322
|
+
try {
|
|
323
|
+
current = getAt(s, op.path);
|
|
324
|
+
} catch {
|
|
325
|
+
current = void 0;
|
|
326
|
+
}
|
|
327
|
+
setAt(s, op.path, mergePatch(current, op.value));
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
case "remove":
|
|
331
|
+
if (!removeAt(s, op.path)) throw opError(i, op, `Nothing to remove at "${op.path}".`);
|
|
332
|
+
return;
|
|
333
|
+
case "addObject": {
|
|
334
|
+
const obj = op.object;
|
|
335
|
+
if (!obj || typeof obj !== "object") throw opError(i, op, "\"object\" must be an ObjectDef.", "Example: { \"id\": \"box\", \"kind\": \"mesh\", \"geometry\": { \"type\": \"box\" } }.");
|
|
336
|
+
if (!isValidId(obj.id)) throw opError(i, op, `Invalid object id ${JSON.stringify(obj.id)}.`, "Ids start with a letter: letters, digits, \"_\" or \"-\".");
|
|
337
|
+
const taken = /* @__PURE__ */ new Set([...allObjectIds(s), ...(s.lights ?? []).map((l) => l.id).filter(Boolean)]);
|
|
338
|
+
const newIds = [];
|
|
339
|
+
walkObjects([obj], (o) => void newIds.push(o.id));
|
|
340
|
+
const dup = newIds.find((id) => taken.has(id));
|
|
341
|
+
if (dup) throw new OpsError("conflict", `Patch op #${i} (addObject) failed: id "${dup}" is already used.`, `Pick another id (e.g. "${dup}-2"), or use updateObject to change the existing one.`, { opIndex: i });
|
|
342
|
+
let container = s.objects;
|
|
343
|
+
if (op.parent !== void 0 && op.parent !== null) {
|
|
344
|
+
const parent = requireObject(s, op.parent, i, op).object;
|
|
345
|
+
parent.children = parent.children ?? [];
|
|
346
|
+
container = parent.children;
|
|
347
|
+
}
|
|
348
|
+
const idx = op.index === void 0 ? container.length : Math.max(0, Math.min(container.length, Math.floor(op.index)));
|
|
349
|
+
container.splice(idx, 0, clone(obj));
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
case "updateObject": {
|
|
353
|
+
const loc = requireObject(s, op.id, i, op);
|
|
354
|
+
if (!op.set || typeof op.set !== "object") throw opError(i, op, "\"set\" must be an object of fields to change.", "Example: { \"position\": [0, 1, 0], \"material\": { \"color\": \"#ff0000\" } } (objects merge, null deletes).");
|
|
355
|
+
const set = op.set;
|
|
356
|
+
if ("id" in set && set.id !== op.id) throw opError(i, op, "Changing an object id is not supported by updateObject.", "Remove the object and add it again with the new id (and update timeline tracks / camera.follow).");
|
|
357
|
+
if ("children" in set) throw opError(i, op, "updateObject cannot replace children.", "Use addObject with parent, removeObject or moveObject.");
|
|
358
|
+
loc.container[loc.index] = mergePatch(loc.object, set);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
case "removeObject": {
|
|
362
|
+
const loc = requireObject(s, op.id, i, op);
|
|
363
|
+
const removedIds = [];
|
|
364
|
+
walkObjects([loc.object], (o) => void removedIds.push(o.id));
|
|
365
|
+
loc.container.splice(loc.index, 1);
|
|
366
|
+
if (s.timeline?.tracks) s.timeline.tracks = s.timeline.tracks.filter((t) => !removedIds.includes(String(t.target).split(".")[0]));
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
case "moveObject": {
|
|
370
|
+
const loc = requireObject(s, op.id, i, op);
|
|
371
|
+
let target;
|
|
372
|
+
if (op.parent === void 0) target = loc.container;
|
|
373
|
+
else if (op.parent === null) target = s.objects;
|
|
374
|
+
else {
|
|
375
|
+
if (op.parent === op.id || isDescendant(loc.object, op.parent)) throw opError(i, op, "Cannot move an object into itself or one of its descendants.");
|
|
376
|
+
const parent = requireObject(s, op.parent, i, op).object;
|
|
377
|
+
parent.children = parent.children ?? [];
|
|
378
|
+
target = parent.children;
|
|
379
|
+
}
|
|
380
|
+
loc.container.splice(loc.index, 1);
|
|
381
|
+
const idx = op.index === void 0 ? target.length : Math.max(0, Math.min(target.length, Math.floor(op.index)));
|
|
382
|
+
target.splice(idx, 0, loc.object);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
case "addBehaviour": {
|
|
386
|
+
if (!op.behaviour || typeof op.behaviour !== "object" || typeof op.behaviour.type !== "string") throw opError(i, op, "\"behaviour\" must be { \"type\": \"<catalog behaviour>\", …params }.");
|
|
387
|
+
const loc = findObject(s.objects, op.id);
|
|
388
|
+
const lightTarget = loc ? null : (s.lights ?? []).find((l) => l.id === op.id);
|
|
389
|
+
const target = loc?.object ?? lightTarget;
|
|
390
|
+
if (!target) requireObject(s, op.id, i, op);
|
|
391
|
+
const list = target.behaviours = target.behaviours ?? [];
|
|
392
|
+
if (!list.some((b) => deepEqual(b, op.behaviour))) list.push(clone(op.behaviour));
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
case "addTrack": {
|
|
396
|
+
const tr = op.track;
|
|
397
|
+
if (!tr || typeof tr !== "object" || typeof tr.target !== "string" || !Array.isArray(tr.keys)) throw opError(i, op, "\"track\" must be { \"target\": \"<id>.<property>\", \"keys\": [[t, v], …] }.");
|
|
398
|
+
const maxT = Math.max(0, ...tr.keys.map((k) => Array.isArray(k) && typeof k[0] === "number" ? k[0] : 0));
|
|
399
|
+
if (!s.timeline) s.timeline = {
|
|
400
|
+
duration: Math.max(1, maxT),
|
|
401
|
+
loop: true,
|
|
402
|
+
tracks: []
|
|
403
|
+
};
|
|
404
|
+
s.timeline.tracks = s.timeline.tracks ?? [];
|
|
405
|
+
const copy = clone(tr);
|
|
406
|
+
copy.keys = [...copy.keys].sort((a, b) => (a?.[0] ?? 0) - (b?.[0] ?? 0));
|
|
407
|
+
const existing = s.timeline.tracks.findIndex((t) => t.target === tr.target);
|
|
408
|
+
if (existing >= 0) s.timeline.tracks[existing] = copy;
|
|
409
|
+
else s.timeline.tracks.push(copy);
|
|
410
|
+
if (maxT > s.timeline.duration) s.timeline.duration = maxT;
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
case "removeTrack": {
|
|
414
|
+
const tracks = s.timeline?.tracks ?? [];
|
|
415
|
+
const idx = tracks.findIndex((t) => t.target === op.target);
|
|
416
|
+
if (idx < 0) {
|
|
417
|
+
const sug = closest(String(op.target), tracks.map((t) => t.target));
|
|
418
|
+
throw opError(i, op, `No track targets "${op.target}".`, sug ? `Did you mean "${sug}"?` : `Existing tracks: ${tracks.map((t) => t.target).join(", ") || "none"}.`);
|
|
419
|
+
}
|
|
420
|
+
tracks.splice(idx, 1);
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
async function patchScene(fs, ops, opts = {}) {
|
|
426
|
+
const before = await readSceneFile(fs);
|
|
427
|
+
const after = applyPatchOps(before, ops);
|
|
428
|
+
const issues = validateScene(after);
|
|
429
|
+
const plan = diffScenes(before, after);
|
|
430
|
+
if (hasErrors(issues) || plan.empty || opts.dryRun) return {
|
|
431
|
+
plan,
|
|
432
|
+
issues,
|
|
433
|
+
applied: false,
|
|
434
|
+
scene: hasErrors(issues) ? before : after
|
|
435
|
+
};
|
|
436
|
+
await saveScene(fs, after);
|
|
437
|
+
return {
|
|
438
|
+
plan,
|
|
439
|
+
issues,
|
|
440
|
+
applied: true,
|
|
441
|
+
scene: after
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
export { scene_exports as a, patchScene as i, applyScene as n, summarizeScene as o, getScene as r, PATCH_OPS as t };
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { createRequire as __a3dRequire } from "node:module";
|
|
2
|
+
import { fileURLToPath as __a3dPath } from "node:url";
|
|
3
|
+
import { dirname as __a3dDirname } from "node:path";
|
|
4
|
+
__a3dRequire(import.meta.url);
|
|
5
|
+
const __filename = __a3dPath(import.meta.url);
|
|
6
|
+
__a3dDirname(__filename);
|
|
7
|
+
import { B as toCliError } from "../agent3d.mjs";
|
|
8
|
+
// agent/mcp/server.ts
|
|
9
|
+
var SUPPORTED_PROTOCOLS = [
|
|
10
|
+
"2025-06-18",
|
|
11
|
+
"2025-03-26",
|
|
12
|
+
"2024-11-05"
|
|
13
|
+
];
|
|
14
|
+
var LATEST_PROTOCOL = SUPPORTED_PROTOCOLS[0];
|
|
15
|
+
var RPC = {
|
|
16
|
+
parse: -32700,
|
|
17
|
+
invalidRequest: -32600,
|
|
18
|
+
methodNotFound: -32601,
|
|
19
|
+
invalidParams: -32602,
|
|
20
|
+
internal: -32603
|
|
21
|
+
};
|
|
22
|
+
var DESTRUCTIVE = /* @__PURE__ */ new Set([
|
|
23
|
+
"scene_apply",
|
|
24
|
+
"object_remove",
|
|
25
|
+
"timeline_set",
|
|
26
|
+
"export",
|
|
27
|
+
"assets_remove"
|
|
28
|
+
]);
|
|
29
|
+
var IDEMPOTENT = /* @__PURE__ */ new Set([
|
|
30
|
+
"scene_apply",
|
|
31
|
+
"object_update",
|
|
32
|
+
"timeline_set",
|
|
33
|
+
"render_preview",
|
|
34
|
+
"export"
|
|
35
|
+
]);
|
|
36
|
+
var OPEN_WORLD = /* @__PURE__ */ new Set(["assets_search", "assets_add"]);
|
|
37
|
+
function toolAnnotations(tool) {
|
|
38
|
+
return {
|
|
39
|
+
title: tool.name.replace(/_/g, " ").replace(/^\w/, (c) => c.toUpperCase()),
|
|
40
|
+
readOnlyHint: !tool.mutating,
|
|
41
|
+
destructiveHint: tool.mutating && DESTRUCTIVE.has(tool.name),
|
|
42
|
+
idempotentHint: !tool.mutating || IDEMPOTENT.has(tool.name),
|
|
43
|
+
openWorldHint: OPEN_WORLD.has(tool.name)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isRefusal(result) {
|
|
47
|
+
if (!result || typeof result !== "object") return false;
|
|
48
|
+
const r = result;
|
|
49
|
+
return r.status === "refused" || r.applied === false && typeof r.counts?.errors === "number" && r.counts.errors > 0;
|
|
50
|
+
}
|
|
51
|
+
function createMcpServer(opts) {
|
|
52
|
+
const all = () => typeof opts.tools === "function" ? opts.tools() : opts.tools;
|
|
53
|
+
const visible = () => all().filter((t) => !(opts.readOnly && t.mutating));
|
|
54
|
+
const resources = opts.resources ?? [];
|
|
55
|
+
let initialized = false;
|
|
56
|
+
let protocol = LATEST_PROTOCOL;
|
|
57
|
+
const ok = (id, result) => ({
|
|
58
|
+
jsonrpc: "2.0",
|
|
59
|
+
id,
|
|
60
|
+
result
|
|
61
|
+
});
|
|
62
|
+
const fail = (id, code, message, data) => ({
|
|
63
|
+
jsonrpc: "2.0",
|
|
64
|
+
id,
|
|
65
|
+
error: {
|
|
66
|
+
code,
|
|
67
|
+
message,
|
|
68
|
+
...data !== void 0 ? { data } : {}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const withStructured = (text) => protocol >= "2025-06-18" && text.length <= 8192;
|
|
72
|
+
async function callTool(id, params) {
|
|
73
|
+
const name = typeof params.name === "string" ? params.name : "";
|
|
74
|
+
const tool = all().find((t) => t.name === name);
|
|
75
|
+
if (!tool) return fail(id, RPC.invalidParams, `Unknown tool: ${name}`);
|
|
76
|
+
if (opts.readOnly && tool.mutating) return fail(id, RPC.invalidParams, `Tool ${name} changes the project and this server is read-only.`);
|
|
77
|
+
const args = params.arguments && typeof params.arguments === "object" ? params.arguments : {};
|
|
78
|
+
try {
|
|
79
|
+
const result = await opts.call(name, args);
|
|
80
|
+
const structured = result && typeof result === "object" && !Array.isArray(result) ? result : { result: result ?? null };
|
|
81
|
+
const images = opts.images ? await opts.images(name, result).catch(() => []) : [];
|
|
82
|
+
const text = JSON.stringify(result ?? null);
|
|
83
|
+
return ok(id, {
|
|
84
|
+
content: [{
|
|
85
|
+
type: "text",
|
|
86
|
+
text
|
|
87
|
+
}, ...images.map((img) => ({
|
|
88
|
+
type: "image",
|
|
89
|
+
data: img.data,
|
|
90
|
+
mimeType: img.mimeType
|
|
91
|
+
}))],
|
|
92
|
+
...withStructured(text) ? { structuredContent: structured } : {},
|
|
93
|
+
isError: isRefusal(result)
|
|
94
|
+
});
|
|
95
|
+
} catch (err) {
|
|
96
|
+
const e = toCliError(err);
|
|
97
|
+
const error = {
|
|
98
|
+
code: e.code,
|
|
99
|
+
message: e.message,
|
|
100
|
+
...e.hint ? { hint: e.hint } : {},
|
|
101
|
+
...e.details !== void 0 ? { details: e.details } : {}
|
|
102
|
+
};
|
|
103
|
+
const text = JSON.stringify({ error });
|
|
104
|
+
return ok(id, {
|
|
105
|
+
content: [{
|
|
106
|
+
type: "text",
|
|
107
|
+
text
|
|
108
|
+
}],
|
|
109
|
+
...withStructured(text) ? { structuredContent: { error } } : {},
|
|
110
|
+
isError: true
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function readResource(id, uri) {
|
|
115
|
+
const r = resources.find((x) => x.uri === uri);
|
|
116
|
+
if (!r) return fail(id, -32002, `Resource not found: ${uri}`, { uri });
|
|
117
|
+
const value = await r.read();
|
|
118
|
+
return ok(id, { contents: [{
|
|
119
|
+
uri,
|
|
120
|
+
mimeType: r.mimeType,
|
|
121
|
+
text: typeof value === "string" ? value : JSON.stringify(value)
|
|
122
|
+
}] });
|
|
123
|
+
}
|
|
124
|
+
async function handle(msg) {
|
|
125
|
+
if (!msg || typeof msg !== "object" || msg.jsonrpc !== "2.0" || typeof msg.method !== "string") {
|
|
126
|
+
const id = msg && typeof msg === "object" && "id" in msg ? msg.id ?? null : null;
|
|
127
|
+
return fail(id, RPC.invalidRequest, "Invalid JSON-RPC 2.0 request.");
|
|
128
|
+
}
|
|
129
|
+
const req = msg;
|
|
130
|
+
const isNotification = !("id" in req) || req.id === void 0;
|
|
131
|
+
const id = req.id ?? null;
|
|
132
|
+
const params = req.params ?? {};
|
|
133
|
+
if (isNotification) {
|
|
134
|
+
if (req.method === "notifications/initialized") initialized = true;
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
switch (req.method) {
|
|
139
|
+
case "initialize": {
|
|
140
|
+
const requested = typeof params.protocolVersion === "string" ? params.protocolVersion : LATEST_PROTOCOL;
|
|
141
|
+
protocol = SUPPORTED_PROTOCOLS.includes(requested) ? requested : LATEST_PROTOCOL;
|
|
142
|
+
return ok(id, {
|
|
143
|
+
protocolVersion: protocol,
|
|
144
|
+
capabilities: {
|
|
145
|
+
tools: { listChanged: false },
|
|
146
|
+
resources: {
|
|
147
|
+
listChanged: false,
|
|
148
|
+
subscribe: false
|
|
149
|
+
},
|
|
150
|
+
prompts: { listChanged: false },
|
|
151
|
+
logging: {}
|
|
152
|
+
},
|
|
153
|
+
serverInfo: {
|
|
154
|
+
name: opts.serverName,
|
|
155
|
+
title: "Agent3D",
|
|
156
|
+
version: opts.version
|
|
157
|
+
},
|
|
158
|
+
instructions: `${opts.instructions}${opts.readOnly ? " READ-ONLY: tools that change the project are hidden." : ""}`
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
case "ping": return ok(id, {});
|
|
162
|
+
case "tools/list": return ok(id, { tools: visible().map((t) => ({
|
|
163
|
+
name: t.name,
|
|
164
|
+
title: toolAnnotations(t).title,
|
|
165
|
+
description: t.description,
|
|
166
|
+
inputSchema: t.inputSchema,
|
|
167
|
+
annotations: toolAnnotations(t)
|
|
168
|
+
})) });
|
|
169
|
+
case "tools/call": return callTool(id, params);
|
|
170
|
+
case "resources/list": return ok(id, { resources: resources.map(({ read: _read, ...r }) => r) });
|
|
171
|
+
case "resources/templates/list": return ok(id, { resourceTemplates: [] });
|
|
172
|
+
case "resources/read": return readResource(id, typeof params.uri === "string" ? params.uri : "");
|
|
173
|
+
case "prompts/list": return ok(id, { prompts: [] });
|
|
174
|
+
case "logging/setLevel": return ok(id, {});
|
|
175
|
+
default: return fail(id, RPC.methodNotFound, `Method not found: ${req.method}`);
|
|
176
|
+
}
|
|
177
|
+
} catch (err) {
|
|
178
|
+
return fail(id, RPC.internal, err.message);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
handle,
|
|
183
|
+
get initialized() {
|
|
184
|
+
return initialized;
|
|
185
|
+
},
|
|
186
|
+
get protocol() {
|
|
187
|
+
return protocol;
|
|
188
|
+
},
|
|
189
|
+
toolNames: () => visible().map((t) => t.name)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function serveStdio(server, input, write, log = () => void 0) {
|
|
193
|
+
return new Promise((resolve) => {
|
|
194
|
+
let buffer = "";
|
|
195
|
+
let chain = Promise.resolve();
|
|
196
|
+
const processLine = async (line) => {
|
|
197
|
+
if (!line.trim()) return;
|
|
198
|
+
let msg;
|
|
199
|
+
try {
|
|
200
|
+
msg = JSON.parse(line);
|
|
201
|
+
} catch {
|
|
202
|
+
write(JSON.stringify({
|
|
203
|
+
jsonrpc: "2.0",
|
|
204
|
+
id: null,
|
|
205
|
+
error: {
|
|
206
|
+
code: RPC.parse,
|
|
207
|
+
message: "Parse error"
|
|
208
|
+
}
|
|
209
|
+
}));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (Array.isArray(msg)) {
|
|
213
|
+
const out = (await Promise.all(msg.map((m) => server.handle(m)))).filter((r) => r !== null);
|
|
214
|
+
if (out.length) write(JSON.stringify(out));
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const res = await server.handle(msg);
|
|
218
|
+
if (res) write(JSON.stringify(res));
|
|
219
|
+
};
|
|
220
|
+
input.setEncoding?.("utf8");
|
|
221
|
+
input.on("data", (chunk) => {
|
|
222
|
+
buffer += chunk.toString();
|
|
223
|
+
let nl;
|
|
224
|
+
while ((nl = buffer.indexOf("\n")) >= 0) {
|
|
225
|
+
const line = buffer.slice(0, nl).replace(/\r$/, "");
|
|
226
|
+
buffer = buffer.slice(nl + 1);
|
|
227
|
+
chain = chain.then(() => processLine(line)).catch((err) => log(`[mcp] ${err.message}`));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
input.on("end", () => {
|
|
231
|
+
const rest = buffer;
|
|
232
|
+
buffer = "";
|
|
233
|
+
chain = chain.then(() => processLine(rest)).finally(() => resolve());
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
export { createMcpServer, serveStdio };
|