UNPKG

@itwin/core-common

Version:

iTwin.js components common to frontend and backend

101 lines 3.17 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 = []; polylines = []; 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 { 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; } } exports.PolylineEdgeArgs = PolylineEdgeArgs; //# sourceMappingURL=RenderMesh.js.map