@craft_eco/craft-mcp 0.1.18 → 0.1.22
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 +45 -8
- package/bin/craft-mcp.mjs +14 -1
- package/dist-server/core/connector-auth.mjs +3 -3
- package/dist-server/game-workflow/asset-formats.mjs +25 -64
- package/dist-server/game-workflow/asset-import.mjs +83 -67
- package/dist-server/game-workflow/assets.mjs +81 -9
- package/dist-server/game-workflow/capture-worker.mjs +1 -1
- package/dist-server/game-workflow/check.mjs +1 -1
- package/dist-server/game-workflow/draft-archive.mjs +53 -53
- package/dist-server/game-workflow/draft-bindings.mjs +35 -35
- package/dist-server/game-workflow/draft-uploads.mjs +225 -207
- package/dist-server/game-workflow/engines.mjs +2 -2
- package/dist-server/game-workflow/library-assets.mjs +16 -5
- package/dist-server/game-workflow/library-candidates.mjs +2 -1
- package/dist-server/game-workflow/library-catalog.mjs +2 -2
- package/dist-server/game-workflow/publication-materials.mjs +92 -67
- package/dist-server/game-workflow/publications.mjs +164 -148
- package/dist-server/game-workflow/publish-capture-worker.mjs +57 -57
- package/dist-server/game-workflow/publish-capture.mjs +75 -75
- package/dist-server/game-workflow/resource-catalog.mjs +16 -13
- package/dist-server/mcp/control-panel.html +2 -2
- package/dist-server/mcp/control-panel.mjs +59 -59
- package/dist-server/mcp/publication-page.html +86 -86
- package/dist-server/mcp/publication-page.mjs +375 -347
- package/dist-server/mcp/publication-preview.mjs +62 -48
- package/dist-server/mcp/publication-tools.mjs +22 -22
- package/dist-server/mcp/publish-panel.mjs +205 -191
- package/dist-server/mcp/server.mjs +312 -312
- package/dist-server/upstream/craft-aigc.mjs +182 -169
- package/dist-server/upstream/library-url.mjs +3 -5
- package/dist-server/upstream/publication-transport.mjs +101 -81
- package/dist-server/upstream/resource-path.mjs +17 -0
- package/package.json +2 -2
- package/resources/craft-game-maker/SKILL.md +71 -69
- package/resources/craft-game-maker/js.md +6 -5
- package/resources/craft-game-maker/js3d.md +6 -5
- package/resources/game_visual_qa.mjs +9 -3
- package/resources/js/context/.role/AGENTS_DESIGN.md +9 -0
- package/resources/js/context/AGENTS.md +112 -0
- package/resources/js/context/agents/aigc-asset.md +168 -0
- package/resources/js/context/hooks/hooks.json +14 -20
- package/resources/js/context/knowledge/AigcEnabled.md +49 -41
- package/resources/js/context/knowledge/AigcWiring.md +200 -200
- package/resources/js/context/knowledge/AssetUrl.md +24 -24
- package/resources/js/context/knowledge/FrontendComponents.md +17 -23
- package/resources/js/context/knowledge/Lifecycle.md +32 -27
- package/resources/js/context/knowledge/MobileAdaptation.md +73 -0
- package/resources/js/context/knowledge/MobileAdapted.md +36 -0
- package/resources/js/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -114
- package/resources/js/context/knowledge/Multiplayer/OverviewKnowledge.md +115 -115
- package/resources/js/context/knowledge/Multiplayer/StateSyncKnowledge.md +392 -392
- package/resources/js/context/knowledge/PlatformServices.md +190 -184
- package/resources/js/context/knowledge/ProjectDisplayConfig.md +35 -0
- package/resources/js/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -242
- package/resources/js/context/knowledge/Ui.md +11 -11
- package/resources/js/context/knowledge/UiEditorCompat.md +21 -21
- package/resources/js/context/rules/MultiplayerCapability.md +23 -23
- package/resources/js/context/rules/MultiplayerRoomEntryUX.md +63 -63
- package/resources/js/context/rules/PlatformBoundaryModules.md +44 -43
- package/resources/js/context/rules/preview_ready.md +8 -0
- package/resources/js/context/skills/aigc-generate/SKILL.md +149 -301
- package/resources/js/context/skills/aigc-generate/knowledge/audio.md +39 -39
- package/resources/js/context/skills/aigc-generate/knowledge/batch-replace.md +26 -14
- package/resources/js/context/skills/aigc-generate/knowledge/character2d.md +132 -129
- package/resources/js/context/skills/aigc-generate/knowledge/non-stepwise-aigc.md +53 -54
- package/resources/js/context/skills/aigc-generate/knowledge/texture-prop.md +52 -50
- package/resources/js/context/skills/aigc-generate/knowledge/texture-scene.md +191 -201
- package/resources/js/context/skills/aigc-generate/knowledge/texture-ui.md +55 -53
- package/resources/js/context/skills/asset-search/SKILL.md +69 -73
- package/resources/js/context/skills/asset-search/scripts/asset_display.mjs +62 -62
- package/resources/js/context/skills/asset-search/scripts/config.json +5 -5
- package/resources/js/context/skills/asset-search/scripts/provided_assets.mjs +125 -125
- package/resources/js/context/skills/asset-search/scripts/search.mjs +760 -749
- package/resources/js/context/skills/asset-search/scripts/sprite_source_materializer.mjs +657 -723
- package/resources/js/context/skills/asset-search/strategies/anim2d.md +42 -0
- package/resources/js/context/skills/asset-search/strategies/audio.md +34 -34
- package/resources/js/context/skills/asset-search/strategies/effect2d.md +31 -31
- package/resources/js/context/skills/asset-search/strategies/texture-prop.md +22 -22
- package/resources/js/context/skills/asset-search/strategies/ui-common.md +40 -40
- package/resources/js/context/skills/asset-search/strategies/ui-style.md +28 -28
- package/resources/js/context/skills/export-config/SKILL.md +28 -20
- package/resources/js/context/skills/export-config/assets/tooling/cli.mjs +20 -0
- package/resources/js/context/skills/{lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform → export-config/assets/tooling}/config.d.mts +19 -19
- package/resources/js/context/skills/{lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform → export-config/assets/tooling}/config.mjs +1 -1
- package/resources/js/context/skills/export-config/assets/tooling/project.d.mts +6 -0
- package/resources/js/context/skills/export-config/assets/tooling/project.mjs +77 -0
- package/resources/js/context/skills/export-config/assets/tooling/vite.d.mts +2 -0
- package/resources/js/context/skills/export-config/assets/tooling/vite.mjs +34 -0
- package/resources/js/context/skills/export-config/scripts/assert-asset-wiring.mjs +72 -72
- package/resources/js/context/skills/export-config/scripts/export-config.mjs +46 -43
- package/resources/js/context/skills/export-config/scripts/install.mjs +89 -0
- package/resources/js/context/skills/export-config/scripts/panel-resource-path.mjs +106 -106
- package/resources/js/context/skills/export-config/scripts/sync-asset-controls.mjs +352 -351
- package/resources/js/context/skills/export-config/scripts/translate-asset-titles.mjs +161 -163
- package/resources/js/context/skills/lightgame-runtime-adapt/SKILL.md +93 -92
- package/resources/js/context/skills/lightgame-runtime-adapt/project/game-runtime.json +7 -7
- package/resources/js/context/skills/lightgame-runtime-adapt/project/package.json +22 -22
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +208 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +37 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform-capture-video.mjs +227 -227
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform-service.d.mts +31 -25
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +272 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform.d.mts +79 -79
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/platform/platform.mjs +29 -29
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/release.json +22 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/cli.mjs +16 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.d.mts +4 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/project.mjs +50 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +3 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.1.0/tooling/vite.mjs +72 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/assets.d.mts +24 -24
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/assets.mjs +2 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/astc.d.mts +10 -10
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/{1.0.0 → 1.1.0}/tools/astc.mjs +1 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/config-export.mjs +37 -32
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/refresh-runtime.mjs +50 -50
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/cli.mjs +20 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.d.mts +19 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/config.mjs +1 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/installed.json +6 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.d.mts +6 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/project.mjs +77 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.d.mts +2 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/scripts/skill-modules/export-config/vite.mjs +34 -0
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/ui-stage.ts +156 -121
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/display/viewport.ts +249 -254
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/main.ts +87 -99
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/platform.ts +2 -14
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/screenUi.ts +185 -172
- package/resources/js/context/skills/lightgame-runtime-adapt/project/src/style.css +294 -165
- package/resources/js/context/skills/lightgame-runtime-adapt/project/tsconfig.json +20 -20
- package/resources/js/context/skills/lightgame-runtime-adapt/project/vite.config.ts +5 -4
- package/resources/js/context/skills/lightgame-runtime-adapt/scripts/install-template.mjs +159 -109
- package/resources/js/context/skills/mobile-adaptation/SKILL.md +277 -260
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +50 -50
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +862 -881
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -92
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +254 -0
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -245
- package/resources/js/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +135 -134
- package/resources/js/context/skills/mobile-adaptation/references/input-config.md +342 -311
- package/resources/js/context/skills/mobile-adaptation/references/verification.md +140 -106
- package/resources/js/context/skills/mobile-adaptation/references/web-audio.md +11 -0
- package/resources/js/context/skills/mobile-compat-qa/SKILL.md +53 -0
- package/resources/js/context/skills/mobile-compat-qa/references/startup-diagnosis.md +23 -0
- package/resources/js/context/skills/mobile-compat-qa/references/web-lifecycle.md +20 -0
- package/resources/js/context/skills/mobile-compat-qa/references/web-performance.md +19 -0
- package/resources/js/context/skills/optimization-suggestions/SKILL.md +89 -89
- package/resources/js/context/skills/platform-services/SKILL.md +101 -94
- package/resources/js/context/skills/platform-services/assets/modules/MultiplayerManager.ts +465 -783
- package/resources/js/context/skills/platform-services/assets/modules/eventBus.ts +57 -57
- package/resources/js/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js/context/skills/platform-services/assets/modules/identity/qq-session.mjs +208 -0
- package/resources/js/context/skills/platform-services/assets/modules/identity/shared.mjs +37 -0
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -39
- package/resources/js/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -1
- package/resources/js/context/skills/platform-services/assets/modules/log.ts +35 -35
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +61 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +52 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +30 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +89 -0
- package/resources/js/context/skills/platform-services/assets/modules/multiplayer/types.ts +47 -0
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.d.mts +31 -25
- package/resources/js/context/skills/platform-services/assets/modules/platform-service.mjs +272 -1
- package/resources/js/context/skills/platform-services/assets/modules/save.d.mts +49 -49
- package/resources/js/context/skills/platform-services/assets/modules/save.mjs +1 -1
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -7
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -264
- package/resources/js/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -39
- package/resources/js/context/skills/platform-services/references/SERVER_GUIDE.md +139 -139
- package/resources/js/context/skills/platform-services/references/api_reference.md +18 -18
- package/resources/js/context/skills/platform-services/references/leaderboard_playbook.md +96 -0
- package/resources/js/context/skills/platform-services/scripts/install.mjs +148 -134
- package/resources/js/context/skills/resolution-adaptation/SKILL.md +47 -202
- package/resources/js/context/skills/resolution-adaptation/assets/display/ui-stage.ts +156 -121
- package/resources/js/context/skills/resolution-adaptation/assets/display/viewport.ts +249 -254
- package/resources/js/context/skills/resolution-adaptation/assets/example/main.ts +98 -98
- package/resources/js/context/skills/resolution-adaptation/assets/example/ui-tokens.css +200 -200
- package/resources/js/context/skills/resolution-adaptation/references/audit.md +31 -0
- package/resources/js/context/skills/resolution-adaptation/references/device-safe-area.md +40 -0
- package/resources/js/context/skills/resolution-adaptation/references/game-ui-occlusion.md +18 -0
- package/resources/js/context/skills/resolution-adaptation/references/layout-rules.md +15 -134
- package/resources/js/context/skills/resolution-adaptation/references/troubleshooting.md +34 -0
- package/resources/js/context/skills/resolution-adaptation/references/viewport-api.md +38 -119
- package/resources/js/context/skills/resolution-adaptation/references/world-resize.md +55 -0
- package/resources/js/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +448 -338
- package/resources/js/context/skills/scene-editor-compat/SKILL.md +94 -94
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.assets.json +13 -13
- package/resources/js/context/skills/scene-editor-compat/assets/example/localcraft.scene-editor.json +6 -6
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/game/sceneAdapter.ts +25 -25
- package/resources/js/context/skills/scene-editor-compat/assets/example/src/scenes/main.scene.json +18 -18
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/release.json +7 -7
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.d.mts +42 -42
- package/resources/js/context/skills/scene-editor-compat/assets/runtime/scene.mjs +144 -144
- package/resources/js/context/skills/scene-editor-compat/docs/contract.md +330 -330
- package/resources/js/context/skills/scene-editor-compat/docs/resource-sync.md +64 -64
- package/resources/js/context/skills/scene-editor-compat/docs/runtime-state.md +28 -28
- package/resources/js/context/skills/scene-editor-compat/docs/terrain-contract.md +47 -47
- package/resources/js/context/skills/scene-editor-compat/docs/visual-contract.md +64 -64
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.assets.json +38 -38
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/localcraft.scene-editor.json +9 -9
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneAdapter.ts +59 -59
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneBlockers.ts +30 -30
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/game/sceneFileAssets.ts +66 -66
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/Main.Scene.ts +20 -20
- package/resources/js/context/skills/scene-editor-compat/examples/platformer-ts/src/scenes/SceneTypes.ts +26 -26
- package/resources/js/context/skills/scene-editor-compat/references/contract.md +73 -73
- package/resources/js/context/skills/scene-editor-compat/scripts/apply_scene_marker.py +162 -162
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_contract.py +853 -853
- package/resources/js/context/skills/scene-editor-compat/scripts/check_scene_resource_urls.py +173 -173
- package/resources/js/context/skills/scene-editor-compat/scripts/scene-editor.mjs +427 -427
- package/resources/js/context/skills/scene-editor-compat/version.json +1 -1
- package/resources/js/context/skills/ui-editor-compat/SKILL.md +48 -48
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -35
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +74 -74
- package/resources/js/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -60
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -45
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -265
- package/resources/js/context/skills/ui-editor-compat/assets/runtime/release.json +7 -7
- package/resources/js/context/skills/ui-editor-compat/references/contract.md +132 -132
- package/resources/js/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -327
- package/resources/js/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -80
- package/resources/js/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -84
- package/resources/js/context/skills/version-update/SKILL.md +192 -192
- package/resources/js/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -129
- package/resources/js/context/skills/version-update/scripts/feature_snapshot.mjs +159 -159
- package/resources/js/context/skills/version-update/scripts/update_feature_version.mjs +157 -157
- package/resources/js/context/skills/visual-qa/SKILL.md +36 -36
- package/resources/js/context/version/version.json +1 -1
- package/resources/js/project/README.md +99 -99
- package/resources/js/project/SPEC/readme.md +6 -6
- package/resources/js/project/configs/assets.json +1 -1
- package/resources/js/project/configs/game.controls.json +3 -3
- package/resources/js/project/configs/game.json +3 -3
- package/resources/js/project/game-runtime.json +2 -2
- package/resources/js/project/{projectDisplayInfo.json → game.config.json} +7 -7
- package/resources/js/project/index.html +20 -20
- package/resources/js/project/package.json +23 -23
- package/resources/js/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +208 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +37 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform-service.d.mts +31 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +272 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform.d.mts +79 -0
- package/resources/js/project/runtime/lightgame/1.1.0/platform/platform.mjs +29 -0
- package/resources/js/project/runtime/lightgame/1.1.0/release.json +22 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/cli.mjs +16 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/project.d.mts +4 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/project.mjs +50 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +3 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tooling/vite.mjs +72 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/assets.d.mts +24 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/assets.mjs +2 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/astc.d.mts +10 -0
- package/resources/js/project/runtime/lightgame/1.1.0/tools/astc.mjs +1 -0
- package/resources/js/project/scripts/config-export.mjs +37 -32
- package/resources/js/project/scripts/refresh-runtime.mjs +50 -50
- package/resources/js/project/scripts/skill-modules/export-config/cli.mjs +20 -0
- package/resources/js/project/scripts/skill-modules/export-config/config.d.mts +19 -0
- package/resources/js/project/scripts/skill-modules/export-config/config.mjs +1 -0
- package/resources/js/project/scripts/skill-modules/export-config/installed.json +6 -0
- package/resources/js/project/scripts/skill-modules/export-config/project.d.mts +6 -0
- package/resources/js/project/scripts/skill-modules/export-config/project.mjs +77 -0
- package/resources/js/project/scripts/skill-modules/export-config/vite.d.mts +2 -0
- package/resources/js/project/scripts/skill-modules/export-config/vite.mjs +34 -0
- package/resources/js/project/scripts/write-preview-ready.mjs +22 -0
- package/resources/js/project/src/display/ui-stage.ts +156 -121
- package/resources/js/project/src/display/viewport.ts +249 -254
- package/resources/js/project/src/main.ts +87 -99
- package/resources/js/project/src/platform.ts +2 -14
- package/resources/js/project/src/scenes/LoadScene.ts +89 -89
- package/resources/js/project/src/scenes/PlayScene.ts +17 -17
- package/resources/js/project/src/screenUi.ts +185 -172
- package/resources/js/project/src/style.css +294 -165
- package/resources/js/project/tsconfig.json +20 -20
- package/resources/js/project/unified_data_control_config.json +20 -20
- package/resources/js/project/vendor/core-manager-js/src/.versions.json +42 -42
- package/resources/js/project/vendor/core-manager-js/src/CoreManagerPlugin.ts +41 -41
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AssetRef.ts +93 -90
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcFirstImageFile.ts +203 -203
- package/resources/js/project/vendor/core-manager-js/src/assetManager/AstcTextureLoader.ts +106 -106
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.test.ts +25 -25
- package/resources/js/project/vendor/core-manager-js/src/assetManager/resolveAssetUrl.ts +21 -21
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.test.ts +65 -65
- package/resources/js/project/vendor/core-manager-js/src/audioManager/AudioManager.ts +340 -340
- package/resources/js/project/vendor/core-manager-js/src/configManager/FeatureConfig.ts +87 -87
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.d.mts +92 -92
- package/resources/js/project/vendor/core-manager-js/src/configManager/tuneRuntime.mjs +271 -271
- package/resources/js/project/vendor/core-manager-js/src/index.ts +31 -31
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputConfig.ts +81 -81
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.test.ts +43 -43
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputManager.ts +32 -32
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.test.ts +141 -141
- package/resources/js/project/vendor/core-manager-js/src/inputManager/InputRuntime.ts +20 -20
- package/resources/js/project/vendor/core-manager-js/src/inputManager/KeyboardProvider.ts +183 -183
- package/resources/js/project/vendor/core-manager-js/src/inputManager/TouchProvider.ts +304 -304
- package/resources/js/project/vendor/core-manager-js/src/inputManager/VirtualJoystick.ts +351 -351
- package/resources/js/project/vendor/core-manager-js/src/inputManager/_internal/InputManagerImpl.ts +180 -180
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64 +13 -13
- package/resources/js/project/vendor/core-manager-js/src/inputManager/icons.b64.d.ts +14 -14
- package/resources/js/project/vendor/core-manager-js/src/inputManager/input_config.example.json +68 -68
- package/resources/js/project/vendor/core-manager-js/src/logManager/DebugConsole.ts +433 -433
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogCapture.ts +118 -118
- package/resources/js/project/vendor/core-manager-js/src/logManager/LogManager.ts +444 -444
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCapture.ts +485 -485
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.test.ts +66 -66
- package/resources/js/project/vendor/core-manager-js/src/logManager/ScreenCaptureVideo.ts +149 -149
- package/resources/js/project/vendor/core-manager-js/src/logManager/icons.b64 +9 -9
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/AssetUrlResolver.ts +29 -29
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.test.ts +88 -88
- package/resources/js/project/vendor/core-manager-js/src/resourceManager/ResourceManager.ts +122 -122
- package/resources/js/project/vendor/core-manager-js/src/runtime.ts +24 -24
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterEntity.ts +318 -318
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.test.ts +151 -151
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/CharacterPhysicsBinding.ts +235 -235
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.test.ts +98 -98
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectComposite.ts +94 -94
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/EffectEntity.ts +209 -209
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.test.ts +106 -106
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxManager.ts +341 -341
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.test.ts +68 -68
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/FxRecipe.ts +236 -236
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.test.ts +22 -22
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteAnimManager.ts +29 -29
- package/resources/js/project/vendor/core-manager-js/src/spriteAnimManager/SpriteEntity.test.ts +197 -197
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiContracts.ts +9 -9
- package/resources/js/project/vendor/core-manager-js/src/uiManager/DomUiKit.ts +555 -555
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.test.ts +112 -112
- package/resources/js/project/vendor/core-manager-js/src/uiManager/UIFacadePlugin.ts +178 -178
- package/resources/js/project/vendor/core-manager-js/src/uiManager/ui-base.css +246 -246
- package/resources/js/project/vendor/core-manager-js/src/videoManager/VideoManager.ts +139 -139
- package/resources/js/project/vendor/core-manager-js/tsconfig.json +15 -15
- package/resources/js/project/vendor/run.sh +4 -107
- package/resources/js/project/version/craft_feature_version.json +42 -42
- package/resources/js/project/version/project_feature_version.json +11 -11
- package/resources/js/project/vite.config.ts +5 -4
- package/resources/js3d/context/.role/AGENTS_DESIGN.md +9 -0
- package/resources/js3d/context/AGENTS.md +95 -0
- package/resources/js3d/context/hooks/hooks.json +14 -20
- package/resources/js3d/context/knowledge/3D/PoseInterpolationKnowledge.md +75 -87
- package/resources/js3d/context/knowledge/CodingGuide/Pitfalls.md +69 -69
- package/resources/js3d/context/knowledge/CodingGuide/SceneEditableGuide.md +42 -42
- package/resources/js3d/context/knowledge/FrontendComponents.md +19 -23
- package/resources/js3d/context/knowledge/MobileAdaptation.md +73 -0
- package/resources/js3d/context/knowledge/MobileAdapted.md +36 -0
- package/resources/js3d/context/knowledge/Multiplayer/GameplaySystemKnowledge.md +114 -114
- package/resources/js3d/context/knowledge/Multiplayer/OverviewKnowledge.md +117 -117
- package/resources/js3d/context/knowledge/Multiplayer/StateSyncKnowledge.md +430 -430
- package/resources/js3d/context/knowledge/PlatformServices.md +190 -162
- package/resources/js3d/context/knowledge/ProjectDisplayConfig.md +35 -0
- package/resources/js3d/context/knowledge/Runtime.md +34 -30
- package/resources/js3d/context/knowledge/SceneEditorCompat.md +35 -34
- package/resources/js3d/context/knowledge/StepByStep.md +21 -21
- package/resources/js3d/context/knowledge/Subsystems/Optional/MultiplayerManagerKnowledge.md +242 -242
- package/resources/js3d/context/knowledge/UiEditorCompat.md +21 -21
- package/resources/js3d/context/rules/MultiplayerCapability.md +27 -27
- package/resources/js3d/context/rules/MultiplayerRoomEntryUX.md +63 -63
- package/resources/js3d/context/rules/PlatformBoundaryModules.md +44 -43
- package/resources/js3d/context/rules/preview_ready.md +8 -0
- package/resources/js3d/context/skills/aigc-integration/SKILL.md +172 -176
- package/resources/js3d/context/skills/aigc-integration/assets/sprite-sheet-player.mjs +70 -0
- package/resources/js3d/context/skills/aigc-integration/callback.md +77 -56
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/README.md +23 -22
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/audio-aigc-knowledge.md +38 -38
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/character2d-aigc-knowledge.md +72 -0
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/staticmesh-aigc-knowledge.md +33 -33
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-prop-aigc-knowledge.md +36 -36
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-scene-aigc-knowledge.md +37 -37
- package/resources/js3d/context/skills/aigc-integration/knowledge/aigc/texture-ui-aigc-knowledge.md +35 -35
- package/resources/js3d/context/skills/asset-search/SKILL.md +178 -159
- package/resources/js3d/context/skills/asset-search/references/resource-config.md +99 -56
- package/resources/js3d/context/skills/asset-search/references/sprite-sheets.md +58 -0
- package/resources/js3d/context/skills/asset-search/scripts/asset_display.mjs +62 -62
- package/resources/js3d/context/skills/asset-search/scripts/config.json +235 -213
- package/resources/js3d/context/skills/asset-search/scripts/manifest_pipeline.mjs +905 -885
- package/resources/js3d/context/skills/asset-search/scripts/preflight.mjs +79 -79
- package/resources/js3d/context/skills/asset-search/scripts/provided_assets.mjs +74 -74
- package/resources/js3d/context/skills/asset-search/scripts/search.mjs +637 -597
- package/resources/js3d/context/skills/asset-search/scripts/sprite_source_materializer.mjs +667 -0
- package/resources/js3d/context/skills/asset-search/strategies/anim2d.md +42 -0
- package/resources/js3d/context/skills/asset-search/strategies/effect2d.md +31 -0
- package/resources/js3d/context/skills/asset-usage-audit/SKILL.md +92 -0
- package/resources/js3d/context/skills/asset-usage-audit/references/case-tidewater-zoo.md +89 -0
- package/resources/js3d/context/skills/asset-usage-audit/references/optimization-playbook.md +143 -0
- package/resources/js3d/context/skills/asset-usage-audit/references/usage-model.md +90 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/compare-animations.mjs +48 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/lib/anim.mjs +266 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/lib/glb.mjs +241 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/lib/scan.mjs +455 -0
- package/resources/js3d/context/skills/asset-usage-audit/scripts/scan-assets.mjs +77 -0
- package/resources/js3d/context/skills/export-config/SKILL.md +20 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/cli.mjs +20 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/config.d.mts +19 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/config.mjs +1 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/project.d.mts +6 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/project.mjs +77 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/vite.d.mts +2 -0
- package/resources/js3d/context/skills/export-config/assets/tooling/vite.mjs +34 -0
- package/resources/js3d/context/skills/export-config/scripts/assert-asset-wiring.mjs +97 -83
- package/resources/js3d/context/skills/export-config/scripts/export-config.mjs +56 -53
- package/resources/js3d/context/skills/export-config/scripts/install.mjs +89 -0
- package/resources/js3d/context/skills/export-config/scripts/panel-resource-path.mjs +106 -106
- package/resources/js3d/context/skills/export-config/scripts/sync-asset-controls.mjs +327 -325
- package/resources/js3d/context/skills/export-config/scripts/sync-scene-assets.mjs +216 -181
- package/resources/js3d/context/skills/export-config/scripts/translate-asset-titles.mjs +161 -163
- package/resources/js3d/context/skills/game-art-style/SKILL.md +60 -60
- package/resources/js3d/context/skills/game-art-style/references/art-parameters-lite.md +38 -38
- package/resources/js3d/context/skills/game-art-style/references/construction.md +111 -111
- package/resources/js3d/context/skills/game-art-style/references/materials-textures.md +105 -105
- package/resources/js3d/context/skills/game-art-style/references/sources.md +25 -25
- package/resources/js3d/context/skills/game-art-style/references/styles/cartoon.md +175 -175
- package/resources/js3d/context/skills/game-art-style/references/styles/comic.md +168 -168
- package/resources/js3d/context/skills/game-art-style/references/styles/cozy.md +191 -191
- package/resources/js3d/context/skills/game-art-style/references/styles/cyber.md +165 -165
- package/resources/js3d/context/skills/game-art-style/references/styles/horror.md +173 -173
- package/resources/js3d/context/skills/game-art-style/references/styles/lowpoly.md +185 -185
- package/resources/js3d/context/skills/game-art-style/references/styles/paper.md +181 -181
- package/resources/js3d/context/skills/game-art-style/references/styles/voxel.md +189 -189
- package/resources/js3d/context/skills/game-art-style/references/user-style-document.md +88 -88
- package/resources/js3d/context/skills/mobile-adaptation/SKILL.md +301 -284
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-config.json +104 -104
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts +933 -952
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-platform.ts +92 -92
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/input-primitives.ts +254 -0
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/input/look-pad.ts +245 -245
- package/resources/js3d/context/skills/mobile-adaptation/assets/example/src/ui/touch-controls.css +257 -256
- package/resources/js3d/context/skills/mobile-adaptation/references/input-config.md +342 -311
- package/resources/js3d/context/skills/mobile-adaptation/references/verification.md +140 -106
- package/resources/js3d/context/skills/mobile-adaptation/references/web-audio.md +11 -0
- package/resources/js3d/context/skills/mobile-compat-qa/SKILL.md +53 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/startup-diagnosis.md +23 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-form-input.md +10 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-lifecycle.md +20 -0
- package/resources/js3d/context/skills/mobile-compat-qa/references/web-performance.md +19 -0
- package/resources/js3d/context/skills/optimization-suggestions/SKILL.md +74 -74
- package/resources/js3d/context/skills/performance-audit/SKILL.md +166 -0
- package/resources/js3d/context/skills/performance-audit/references/case-notes.md +93 -0
- package/resources/js3d/context/skills/performance-audit/references/rules.md +183 -0
- package/resources/js3d/context/skills/performance-audit/scripts/lib/rules.mjs +470 -0
- package/resources/js3d/context/skills/performance-audit/scripts/lib/scan.mjs +387 -0
- package/resources/js3d/context/skills/performance-audit/scripts/lib/source.mjs +398 -0
- package/resources/js3d/context/skills/performance-audit/scripts/scan-perf.mjs +130 -0
- package/resources/js3d/context/skills/platform-services/SKILL.md +101 -94
- package/resources/js3d/context/skills/platform-services/assets/modules/MultiplayerManager.ts +465 -783
- package/resources/js3d/context/skills/platform-services/assets/modules/eventBus.ts +57 -57
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/qq-session.mjs +208 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/identity/shared.mjs +37 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.d.mts +39 -39
- package/resources/js3d/context/skills/platform-services/assets/modules/leaderboard.mjs +1 -1
- package/resources/js3d/context/skills/platform-services/assets/modules/log.ts +35 -35
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/clockSync.ts +61 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/dsClient.ts +52 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/payloadCodec.ts +30 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/roomHttp.ts +89 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/multiplayer/types.ts +47 -0
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.d.mts +31 -25
- package/resources/js3d/context/skills/platform-services/assets/modules/platform-service.mjs +272 -1
- package/resources/js3d/context/skills/platform-services/assets/modules/save.d.mts +49 -49
- package/resources/js3d/context/skills/platform-services/assets/modules/save.mjs +1 -1
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/main.mjs +7 -7
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/SyncRoom.mjs +264 -264
- package/resources/js3d/context/skills/platform-services/assets/scaffold/ds/rooms/syncSchema.mjs +39 -39
- package/resources/js3d/context/skills/platform-services/references/SERVER_GUIDE.md +139 -139
- package/resources/js3d/context/skills/platform-services/references/api_reference.md +18 -18
- package/resources/js3d/context/skills/platform-services/references/leaderboard_playbook.md +96 -0
- package/resources/js3d/context/skills/platform-services/scripts/install.mjs +148 -134
- package/resources/js3d/context/skills/resolution-adaptation/SKILL.md +46 -170
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/ui-stage.ts +156 -121
- package/resources/js3d/context/skills/resolution-adaptation/assets/display/viewport.ts +239 -244
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/main.ts +129 -127
- package/resources/js3d/context/skills/resolution-adaptation/assets/example/ui-tokens.css +188 -188
- package/resources/js3d/context/skills/resolution-adaptation/references/audit.md +31 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/device-safe-area.md +40 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/game-ui-occlusion.md +18 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/layout-rules.md +15 -124
- package/resources/js3d/context/skills/resolution-adaptation/references/troubleshooting.md +34 -0
- package/resources/js3d/context/skills/resolution-adaptation/references/viewport-api.md +38 -117
- package/resources/js3d/context/skills/resolution-adaptation/scripts/aspect_audit.mjs +448 -338
- package/resources/js3d/context/skills/scene-editor-compat/SKILL.md +599 -599
- package/resources/js3d/context/skills/scene-editor-compat/references/bundle-contract.md +141 -141
- package/resources/js3d/context/skills/scene-editor-compat/references/editor-integration.md +92 -92
- package/resources/js3d/context/skills/scene-editor-compat/references/scene-data-format.md +125 -125
- package/resources/js3d/context/skills/scene-editor-compat/references/slots-rules.md +113 -113
- package/resources/js3d/context/skills/scene-editor-compat/scripts/scene-editor.mjs +1187 -1187
- package/resources/js3d/context/skills/threejs-game-quality/SKILL.md +53 -52
- package/resources/js3d/context/skills/threejs-game-quality/agents/openai.yaml +4 -4
- package/resources/js3d/context/skills/threejs-game-quality/references/01-build.md +94 -94
- package/resources/js3d/context/skills/threejs-game-quality/references/02-avoid.md +50 -50
- package/resources/js3d/context/skills/threejs-game-quality/references/03-detect.md +105 -105
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-by-genre.md +147 -147
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-distance.md +79 -79
- package/resources/js3d/context/skills/threejs-game-quality/references/camera-sources.md +56 -56
- package/resources/js3d/context/skills/threejs-game-quality/references/character-motion-face.md +51 -51
- package/resources/js3d/context/skills/threejs-game-quality/references/parameter-contract.md +55 -55
- package/resources/js3d/context/skills/threejs-game-quality/references/refine-existing.md +78 -78
- package/resources/js3d/context/skills/threejs-game-quality/references/rendering-stability.md +84 -84
- package/resources/js3d/context/skills/threejs-game-quality/references/runtime-tools.md +117 -117
- package/resources/js3d/context/skills/threejs-game-quality/scripts/package.json +4 -4
- package/resources/js3d/context/skills/threejs-game-quality/scripts/runtime-audit.js +238 -238
- package/resources/js3d/context/skills/ui-editor-compat/SKILL.md +59 -59
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLayout_Hud.ts +35 -35
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/WidgetLogic_Hud.ts +61 -61
- package/resources/js3d/context/skills/ui-editor-compat/assets/example/hud/hud.css +60 -60
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.d.mts +45 -45
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/dom-ui.mjs +265 -265
- package/resources/js3d/context/skills/ui-editor-compat/assets/runtime/release.json +7 -7
- package/resources/js3d/context/skills/ui-editor-compat/references/contract.md +110 -110
- package/resources/js3d/context/skills/ui-editor-compat/scripts/editor-contract.mjs +327 -327
- package/resources/js3d/context/skills/ui-editor-compat/scripts/project-files.mjs +80 -80
- package/resources/js3d/context/skills/ui-editor-compat/scripts/ui-editor.mjs +84 -84
- package/resources/js3d/context/skills/version-update/SKILL.md +191 -191
- package/resources/js3d/context/skills/version-update/scripts/check_runtime_refs.mjs +129 -129
- package/resources/js3d/context/skills/version-update/scripts/feature_snapshot.mjs +159 -159
- package/resources/js3d/context/skills/version-update/scripts/update_feature_version.mjs +157 -157
- package/resources/js3d/context/version/version.json +1 -1
- package/resources/js3d/project/README.md +106 -100
- package/resources/js3d/project/configs/game.controls.json +3 -3
- package/resources/js3d/project/configs/game.json +3 -3
- package/resources/js3d/project/game-runtime.json +2 -2
- package/resources/js3d/project/{projectDisplayInfo.json → game.config.json} +7 -7
- package/resources/js3d/project/index.html +12 -12
- package/resources/js3d/project/package.json +24 -24
- package/resources/js3d/project/runtime/lightgame/1.0.0/release.json +2 -2
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.d.mts +2 -12
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.mjs +21 -29
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/identity/qq-ai-game-sdk.min.js +5 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/identity/qq-session.mjs +208 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/identity/shared.mjs +37 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform-capture-video.mjs +227 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform-service.d.mts +31 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform-service.mjs +272 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform.d.mts +79 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/platform/platform.mjs +30 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/release.json +24 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/cli.mjs +16 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/project.d.mts +4 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/project.mjs +50 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/vite.d.mts +3 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tooling/vite.mjs +72 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/assets.d.mts +24 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/assets.mjs +2 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/astc.d.mts +10 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/astc.mjs +1 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/glb.d.mts +26 -0
- package/resources/js3d/project/runtime/lightgame/1.1.0/tools/glb.mjs +351 -0
- package/resources/js3d/project/scripts/config-export.mjs +37 -32
- package/resources/js3d/project/scripts/refresh-runtime.mjs +50 -50
- package/resources/js3d/project/scripts/skill-modules/export-config/cli.mjs +20 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/config.d.mts +19 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/config.mjs +1 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/installed.json +6 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/project.d.mts +6 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/project.mjs +77 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/vite.d.mts +2 -0
- package/resources/js3d/project/scripts/skill-modules/export-config/vite.mjs +34 -0
- package/resources/js3d/project/scripts/write-preview-ready.mjs +22 -0
- package/resources/js3d/project/src/display/ui-stage.ts +156 -121
- package/resources/js3d/project/src/display/viewport.ts +239 -244
- package/resources/js3d/project/src/main.ts +85 -83
- package/resources/js3d/project/src/platform.ts +2 -14
- package/resources/js3d/project/src/style.css +83 -17
- package/resources/js3d/project/tsconfig.json +20 -20
- package/resources/js3d/project/unified_data_control_config.json +20 -20
- package/resources/js3d/project/vendor/core-manager-three/package.json +12 -12
- package/resources/js3d/project/vendor/core-manager-three/src/index.ts +2 -2
- package/resources/js3d/project/vendor/run.sh +4 -4
- package/resources/js3d/project/version/craft_feature_version.json +42 -42
- package/resources/js3d/project/version/project_feature_version.json +11 -11
- package/resources/js3d/project/vite.config.ts +5 -4
- package/vendor/agent-cli/dist/runtime-tools/ue/blender-cook-assets.cjs +19 -19
- package/vendor/agent-cli/dist/runtime-tools/ue/tool-manifest.json +1 -1
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts +1 -1
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js +15 -6
- package/vendor/agent-cli/dist/src/artifacts/context-finalize.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/native-source.d.ts +3 -0
- package/vendor/agent-cli/dist/src/artifacts/native-source.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/native-source.js +13 -0
- package/vendor/agent-cli/dist/src/artifacts/native-source.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.d.ts +13 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js +300 -0
- package/vendor/agent-cli/dist/src/artifacts/preinstalled-dependencies.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts +4 -0
- package/vendor/agent-cli/dist/src/artifacts/prepare.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/prepare.js +20 -7
- package/vendor/agent-cli/dist/src/artifacts/prepare.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts +8 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js +64 -37
- package/vendor/agent-cli/dist/src/artifacts/process-artifacts.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.d.ts +27 -0
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.js +112 -0
- package/vendor/agent-cli/dist/src/artifacts/restore-permissions.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts +9 -0
- package/vendor/agent-cli/dist/src/artifacts/restore.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/restore.js +140 -59
- package/vendor/agent-cli/dist/src/artifacts/restore.js.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.d.ts +7 -0
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.js +145 -0
- package/vendor/agent-cli/dist/src/artifacts/scene-asset-delivery.js.map +1 -0
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts +6 -2
- package/vendor/agent-cli/dist/src/artifacts/static.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/artifacts/static.js +100 -28
- package/vendor/agent-cli/dist/src/artifacts/static.js.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-protocol.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/cli/process-protocol.js +6 -3
- package/vendor/agent-cli/dist/src/cli/process-protocol.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/browser-queue.d.ts +55 -0
- package/vendor/agent-cli/dist/src/component/browser-queue.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/browser-queue.js +63 -0
- package/vendor/agent-cli/dist/src/component/browser-queue.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts +4 -0
- package/vendor/agent-cli/dist/src/component/execution.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/component/execution.js +16 -4
- package/vendor/agent-cli/dist/src/component/execution.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/isolated-launcher.d.ts +2 -0
- package/vendor/agent-cli/dist/src/component/isolated-launcher.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/isolated-launcher.js +76 -0
- package/vendor/agent-cli/dist/src/component/isolated-launcher.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.d.ts +2 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.js +27 -0
- package/vendor/agent-cli/dist/src/component/isolated-preload.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts +0 -5
- package/vendor/agent-cli/dist/src/component/platform-access/server.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/component/platform-access/server.js +9 -3
- package/vendor/agent-cli/dist/src/component/platform-access/server.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js +5 -0
- package/vendor/agent-cli/dist/src/component/preparation-diagnostics.js.map +1 -1
- package/vendor/agent-cli/dist/src/component/process-diagnostics.d.ts +25 -0
- package/vendor/agent-cli/dist/src/component/process-diagnostics.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/process-diagnostics.js +137 -0
- package/vendor/agent-cli/dist/src/component/process-diagnostics.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.d.ts +10 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.js +59 -0
- package/vendor/agent-cli/dist/src/component/process-isolation.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.d.ts +2 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.js +46 -0
- package/vendor/agent-cli/dist/src/component/proxied-fetch.js.map +1 -0
- package/vendor/agent-cli/dist/src/component/public-egress.d.ts +17 -0
- package/vendor/agent-cli/dist/src/component/public-egress.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/component/public-egress.js +246 -0
- package/vendor/agent-cli/dist/src/component/public-egress.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.d.ts +3 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.js +68 -0
- package/vendor/agent-cli/dist/src/context/cache-publication-lock.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts +1 -1
- package/vendor/agent-cli/dist/src/context/cache-publication.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/cache-publication.js +8 -4
- package/vendor/agent-cli/dist/src/context/cache-publication.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-cache.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-cache.js +5 -2
- package/vendor/agent-cli/dist/src/context/context-cache.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-project.d.ts +45 -4
- package/vendor/agent-cli/dist/src/context/context-project.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-project.js +157 -16
- package/vendor/agent-cli/dist/src/context/context-project.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-scoped-source.d.ts +13 -0
- package/vendor/agent-cli/dist/src/context/context-scoped-source.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-scoped-source.js +78 -0
- package/vendor/agent-cli/dist/src/context/context-scoped-source.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts +14 -0
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js +110 -44
- package/vendor/agent-cli/dist/src/context/context-snapshot-cache.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts +2 -0
- package/vendor/agent-cli/dist/src/context/local-skills.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/local-skills.js +36 -19
- package/vendor/agent-cli/dist/src/context/local-skills.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/member-context.d.ts +2 -1
- package/vendor/agent-cli/dist/src/context/member-context.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/member-context.js +17 -9
- package/vendor/agent-cli/dist/src/context/member-context.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts +9 -1
- package/vendor/agent-cli/dist/src/context/script-dependencies.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/script-dependencies.js +22 -6
- package/vendor/agent-cli/dist/src/context/script-dependencies.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts +1 -1
- package/vendor/agent-cli/dist/src/context/shared-cache-build.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js +1 -0
- package/vendor/agent-cli/dist/src/context/shared-cache-build.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/team-knowledge.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/team-knowledge.js +11 -2
- package/vendor/agent-cli/dist/src/context/team-knowledge.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-cache.d.ts +5 -1
- package/vendor/agent-cli/dist/src/context/template-cache.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-cache.js +2 -2
- package/vendor/agent-cli/dist/src/context/template-cache.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-refresh.d.ts +6 -0
- package/vendor/agent-cli/dist/src/context/template-refresh.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-refresh.js +45 -0
- package/vendor/agent-cli/dist/src/context/template-refresh.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts +16 -3
- package/vendor/agent-cli/dist/src/context/template-seed.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-seed.js +71 -19
- package/vendor/agent-cli/dist/src/context/template-seed.js.map +1 -1
- package/vendor/agent-cli/dist/src/context/template-sync.d.ts +11 -0
- package/vendor/agent-cli/dist/src/context/template-sync.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/context/template-sync.js +167 -0
- package/vendor/agent-cli/dist/src/context/template-sync.js.map +1 -0
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts +3 -1
- package/vendor/agent-cli/dist/src/context/user-skill-context.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/context/user-skill-context.js +41 -2
- package/vendor/agent-cli/dist/src/context/user-skill-context.js.map +1 -1
- package/vendor/agent-cli/dist/src/index.d.ts +5 -1
- package/vendor/agent-cli/dist/src/index.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/index.js +5 -1
- package/vendor/agent-cli/dist/src/index.js.map +1 -1
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.d.ts +2 -2
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js +4 -2
- package/vendor/agent-cli/dist/src/lifecycle/engine-hooks.js.map +1 -1
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js +1 -1
- package/vendor/agent-cli/dist/src/lifecycle/hook-command.js.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts +24 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js +6 -0
- package/vendor/agent-cli/dist/src/protocol/messages/errors.gen.js.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts +71 -4
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js +13 -1
- package/vendor/agent-cli/dist/src/protocol/messages/messages.gen.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/command-translate.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/command-translate.js +4 -0
- package/vendor/agent-cli/dist/src/security/command-translate.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/guard.d.ts +4 -0
- package/vendor/agent-cli/dist/src/security/guard.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/guard.js +17 -5
- package/vendor/agent-cli/dist/src/security/guard.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts +11 -2
- package/vendor/agent-cli/dist/src/security/mount-table.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/mount-table.js +92 -5
- package/vendor/agent-cli/dist/src/security/mount-table.js.map +1 -1
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts +4 -1
- package/vendor/agent-cli/dist/src/security/tool-scope.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/security/tool-scope.js +38 -4
- package/vendor/agent-cli/dist/src/security/tool-scope.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/client.d.ts +20 -0
- package/vendor/agent-cli/dist/src/session/client.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/client.js +28 -5
- package/vendor/agent-cli/dist/src/session/client.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/custom-context.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/custom-context.js +12 -6
- package/vendor/agent-cli/dist/src/session/custom-context.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/execution-recovery.d.ts +9 -0
- package/vendor/agent-cli/dist/src/session/execution-recovery.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/execution-recovery.js +49 -0
- package/vendor/agent-cli/dist/src/session/execution-recovery.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.js +20 -0
- package/vendor/agent-cli/dist/src/session/expert-definition.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/link-config.js +1 -1
- package/vendor/agent-cli/dist/src/session/link-config.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/link-session.d.ts +1 -0
- package/vendor/agent-cli/dist/src/session/link-session.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/link-session.js +19 -2
- package/vendor/agent-cli/dist/src/session/link-session.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-environment.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-environment.js +11 -0
- package/vendor/agent-cli/dist/src/session/process-environment.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-lifecycle.d.ts +5 -0
- package/vendor/agent-cli/dist/src/session/process-lifecycle.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-lifecycle.js +18 -0
- package/vendor/agent-cli/dist/src/session/process-lifecycle.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-observability.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/process-observability.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-observability.js +14 -0
- package/vendor/agent-cli/dist/src/session/process-observability.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-request.d.ts +7 -6
- package/vendor/agent-cli/dist/src/session/process-request.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-request.js +66 -87
- package/vendor/agent-cli/dist/src/session/process-request.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/process-restore.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/process-restore.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-restore.js +21 -0
- package/vendor/agent-cli/dist/src/session/process-restore.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-summary-output.d.ts +15 -0
- package/vendor/agent-cli/dist/src/session/process-summary-output.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-summary-output.js +46 -0
- package/vendor/agent-cli/dist/src/session/process-summary-output.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.d.ts +3 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.js +21 -0
- package/vendor/agent-cli/dist/src/session/process-workspace.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/reference-tools.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/reference-tools.js +3 -2
- package/vendor/agent-cli/dist/src/session/reference-tools.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts +2 -0
- package/vendor/agent-cli/dist/src/session/run-setup.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-setup.js +35 -14
- package/vendor/agent-cli/dist/src/session/run-setup.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts +5 -0
- package/vendor/agent-cli/dist/src/session/run-start-body.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.js +13 -1
- package/vendor/agent-cli/dist/src/session/run-start-body.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/team-persistence.js +1 -1
- package/vendor/agent-cli/dist/src/session/team-persistence.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/tool-scheduler.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js +33 -23
- package/vendor/agent-cli/dist/src/session/tool-scheduler.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-choice-policy.d.ts +25 -0
- package/vendor/agent-cli/dist/src/session/user-choice-policy.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-choice-policy.js +70 -0
- package/vendor/agent-cli/dist/src/session/user-choice-policy.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-choice.d.ts +3 -2
- package/vendor/agent-cli/dist/src/session/user-choice.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-choice.js +30 -9
- package/vendor/agent-cli/dist/src/session/user-choice.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.js +25 -0
- package/vendor/agent-cli/dist/src/session/user-skill-compatibility.js.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js +2 -1
- package/vendor/agent-cli/dist/src/session/user-skill-loaded.js.map +1 -1
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.d.ts +4 -0
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.js +15 -0
- package/vendor/agent-cli/dist/src/session/user-skill-prompt.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/replace-file.d.ts +3 -0
- package/vendor/agent-cli/dist/src/shared/replace-file.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/shared/replace-file.js +34 -0
- package/vendor/agent-cli/dist/src/shared/replace-file.js.map +1 -0
- package/vendor/agent-cli/dist/src/shared/types.d.ts +55 -4
- package/vendor/agent-cli/dist/src/shared/types.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/shared/user-choice.d.ts +21 -2
- package/vendor/agent-cli/dist/src/shared/user-choice.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts +3 -0
- package/vendor/agent-cli/dist/src/tools/command-executor.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/command-executor.js +42 -5
- package/vendor/agent-cli/dist/src/tools/command-executor.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/context-program.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/context-program.js +46 -20
- package/vendor/agent-cli/dist/src/tools/context-program.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts +10 -19
- package/vendor/agent-cli/dist/src/tools/file-ops.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/file-ops.js +11 -85
- package/vendor/agent-cli/dist/src/tools/file-ops.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/file-search.d.ts +29 -0
- package/vendor/agent-cli/dist/src/tools/file-search.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-search.js +98 -0
- package/vendor/agent-cli/dist/src/tools/file-search.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.d.ts +9 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.d.ts.map +1 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.js +29 -0
- package/vendor/agent-cli/dist/src/tools/file-stat.js.map +1 -0
- package/vendor/agent-cli/dist/src/tools/local-hands.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/local-hands.js +10 -2
- package/vendor/agent-cli/dist/src/tools/local-hands.js.map +1 -1
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts +3 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.d.ts.map +1 -1
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js +3 -0
- package/vendor/agent-cli/dist/src/tools/tool-contract.gen.js.map +1 -1
- package/resources/js/context/CLAUDE.md +0 -54
- package/resources/js/context/agents/aigc-manager.md +0 -91
- package/resources/js/context/knowledge/GameProbe.md +0 -74
- package/resources/js/context/skills/aigc-generate/scripts/apply-results.mjs +0 -83
- package/resources/js/context/skills/aigc-generate/scripts/config.json +0 -29
- package/resources/js/context/skills/aigc-generate/scripts/generate.mjs +0 -1016
- package/resources/js/context/skills/aigc-generate/scripts/lib/client.mjs +0 -228
- package/resources/js/context/skills/aigc-generate/scripts/lib/ledger.mjs +0 -119
- package/resources/js/context/skills/aigc-generate/scripts/lib/nstep-handoff.mjs +0 -100
- package/resources/js/context/skills/aigc-generate/scripts/lib/pipelines.mjs +0 -441
- package/resources/js/context/skills/aigc-generate/scripts/lib/queue.mjs +0 -283
- package/resources/js/context/skills/aigc-generate/scripts/lib/submit.mjs +0 -122
- package/resources/js/context/skills/aigc-generate/scripts/worker.mjs +0 -171
- package/resources/js/context/skills/asset-search/scripts/recalled_sprite_paths.mjs +0 -47
- package/resources/js/context/skills/asset-search/strategies/character2d.md +0 -33
- package/resources/js/context/skills/asset-search/strategies/texture-ui.md +0 -35
- package/resources/js/context/skills/display-info-setup/SKILL.md +0 -32
- package/resources/js/context/skills/display-info-setup/scripts/init_project.mjs +0 -38
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.d.mts +0 -39
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/leaderboard.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/platform-service.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.d.mts +0 -49
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/platform/save.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/release.json +0 -37
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/cli.mjs +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.d.mts +0 -8
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/project.mjs +0 -2
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.d.mts +0 -3
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tooling/vite.mjs +0 -8
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.d.mts +0 -20
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/audio.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.d.mts +0 -21
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/canvas.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.d.mts +0 -17
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/input.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.d.mts +0 -40
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/three.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.d.mts +0 -10
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/ui.mjs +0 -1
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.d.mts +0 -8
- package/resources/js/context/skills/lightgame-runtime-adapt/project/runtime/lightgame/1.0.0/tools/video.mjs +0 -1
- package/resources/js/context/skills/platform-services/assets/release.json +0 -44
- package/resources/js/project/.gitattributes +0 -2
- package/resources/js/project/gameplay-probe.json +0 -37
- package/resources/js/project/package-lock.json +0 -1155
- package/resources/js3d/context/CLAUDE.md +0 -50
- package/resources/js3d/context/skills/aigc-integration/scripts/config.json +0 -3
- package/resources/js3d/context/skills/aigc-integration/scripts/lib/submit.mjs +0 -344
- package/resources/js3d/context/skills/aigc-integration/scripts/query-music.mjs +0 -53
- package/resources/js3d/context/skills/aigc-integration/scripts/query-results.mjs +0 -53
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-cover.mjs +0 -44
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-image.mjs +0 -48
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-music.mjs +0 -34
- package/resources/js3d/context/skills/aigc-integration/scripts/submit-staticmesh.mjs +0 -39
- package/resources/js3d/context/skills/platform-services/assets/release.json +0 -44
- package/resources/js3d/project/.gitattributes +0 -2
- package/resources/js3d/project/gameplay-probe.json +0 -38
- package/resources/js3d/project/package-lock.json +0 -1204
- package/resources/js3d/project/runtime/lightgame/1.0.0/tools/glb.test.mjs +0 -25
package/resources/js/context/skills/mobile-adaptation/assets/example/src/input/input-layer.ts
CHANGED
|
@@ -1,881 +1,862 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 统一输入层:把 PC 键鼠与移动端虚拟控件收敛到**同一套语义接口**。
|
|
3
|
-
*
|
|
4
|
-
* 落盘位置:`${
|
|
5
|
-
*
|
|
6
|
-
* Phaser 侧的用法:入口 `main.ts` 建一次(`canvas` 传 `game.canvas`),拿到 `input` 后挂到
|
|
7
|
-
* `game.registry` 或模块单例上;Scene 在 `update()` 里读语义接口。
|
|
8
|
-
* **不要用 `this.input.on('pointerdown')` 处理同一批玩法动作** —— 那是另一条输入通路,
|
|
9
|
-
* 会在 PC 与移动端上各触发一次。Phaser 的指针事件只保留给「世界内点选 / 拖拽世界物体」,
|
|
10
|
-
* 且这类交互要按 SKILL.md「四、触点仲裁」确认触点没有被虚拟控件消费。
|
|
11
|
-
*
|
|
12
|
-
* 三层职责,不要混:
|
|
13
|
-
* ① 语义层(本文件的对外接口):`isDown('jump')` / `horizontal()` / `lookDelta()`。
|
|
14
|
-
* **业务只认这一层**,因此 PC 与移动端是同一条代码路径,不需要 `if (mobile)`。
|
|
15
|
-
* ② 映射层:`input-config.json` 里每个条目同时给出 `pc`(按键名)与 `mobile`(控件描述)。
|
|
16
|
-
* 两者映射到同一个语义 key;缺一边等于该平台玩不了。
|
|
17
|
-
* ③ 控件层:PC 用键盘事件;移动端用 DOM 虚拟控件(摇杆 / 动作按钮 / 视角滑动区)。
|
|
18
|
-
*
|
|
19
|
-
* 触点仲裁:**button > joystick > look**。这里靠 DOM 命中测试天然成立 ——
|
|
20
|
-
* 动作按钮是滑动区**之后**插入的兄弟节点(同 z-index 下后插入者优先命中),
|
|
21
|
-
*
|
|
22
|
-
* 且 `setPointerCapture` 之后该指针的后续事件只发给它 —— 等价于「一根手指自 down 起归属唯一控件」。
|
|
23
|
-
* 由此得到两条可以直接依赖的性质:
|
|
24
|
-
* - 落在动作按钮上的触点**不会**驱动视角,无需给滑动区配排除区;
|
|
25
|
-
* - 拖摇杆时手指划过按钮**不会**误触发按钮(触点已被摇杆捕获)。
|
|
26
|
-
*/
|
|
27
|
-
import {
|
|
28
|
-
createActionInput,
|
|
29
|
-
createJoystick,
|
|
30
|
-
createKeyboard,
|
|
31
|
-
} from '
|
|
32
|
-
import { applyPlatformAttr } from './input-platform';
|
|
33
|
-
import type { InputPlatform } from './input-platform';
|
|
34
|
-
import { createLookPad } from './look-pad';
|
|
35
|
-
import type { LookPad } from './look-pad';
|
|
36
|
-
import type { UiStageHandle } from '../display/ui-stage';
|
|
37
|
-
import inputConfig from './input-config.json';
|
|
38
|
-
|
|
39
|
-
// ─────────────────────── 配置结构(与 input-config.json 一一对应) ───────────────────────
|
|
40
|
-
|
|
41
|
-
export interface InputAxisConfig {
|
|
42
|
-
pc: {
|
|
43
|
-
/** 键位名见 SKILL.md「PC 键位名」 */
|
|
44
|
-
horizontal: { negative: readonly string[]; positive: readonly string[] };
|
|
45
|
-
vertical: { negative: readonly string[]; positive: readonly string[] };
|
|
46
|
-
};
|
|
47
|
-
mobile: {
|
|
48
|
-
type: 'joystick';
|
|
49
|
-
/** 有效拖动半径(设计像素)。**不得小于 40** */
|
|
50
|
-
radius: number;
|
|
51
|
-
/** 死区比例 [0,1),默认 0.12 */
|
|
52
|
-
deadZone?: number;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface InputActionConfig {
|
|
57
|
-
/**
|
|
58
|
-
* PC 触发源。两类 token,可混写:
|
|
59
|
-
* - 键盘:逐字的 `KeyboardEvent.code`(`KeyJ` / `Space` / `ArrowUp`);
|
|
60
|
-
* - 鼠标键:`Mouse0`(左)/ `Mouse1`(中)/ `Mouse2`(右)。
|
|
61
|
-
* 鼠标键**不是** `event.code`,由本文件转成 `createActionInput({ buttons })` 回调,
|
|
62
|
-
* 与键盘是 OR 关系、边沿检测同一条路径。写错的键名会打 warn(见 `warnSuspectKeyNames`)。
|
|
63
|
-
*/
|
|
64
|
-
pc: readonly string[];
|
|
65
|
-
/**
|
|
66
|
-
* 触发语义,默认 `'hold'`。
|
|
67
|
-
* - `'hold'`:`isDown()` 跟随物理按下(开火、加速、格挡);
|
|
68
|
-
* - `'toggle'`:**按一次翻转一次**,`isDown()` 返回锁存态(瞄准镜、自动奔跑、静步)。
|
|
69
|
-
* 此时 `wasPressed()` / `wasReleased()` 报的是**锁存开 / 关**的那一帧,
|
|
70
|
-
* 不是手指按下 / 抬起 —— 业务不需要自己存 boolean 做翻转。
|
|
71
|
-
*
|
|
72
|
-
* **写在 action 级而不是 `mobile` 里**:PC 与移动端必须同为 toggle,
|
|
73
|
-
* 否则 `isDown()` 在一个平台是瞬时、另一个平台是锁存,业务被迫分平台写两套。
|
|
74
|
-
*/
|
|
75
|
-
mode?: 'hold' | 'toggle';
|
|
76
|
-
mobile: {
|
|
77
|
-
type: 'button';
|
|
78
|
-
/** 按钮文字(图标走 CSS background,见 touch-controls.css) */
|
|
79
|
-
label: string;
|
|
80
|
-
/** 中心 X。**负数从右边缘算起** */
|
|
81
|
-
x: number;
|
|
82
|
-
/** 中心 Y。**负数从下边缘算起** */
|
|
83
|
-
y: number;
|
|
84
|
-
/** 触控半径(设计像素)。**不得小于 40** */
|
|
85
|
-
radius: number;
|
|
86
|
-
/**
|
|
87
|
-
* 建出来就先隐藏。**上下文交互按钮**(靠近才出现的「开门 / 拾取 / 对话」)写 `true`,
|
|
88
|
-
* 之后由业务用 `setActionButtonVisible(action, true)` 放出来。
|
|
89
|
-
* 不写的话开局会先闪一下按钮,再被业务第一帧的 `setActionButtonVisible(false)` 收掉。
|
|
90
|
-
*/
|
|
91
|
-
hidden?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* 按住本按钮拖动时,把指针位移并入 look 通道 ——
|
|
94
|
-
* 需求形态是「开火按钮按下即持续开火,拖拽可控制方向」。不写则拖动不影响视角。
|
|
95
|
-
*
|
|
96
|
-
* 前提是同名 look 通道已在 `looks` 里声明;缺失会打 warn 并忽略。
|
|
97
|
-
*/
|
|
98
|
-
drag?: {
|
|
99
|
-
/** 注入哪个 look 通道,默认 `'look'` */
|
|
100
|
-
look?: string;
|
|
101
|
-
/**
|
|
102
|
-
* **相对该 look 通道 `mobile.sensitivity` 的倍率**,默认 1。
|
|
103
|
-
* 位移先乘这里、再进 LookPad 乘通道灵敏度,所以两条路的 `invertY` 天然一致。
|
|
104
|
-
* 按钮拖拽通常要比滑动区更钝(拇指还要兼顾按住),建议 0.5~0.8。
|
|
105
|
-
*/
|
|
106
|
-
sensitivity?: number;
|
|
107
|
-
/**
|
|
108
|
-
* 起手死区(CSS 像素),默认 0。
|
|
109
|
-
* 按钮本身已是明确的按下意图,一般不需要再过滤;只有按钮很小、按下时容易带位移才调大。
|
|
110
|
-
*/
|
|
111
|
-
deadZonePx?: number;
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface InputLookConfig {
|
|
117
|
-
/**
|
|
118
|
-
* PC:鼠标位移。`requireButton=2` 按住右键拖动转向(**字段缺省时的默认值**);
|
|
119
|
-
* `0`=左键;**显式写 `null` = 不限制**,移动鼠标即转向(FPS 标准操作)。
|
|
120
|
-
* `null` 与「不写」语义不同,读取一律走 `pcLookRequireButton()`,不要用 `??`。
|
|
121
|
-
*/
|
|
122
|
-
pc: { requireButton?: number | null; sensitivity?: number; invertY?: boolean };
|
|
123
|
-
/** 移动端:滑动区几何由 CSS 决定(默认右半屏),不在配置里写坐标 */
|
|
124
|
-
mobile: { sensitivity?: number; invertY?: boolean; deadZonePx?: number };
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface InputConfigFile {
|
|
128
|
-
axes: Record<string, InputAxisConfig>;
|
|
129
|
-
actions: Record<string, InputActionConfig>;
|
|
130
|
-
/** 视角通道:**只在玩家需要主动控制镜头(FPS/TPS)时声明**,其它品类整段不写 */
|
|
131
|
-
looks?: Record<string, InputLookConfig>;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ─────────────────────── 对外接口 ───────────────────────
|
|
135
|
-
|
|
136
|
-
/** 轴上两根键的极性统一为「右正 X、下正 Y」,与键盘一致;世界方向转换在消费侧统一做 */
|
|
137
|
-
export interface GameInput {
|
|
138
|
-
readonly platform: InputPlatform;
|
|
139
|
-
/** 每帧一次,**必须在所有消费者之前**调用 */
|
|
140
|
-
sample(): void;
|
|
141
|
-
/**
|
|
142
|
-
* 直接读键盘边沿时需要,在所有消费者之后调用。
|
|
143
|
-
* 只用本接口的 `wasPressed/wasReleased` 时,可在 `sample()` 之后立即调用。
|
|
144
|
-
*/
|
|
145
|
-
endFrame(): void;
|
|
146
|
-
/** `mode: 'toggle'` 的动作返回**锁存态**(按一次开、再按一次关),不是物理按下 */
|
|
147
|
-
isDown(action: string): boolean;
|
|
148
|
-
/** toggle 型动作报的是**锁存打开**的那一帧,不是手指按下 */
|
|
149
|
-
wasPressed(action: string): boolean;
|
|
150
|
-
/** toggle 型动作报的是**锁存关闭**的那一帧,不是手指抬起 */
|
|
151
|
-
wasReleased(action: string): boolean;
|
|
152
|
-
/**
|
|
153
|
-
* 手动设置 `mode: 'toggle'` 动作的锁存态:死亡 / 换弹 / 切武器时强制退出瞄准。
|
|
154
|
-
* 在 `sample()` 之后调用 —— 本帧的 `wasPressed` / `wasReleased` 会反映这次变化,
|
|
155
|
-
* 下一次 `sample()` 清掉。对 `'hold'` 型动作调用会打 warn 并忽略。
|
|
156
|
-
*/
|
|
157
|
-
setToggle(action: string, on: boolean): void;
|
|
158
|
-
/** 语义轴(`move` / …):右正 X、下正的 [-1,1] */
|
|
159
|
-
horizontal(axis?: string): number;
|
|
160
|
-
vertical(axis?: string): number;
|
|
161
|
-
/** 消费型:读一次即清零,**每帧只能读一次** */
|
|
162
|
-
lookDelta(look?: string): { x: number; y: number };
|
|
163
|
-
isLookActive(look?: string): boolean;
|
|
164
|
-
/** 把外部位移并入 look 通道(如「开火按钮按住拖拽也能控向」) */
|
|
165
|
-
feedLookDelta(dx: number, dy: number, look?: string): void;
|
|
166
|
-
/**
|
|
167
|
-
* 显隐**单个**移动端虚拟按钮 —— 上下文交互按钮(靠近宝箱才出现的「开门 / 拾取」)用这个。
|
|
168
|
-
* 可以每帧无脑调用,值没变时不做任何事。
|
|
169
|
-
*
|
|
170
|
-
* **只管移动端 UI,不屏蔽 PC 键位。** PC 上没有虚拟控件,这里是 no-op;
|
|
171
|
-
* 业务照常自己判上下文 —— `if (target && input.wasPressed('interact'))` ——
|
|
172
|
-
* 这一条判断两端共用,不构成平台分支。
|
|
173
|
-
*
|
|
174
|
-
* **不要自己去改 `.touch-btn` 的 DOM**:隐藏时必须同时清掉按钮上残留的触点,
|
|
175
|
-
* 否则 `display: none` 不保证释放指针捕获(元素仍在文档里),`pointerup` 可能永远收不到,
|
|
176
|
-
* `isDown()` 会永久为真(表现为「按钮消失了却一直在开火」)。
|
|
177
|
-
*
|
|
178
|
-
* 对 `mode: 'toggle'` 的按钮**不清锁存**:`latched` 是两端共享的语义状态,
|
|
179
|
-
* 单端的 UI 可见性不该改它。需要退出锁存时显式调 `setToggle(action, false)`。
|
|
180
|
-
*/
|
|
181
|
-
setActionButtonVisible(action: string, visible: boolean): void;
|
|
182
|
-
/**
|
|
183
|
-
* 改移动端按钮文案:同一个 `interact` 按钮在门前显示「开门」、在 NPC 前显示「对话」。
|
|
184
|
-
* PC 上是 no-op —— PC 的操作提示(「按 E 开门」)属于业务 HUD,不在输入层。
|
|
185
|
-
*/
|
|
186
|
-
setActionLabel(action: string, label: string): void;
|
|
187
|
-
/** 模态面板打开 / 暂停时隐藏并复位**全部**虚拟控件,避免触点残留与按键卡住 */
|
|
188
|
-
setControlsVisible(visible: boolean): void;
|
|
189
|
-
dispose(): void;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface InputLayerOptions {
|
|
193
|
-
/** 游戏容器(模板 `#game`);`data-platform` 写在它上面 */
|
|
194
|
-
container: HTMLElement;
|
|
195
|
-
/**
|
|
196
|
-
* 分辨率适配 skill 的 UI stage 句柄(`src/display/ui-stage.ts`)。
|
|
197
|
-
* 虚拟控件按设计像素摆放,尺寸换算取这里的 `scale`(= 短边锁定模型解出的
|
|
198
|
-
* viewport 短边 / 1080
|
|
199
|
-
*
|
|
200
|
-
*/
|
|
201
|
-
ui: UiStageHandle;
|
|
202
|
-
/** PC 鼠标视角的监听目标(canvas);键盘监听目标是 window —— canvas 默认不可聚焦,收不到 keydown */
|
|
203
|
-
canvas: HTMLCanvasElement;
|
|
204
|
-
config?: InputConfigFile;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const DEFAULT_AXIS = 'move';
|
|
208
|
-
const DEFAULT_LOOK = 'look';
|
|
209
|
-
|
|
210
|
-
export function createInputLayer(options: InputLayerOptions): GameInput {
|
|
211
|
-
const { container, ui, canvas } = options;
|
|
212
|
-
const config = options.config ?? (inputConfig as unknown as InputConfigFile);
|
|
213
|
-
const platform = applyPlatformAttr(container);
|
|
214
|
-
|
|
215
|
-
// ── ② 映射层 ──
|
|
216
|
-
const pcActions: Record<string, readonly string[]> = {};
|
|
217
|
-
const pcAxes: Record<string, { negative?: readonly string[]; positive?: readonly string[] }> = {};
|
|
218
|
-
const analog: Record<string, () => number> = {};
|
|
219
|
-
/** 动作 → 「当前是否按下」。PC 鼠标键与移动端虚拟按钮都汇到这里,两个平台互斥不会打架 */
|
|
220
|
-
const buttons: Record<string, () => boolean> = {};
|
|
221
|
-
const heldPointers = new Map<string, Set<number>>();
|
|
222
|
-
/** 动作 → 需要的鼠标键(`event.button` 值)。空数组表示该动作只用键盘 */
|
|
223
|
-
const pcMouse = new Map<string, number[]>();
|
|
224
|
-
/**
|
|
225
|
-
* `mode: 'toggle'` 动作的**锁存态**。键的存在与否就是「这个动作是不是 toggle 型」的判据,
|
|
226
|
-
* 所以 `latched.has(name)` 与 `latched.get(name)` 分别承担类型判定与取值,不要再存一份 Set。
|
|
227
|
-
*/
|
|
228
|
-
const latched = new Map<string, boolean>();
|
|
229
|
-
/** 本帧锁存的翻转方向(`true` = 刚打开)。用来合成 toggle 的 wasPressed / wasReleased */
|
|
230
|
-
const latchEdge = new Map<string, boolean>();
|
|
231
|
-
/** 动作 → 同步移动端按钮的锁存视觉。PC 无虚拟控件时为空 */
|
|
232
|
-
const latchVisuals = new Map<string, (on: boolean) => void>();
|
|
233
|
-
/** 按钮拖拽状态的复位钩子(隐藏控件 / dispose 时调用) */
|
|
234
|
-
const dragResets: Array<() => void> = [];
|
|
235
|
-
/** 动作 → 移动端按钮句柄。**PC 上为空**,所以两个 setter 在 PC 上天然是 no-op */
|
|
236
|
-
const mobileButtons = new Map<string, MobileButtonHandle>();
|
|
237
|
-
/** 已经报过的未知动作名。两个 setter 通常每帧调用,不去重会刷屏 */
|
|
238
|
-
const warnedUnknownActions = new Set<string>();
|
|
239
|
-
|
|
240
|
-
/** 动作名写错时两个 setter 会静默失效(PC 上本来就是 no-op,更难发现),这里报一次 */
|
|
241
|
-
const isUnknownAction = (api: string, action: string): boolean => {
|
|
242
|
-
if (config.actions?.[action]) return false;
|
|
243
|
-
if (!warnedUnknownActions.has(action)) {
|
|
244
|
-
warnedUnknownActions.add(action);
|
|
245
|
-
console.warn(`[input] ${api}("${action}"):该动作不在 input-config.json 的 actions 里`);
|
|
246
|
-
}
|
|
247
|
-
return true;
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
for (const [name, action] of Object.entries(config.actions ?? {})) {
|
|
251
|
-
// 鼠标键不能交给 keyboard(它只认 KeyboardEvent.code),必须在这里分流
|
|
252
|
-
const split = splitPcBinding(action.pc);
|
|
253
|
-
pcActions[name] = split.codes;
|
|
254
|
-
if (split.mouseButtons.length > 0) pcMouse.set(name, split.mouseButtons);
|
|
255
|
-
if (action.mode === 'toggle') latched.set(name, false);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
for (const [name, axis] of Object.entries(config.axes ?? {})) {
|
|
259
|
-
// createActionInput 的轴 key 是「一个轴一个条目」,与本配置的 h/v 双键结构对齐
|
|
260
|
-
pcAxes[`${name}.h`] = axis.pc.horizontal;
|
|
261
|
-
pcAxes[`${name}.v`] = axis.pc.vertical;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// 键名写错不会有任何运行时报错(isDown 恒 false),这里把它变成显式 warn。
|
|
265
|
-
// **两个平台都校验**:移动端预览时也能发现 PC 配置的拼写错误。
|
|
266
|
-
warnSuspectKeyNames(config);
|
|
267
|
-
|
|
268
|
-
// ── ③ PC:键盘 + 鼠标视角 ──
|
|
269
|
-
// 只在 PC 装配键盘;移动端不装,避免两套输入同时改同一份状态
|
|
270
|
-
// (触屏笔记本按 (pointer: coarse) 判为 pc,用键鼠,符合「主要指针是鼠标」的直觉)。
|
|
271
|
-
const keyboard =
|
|
272
|
-
platform === 'pc'
|
|
273
|
-
? createKeyboard(window, {
|
|
274
|
-
blurTarget: window,
|
|
275
|
-
visibilityTarget: document,
|
|
276
|
-
// 阻止方向键 / 空格滚动页面,否则浏览器会吃掉按键
|
|
277
|
-
preventDefault: collectPreventDefault(config),
|
|
278
|
-
})
|
|
279
|
-
: null;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* PC 鼠标键。**右键一旦参与输入就必须吃掉 contextmenu**,否则按下右键先弹出系统菜单
|
|
283
|
-
* (`looks.*.pc.requireButton` 默认就是右键,所以有 look 通道时基本一定要吃)。
|
|
284
|
-
*/
|
|
285
|
-
const needsRightButton =
|
|
286
|
-
[...pcMouse.values()].some((list) => list.includes(2)) ||
|
|
287
|
-
Object.values(config.looks ?? {}).some((look) => pcLookRequireButton(look) === 2);
|
|
288
|
-
const mouse =
|
|
289
|
-
platform === 'pc' && (pcMouse.size > 0 || needsRightButton)
|
|
290
|
-
? createMouseButtons(canvas, { suppressContextMenu: needsRightButton })
|
|
291
|
-
: null;
|
|
292
|
-
if (mouse) {
|
|
293
|
-
for (const [action, list] of pcMouse) {
|
|
294
|
-
buttons[action] = () => list.some((button) => mouse.isDown(button));
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const lookPads = new Map<string, LookPad>();
|
|
299
|
-
if (platform === 'pc') {
|
|
300
|
-
for (const [name, look] of Object.entries(config.looks ?? {})) {
|
|
301
|
-
lookPads.set(
|
|
302
|
-
name,
|
|
303
|
-
createLookPad(canvas, {
|
|
304
|
-
pointerTypes: ['mouse'],
|
|
305
|
-
requireButton: pcLookRequireButton(look),
|
|
306
|
-
sensitivity: look.pc?.sensitivity,
|
|
307
|
-
invertY: look.pc?.invertY,
|
|
308
|
-
}),
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
// ── ③ 移动端:虚拟控件 ──
|
|
314
|
-
// 控件建在 UI stage 的 hud 层里:坐标即设计像素,缩放由 stage 的 transform 承担,
|
|
315
|
-
// 因此「半径 72 设计像素」在任何设备上的物理大小都一致。
|
|
316
|
-
let controls: HTMLElement | null = null;
|
|
317
|
-
|
|
318
|
-
if (platform === 'mobile') {
|
|
319
|
-
const root = document.createElement('div');
|
|
320
|
-
root.id = 'touch-controls';
|
|
321
|
-
|
|
322
|
-
// 视角滑动区先插入(先插入 = 命中优先级低)
|
|
323
|
-
for (const [name, look] of Object.entries(config.looks ?? {})) {
|
|
324
|
-
const zone = document.createElement('div');
|
|
325
|
-
zone.className = 'touch-look-zone';
|
|
326
|
-
zone.dataset.look = name;
|
|
327
|
-
root.appendChild(zone);
|
|
328
|
-
lookPads.set(
|
|
329
|
-
name,
|
|
330
|
-
createLookPad(zone, {
|
|
331
|
-
/**
|
|
332
|
-
* **必须带上 `'mouse'`**:桌面浏览器用 `?launchPlatform=mobile` 验收时,
|
|
333
|
-
* 指针类型仍然是 mouse。只写 `['touch', 'pen']` 会让滑动区在验收环境里完全不响应 ——
|
|
334
|
-
* 而同一形态下摇杆(`createJoystick` 认鼠标左键)和动作按钮(不筛 pointerType)都能用,
|
|
335
|
-
* 于是表现为「摇杆能推、按钮能按,唯独视角拖不动」,很容易被误判成 look 区没实现。
|
|
336
|
-
* 真机不会产生 mouse 事件,这一项对真机无影响。
|
|
337
|
-
*
|
|
338
|
-
* `requireButton: 0` 让鼠标只认左键,与 `createJoystick` 的门槛逐字一致;
|
|
339
|
-
* touch / pen 不受它约束(见 look-pad.ts 的 `allowed()`:非 mouse 直接放行)。
|
|
340
|
-
*/
|
|
341
|
-
pointerTypes: ['touch', 'pen', 'mouse'],
|
|
342
|
-
requireButton: 0,
|
|
343
|
-
sensitivity: look.mobile?.sensitivity,
|
|
344
|
-
invertY: look.mobile?.invertY,
|
|
345
|
-
deadZonePx: look.mobile?.deadZonePx,
|
|
346
|
-
}),
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
// 摇杆区(CSS
|
|
351
|
-
// 移动端推荐形态,不需要玩家去找固定摇杆的位置。
|
|
352
|
-
for (const [name, axis] of Object.entries(config.axes ?? {})) {
|
|
353
|
-
if (axis.mobile?.type !== 'joystick') {
|
|
354
|
-
console.warn(`[input] 轴 ${name} 的 mobile.type 不是 'joystick',已跳过`);
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
const zone = document.createElement('div');
|
|
358
|
-
zone.className = 'touch-stick-zone';
|
|
359
|
-
zone.dataset.axis = name;
|
|
360
|
-
const base = document.createElement('div');
|
|
361
|
-
base.className = 'touch-stick__base';
|
|
362
|
-
const thumb = document.createElement('div');
|
|
363
|
-
thumb.className = 'touch-stick__thumb';
|
|
364
|
-
base.appendChild(thumb);
|
|
365
|
-
zone.appendChild(base);
|
|
366
|
-
root.appendChild(zone);
|
|
367
|
-
|
|
368
|
-
const radius = axis.mobile.radius;
|
|
369
|
-
// 尺寸在配置里(设计像素),这里落到内联样式;CSS 只管居中与配色
|
|
370
|
-
base.style.width = `${radius * 2}px`;
|
|
371
|
-
base.style.height = `${radius * 2}px`;
|
|
372
|
-
thumb.style.width = `${radius}px`;
|
|
373
|
-
thumb.style.height = `${radius}px`;
|
|
374
|
-
const joystick = createJoystick(zone, {
|
|
375
|
-
radius,
|
|
376
|
-
deadZone: axis.mobile.deadZone ?? 0.12,
|
|
377
|
-
floating: true,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
event.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
drag?.
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
//
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
latched.
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
*
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
canvas.removeEventListener('
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
if (
|
|
696
|
-
return
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
/**
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
let
|
|
785
|
-
let
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
element
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
* **接收门槛必须与 runtime `createJoystick` 的 `down` 逐字一致**(见下面那行)。
|
|
864
|
-
* 这两个 handler 挂在同一个元素的同一个 `pointerdown` 上:joystick 负责算轴、
|
|
865
|
-
* 本函数负责摆底盘。门槛一旦不同,就会出现「摇杆能推但底盘不跟手」——
|
|
866
|
-
* 曾经这里写成 `pointerType === 'mouse'` 就 return,而 joystick 接受鼠标左键,
|
|
867
|
-
* 于是桌面用 `?launchPlatform=mobile` 验收时底盘的 left/top 从不写入,
|
|
868
|
-
* `position: absolute` 退化为静态位置 + `translate(-50%, -50%)`,
|
|
869
|
-
* **整个底盘卡在摇杆区左上角只露出右下 1/4**。这类劈叉不报错,只表现为「一半功能正常」。
|
|
870
|
-
*/
|
|
871
|
-
function followFloatingStick(zone: HTMLElement, base: HTMLElement, getScale: () => number): void {
|
|
872
|
-
zone.addEventListener('pointerdown', (event) => {
|
|
873
|
-
// 与 createJoystick 同款门槛:鼠标只认左键,touch / pen 一律接收
|
|
874
|
-
if (event.pointerType === 'mouse' && event.button !== 0) return;
|
|
875
|
-
const stage = zone.closest<HTMLElement>('#ui-stage') ?? zone;
|
|
876
|
-
const rect = stage.getBoundingClientRect();
|
|
877
|
-
const scale = getScale() || 1;
|
|
878
|
-
base.style.left = `${(event.clientX - rect.left) / scale}px`;
|
|
879
|
-
base.style.top = `${(event.clientY - rect.top) / scale}px`;
|
|
880
|
-
});
|
|
881
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 统一输入层:把 PC 键鼠与移动端虚拟控件收敛到**同一套语义接口**。
|
|
3
|
+
*
|
|
4
|
+
* 落盘位置:`${CRAFT_PROJECT_DIR}/src/input/input-layer.ts`
|
|
5
|
+
*
|
|
6
|
+
* Phaser 侧的用法:入口 `main.ts` 建一次(`canvas` 传 `game.canvas`),拿到 `input` 后挂到
|
|
7
|
+
* `game.registry` 或模块单例上;Scene 在 `update()` 里读语义接口。
|
|
8
|
+
* **不要用 `this.input.on('pointerdown')` 处理同一批玩法动作** —— 那是另一条输入通路,
|
|
9
|
+
* 会在 PC 与移动端上各触发一次。Phaser 的指针事件只保留给「世界内点选 / 拖拽世界物体」,
|
|
10
|
+
* 且这类交互要按 SKILL.md「四、触点仲裁」确认触点没有被虚拟控件消费。
|
|
11
|
+
*
|
|
12
|
+
* 三层职责,不要混:
|
|
13
|
+
* ① 语义层(本文件的对外接口):`isDown('jump')` / `horizontal()` / `lookDelta()`。
|
|
14
|
+
* **业务只认这一层**,因此 PC 与移动端是同一条代码路径,不需要 `if (mobile)`。
|
|
15
|
+
* ② 映射层:`input-config.json` 里每个条目同时给出 `pc`(按键名)与 `mobile`(控件描述)。
|
|
16
|
+
* 两者映射到同一个语义 key;缺一边等于该平台玩不了。
|
|
17
|
+
* ③ 控件层:PC 用键盘事件;移动端用 DOM 虚拟控件(摇杆 / 动作按钮 / 视角滑动区)。
|
|
18
|
+
*
|
|
19
|
+
* 触点仲裁:**button > joystick > look**。这里靠 DOM 命中测试天然成立 ——
|
|
20
|
+
* 动作按钮是滑动区**之后**插入的兄弟节点(同 z-index 下后插入者优先命中),
|
|
21
|
+
* 摇杆区与滑动区是互不重叠的左下区域与右半屏。一次 pointerdown 只可能落在其中一个元素上,
|
|
22
|
+
* 且 `setPointerCapture` 之后该指针的后续事件只发给它 —— 等价于「一根手指自 down 起归属唯一控件」。
|
|
23
|
+
* 由此得到两条可以直接依赖的性质:
|
|
24
|
+
* - 落在动作按钮上的触点**不会**驱动视角,无需给滑动区配排除区;
|
|
25
|
+
* - 拖摇杆时手指划过按钮**不会**误触发按钮(触点已被摇杆捕获)。
|
|
26
|
+
*/
|
|
27
|
+
import {
|
|
28
|
+
createActionInput,
|
|
29
|
+
createJoystick,
|
|
30
|
+
createKeyboard,
|
|
31
|
+
} from './input-primitives';
|
|
32
|
+
import { applyPlatformAttr } from './input-platform';
|
|
33
|
+
import type { InputPlatform } from './input-platform';
|
|
34
|
+
import { createLookPad } from './look-pad';
|
|
35
|
+
import type { LookPad } from './look-pad';
|
|
36
|
+
import type { UiStageHandle } from '../display/ui-stage';
|
|
37
|
+
import inputConfig from './input-config.json';
|
|
38
|
+
|
|
39
|
+
// ─────────────────────── 配置结构(与 input-config.json 一一对应) ───────────────────────
|
|
40
|
+
|
|
41
|
+
export interface InputAxisConfig {
|
|
42
|
+
pc: {
|
|
43
|
+
/** 键位名见 SKILL.md「PC 键位名」 */
|
|
44
|
+
horizontal: { negative: readonly string[]; positive: readonly string[] };
|
|
45
|
+
vertical: { negative: readonly string[]; positive: readonly string[] };
|
|
46
|
+
};
|
|
47
|
+
mobile: {
|
|
48
|
+
type: 'joystick';
|
|
49
|
+
/** 有效拖动半径(设计像素)。**不得小于 40** */
|
|
50
|
+
radius: number;
|
|
51
|
+
/** 死区比例 [0,1),默认 0.12 */
|
|
52
|
+
deadZone?: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface InputActionConfig {
|
|
57
|
+
/**
|
|
58
|
+
* PC 触发源。两类 token,可混写:
|
|
59
|
+
* - 键盘:逐字的 `KeyboardEvent.code`(`KeyJ` / `Space` / `ArrowUp`);
|
|
60
|
+
* - 鼠标键:`Mouse0`(左)/ `Mouse1`(中)/ `Mouse2`(右)。
|
|
61
|
+
* 鼠标键**不是** `event.code`,由本文件转成 `createActionInput({ buttons })` 回调,
|
|
62
|
+
* 与键盘是 OR 关系、边沿检测同一条路径。写错的键名会打 warn(见 `warnSuspectKeyNames`)。
|
|
63
|
+
*/
|
|
64
|
+
pc: readonly string[];
|
|
65
|
+
/**
|
|
66
|
+
* 触发语义,默认 `'hold'`。
|
|
67
|
+
* - `'hold'`:`isDown()` 跟随物理按下(开火、加速、格挡);
|
|
68
|
+
* - `'toggle'`:**按一次翻转一次**,`isDown()` 返回锁存态(瞄准镜、自动奔跑、静步)。
|
|
69
|
+
* 此时 `wasPressed()` / `wasReleased()` 报的是**锁存开 / 关**的那一帧,
|
|
70
|
+
* 不是手指按下 / 抬起 —— 业务不需要自己存 boolean 做翻转。
|
|
71
|
+
*
|
|
72
|
+
* **写在 action 级而不是 `mobile` 里**:PC 与移动端必须同为 toggle,
|
|
73
|
+
* 否则 `isDown()` 在一个平台是瞬时、另一个平台是锁存,业务被迫分平台写两套。
|
|
74
|
+
*/
|
|
75
|
+
mode?: 'hold' | 'toggle';
|
|
76
|
+
mobile: {
|
|
77
|
+
type: 'button';
|
|
78
|
+
/** 按钮文字(图标走 CSS background,见 touch-controls.css) */
|
|
79
|
+
label: string;
|
|
80
|
+
/** 中心 X。**负数从右边缘算起** */
|
|
81
|
+
x: number;
|
|
82
|
+
/** 中心 Y。**负数从下边缘算起** */
|
|
83
|
+
y: number;
|
|
84
|
+
/** 触控半径(设计像素)。**不得小于 40** */
|
|
85
|
+
radius: number;
|
|
86
|
+
/**
|
|
87
|
+
* 建出来就先隐藏。**上下文交互按钮**(靠近才出现的「开门 / 拾取 / 对话」)写 `true`,
|
|
88
|
+
* 之后由业务用 `setActionButtonVisible(action, true)` 放出来。
|
|
89
|
+
* 不写的话开局会先闪一下按钮,再被业务第一帧的 `setActionButtonVisible(false)` 收掉。
|
|
90
|
+
*/
|
|
91
|
+
hidden?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 按住本按钮拖动时,把指针位移并入 look 通道 ——
|
|
94
|
+
* 需求形态是「开火按钮按下即持续开火,拖拽可控制方向」。不写则拖动不影响视角。
|
|
95
|
+
*
|
|
96
|
+
* 前提是同名 look 通道已在 `looks` 里声明;缺失会打 warn 并忽略。
|
|
97
|
+
*/
|
|
98
|
+
drag?: {
|
|
99
|
+
/** 注入哪个 look 通道,默认 `'look'` */
|
|
100
|
+
look?: string;
|
|
101
|
+
/**
|
|
102
|
+
* **相对该 look 通道 `mobile.sensitivity` 的倍率**,默认 1。
|
|
103
|
+
* 位移先乘这里、再进 LookPad 乘通道灵敏度,所以两条路的 `invertY` 天然一致。
|
|
104
|
+
* 按钮拖拽通常要比滑动区更钝(拇指还要兼顾按住),建议 0.5~0.8。
|
|
105
|
+
*/
|
|
106
|
+
sensitivity?: number;
|
|
107
|
+
/**
|
|
108
|
+
* 起手死区(CSS 像素),默认 0。
|
|
109
|
+
* 按钮本身已是明确的按下意图,一般不需要再过滤;只有按钮很小、按下时容易带位移才调大。
|
|
110
|
+
*/
|
|
111
|
+
deadZonePx?: number;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface InputLookConfig {
|
|
117
|
+
/**
|
|
118
|
+
* PC:鼠标位移。`requireButton=2` 按住右键拖动转向(**字段缺省时的默认值**);
|
|
119
|
+
* `0`=左键;**显式写 `null` = 不限制**,移动鼠标即转向(FPS 标准操作)。
|
|
120
|
+
* `null` 与「不写」语义不同,读取一律走 `pcLookRequireButton()`,不要用 `??`。
|
|
121
|
+
*/
|
|
122
|
+
pc: { requireButton?: number | null; sensitivity?: number; invertY?: boolean };
|
|
123
|
+
/** 移动端:滑动区几何由 CSS 决定(默认右半屏),不在配置里写坐标 */
|
|
124
|
+
mobile: { sensitivity?: number; invertY?: boolean; deadZonePx?: number };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface InputConfigFile {
|
|
128
|
+
axes: Record<string, InputAxisConfig>;
|
|
129
|
+
actions: Record<string, InputActionConfig>;
|
|
130
|
+
/** 视角通道:**只在玩家需要主动控制镜头(FPS/TPS)时声明**,其它品类整段不写 */
|
|
131
|
+
looks?: Record<string, InputLookConfig>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ─────────────────────── 对外接口 ───────────────────────
|
|
135
|
+
|
|
136
|
+
/** 轴上两根键的极性统一为「右正 X、下正 Y」,与键盘一致;世界方向转换在消费侧统一做 */
|
|
137
|
+
export interface GameInput {
|
|
138
|
+
readonly platform: InputPlatform;
|
|
139
|
+
/** 每帧一次,**必须在所有消费者之前**调用 */
|
|
140
|
+
sample(): void;
|
|
141
|
+
/**
|
|
142
|
+
* 直接读键盘边沿时需要,在所有消费者之后调用。
|
|
143
|
+
* 只用本接口的 `wasPressed/wasReleased` 时,可在 `sample()` 之后立即调用。
|
|
144
|
+
*/
|
|
145
|
+
endFrame(): void;
|
|
146
|
+
/** `mode: 'toggle'` 的动作返回**锁存态**(按一次开、再按一次关),不是物理按下 */
|
|
147
|
+
isDown(action: string): boolean;
|
|
148
|
+
/** toggle 型动作报的是**锁存打开**的那一帧,不是手指按下 */
|
|
149
|
+
wasPressed(action: string): boolean;
|
|
150
|
+
/** toggle 型动作报的是**锁存关闭**的那一帧,不是手指抬起 */
|
|
151
|
+
wasReleased(action: string): boolean;
|
|
152
|
+
/**
|
|
153
|
+
* 手动设置 `mode: 'toggle'` 动作的锁存态:死亡 / 换弹 / 切武器时强制退出瞄准。
|
|
154
|
+
* 在 `sample()` 之后调用 —— 本帧的 `wasPressed` / `wasReleased` 会反映这次变化,
|
|
155
|
+
* 下一次 `sample()` 清掉。对 `'hold'` 型动作调用会打 warn 并忽略。
|
|
156
|
+
*/
|
|
157
|
+
setToggle(action: string, on: boolean): void;
|
|
158
|
+
/** 语义轴(`move` / …):右正 X、下正的 [-1,1] */
|
|
159
|
+
horizontal(axis?: string): number;
|
|
160
|
+
vertical(axis?: string): number;
|
|
161
|
+
/** 消费型:读一次即清零,**每帧只能读一次** */
|
|
162
|
+
lookDelta(look?: string): { x: number; y: number };
|
|
163
|
+
isLookActive(look?: string): boolean;
|
|
164
|
+
/** 把外部位移并入 look 通道(如「开火按钮按住拖拽也能控向」) */
|
|
165
|
+
feedLookDelta(dx: number, dy: number, look?: string): void;
|
|
166
|
+
/**
|
|
167
|
+
* 显隐**单个**移动端虚拟按钮 —— 上下文交互按钮(靠近宝箱才出现的「开门 / 拾取」)用这个。
|
|
168
|
+
* 可以每帧无脑调用,值没变时不做任何事。
|
|
169
|
+
*
|
|
170
|
+
* **只管移动端 UI,不屏蔽 PC 键位。** PC 上没有虚拟控件,这里是 no-op;
|
|
171
|
+
* 业务照常自己判上下文 —— `if (target && input.wasPressed('interact'))` ——
|
|
172
|
+
* 这一条判断两端共用,不构成平台分支。
|
|
173
|
+
*
|
|
174
|
+
* **不要自己去改 `.touch-btn` 的 DOM**:隐藏时必须同时清掉按钮上残留的触点,
|
|
175
|
+
* 否则 `display: none` 不保证释放指针捕获(元素仍在文档里),`pointerup` 可能永远收不到,
|
|
176
|
+
* `isDown()` 会永久为真(表现为「按钮消失了却一直在开火」)。
|
|
177
|
+
*
|
|
178
|
+
* 对 `mode: 'toggle'` 的按钮**不清锁存**:`latched` 是两端共享的语义状态,
|
|
179
|
+
* 单端的 UI 可见性不该改它。需要退出锁存时显式调 `setToggle(action, false)`。
|
|
180
|
+
*/
|
|
181
|
+
setActionButtonVisible(action: string, visible: boolean): void;
|
|
182
|
+
/**
|
|
183
|
+
* 改移动端按钮文案:同一个 `interact` 按钮在门前显示「开门」、在 NPC 前显示「对话」。
|
|
184
|
+
* PC 上是 no-op —— PC 的操作提示(「按 E 开门」)属于业务 HUD,不在输入层。
|
|
185
|
+
*/
|
|
186
|
+
setActionLabel(action: string, label: string): void;
|
|
187
|
+
/** 模态面板打开 / 暂停时隐藏并复位**全部**虚拟控件,避免触点残留与按键卡住 */
|
|
188
|
+
setControlsVisible(visible: boolean): void;
|
|
189
|
+
dispose(): void;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface InputLayerOptions {
|
|
193
|
+
/** 游戏容器(模板 `#game`);`data-platform` 写在它上面 */
|
|
194
|
+
container: HTMLElement;
|
|
195
|
+
/**
|
|
196
|
+
* 分辨率适配 skill 的 UI stage 句柄(`src/display/ui-stage.ts`)。
|
|
197
|
+
* 虚拟控件按设计像素摆放,尺寸换算取这里的 `scale`(= 短边锁定模型解出的
|
|
198
|
+
* viewport 短边 / 1080),**不要按固定设计尺寸另算 contain 缩放** ——
|
|
199
|
+
* 长边伸缩下会与 stage 实际缩放不一致。
|
|
200
|
+
*/
|
|
201
|
+
ui: UiStageHandle;
|
|
202
|
+
/** PC 鼠标视角的监听目标(canvas);键盘监听目标是 window —— canvas 默认不可聚焦,收不到 keydown */
|
|
203
|
+
canvas: HTMLCanvasElement;
|
|
204
|
+
config?: InputConfigFile;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const DEFAULT_AXIS = 'move';
|
|
208
|
+
const DEFAULT_LOOK = 'look';
|
|
209
|
+
|
|
210
|
+
export function createInputLayer(options: InputLayerOptions): GameInput {
|
|
211
|
+
const { container, ui, canvas } = options;
|
|
212
|
+
const config = options.config ?? (inputConfig as unknown as InputConfigFile);
|
|
213
|
+
const platform = applyPlatformAttr(container);
|
|
214
|
+
|
|
215
|
+
// ── ② 映射层 ──
|
|
216
|
+
const pcActions: Record<string, readonly string[]> = {};
|
|
217
|
+
const pcAxes: Record<string, { negative?: readonly string[]; positive?: readonly string[] }> = {};
|
|
218
|
+
const analog: Record<string, () => number> = {};
|
|
219
|
+
/** 动作 → 「当前是否按下」。PC 鼠标键与移动端虚拟按钮都汇到这里,两个平台互斥不会打架 */
|
|
220
|
+
const buttons: Record<string, () => boolean> = {};
|
|
221
|
+
const heldPointers = new Map<string, Set<number>>();
|
|
222
|
+
/** 动作 → 需要的鼠标键(`event.button` 值)。空数组表示该动作只用键盘 */
|
|
223
|
+
const pcMouse = new Map<string, number[]>();
|
|
224
|
+
/**
|
|
225
|
+
* `mode: 'toggle'` 动作的**锁存态**。键的存在与否就是「这个动作是不是 toggle 型」的判据,
|
|
226
|
+
* 所以 `latched.has(name)` 与 `latched.get(name)` 分别承担类型判定与取值,不要再存一份 Set。
|
|
227
|
+
*/
|
|
228
|
+
const latched = new Map<string, boolean>();
|
|
229
|
+
/** 本帧锁存的翻转方向(`true` = 刚打开)。用来合成 toggle 的 wasPressed / wasReleased */
|
|
230
|
+
const latchEdge = new Map<string, boolean>();
|
|
231
|
+
/** 动作 → 同步移动端按钮的锁存视觉。PC 无虚拟控件时为空 */
|
|
232
|
+
const latchVisuals = new Map<string, (on: boolean) => void>();
|
|
233
|
+
/** 按钮拖拽状态的复位钩子(隐藏控件 / dispose 时调用) */
|
|
234
|
+
const dragResets: Array<() => void> = [];
|
|
235
|
+
/** 动作 → 移动端按钮句柄。**PC 上为空**,所以两个 setter 在 PC 上天然是 no-op */
|
|
236
|
+
const mobileButtons = new Map<string, MobileButtonHandle>();
|
|
237
|
+
/** 已经报过的未知动作名。两个 setter 通常每帧调用,不去重会刷屏 */
|
|
238
|
+
const warnedUnknownActions = new Set<string>();
|
|
239
|
+
|
|
240
|
+
/** 动作名写错时两个 setter 会静默失效(PC 上本来就是 no-op,更难发现),这里报一次 */
|
|
241
|
+
const isUnknownAction = (api: string, action: string): boolean => {
|
|
242
|
+
if (config.actions?.[action]) return false;
|
|
243
|
+
if (!warnedUnknownActions.has(action)) {
|
|
244
|
+
warnedUnknownActions.add(action);
|
|
245
|
+
console.warn(`[input] ${api}("${action}"):该动作不在 input-config.json 的 actions 里`);
|
|
246
|
+
}
|
|
247
|
+
return true;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
for (const [name, action] of Object.entries(config.actions ?? {})) {
|
|
251
|
+
// 鼠标键不能交给 keyboard(它只认 KeyboardEvent.code),必须在这里分流
|
|
252
|
+
const split = splitPcBinding(action.pc);
|
|
253
|
+
pcActions[name] = split.codes;
|
|
254
|
+
if (split.mouseButtons.length > 0) pcMouse.set(name, split.mouseButtons);
|
|
255
|
+
if (action.mode === 'toggle') latched.set(name, false);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
for (const [name, axis] of Object.entries(config.axes ?? {})) {
|
|
259
|
+
// createActionInput 的轴 key 是「一个轴一个条目」,与本配置的 h/v 双键结构对齐
|
|
260
|
+
pcAxes[`${name}.h`] = axis.pc.horizontal;
|
|
261
|
+
pcAxes[`${name}.v`] = axis.pc.vertical;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 键名写错不会有任何运行时报错(isDown 恒 false),这里把它变成显式 warn。
|
|
265
|
+
// **两个平台都校验**:移动端预览时也能发现 PC 配置的拼写错误。
|
|
266
|
+
warnSuspectKeyNames(config);
|
|
267
|
+
|
|
268
|
+
// ── ③ PC:键盘 + 鼠标视角 ──
|
|
269
|
+
// 只在 PC 装配键盘;移动端不装,避免两套输入同时改同一份状态
|
|
270
|
+
// (触屏笔记本按 (pointer: coarse) 判为 pc,用键鼠,符合「主要指针是鼠标」的直觉)。
|
|
271
|
+
const keyboard =
|
|
272
|
+
platform === 'pc'
|
|
273
|
+
? createKeyboard(window, {
|
|
274
|
+
blurTarget: window,
|
|
275
|
+
visibilityTarget: document,
|
|
276
|
+
// 阻止方向键 / 空格滚动页面,否则浏览器会吃掉按键
|
|
277
|
+
preventDefault: collectPreventDefault(config),
|
|
278
|
+
})
|
|
279
|
+
: null;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* PC 鼠标键。**右键一旦参与输入就必须吃掉 contextmenu**,否则按下右键先弹出系统菜单
|
|
283
|
+
* (`looks.*.pc.requireButton` 默认就是右键,所以有 look 通道时基本一定要吃)。
|
|
284
|
+
*/
|
|
285
|
+
const needsRightButton =
|
|
286
|
+
[...pcMouse.values()].some((list) => list.includes(2)) ||
|
|
287
|
+
Object.values(config.looks ?? {}).some((look) => pcLookRequireButton(look) === 2);
|
|
288
|
+
const mouse =
|
|
289
|
+
platform === 'pc' && (pcMouse.size > 0 || needsRightButton)
|
|
290
|
+
? createMouseButtons(canvas, { suppressContextMenu: needsRightButton })
|
|
291
|
+
: null;
|
|
292
|
+
if (mouse) {
|
|
293
|
+
for (const [action, list] of pcMouse) {
|
|
294
|
+
buttons[action] = () => list.some((button) => mouse.isDown(button));
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const lookPads = new Map<string, LookPad>();
|
|
299
|
+
if (platform === 'pc') {
|
|
300
|
+
for (const [name, look] of Object.entries(config.looks ?? {})) {
|
|
301
|
+
lookPads.set(
|
|
302
|
+
name,
|
|
303
|
+
createLookPad(canvas, {
|
|
304
|
+
pointerTypes: ['mouse'],
|
|
305
|
+
requireButton: pcLookRequireButton(look),
|
|
306
|
+
sensitivity: look.pc?.sensitivity,
|
|
307
|
+
invertY: look.pc?.invertY,
|
|
308
|
+
}),
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// ── ③ 移动端:虚拟控件 ──
|
|
314
|
+
// 控件建在 UI stage 的 hud 层里:坐标即设计像素,缩放由 stage 的 transform 承担,
|
|
315
|
+
// 因此「半径 72 设计像素」在任何设备上的物理大小都一致。
|
|
316
|
+
let controls: HTMLElement | null = null;
|
|
317
|
+
|
|
318
|
+
if (platform === 'mobile') {
|
|
319
|
+
const root = document.createElement('div');
|
|
320
|
+
root.id = 'touch-controls';
|
|
321
|
+
|
|
322
|
+
// 视角滑动区先插入(先插入 = 命中优先级低)
|
|
323
|
+
for (const [name, look] of Object.entries(config.looks ?? {})) {
|
|
324
|
+
const zone = document.createElement('div');
|
|
325
|
+
zone.className = 'touch-look-zone';
|
|
326
|
+
zone.dataset.look = name;
|
|
327
|
+
root.appendChild(zone);
|
|
328
|
+
lookPads.set(
|
|
329
|
+
name,
|
|
330
|
+
createLookPad(zone, {
|
|
331
|
+
/**
|
|
332
|
+
* **必须带上 `'mouse'`**:桌面浏览器用 `?launchPlatform=mobile` 验收时,
|
|
333
|
+
* 指针类型仍然是 mouse。只写 `['touch', 'pen']` 会让滑动区在验收环境里完全不响应 ——
|
|
334
|
+
* 而同一形态下摇杆(`createJoystick` 认鼠标左键)和动作按钮(不筛 pointerType)都能用,
|
|
335
|
+
* 于是表现为「摇杆能推、按钮能按,唯独视角拖不动」,很容易被误判成 look 区没实现。
|
|
336
|
+
* 真机不会产生 mouse 事件,这一项对真机无影响。
|
|
337
|
+
*
|
|
338
|
+
* `requireButton: 0` 让鼠标只认左键,与 `createJoystick` 的门槛逐字一致;
|
|
339
|
+
* touch / pen 不受它约束(见 look-pad.ts 的 `allowed()`:非 mouse 直接放行)。
|
|
340
|
+
*/
|
|
341
|
+
pointerTypes: ['touch', 'pen', 'mouse'],
|
|
342
|
+
requireButton: 0,
|
|
343
|
+
sensitivity: look.mobile?.sensitivity,
|
|
344
|
+
invertY: look.mobile?.invertY,
|
|
345
|
+
deadZonePx: look.mobile?.deadZonePx,
|
|
346
|
+
}),
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// 摇杆区(CSS 定为左侧 50% 宽、下方 65% 高)。范式实现为**浮动摇杆**(手指落点即圆心):
|
|
351
|
+
// 移动端推荐形态,不需要玩家去找固定摇杆的位置。
|
|
352
|
+
for (const [name, axis] of Object.entries(config.axes ?? {})) {
|
|
353
|
+
if (axis.mobile?.type !== 'joystick') {
|
|
354
|
+
console.warn(`[input] 轴 ${name} 的 mobile.type 不是 'joystick',已跳过`);
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
357
|
+
const zone = document.createElement('div');
|
|
358
|
+
zone.className = 'touch-stick-zone';
|
|
359
|
+
zone.dataset.axis = name;
|
|
360
|
+
const base = document.createElement('div');
|
|
361
|
+
base.className = 'touch-stick__base';
|
|
362
|
+
const thumb = document.createElement('div');
|
|
363
|
+
thumb.className = 'touch-stick__thumb';
|
|
364
|
+
base.appendChild(thumb);
|
|
365
|
+
zone.appendChild(base);
|
|
366
|
+
root.appendChild(zone);
|
|
367
|
+
|
|
368
|
+
const radius = axis.mobile.radius;
|
|
369
|
+
// 尺寸在配置里(设计像素),这里落到内联样式;CSS 只管居中与配色
|
|
370
|
+
base.style.width = `${radius * 2}px`;
|
|
371
|
+
base.style.height = `${radius * 2}px`;
|
|
372
|
+
thumb.style.width = `${radius}px`;
|
|
373
|
+
thumb.style.height = `${radius}px`;
|
|
374
|
+
const joystick = createJoystick(zone, {
|
|
375
|
+
radius,
|
|
376
|
+
deadZone: axis.mobile.deadZone ?? 0.12,
|
|
377
|
+
floating: true,
|
|
378
|
+
onStart: (origin) => {
|
|
379
|
+
// base 相对 zone 定位;不能用 stage 原点,否则区域下移会产生偏移。
|
|
380
|
+
const rect = zone.getBoundingClientRect();
|
|
381
|
+
base.style.left = `${(origin.x - rect.left) / ui.scale}px`;
|
|
382
|
+
base.style.top = `${(origin.y - rect.top) / ui.scale}px`;
|
|
383
|
+
},
|
|
384
|
+
// radius 按设计像素给,这里换算成实际 CSS 像素
|
|
385
|
+
scale: () => ui.scale,
|
|
386
|
+
blurTarget: window,
|
|
387
|
+
onChange: (value) => {
|
|
388
|
+
// 居中位移与摇杆位移写进同一个 transform,避免两处争抢(CSS 里不再写 thumb 的 transform)
|
|
389
|
+
thumb.style.transform =
|
|
390
|
+
`translate(calc(-50% + ${value.x * radius * 0.6}px), calc(-50% + ${value.y * radius * 0.6}px))`;
|
|
391
|
+
base.classList.toggle('is-active', value.active);
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
analog[`${name}.h`] = () => joystick.value().x;
|
|
397
|
+
// 摇杆「下正 Y」与键盘 vertical(负向=W/上)极性一致,**不要在移动端单独取反**
|
|
398
|
+
analog[`${name}.v`] = () => joystick.value().y;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// 动作按钮最后插入:同 z-index 下后插入者优先命中 → **button > look** 成立
|
|
402
|
+
for (const [action, definition] of Object.entries(config.actions ?? {})) {
|
|
403
|
+
const mobile = definition.mobile;
|
|
404
|
+
if (mobile?.type !== 'button') {
|
|
405
|
+
console.warn(`[input] 动作 ${action} 的 mobile.type 不是 'button',已跳过`);
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
const button = document.createElement('button');
|
|
409
|
+
button.type = 'button';
|
|
410
|
+
button.className = 'touch-btn';
|
|
411
|
+
button.dataset.action = action;
|
|
412
|
+
button.textContent = mobile.label;
|
|
413
|
+
// 负值从右 / 下边缘算起:用 right / bottom 表达,转屏与改比例后**不需要重算**
|
|
414
|
+
applyEdgeAnchors(button, mobile);
|
|
415
|
+
root.appendChild(button);
|
|
416
|
+
|
|
417
|
+
const pointers = new Set<number>();
|
|
418
|
+
heldPointers.set(action, pointers);
|
|
419
|
+
const sync = (): void => {
|
|
420
|
+
button.classList.toggle('is-pressed', pointers.size > 0);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
if (latched.has(action)) {
|
|
424
|
+
// toggle 按钮的「亮」= 锁存开启,与手指是否还按着无关,所以是独立的 class。
|
|
425
|
+
// `.is-latched` 在 CSS 里必须排在 `.is-pressed` 之后才能赢样式(同特异度后来者胜)。
|
|
426
|
+
button.classList.add('is-toggle');
|
|
427
|
+
latchVisuals.set(action, (on) => button.classList.toggle('is-latched', on));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// 「按住持续开火 + 拖拽控向」:拖拽量并入 look 通道,业务侧仍只读一个 lookDelta()
|
|
431
|
+
const drag = mobile.drag
|
|
432
|
+
? createButtonDrag(button, action, mobile.drag, () =>
|
|
433
|
+
lookPads.get(mobile.drag?.look ?? DEFAULT_LOOK),
|
|
434
|
+
)
|
|
435
|
+
: null;
|
|
436
|
+
if (drag) dragResets.push(drag.reset);
|
|
437
|
+
|
|
438
|
+
button.addEventListener('pointerdown', (event) => {
|
|
439
|
+
// 捕获失败(指针已失效)不致命:后续 move 由元素自身命中的事件兜底
|
|
440
|
+
try {
|
|
441
|
+
button.setPointerCapture(event.pointerId);
|
|
442
|
+
} catch {
|
|
443
|
+
/* ignore */
|
|
444
|
+
}
|
|
445
|
+
pointers.add(event.pointerId);
|
|
446
|
+
// 捕获之后手指拖出按钮外仍归属本按钮:这既让「按住不放继续开火」成立,
|
|
447
|
+
// 也让 pointermove 继续发给按钮,拖拽控向才有事件可用
|
|
448
|
+
drag?.begin(event);
|
|
449
|
+
sync();
|
|
450
|
+
event.preventDefault();
|
|
451
|
+
});
|
|
452
|
+
const release = (event: PointerEvent): void => {
|
|
453
|
+
drag?.end(event);
|
|
454
|
+
if (!pointers.delete(event.pointerId)) return;
|
|
455
|
+
sync();
|
|
456
|
+
};
|
|
457
|
+
button.addEventListener('pointerup', release);
|
|
458
|
+
button.addEventListener('pointercancel', release);
|
|
459
|
+
button.addEventListener('lostpointercapture', release);
|
|
460
|
+
|
|
461
|
+
buttons[action] = () => pointers.size > 0;
|
|
462
|
+
|
|
463
|
+
// 上下文交互按钮:建好即隐藏,等业务判定「够得着」时再放出来
|
|
464
|
+
if (mobile.hidden) button.classList.add('is-hidden');
|
|
465
|
+
mobileButtons.set(action, {
|
|
466
|
+
setVisible(visible) {
|
|
467
|
+
// toggle 的第二个参数是「是否加上」,返回值是加完之后 token 在不在 —— 即「现在是否隐藏」
|
|
468
|
+
const nowHidden = button.classList.toggle('is-hidden', !visible);
|
|
469
|
+
if (!nowHidden) return;
|
|
470
|
+
// 隐藏瞬间必须自己清触点:`display: none` 的元素**仍在文档里**,
|
|
471
|
+
// 规范不保证释放指针捕获,`pointerup` / `lostpointercapture` 可能永远收不到,
|
|
472
|
+
// `pointers` 会残留 → `isDown()` 永久为真。
|
|
473
|
+
pointers.clear();
|
|
474
|
+
sync();
|
|
475
|
+
drag?.reset();
|
|
476
|
+
},
|
|
477
|
+
setLabel(label) {
|
|
478
|
+
button.textContent = label;
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
ui.layer('hud').appendChild(root);
|
|
484
|
+
controls = root;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
// ── ① 语义层:按键与控件的边沿统一由 createActionInput 维护 ──
|
|
488
|
+
const actionInput = createActionInput({
|
|
489
|
+
keyboard: keyboard ?? undefined,
|
|
490
|
+
actions: pcActions,
|
|
491
|
+
axes: pcAxes,
|
|
492
|
+
buttons,
|
|
493
|
+
analog,
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
return {
|
|
497
|
+
platform,
|
|
498
|
+
sample() {
|
|
499
|
+
actionInput.sample();
|
|
500
|
+
// toggle:用**物理按下沿**翻转锁存。合成的边沿只在本帧有效,下一次 sample 清掉。
|
|
501
|
+
// 注意只改既有 key 的值,不新增 key,因此边遍历边 set 是安全的。
|
|
502
|
+
latchEdge.clear();
|
|
503
|
+
for (const [action, on] of latched) {
|
|
504
|
+
if (!actionInput.wasPressed(action)) continue;
|
|
505
|
+
const next = !on;
|
|
506
|
+
latched.set(action, next);
|
|
507
|
+
latchEdge.set(action, next);
|
|
508
|
+
latchVisuals.get(action)?.(next);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
endFrame() {
|
|
512
|
+
keyboard?.endFrame();
|
|
513
|
+
},
|
|
514
|
+
// toggle 型返回锁存态:`latched.get()` 为 false 时 `??` 不会退化到物理状态(只有 undefined 才会)
|
|
515
|
+
isDown: (action) => latched.get(action) ?? actionInput.isDown(action),
|
|
516
|
+
wasPressed: (action) =>
|
|
517
|
+
latched.has(action) ? latchEdge.get(action) === true : actionInput.wasPressed(action),
|
|
518
|
+
wasReleased: (action) =>
|
|
519
|
+
latched.has(action) ? latchEdge.get(action) === false : actionInput.wasReleased(action),
|
|
520
|
+
setToggle(action, on) {
|
|
521
|
+
if (!latched.has(action)) {
|
|
522
|
+
console.warn(`[input] 动作 ${action} 不是 mode: 'toggle',setToggle 无效`);
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (latched.get(action) === on) return;
|
|
526
|
+
latched.set(action, on);
|
|
527
|
+
latchEdge.set(action, on);
|
|
528
|
+
latchVisuals.get(action)?.(on);
|
|
529
|
+
},
|
|
530
|
+
horizontal: (axis = DEFAULT_AXIS) => actionInput.axis(`${axis}.h`),
|
|
531
|
+
vertical: (axis = DEFAULT_AXIS) => actionInput.axis(`${axis}.v`),
|
|
532
|
+
lookDelta: (look = DEFAULT_LOOK) => lookPads.get(look)?.consumeDelta() ?? { x: 0, y: 0 },
|
|
533
|
+
isLookActive: (look = DEFAULT_LOOK) => lookPads.get(look)?.isActive() ?? false,
|
|
534
|
+
feedLookDelta: (dx, dy, look = DEFAULT_LOOK) => lookPads.get(look)?.feedDelta(dx, dy),
|
|
535
|
+
setActionButtonVisible(action, visible) {
|
|
536
|
+
if (isUnknownAction('setActionButtonVisible', action)) return;
|
|
537
|
+
mobileButtons.get(action)?.setVisible(visible);
|
|
538
|
+
},
|
|
539
|
+
setActionLabel(action, label) {
|
|
540
|
+
if (isUnknownAction('setActionLabel', action)) return;
|
|
541
|
+
mobileButtons.get(action)?.setLabel(label);
|
|
542
|
+
},
|
|
543
|
+
setControlsVisible(visible) {
|
|
544
|
+
if (controls) {
|
|
545
|
+
controls.style.display = visible ? '' : 'none';
|
|
546
|
+
if (!visible) {
|
|
547
|
+
// 关闭时复位:否则手指抬起前切走会留下「一直在按」的残留状态
|
|
548
|
+
for (const pad of lookPads.values()) pad.reset();
|
|
549
|
+
for (const reset of dragResets) reset();
|
|
550
|
+
for (const pointers of heldPointers.values()) pointers.clear();
|
|
551
|
+
for (const button of controls.querySelectorAll<HTMLElement>('.touch-btn')) {
|
|
552
|
+
// 只清按下态:`is-hidden` 是单个按钮的**上下文可用性**,由业务用
|
|
553
|
+
// `setActionButtonVisible` 维护,恢复控件时不能把它一起抹掉
|
|
554
|
+
// (否则关掉暂停面板,所有上下文按钮会一起冒出来)
|
|
555
|
+
button.classList.remove('is-pressed');
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
// PC 上没有虚拟控件,但同样要清掉按键与鼠标键状态:
|
|
560
|
+
// 模态面板打开时不应该角色还在走,也不应该「一直在开火」
|
|
561
|
+
if (!visible) {
|
|
562
|
+
keyboard?.clear();
|
|
563
|
+
mouse?.clear();
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
dispose() {
|
|
567
|
+
for (const reset of dragResets) reset();
|
|
568
|
+
dragResets.length = 0;
|
|
569
|
+
latched.clear();
|
|
570
|
+
latchEdge.clear();
|
|
571
|
+
latchVisuals.clear();
|
|
572
|
+
mobileButtons.clear();
|
|
573
|
+
warnedUnknownActions.clear();
|
|
574
|
+
for (const pad of lookPads.values()) pad.dispose();
|
|
575
|
+
lookPads.clear();
|
|
576
|
+
keyboard?.dispose();
|
|
577
|
+
mouse?.dispose();
|
|
578
|
+
actionInput.reset();
|
|
579
|
+
controls?.remove();
|
|
580
|
+
controls = null;
|
|
581
|
+
},
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// ─────────────────────── 内部工具 ───────────────────────
|
|
586
|
+
|
|
587
|
+
/** 单个移动端按钮的运行时句柄。只有移动端会建,PC 上这张表是空的 */
|
|
588
|
+
interface MobileButtonHandle {
|
|
589
|
+
setVisible(visible: boolean): void;
|
|
590
|
+
setLabel(label: string): void;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* PC look 通道的鼠标键门槛。**不要改成 `?? 2`** —— `??` 对 `null` 也生效,
|
|
595
|
+
* 会把配置里显式写的 `"requireButton": null`(语义:不限制,移动鼠标即转向,
|
|
596
|
+
* FPS/TPS 在 PC 上的标准操作)强制成右键,表现为「视角必须按住右键才能转」。
|
|
597
|
+
* 只有「字段缺省」(`undefined`) 才落到默认的右键。
|
|
598
|
+
* 这个函数是该语义的唯一出口,`needsRightButton` 的 contextmenu 判断也必须走它,
|
|
599
|
+
* 否则配 `null` 时会误判成「用了右键」而多抑制一次右键菜单。
|
|
600
|
+
*/
|
|
601
|
+
function pcLookRequireButton(look: InputLookConfig): number | null {
|
|
602
|
+
const required = look.pc?.requireButton;
|
|
603
|
+
return required === undefined ? 2 : required;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/** 鼠标键 token:`Mouse0` = 左键、`Mouse1` = 中键、`Mouse2` = 右键(对应 `event.button`) */
|
|
607
|
+
const MOUSE_TOKEN = /^Mouse([0-4])$/;
|
|
608
|
+
|
|
609
|
+
/** 把 `pc` 数组拆成键盘 code 与鼠标键两组。鼠标键不能进 keyboard,它只认 `event.code` */
|
|
610
|
+
function splitPcBinding(names: readonly string[]): { codes: string[]; mouseButtons: number[] } {
|
|
611
|
+
const codes: string[] = [];
|
|
612
|
+
const mouseButtons: number[] = [];
|
|
613
|
+
for (const name of names) {
|
|
614
|
+
const matched = MOUSE_TOKEN.exec(name);
|
|
615
|
+
if (matched) mouseButtons.push(Number(matched[1]));
|
|
616
|
+
else codes.push(name);
|
|
617
|
+
}
|
|
618
|
+
return { codes, mouseButtons };
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface MouseButtons {
|
|
622
|
+
isDown(button: number): boolean;
|
|
623
|
+
clear(): void;
|
|
624
|
+
dispose(): void;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* PC 鼠标键状态。只产出**状态量**,边沿(`wasPressed` / `wasReleased`)仍由
|
|
629
|
+
* `createActionInput` 统一算 —— 与键盘、移动端虚拟按钮走同一条路径,业务不需要区分来源。
|
|
630
|
+
*
|
|
631
|
+
* 两个必须这么写的点:
|
|
632
|
+
* 1. **抬起监听挂在 window 上**:鼠标按住后移出 canvas 再松开,canvas 收不到 `pointerup`,
|
|
633
|
+
* 状态会永久卡在「按下」(表现为松手后还在持续开火)。
|
|
634
|
+
* 2. **失焦 / 切标签页一律清空**:期间的抬起事件收不到,回来时状态不可信。
|
|
635
|
+
*/
|
|
636
|
+
function createMouseButtons(
|
|
637
|
+
canvas: HTMLElement,
|
|
638
|
+
options: { suppressContextMenu: boolean },
|
|
639
|
+
): MouseButtons {
|
|
640
|
+
const held = new Set<number>();
|
|
641
|
+
|
|
642
|
+
const onDown = (event: PointerEvent): void => {
|
|
643
|
+
if (event.pointerType !== 'mouse') return;
|
|
644
|
+
held.add(event.button);
|
|
645
|
+
};
|
|
646
|
+
const onUp = (event: PointerEvent): void => {
|
|
647
|
+
if (event.pointerType !== 'mouse') return;
|
|
648
|
+
held.delete(event.button);
|
|
649
|
+
};
|
|
650
|
+
const clear = (): void => held.clear();
|
|
651
|
+
const onContextMenu = (event: MouseEvent): void => event.preventDefault();
|
|
652
|
+
|
|
653
|
+
canvas.addEventListener('pointerdown', onDown);
|
|
654
|
+
window.addEventListener('pointerup', onUp);
|
|
655
|
+
window.addEventListener('pointercancel', onUp);
|
|
656
|
+
window.addEventListener('blur', clear);
|
|
657
|
+
document.addEventListener('visibilitychange', clear);
|
|
658
|
+
if (options.suppressContextMenu) canvas.addEventListener('contextmenu', onContextMenu);
|
|
659
|
+
|
|
660
|
+
return {
|
|
661
|
+
isDown: (button) => held.has(button),
|
|
662
|
+
clear,
|
|
663
|
+
dispose() {
|
|
664
|
+
clear();
|
|
665
|
+
canvas.removeEventListener('pointerdown', onDown);
|
|
666
|
+
window.removeEventListener('pointerup', onUp);
|
|
667
|
+
window.removeEventListener('pointercancel', onUp);
|
|
668
|
+
window.removeEventListener('blur', clear);
|
|
669
|
+
document.removeEventListener('visibilitychange', clear);
|
|
670
|
+
canvas.removeEventListener('contextmenu', onContextMenu);
|
|
671
|
+
},
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
/** 旧键名 / 常见笔误 → 正确写法。**只用于 warn 文案,不参与实际匹配** */
|
|
676
|
+
const KEY_NAME_HINTS: Record<string, string> = {
|
|
677
|
+
UP: 'ArrowUp',
|
|
678
|
+
DOWN: 'ArrowDown',
|
|
679
|
+
LEFT: 'ArrowLeft',
|
|
680
|
+
RIGHT: 'ArrowRight',
|
|
681
|
+
SPACE: 'Space',
|
|
682
|
+
ENTER: 'Enter',
|
|
683
|
+
SHIFT: 'ShiftLeft',
|
|
684
|
+
CTRL: 'ControlLeft',
|
|
685
|
+
ALT: 'AltLeft',
|
|
686
|
+
TAB: 'Tab',
|
|
687
|
+
ESC: 'Escape',
|
|
688
|
+
MOUSE_LEFT: 'Mouse0',
|
|
689
|
+
MOUSE_MIDDLE: 'Mouse1',
|
|
690
|
+
MOUSE_RIGHT: 'Mouse2',
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
/** 能明确判定写错的给出建议;形态合法但不认识的名字放过(无法穷举所有 code) */
|
|
694
|
+
function keyNameHint(name: string): string | null {
|
|
695
|
+
if (MOUSE_TOKEN.test(name)) return null;
|
|
696
|
+
if (KEY_NAME_HINTS[name]) return KEY_NAME_HINTS[name];
|
|
697
|
+
if (/^[A-Za-z]$/.test(name)) return `Key${name.toUpperCase()}`;
|
|
698
|
+
if (/^[0-9]$/.test(name)) return `Digit${name}`;
|
|
699
|
+
if (name !== name.trim()) return `"${name.trim()}"(去掉首尾空格)`;
|
|
700
|
+
if (/^[a-z]/.test(name)) return name.charAt(0).toUpperCase() + name.slice(1);
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* 键名写错不会有任何运行时报错 —— `keyboard.isDown()` 逐字比较,不匹配就恒为 `false`,
|
|
706
|
+
* 表现是「这个键完全没反应」。这里把静默失效变成一条 warn。
|
|
707
|
+
*/
|
|
708
|
+
function warnSuspectKeyNames(config: InputConfigFile): void {
|
|
709
|
+
const names = new Set<string>();
|
|
710
|
+
for (const axis of Object.values(config.axes ?? {})) {
|
|
711
|
+
for (const group of [axis.pc.horizontal, axis.pc.vertical]) {
|
|
712
|
+
group.negative.forEach((name) => names.add(name));
|
|
713
|
+
group.positive.forEach((name) => names.add(name));
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
for (const action of Object.values(config.actions ?? {})) {
|
|
717
|
+
action.pc.forEach((name) => names.add(name));
|
|
718
|
+
}
|
|
719
|
+
for (const name of names) {
|
|
720
|
+
const hint = keyNameHint(name);
|
|
721
|
+
if (hint) {
|
|
722
|
+
console.warn(
|
|
723
|
+
`[input] 键名 "${name}" 不是 KeyboardEvent.code,永远不会触发;应写成 ${hint}`,
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* 收集需要 preventDefault 的键,避免方向键滚动页面 / 空格滚动。
|
|
731
|
+
*
|
|
732
|
+
* **逐字使用配置里的名字,不做任何别名或大小写转换。** 这里转换过一次就会出现
|
|
733
|
+
* 「preventDefault 生效、`isDown` 永假」的静默失效 —— `keyboard.isDown()` 用的是配置原值。
|
|
734
|
+
* 写错的名字在 `warnSuspectKeyNames` 里报出来,不在这里悄悄纠正。
|
|
735
|
+
*/
|
|
736
|
+
function collectPreventDefault(config: InputConfigFile): string[] {
|
|
737
|
+
const codes = new Set<string>();
|
|
738
|
+
const add = (name: string): void => {
|
|
739
|
+
// 鼠标键不走 keyboard,别塞进它的 preventDefault 名单
|
|
740
|
+
if (!MOUSE_TOKEN.test(name)) codes.add(name);
|
|
741
|
+
};
|
|
742
|
+
for (const axis of Object.values(config.axes ?? {})) {
|
|
743
|
+
axis.pc.horizontal.negative.forEach(add);
|
|
744
|
+
axis.pc.horizontal.positive.forEach(add);
|
|
745
|
+
axis.pc.vertical.negative.forEach(add);
|
|
746
|
+
axis.pc.vertical.positive.forEach(add);
|
|
747
|
+
}
|
|
748
|
+
for (const action of Object.values(config.actions ?? {})) action.pc.forEach(add);
|
|
749
|
+
for (const code of ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Space']) codes.add(code);
|
|
750
|
+
return [...codes];
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
interface ButtonDrag {
|
|
754
|
+
/** pointerdown 时登记拖拽起点 */
|
|
755
|
+
begin(event: PointerEvent): void;
|
|
756
|
+
/** pointerup / cancel / lostcapture 时结束 */
|
|
757
|
+
end(event: PointerEvent): void;
|
|
758
|
+
reset(): void;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* 动作按钮的「按住拖拽 → 并入 look 通道」。
|
|
763
|
+
*
|
|
764
|
+
* 为什么能直接监听按钮自己的 `pointermove`:按钮在 pointerdown 时做了
|
|
765
|
+
* `setPointerCapture`,该指针的后续事件**只**发给按钮,手指拖出按钮外仍然收得到。
|
|
766
|
+
* 这同时保证了按住拖出去 `isDown` 不掉(需求里的「按下即持续开火」)。
|
|
767
|
+
*
|
|
768
|
+
* 三条不能省的性质:
|
|
769
|
+
* 1. **只跟随第一根手指。** 同一按钮上的第二根手指不参与转向,否则两指微抖会互相叠加。
|
|
770
|
+
* 2. **滑动区已有活跃指针时让位。** 玩家已经有专职转向手指时,按钮的抖动只会给镜头加噪。
|
|
771
|
+
* 让位期间**仍然更新 last**,否则恢复瞬间会把攒下的位移一次性灌进去(镜头猛甩)。
|
|
772
|
+
* 3. **传原始 CSS 像素位移,不按 `ui.scale` 换算。** LookPad 的量纲就是 CSS 像素
|
|
773
|
+
* (滑动区也是直接用 `clientX` 差值),换算会让两条路的速度不一致。
|
|
774
|
+
*/
|
|
775
|
+
function createButtonDrag(
|
|
776
|
+
button: HTMLElement,
|
|
777
|
+
action: string,
|
|
778
|
+
config: NonNullable<InputActionConfig['mobile']['drag']>,
|
|
779
|
+
getPad: () => LookPad | undefined,
|
|
780
|
+
): ButtonDrag {
|
|
781
|
+
const factor = config.sensitivity ?? 1;
|
|
782
|
+
const deadZonePx = Math.max(0, config.deadZonePx ?? 0);
|
|
783
|
+
let pointerId: number | null = null;
|
|
784
|
+
let startX = 0;
|
|
785
|
+
let startY = 0;
|
|
786
|
+
let lastX = 0;
|
|
787
|
+
let lastY = 0;
|
|
788
|
+
/** 是否已越过起手死区 */
|
|
789
|
+
let crossed = false;
|
|
790
|
+
let warnedMissingLook = false;
|
|
791
|
+
|
|
792
|
+
const onMove = (event: PointerEvent): void => {
|
|
793
|
+
if (event.pointerId !== pointerId) return;
|
|
794
|
+
event.preventDefault();
|
|
795
|
+
|
|
796
|
+
if (!crossed) {
|
|
797
|
+
// 与 LookPad 一致:越界瞬间把基准挪到当前点,丢弃死区那一小段,避免起手时镜头跳一下
|
|
798
|
+
if (Math.hypot(event.clientX - startX, event.clientY - startY) < deadZonePx) return;
|
|
799
|
+
crossed = true;
|
|
800
|
+
lastX = event.clientX;
|
|
801
|
+
lastY = event.clientY;
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
const dx = event.clientX - lastX;
|
|
806
|
+
const dy = event.clientY - lastY;
|
|
807
|
+
lastX = event.clientX;
|
|
808
|
+
lastY = event.clientY;
|
|
809
|
+
|
|
810
|
+
const pad = getPad();
|
|
811
|
+
if (!pad) {
|
|
812
|
+
if (!warnedMissingLook) {
|
|
813
|
+
warnedMissingLook = true;
|
|
814
|
+
console.warn(
|
|
815
|
+
`[input] 动作 ${action} 配了 mobile.drag 但 look 通道 ` +
|
|
816
|
+
`"${config.look ?? 'look'}" 不存在(looks 里没声明),拖拽已忽略`,
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
return;
|
|
820
|
+
}
|
|
821
|
+
// 让位判断放在更新 last 之后 —— 顺序反了会攒出一次猛甩
|
|
822
|
+
if (pad.isActive()) return;
|
|
823
|
+
pad.feedDelta(dx * factor, dy * factor);
|
|
824
|
+
};
|
|
825
|
+
|
|
826
|
+
button.addEventListener('pointermove', onMove);
|
|
827
|
+
|
|
828
|
+
return {
|
|
829
|
+
begin(event) {
|
|
830
|
+
if (pointerId !== null) return;
|
|
831
|
+
pointerId = event.pointerId;
|
|
832
|
+
startX = event.clientX;
|
|
833
|
+
startY = event.clientY;
|
|
834
|
+
lastX = startX;
|
|
835
|
+
lastY = startY;
|
|
836
|
+
// 死区为 0 时不能走「丢弃首段」分支,否则第一次 move 的位移会被吞掉
|
|
837
|
+
crossed = deadZonePx === 0;
|
|
838
|
+
},
|
|
839
|
+
end(event) {
|
|
840
|
+
if (event.pointerId === pointerId) pointerId = null;
|
|
841
|
+
},
|
|
842
|
+
reset() {
|
|
843
|
+
pointerId = null;
|
|
844
|
+
crossed = deadZonePx === 0;
|
|
845
|
+
},
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/** 负值 = 从右 / 下边缘算起。用 right / bottom 表达,尺寸变化时无需重算 */
|
|
850
|
+
function applyEdgeAnchors(
|
|
851
|
+
element: HTMLElement,
|
|
852
|
+
mobile: { x: number; y: number; radius: number },
|
|
853
|
+
): void {
|
|
854
|
+
const size = mobile.radius * 2;
|
|
855
|
+
element.style.position = 'absolute';
|
|
856
|
+
element.style.width = `${size}px`;
|
|
857
|
+
element.style.height = `${size}px`;
|
|
858
|
+
if (mobile.x < 0) element.style.right = `${-mobile.x - mobile.radius}px`;
|
|
859
|
+
else element.style.left = `${mobile.x - mobile.radius}px`;
|
|
860
|
+
if (mobile.y < 0) element.style.bottom = `${-mobile.y - mobile.radius}px`;
|
|
861
|
+
else element.style.top = `${mobile.y - mobile.radius}px`;
|
|
862
|
+
}
|