From 58cd883720ecceb68399b67b31838776872b914d Mon Sep 17 00:00:00 2001 From: yinsx Date: Mon, 5 Jan 2026 14:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/module-demo.html | 2 +- index.html | 20 +++++++++----------- src/babylonjs/AppConfig.ts | 2 +- src/babylonjs/AppEnv.ts | 17 +++++------------ src/main.ts | 11 ----------- 5 files changed, 16 insertions(+), 36 deletions(-) diff --git a/examples/module-demo.html b/examples/module-demo.html index 848326a..71cb6a2 100644 --- a/examples/module-demo.html +++ b/examples/module-demo.html @@ -15,7 +15,7 @@ const config = { container: 'renderDom', modelUrlList: ['/public/model/model.glb'], - env: '/public/model/model.glb', + env: { hdrPath: '/hdr/hdr.env', intensity: 1.2, rotationY: 0.3 }, onSuccess: () => console.log('SDK initialized (module)'), onError: (err) => console.error('SDK init error', err), }; diff --git a/index.html b/index.html index 612a6ed..cf0383c 100644 --- a/index.html +++ b/index.html @@ -21,19 +21,17 @@ diff --git a/src/babylonjs/AppConfig.ts b/src/babylonjs/AppConfig.ts index 25d7fb9..ce0a151 100644 --- a/src/babylonjs/AppConfig.ts +++ b/src/babylonjs/AppConfig.ts @@ -11,7 +11,7 @@ export const AppConfig = { success: null as OptionalCallback, error: null as ErrorCallback, env: { - hdrPath:"", + envPath:"", intensity: 1, rotationY: 0 } diff --git a/src/babylonjs/AppEnv.ts b/src/babylonjs/AppEnv.ts index 3257a6b..032353a 100644 --- a/src/babylonjs/AppEnv.ts +++ b/src/babylonjs/AppEnv.ts @@ -15,17 +15,17 @@ export class AppEnv extends Monobehiver { /** 初始化 - 创建默认HDR环境 */ Awake(): void { - this.createHDR(AppConfig.env); + } /** * 创建HDR环境贴图 * @param hdrPath HDR文件路径 */ - createHDR(options?: { hdrPath?: string; intensity?: number; rotationY?: number }): void { - const hdrPath = options?.hdrPath || AppConfig.env.hdrPath || '/hdr/sanGiuseppeBridge.env'; - const intensity = options?.intensity ?? AppConfig.env.intensity ?? 1.5; - const rotationY = options?.rotationY ?? AppConfig.env.rotationY ?? 0; + createHDR(): void { + const hdrPath = AppConfig.env.envPath; + const intensity = AppConfig.env.intensity ?? 1.5; + const rotationY = AppConfig.env.rotationY ?? 0; const scene = this.mainApp.appScene.object; if (!scene) return; if (this.object) { @@ -57,13 +57,6 @@ export class AppEnv extends Monobehiver { if (this.object) this.object.rotationY = angle; } - /** - * 更新环境配置 - */ - updateEnvironment(options: { hdrPath?: string; intensity?: number; rotationY?: number }): void { - this.createHDR(options); - } - /** 清理资源 */ clean(): void { if (this.object) { diff --git a/src/main.ts b/src/main.ts index cca828f..6028c4c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -57,17 +57,6 @@ const kernel = { await mainApp.loadModel(); }, - /** 更新环境贴图配置(路径/强度/旋转) */ - setEnvironment: function (envConfig: { hdrPath?: string; intensity?: number; rotationY?: number }): void { - if (!mainApp) { - console.warn('mainApp is not initialized yet'); - return; - } - if (envConfig) { - AppConfig.env = { ...AppConfig.env, ...envConfig }; - mainApp.appEnv.updateEnvironment(AppConfig.env); - } - } }; if (!window.faceSDK) {