From 45135381c79df428d0b1fda997e7ee7be42df4ab Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Mon, 27 Nov 2023 13:12:05 +0100 Subject: [PATCH] Fix MediaContent bounds --- src/bit-systems/media-loading.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bit-systems/media-loading.ts b/src/bit-systems/media-loading.ts index 0b113e44b9..c865a624d0 100644 --- a/src/bit-systems/media-loading.ts +++ b/src/bit-systems/media-loading.ts @@ -140,14 +140,20 @@ export function* animateScale(world: HubsWorld, mediaLoaderEid: EntityID) { } function* finish(world: HubsWorld, mediaLoaderEid: EntityID) { - if (MediaLoader.flags[mediaLoaderEid] & MEDIA_LOADER_FLAGS.ANIMATE_LOAD) { - yield* animateScale(world, mediaLoaderEid); - } if (entityExists(world, mediaLoaderEid)) { + if (MediaLoader.flags[mediaLoaderEid] & MEDIA_LOADER_FLAGS.ANIMATE_LOAD) { + yield* animateScale(world, mediaLoaderEid); + } inflatePhysicsShape(world, mediaLoaderEid, { type: Shape.HULL, minHalfExtent: 0.04 }); + + addComponent(world, MediaContentBounds, mediaLoaderEid); + const mediaLoaderObj = world.eid2obj.get(mediaLoaderEid)!; + box.setFromObject(mediaLoaderObj); + box.getSize(tmpVector); + MediaContentBounds.bounds[mediaLoaderEid].set(tmpVector.toArray()); } } @@ -286,12 +292,6 @@ function* loadAndAnimateMedia(world: HubsWorld, mediaLoaderEid: EntityID, clearR setNetworkedDataWithoutRoot(world, APP.getString(Networked.id[mediaLoaderEid])!, mediaEid); - addComponent(world, MediaContentBounds, mediaLoaderEid); - const mediaObj = world.eid2obj.get(mediaEid)!; - box.setFromObject(mediaObj); - box.getSize(tmpVector); - MediaContentBounds.bounds[mediaLoaderEid].set(tmpVector.toArray()); - removeComponent(world, MediaLoading, mediaLoaderEid); removeComponent(world, MediaLink, mediaLoaderEid); }