From ab518ea574d5c4d936118b22ed7b2caeb5f7b133 Mon Sep 17 00:00:00 2001 From: Suzumiya Date: Sun, 4 Oct 2026 20:50:33 +0800 Subject: [PATCH] =?UTF-8?q?AGC=20=E8=B5=B7=E6=AD=A5=E5=B7=A5=E7=A8=8B?= =?UTF-8?q?=E4=B8=8E=E6=96=B0=E5=BB=BA=E8=84=9A=E6=89=8B=E6=9E=B6=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E7=82=B9=E9=80=89=E6=89=80=E9=9C=80=E5=BC=95=E6=93=8E?= =?UTF-8?q?=E5=8F=A5=E6=9F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新建项目默认脚本创建 Phaser 实例后发布只读句柄 - Phaser 与 three.js 两个起步模板及空白三维场景模板同样发布句柄 - Phaser 脚手架与模板改用 Image 标签装载图片,让贴图保留原始素材地址 --- apps/ai-game-creator-shell/src-tauri/src/main.rs | 2 +- .../v1/blank-3d-scene/project/game/main.js | 9 +++++++++ .../v1/phaser-2d-starter/project/game/game.js | 7 ++++++- .../v1/threejs-3d-starter/project/game/main.js | 9 +++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/main.rs b/apps/ai-game-creator-shell/src-tauri/src/main.rs index 8db190f8d..94cf14b63 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/main.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/main.rs @@ -1253,7 +1253,7 @@ const DEFAULT_GAME_INDEX_HTML: &str = r#" "#; const DEFAULT_GAME_STYLE_CSS: &str = "body { margin: 0; display: grid; min-height: 100vh; place-items: center; background: #101827; color: #d9e7ff; font: 16px system-ui, sans-serif; }\nmain { width: min(720px, calc(100vw - 32px)); }\n"; -const DEFAULT_GAME_SCRIPT_JS: &str = "import Phaser from 'phaser';\nimport './style.css';\n\nclass PlaceholderScene extends Phaser.Scene {\n create() { this.add.text(24, 24, '还没有生成游戏。回到聊天输入创意并确认生成后,这里会写入可试玩原型。'); }\n}\n\nnew Phaser.Game({ type: Phaser.AUTO, width: 720, height: 420, parent: 'game', scene: PlaceholderScene });\n"; +const DEFAULT_GAME_SCRIPT_JS: &str = "import Phaser from 'phaser';\nimport './style.css';\n\nclass PlaceholderScene extends Phaser.Scene {\n create() { this.add.text(24, 24, '还没有生成游戏。回到聊天输入创意并确认生成后,这里会写入可试玩原型。'); }\n}\n\n// 用 Image 标签装载图片,让贴图保留原始素材地址,运行画面点选才能定位素材。\nconst game = new Phaser.Game({ type: Phaser.AUTO, width: 720, height: 420, parent: 'game', loader: { imageLoadType: 'HTMLImageElement' }, scene: PlaceholderScene });\n// 发布运行画面实例句柄,供预览桥点选定位游戏实例。\nwindow.__GENARRATIVE_PREVIEW_GAME__ = { engine: 'phaser', game };\n"; const DEFAULT_EDITOR_BASE_URL: &str = "http://127.0.0.1:3000"; const GAME_CREATOR_CONFIG_FILE_NAME: &str = "game-creator.config.json"; diff --git a/apps/ai-game-creator-shell/template-library/v1/blank-3d-scene/project/game/main.js b/apps/ai-game-creator-shell/template-library/v1/blank-3d-scene/project/game/main.js index 73c37324b..2febd40ff 100644 --- a/apps/ai-game-creator-shell/template-library/v1/blank-3d-scene/project/game/main.js +++ b/apps/ai-game-creator-shell/template-library/v1/blank-3d-scene/project/game/main.js @@ -18,6 +18,15 @@ renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); container.append(renderer.domElement); +// 发布运行画面实例句柄,供预览桥点选定位场景、相机与渲染器。 +window.__GENARRATIVE_PREVIEW_GAME__ = { + engine: 'three', + THREE, + scene, + camera, + renderer, +}; + const light = new THREE.DirectionalLight(0xffffff, 1.2); light.position.set(4, 8, 6); scene.add(light, new THREE.AmbientLight(0x8899ff, 0.5)); diff --git a/apps/ai-game-creator-shell/template-library/v1/phaser-2d-starter/project/game/game.js b/apps/ai-game-creator-shell/template-library/v1/phaser-2d-starter/project/game/game.js index a77ba6be9..61574cba8 100644 --- a/apps/ai-game-creator-shell/template-library/v1/phaser-2d-starter/project/game/game.js +++ b/apps/ai-game-creator-shell/template-library/v1/phaser-2d-starter/project/game/game.js @@ -12,10 +12,15 @@ class PlaceholderScene extends Phaser.Scene { } } -new Phaser.Game({ +// 用 Image 标签装载图片,让贴图保留原始素材地址,运行画面点选才能定位素材。 +const game = new Phaser.Game({ type: Phaser.AUTO, width: 720, height: 420, parent: 'game', + loader: { imageLoadType: 'HTMLImageElement' }, scene: PlaceholderScene, }); + +// 发布运行画面实例句柄,供预览桥点选定位游戏实例。 +window.__GENARRATIVE_PREVIEW_GAME__ = { engine: 'phaser', game }; diff --git a/apps/ai-game-creator-shell/template-library/v1/threejs-3d-starter/project/game/main.js b/apps/ai-game-creator-shell/template-library/v1/threejs-3d-starter/project/game/main.js index 211f285ef..dc0ed61ac 100644 --- a/apps/ai-game-creator-shell/template-library/v1/threejs-3d-starter/project/game/main.js +++ b/apps/ai-game-creator-shell/template-library/v1/threejs-3d-starter/project/game/main.js @@ -18,6 +18,15 @@ renderer.setPixelRatio(window.devicePixelRatio); renderer.setSize(window.innerWidth, window.innerHeight); container.append(renderer.domElement); +// 发布运行画面实例句柄,供预览桥点选定位场景、相机与渲染器。 +window.__GENARRATIVE_PREVIEW_GAME__ = { + engine: 'three', + THREE, + scene, + camera, + renderer, +}; + const light = new THREE.DirectionalLight(0xffffff, 1.4); light.position.set(3, 5, 4); scene.add(light, new THREE.AmbientLight(0x8899ff, 0.6));