UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

95 lines 2.78 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 = []; appearance; polylineGroups = []; 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 { groups; constructor(groups) { this.init(groups); } init(groups) { this.groups = groups?.filter((group) => group.polylines.length > 0); return this.isValid; } get numGroups() { return this.groups?.length ?? 0; } get isValid() { return this.numGroups > 0; } clear() { this.groups = undefined; } } //# sourceMappingURL=RenderMesh.js.map