UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.

89 lines (88 loc) 3.06 kB
import { Behaviour } from "./Component.js"; /** * RemoteSkybox is a component that allows you to set the skybox of a scene from a URL or a local file. * It supports .hdr, .exr, .jpg, .png files. * * ### Events * - `dropped-unknown-url`: Emitted when a file is dropped on the scene. The event detail contains the sender, the url and a function to apply the url. * * @example adding a skybox * ```ts * GameObject.addComponent(gameObject, Skybox, { url: "https://example.com/skybox.hdr", background: true, environment: true }); * ``` * * @example handle custom url * ```ts * const skybox = GameObject.addComponent(gameObject, Skybox); * skybox.addEventListener("dropped-unknown-url", (evt) => { * let url = evt.detail.url; * console.log("User dropped file", url); * // change url or resolve it differently * url = "https://example.com/skybox.hdr"; * // apply the url * evt.detail.apply(url); * }); * ``` * * @example update skybox url * ```ts * skybox.setSkybox("https://example.com/skybox.hdr"); * ``` */ export declare class RemoteSkybox extends Behaviour { /** * URL to a remote skybox. This value can also use a magic skybox name. Options are "quicklook", "quicklook-ar", "studio", "blurred-skybox". * To update the skybox/environment map use `setSkybox(url)` * @example * ```ts * skybox.url = "https://example.com/skybox.hdr"; * ``` */ url?: string; /** * When enabled a user can drop a link to a skybox image on the scene to set the skybox. * @default true */ allowDrop: boolean; /** * When enabled the skybox will be set as the background of the scene. * @default true */ background: boolean; /** * When enabled the skybox will be set as the environment of the scene (to be used as environment map for reflections and lighting) * @default true */ environment: boolean; /** * When enabled dropped skybox urls (or assigned skybox urls) will be networked to other users in the same networked room. * @default true */ allowNetworking: boolean; private _loader?; private _prevUrl?; private _prevLoadedEnvironment?; private _prevEnvironment; private _prevBackground; /** @internal */ onEnable(): void; /** @internal */ onDisable(): void; private urlChangedSyncField; /** * Set the skybox from a given url * @param url The url of the skybox image * @param name Define name of the file with extension if it isn't apart of the url * @returns Whether the skybox was successfully set */ setSkybox(url: string | undefined | null, name?: string): Promise<boolean>; private loadTexture; private apply; private readonly validTextureTypes; private isRemoteTexture; private isValidTextureType; private registerDropEvents; private unregisterDropEvents; private onDragOverEvent; private onDrop; }