UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

92 lines 2.77 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Rendering */ /** @internal */ export class MeshPolyline { indices; constructor(indices = []) { this.indices = indices.slice(); } addIndex(index) { const { indices } = this; if (indices.length === 0 || indices[indices.length - 1] !== index) indices.push(index); } clear() { this.indices.length = 0; } } /** @internal */ export class MeshEdge { indices = [0, 0]; constructor(index0, index1) { if (undefined === index0 || undefined === index1) return; if (index0 < index1) { this.indices[0] = index0; this.indices[1] = index1; } else { this.indices[0] = index1; this.indices[1] = index0; } } compareTo(other) { let diff = this.indices[0] - other.indices[0]; if (0 === diff) diff = this.indices[1] - other.indices[1]; return diff; } } /** @internal */ export class MeshEdges { visible = []; silhouette = []; polylines = []; silhouetteNormals = []; constructor() { } } /** @internal */ export class EdgeArgs { edges; init(meshEdges) { this.clear(); if (undefined !== meshEdges && 0 < meshEdges.visible.length) this.edges = meshEdges.visible; return this.isValid; } clear() { this.edges = undefined; } get isValid() { return 0 < this.numEdges; } get numEdges() { return undefined !== this.edges ? this.edges.length : 0; } } /** @internal */ export class SilhouetteEdgeArgs extends EdgeArgs { normals; init(meshEdges) { this.clear(); if (undefined !== meshEdges && 0 < meshEdges.silhouette.length) { this.edges = meshEdges.silhouette; this.normals = meshEdges.silhouetteNormals; } return this.isValid; } clear() { this.normals = undefined; super.clear(); } } /** @internal */ export class PolylineEdgeArgs { lines; constructor(lines) { this.init(lines); } init(lines) { this.lines = undefined !== lines && 0 < lines.length ? lines : undefined; return this.isValid; } get numLines() { return undefined !== this.lines ? this.lines.length : 0; } get isValid() { return this.numLines > 0; } clear() { this.lines = undefined; } } //# sourceMappingURL=RenderMesh.js.map