From 917826e51e7b8e5157ecf5454b6de8f6ecca791e Mon Sep 17 00:00:00 2001 From: Kalila <69767640+digisomni@users.noreply.github.com> Date: Tue, 14 Nov 2023 19:13:10 +0800 Subject: [PATCH] Fix my avatar being unnecessarily reloaded. --- src/modules/scene/resource.ts | 4 ---- src/modules/scene/vscene.ts | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/modules/scene/resource.ts b/src/modules/scene/resource.ts index 31dc20d6..b9ebb145 100644 --- a/src/modules/scene/resource.ts +++ b/src/modules/scene/resource.ts @@ -52,10 +52,6 @@ export class ResourceManager { return { rootUrl, filename }; } - public async loadMyAvatar(modelUrl: string): Promise { - return this._loadAvatar(modelUrl); - } - public async loadAvatar(modelUrl: string): Promise { const avatar = await this._loadAvatar(modelUrl); return avatar; diff --git a/src/modules/scene/vscene.ts b/src/modules/scene/vscene.ts index d61a1d47..a92b6f8d 100644 --- a/src/modules/scene/vscene.ts +++ b/src/modules/scene/vscene.ts @@ -204,7 +204,10 @@ export class VScene { } // setup avatar - await this.loadMyAvatar(avatarModelURL); + if (!this._myAvatar) { + await this.loadMyAvatar(avatarModelURL); + } + if (this._myAvatar) { this._myAvatar.position = avatarPos ?? new Vector3(0, 1, 0); this._myAvatar.rotationQuaternion = @@ -378,7 +381,7 @@ export class VScene { previousAvatar.dispose(); } - const result = await this._resourceManager.loadMyAvatar( + const result = await this._resourceManager.loadAvatar( this._myAvatarModelURL ); let boundingVectors = {