修改
This commit is contained in:
21
src/main.ts
21
src/main.ts
@ -1,4 +1,5 @@
|
||||
import { MainApp } from './babylonjs/MainApp';
|
||||
import { AppConfig } from './babylonjs/AppConfig';
|
||||
import configurator, { ConfiguratorParams } from './components/conf';
|
||||
import auth from './components/auth';
|
||||
import { on } from './utils/event';
|
||||
@ -18,6 +19,11 @@ type InitParams = {
|
||||
onSuccess?: () => void;
|
||||
onError?: (error?: unknown) => void;
|
||||
apiConfig?: ConfiguratorParams;
|
||||
envConfig?: {
|
||||
hdrPath?: string;
|
||||
intensity?: number;
|
||||
rotationY?: number;
|
||||
};
|
||||
};
|
||||
|
||||
let mainApp: MainApp | null = null;
|
||||
@ -43,11 +49,24 @@ const kernel = {
|
||||
container: params.container || 'renderDom',
|
||||
modelUrlList: params.modelUrlList || [],
|
||||
success: params.onSuccess ?? null,
|
||||
error: params.onError ?? null
|
||||
error: params.onError ?? null,
|
||||
envConfig: params.envConfig
|
||||
});
|
||||
|
||||
await mainApp.Awake();
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user