AGC 起步工程与新建脚手架发布点选所需引擎句柄

- 新建项目默认脚本创建 Phaser 实例后发布只读句柄
- Phaser 与 three.js 两个起步模板及空白三维场景模板同样发布句柄
- Phaser 脚手架与模板改用 Image 标签装载图片,让贴图保留原始素材地址
This commit is contained in:
2026-10-04 20:50:33 +08:00
parent 6264fed6b4
commit ab518ea574
4 changed files with 25 additions and 2 deletions
@@ -1253,7 +1253,7 @@ const DEFAULT_GAME_INDEX_HTML: &str = r#"<!doctype html>
</html>
"#;
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";
@@ -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));
@@ -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 };
@@ -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));