@google/model-viewer
Version:
Easily display interactive 3D models on the web and in AR!
49 lines (48 loc) • 1.85 kB
TypeScript
import { EventDispatcher, WebGLRenderer } from 'three';
import { Event } from 'three';
import ModelScene from './ModelScene.js';
import TextureUtils from './TextureUtils.js';
export interface ContextLostEvent extends Event {
type: 'contextlost';
sourceEvent: WebGLContextEvent;
}
export declare const $arRenderer: unique symbol;
declare const $onWebGLContextLost: unique symbol;
declare const $webGLContextLostHandler: unique symbol;
/**
* Registers canvases with Canvas2DRenderingContexts and renders them
* all in the same WebGLRenderingContext, spitting out textures to apply
* to the canvases. Creates a fullscreen WebGL canvas that is not added
* to the DOM, and on each frame, renders each registered canvas on a portion
* of the WebGL canvas, and applies the texture on the registered canvas.
*
* In the future, can use ImageBitmapRenderingContext instead of
* Canvas2DRenderingContext if supported for cheaper transfering of
* the texture.
*/
export declare class Renderer extends EventDispatcher {
renderer: WebGLRenderer;
context: WebGLRenderingContext | null;
canvas: HTMLCanvasElement;
textureUtils: TextureUtils | null;
width: number;
height: number;
private [$arRenderer];
private scenes;
private lastTick;
private [$webGLContextLostHandler];
readonly canRender: boolean;
constructor();
setRendererSize(width: number, height: number): void;
registerScene(scene: ModelScene): void;
unregisterScene(scene: ModelScene): void;
supportsPresentation(): Promise<boolean>;
readonly presentedScene: ModelScene | null;
present(scene: ModelScene): Promise<void>;
stopPresenting(): Promise<void>;
readonly isPresenting: boolean;
render(t: number): void;
dispose(): void;
[$onWebGLContextLost](event: WebGLContextEvent): void;
}
export {};