@auraindustry/aurajs 0.0.7 → 0.1.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/README.md +98 -2
- package/benchmarks/perf-thresholds.json +54 -0
- package/package.json +4 -7
- package/src/asset-pack.mjs +5 -1
- package/src/authored-project.mjs +1449 -0
- package/src/authored-runtime.mjs +2016 -0
- package/src/authoring/avatar-animation-graph.mjs +648 -0
- package/src/bin-integrity.mjs +272 -0
- package/src/build-contract/assets.mjs +130 -0
- package/src/build-contract/capabilities.mjs +116 -0
- package/src/build-contract/constants.mjs +6 -0
- package/src/build-contract/helpers.mjs +44 -0
- package/src/build-contract/web-templates.mjs +5993 -0
- package/src/build-contract.mjs +27 -2910
- package/src/bundler.mjs +188 -55
- package/src/cli.mjs +4825 -1512
- package/src/commands/project-authoring.mjs +434 -0
- package/src/config.mjs +27 -0
- package/src/conformance/cases/app-and-ui-runtime-cases.mjs +3309 -0
- package/src/conformance/cases/core-runtime-cases.mjs +1431 -0
- package/src/conformance/cases/index.mjs +11 -0
- package/src/conformance/cases/scene3d-and-media-cases.mjs +2094 -0
- package/src/conformance/cases/systems-and-gameplay-cases.mjs +1776 -0
- package/src/conformance/shared.mjs +27 -0
- package/src/conformance-runner.mjs +25 -13
- package/src/conformance.mjs +619 -4020
- package/src/cutscene.mjs +362 -5
- package/src/dev-cli-action.mjs +249 -0
- package/src/dev-cli-inspect.mjs +92 -0
- package/src/dev-cli-state.mjs +80 -0
- package/src/external-asset-cache.mjs +587 -0
- package/src/external-asset-policy.mjs +217 -0
- package/src/external-package-surface.mjs +206 -0
- package/src/game-action-runtime.mjs +869 -0
- package/src/game-state-runtime.mjs +206 -6
- package/src/headless-action.mjs +186 -0
- package/src/headless-test/runtime-animation.mjs +1173 -0
- package/src/headless-test/runtime-coordinator.mjs +1514 -0
- package/src/headless-test/runtime-primitives.mjs +320 -0
- package/src/headless-test/runtime-world.mjs +2253 -0
- package/src/headless-test.mjs +392 -4298
- package/src/host-binary.mjs +342 -14
- package/src/icon-discovery.mjs +64 -0
- package/src/make-catalog.mjs +109 -0
- package/src/make.mjs +197 -0
- package/src/package-integrity.mjs +586 -0
- package/src/perf-benchmark.mjs +353 -0
- package/src/postinstall.mjs +5 -5
- package/src/prefabs/index.mjs +34 -0
- package/src/prefabs/scene-serialization.mjs +184 -0
- package/src/project-importer.mjs +620 -0
- package/src/project-registry.mjs +24 -0
- package/src/publish-command.mjs +195 -0
- package/src/publish-env-example.mjs +83 -0
- package/src/publish-validation.mjs +708 -0
- package/src/retro/assets/compile.mjs +232 -0
- package/src/retro/backend-gba/authoring.mjs +1029 -0
- package/src/retro/backend-gba/rom.mjs +363 -0
- package/src/retro/backend-gbc/rom.mjs +85 -0
- package/src/retro/build.mjs +278 -0
- package/src/retro/cli/commands.mjs +292 -0
- package/src/retro/cli/templates.mjs +84 -0
- package/src/retro/diagnostics/catalog.mjs +110 -0
- package/src/retro/diagnostics/emit.mjs +72 -0
- package/src/retro/emulator/case-overlay.mjs +64 -0
- package/src/retro/emulator/discovery.mjs +158 -0
- package/src/retro/emulator/macos-case-overlay.swift +220 -0
- package/src/retro/emulator/profiles.mjs +146 -0
- package/src/retro/emulator/runner.mjs +289 -0
- package/src/retro/frontend/load-project.mjs +98 -0
- package/src/retro/index.mjs +30 -0
- package/src/retro/ir/build-ir.mjs +108 -0
- package/src/retro/runtime-gba/contract.mjs +151 -0
- package/src/retro/runtime-gbc/contract.mjs +117 -0
- package/src/retro/shared/span.mjs +26 -0
- package/src/retro/shared/targets.mjs +64 -0
- package/src/retro/validator/check-project.mjs +114 -0
- package/src/runtime-hotspot-audit.mjs +707 -0
- package/src/scaffold/config.mjs +1000 -0
- package/src/scaffold/fs.mjs +56 -0
- package/src/scaffold/layout.mjs +318 -0
- package/src/scaffold/project-docs.mjs +438 -0
- package/src/scaffold.mjs +93 -596
- package/src/scene-composition/index.mjs +326 -0
- package/src/scene-composition/runtime.mjs +751 -0
- package/src/self-hosted-assets.mjs +604 -0
- package/src/session-client.mjs +750 -0
- package/src/session-native-launcher.mjs +74 -0
- package/src/session-protocol.mjs +75 -0
- package/src/session-runtime.mjs +321 -0
- package/src/session-server.mjs +360 -0
- package/src/shader-kits/index.mjs +773 -0
- package/src/starter-content-registry.mjs +292 -0
- package/src/state-artifacts.mjs +662 -24
- package/src/state-dev-reload.mjs +99 -2
- package/src/terminal-ui.mjs +245 -0
- package/src/web-conformance.mjs +219 -0
- package/templates/create/2d/config/gameplay/shooter.config.js +26 -0
- package/templates/create/2d/content/gameplay/waves.json +26 -0
- package/templates/create/2d/content/registries/.gitkeep +1 -0
- package/templates/create/2d/docs/design/.gitkeep +1 -0
- package/templates/create/2d/docs/design/loop.md +5 -0
- package/templates/create/2d/prefabs/enemies.prefab.js +90 -0
- package/templates/create/2d/prefabs/enemy-basic.prefab.js +18 -0
- package/templates/create/2d/prefabs/player.prefab.js +36 -0
- package/templates/create/2d/prefabs/projectiles.prefab.js +35 -0
- package/templates/create/2d/scenes/boot.scene.js +12 -0
- package/templates/create/2d/scenes/gameplay.scene.js +230 -0
- package/templates/create/2d/scenes/menu.scene.js +9 -0
- package/templates/create/2d/src/main.js +6 -185
- package/templates/create/2d/src/runtime/app.js +49 -0
- package/templates/create/2d/src/runtime/capabilities.js +35 -0
- package/templates/create/2d/ui/hud.screen.js +40 -0
- package/templates/create/2d/ui/pause.screen.js +149 -0
- package/templates/create/2d/ui/settings.screen.js +347 -0
- package/templates/create/2d/ui/title.screen.js +13 -0
- package/templates/create/2d-adventure/aura.config.json +28 -0
- package/templates/create/2d-adventure/config/gameplay/adventure.config.js +14 -0
- package/templates/create/2d-adventure/content/gameplay/world.js +46 -0
- package/templates/create/2d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/2d-adventure/docs/design/loop.md +5 -0
- package/templates/create/2d-adventure/prefabs/player.prefab.js +54 -0
- package/templates/create/2d-adventure/prefabs/relic.prefab.js +38 -0
- package/templates/create/2d-adventure/prefabs/world.prefab.js +125 -0
- package/templates/create/2d-adventure/scenes/gameplay.scene.js +256 -0
- package/templates/create/2d-adventure/src/runtime/capabilities.js +34 -0
- package/templates/create/2d-adventure/ui/hud.screen.js +60 -0
- package/templates/create/2d-survivor/config/gameplay/survivor.config.js +33 -0
- package/templates/create/2d-survivor/content/gameplay/spawn-zones.json +29 -0
- package/templates/create/2d-survivor/content/registries/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/loop.md +5 -0
- package/templates/create/2d-survivor/prefabs/enemies.prefab.js +178 -0
- package/templates/create/2d-survivor/prefabs/enemy-swarm.prefab.js +18 -0
- package/templates/create/2d-survivor/prefabs/player.prefab.js +42 -0
- package/templates/create/2d-survivor/prefabs/projectiles.prefab.js +56 -0
- package/templates/create/2d-survivor/scenes/boot.scene.js +12 -0
- package/templates/create/2d-survivor/scenes/gameplay.scene.js +314 -0
- package/templates/create/2d-survivor/scenes/menu.scene.js +9 -0
- package/templates/create/2d-survivor/src/main.js +5 -332
- package/templates/create/2d-survivor/src/runtime/app.js +49 -0
- package/templates/create/2d-survivor/src/runtime/capabilities.js +35 -0
- package/templates/create/2d-survivor/ui/hud.screen.js +45 -0
- package/templates/create/2d-survivor/ui/title.screen.js +13 -0
- package/templates/create/3d/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d/content/gameplay/checkpoints.json +33 -0
- package/templates/create/3d/content/gameplay/course.js +40 -0
- package/templates/create/3d/content/registries/.gitkeep +1 -0
- package/templates/create/3d/docs/design/.gitkeep +1 -0
- package/templates/create/3d/docs/design/loop.md +5 -0
- package/templates/create/3d/prefabs/checkpoint.prefab.js +15 -0
- package/templates/create/3d/prefabs/player.prefab.js +204 -0
- package/templates/create/3d/prefabs/world.prefab.js +112 -0
- package/templates/create/3d/scenes/boot.scene.js +12 -0
- package/templates/create/3d/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d/scenes/gameplay.scene.js +292 -0
- package/templates/create/3d/src/main.js +6 -295
- package/templates/create/3d/src/runtime/app.js +49 -0
- package/templates/create/3d/src/runtime/capabilities.js +53 -0
- package/templates/create/3d/src/runtime/materials.js +34 -0
- package/templates/create/3d/src/runtime/state.js +39 -0
- package/templates/create/3d/ui/hud.screen.js +75 -0
- package/templates/create/3d/ui/pause.screen.js +166 -0
- package/templates/create/3d/ui/settings.screen.js +387 -0
- package/templates/create/3d-adventure/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-adventure/aura.config.json +28 -0
- package/templates/create/3d-adventure/config/gameplay/adventure.config.js +9 -0
- package/templates/create/3d-adventure/content/gameplay/course.js +62 -0
- package/templates/create/3d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/3d-adventure/docs/design/loop.md +5 -0
- package/templates/create/3d-adventure/prefabs/player.prefab.js +168 -0
- package/templates/create/3d-adventure/prefabs/relic.prefab.js +35 -0
- package/templates/create/3d-adventure/prefabs/world.prefab.js +119 -0
- package/templates/create/3d-adventure/scenes/gameplay.scene.js +358 -0
- package/templates/create/3d-adventure/src/runtime/capabilities.js +56 -0
- package/templates/create/3d-adventure/src/runtime/materials.js +39 -0
- package/templates/create/3d-adventure/src/runtime/state.js +31 -0
- package/templates/create/3d-adventure/ui/hud.screen.js +70 -0
- package/templates/create/3d-adventure/ui/pause.screen.js +437 -0
- package/templates/create/3d-collectathon/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-collectathon/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d-collectathon/content/gameplay/collectibles.json +26 -0
- package/templates/create/3d-collectathon/content/gameplay/course.js +46 -0
- package/templates/create/3d-collectathon/content/registries/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/loop.md +5 -0
- package/templates/create/3d-collectathon/prefabs/collectible.prefab.js +15 -0
- package/templates/create/3d-collectathon/prefabs/player.prefab.js +207 -0
- package/templates/create/3d-collectathon/prefabs/world.prefab.js +112 -0
- package/templates/create/3d-collectathon/scenes/boot.scene.js +12 -0
- package/templates/create/3d-collectathon/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d-collectathon/scenes/gameplay.scene.js +200 -0
- package/templates/create/3d-collectathon/src/main.js +5 -355
- package/templates/create/3d-collectathon/src/runtime/app.js +49 -0
- package/templates/create/3d-collectathon/src/runtime/capabilities.js +53 -0
- package/templates/create/3d-collectathon/src/runtime/materials.js +34 -0
- package/templates/create/3d-collectathon/src/runtime/state.js +27 -0
- package/templates/create/3d-collectathon/ui/hud.screen.js +66 -0
- package/templates/create/3d-collectathon/ui/pause.screen.js +13 -0
- package/templates/create/blank/config/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/registries/.gitkeep +1 -0
- package/templates/create/blank/docs/design/.gitkeep +1 -0
- package/templates/create/blank/docs/design/loop.md +5 -0
- package/templates/create/blank/prefabs/.gitkeep +1 -0
- package/templates/create/blank/scenes/.gitkeep +1 -0
- package/templates/create/blank/src/runtime/.gitkeep +1 -0
- package/templates/create/blank/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/audio/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/fonts/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/sprites/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/starter/README.md +11 -0
- package/templates/create/deckbuilder-2d/assets/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/aura.config.json +28 -0
- package/templates/create/deckbuilder-2d/config/gameplay/deckbuilder.config.js +26 -0
- package/templates/create/deckbuilder-2d/content/cards/guard.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/spark.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/cards/starter.deck.js +69 -0
- package/templates/create/deckbuilder-2d/content/cards/strike.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/survey.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.encounter.js +14 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.js +65 -0
- package/templates/create/deckbuilder-2d/content/enemies/training-automaton.enemy.js +48 -0
- package/templates/create/deckbuilder-2d/content/gameplay/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/content/registries/cards.registry.js +26 -0
- package/templates/create/deckbuilder-2d/content/registries/encounters.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/enemies.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/relics.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/relics/ember-charm.relic.js +18 -0
- package/templates/create/deckbuilder-2d/docs/design/loop.md +12 -0
- package/templates/create/deckbuilder-2d/prefabs/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/scenes/boot.scene.js +84 -0
- package/templates/create/deckbuilder-2d/scenes/gameplay.scene.js +641 -0
- package/templates/create/deckbuilder-2d/src/components/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/main.js +17 -0
- package/templates/create/deckbuilder-2d/src/runtime/capabilities.js +22 -0
- package/templates/create/deckbuilder-2d/src/shared/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/systems/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/tests/smoke/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/ui/hud.screen.js +80 -0
- package/templates/create/deckbuilder-2d/ui/pause.screen.js +146 -0
- package/templates/create/deckbuilder-2d/ui/settings.screen.js +342 -0
- package/templates/create/local-multiplayer/aura.config.json +40 -0
- package/templates/create/local-multiplayer/config/gameplay/local-multiplayer.config.js +26 -0
- package/templates/create/local-multiplayer/content/gameplay/room-layout.js +13 -0
- package/templates/create/local-multiplayer/content/registries/.gitkeep +1 -0
- package/templates/create/local-multiplayer/docs/design/loop.md +14 -0
- package/templates/create/local-multiplayer/prefabs/player.prefab.js +99 -0
- package/templates/create/local-multiplayer/scenes/boot.scene.js +12 -0
- package/templates/create/local-multiplayer/scenes/gameplay.scene.js +443 -0
- package/templates/create/local-multiplayer/src/main.js +17 -0
- package/templates/create/local-multiplayer/src/runtime/capabilities.js +28 -0
- package/templates/create/local-multiplayer/ui/hud.screen.js +60 -0
- package/templates/create/shared/src/runtime/project-inspector.js +105 -0
- package/templates/create/shared/src/runtime/scene-flow.js +290 -0
- package/templates/create/shared/src/runtime/screen-shell.js +222 -0
- package/templates/create/shared/src/runtime/ui-forms.js +209 -0
- package/templates/create/shared/src/runtime/ui-settings.js +237 -0
- package/templates/create/shared/src/runtime/ui-theme.js +352 -0
- package/templates/create/shared/src/starter-utils/adventure-objectives.js +102 -0
- package/templates/create/shared/src/starter-utils/animation-2d.js +337 -0
- package/templates/create/shared/src/starter-utils/avatar-3d.js +404 -0
- package/templates/create/shared/src/starter-utils/combat-feedback-2d.js +320 -0
- package/templates/create/shared/src/starter-utils/core.js +39 -3
- package/templates/create/shared/src/starter-utils/index.js +8 -2
- package/templates/create/shared/src/starter-utils/platformer-3d.js +34 -3
- package/templates/create/shared/src/starter-utils/triggers.js +662 -0
- package/templates/create/shared/src/starter-utils/tween-2d.js +615 -0
- package/templates/create/video-cutscene/assets/video/.gitkeep +0 -0
- package/templates/create/video-cutscene/aura.config.json +28 -0
- package/templates/create/video-cutscene/config/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/registries/.gitkeep +0 -0
- package/templates/create/video-cutscene/docs/design/loop.md +22 -0
- package/templates/create/video-cutscene/prefabs/.gitkeep +0 -0
- package/templates/create/video-cutscene/scenes/boot.scene.js +11 -0
- package/templates/create/video-cutscene/scenes/cutscene.scene.js +113 -0
- package/templates/create/video-cutscene/scenes/gameplay.scene.js +50 -0
- package/templates/create/video-cutscene/src/main.js +17 -0
- package/templates/create/video-cutscene/src/runtime/app.js +52 -0
- package/templates/create/video-cutscene/src/runtime/capabilities.js +35 -0
- package/templates/create/video-cutscene/src/runtime/state.js +13 -0
- package/templates/create/video-cutscene/ui/.gitkeep +0 -0
- package/templates/create-bin/play.js +1187 -0
- package/templates/make/README.md +46 -0
- package/templates/make/catalog.json +51 -0
- package/templates/make/component/files/{{MAKE_NAME}}.component.js +20 -0
- package/templates/make/component/manifest.json +9 -0
- package/templates/make/data/files/{{MAKE_NAME}}.json +14 -0
- package/templates/make/data/manifest.json +9 -0
- package/templates/make/material/files/{{MAKE_NAME}}.material.json +17 -0
- package/templates/make/material/manifest.json +9 -0
- package/templates/make/prefab/files/{{MAKE_NAME}}.prefab.js +20 -0
- package/templates/make/prefab/manifest.json +9 -0
- package/templates/make/scene/files/{{MAKE_NAME}}.scene.js +31 -0
- package/templates/make/scene/manifest.json +9 -0
- package/templates/make/shader/files/{{MAKE_NAME}}.shader.js +23 -0
- package/templates/make/shader/manifest.json +9 -0
- package/templates/make/system/files/{{MAKE_NAME}}.system.js +15 -0
- package/templates/make/system/manifest.json +9 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.js +16 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.json +23 -0
- package/templates/make/ui-screen/manifest.json +10 -0
- package/templates/make-starters/deckbuilder-2d/card/files/{{MAKE_NAME}}.card.js +22 -0
- package/templates/make-starters/deckbuilder-2d/card/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/catalog.json +34 -0
- package/templates/make-starters/deckbuilder-2d/encounter/files/{{MAKE_NAME}}.encounter.js +18 -0
- package/templates/make-starters/deckbuilder-2d/encounter/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/enemy/files/{{MAKE_NAME}}.enemy.js +28 -0
- package/templates/make-starters/deckbuilder-2d/enemy/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/relic/files/{{MAKE_NAME}}.relic.js +23 -0
- package/templates/make-starters/deckbuilder-2d/relic/manifest.json +9 -0
- package/templates/retro/platformer/README.md +10 -0
- package/templates/retro/platformer/assets/retro/assets.json +91 -0
- package/templates/retro/platformer/aura.config.json +7 -0
- package/templates/retro/platformer/package.json +5 -0
- package/templates/retro/platformer/src/main.js +40 -0
- package/templates/retro/puzzle-grid/README.md +10 -0
- package/templates/retro/puzzle-grid/assets/retro/assets.json +90 -0
- package/templates/retro/puzzle-grid/aura.config.json +7 -0
- package/templates/retro/puzzle-grid/package.json +5 -0
- package/templates/retro/puzzle-grid/src/main.js +29 -0
- package/templates/retro/tactics-grid/README.md +10 -0
- package/templates/retro/tactics-grid/assets/retro/assets.json +90 -0
- package/templates/retro/tactics-grid/aura.config.json +7 -0
- package/templates/retro/tactics-grid/package.json +5 -0
- package/templates/retro/tactics-grid/src/main.js +35 -0
- package/templates/retro/topdown-adventure/README.md +10 -0
- package/templates/retro/topdown-adventure/assets/retro/assets.json +95 -0
- package/templates/retro/topdown-adventure/aura.config.json +7 -0
- package/templates/retro/topdown-adventure/package.json +5 -0
- package/templates/retro/topdown-adventure/src/main.js +29 -0
- package/templates/skills/aurajs/SKILL.md +61 -5
|
@@ -0,0 +1,620 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cpSync,
|
|
3
|
+
existsSync,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
readdirSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
statSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from 'node:fs';
|
|
10
|
+
import { basename, dirname, extname, join, relative, resolve } from 'node:path';
|
|
11
|
+
|
|
12
|
+
import { scaffoldGame } from './scaffold.mjs';
|
|
13
|
+
|
|
14
|
+
const SOURCE_CODE_EXTENSIONS = new Set(['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx']);
|
|
15
|
+
const SCENE_EXTENSIONS = new Set(['.glb', '.gltf']);
|
|
16
|
+
const SKIP_DIR_NAMES = new Set([
|
|
17
|
+
'.aura',
|
|
18
|
+
'.git',
|
|
19
|
+
'.idea',
|
|
20
|
+
'.next',
|
|
21
|
+
'.turbo',
|
|
22
|
+
'.vscode',
|
|
23
|
+
'aurajs',
|
|
24
|
+
'build',
|
|
25
|
+
'coverage',
|
|
26
|
+
'dist',
|
|
27
|
+
'node_modules',
|
|
28
|
+
'out',
|
|
29
|
+
'tasks',
|
|
30
|
+
]);
|
|
31
|
+
const DEFAULT_UNSUPPORTED_FEATURES = Object.freeze([
|
|
32
|
+
{
|
|
33
|
+
code: 'manual_review_required',
|
|
34
|
+
message:
|
|
35
|
+
'Gameplay logic, DOM UI, runtime-generated geometry, physics integrations, and bespoke app flow still require manual AuraJS authoring.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
code: 'custom_shaders_not_migrated',
|
|
39
|
+
message:
|
|
40
|
+
'Custom GLSL, node-material graphs, and renderer/plugin mutations are not converted automatically in this MVP.',
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
export function parseFromArgs(args) {
|
|
45
|
+
const parsed = {
|
|
46
|
+
sourcePath: null,
|
|
47
|
+
sourceType: null,
|
|
48
|
+
outputPath: null,
|
|
49
|
+
projectName: null,
|
|
50
|
+
scenePath: null,
|
|
51
|
+
skipInstall: false,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
55
|
+
const arg = args[i];
|
|
56
|
+
if (arg === '--source') {
|
|
57
|
+
parsed.sourceType = readRequiredOptionValue(args, i, '--source').toLowerCase();
|
|
58
|
+
i += 1;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (arg.startsWith('--source=')) {
|
|
62
|
+
parsed.sourceType = arg.slice('--source='.length).toLowerCase();
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (arg === '--out') {
|
|
66
|
+
parsed.outputPath = readRequiredOptionValue(args, i, '--out');
|
|
67
|
+
i += 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (arg.startsWith('--out=')) {
|
|
71
|
+
parsed.outputPath = arg.slice('--out='.length);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (arg === '--name') {
|
|
75
|
+
parsed.projectName = readRequiredOptionValue(args, i, '--name');
|
|
76
|
+
i += 1;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (arg.startsWith('--name=')) {
|
|
80
|
+
parsed.projectName = arg.slice('--name='.length);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (arg === '--scene') {
|
|
84
|
+
parsed.scenePath = readRequiredOptionValue(args, i, '--scene');
|
|
85
|
+
i += 1;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (arg.startsWith('--scene=')) {
|
|
89
|
+
parsed.scenePath = arg.slice('--scene='.length);
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (arg === '--skip-install' || arg === '--no-install') {
|
|
93
|
+
parsed.skipInstall = true;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (arg.startsWith('--')) {
|
|
97
|
+
throw new Error(`Unknown option for from: ${arg}`);
|
|
98
|
+
}
|
|
99
|
+
if (parsed.sourcePath !== null) {
|
|
100
|
+
throw new Error('Unexpected extra argument for from. Usage: aura from <source-path> --source threejs [--out <path>] [--name <name>] [--scene <path>] [--skip-install]');
|
|
101
|
+
}
|
|
102
|
+
parsed.sourcePath = arg;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (!parsed.sourcePath) {
|
|
106
|
+
throw new Error('Missing source path. Usage: aura from <source-path> --source threejs [--out <path>] [--name <name>] [--scene <path>] [--skip-install]');
|
|
107
|
+
}
|
|
108
|
+
if (!parsed.sourceType) {
|
|
109
|
+
throw new Error('Missing --source. Currently supported: threejs.');
|
|
110
|
+
}
|
|
111
|
+
if (parsed.sourceType !== 'threejs') {
|
|
112
|
+
throw new Error(`Unsupported --source "${parsed.sourceType}". Currently supported: threejs.`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return parsed;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function detectThreeJsProject(options = {}) {
|
|
119
|
+
const sourceRoot = resolve(options.sourceRoot || process.cwd());
|
|
120
|
+
const packageJsonPath = resolve(sourceRoot, 'package.json');
|
|
121
|
+
const packageJson = readJsonIfPresent(packageJsonPath);
|
|
122
|
+
const dependencyNames = collectDependencyNames(packageJson);
|
|
123
|
+
const sceneCandidates = collectSceneCandidates(sourceRoot);
|
|
124
|
+
const sourceSignals = collectSourceSignals(sourceRoot);
|
|
125
|
+
const usesThreeDependency = dependencyNames.some((name) => (
|
|
126
|
+
name === 'three' || name.startsWith('@react-three/')
|
|
127
|
+
));
|
|
128
|
+
const usesPostprocessing = dependencyNames.some((name) => (
|
|
129
|
+
name === 'postprocessing' || name === 'three-stdlib' || name === '@react-three/postprocessing'
|
|
130
|
+
));
|
|
131
|
+
const detected = usesThreeDependency || sourceSignals.length > 0;
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
detected,
|
|
135
|
+
sourceRoot,
|
|
136
|
+
packageJsonPath: existsSync(packageJsonPath) ? packageJsonPath : null,
|
|
137
|
+
packageName: packageJson && typeof packageJson.name === 'string' ? packageJson.name : null,
|
|
138
|
+
dependencyNames,
|
|
139
|
+
sceneCandidates,
|
|
140
|
+
sourceSignals,
|
|
141
|
+
usesThreeDependency,
|
|
142
|
+
usesPostprocessing,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function importThreeJsProject(options = {}) {
|
|
147
|
+
const sourceRoot = resolve(options.sourceRoot || process.cwd());
|
|
148
|
+
const detection = detectThreeJsProject({ sourceRoot });
|
|
149
|
+
if (!detection.detected) {
|
|
150
|
+
throw new Error(`Could not verify a Three.js project at ${sourceRoot}. Add a package.json dependency on "three" or import "three" from source files before retrying.`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const requestedScene = normalizeOptionalPath(options.scenePath);
|
|
154
|
+
const selectedSceneSourcePath = selectSceneCandidate(detection.sceneCandidates, requestedScene);
|
|
155
|
+
const projectName = normalizeImportedProjectName(
|
|
156
|
+
options.projectName
|
|
157
|
+
|| detection.packageName
|
|
158
|
+
|| basename(sourceRoot),
|
|
159
|
+
);
|
|
160
|
+
const outputRoot = resolve(options.outputPath || join(sourceRoot, 'aurajs', projectName));
|
|
161
|
+
|
|
162
|
+
scaffoldGame({
|
|
163
|
+
name: projectName,
|
|
164
|
+
dest: outputRoot,
|
|
165
|
+
template: 'blank',
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const sceneCopy = copySelectedSceneIntoProject({
|
|
169
|
+
sourceRoot,
|
|
170
|
+
outputRoot,
|
|
171
|
+
selectedSceneSourcePath,
|
|
172
|
+
});
|
|
173
|
+
const report = buildImportReport({
|
|
174
|
+
detection,
|
|
175
|
+
outputRoot,
|
|
176
|
+
projectName,
|
|
177
|
+
requestedScene,
|
|
178
|
+
sceneCopy,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
writeGeneratedBootstrap(outputRoot, report);
|
|
182
|
+
writeCapabilitiesDeclaration(outputRoot, report);
|
|
183
|
+
|
|
184
|
+
const reportPath = resolve(outputRoot, 'migration-report.json');
|
|
185
|
+
writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`, 'utf8');
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
outputRoot,
|
|
189
|
+
projectName,
|
|
190
|
+
report,
|
|
191
|
+
reportPath,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function readRequiredOptionValue(args, index, flag) {
|
|
196
|
+
const value = args[index + 1];
|
|
197
|
+
if (!value || value.startsWith('--')) {
|
|
198
|
+
throw new Error(`Missing value for ${flag}.`);
|
|
199
|
+
}
|
|
200
|
+
return value;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function normalizeOptionalPath(value) {
|
|
204
|
+
if (typeof value !== 'string') return null;
|
|
205
|
+
const trimmed = value.trim();
|
|
206
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function normalizeImportedProjectName(value) {
|
|
210
|
+
const normalized = String(value || '')
|
|
211
|
+
.trim()
|
|
212
|
+
.toLowerCase()
|
|
213
|
+
.replace(/[^a-z0-9_-]+/g, '-')
|
|
214
|
+
.replace(/-+/g, '-')
|
|
215
|
+
.replace(/^[-_]+|[-_]+$/g, '');
|
|
216
|
+
return normalized || 'imported-threejs-project';
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function readJsonIfPresent(filePath) {
|
|
220
|
+
if (!existsSync(filePath)) return null;
|
|
221
|
+
try {
|
|
222
|
+
return JSON.parse(readFileSync(filePath, 'utf8'));
|
|
223
|
+
} catch {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function collectDependencyNames(packageJson) {
|
|
229
|
+
if (!packageJson || typeof packageJson !== 'object') return [];
|
|
230
|
+
const names = new Set();
|
|
231
|
+
for (const key of ['dependencies', 'devDependencies', 'peerDependencies']) {
|
|
232
|
+
const deps = packageJson[key];
|
|
233
|
+
if (!deps || typeof deps !== 'object' || Array.isArray(deps)) continue;
|
|
234
|
+
for (const name of Object.keys(deps)) {
|
|
235
|
+
names.add(String(name));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return [...names].sort((a, b) => a.localeCompare(b));
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function collectSceneCandidates(sourceRoot) {
|
|
242
|
+
const files = collectFiles(sourceRoot, {
|
|
243
|
+
shouldIncludeFile(filePath) {
|
|
244
|
+
return SCENE_EXTENSIONS.has(extname(filePath).toLowerCase());
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
return files
|
|
249
|
+
.map((filePath) => ({
|
|
250
|
+
sourcePath: filePath,
|
|
251
|
+
relativePath: toPosix(relative(sourceRoot, filePath)),
|
|
252
|
+
extension: extname(filePath).toLowerCase(),
|
|
253
|
+
}))
|
|
254
|
+
.sort((a, b) => {
|
|
255
|
+
const extScore = sceneExtensionScore(a.extension) - sceneExtensionScore(b.extension);
|
|
256
|
+
if (extScore !== 0) return extScore;
|
|
257
|
+
return a.relativePath.localeCompare(b.relativePath);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function sceneExtensionScore(extension) {
|
|
262
|
+
if (extension === '.glb') return 0;
|
|
263
|
+
if (extension === '.gltf') return 1;
|
|
264
|
+
return 10;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function collectSourceSignals(sourceRoot) {
|
|
268
|
+
const files = collectFiles(sourceRoot, {
|
|
269
|
+
shouldIncludeFile(filePath) {
|
|
270
|
+
return SOURCE_CODE_EXTENSIONS.has(extname(filePath).toLowerCase());
|
|
271
|
+
},
|
|
272
|
+
maxFiles: 240,
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
const results = [];
|
|
276
|
+
for (const filePath of files) {
|
|
277
|
+
let content = '';
|
|
278
|
+
try {
|
|
279
|
+
content = readFileSync(filePath, 'utf8');
|
|
280
|
+
} catch {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
if (
|
|
284
|
+
!/['"]three['"]|@react-three\/(fiber|drei|postprocessing)/.test(content)
|
|
285
|
+
&& !/OrbitControls|EffectComposer|WebGLRenderer|Scene\(/.test(content)
|
|
286
|
+
) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
results.push({
|
|
290
|
+
file: toPosix(relative(sourceRoot, filePath)),
|
|
291
|
+
reason: 'threejs_source_signal_detected',
|
|
292
|
+
});
|
|
293
|
+
if (results.length >= 24) break;
|
|
294
|
+
}
|
|
295
|
+
return results;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function collectFiles(rootPath, options = {}) {
|
|
299
|
+
const output = [];
|
|
300
|
+
const maxFiles = Number.isInteger(options.maxFiles) && options.maxFiles > 0
|
|
301
|
+
? options.maxFiles
|
|
302
|
+
: Number.POSITIVE_INFINITY;
|
|
303
|
+
walk(rootPath);
|
|
304
|
+
return output;
|
|
305
|
+
|
|
306
|
+
function walk(dirPath) {
|
|
307
|
+
if (output.length >= maxFiles) return;
|
|
308
|
+
const names = safeReadDir(dirPath);
|
|
309
|
+
for (const name of names) {
|
|
310
|
+
if (output.length >= maxFiles) return;
|
|
311
|
+
const fullPath = resolve(dirPath, name);
|
|
312
|
+
let stat = null;
|
|
313
|
+
try {
|
|
314
|
+
stat = statSync(fullPath);
|
|
315
|
+
} catch {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
if (stat.isDirectory()) {
|
|
319
|
+
if (SKIP_DIR_NAMES.has(name)) continue;
|
|
320
|
+
walk(fullPath);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (typeof options.shouldIncludeFile === 'function' && !options.shouldIncludeFile(fullPath)) {
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
output.push(fullPath);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function safeReadDir(dirPath) {
|
|
332
|
+
try {
|
|
333
|
+
return readdirSync(dirPath).sort((a, b) => a.localeCompare(b));
|
|
334
|
+
} catch {
|
|
335
|
+
return [];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function selectSceneCandidate(sceneCandidates, requestedScene) {
|
|
340
|
+
if (requestedScene) {
|
|
341
|
+
const normalizedRequested = toPosix(requestedScene.replace(/^\.?\//, ''));
|
|
342
|
+
const exact = sceneCandidates.find((entry) => entry.relativePath === normalizedRequested);
|
|
343
|
+
if (!exact) {
|
|
344
|
+
throw new Error(`Requested --scene "${requestedScene}" was not found under the source project.`);
|
|
345
|
+
}
|
|
346
|
+
return exact.sourcePath;
|
|
347
|
+
}
|
|
348
|
+
return sceneCandidates.length > 0 ? sceneCandidates[0].sourcePath : null;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function copySelectedSceneIntoProject({ sourceRoot, outputRoot, selectedSceneSourcePath }) {
|
|
352
|
+
if (!selectedSceneSourcePath) {
|
|
353
|
+
return {
|
|
354
|
+
sourceScenePath: null,
|
|
355
|
+
outputScenePath: null,
|
|
356
|
+
copiedRoots: [],
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const extension = extname(selectedSceneSourcePath).toLowerCase();
|
|
361
|
+
const importedRoot = resolve(outputRoot, 'assets', 'imported');
|
|
362
|
+
mkdirSync(importedRoot, { recursive: true });
|
|
363
|
+
|
|
364
|
+
if (extension === '.glb') {
|
|
365
|
+
const targetPath = resolve(importedRoot, basename(selectedSceneSourcePath));
|
|
366
|
+
cpSync(selectedSceneSourcePath, targetPath);
|
|
367
|
+
return {
|
|
368
|
+
sourceScenePath: toPosix(relative(sourceRoot, selectedSceneSourcePath)),
|
|
369
|
+
outputScenePath: toPosix(relative(outputRoot, targetPath)),
|
|
370
|
+
copiedRoots: [toPosix(relative(outputRoot, targetPath))],
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const sourceDir = dirname(selectedSceneSourcePath);
|
|
375
|
+
const dirLabel = normalizeImportedProjectName(basename(sourceDir) || 'scene-assets');
|
|
376
|
+
const targetDir = resolve(importedRoot, dirLabel);
|
|
377
|
+
cpSync(sourceDir, targetDir, { recursive: true });
|
|
378
|
+
const targetScenePath = resolve(targetDir, basename(selectedSceneSourcePath));
|
|
379
|
+
return {
|
|
380
|
+
sourceScenePath: toPosix(relative(sourceRoot, selectedSceneSourcePath)),
|
|
381
|
+
outputScenePath: toPosix(relative(outputRoot, targetScenePath)),
|
|
382
|
+
copiedRoots: [toPosix(relative(outputRoot, targetDir))],
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
function buildImportReport({ detection, outputRoot, projectName, requestedScene, sceneCopy }) {
|
|
387
|
+
const unsupportedFeatures = [...DEFAULT_UNSUPPORTED_FEATURES];
|
|
388
|
+
if (detection.dependencyNames.includes('@react-three/fiber')) {
|
|
389
|
+
unsupportedFeatures.push({
|
|
390
|
+
code: 'react_three_fiber_manual_rewrite_required',
|
|
391
|
+
message: 'React Three Fiber components are not migrated automatically; convert them into authored AuraJS runtime modules manually.',
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
if (detection.usesPostprocessing) {
|
|
395
|
+
unsupportedFeatures.push({
|
|
396
|
+
code: 'postprocessing_manual_rewrite_required',
|
|
397
|
+
message: 'EffectComposer and postprocessing stacks require a manual AuraJS draw3d/postfx rewrite.',
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
if (!sceneCopy.outputScenePath) {
|
|
401
|
+
unsupportedFeatures.push({
|
|
402
|
+
code: 'scene_export_required',
|
|
403
|
+
message: 'No glTF/GLB scene was discovered. Export a scene asset from the Three.js project and rerun the importer with --scene if needed.',
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return {
|
|
408
|
+
schema: 'aurajs.threejs-import-report.v1',
|
|
409
|
+
sourceType: 'threejs',
|
|
410
|
+
projectName,
|
|
411
|
+
sourceRoot: detection.sourceRoot,
|
|
412
|
+
outputRoot,
|
|
413
|
+
detection: {
|
|
414
|
+
detected: detection.detected,
|
|
415
|
+
packageJsonPath: detection.packageJsonPath,
|
|
416
|
+
dependencyNames: detection.dependencyNames,
|
|
417
|
+
usesThreeDependency: detection.usesThreeDependency,
|
|
418
|
+
sourceSignals: detection.sourceSignals,
|
|
419
|
+
},
|
|
420
|
+
sceneImport: {
|
|
421
|
+
requestedScene,
|
|
422
|
+
candidates: detection.sceneCandidates.map((entry) => entry.relativePath),
|
|
423
|
+
selectedSourceScene: sceneCopy.sourceScenePath,
|
|
424
|
+
outputScenePath: sceneCopy.outputScenePath,
|
|
425
|
+
copiedRoots: sceneCopy.copiedRoots,
|
|
426
|
+
reasonCode: sceneCopy.outputScenePath
|
|
427
|
+
? 'threejs_scene_selected'
|
|
428
|
+
: 'threejs_scene_missing',
|
|
429
|
+
},
|
|
430
|
+
unsupportedFeatures,
|
|
431
|
+
nextSteps: sceneCopy.outputScenePath
|
|
432
|
+
? [
|
|
433
|
+
'Run `npm install` inside the generated AuraJS project if dependencies were not installed.',
|
|
434
|
+
'Run `npm run dev` and verify the imported scene loads through the generated bootstrap.',
|
|
435
|
+
'Rewrite gameplay, UI, and any renderer-specific logic using AuraJS runtime surfaces.',
|
|
436
|
+
]
|
|
437
|
+
: [
|
|
438
|
+
'Export a .glb or .gltf scene from the source project.',
|
|
439
|
+
'Rerun the importer with `--scene <relative-path>` once the scene asset exists.',
|
|
440
|
+
'Port gameplay and UI manually after the scene path is stable.',
|
|
441
|
+
],
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function writeGeneratedBootstrap(outputRoot, report) {
|
|
446
|
+
const scenePath = report.sceneImport.outputScenePath;
|
|
447
|
+
const mainSource = buildGeneratedMainSource({
|
|
448
|
+
projectName: report.projectName,
|
|
449
|
+
scenePath,
|
|
450
|
+
});
|
|
451
|
+
writeFileSync(resolve(outputRoot, 'src', 'main.js'), mainSource, 'utf8');
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
function writeCapabilitiesDeclaration(outputRoot, report) {
|
|
455
|
+
const capabilitiesPath = resolve(outputRoot, 'aura.capabilities.json');
|
|
456
|
+
const capabilities = readJsonIfPresent(capabilitiesPath) || {};
|
|
457
|
+
const requiredApis = new Set(Array.isArray(capabilities.requiredApis) ? capabilities.requiredApis : []);
|
|
458
|
+
for (const apiName of [
|
|
459
|
+
'aura.draw2d.clear',
|
|
460
|
+
'aura.draw2d.text',
|
|
461
|
+
'aura.draw3d.clear3d',
|
|
462
|
+
'aura.camera3d.lookAt',
|
|
463
|
+
'aura.camera3d.perspective',
|
|
464
|
+
'aura.camera3d.setPosition',
|
|
465
|
+
'aura.light.ambient',
|
|
466
|
+
'aura.light.directional',
|
|
467
|
+
'aura.rgb',
|
|
468
|
+
'aura.rgba',
|
|
469
|
+
]) {
|
|
470
|
+
requiredApis.add(apiName);
|
|
471
|
+
}
|
|
472
|
+
if (report.sceneImport.outputScenePath) {
|
|
473
|
+
for (const apiName of [
|
|
474
|
+
'aura.scene3d.getImportedScene',
|
|
475
|
+
'aura.scene3d.loadGltfScene',
|
|
476
|
+
'aura.scene3d.submitRenderBindings',
|
|
477
|
+
'aura.scene3d.updateClips',
|
|
478
|
+
]) {
|
|
479
|
+
requiredApis.add(apiName);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
capabilities.schema = capabilities.schema || 'aurajs.create-capabilities.v1';
|
|
484
|
+
capabilities.template = capabilities.template || 'blank';
|
|
485
|
+
capabilities.summary = 'Generated from a Three.js project by the AuraJS importer.';
|
|
486
|
+
capabilities.requiredApis = [...requiredApis].sort((a, b) => a.localeCompare(b));
|
|
487
|
+
capabilities.notes = [
|
|
488
|
+
'Generated by `aura from --source threejs`.',
|
|
489
|
+
'Keep this file aligned with generated bootstrap changes and later manual migration work.',
|
|
490
|
+
];
|
|
491
|
+
|
|
492
|
+
writeFileSync(capabilitiesPath, `${JSON.stringify(capabilities, null, 2)}\n`, 'utf8');
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function buildGeneratedMainSource({ projectName, scenePath }) {
|
|
496
|
+
const sceneCandidates = scenePath ? [scenePath] : [];
|
|
497
|
+
return `// ${projectName} — generated by \`aura from --source threejs\`
|
|
498
|
+
|
|
499
|
+
const IMPORTED_SCENE_CANDIDATES = Object.freeze(${JSON.stringify(sceneCandidates, null, 2)});
|
|
500
|
+
|
|
501
|
+
const state = {
|
|
502
|
+
loadedScenePath: null,
|
|
503
|
+
importId: 0,
|
|
504
|
+
importSummary: '',
|
|
505
|
+
error: '',
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
function hasMethod(obj, method) {
|
|
509
|
+
return Boolean(obj) && typeof obj[method] === 'function';
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function rgba(r, g, b, a = 1) {
|
|
513
|
+
return { r, g, b, a };
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function tryLoadImportedScene() {
|
|
517
|
+
if (!hasMethod(aura.scene3d, 'loadGltfScene')) {
|
|
518
|
+
state.error = 'aura.scene3d.loadGltfScene is unavailable in this runtime.';
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
for (const candidate of IMPORTED_SCENE_CANDIDATES) {
|
|
523
|
+
try {
|
|
524
|
+
const loaded = aura.scene3d.loadGltfScene(candidate, {
|
|
525
|
+
bindRenderNodes: true,
|
|
526
|
+
visible: true,
|
|
527
|
+
cull: false,
|
|
528
|
+
});
|
|
529
|
+
const record = Number.isInteger(loaded)
|
|
530
|
+
? { importId: loaded }
|
|
531
|
+
: loaded;
|
|
532
|
+
const importId = Number(record && record.importId ? record.importId : loaded);
|
|
533
|
+
if (!Number.isInteger(importId) || importId <= 0) {
|
|
534
|
+
continue;
|
|
535
|
+
}
|
|
536
|
+
const summary = hasMethod(aura.scene3d, 'getImportedScene')
|
|
537
|
+
? aura.scene3d.getImportedScene(importId)
|
|
538
|
+
: null;
|
|
539
|
+
state.loadedScenePath = candidate;
|
|
540
|
+
state.importId = importId;
|
|
541
|
+
state.importSummary = summary && typeof summary === 'object'
|
|
542
|
+
? \`\${Number(summary.nodeCount || 0)} nodes / \${Number(summary.primitiveCount || 0)} prims / \${Number(summary.materialCount || 0)} mats\`
|
|
543
|
+
: 'scene import loaded';
|
|
544
|
+
return true;
|
|
545
|
+
} catch (error) {
|
|
546
|
+
state.error = String(error && error.message ? error.message : error);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if (!state.error && IMPORTED_SCENE_CANDIDATES.length === 0) {
|
|
551
|
+
state.error = 'No glTF/GLB scene was selected during import.';
|
|
552
|
+
}
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
aura.setup = function () {
|
|
557
|
+
if (hasMethod(aura.camera3d, 'perspective')) {
|
|
558
|
+
aura.camera3d.perspective(58, 0.1, 120);
|
|
559
|
+
}
|
|
560
|
+
if (hasMethod(aura.camera3d, 'setPosition')) {
|
|
561
|
+
aura.camera3d.setPosition(0, 2.8, 6.8);
|
|
562
|
+
}
|
|
563
|
+
if (hasMethod(aura.camera3d, 'lookAt')) {
|
|
564
|
+
aura.camera3d.lookAt(0, 1.1, 0);
|
|
565
|
+
}
|
|
566
|
+
if (hasMethod(aura.light, 'ambient')) {
|
|
567
|
+
aura.light.ambient(rgba(1, 1, 1, 1), 0.32);
|
|
568
|
+
}
|
|
569
|
+
if (hasMethod(aura.light, 'directional')) {
|
|
570
|
+
aura.light.directional({ x: -0.55, y: -1, z: -0.4 }, rgba(1, 0.97, 0.92, 1), 1.1);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
tryLoadImportedScene();
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
aura.update = function (dt) {
|
|
577
|
+
if (hasMethod(aura.scene3d, 'updateClips')) {
|
|
578
|
+
aura.scene3d.updateClips(Number.isFinite(dt) ? dt : 0);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
aura.draw = function () {
|
|
583
|
+
if (hasMethod(aura.draw3d, 'clear3d')) {
|
|
584
|
+
aura.draw3d.clear3d(rgba(0.035, 0.04, 0.055, 1));
|
|
585
|
+
} else if (hasMethod(aura.draw2d, 'clear')) {
|
|
586
|
+
aura.draw2d.clear(rgba(0.035, 0.04, 0.055, 1));
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
if (state.importId > 0 && hasMethod(aura.scene3d, 'submitRenderBindings')) {
|
|
590
|
+
aura.scene3d.submitRenderBindings();
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
if (!hasMethod(aura.draw2d, 'text') || typeof aura.rgb !== 'function') {
|
|
594
|
+
return;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
aura.draw2d.text('${projectName} — imported from Three.js', 24, 24, {
|
|
598
|
+
size: 20,
|
|
599
|
+
color: aura.rgb(0.96, 0.97, 1),
|
|
600
|
+
});
|
|
601
|
+
aura.draw2d.text(
|
|
602
|
+
state.loadedScenePath
|
|
603
|
+
? \`scene: \${state.loadedScenePath}\`
|
|
604
|
+
: 'scene: none detected',
|
|
605
|
+
24,
|
|
606
|
+
52,
|
|
607
|
+
{ size: 14, color: aura.rgb(0.82, 0.9, 0.98) },
|
|
608
|
+
);
|
|
609
|
+
aura.draw2d.text(
|
|
610
|
+
state.importSummary || state.error || 'manual gameplay migration still required',
|
|
611
|
+
24,
|
|
612
|
+
74,
|
|
613
|
+
{ size: 14, color: aura.rgb(0.88, 0.9, 0.84) },
|
|
614
|
+
);
|
|
615
|
+
};\n`;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function toPosix(value) {
|
|
619
|
+
return String(value || '').split('\\\\').join('/');
|
|
620
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export {
|
|
2
|
+
CANONICAL_PREFAB_ROLES,
|
|
3
|
+
PROJECT_CHECK_SCHEMA,
|
|
4
|
+
PROJECT_CONTINUITY_SCHEMA,
|
|
5
|
+
PROJECT_EXPLAIN_SCHEMA,
|
|
6
|
+
PROJECT_REGISTRY_RELATIVE_PATH,
|
|
7
|
+
PROJECT_REGISTRY_SCHEMA,
|
|
8
|
+
SCENE_REGISTRY_RELATIVE_PATH,
|
|
9
|
+
assertAuraProjectRoot,
|
|
10
|
+
buildStarterRegistryEntries,
|
|
11
|
+
checkProject,
|
|
12
|
+
createScaffoldProjectRegistryModel,
|
|
13
|
+
createStarterProjectRegistry,
|
|
14
|
+
explainProject,
|
|
15
|
+
getProjectRegistryRelativePath,
|
|
16
|
+
getSceneRegistryRelativePath,
|
|
17
|
+
inferPrefabRole,
|
|
18
|
+
isSelfWiringMakeKind,
|
|
19
|
+
normalizePrefabRole,
|
|
20
|
+
registerGeneratedProjectFiles,
|
|
21
|
+
runProjectCheck,
|
|
22
|
+
runProjectExplain,
|
|
23
|
+
writeProjectRegistryFiles,
|
|
24
|
+
} from './authored-project.mjs';
|