Skip to content

Commit

Permalink
Fix MediaContent bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Nov 27, 2023
1 parent d2ea71e commit 4513538
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/bit-systems/media-loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 4513538

Please sign in to comment.