UNPKG

@itwin/core-frontend

Version:
87 lines 3.83 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PointStringGeometry = void 0; const core_bentley_1 = require("@itwin/core-bentley"); const core_common_1 = require("@itwin/core-common"); const AttributeMap_1 = require("./AttributeMap"); const CachedGeometry_1 = require("./CachedGeometry"); const GL_1 = require("./GL"); const AttributeBuffers_1 = require("./AttributeBuffers"); const System_1 = require("./System"); const VertexLUT_1 = require("./VertexLUT"); /** @internal */ class PointStringGeometry extends CachedGeometry_1.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 = AttributeBuffers_1.BuffersContainer.create(); const attrPos = AttributeMap_1.AttributeMap.findAttribute("a_pos", 3 /* TechniqueId.PointString */, false); (0, core_bentley_1.assert)(undefined !== attrPos); this.buffers.addBuffer(indices, [AttributeBuffers_1.BufferParameters.create(attrPos.location, 3, GL_1.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_1.System.instance; const bufs = instanceBuffersContainer !== undefined ? instanceBuffersContainer : this.buffers; bufs.bind(); gl.drawArrays(GL_1.GL.PrimitiveType.Points, 0, this.numIndices, numInstances); bufs.unbind(); } static create(params, viOrigin) { const indices = AttributeBuffers_1.BufferHandle.createArrayBuffer(params.indices.data); if (undefined === indices) return undefined; const lut = VertexLUT_1.VertexLUT.createFromVertexTable(params.vertices); if (undefined === lut) return undefined; const hasFeatures = core_common_1.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) { (0, core_bentley_1.dispose)(this.buffers); (0, core_bentley_1.dispose)(this.lut); (0, core_bentley_1.dispose)(this.indices); } } collectStatistics(stats) { stats.addVertexTable(this.lut.bytesUsed); stats.addPointString(this.indices.bytesUsed); } } exports.PointStringGeometry = PointStringGeometry; //# sourceMappingURL=PointString.js.map