@itwin/core-frontend
Version:
iTwin.js frontend components
57 lines • 2.56 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* 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
*/
import { RenderMode } from "@itwin/core-common";
import { LUTGeometry } from "./CachedGeometry";
/** Defines one aspect of the geometry of a mesh (surface or edges)
* @internal
*/
export class MeshGeometry extends LUTGeometry {
mesh;
_numIndices;
get asMesh() { return this; }
_getLineWeight(params) { return this.computeEdgeWeight(params); }
// Convenience accessors...
get edgeWidth() { return this.mesh.edgeWidth; }
get edgeLineCode() { return this.mesh.edgeLineCode; }
get hasFeatures() { return this.mesh.hasFeatures; }
get surfaceType() { return this.mesh.type; }
get fillFlags() { return this.mesh.fillFlags; }
get isPlanar() { return this.mesh.isPlanar; }
get colorInfo() { return this.mesh.lut.colorInfo; }
get uniformColor() { return this.colorInfo.isUniform ? this.colorInfo.uniform : undefined; }
get texture() { return this.mesh.texture; }
get normalMap() { return this.mesh.normalMap; }
get hasBakedLighting() { return this.mesh.hasBakedLighting; }
get lut() { return this.mesh.lut; }
get hasScalarAnimation() { return this.mesh.lut.hasScalarAnimation; }
constructor(mesh, numIndices) {
super(mesh.viewIndependentOrigin);
this._numIndices = numIndices;
this.mesh = mesh;
}
computeEdgeWeight(params) {
return params.target.computeEdgeWeight(params.renderPass, this.edgeWidth);
}
computeEdgeLineCode(params) {
return params.target.computeEdgeLineCode(params.renderPass, this.edgeLineCode);
}
computeEdgeColor(target) {
return target.computeEdgeColor(this.colorInfo);
}
computeEdgePass(target) {
if (target.isDrawingShadowMap)
return "none";
const vf = target.currentViewFlags;
if (RenderMode.SmoothShade === vf.renderMode && !vf.visibleEdges)
return "none";
// Only want translucent edges in wireframe mode.
const isTranslucent = RenderMode.Wireframe === vf.renderMode && vf.transparency && this.colorInfo.hasTranslucency;
return isTranslucent ? "translucent" : "opaque-linear";
}
}
//# sourceMappingURL=MeshGeometry.js.map