Skip to content

Commit

Permalink
Merge pull request #6229 from mozilla/glTFLinkComponent
Browse files Browse the repository at this point in the history
bitECS: Support glTF link component
  • Loading branch information
takahirox authored Sep 1, 2023
2 parents a783fd6 + a612030 commit c4cf76e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
18 changes: 18 additions & 0 deletions src/inflators/link-loader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { HubsWorld } from "../app";
import { inflateMediaLoader } from "./media-loader";

export type LinkLoaderParams = {
href: string;
};

export function inflateLinkLoader(world: HubsWorld, eid: number, params: LinkLoaderParams): number {
inflateMediaLoader(world, eid, {
src: params.href,
resize: false,
recenter: true,
animateLoad: false,
isObjectMenuTarget: true
});

return eid;
}
9 changes: 6 additions & 3 deletions src/utils/jsx-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { inflateVideoLoader, VideoLoaderParams } from "../inflators/video-loader
import { inflateImageLoader, ImageLoaderParams } from "../inflators/image-loader";
import { inflateModelLoader, ModelLoaderParams } from "../inflators/model-loader";
import { inflateLink, LinkParams } from "../inflators/link";
import { inflateLinkLoader, LinkLoaderParams } from "../inflators/link-loader";
import { inflateLoopAnimationInitialize, LoopAnimationParams } from "../inflators/loop-animation";
import { inflateSlice9 } from "../inflators/slice9";
import { TextParams, inflateText } from "../inflators/text";
Expand Down Expand Up @@ -252,7 +253,6 @@ export interface ComponentData {
spotLight?: SpotLightParams;
grabbable?: GrabbableParams;
billboard?: { onlyY: boolean };
link?: LinkParams;
mirror?: MirrorParams;
audioZone?: AudioZoneParams;
audioParams?: AudioSettings;
Expand All @@ -276,6 +276,7 @@ export interface JSXComponentData extends ComponentData {
cacheKey: string;
};
video?: VideoParams;
link?: LinkParams;
networkedVideo?: true;
videoMenu?: {
sliderRef: Ref;
Expand Down Expand Up @@ -365,6 +366,7 @@ export interface GLTFComponentData extends ComponentData {
audio?: VideoLoaderParams;
video?: VideoLoaderParams;
image?: ImageLoaderParams;
link?: LinkLoaderParams;
model?: ModelLoaderParams;
environmentSettings?: EnvironmentSettingsParams;
reflectionProbe?: ReflectionProbeParams;
Expand Down Expand Up @@ -409,7 +411,6 @@ declare global {
export const commonInflators: Required<{ [K in keyof ComponentData]: InflatorFn }> = {
grabbable: inflateGrabbable,
billboard: createDefaultInflator(Billboard),
link: inflateLink,

// inflators that create Object3Ds
ambientLight: inflateAmbientLight,
Expand Down Expand Up @@ -468,7 +469,8 @@ const jsxInflators: Required<{ [K in keyof JSXComponentData]: InflatorFn }> = {
slice9: inflateSlice9,
model: inflateModel,
image: inflateImage,
video: inflateVideo
video: inflateVideo,
link: inflateLink,
};

export const gltfInflators: Required<{ [K in keyof GLTFComponentData]: InflatorFn }> = {
Expand All @@ -481,6 +483,7 @@ export const gltfInflators: Required<{ [K in keyof GLTFComponentData]: InflatorF
audio: inflateVideoLoader,
video: inflateVideoLoader,
image: inflateImageLoader,
link: inflateLinkLoader,
model: inflateModelLoader,
reflectionProbe: inflateReflectionProbe,
navMesh: createDefaultInflator(NavMesh),
Expand Down

0 comments on commit c4cf76e

Please sign in to comment.