UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

104 lines 3.18 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 Rendering */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PolylineEdgeArgs = exports.SilhouetteEdgeArgs = exports.EdgeArgs = exports.MeshEdges = exports.MeshEdge = exports.MeshPolyline = void 0; /** @internal */ 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; } } exports.MeshPolyline = MeshPolyline; /** @internal */ 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; } } exports.MeshEdge = MeshEdge; /** @internal */ class MeshEdges { visible = []; silhouette = []; appearance; polylineGroups = []; silhouetteNormals = []; constructor() { } } exports.MeshEdges = MeshEdges; /** @internal */ 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; } } exports.EdgeArgs = EdgeArgs; /** @internal */ 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(); } } exports.SilhouetteEdgeArgs = SilhouetteEdgeArgs; /** @internal */ 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; } } exports.PolylineEdgeArgs = PolylineEdgeArgs; //# sourceMappingURL=RenderMesh.js.map