UNPKG

@qctrl/visualizer

Version:

The Q-CTRL Visualizer is a package for displaying animated 3d Bloch sphere visualizations.

47 lines (46 loc) 2.07 kB
import { Vector3Tuple, WebGLRenderer, Color } from "three"; import { Styles } from "../styles/theme"; import { CustomLabel } from "../types"; import Viewport, { UpdateMethodProps } from "./Viewport"; interface SceneManagerProps { canvasRef: HTMLCanvasElement; viewportDiv: HTMLElement; data: Vector3Tuple[]; nonErrorStateData?: Vector3Tuple[]; segmentIndexes: number[]; initialFrameIndex: number; finalFrameIndex: number; style: Styles; continuousSegments?: boolean; drawArcs?: boolean; drawPaths: boolean; skipLastLineDraw?: boolean; customLabels?: CustomLabel[]; onControlsStart?: () => void; onControlsEnd?: () => void; onControlsChange?: () => void; } /** * The SceneManager class manages the entire threejs 'scene' including the renderer, * Canvas element/webgl context, and each "Element" (consisting of a sub scene, a camera and some three objects) of the threejs scene */ declare class SceneManager { canvasRef: HTMLCanvasElement; renderer: WebGLRenderer | undefined; backgroundColor: string | Color; viewport: Viewport; canvasResize: { stop(): void; forceResize(): void; }; constructor({ canvasRef, initialFrameIndex, finalFrameIndex, continuousSegments, segmentIndexes, drawArcs, data, nonErrorStateData, style, drawPaths, skipLastLineDraw, customLabels, onControlsStart, onControlsEnd, onControlsChange, viewportDiv, }: SceneManagerProps); threeCleanup(): void; setBackgroundColor(backgroundColor?: string): void; /** * This method sets the viewport of the renderer for each "element" and then renders that element's scene to the specific viewport of the renderer/webgl context * It also calls the update method of the element with any updates passed into the SceneManager's update method. * Finally it calls any matching methods in the scene manager instance from the updates passed in */ update({ frameIndex, currentSegmentNumber, updates, props, }: UpdateMethodProps): void; } export default SceneManager;