Skip to content

Commit

Permalink
Merge pull request Hubs-Foundation#6392 from mozilla/bitecs-image-con…
Browse files Browse the repository at this point in the history
…trols-link-menu

Bitecs-image-controls-link-menu
  • Loading branch information
keianhzo authored Dec 4, 2023
2 parents 13d7597 + ffe75f9 commit 4ef68d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/bit-systems/link-hover-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async function handleLinkClick(world: HubsWorld, button: EntityID) {
const menu = findAncestorWithComponent(world, LinkHoverMenu, button)!;
const linkEid = LinkHoverMenu.targetObjectRef[menu];
const src = APP.getString(Link.url[linkEid])!;
if (!src) return;
const url = new URL(src);
const linkType = Link.type[linkEid];
switch (linkType) {
Expand Down
11 changes: 9 additions & 2 deletions src/inflators/image-loader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { addComponent } from "bitecs";
import { HubsWorld } from "../app";
import { MediaImageLoaderData } from "../bit-components";
import { MediaImageLoaderData, MediaLink } from "../bit-components";
import { AlphaModeName, getAlphaModeFromAlphaModeName } from "../utils/create-image-mesh";
import { ProjectionModeName, getProjectionFromProjectionName } from "../utils/projection-mode";
import { inflateMediaLoader } from "./media-loader";
Expand All @@ -9,12 +10,14 @@ export interface ImageLoaderParams {
projection: ProjectionModeName;
alphaMode: AlphaModeName;
alphaCutoff: number;
controls: boolean;
}

const DEFAULTS: Partial<ImageLoaderParams> = {
projection: ProjectionModeName.FLAT,
alphaMode: AlphaModeName.OPAQUE,
alphaCutoff: 0.5
alphaCutoff: 0.5,
controls: false
};

export function inflateImageLoader(world: HubsWorld, eid: number, params: ImageLoaderParams) {
Expand All @@ -35,4 +38,8 @@ export function inflateImageLoader(world: HubsWorld, eid: number, params: ImageL
alphaMode: getAlphaModeFromAlphaModeName(requiredParams.alphaMode),
projection: getProjectionFromProjectionName(requiredParams.projection)
});

if (params.controls) {
addComponent(world, MediaLink, eid);
}
}

0 comments on commit 4ef68d2

Please sign in to comment.