@fleox/agent3d 0.0.0-stage → 0.2.1
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 +396 -2
- package/changelog.json +68 -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-Bdtm4fBN.mjs +178 -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-Dz9PFxi9.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-BOIyp_2B.mjs +75 -0
- package/dist/agent/chunks/png-DXfSGJZt.mjs +91 -0
- package/dist/agent/chunks/render-CN4mgGLQ.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-XmME4f7Z.js +1 -0
- package/dist/runtime/chunks/EXRLoader-CBdIpBMT.js +1 -0
- package/dist/runtime/chunks/FontLoader-dVu9WH2X.js +2 -0
- package/dist/runtime/chunks/GLTFLoader-Z9Inv-Xm.js +1 -0
- package/dist/runtime/chunks/GroundedSkybox-g1ASZWNu.js +1 -0
- package/dist/runtime/chunks/HDRLoader-DBOMWa7O.js +5 -0
- package/dist/runtime/chunks/OrbitControls-BIpWXK4x.js +1 -0
- package/dist/runtime/chunks/RectAreaLightUniformsLib-4ZzgX9vp.js +1 -0
- package/dist/runtime/chunks/RoomEnvironment-CXgfLJdO.js +1 -0
- package/dist/runtime/chunks/RoundedBoxGeometry-BViRogcJ.js +1 -0
- package/dist/runtime/chunks/SVGLoader-CV0U1EIF.js +1 -0
- package/dist/runtime/chunks/SkeletonUtils-DHlReJx3.js +1 -0
- package/dist/runtime/chunks/Sky-DGJXlPb_.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-D6WnITQq.js +1 -0
- package/dist/runtime/chunks/game-BoEiyZrL.js +20 -0
- package/dist/runtime/chunks/generators-D5JUo0jp.js +331 -0
- package/dist/runtime/chunks/materials-Dn-bYrZd.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-BCVF3QzB.js +1 -0
- package/dist/runtime/chunks/params-C2uoUDJ0.js +1 -0
- package/dist/runtime/chunks/physicsHost-ChPgysMQ.js +1 -0
- package/dist/runtime/chunks/postfx-UgKCbmZs.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-Dw6zHdu_.js +443 -0
- package/dist/runtime/chunks/svg-CmlFY_8O.js +1 -0
- package/dist/runtime/chunks/text-D1EQpdSU.js +2 -0
- package/dist/runtime/chunks/three.module-DnaBiDAJ.js +4225 -0
- package/dist/runtime/chunks/toon-BsvVk_nK.js +6 -0
- package/dist/runtime/chunks/util-CyaW1fcW.js +1 -0
- package/dist/studio/assets/BufferGeometryUtils-CAlXAboW.js +1 -0
- package/dist/studio/assets/EXRLoader-BKkzlNd8.js +1 -0
- package/dist/studio/assets/FontLoader-Bzjx8mXt.js +2 -0
- package/dist/studio/assets/GLTFLoader-1Zd9N406.js +1 -0
- package/dist/studio/assets/GroundedSkybox-BEMqNCBD.js +1 -0
- package/dist/studio/assets/HDRLoader-DxB0kxPH.js +5 -0
- package/dist/studio/assets/OrbitControls-MlE9XiCg.js +1 -0
- package/dist/studio/assets/RectAreaLightUniformsLib-ClHrtYY6.js +1 -0
- package/dist/studio/assets/RoomEnvironment-MJ-jIEC8.js +1 -0
- package/dist/studio/assets/SVGLoader-CIYl0nEy.js +1 -0
- package/dist/studio/assets/SkeletonUtils-CG5akqME.js +1 -0
- package/dist/studio/assets/Sky-DNMfpp92.js +243 -0
- package/dist/studio/assets/audio-JD1kyX0A.js +1 -0
- package/dist/studio/assets/camera-7sEn13L-.js +2 -0
- package/dist/studio/assets/editor-CnbvVkhU.js +53 -0
- package/dist/studio/assets/extrude-9bG8hr2C.js +1 -0
- package/dist/studio/assets/game-B04KGAK0.js +19 -0
- package/dist/studio/assets/generators-LSni1Yfc.js +331 -0
- package/dist/studio/assets/index-3LL5NEIH.js +479 -0
- package/dist/studio/assets/index-BQT0otii.css +1 -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-CNddhwmA.js +2 -0
- package/dist/studio/assets/physicsHost-hMU_SDiX.js +1 -0
- package/dist/studio/assets/postfx-BcCZS0Bq.js +1527 -0
- package/dist/studio/assets/runtime-DY_KqD1x.js +572 -0
- package/dist/studio/assets/shaders-BhMCstyv.js +443 -0
- package/dist/studio/assets/svg-CNKK-h7H.js +2 -0
- package/dist/studio/assets/text-BSPI7dk1.js +3 -0
- package/dist/studio/assets/three.module-CnI50X0U.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,319 @@
|
|
|
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
|
+
// agent/render/gif.ts
|
|
8
|
+
function channel(c, ch) {
|
|
9
|
+
return c >>> ch * 8 & 255;
|
|
10
|
+
}
|
|
11
|
+
function medianCut(samples, count) {
|
|
12
|
+
if (!samples.length) return [[
|
|
13
|
+
0,
|
|
14
|
+
0,
|
|
15
|
+
0
|
|
16
|
+
]];
|
|
17
|
+
const boxes = [{
|
|
18
|
+
colors: samples,
|
|
19
|
+
lo: 0,
|
|
20
|
+
hi: samples.length
|
|
21
|
+
}];
|
|
22
|
+
const range = (b) => {
|
|
23
|
+
let best = 0, bestRange = -1;
|
|
24
|
+
for (let ch = 0; ch < 3; ch++) {
|
|
25
|
+
let mn = 255, mx = 0;
|
|
26
|
+
for (let i = b.lo; i < b.hi; i++) {
|
|
27
|
+
const v = channel(b.colors[i], ch);
|
|
28
|
+
if (v < mn) mn = v;
|
|
29
|
+
if (v > mx) mx = v;
|
|
30
|
+
}
|
|
31
|
+
const r = (mx - mn) * (ch === 1 ? 1.2 : ch === 0 ? 1 : .8);
|
|
32
|
+
if (r > bestRange) bestRange = r, best = ch;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
ch: best,
|
|
36
|
+
r: bestRange
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
while (boxes.length < count) {
|
|
40
|
+
let pick = -1, score = 0, pickCh = 0;
|
|
41
|
+
for (let i = 0; i < boxes.length; i++) {
|
|
42
|
+
const b = boxes[i];
|
|
43
|
+
if (b.hi - b.lo < 2) continue;
|
|
44
|
+
const { ch, r } = range(b);
|
|
45
|
+
const s = r * Math.sqrt(b.hi - b.lo);
|
|
46
|
+
if (s > score) score = s, pick = i, pickCh = ch;
|
|
47
|
+
}
|
|
48
|
+
if (pick < 0) break;
|
|
49
|
+
const b = boxes[pick];
|
|
50
|
+
const sub = b.colors.subarray(b.lo, b.hi).sort((x, y) => channel(x, pickCh) - channel(y, pickCh));
|
|
51
|
+
b.colors.set(sub, b.lo);
|
|
52
|
+
const mid = b.lo + (b.hi - b.lo >> 1);
|
|
53
|
+
boxes.splice(pick, 1, {
|
|
54
|
+
colors: b.colors,
|
|
55
|
+
lo: b.lo,
|
|
56
|
+
hi: mid
|
|
57
|
+
}, {
|
|
58
|
+
colors: b.colors,
|
|
59
|
+
lo: mid,
|
|
60
|
+
hi: b.hi
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return boxes.map((b) => {
|
|
64
|
+
let r = 0, g = 0, bl = 0;
|
|
65
|
+
for (let i = b.lo; i < b.hi; i++) {
|
|
66
|
+
const c = b.colors[i];
|
|
67
|
+
r += c & 255;
|
|
68
|
+
g += c >>> 8 & 255;
|
|
69
|
+
bl += c >>> 16 & 255;
|
|
70
|
+
}
|
|
71
|
+
const n = Math.max(1, b.hi - b.lo);
|
|
72
|
+
return [
|
|
73
|
+
Math.round(r / n),
|
|
74
|
+
Math.round(g / n),
|
|
75
|
+
Math.round(bl / n)
|
|
76
|
+
];
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
var BAYER4 = [
|
|
80
|
+
0,
|
|
81
|
+
8,
|
|
82
|
+
2,
|
|
83
|
+
10,
|
|
84
|
+
12,
|
|
85
|
+
4,
|
|
86
|
+
14,
|
|
87
|
+
6,
|
|
88
|
+
3,
|
|
89
|
+
11,
|
|
90
|
+
1,
|
|
91
|
+
9,
|
|
92
|
+
15,
|
|
93
|
+
7,
|
|
94
|
+
13,
|
|
95
|
+
5
|
|
96
|
+
].map((v) => (v + .5) / 16 - .5);
|
|
97
|
+
var Mapper = class {
|
|
98
|
+
palette;
|
|
99
|
+
offset;
|
|
100
|
+
cache = (/* @__PURE__ */ new Int16Array(32768)).fill(-1);
|
|
101
|
+
constructor(palette, offset) {
|
|
102
|
+
this.palette = palette;
|
|
103
|
+
this.offset = offset;
|
|
104
|
+
}
|
|
105
|
+
index(r, g, b) {
|
|
106
|
+
const key = r >> 3 << 10 | g >> 3 << 5 | b >> 3;
|
|
107
|
+
const hit = this.cache[key];
|
|
108
|
+
if (hit >= 0) return hit;
|
|
109
|
+
const cr = r & -8 | 4, cg = g & -8 | 4, cb = b & -8 | 4;
|
|
110
|
+
let best = 0, bestD = Infinity;
|
|
111
|
+
for (let i = 0; i < this.palette.length; i++) {
|
|
112
|
+
const p = this.palette[i];
|
|
113
|
+
const dr = p[0] - cr, dg = p[1] - cg, db = p[2] - cb;
|
|
114
|
+
const d = dr * dr * 2 + dg * dg * 4 + db * db * 3;
|
|
115
|
+
if (d < bestD) bestD = d, best = i;
|
|
116
|
+
}
|
|
117
|
+
const idx = best + this.offset;
|
|
118
|
+
this.cache[key] = idx;
|
|
119
|
+
return idx;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
function lzwEncode(indices, minCodeSize) {
|
|
123
|
+
const clear = 1 << minCodeSize;
|
|
124
|
+
const eoi = clear + 1;
|
|
125
|
+
const out = [];
|
|
126
|
+
let cur = 0, bits = 0;
|
|
127
|
+
let size = minCodeSize + 1;
|
|
128
|
+
const emit = (code) => {
|
|
129
|
+
cur |= code << bits;
|
|
130
|
+
bits += size;
|
|
131
|
+
while (bits >= 8) {
|
|
132
|
+
out.push(cur & 255);
|
|
133
|
+
cur >>>= 8;
|
|
134
|
+
bits -= 8;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
let dict = /* @__PURE__ */ new Map();
|
|
138
|
+
let next = eoi + 1;
|
|
139
|
+
emit(clear);
|
|
140
|
+
let prefix = indices.length ? indices[0] : 0;
|
|
141
|
+
for (let i = 1; i < indices.length; i++) {
|
|
142
|
+
const k = indices[i];
|
|
143
|
+
const key = prefix << 8 | k;
|
|
144
|
+
const found = dict.get(key);
|
|
145
|
+
if (found !== void 0) {
|
|
146
|
+
prefix = found;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
emit(prefix);
|
|
150
|
+
if (next < 4096) {
|
|
151
|
+
dict.set(key, next++);
|
|
152
|
+
if (next > 1 << size && size < 12) size++;
|
|
153
|
+
} else {
|
|
154
|
+
emit(clear);
|
|
155
|
+
dict = /* @__PURE__ */ new Map();
|
|
156
|
+
next = eoi + 1;
|
|
157
|
+
size = minCodeSize + 1;
|
|
158
|
+
}
|
|
159
|
+
prefix = k;
|
|
160
|
+
}
|
|
161
|
+
if (indices.length) emit(prefix);
|
|
162
|
+
emit(eoi);
|
|
163
|
+
if (bits > 0) out.push(cur & 255);
|
|
164
|
+
return new Uint8Array(out);
|
|
165
|
+
}
|
|
166
|
+
var Bytes = class {
|
|
167
|
+
parts = [];
|
|
168
|
+
chunks = [];
|
|
169
|
+
byte(b) {
|
|
170
|
+
this.parts.push(b & 255);
|
|
171
|
+
}
|
|
172
|
+
u16(n) {
|
|
173
|
+
this.byte(n);
|
|
174
|
+
this.byte(n >> 8);
|
|
175
|
+
}
|
|
176
|
+
str(s) {
|
|
177
|
+
for (let i = 0; i < s.length; i++) this.byte(s.charCodeAt(i));
|
|
178
|
+
}
|
|
179
|
+
raw(b) {
|
|
180
|
+
this.flush();
|
|
181
|
+
this.chunks.push(b);
|
|
182
|
+
}
|
|
183
|
+
flush() {
|
|
184
|
+
if (this.parts.length) this.chunks.push(new Uint8Array(this.parts));
|
|
185
|
+
this.parts = [];
|
|
186
|
+
}
|
|
187
|
+
done() {
|
|
188
|
+
this.flush();
|
|
189
|
+
const out = new Uint8Array(this.chunks.reduce((a, c) => a + c.byteLength, 0));
|
|
190
|
+
let o = 0;
|
|
191
|
+
for (const c of this.chunks) out.set(c, o), o += c.byteLength;
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
function subBlocks(data) {
|
|
196
|
+
const n = Math.ceil(data.length / 255);
|
|
197
|
+
const out = new Uint8Array(data.length + n + 1);
|
|
198
|
+
let o = 0;
|
|
199
|
+
for (let i = 0; i < data.length; i += 255) {
|
|
200
|
+
const len = Math.min(255, data.length - i);
|
|
201
|
+
out[o++] = len;
|
|
202
|
+
out.set(data.subarray(i, i + len), o);
|
|
203
|
+
o += len;
|
|
204
|
+
}
|
|
205
|
+
out[o] = 0;
|
|
206
|
+
return out;
|
|
207
|
+
}
|
|
208
|
+
function encodeGif(frames, opts) {
|
|
209
|
+
const { width: w, height: h } = opts;
|
|
210
|
+
if (!frames.length) throw new Error("no frames");
|
|
211
|
+
const threshold = opts.alphaThreshold ?? 128;
|
|
212
|
+
const px = w * h;
|
|
213
|
+
let hasAlpha = false;
|
|
214
|
+
for (const f of frames) {
|
|
215
|
+
if (f.rgba.length !== px * 4) throw new Error("frame size mismatch");
|
|
216
|
+
if (!hasAlpha) {
|
|
217
|
+
for (let i = 3; i < f.rgba.length; i += 16) if (f.rgba[i] < threshold) {
|
|
218
|
+
hasAlpha = true;
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
const colors = Math.max(2, Math.min(256, opts.colors ?? 256)) - 1;
|
|
224
|
+
const step = Math.max(1, Math.floor(px * frames.length / 2e5));
|
|
225
|
+
const samples = [];
|
|
226
|
+
let k = 0;
|
|
227
|
+
for (const f of frames) for (let i = k++ * 7 % step; i < px; i += step) {
|
|
228
|
+
const o = i * 4;
|
|
229
|
+
if (f.rgba[o + 3] < threshold) continue;
|
|
230
|
+
samples.push(f.rgba[o] | f.rgba[o + 1] << 8 | f.rgba[o + 2] << 16);
|
|
231
|
+
}
|
|
232
|
+
const palette = medianCut(Uint32Array.from(samples), colors);
|
|
233
|
+
const mapper = new Mapper(palette, 1);
|
|
234
|
+
const amp = opts.dither !== false ? 255 / Math.cbrt(palette.length) / 2 : 0;
|
|
235
|
+
const out = new Bytes();
|
|
236
|
+
out.str("GIF89a");
|
|
237
|
+
out.u16(w);
|
|
238
|
+
out.u16(h);
|
|
239
|
+
out.byte(247);
|
|
240
|
+
out.byte(0);
|
|
241
|
+
out.byte(0);
|
|
242
|
+
const table = /* @__PURE__ */ new Uint8Array(768);
|
|
243
|
+
palette.forEach((c, i) => table.set(c, (i + 1) * 3));
|
|
244
|
+
out.raw(table);
|
|
245
|
+
if (opts.loop !== -1) {
|
|
246
|
+
out.byte(33);
|
|
247
|
+
out.byte(255);
|
|
248
|
+
out.byte(11);
|
|
249
|
+
out.str("NETSCAPE2.0");
|
|
250
|
+
out.byte(3);
|
|
251
|
+
out.byte(1);
|
|
252
|
+
out.u16(opts.loop ?? 0);
|
|
253
|
+
out.byte(0);
|
|
254
|
+
}
|
|
255
|
+
let prev = null;
|
|
256
|
+
const cs = (i) => Math.round(i * 100 / opts.fps);
|
|
257
|
+
for (let fi = 0; fi < frames.length; fi++) {
|
|
258
|
+
const rgba = frames[fi].rgba;
|
|
259
|
+
const idx = new Uint8Array(px);
|
|
260
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
261
|
+
const p = y * w + x;
|
|
262
|
+
const o = p * 4;
|
|
263
|
+
if (rgba[o + 3] < threshold) {
|
|
264
|
+
idx[p] = 0;
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const d = amp * BAYER4[(y & 3) << 2 | x & 3];
|
|
268
|
+
const r = Math.max(0, Math.min(255, rgba[o] + d)) | 0;
|
|
269
|
+
const g = Math.max(0, Math.min(255, rgba[o + 1] + d)) | 0;
|
|
270
|
+
const b = Math.max(0, Math.min(255, rgba[o + 2] + d)) | 0;
|
|
271
|
+
idx[p] = mapper.index(r, g, b);
|
|
272
|
+
}
|
|
273
|
+
let x0 = 0, y0 = 0, x1 = w - 1, y1 = h - 1;
|
|
274
|
+
let data = idx;
|
|
275
|
+
if (prev && !hasAlpha) {
|
|
276
|
+
x0 = w;
|
|
277
|
+
y0 = h;
|
|
278
|
+
x1 = -1;
|
|
279
|
+
y1 = -1;
|
|
280
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) {
|
|
281
|
+
const p = y * w + x;
|
|
282
|
+
if (idx[p] !== prev[p]) {
|
|
283
|
+
if (x < x0) x0 = x;
|
|
284
|
+
if (x > x1) x1 = x;
|
|
285
|
+
if (y < y0) y0 = y;
|
|
286
|
+
if (y > y1) y1 = y;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (x1 < 0) x0 = 0, y0 = 0, x1 = 0, y1 = 0;
|
|
290
|
+
const cw = x1 - x0 + 1, ch = y1 - y0 + 1;
|
|
291
|
+
data = new Uint8Array(cw * ch);
|
|
292
|
+
for (let y = 0; y < ch; y++) for (let x = 0; x < cw; x++) {
|
|
293
|
+
const p = (y + y0) * w + (x + x0);
|
|
294
|
+
data[y * cw + x] = idx[p] === prev[p] ? 0 : idx[p];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
const transparent = hasAlpha || !!prev;
|
|
298
|
+
out.byte(33);
|
|
299
|
+
out.byte(249);
|
|
300
|
+
out.byte(4);
|
|
301
|
+
const disposal = hasAlpha ? 2 : 1;
|
|
302
|
+
out.byte(disposal << 2 | (transparent ? 1 : 0));
|
|
303
|
+
out.u16(Math.max(2, cs(fi + 1) - cs(fi)));
|
|
304
|
+
out.byte(0);
|
|
305
|
+
out.byte(0);
|
|
306
|
+
out.byte(44);
|
|
307
|
+
out.u16(x0);
|
|
308
|
+
out.u16(y0);
|
|
309
|
+
out.u16(x1 - x0 + 1);
|
|
310
|
+
out.u16(y1 - y0 + 1);
|
|
311
|
+
out.byte(0);
|
|
312
|
+
out.byte(8);
|
|
313
|
+
out.raw(subBlocks(lzwEncode(data, 8)));
|
|
314
|
+
prev = idx;
|
|
315
|
+
}
|
|
316
|
+
out.byte(59);
|
|
317
|
+
return out.done();
|
|
318
|
+
}
|
|
319
|
+
export { encodeGif };
|
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
// src/ops/gltf.ts
|
|
9
|
+
var gltf_exports = /* @__PURE__ */ __exportAll({ modelFileBounds: () => modelFileBounds });
|
|
10
|
+
function glbJson(bytes) {
|
|
11
|
+
if (bytes.byteLength < 20) return null;
|
|
12
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
13
|
+
if (view.getUint32(0, true) !== 1179937895) return null;
|
|
14
|
+
const len = view.getUint32(12, true);
|
|
15
|
+
if (view.getUint32(16, true) !== 1313821514 || 20 + len > bytes.byteLength) return null;
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(new TextDecoder().decode(bytes.subarray(20, 20 + len)));
|
|
18
|
+
} catch {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function gltfInfo(json) {
|
|
23
|
+
if (!json || typeof json !== "object") return null;
|
|
24
|
+
const g = json;
|
|
25
|
+
const acc = g.accessors ?? [];
|
|
26
|
+
const meshTris = (mi) => {
|
|
27
|
+
let t = 0;
|
|
28
|
+
for (const p of g.meshes?.[mi]?.primitives ?? []) {
|
|
29
|
+
const pos = p.attributes?.POSITION;
|
|
30
|
+
const count = p.indices !== void 0 ? acc[p.indices]?.count : pos !== void 0 ? acc[pos]?.count : 0;
|
|
31
|
+
const mode = p.mode ?? 4;
|
|
32
|
+
const n = Number(count) || 0;
|
|
33
|
+
t += mode === 4 ? n / 3 : mode === 5 || mode === 6 ? Math.max(0, n - 2) : 0;
|
|
34
|
+
}
|
|
35
|
+
return t;
|
|
36
|
+
};
|
|
37
|
+
let triangles = 0;
|
|
38
|
+
const seen = /* @__PURE__ */ new Set();
|
|
39
|
+
const visit = (ni, depth) => {
|
|
40
|
+
const n = g.nodes?.[ni];
|
|
41
|
+
if (!n || depth > 64 || seen.has(ni)) return;
|
|
42
|
+
seen.add(ni);
|
|
43
|
+
if (n.mesh !== void 0) triangles += meshTris(n.mesh);
|
|
44
|
+
for (const c of n.children ?? []) visit(c, depth + 1);
|
|
45
|
+
};
|
|
46
|
+
const scene = g.scenes?.[g.scene ?? 0];
|
|
47
|
+
if (scene) for (const ni of scene.nodes ?? []) visit(ni, 0);
|
|
48
|
+
else (g.meshes ?? []).forEach((_, mi) => triangles += meshTris(mi));
|
|
49
|
+
return {
|
|
50
|
+
triangles: Math.round(triangles),
|
|
51
|
+
animations: (g.animations ?? []).map((a, i) => a.name || `clip${i}`)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function modelInfo(path, bytes) {
|
|
55
|
+
if (/\.glb$/i.test(path)) return gltfInfo(glbJson(bytes));
|
|
56
|
+
try {
|
|
57
|
+
return gltfInfo(JSON.parse(new TextDecoder().decode(bytes)));
|
|
58
|
+
} catch {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
var COMPONENT_MAX = {
|
|
63
|
+
5120: 127,
|
|
64
|
+
5121: 255,
|
|
65
|
+
5122: 32767,
|
|
66
|
+
5123: 65535
|
|
67
|
+
};
|
|
68
|
+
var IDENTITY = [
|
|
69
|
+
1,
|
|
70
|
+
0,
|
|
71
|
+
0,
|
|
72
|
+
0,
|
|
73
|
+
0,
|
|
74
|
+
1,
|
|
75
|
+
0,
|
|
76
|
+
0,
|
|
77
|
+
0,
|
|
78
|
+
0,
|
|
79
|
+
1,
|
|
80
|
+
0,
|
|
81
|
+
0,
|
|
82
|
+
0,
|
|
83
|
+
0,
|
|
84
|
+
1
|
|
85
|
+
];
|
|
86
|
+
function mul(a, b) {
|
|
87
|
+
const o = new Array(16).fill(0);
|
|
88
|
+
for (let c = 0; c < 4; c++) for (let r = 0; r < 4; r++) for (let k = 0; k < 4; k++) o[c * 4 + r] += a[k * 4 + r] * b[c * 4 + k];
|
|
89
|
+
return o;
|
|
90
|
+
}
|
|
91
|
+
function nodeMatrix(n) {
|
|
92
|
+
if (n.matrix?.length === 16) return n.matrix.slice();
|
|
93
|
+
const [x, y, z, w] = n.rotation ?? [
|
|
94
|
+
0,
|
|
95
|
+
0,
|
|
96
|
+
0,
|
|
97
|
+
1
|
|
98
|
+
];
|
|
99
|
+
const [sx, sy, sz] = n.scale ?? [
|
|
100
|
+
1,
|
|
101
|
+
1,
|
|
102
|
+
1
|
|
103
|
+
];
|
|
104
|
+
const [tx, ty, tz] = n.translation ?? [
|
|
105
|
+
0,
|
|
106
|
+
0,
|
|
107
|
+
0
|
|
108
|
+
];
|
|
109
|
+
return [
|
|
110
|
+
(1 - 2 * (y * y + z * z)) * sx,
|
|
111
|
+
2 * (x * y + z * w) * sx,
|
|
112
|
+
2 * (x * z - y * w) * sx,
|
|
113
|
+
0,
|
|
114
|
+
2 * (x * y - z * w) * sy,
|
|
115
|
+
(1 - 2 * (x * x + z * z)) * sy,
|
|
116
|
+
2 * (y * z + x * w) * sy,
|
|
117
|
+
0,
|
|
118
|
+
2 * (x * z + y * w) * sz,
|
|
119
|
+
2 * (y * z - x * w) * sz,
|
|
120
|
+
(1 - 2 * (x * x + y * y)) * sz,
|
|
121
|
+
0,
|
|
122
|
+
tx,
|
|
123
|
+
ty,
|
|
124
|
+
tz,
|
|
125
|
+
1
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
function gltfBounds(json) {
|
|
129
|
+
if (!json || typeof json !== "object") return null;
|
|
130
|
+
const g = json;
|
|
131
|
+
const acc = g.accessors ?? [];
|
|
132
|
+
const lo = [
|
|
133
|
+
Infinity,
|
|
134
|
+
Infinity,
|
|
135
|
+
Infinity
|
|
136
|
+
];
|
|
137
|
+
const hi = [
|
|
138
|
+
-Infinity,
|
|
139
|
+
-Infinity,
|
|
140
|
+
-Infinity
|
|
141
|
+
];
|
|
142
|
+
const seen = /* @__PURE__ */ new Set();
|
|
143
|
+
const visit = (ni, parent, depth) => {
|
|
144
|
+
const n = g.nodes?.[ni];
|
|
145
|
+
if (!n || depth > 64 || seen.has(ni)) return;
|
|
146
|
+
seen.add(ni);
|
|
147
|
+
const m = mul(parent, nodeMatrix(n));
|
|
148
|
+
if (n.mesh !== void 0) for (const p of g.meshes?.[n.mesh]?.primitives ?? []) {
|
|
149
|
+
const pos = p.attributes?.POSITION !== void 0 ? acc[p.attributes.POSITION] : void 0;
|
|
150
|
+
if (!pos?.min || !pos.max) continue;
|
|
151
|
+
const k = pos.normalized ? 1 / (COMPONENT_MAX[pos.componentType ?? 0] ?? 1) : 1;
|
|
152
|
+
const a = pos.min.map((v) => v * k);
|
|
153
|
+
const b = pos.max.map((v) => v * k);
|
|
154
|
+
for (let i = 0; i < 8; i++) {
|
|
155
|
+
const x = i & 1 ? b[0] : a[0];
|
|
156
|
+
const y = i & 2 ? b[1] : a[1];
|
|
157
|
+
const z = i & 4 ? b[2] : a[2];
|
|
158
|
+
const w = [
|
|
159
|
+
m[0] * x + m[4] * y + m[8] * z + m[12],
|
|
160
|
+
m[1] * x + m[5] * y + m[9] * z + m[13],
|
|
161
|
+
m[2] * x + m[6] * y + m[10] * z + m[14]
|
|
162
|
+
];
|
|
163
|
+
for (let c = 0; c < 3; c++) {
|
|
164
|
+
lo[c] = Math.min(lo[c], w[c]);
|
|
165
|
+
hi[c] = Math.max(hi[c], w[c]);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
for (const c of n.children ?? []) visit(c, m, depth + 1);
|
|
170
|
+
};
|
|
171
|
+
const roots = (g.scenes?.[g.scene ?? 0])?.nodes ?? (g.nodes ?? []).map((_, i) => i);
|
|
172
|
+
for (const ni of roots) visit(ni, IDENTITY, 0);
|
|
173
|
+
if (!Number.isFinite(lo[0])) return null;
|
|
174
|
+
const r = (v) => Math.round(v * 1e3) / 1e3;
|
|
175
|
+
const size = [
|
|
176
|
+
0,
|
|
177
|
+
1,
|
|
178
|
+
2
|
|
179
|
+
].map((c) => r(hi[c] - lo[c]));
|
|
180
|
+
const center = [
|
|
181
|
+
0,
|
|
182
|
+
1,
|
|
183
|
+
2
|
|
184
|
+
].map((c) => r((hi[c] + lo[c]) / 2));
|
|
185
|
+
const zUp = size[2] > size[1] * 2 && size[2] > size[0] * 1.2 && Math.abs(center[2]) > size[1] * .25;
|
|
186
|
+
return {
|
|
187
|
+
size,
|
|
188
|
+
center,
|
|
189
|
+
min: lo.map(r),
|
|
190
|
+
max: hi.map(r),
|
|
191
|
+
upAxis: zUp ? "z?" : "y",
|
|
192
|
+
...zUp ? { hint: "Much deeper (Z) than tall (Y) and off-centre in Z: it may have been exported Z-up (lying on its back). Check with `agent3d render --isolate <id>`; if so set the object's rotation to [-90, 0, 0]." } : {}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function modelBounds(path, bytes) {
|
|
196
|
+
if (/\.glb$/i.test(path)) return gltfBounds(glbJson(bytes));
|
|
197
|
+
try {
|
|
198
|
+
return gltfBounds(JSON.parse(new TextDecoder().decode(bytes)));
|
|
199
|
+
} catch {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function modelFileBounds(fs, path) {
|
|
204
|
+
if (!/\.(glb|gltf)$/i.test(path) || !await fs.exists(path)) return null;
|
|
205
|
+
return modelBounds(path, await fs.readBytes(path));
|
|
206
|
+
}
|
|
207
|
+
export { modelInfo as i, gltf_exports as n, modelFileBounds as r, glbJson as t };
|
|
@@ -0,0 +1,101 @@
|
|
|
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 { z as CliError } from "../agent3d.mjs";
|
|
8
|
+
import { launchBrowser, requireBrowser } from "./browser-t_JL_B82.mjs";
|
|
9
|
+
import { t as CdpClient } from "./cdp-Bdtm4fBN.mjs";
|
|
10
|
+
// agent/render/imageCodec.ts
|
|
11
|
+
var PAGE_FN = `async function (b64, mime, maxSize, quality, format, allowJpeg) {
|
|
12
|
+
const bin = atob(b64);
|
|
13
|
+
const bytes = new Uint8Array(bin.length);
|
|
14
|
+
for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
|
|
15
|
+
const bmp = await createImageBitmap(new Blob([bytes], { type: mime }), { colorSpaceConversion: "none", premultiplyAlpha: "none" });
|
|
16
|
+
const s = Math.min(1, maxSize / Math.max(bmp.width, bmp.height));
|
|
17
|
+
const w = Math.max(1, Math.round(bmp.width * s)), h = Math.max(1, Math.round(bmp.height * s));
|
|
18
|
+
const canvas = new OffscreenCanvas(w, h);
|
|
19
|
+
const g = canvas.getContext("2d");
|
|
20
|
+
g.imageSmoothingEnabled = true;
|
|
21
|
+
g.imageSmoothingQuality = "high";
|
|
22
|
+
g.drawImage(bmp, 0, 0, w, h);
|
|
23
|
+
let hasAlpha = false;
|
|
24
|
+
if (mime !== "image/jpeg") {
|
|
25
|
+
const d = g.getImageData(0, 0, w, h).data;
|
|
26
|
+
for (let i = 3; i < d.length; i += 4) if (d[i] < 255) { hasAlpha = true; break; }
|
|
27
|
+
}
|
|
28
|
+
let type = mime;
|
|
29
|
+
if (format === "auto" || format === "webp") type = "image/webp";
|
|
30
|
+
else if (format === "png") type = "image/png";
|
|
31
|
+
else if (format === "jpeg") type = hasAlpha ? mime : "image/jpeg";
|
|
32
|
+
else if (mime === "image/png" && allowJpeg && !hasAlpha) type = "image/jpeg";
|
|
33
|
+
const blob = await canvas.convertToBlob(type === "image/png" ? { type } : { type, quality: Math.min(quality, 99) / 100 });
|
|
34
|
+
const buf = new Uint8Array(await blob.arrayBuffer());
|
|
35
|
+
let out = "";
|
|
36
|
+
for (let i = 0; i < buf.length; i += 0x8000) out += String.fromCharCode.apply(null, buf.subarray(i, i + 0x8000));
|
|
37
|
+
return { b64: btoa(out), mimeType: blob.type, width: w, height: h, srcWidth: bmp.width, srcHeight: bmp.height, hasAlpha };
|
|
38
|
+
}`;
|
|
39
|
+
async function openImageCodec(opts = {}) {
|
|
40
|
+
const info = requireBrowser();
|
|
41
|
+
let browser = null;
|
|
42
|
+
let client = null;
|
|
43
|
+
const close = async () => {
|
|
44
|
+
try {
|
|
45
|
+
client?.close();
|
|
46
|
+
} catch {}
|
|
47
|
+
await browser?.close().catch(() => void 0);
|
|
48
|
+
};
|
|
49
|
+
let page;
|
|
50
|
+
let windowId;
|
|
51
|
+
try {
|
|
52
|
+
opts.log?.(`[agent3d assets] ${info.name}: ${info.path}`);
|
|
53
|
+
browser = await launchBrowser(info);
|
|
54
|
+
client = await CdpClient.connect(browser.wsUrl);
|
|
55
|
+
page = await client.newPage();
|
|
56
|
+
windowId = (await page.send("Runtime.evaluate", { expression: "window" })).result.objectId;
|
|
57
|
+
} catch (e) {
|
|
58
|
+
await close();
|
|
59
|
+
throw e;
|
|
60
|
+
}
|
|
61
|
+
const codec = async (input) => {
|
|
62
|
+
const r = await page.send("Runtime.callFunctionOn", {
|
|
63
|
+
functionDeclaration: PAGE_FN,
|
|
64
|
+
objectId: windowId,
|
|
65
|
+
arguments: [
|
|
66
|
+
{ value: Buffer.from(input.bytes).toString("base64") },
|
|
67
|
+
{ value: input.mimeType },
|
|
68
|
+
{ value: input.maxSize },
|
|
69
|
+
{ value: input.quality },
|
|
70
|
+
{ value: input.format ?? "keep" },
|
|
71
|
+
{ value: !!input.allowJpeg }
|
|
72
|
+
],
|
|
73
|
+
awaitPromise: true,
|
|
74
|
+
returnByValue: true
|
|
75
|
+
}, 12e4);
|
|
76
|
+
if (r.exceptionDetails || !r.result.value) throw new CliError("image-decode", `Could not decode this ${input.mimeType} image: ${(r.exceptionDetails?.exception?.description ?? r.exceptionDetails?.text ?? "no result").split("\n")[0]}`, "The file may be corrupt or in an unsupported format.");
|
|
77
|
+
const v = r.result.value;
|
|
78
|
+
return {
|
|
79
|
+
bytes: new Uint8Array(Buffer.from(v.b64, "base64")),
|
|
80
|
+
mimeType: v.mimeType,
|
|
81
|
+
width: v.width,
|
|
82
|
+
height: v.height,
|
|
83
|
+
srcWidth: v.srcWidth,
|
|
84
|
+
srcHeight: v.srcHeight,
|
|
85
|
+
hasAlpha: v.hasAlpha
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
codec,
|
|
90
|
+
close
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
async function withImageCodec(fn, opts = {}) {
|
|
94
|
+
const c = await openImageCodec(opts);
|
|
95
|
+
try {
|
|
96
|
+
return await fn(c.codec);
|
|
97
|
+
} finally {
|
|
98
|
+
await c.close();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export { openImageCodec, withImageCodec };
|