@itwin/core-frontend
Version:
iTwin.js frontend components
83 lines • 3.48 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module WebGL
*/
import { assert, dispose } from "@itwin/core-bentley";
import { FeatureIndexType } from "@itwin/core-common";
import { AttributeMap } from "./AttributeMap";
import { LUTGeometry } from "./CachedGeometry";
import { GL } from "./GL";
import { BufferHandle, BufferParameters, BuffersContainer } from "./AttributeBuffers";
import { System } from "./System";
import { VertexLUT } from "./VertexLUT";
/** @internal */
export class PointStringGeometry extends LUTGeometry {
renderGeometryType = "point-string";
isInstanceable;
noDispose = false;
buffers;
vertexParams;
_hasFeatures;
weight;
lut;
indices;
numIndices;
get lutBuffers() { return this.buffers; }
constructor(indices, numIndices, lut, qparams, weight, hasFeatures, viOrigin) {
super(viOrigin);
this.isInstanceable = undefined === viOrigin;
this.buffers = BuffersContainer.create();
const attrPos = AttributeMap.findAttribute("a_pos", 3 /* TechniqueId.PointString */, false);
assert(undefined !== attrPos);
this.buffers.addBuffer(indices, [BufferParameters.create(attrPos.location, 3, GL.DataType.UnsignedByte, false, 0, 0, false)]);
this.numIndices = numIndices;
this.indices = indices;
this.lut = lut;
this.vertexParams = qparams;
this.weight = weight;
this._hasFeatures = hasFeatures;
}
_wantWoWReversal(_target) { return true; }
get techniqueId() { return 3 /* TechniqueId.PointString */; }
getPass() { return "opaque-linear"; }
get hasFeatures() { return this._hasFeatures; }
get renderOrder() { return 13 /* RenderOrder.PlanarLinear */; }
_getLineWeight(_params) { return this.weight; }
_draw(numInstances, instanceBuffersContainer) {
const gl = System.instance;
const bufs = instanceBuffersContainer !== undefined ? instanceBuffersContainer : this.buffers;
bufs.bind();
gl.drawArrays(GL.PrimitiveType.Points, 0, this.numIndices, numInstances);
bufs.unbind();
}
static create(params, viOrigin) {
const indices = BufferHandle.createArrayBuffer(params.indices.data);
if (undefined === indices)
return undefined;
const lut = VertexLUT.createFromVertexTable(params.vertices);
if (undefined === lut)
return undefined;
const hasFeatures = FeatureIndexType.Empty !== params.vertices.featureIndexType;
return new PointStringGeometry(indices, params.indices.length, lut, params.vertices.qparams, params.weight, hasFeatures, viOrigin);
}
get isDisposed() {
return this.buffers.isDisposed
&& this.lut.isDisposed
&& this.indices.isDisposed;
}
[Symbol.dispose]() {
if (!this.noDispose) {
dispose(this.buffers);
dispose(this.lut);
dispose(this.indices);
}
}
collectStatistics(stats) {
stats.addVertexTable(this.lut.bytesUsed);
stats.addPointString(this.indices.bytesUsed);
}
}
//# sourceMappingURL=PointString.js.map