Skip to content

Commit

Permalink
Fix MediaVideo/MediaImage params initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Aug 16, 2023
1 parent 2605af1 commit e6b84a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/inflators/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,20 @@ export function inflateImage(world: HubsWorld, eid: EntityID, params: ImageParam
addObject3DComponent(world, eid, mesh);
addComponent(world, MediaImage, eid);

if (projection) {
if (projection !== undefined) {
MediaImage.projection[eid] = APP.getSid(projection);
} else {
MediaImage.projection[eid] = APP.getSid(ProjectionMode.FLAT);
}
if (alphaMode) {
if (alphaMode !== undefined) {
MediaImage.alphaMode[eid] = APP.getSid(alphaMode);
} else {
MediaImage.alphaMode[eid] = APP.getSid(AlphaMode.Opaque);
}
if (alphaCutoff) {
if (alphaCutoff !== undefined) {
MediaImage.alphaCutoff[eid] = alphaCutoff;
} else {
MediaImage.alphaCutoff[eid] = 0;
}

MediaImage.cacheKey[eid] = APP.getSid(cacheKey);
Expand Down
7 changes: 5 additions & 2 deletions src/inflators/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ export function inflateVideo(world: HubsWorld, eid: EntityID, params: VideoParam
addObject3DComponent(world, eid, mesh);
addComponent(world, MediaVideo, eid);

if (controls) {
MediaVideo.flags[eid] = 0;
if (controls !== undefined) {
MediaVideo.flags[eid] |= VIDEO_FLAGS.CONTROLS;
}
if (projection) {
MediaVideo.projection[eid] = APP.getSid(projection);
} else {
MediaVideo.projection[eid] = APP.getSid(ProjectionMode.FLAT);
}

MediaVideo.ratio[eid] = ratio;
MediaVideo.ratio[eid] = ratio !== undefined ? ratio : 1;
MediaVideoData.set(eid, video);
return eid;
}

0 comments on commit e6b84a9

Please sign in to comment.