This commit is contained in:
20
src/main.ts
20
src/main.ts
@ -14,13 +14,10 @@ declare global {
|
||||
type InitParams = {
|
||||
container?: string;
|
||||
modelUrlList?: string[];
|
||||
animationUrlList?: string[];
|
||||
idleAnimationUrlList?: string[];
|
||||
onSuccess?: () => void;
|
||||
onError?: (error?: unknown) => void;
|
||||
apiConfig?: ConfiguratorParams;
|
||||
envConfig?: {
|
||||
hdrPath?: string;
|
||||
env?: {
|
||||
envPath?: string;
|
||||
intensity?: number;
|
||||
rotationY?: number;
|
||||
};
|
||||
@ -33,24 +30,13 @@ const kernel = {
|
||||
init: async function (params: InitParams): Promise<void> {
|
||||
if (!params) { console.error('params is required'); return; }
|
||||
|
||||
if (params.apiConfig) {
|
||||
await configurator.init(params.apiConfig);
|
||||
if (params.apiConfig.name) {
|
||||
const userInfo = await auth.login(params.apiConfig.name);
|
||||
if (!userInfo) {
|
||||
console.error('failed to fetch user');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mainApp = new MainApp();
|
||||
mainApp.loadAConfig({
|
||||
container: params.container || 'renderDom',
|
||||
modelUrlList: params.modelUrlList || [],
|
||||
success: params.onSuccess ?? null,
|
||||
error: params.onError ?? null,
|
||||
envConfig: params.envConfig
|
||||
env: params.env
|
||||
});
|
||||
|
||||
await mainApp.Awake();
|
||||
|
||||
Reference in New Issue
Block a user