/** * Copyright (c) 2018-2026 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose * @author David Sehnal * @author Gianluca Tomasello * @author Herman Bergwerf */ import { BehaviorSubject, Subject } from 'rxjs'; import { now } from '../mol-util/now.js'; import { Vec3, Vec2 } from '../mol-math/linear-algebra.js'; import { InputObserver, ModifiersKeys, ButtonsType } from '../mol-util/input/input-observer.js'; import { RendererStats } from '../mol-gl/renderer.js'; import { GraphicsRenderObject } from '../mol-gl/render-object.js'; import { WebGLContext } from '../mol-gl/webgl/context.js'; import { Representation } from '../mol-repr/representation.js'; import { PickingId } from '../mol-geo/geometry/picking.js'; import { MarkerAction } from '../mol-util/marker-action.js'; import { Camera } from './camera.js'; import { ParamDefinition as PD } from '../mol-util/param-definition.js'; import { Canvas3dInteractionHelper } from './helper/interaction-events.js'; import { AsyncPickData, PickData } from './passes/pick.js'; import { ImagePass, ImageProps } from './passes/image.js'; import { Sphere3D } from '../mol-math/geometry.js'; import { Passes } from './passes/passes.js'; import { AssetManager } from '../mol-util/assets.js'; import { Ray3D } from '../mol-math/geometry/primitives/ray3d.js'; export declare const CameraFogParams: { intensity: PD.Numeric; }; export declare const Canvas3DParams: { camera: PD.Group; stereo: PD.NamedParams, "off"> | PD.NamedParams, "on">; fov: number; manualReset: boolean; }>>; cameraFog: PD.Mapped, "off"> | PD.NamedParams, "on">>; cameraClipping: PD.Group>; viewport: PD.Mapped, "canvas"> | PD.NamedParams, "static-frame"> | PD.NamedParams, "relative-frame">>; cameraResetDurationMs: PD.Numeric; sceneRadiusFactor: PD.Numeric; transparentBackground: PD.BooleanParam; checkeredTransparentBackground: PD.BooleanParam; dpoitIterations: PD.Numeric; pickPadding: PD.Numeric; userInteractionReleaseMs: PD.Numeric; multiSample: PD.Group>; postprocessing: PD.Group, "off"> | PD.NamedParams, "on">; shadow: PD.NamedParams, "off"> | PD.NamedParams, "on">; outline: PD.NamedParams, "off"> | PD.NamedParams, "on">; dof: PD.NamedParams, "off"> | PD.NamedParams, "on">; antialiasing: PD.NamedParams, "off"> | PD.NamedParams, "smaa"> | PD.NamedParams, "fxaa">; sharpening: PD.NamedParams, "off"> | PD.NamedParams, "on">; background: PD.Normalize<{ variant: /*elided*/ any; }>; bloom: PD.NamedParams, "off"> | PD.NamedParams, "on">; }>>; marking: PD.Group>; illumination: PD.Group>; hiZ: PD.Group>; renderer: PD.Group[]; ambientColor: import("../mol-util/color/index.js").Color; ambientIntensity: number; }>>; trackball: PD.Group, "off"> | PD.NamedParams, "spin"> | PD.NamedParams, "rock">; staticMoving: boolean; dynamicDampingFactor: number; minDistance: number; maxDistance: number; gestureScaleFactor: number; maxWheelDelta: number; autoAdjustMinMaxDistance: PD.NamedParams, "off"> | PD.NamedParams, "on">; }>>; interaction: PD.Group>; debug: PD.Group>; handle: PD.Group, "off"> | PD.NamedParams, "on">; }>>; pointer: PD.Group; alpha: number; quality: "auto" | "medium" | "high" | "low" | "custom" | "highest" | "higher" | "lower" | "lowest"; material: PD.Normalize<{ metalness: number; roughness: number; bumpiness: number; }>; clip: PD.Normalize<{ variant: /*elided*/ any; objects: /*elided*/ any; }>; emissive: number; density: number; instanceGranularity: boolean; lod: Vec3; cellSize: number; batchSize: number; }>>; xr: PD.Group>; }; export declare const DefaultCanvas3DParams: PD.Values<{ camera: PD.Group; stereo: PD.NamedParams, "off"> | PD.NamedParams, "on">; fov: number; manualReset: boolean; }>>; cameraFog: PD.Mapped, "off"> | PD.NamedParams, "on">>; cameraClipping: PD.Group>; viewport: PD.Mapped, "canvas"> | PD.NamedParams, "static-frame"> | PD.NamedParams, "relative-frame">>; cameraResetDurationMs: PD.Numeric; sceneRadiusFactor: PD.Numeric; transparentBackground: PD.BooleanParam; checkeredTransparentBackground: PD.BooleanParam; dpoitIterations: PD.Numeric; pickPadding: PD.Numeric; userInteractionReleaseMs: PD.Numeric; multiSample: PD.Group>; postprocessing: PD.Group, "off"> | PD.NamedParams, "on">; shadow: PD.NamedParams, "off"> | PD.NamedParams, "on">; outline: PD.NamedParams, "off"> | PD.NamedParams, "on">; dof: PD.NamedParams, "off"> | PD.NamedParams, "on">; antialiasing: PD.NamedParams, "off"> | PD.NamedParams, "smaa"> | PD.NamedParams, "fxaa">; sharpening: PD.NamedParams, "off"> | PD.NamedParams, "on">; background: PD.Normalize<{ variant: /*elided*/ any; }>; bloom: PD.NamedParams, "off"> | PD.NamedParams, "on">; }>>; marking: PD.Group>; illumination: PD.Group>; hiZ: PD.Group>; renderer: PD.Group[]; ambientColor: import("../mol-util/color/index.js").Color; ambientIntensity: number; }>>; trackball: PD.Group, "off"> | PD.NamedParams, "spin"> | PD.NamedParams, "rock">; staticMoving: boolean; dynamicDampingFactor: number; minDistance: number; maxDistance: number; gestureScaleFactor: number; maxWheelDelta: number; autoAdjustMinMaxDistance: PD.NamedParams, "off"> | PD.NamedParams, "on">; }>>; interaction: PD.Group>; debug: PD.Group>; handle: PD.Group, "off"> | PD.NamedParams, "on">; }>>; pointer: PD.Group; alpha: number; quality: "auto" | "medium" | "high" | "low" | "custom" | "highest" | "higher" | "lower" | "lowest"; material: PD.Normalize<{ metalness: number; roughness: number; bumpiness: number; }>; clip: PD.Normalize<{ variant: /*elided*/ any; objects: /*elided*/ any; }>; emissive: number; density: number; instanceGranularity: boolean; lod: Vec3; cellSize: number; batchSize: number; }>>; xr: PD.Group>; }>; export type Canvas3DProps = PD.Values; export type PartialCanvas3DProps = { [K in keyof Canvas3DProps]?: Canvas3DProps[K] extends { name: string; params: any; } ? Canvas3DProps[K] : Partial; }; export declare const DefaultCanvas3DAttribs: { trackball: { bindings: { dragRotate: import("../mol-util/binding.js").Binding; dragRotateZ: import("../mol-util/binding.js").Binding; dragPan: import("../mol-util/binding.js").Binding; dragZoom: import("../mol-util/binding.js").Binding; dragFocus: import("../mol-util/binding.js").Binding; dragFocusZoom: import("../mol-util/binding.js").Binding; scrollZoom: import("../mol-util/binding.js").Binding; scrollFocus: import("../mol-util/binding.js").Binding; scrollFocusZoom: import("../mol-util/binding.js").Binding; keyMoveForward: import("../mol-util/binding.js").Binding; keyMoveBack: import("../mol-util/binding.js").Binding; keyMoveLeft: import("../mol-util/binding.js").Binding; keyMoveRight: import("../mol-util/binding.js").Binding; keyMoveUp: import("../mol-util/binding.js").Binding; keyMoveDown: import("../mol-util/binding.js").Binding; keyRollLeft: import("../mol-util/binding.js").Binding; keyRollRight: import("../mol-util/binding.js").Binding; keyPitchUp: import("../mol-util/binding.js").Binding; keyPitchDown: import("../mol-util/binding.js").Binding; keyYawLeft: import("../mol-util/binding.js").Binding; keyYawRight: import("../mol-util/binding.js").Binding; boostMove: import("../mol-util/binding.js").Binding; enablePointerLock: import("../mol-util/binding.js").Binding; }; }; xr: { bindings: { exit: import("../mol-util/binding.js").Binding; togglePassthrough: import("../mol-util/binding.js").Binding; gestureScale: import("../mol-util/binding.js").Binding; }; }; }; export type Canvas3DAttribs = typeof DefaultCanvas3DAttribs; export type PartialCanvas3DAttribs = { [K in keyof Canvas3DAttribs]?: Canvas3DAttribs[K] extends { name: string; params: any; } ? Canvas3DAttribs[K] : Partial; }; export { Canvas3DContext }; /** Can be used to create multiple Canvas3D objects */ interface Canvas3DContext { readonly canvas?: HTMLCanvasElement; readonly webgl: WebGLContext; readonly input: InputObserver; readonly passes: Passes; readonly attribs: Readonly; readonly props: Readonly; readonly contextLost?: Subject; readonly contextRestored?: Subject; readonly assetManager: AssetManager; readonly changed?: BehaviorSubject; readonly pixelScale: number; syncPixelScale(): void; setProps: (props?: Partial) => void; dispose: (options?: Partial<{ doNotForceWebGLContextLoss: boolean; }>) => void; } declare namespace Canvas3DContext { const DefaultAttribs: { powerPreference: WebGLContextAttributes["powerPreference"]; failIfMajorPerformanceCaveat: boolean; /** true by default to avoid issues with Safari (Jan 2021) */ antialias: boolean; /** true to support multiple Canvas3D objects with a single context */ preserveDrawingBuffer: boolean; preferWebGl1: boolean; handleResize: () => void; }; type Attribs = typeof DefaultAttribs; const Params: { resolutionMode: PD.Select<"auto" | "scaled" | "native">; pixelScale: PD.Numeric; pickScale: PD.Numeric; transparency: PD.Select<"blended" | "wboit" | "dpoit">; }; const DefaultProps: PD.Values<{ resolutionMode: PD.Select<"auto" | "scaled" | "native">; pixelScale: PD.Numeric; pickScale: PD.Numeric; transparency: PD.Select<"blended" | "wboit" | "dpoit">; }>; type Props = PD.Values; function fromCanvas(canvas: HTMLCanvasElement, assetManager: AssetManager, attribs?: Partial, props?: Partial): Canvas3DContext; } export { Canvas3D }; interface Canvas3D { readonly webgl: WebGLContext; add(repr: Representation.Any): void; remove(repr: Representation.Any): void; /** * This function must be called if animate() is not set up so that add/remove actions take place. */ commit(isSynchronous?: boolean): void; /** * Function for external "animation" control * Calls commit. */ tick(t: now.Timestamp, options?: { isSynchronous?: boolean; manualDraw?: boolean; updateControls?: boolean; xrFrame?: XRFrame; }): void; update(repr?: Representation.Any, keepBoundingSphere?: boolean): void; clear(): void; syncVisibility(): void; requestDraw(): void; /** Reset the timers, used by "animate" */ resetTime(t: number): void; animate(): void; /** * Pause animation loop and optionally any rendering * @param noDraw pause any rendering (drawPaused = true) */ pause(noDraw?: boolean): void; /** Sets drawPaused = false without starting the built in animation loop */ resume(): void; requestAnimationFrame(callback: FrameRequestCallback | XRFrameRequestCallback): number; cancelAnimationFrame(handle: number): void; identify(target: Vec2 | Ray3D): PickData | undefined; asyncIdentify(target: Vec2 | Ray3D): AsyncPickData | undefined; mark(loci: Representation.Loci, action: MarkerAction): void; getLoci(pickingId: PickingId | undefined): Representation.Loci; notifyDidDraw: boolean; readonly didDraw: BehaviorSubject; readonly commited: BehaviorSubject; readonly commitQueueSize: BehaviorSubject; readonly reprCount: BehaviorSubject; readonly resized: BehaviorSubject; handleResize(): void; /** performs handleResize on the next animation frame */ requestResize(): void; /** Focuses camera on scene's bounding sphere, centered and zoomed. */ requestCameraReset(options?: { durationMs?: number; snapshot?: Camera.SnapshotProvider; }): void; readonly camera: Camera; readonly boundingSphere: Readonly; readonly boundingSphereVisible: Readonly; setProps(props: PartialCanvas3DProps | ((old: Canvas3DProps) => Partial | void), doNotRequestDraw?: boolean): void; setAttribs(attribs: PartialCanvas3DAttribs): void; getImagePass(props: Partial): ImagePass; getRenderObjects(): GraphicsRenderObject[]; /** Returns a copy of the current Canvas3D instance props */ readonly props: Readonly; readonly attribs: Readonly; readonly input: InputObserver; readonly stats: RendererStats; readonly interaction: Canvas3dInteractionHelper['events']; readonly xr: { request(): Promise; end(): Promise; readonly isSupported: BehaviorSubject; readonly isPresenting: BehaviorSubject; readonly requestFailed: Subject; }; dispose(): void; } declare namespace Canvas3D { interface HoverEvent { current: Representation.Loci; buttons: ButtonsType; button: ButtonsType.Flag; modifiers: ModifiersKeys; page?: Vec2; position?: Vec3; } interface DragEvent { current: Representation.Loci; buttons: ButtonsType; button: ButtonsType.Flag; modifiers: ModifiersKeys; pageStart: Vec2; pageEnd: Vec2; } interface ClickEvent { current: Representation.Loci; buttons: ButtonsType; button: ButtonsType.Flag; modifiers: ModifiersKeys; page?: Vec2; position?: Vec3; } function create(ctx: Canvas3DContext, props?: Partial, attribs?: Partial): Canvas3D; }