/** * Copyright (c) 2018-2026 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose */ import { Program } from './webgl/program.js'; import { RenderableValues, Values, RenderableSchema, BaseValues } from './renderable/schema.js'; import { GraphicsRenderItem, ComputeRenderItem, GraphicsRenderVariant, MultiDrawBaseData, Transparency } from './webgl/render-item.js'; import { ValueCell } from '../mol-util/value-cell.js'; import { Frustum3D } from '../mol-math/geometry/primitives/frustum3d.js'; import { Plane3D } from '../mol-math/geometry/primitives/plane3d.js'; import { Sphere3D } from '../mol-math/geometry/primitives/sphere3d.js'; import { Vec4 } from '../mol-math/linear-algebra/3d/vec4.js'; import { WebGLStats } from './webgl/context.js'; import { InstanceGrid } from '../mol-math/geometry/instance-grid.js'; import { Clip } from '../mol-util/clip.js'; declare const frameBrand: unique symbol; export type Frame = { readonly [frameBrand]: never; }; /** Mint a new frame token - call this whenever an owner starts a new logical "frame". */ export declare function createFrame(): Frame; export type RenderableState = { disposed: boolean; visible: boolean; alphaFactor: number; pickable: boolean; colorOnly: boolean; opaque: boolean; writeDepth: boolean; }; export interface Renderable { readonly id: number; readonly materialId: number; readonly values: T; readonly state: RenderableState; cull: (cameraPlane: Plane3D, frustum: Frustum3D, isOccluded: ((s: Sphere3D) => boolean) | null, stats: WebGLStats, frame: Frame) => void; uncull: () => void; cullSimple: (d: number, radius: number, scale: number) => void; render: (variant: GraphicsRenderVariant, sharedTexturesCount: number) => void; /** Cached clip info, `undefined` if there are no clip objects */ getClipInfo: () => ClipInfo | undefined; getByteCount: () => number; getProgram: (variant: GraphicsRenderVariant) => Program; setTransparency: (transparency: Transparency) => void; update: () => void; dispose: () => void; } export type LodLevelsValue = [minDistance: number, maxDistance: number, overlap: number, count: number, scale: number][]; /** The minimal set of values needed to cull a (segment of a) render item. */ export type CullValues = { readonly drawCount: ValueCell; readonly instanceCount: ValueCell; readonly uLod: ValueCell; readonly instanceGrid: ValueCell; readonly boundingSphere: ValueCell; readonly lodLevels?: ValueCell; }; export type CullSegment = { /** first vertex of the segment, for non-indexed draws */ first: number; /** byte offset into the element buffer, for indexed draws */ offset: number; /** first instance of the segment in the instanced attributes */ instanceBase: number; }; export declare const ZeroCullSegment: CullSegment; /** * A multi-draw-base-data list (one entry per lod level) that can be filled * from multiple segments sharing one render item. */ export interface SegmentedMdbList { readonly list: MultiDrawBaseData[]; /** resize and reset the list and refresh the per-level uLod (and, if segmented, uLodLevel) uniforms */ prepare: (lodCell: ValueCell | undefined, capacity: number, segmented: boolean) => LodLevelsValue | undefined; /** append a draw entry, extending the previous entry when contiguous */ append: (l: MultiDrawBaseData, first: number, offset: number, count: number, instanceCount: number, baseInstance: number) => void; /** * Cull a segment against its instance grid and append draw entries. * Returns false without appending if the segment has no usable grid. * With `wholeSegmentFallback` gridless segments are instead culled as a * whole using their bounding sphere. */ cullSegment: (values: CullValues, segment: CullSegment, lodLevels: LodLevelsValue | undefined, cameraPlane: Plane3D, frustum: Frustum3D, isOccluded: ((s: Sphere3D) => boolean) | null, stats: WebGLStats, wholeSegmentFallback: boolean) => boolean; /** append draw entries for the whole segment without culling */ fullSegment: (values: CullValues, segment: CullSegment, lodLevels: LodLevelsValue | undefined) => void; /** append the draw entry for the lod level matching the given distance */ cullSimpleSegment: (values: CullValues, segment: CullSegment, lodLevels: LodLevelsValue, d: number, radius: number, scale: number) => void; } export declare function createSegmentedMdbList(): SegmentedMdbList; type GraphicsRenderableValues = RenderableValues & BaseValues; export declare function createRenderable(renderItem: GraphicsRenderItem, values: T, state: RenderableState): Renderable; export type GraphicsRenderable = Renderable; export type ClipInfo = { readonly objects: Clip.Objects; /** Planes of the plane-type clip objects, see `Clip.getPlane`, only for the pixel variant */ readonly planes: Plane3D[]; /** Indices of clip objects whose surface can intersect the bounding sphere, only for the pixel variant */ readonly capIndices: number[]; }; export interface ClipInfoCache { /** Clip info, recomputed when any of its inputs changed, `undefined` if there are no clip objects */ readonly get: () => ClipInfo | undefined; } export declare function createClipInfoCache(values: BaseValues): ClipInfoCache; export interface ComputeRenderable { readonly id: number; readonly values: T; render: () => void; update: () => void; dispose: () => void; } export declare function createComputeRenderable>(renderItem: ComputeRenderItem, values: T): ComputeRenderable; export {};