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.

117 lines (116 loc) 4.55 kB
/// <reference types="webxr" /> import { Context } from "../engine_setup.js"; import { type INeedleEngineComponent } from "../engine_types.js"; import { TonemappingAttributeOptions } from "./needle-engine.attributes.js"; /** * <needle-engine> web component. See {@link NeedleEngineAttributes} attributes for supported attributes * The needle engine web component creates and manages a needle engine context which is responsible for rendering a 3D scene using threejs. * The needle engine context is created when the src attribute is set and disposed when the needle engine is removed from the document (you can prevent this by setting the keep-alive attribute to true). * The needle engine context is accessible via the context property on the needle engine element (e.g. document.querySelector("needle-engine").context). * @link https://engine.needle.tools/docs/reference/needle-engine-attributes * * @example * <needle-engine src="https://example.com/scene.glb"></needle-engine> * @example * <needle-engine src="https://example.com/scene.glb" camera-controls="false"></needle-engine> */ export declare class NeedleEngineWebComponent extends HTMLElement implements INeedleEngineComponent { static get observedAttributes(): string[]; get loadingProgress01(): number; get loadingFinished(): boolean; /** * If set to false the camera controls are disabled. Default is true. * @type {boolean | null} * @memberof NeedleEngineAttributes * @example * <needle-engine camera-controls="false"></needle-engine> * @example * <needle-engine camera-controls="true"></needle-engine> * @example * <needle-engine camera-controls></needle-engine> * @example * <needle-engine></needle-engine> * @returns {boolean | null} if the attribute is not set it returns null */ get cameraControls(): boolean | null; /** * Get the current context for this web component instance. The context is created when the src attribute is set and the loading has finished. * The context is disposed when the needle engine is removed from the document (you can prevent this by setting the keep-alive attribute to true). * @returns {Promise<Context>} a promise that resolves to the context when the loading has finished */ getContext(): Promise<Context>; /** * Get the context that is created when the src attribute is set and the loading has finished. */ get context(): Context; private _context; private _overlay_ar; private _loadingProgress01; private _loadingView?; private _previousSrc; /** set to true after <needle-engine> did load completely at least once. Set to false when <needle-engine> is removed from the document */ private _didFullyLoad; constructor(); /** * @internal */ connectedCallback(): Promise<void>; /** * @internal */ disconnectedCallback(): void; /** * @internal */ attributeChangedCallback(name: string, oldValue: string, newValue: string): void; /** The tonemapping setting configured as an attribute on the <needle-engine> component */ get toneMapping(): TonemappingAttributeOptions | null | undefined; private _loadId; private _abortController; private _lastSourceFiles; private _createContextPromise; private onLoad; private applyAttributes; private onXRSessionStarted; /** called by the context when the first frame has been rendered */ private onReady; private onError; private internalSetLoadingMessage; private getSourceFiles; private checkIfSourceHasChanged; private _previouslyRegisteredMap; private ensureLoadStartIsRegistered; private registerEventFromAttribute; private setPublicKey; private setVersion; /** * @internal */ getAROverlayContainer(): HTMLElement; /** * @internal */ getVROverlayContainer(): HTMLElement | null; /** * @internal */ onEnterAR(session: XRSession): void; /** * @internal */ onExitAR(session: XRSession): void; /** * @internal */ onEnterVR(session: XRSession): void; /** * @internal */ onExitVR(session: XRSession): void; private onSetupAR; private onSetupVR; private onSetupDesktop; private setupElementsForMode; private foreachHtmlElement; private onBeforeBeginLoading; }