@speckle/viewer
Version:
A 3d viewer for Speckle, based on threejs.
61 lines (60 loc) • 2.73 kB
TypeScript
import { WebGLCapabilities } from 'three';
import LineBatch from './LineBatch.js';
import Materials from '../materials/Materials.js';
import { NodeRenderView } from '../tree/NodeRenderView.js';
import { type Batch, type BatchUpdateRange, GeometryType } from './Batch.js';
import { Material, WebGLRenderer } from 'three';
import { RenderTree } from '../tree/RenderTree.js';
import TextBatch from './TextBatch.js';
import { SpeckleType } from '../loaders/GeometryConverter.js';
import { WorldTree } from '../../index.js';
import { MeshBatch } from './MeshBatch.js';
import { PointBatch } from './PointBatch.js';
import { ObjectVisibility } from '../pipeline/Passes/GPass.js';
type BatchTypeMap = {
[GeometryType.MESH]: MeshBatch;
[GeometryType.LINE]: LineBatch;
[GeometryType.POINT]: PointBatch;
[GeometryType.POINT_CLOUD]: PointBatch;
[GeometryType.TEXT]: TextBatch;
};
export default class Batcher {
private caps;
private maxBatchObjects;
private maxBatchVertices;
private minInstancedBatchVertices;
materials: Materials;
batches: {
[id: string]: Batch;
};
constructor(caps: WebGLCapabilities);
makeBatches(worldTree: WorldTree, renderTree: RenderTree, speckleType: SpeckleType[], batchType?: GeometryType): AsyncGenerator<Batch, void, unknown>;
private splitBatch;
private buildInstancedBatch;
private buildBatch;
update(deltaTime: number): void;
render(renderer: WebGLRenderer): void;
saveVisiblity(): Record<string, BatchUpdateRange>;
applyVisibility(ranges: Record<string, BatchUpdateRange>): void;
getVisibility(objectVisibility: ObjectVisibility): Record<string, BatchUpdateRange>;
getTransparent(): Record<string, BatchUpdateRange>;
getStencil(): Record<string, BatchUpdateRange>;
getOpaque(): Record<string, BatchUpdateRange>;
getDepth(): Record<string, BatchUpdateRange>;
overrideMaterial(ranges: Record<string, BatchUpdateRange>, material: Material): void;
overrideBatchMaterial(ranges: Record<string, BatchUpdateRange>, material: Material): void;
restoreMaterial(ranges: Record<string, BatchUpdateRange>): void;
restoreBatchMaterial(ranges: Record<string, BatchUpdateRange>): void;
purgeBatches(subtreeId: string): void;
getBatches<K extends GeometryType>(subtreeId?: string, geometryType?: K): BatchTypeMap[K][];
private isBatchType;
getBatch(rv: NodeRenderView): Batch | undefined;
getRenderView(batchId: string, index: number): NodeRenderView | null;
getRenderViewMaterial(batchId: string, index: number): Material | null;
resetBatchesDrawRanges(): void;
/**
* Used for debuggin only
*/
isolateBatch(batchId: string): void;
}
export {};