From 4c4e61a170508cc5415729b23720cf9b8e0a7162 Mon Sep 17 00:00:00 2001 From: Manuel Martin Date: Wed, 5 Jul 2023 12:50:20 +0200 Subject: [PATCH] Media loading fixes --- src/bit-systems/media-loading.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bit-systems/media-loading.ts b/src/bit-systems/media-loading.ts index 6841c728aa..ef3bc1b6ed 100644 --- a/src/bit-systems/media-loading.ts +++ b/src/bit-systems/media-loading.ts @@ -79,8 +79,9 @@ const loaderForMediaType = { { accessibleUrl, contentType }: { accessibleUrl: string; contentType: string } ) => loadModel(world, accessibleUrl, contentType, true), [MediaType.PDF]: (world: HubsWorld, { accessibleUrl }: { accessibleUrl: string }) => loadPDF(world, accessibleUrl), - [MediaType.AUDIO]: (world: HubsWorld, { accessibleUrl }: { accessibleUrl: string }) => loadAudio(world, accessibleUrl), - [MediaType.HTML]: (world: HubsWorld, { canonicalUrl, thumbnail }: { canonicalUrl: string, thumbnail: string }) => + [MediaType.AUDIO]: (world: HubsWorld, { accessibleUrl }: { accessibleUrl: string }) => + loadAudio(world, accessibleUrl), + [MediaType.HTML]: (world: HubsWorld, { canonicalUrl, thumbnail }: { canonicalUrl: string; thumbnail: string }) => loadHtml(world, canonicalUrl, thumbnail) }; @@ -100,6 +101,10 @@ function resizeAndRecenter(world: HubsWorld, media: EntityID, eid: EntityID) { const box = new Box3(); box.setFromObject(mediaObj); + // The AABB can be empty here for interactables that fetch media (ie. gltf with an empty that has a video component). + // If we don't return the interactable would be wrongly positioned at the (0,0,0). + if (box.isEmpty()) return; + let scalar = 1; if (resize) { const size = new Vector3();