@itwin/core-frontend 3.0.0-dev.136 → 3.0.0-dev.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/AccuSnap.js +3 -3
- package/lib/cjs/AccuSnap.js.map +1 -1
- package/lib/cjs/ApproximateTerrainHeights.d.ts.map +1 -1
- package/lib/cjs/ApproximateTerrainHeights.js +2 -1
- package/lib/cjs/ApproximateTerrainHeights.js.map +1 -1
- package/lib/cjs/HitDetail.js +7 -7
- package/lib/cjs/HitDetail.js.map +1 -1
- package/lib/cjs/IModelApp.d.ts +15 -5
- package/lib/cjs/IModelApp.d.ts.map +1 -1
- package/lib/cjs/IModelApp.js +13 -8
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/IModelConnection.d.ts +1 -1
- package/lib/cjs/IModelConnection.js +1 -1
- package/lib/cjs/IModelConnection.js.map +1 -1
- package/lib/cjs/IModeljs-css.js +1 -1
- package/lib/cjs/IModeljs-css.js.map +1 -1
- package/lib/cjs/LocalhostIpcApp.d.ts +2 -1
- package/lib/cjs/LocalhostIpcApp.d.ts.map +1 -1
- package/lib/cjs/LocalhostIpcApp.js +21 -7
- package/lib/cjs/LocalhostIpcApp.js.map +1 -1
- package/lib/cjs/ViewManager.d.ts.map +1 -1
- package/lib/cjs/ViewManager.js +8 -8
- package/lib/cjs/ViewManager.js.map +1 -1
- package/lib/cjs/Viewport.d.ts +1 -1
- package/lib/cjs/Viewport.js +2 -2
- package/lib/cjs/Viewport.js.map +1 -1
- package/lib/cjs/core-frontend.d.ts +1 -1
- package/lib/cjs/core-frontend.js +1 -1
- package/lib/cjs/core-frontend.js.map +1 -1
- package/lib/cjs/render/MockRender.d.ts +3 -1
- package/lib/cjs/render/MockRender.d.ts.map +1 -1
- package/lib/cjs/render/MockRender.js.map +1 -1
- package/lib/cjs/render/RenderSystem.d.ts +3 -1
- package/lib/cjs/render/RenderSystem.d.ts.map +1 -1
- package/lib/cjs/render/RenderSystem.js +4 -2
- package/lib/cjs/render/RenderSystem.js.map +1 -1
- package/lib/cjs/render/primitives/EdgeParams.d.ts +50 -0
- package/lib/cjs/render/primitives/EdgeParams.d.ts.map +1 -0
- package/lib/cjs/render/primitives/EdgeParams.js +116 -0
- package/lib/cjs/render/primitives/EdgeParams.js.map +1 -0
- package/lib/cjs/render/primitives/PointStringParams.d.ts +16 -0
- package/lib/cjs/render/primitives/PointStringParams.d.ts.map +1 -0
- package/lib/cjs/render/primitives/PointStringParams.js +43 -0
- package/lib/cjs/render/primitives/PointStringParams.js.map +1 -0
- package/lib/cjs/render/primitives/PolylineParams.d.ts +44 -0
- package/lib/cjs/render/primitives/PolylineParams.d.ts.map +1 -0
- package/lib/cjs/render/primitives/PolylineParams.js +205 -0
- package/lib/cjs/render/primitives/PolylineParams.js.map +1 -0
- package/lib/cjs/render/primitives/SurfaceParams.d.ts +46 -0
- package/lib/cjs/render/primitives/SurfaceParams.d.ts.map +1 -0
- package/lib/cjs/render/primitives/SurfaceParams.js +42 -0
- package/lib/cjs/render/primitives/SurfaceParams.js.map +1 -0
- package/lib/cjs/render/primitives/VertexTable.d.ts +3 -123
- package/lib/cjs/render/primitives/VertexTable.d.ts.map +1 -1
- package/lib/cjs/render/primitives/VertexTable.js +10 -351
- package/lib/cjs/render/primitives/VertexTable.js.map +1 -1
- package/lib/cjs/render/webgl/CachedGeometry.d.ts +4 -2
- package/lib/cjs/render/webgl/CachedGeometry.d.ts.map +1 -1
- package/lib/cjs/render/webgl/CachedGeometry.js.map +1 -1
- package/lib/cjs/render/webgl/EdgeGeometry.d.ts +73 -0
- package/lib/cjs/render/webgl/EdgeGeometry.d.ts.map +1 -0
- package/lib/cjs/render/webgl/EdgeGeometry.js +141 -0
- package/lib/cjs/render/webgl/EdgeGeometry.js.map +1 -0
- package/lib/cjs/render/webgl/InstancedGeometry.d.ts +4 -4
- package/lib/cjs/render/webgl/InstancedGeometry.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Material.d.ts +1 -1
- package/lib/cjs/render/webgl/Material.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Material.js.map +1 -1
- package/lib/cjs/render/webgl/Mesh.d.ts +6 -162
- package/lib/cjs/render/webgl/Mesh.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Mesh.js +11 -456
- package/lib/cjs/render/webgl/Mesh.js.map +1 -1
- package/lib/cjs/render/webgl/MeshData.d.ts +38 -0
- package/lib/cjs/render/webgl/MeshData.d.ts.map +1 -0
- package/lib/cjs/render/webgl/MeshData.js +66 -0
- package/lib/cjs/render/webgl/MeshData.js.map +1 -0
- package/lib/cjs/render/webgl/MeshGeometry.d.ts +38 -0
- package/lib/cjs/render/webgl/MeshGeometry.d.ts.map +1 -0
- package/lib/cjs/render/webgl/MeshGeometry.js +60 -0
- package/lib/cjs/render/webgl/MeshGeometry.js.map +1 -0
- package/lib/cjs/render/webgl/PointString.d.ts +1 -1
- package/lib/cjs/render/webgl/PointString.d.ts.map +1 -1
- package/lib/cjs/render/webgl/PointString.js.map +1 -1
- package/lib/cjs/render/webgl/Polyline.d.ts +1 -1
- package/lib/cjs/render/webgl/Polyline.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Polyline.js.map +1 -1
- package/lib/cjs/render/webgl/RenderCommands.js +4 -4
- package/lib/cjs/render/webgl/RenderCommands.js.map +1 -1
- package/lib/cjs/render/webgl/SurfaceGeometry.d.ts +54 -0
- package/lib/cjs/render/webgl/SurfaceGeometry.d.ts.map +1 -0
- package/lib/cjs/render/webgl/SurfaceGeometry.js +240 -0
- package/lib/cjs/render/webgl/SurfaceGeometry.js.map +1 -0
- package/lib/cjs/render/webgl/System.d.ts +3 -1
- package/lib/cjs/render/webgl/System.d.ts.map +1 -1
- package/lib/cjs/render/webgl/System.js.map +1 -1
- package/lib/cjs/render/webgl/glsl/Surface.js +3 -3
- package/lib/cjs/render/webgl/glsl/Surface.js.map +1 -1
- package/lib/cjs/render-primitives.d.ts +5 -1
- package/lib/cjs/render-primitives.d.ts.map +1 -1
- package/lib/cjs/render-primitives.js +5 -1
- package/lib/cjs/render-primitives.js.map +1 -1
- package/lib/cjs/tile/ContextShareProvider.d.ts.map +1 -1
- package/lib/cjs/tile/ContextShareProvider.js +19 -0
- package/lib/cjs/tile/ContextShareProvider.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +8 -5
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/cjs/tile/map/CesiumTerrainProvider.js +1 -1
- package/lib/cjs/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
- package/lib/cjs/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/cjs/tile/map/MapLayerSources.js +1 -1
- package/lib/cjs/tile/map/MapLayerSources.js.map +1 -1
- package/lib/cjs/webgl.d.ts +4 -0
- package/lib/cjs/webgl.d.ts.map +1 -1
- package/lib/cjs/webgl.js +4 -0
- package/lib/cjs/webgl.js.map +1 -1
- package/lib/esm/AccuSnap.js +3 -3
- package/lib/esm/AccuSnap.js.map +1 -1
- package/lib/esm/ApproximateTerrainHeights.d.ts.map +1 -1
- package/lib/esm/ApproximateTerrainHeights.js +2 -1
- package/lib/esm/ApproximateTerrainHeights.js.map +1 -1
- package/lib/esm/HitDetail.js +7 -7
- package/lib/esm/HitDetail.js.map +1 -1
- package/lib/esm/IModelApp.d.ts +15 -5
- package/lib/esm/IModelApp.d.ts.map +1 -1
- package/lib/esm/IModelApp.js +13 -8
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/IModelConnection.d.ts +1 -1
- package/lib/esm/IModelConnection.js +1 -1
- package/lib/esm/IModelConnection.js.map +1 -1
- package/lib/esm/IModeljs-css.js +1 -1
- package/lib/esm/IModeljs-css.js.map +1 -1
- package/lib/esm/LocalhostIpcApp.d.ts +2 -1
- package/lib/esm/LocalhostIpcApp.d.ts.map +1 -1
- package/lib/esm/LocalhostIpcApp.js +22 -8
- package/lib/esm/LocalhostIpcApp.js.map +1 -1
- package/lib/esm/ViewManager.d.ts.map +1 -1
- package/lib/esm/ViewManager.js +8 -8
- package/lib/esm/ViewManager.js.map +1 -1
- package/lib/esm/Viewport.d.ts +1 -1
- package/lib/esm/Viewport.js +2 -2
- package/lib/esm/Viewport.js.map +1 -1
- package/lib/esm/core-frontend.d.ts +1 -1
- package/lib/esm/core-frontend.js +1 -1
- package/lib/esm/core-frontend.js.map +1 -1
- package/lib/esm/render/MockRender.d.ts +3 -1
- package/lib/esm/render/MockRender.d.ts.map +1 -1
- package/lib/esm/render/MockRender.js.map +1 -1
- package/lib/esm/render/RenderSystem.d.ts +3 -1
- package/lib/esm/render/RenderSystem.d.ts.map +1 -1
- package/lib/esm/render/RenderSystem.js +3 -1
- package/lib/esm/render/RenderSystem.js.map +1 -1
- package/lib/esm/render/primitives/EdgeParams.d.ts +50 -0
- package/lib/esm/render/primitives/EdgeParams.d.ts.map +1 -0
- package/lib/esm/render/primitives/EdgeParams.js +113 -0
- package/lib/esm/render/primitives/EdgeParams.js.map +1 -0
- package/lib/esm/render/primitives/PointStringParams.d.ts +16 -0
- package/lib/esm/render/primitives/PointStringParams.d.ts.map +1 -0
- package/lib/esm/render/primitives/PointStringParams.js +39 -0
- package/lib/esm/render/primitives/PointStringParams.js.map +1 -0
- package/lib/esm/render/primitives/PolylineParams.d.ts +44 -0
- package/lib/esm/render/primitives/PolylineParams.d.ts.map +1 -0
- package/lib/esm/render/primitives/PolylineParams.js +199 -0
- package/lib/esm/render/primitives/PolylineParams.js.map +1 -0
- package/lib/esm/render/primitives/SurfaceParams.d.ts +46 -0
- package/lib/esm/render/primitives/SurfaceParams.d.ts.map +1 -0
- package/lib/esm/render/primitives/SurfaceParams.js +37 -0
- package/lib/esm/render/primitives/SurfaceParams.js.map +1 -0
- package/lib/esm/render/primitives/VertexTable.d.ts +3 -123
- package/lib/esm/render/primitives/VertexTable.d.ts.map +1 -1
- package/lib/esm/render/primitives/VertexTable.js +5 -341
- package/lib/esm/render/primitives/VertexTable.js.map +1 -1
- package/lib/esm/render/webgl/CachedGeometry.d.ts +4 -2
- package/lib/esm/render/webgl/CachedGeometry.d.ts.map +1 -1
- package/lib/esm/render/webgl/CachedGeometry.js.map +1 -1
- package/lib/esm/render/webgl/EdgeGeometry.d.ts +73 -0
- package/lib/esm/render/webgl/EdgeGeometry.d.ts.map +1 -0
- package/lib/esm/render/webgl/EdgeGeometry.js +135 -0
- package/lib/esm/render/webgl/EdgeGeometry.js.map +1 -0
- package/lib/esm/render/webgl/InstancedGeometry.d.ts +4 -4
- package/lib/esm/render/webgl/InstancedGeometry.d.ts.map +1 -1
- package/lib/esm/render/webgl/Material.d.ts +1 -1
- package/lib/esm/render/webgl/Material.d.ts.map +1 -1
- package/lib/esm/render/webgl/Material.js.map +1 -1
- package/lib/esm/render/webgl/Mesh.d.ts +6 -162
- package/lib/esm/render/webgl/Mesh.d.ts.map +1 -1
- package/lib/esm/render/webgl/Mesh.js +5 -443
- package/lib/esm/render/webgl/Mesh.js.map +1 -1
- package/lib/esm/render/webgl/MeshData.d.ts +38 -0
- package/lib/esm/render/webgl/MeshData.d.ts.map +1 -0
- package/lib/esm/render/webgl/MeshData.js +62 -0
- package/lib/esm/render/webgl/MeshData.js.map +1 -0
- package/lib/esm/render/webgl/MeshGeometry.d.ts +38 -0
- package/lib/esm/render/webgl/MeshGeometry.d.ts.map +1 -0
- package/lib/esm/render/webgl/MeshGeometry.js +56 -0
- package/lib/esm/render/webgl/MeshGeometry.js.map +1 -0
- package/lib/esm/render/webgl/PointString.d.ts +1 -1
- package/lib/esm/render/webgl/PointString.d.ts.map +1 -1
- package/lib/esm/render/webgl/PointString.js.map +1 -1
- package/lib/esm/render/webgl/Polyline.d.ts +1 -1
- package/lib/esm/render/webgl/Polyline.d.ts.map +1 -1
- package/lib/esm/render/webgl/Polyline.js.map +1 -1
- package/lib/esm/render/webgl/RenderCommands.js +1 -1
- package/lib/esm/render/webgl/RenderCommands.js.map +1 -1
- package/lib/esm/render/webgl/SurfaceGeometry.d.ts +54 -0
- package/lib/esm/render/webgl/SurfaceGeometry.d.ts.map +1 -0
- package/lib/esm/render/webgl/SurfaceGeometry.js +235 -0
- package/lib/esm/render/webgl/SurfaceGeometry.js.map +1 -0
- package/lib/esm/render/webgl/System.d.ts +3 -1
- package/lib/esm/render/webgl/System.d.ts.map +1 -1
- package/lib/esm/render/webgl/System.js.map +1 -1
- package/lib/esm/render/webgl/glsl/Surface.js +1 -1
- package/lib/esm/render/webgl/glsl/Surface.js.map +1 -1
- package/lib/esm/render-primitives.d.ts +5 -1
- package/lib/esm/render-primitives.d.ts.map +1 -1
- package/lib/esm/render-primitives.js +5 -1
- package/lib/esm/render-primitives.js.map +1 -1
- package/lib/esm/tile/ContextShareProvider.d.ts.map +1 -1
- package/lib/esm/tile/ContextShareProvider.js +19 -0
- package/lib/esm/tile/ContextShareProvider.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +4 -1
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/lib/esm/tile/map/CesiumTerrainProvider.js +1 -1
- package/lib/esm/tile/map/CesiumTerrainProvider.js.map +1 -1
- package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js +1 -1
- package/lib/esm/tile/map/ImageryProviders/BingImageryProvider.js.map +1 -1
- package/lib/esm/tile/map/MapLayerSources.js +1 -1
- package/lib/esm/tile/map/MapLayerSources.js.map +1 -1
- package/lib/esm/webgl.d.ts +4 -0
- package/lib/esm/webgl.d.ts.map +1 -1
- package/lib/esm/webgl.js +4 -0
- package/lib/esm/webgl.js.map +1 -1
- package/package.json +22 -22
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Rendering
|
|
7
|
+
*/
|
|
8
|
+
import { VertexIndices } from "./VertexTable";
|
|
9
|
+
import { TesselatedPolyline, wantJointTriangles } from "./PolylineParams";
|
|
10
|
+
function convertPolylinesAndEdges(polylines, edges) {
|
|
11
|
+
let numIndices = undefined !== edges ? edges.length : 0;
|
|
12
|
+
if (undefined !== polylines)
|
|
13
|
+
for (const pd of polylines)
|
|
14
|
+
numIndices += (pd.vertIndices.length - 1);
|
|
15
|
+
if (0 === numIndices)
|
|
16
|
+
return undefined;
|
|
17
|
+
numIndices *= 6;
|
|
18
|
+
const indexBytes = new Uint8Array(numIndices * 3);
|
|
19
|
+
const endPointAndQuadIndexBytes = new Uint8Array(numIndices * 4);
|
|
20
|
+
let ndx = 0;
|
|
21
|
+
let ndx2 = 0;
|
|
22
|
+
const addPoint = (p0, p1, quadIndex) => {
|
|
23
|
+
VertexIndices.encodeIndex(p0, indexBytes, ndx);
|
|
24
|
+
ndx += 3;
|
|
25
|
+
VertexIndices.encodeIndex(p1, endPointAndQuadIndexBytes, ndx2);
|
|
26
|
+
endPointAndQuadIndexBytes[ndx2 + 3] = quadIndex;
|
|
27
|
+
ndx2 += 4;
|
|
28
|
+
};
|
|
29
|
+
if (undefined !== polylines) {
|
|
30
|
+
for (const pd of polylines) {
|
|
31
|
+
const num = pd.vertIndices.length - 1;
|
|
32
|
+
for (let i = 0; i < num; ++i) {
|
|
33
|
+
let p0 = pd.vertIndices[i];
|
|
34
|
+
let p1 = pd.vertIndices[i + 1];
|
|
35
|
+
if (p1 < p0) { // swap so that lower index is first.
|
|
36
|
+
p0 = p1;
|
|
37
|
+
p1 = pd.vertIndices[i];
|
|
38
|
+
}
|
|
39
|
+
addPoint(p0, p1, 0);
|
|
40
|
+
addPoint(p1, p0, 2);
|
|
41
|
+
addPoint(p0, p1, 1);
|
|
42
|
+
addPoint(p0, p1, 1);
|
|
43
|
+
addPoint(p1, p0, 2);
|
|
44
|
+
addPoint(p1, p0, 3);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (undefined !== edges) {
|
|
49
|
+
for (const meshEdge of edges) {
|
|
50
|
+
const p0 = meshEdge.indices[0];
|
|
51
|
+
const p1 = meshEdge.indices[1];
|
|
52
|
+
addPoint(p0, p1, 0);
|
|
53
|
+
addPoint(p1, p0, 2);
|
|
54
|
+
addPoint(p0, p1, 1);
|
|
55
|
+
addPoint(p0, p1, 1);
|
|
56
|
+
addPoint(p1, p0, 2);
|
|
57
|
+
addPoint(p1, p0, 3);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
indices: new VertexIndices(indexBytes),
|
|
62
|
+
endPointAndQuadIndices: endPointAndQuadIndexBytes,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function convertSilhouettes(edges, normalPairs) {
|
|
66
|
+
const base = convertPolylinesAndEdges(undefined, edges);
|
|
67
|
+
if (undefined === base)
|
|
68
|
+
return undefined;
|
|
69
|
+
const normalPairBytes = new Uint8Array(normalPairs.length * 6 * 4);
|
|
70
|
+
const normalPair16 = new Uint16Array(normalPairBytes.buffer);
|
|
71
|
+
let ndx = 0;
|
|
72
|
+
for (const pair of normalPairs) {
|
|
73
|
+
for (let i = 0; i < 6; i++) {
|
|
74
|
+
normalPair16[ndx++] = pair.first.value;
|
|
75
|
+
normalPair16[ndx++] = pair.second.value;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
indices: base.indices,
|
|
80
|
+
endPointAndQuadIndices: base.endPointAndQuadIndices,
|
|
81
|
+
normalPairs: normalPairBytes,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export var EdgeParams;
|
|
85
|
+
(function (EdgeParams) {
|
|
86
|
+
function fromMeshArgs(meshArgs) {
|
|
87
|
+
const args = meshArgs.edges;
|
|
88
|
+
if (undefined === args)
|
|
89
|
+
return undefined;
|
|
90
|
+
let polylines;
|
|
91
|
+
let segments;
|
|
92
|
+
if (wantJointTriangles(args.width, meshArgs.is2d)) {
|
|
93
|
+
segments = convertPolylinesAndEdges(args.polylines.lines, args.edges.edges);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
segments = convertPolylinesAndEdges(undefined, args.edges.edges);
|
|
97
|
+
polylines = TesselatedPolyline.fromMesh(meshArgs);
|
|
98
|
+
}
|
|
99
|
+
// ###TODO: why the heck are the edges and normals of SilhouetteEdgeArgs potentially undefined???
|
|
100
|
+
const silhouettes = undefined !== args.silhouettes.edges && undefined !== args.silhouettes.normals ? convertSilhouettes(args.silhouettes.edges, args.silhouettes.normals) : undefined;
|
|
101
|
+
if (undefined === segments && undefined === silhouettes && undefined === polylines)
|
|
102
|
+
return undefined;
|
|
103
|
+
return {
|
|
104
|
+
weight: args.width,
|
|
105
|
+
linePixels: args.linePixels,
|
|
106
|
+
segments,
|
|
107
|
+
silhouettes,
|
|
108
|
+
polylines,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
EdgeParams.fromMeshArgs = fromMeshArgs;
|
|
112
|
+
})(EdgeParams || (EdgeParams = {}));
|
|
113
|
+
//# sourceMappingURL=EdgeParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EdgeParams.js","sourceRoot":"","sources":["../../../../src/render/primitives/EdgeParams.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAmB1E,SAAS,wBAAwB,CAAC,SAA0B,EAAE,KAAkB;IAC9E,IAAI,UAAU,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,IAAI,S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M;YACL,QAAQ,GAAG,wBAAwB,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACjE,SAAS,GAAG,kBAAkB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACnD;QAED,iGAAiG;QACjG,MAAM,WAAW,GAAG,SAAS,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,IAAI,SAAS,KAAK,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtL,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,WAAW,IAAI,SAAS,KAAK,SAAS;YAChF,OAAO,SAAS,CAAC;QAEnB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,KAAK;YAClB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ;YACR,WAAW;YACX,SAAS;SACV,CAAC;IACJ,CAAC;IA1Be,uBAAY,eA0B3B,CAAA;AACH,CAAC,EA5BgB,UAAU,KAAV,UAAU,QA4B1B","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { LinePixels, MeshEdge, OctEncodedNormalPair, PolylineData } from \"@itwin/core-common\";\r\nimport { MeshArgs } from \"./mesh/MeshPrimitives\";\r\nimport { VertexIndices } from \"./VertexTable\";\r\nimport { TesselatedPolyline, wantJointTriangles } from \"./PolylineParams\";\r\n\r\n/**\r\n * Describes a set of line segments representing edges of a mesh.\r\n * Each segment is expanded into a quad defined by two triangles.\r\n * The positions are adjusted in the shader to account for the edge width.\r\n * @internal\r\n */\r\nexport interface SegmentEdgeParams {\r\n /** The 24-bit indices of the tesselated line segment */\r\n readonly indices: VertexIndices;\r\n /**\r\n * For each 24-bit index, 4 bytes:\r\n * the 24-bit index of the vertex at the other end of the segment, followed by\r\n * an 8-bit 'quad index' in [0..3] indicating which point in the expanded quad the vertex represents.\r\n */\r\n readonly endPointAndQuadIndices: Uint8Array;\r\n}\r\n\r\nfunction convertPolylinesAndEdges(polylines?: PolylineData[], edges?: MeshEdge[]): SegmentEdgeParams | undefined {\r\n let numIndices = undefined !== edges ? edges.length : 0;\r\n if (undefined !== polylines)\r\n for (const pd of polylines)\r\n numIndices += (pd.vertIndices.length - 1);\r\n\r\n if (0 === numIndices)\r\n return undefined;\r\n\r\n numIndices *= 6;\r\n const indexBytes = new Uint8Array(numIndices * 3);\r\n const endPointAndQuadIndexBytes = new Uint8Array(numIndices * 4);\r\n\r\n let ndx: number = 0;\r\n let ndx2: number = 0;\r\n\r\n const addPoint = (p0: number, p1: number, quadIndex: number) => {\r\n VertexIndices.encodeIndex(p0, indexBytes, ndx);\r\n ndx += 3;\r\n VertexIndices.encodeIndex(p1, endPointAndQuadIndexBytes, ndx2);\r\n endPointAndQuadIndexBytes[ndx2 + 3] = quadIndex;\r\n ndx2 += 4;\r\n };\r\n\r\n if (undefined !== polylines) {\r\n for (const pd of polylines) {\r\n const num = pd.vertIndices.length - 1;\r\n for (let i = 0; i < num; ++i) {\r\n let p0 = pd.vertIndices[i];\r\n let p1 = pd.vertIndices[i + 1];\r\n if (p1 < p0) { // swap so that lower index is first.\r\n p0 = p1;\r\n p1 = pd.vertIndices[i];\r\n }\r\n addPoint(p0, p1, 0);\r\n addPoint(p1, p0, 2);\r\n addPoint(p0, p1, 1);\r\n addPoint(p0, p1, 1);\r\n addPoint(p1, p0, 2);\r\n addPoint(p1, p0, 3);\r\n }\r\n }\r\n }\r\n\r\n if (undefined !== edges) {\r\n for (const meshEdge of edges) {\r\n const p0 = meshEdge.indices[0];\r\n const p1 = meshEdge.indices[1];\r\n addPoint(p0, p1, 0);\r\n addPoint(p1, p0, 2);\r\n addPoint(p0, p1, 1);\r\n addPoint(p0, p1, 1);\r\n addPoint(p1, p0, 2);\r\n addPoint(p1, p0, 3);\r\n }\r\n }\r\n\r\n return {\r\n indices: new VertexIndices(indexBytes),\r\n endPointAndQuadIndices: endPointAndQuadIndexBytes,\r\n };\r\n}\r\n\r\n/**\r\n * A set of line segments representing edges of curved portions of a mesh.\r\n * Each vertex is augmented with a pair of oct-encoded normals used in the shader\r\n * to determine whether or not the edge should be displayed.\r\n * @internal\r\n */\r\nexport interface SilhouetteParams extends SegmentEdgeParams {\r\n /** Per index, 2 16-bit oct-encoded normals */\r\n readonly normalPairs: Uint8Array;\r\n}\r\n\r\nfunction convertSilhouettes(edges: MeshEdge[], normalPairs: OctEncodedNormalPair[]): SilhouetteParams | undefined {\r\n const base = convertPolylinesAndEdges(undefined, edges);\r\n if (undefined === base)\r\n return undefined;\r\n\r\n const normalPairBytes = new Uint8Array(normalPairs.length * 6 * 4);\r\n const normalPair16 = new Uint16Array(normalPairBytes.buffer);\r\n\r\n let ndx = 0;\r\n for (const pair of normalPairs) {\r\n for (let i = 0; i < 6; i++) {\r\n normalPair16[ndx++] = pair.first.value;\r\n normalPair16[ndx++] = pair.second.value;\r\n }\r\n }\r\n\r\n return {\r\n indices: base.indices,\r\n endPointAndQuadIndices: base.endPointAndQuadIndices,\r\n normalPairs: normalPairBytes,\r\n };\r\n}\r\n\r\n/** Describes the edges of a mesh. */\r\nexport interface EdgeParams {\r\n /** The edge width in pixels. */\r\n readonly weight: number;\r\n /** The line pattern in which edges are drawn. */\r\n readonly linePixels: LinePixels;\r\n /** Simple single-segment edges, always displayed when edge display is enabled. */\r\n readonly segments?: SegmentEdgeParams;\r\n /** Single-segment edges of curved surfaces, displayed based on edge normal relative to eye. */\r\n readonly silhouettes?: SilhouetteParams;\r\n /** Polyline edges, always displayed when edge display is enabled. */\r\n readonly polylines?: TesselatedPolyline;\r\n}\r\n\r\nexport namespace EdgeParams {\r\n export function fromMeshArgs(meshArgs: MeshArgs): EdgeParams | undefined {\r\n const args = meshArgs.edges;\r\n if (undefined === args)\r\n return undefined;\r\n\r\n let polylines: TesselatedPolyline | undefined;\r\n let segments: SegmentEdgeParams | undefined;\r\n if (wantJointTriangles(args.width, meshArgs.is2d)) {\r\n segments = convertPolylinesAndEdges(args.polylines.lines, args.edges.edges);\r\n } else {\r\n segments = convertPolylinesAndEdges(undefined, args.edges.edges);\r\n polylines = TesselatedPolyline.fromMesh(meshArgs);\r\n }\r\n\r\n // ###TODO: why the heck are the edges and normals of SilhouetteEdgeArgs potentially undefined???\r\n const silhouettes = undefined !== args.silhouettes.edges && undefined !== args.silhouettes.normals ? convertSilhouettes(args.silhouettes.edges, args.silhouettes.normals) : undefined;\r\n if (undefined === segments && undefined === silhouettes && undefined === polylines)\r\n return undefined;\r\n\r\n return {\r\n weight: args.width,\r\n linePixels: args.linePixels,\r\n segments,\r\n silhouettes,\r\n polylines,\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Rendering
|
|
3
|
+
*/
|
|
4
|
+
import { PolylineArgs } from "./mesh/MeshPrimitives";
|
|
5
|
+
import { VertexIndices, VertexTable } from "./VertexTable";
|
|
6
|
+
/** Describes point string geometry to be submitted to the rendering system.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare class PointStringParams {
|
|
10
|
+
readonly vertices: VertexTable;
|
|
11
|
+
readonly indices: VertexIndices;
|
|
12
|
+
readonly weight: number;
|
|
13
|
+
constructor(vertices: VertexTable, indices: VertexIndices, weight: number);
|
|
14
|
+
static create(args: PolylineArgs): PointStringParams | undefined;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=PointStringParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PointStringParams.d.ts","sourceRoot":"","sources":["../../../../src/render/primitives/PointStringParams.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,SAAgB,QAAQ,EAAE,WAAW,CAAC;IACtC,SAAgB,OAAO,EAAE,aAAa,CAAC;IACvC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;WAMlE,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,iBAAiB,GAAG,SAAS;CAuBxE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Rendering
|
|
7
|
+
*/
|
|
8
|
+
import { assert } from "@itwin/core-bentley";
|
|
9
|
+
import { VertexIndices, VertexTable } from "./VertexTable";
|
|
10
|
+
/** Describes point string geometry to be submitted to the rendering system.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export class PointStringParams {
|
|
14
|
+
constructor(vertices, indices, weight) {
|
|
15
|
+
this.vertices = vertices;
|
|
16
|
+
this.indices = indices;
|
|
17
|
+
this.weight = weight;
|
|
18
|
+
}
|
|
19
|
+
static create(args) {
|
|
20
|
+
if (!args.flags.isDisjoint)
|
|
21
|
+
return undefined;
|
|
22
|
+
const vertices = VertexTable.createForPolylines(args);
|
|
23
|
+
if (undefined === vertices)
|
|
24
|
+
return undefined;
|
|
25
|
+
const polylines = args.polylines;
|
|
26
|
+
let vertIndices = polylines[0].vertIndices;
|
|
27
|
+
if (1 < polylines.length) {
|
|
28
|
+
// We used to assert this wouldn't happen - apparently it does...
|
|
29
|
+
vertIndices = [];
|
|
30
|
+
for (const polyline of polylines)
|
|
31
|
+
for (const vertIndex of polyline.vertIndices)
|
|
32
|
+
vertIndices.push(vertIndex);
|
|
33
|
+
}
|
|
34
|
+
const vertexIndices = VertexIndices.fromArray(vertIndices);
|
|
35
|
+
assert(vertexIndices.length === vertIndices.length);
|
|
36
|
+
return new PointStringParams(vertices, vertexIndices, args.width);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=PointStringParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PointStringParams.js","sourceRoot":"","sources":["../../../../src/render/primitives/PointStringParams.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE3D;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAK5B,YAAmB,QAAqB,EAAE,OAAsB,EAAE,MAAc;QAC9E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,IAAkB;QACrC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;YACxB,OAAO,SAAS,CAAC;QAEnB,MAAM,QAAQ,GAAG,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,SAAS,KAAK,QAAQ;YACxB,OAAO,SAAS,CAAC;QAEnB,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,WAAW,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QAC3C,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE;YACxB,iEAAiE;YACjE,WAAW,GAAG,EAAE,CAAC;YACjB,KAAK,MAAM,QAAQ,IAAI,SAAS;gBAC9B,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,WAAW;oBAC1C,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACjC;QAED,MAAM,aAAa,GAAG,aAAa,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAC3D,MAAM,CAAC,aAAa,CAAC,MAAM,KAAK,WAAW,CAAC,MAAM,CAAC,CAAC;QAEpD,OAAO,IAAI,iBAAiB,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { PolylineArgs } from \"./mesh/MeshPrimitives\";\r\nimport { VertexIndices, VertexTable } from \"./VertexTable\";\r\n\r\n/** Describes point string geometry to be submitted to the rendering system.\r\n * @internal\r\n */\r\nexport class PointStringParams {\r\n public readonly vertices: VertexTable;\r\n public readonly indices: VertexIndices;\r\n public readonly weight: number;\r\n\r\n public constructor(vertices: VertexTable, indices: VertexIndices, weight: number) {\r\n this.vertices = vertices;\r\n this.indices = indices;\r\n this.weight = weight;\r\n }\r\n\r\n public static create(args: PolylineArgs): PointStringParams | undefined {\r\n if (!args.flags.isDisjoint)\r\n return undefined;\r\n\r\n const vertices = VertexTable.createForPolylines(args);\r\n if (undefined === vertices)\r\n return undefined;\r\n\r\n const polylines = args.polylines;\r\n let vertIndices = polylines[0].vertIndices;\r\n if (1 < polylines.length) {\r\n // We used to assert this wouldn't happen - apparently it does...\r\n vertIndices = [];\r\n for (const polyline of polylines)\r\n for (const vertIndex of polyline.vertIndices)\r\n vertIndices.push(vertIndex);\r\n }\r\n\r\n const vertexIndices = VertexIndices.fromArray(vertIndices);\r\n assert(vertexIndices.length === vertIndices.length);\r\n\r\n return new PointStringParams(vertices, vertexIndices, args.width);\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Rendering
|
|
3
|
+
*/
|
|
4
|
+
import { LinePixels, PolylineData, PolylineTypeFlags, QPoint3dList } from "@itwin/core-common";
|
|
5
|
+
import { MeshArgs, PolylineArgs } from "./mesh/MeshPrimitives";
|
|
6
|
+
import { VertexIndices, VertexTable } from "./VertexTable";
|
|
7
|
+
/**
|
|
8
|
+
* Represents a tesselated polyline.
|
|
9
|
+
* Given a polyline as a line string, each segment of the line string is triangulated into a quad.
|
|
10
|
+
* Based on the angle between two segments, additional joint triangles may be inserted in between to enable smoothly-rounded corners.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface TesselatedPolyline {
|
|
14
|
+
/** 24-bit index of each vertex. */
|
|
15
|
+
readonly indices: VertexIndices;
|
|
16
|
+
/** 24-bit index of the previous vertex in the polyline. */
|
|
17
|
+
readonly prevIndices: VertexIndices;
|
|
18
|
+
/** 24-bit index of the next vertex in the polyline, plus 8-bit parameter describing the semantics of this vertex. */
|
|
19
|
+
readonly nextIndicesAndParams: Uint8Array;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace TesselatedPolyline {
|
|
22
|
+
function fromMesh(args: MeshArgs): TesselatedPolyline | undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Strictly for tests. @internal */
|
|
25
|
+
export declare function tesselatePolyline(polylines: PolylineData[], points: QPoint3dList, doJointTriangles: boolean): TesselatedPolyline;
|
|
26
|
+
/**
|
|
27
|
+
* Describes a set of tesselated polylines.
|
|
28
|
+
* Each segment of each polyline is triangulated into a quad. Additional triangles may be inserted
|
|
29
|
+
* between segments to enable rounded corners.
|
|
30
|
+
*/
|
|
31
|
+
export declare class PolylineParams {
|
|
32
|
+
readonly vertices: VertexTable;
|
|
33
|
+
readonly polyline: TesselatedPolyline;
|
|
34
|
+
readonly isPlanar: boolean;
|
|
35
|
+
readonly type: PolylineTypeFlags;
|
|
36
|
+
readonly weight: number;
|
|
37
|
+
readonly linePixels: LinePixels;
|
|
38
|
+
/** Directly construct a PolylineParams. The PolylineParams takes ownership of all input data. */
|
|
39
|
+
constructor(vertices: VertexTable, polyline: TesselatedPolyline, weight: number, linePixels: LinePixels, isPlanar: boolean, type?: PolylineTypeFlags);
|
|
40
|
+
/** Construct from an PolylineArgs. */
|
|
41
|
+
static create(args: PolylineArgs): PolylineParams | undefined;
|
|
42
|
+
}
|
|
43
|
+
export declare function wantJointTriangles(weight: number, is2d: boolean): boolean;
|
|
44
|
+
//# sourceMappingURL=PolylineParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PolylineParams.d.ts","sourceRoot":"","sources":["../../../../src/render/primitives/PolylineParams.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAc3D;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;IACpC,qHAAqH;IACrH,QAAQ,CAAC,oBAAoB,EAAE,UAAU,CAAC;CAC3C;AAED,yBAAiB,kBAAkB,CAAC;IAClC,SAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,kBAAkB,GAAG,SAAS,CAGvE;CACF;AA8KD,oCAAoC;AACpC,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,YAAY,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,GAAG,kBAAkB,CAGhI;AAED;;;;GAIG;AACH,qBAAa,cAAc;IACzB,SAAgB,QAAQ,EAAE,WAAW,CAAC;IACtC,SAAgB,QAAQ,EAAE,kBAAkB,CAAC;IAC7C,SAAgB,QAAQ,EAAE,OAAO,CAAC;IAClC,SAAgB,IAAI,EAAE,iBAAiB,CAAC;IACxC,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,UAAU,EAAE,UAAU,CAAC;IAEvC,iGAAiG;gBAC9E,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,GAAE,iBAA4C;IASrL,sCAAsC;WACxB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,cAAc,GAAG,SAAS;CAYrE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAIzE"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Rendering
|
|
7
|
+
*/
|
|
8
|
+
import { assert } from "@itwin/core-bentley";
|
|
9
|
+
import { Vector3d } from "@itwin/core-geometry";
|
|
10
|
+
import { PolylineTypeFlags } from "@itwin/core-common";
|
|
11
|
+
import { VertexIndices, VertexTable } from "./VertexTable";
|
|
12
|
+
export var TesselatedPolyline;
|
|
13
|
+
(function (TesselatedPolyline) {
|
|
14
|
+
function fromMesh(args) {
|
|
15
|
+
const tesselator = PolylineTesselator.fromMesh(args);
|
|
16
|
+
return tesselator === null || tesselator === void 0 ? void 0 : tesselator.tesselate();
|
|
17
|
+
}
|
|
18
|
+
TesselatedPolyline.fromMesh = fromMesh;
|
|
19
|
+
})(TesselatedPolyline || (TesselatedPolyline = {}));
|
|
20
|
+
class PolylineVertex {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.isSegmentStart = false;
|
|
23
|
+
this.isPolylineStartOrEnd = false;
|
|
24
|
+
this.vertexIndex = 0;
|
|
25
|
+
this.prevIndex = 0;
|
|
26
|
+
this.nextIndex = 0;
|
|
27
|
+
}
|
|
28
|
+
init(isSegmentStart, isPolylineStartOrEnd, vertexIndex, prevIndex, nextIndex) {
|
|
29
|
+
this.isSegmentStart = isSegmentStart;
|
|
30
|
+
this.isPolylineStartOrEnd = isPolylineStartOrEnd;
|
|
31
|
+
this.vertexIndex = vertexIndex;
|
|
32
|
+
this.prevIndex = prevIndex;
|
|
33
|
+
this.nextIndex = nextIndex;
|
|
34
|
+
}
|
|
35
|
+
computeParam(negatePerp, adjacentToJoint = false, joint = false, noDisplacement = false) {
|
|
36
|
+
if (joint)
|
|
37
|
+
return 12 /* kJointBase */;
|
|
38
|
+
let param;
|
|
39
|
+
if (noDisplacement)
|
|
40
|
+
param = 96 /* kNoneAdjustWeight */; // prevent getting tossed before width adjustment
|
|
41
|
+
else if (adjacentToJoint)
|
|
42
|
+
param = 9 /* kMiterInsideOnly */;
|
|
43
|
+
else
|
|
44
|
+
param = this.isPolylineStartOrEnd ? 3 /* kSquare */ : 6 /* kMiter */;
|
|
45
|
+
let adjust = 0;
|
|
46
|
+
if (negatePerp)
|
|
47
|
+
adjust = 24 /* kNegatePerp */;
|
|
48
|
+
if (!this.isSegmentStart)
|
|
49
|
+
adjust += 48 /* kNegateAlong */;
|
|
50
|
+
return param + adjust;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
class PolylineTesselator {
|
|
54
|
+
constructor(polylines, points, doJointTriangles) {
|
|
55
|
+
this._numIndices = 0;
|
|
56
|
+
this._vertIndex = [];
|
|
57
|
+
this._prevIndex = [];
|
|
58
|
+
this._nextIndex = [];
|
|
59
|
+
this._nextParam = [];
|
|
60
|
+
this._position = [];
|
|
61
|
+
this._polylines = polylines;
|
|
62
|
+
this._points = points;
|
|
63
|
+
this._doJoints = doJointTriangles;
|
|
64
|
+
}
|
|
65
|
+
static fromPolyline(args) {
|
|
66
|
+
return new PolylineTesselator(args.polylines, args.points, wantJointTriangles(args.width, args.flags.is2d));
|
|
67
|
+
}
|
|
68
|
+
static fromMesh(args) {
|
|
69
|
+
if (undefined !== args.edges.polylines.lines && undefined !== args.points)
|
|
70
|
+
return new PolylineTesselator(args.edges.polylines.lines, args.points, wantJointTriangles(args.edges.width, args.is2d));
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
tesselate() {
|
|
74
|
+
for (const p of this._points.list)
|
|
75
|
+
this._position.push(p.unquantize(this._points.params));
|
|
76
|
+
this._tesselate();
|
|
77
|
+
const vertIndex = VertexIndices.fromArray(this._vertIndex);
|
|
78
|
+
const prevIndex = VertexIndices.fromArray(this._prevIndex);
|
|
79
|
+
const nextIndexAndParam = new Uint8Array(this._numIndices * 4);
|
|
80
|
+
for (let i = 0; i < this._numIndices; i++) {
|
|
81
|
+
const index = this._nextIndex[i];
|
|
82
|
+
const j = i * 4;
|
|
83
|
+
VertexIndices.encodeIndex(index, nextIndexAndParam, j);
|
|
84
|
+
nextIndexAndParam[j + 3] = this._nextParam[i] & 0x000000ff;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
indices: vertIndex,
|
|
88
|
+
prevIndices: prevIndex,
|
|
89
|
+
nextIndicesAndParams: nextIndexAndParam,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
_tesselate() {
|
|
93
|
+
const v0 = new PolylineVertex(), v1 = new PolylineVertex();
|
|
94
|
+
const maxJointDot = -0.7;
|
|
95
|
+
for (const line of this._polylines) {
|
|
96
|
+
if (line.numIndices < 2)
|
|
97
|
+
continue;
|
|
98
|
+
const last = line.numIndices - 1;
|
|
99
|
+
const isClosed = line.vertIndices[0] === line.vertIndices[last];
|
|
100
|
+
for (let i = 0; i < last; ++i) {
|
|
101
|
+
const idx0 = line.vertIndices[i];
|
|
102
|
+
const idx1 = line.vertIndices[i + 1];
|
|
103
|
+
const isStart = (0 === i);
|
|
104
|
+
const isEnd = (last - 1 === i);
|
|
105
|
+
const prevIdx0 = isStart ? (isClosed ? line.vertIndices[last - 1] : idx0) : line.vertIndices[i - 1];
|
|
106
|
+
const nextIdx1 = isEnd ? (isClosed ? line.vertIndices[1] : idx1) : line.vertIndices[i + 2];
|
|
107
|
+
v0.init(true, isStart && !isClosed, idx0, prevIdx0, idx1);
|
|
108
|
+
v1.init(false, isEnd && !isClosed, idx1, nextIdx1, idx0);
|
|
109
|
+
const jointAt0 = this._doJoints && (isClosed || !isStart) && this._dotProduct(v0) > maxJointDot;
|
|
110
|
+
const jointAt1 = this._doJoints && (isClosed || !isEnd) && this._dotProduct(v1) > maxJointDot;
|
|
111
|
+
if (jointAt0 || jointAt1) {
|
|
112
|
+
this._addVertex(v0, v0.computeParam(true, jointAt0, false, false));
|
|
113
|
+
this._addVertex(v1, v1.computeParam(false, jointAt1, false, false));
|
|
114
|
+
this._addVertex(v0, v0.computeParam(false, jointAt0, false, true));
|
|
115
|
+
this._addVertex(v0, v0.computeParam(false, jointAt0, false, true));
|
|
116
|
+
this._addVertex(v1, v1.computeParam(false, jointAt1, false, false));
|
|
117
|
+
this._addVertex(v1, v1.computeParam(false, jointAt1, false, true));
|
|
118
|
+
this._addVertex(v0, v0.computeParam(false, jointAt0, false, true));
|
|
119
|
+
this._addVertex(v1, v1.computeParam(false, jointAt1, false, true));
|
|
120
|
+
this._addVertex(v0, v0.computeParam(false, jointAt0, false, false));
|
|
121
|
+
this._addVertex(v0, v0.computeParam(false, jointAt0, false, false));
|
|
122
|
+
this._addVertex(v1, v1.computeParam(false, jointAt1, false, true));
|
|
123
|
+
this._addVertex(v1, v1.computeParam(true, jointAt1, false, false));
|
|
124
|
+
if (jointAt0)
|
|
125
|
+
this.addJointTriangles(v0, v0.computeParam(false, true, false, true), v0);
|
|
126
|
+
if (jointAt1)
|
|
127
|
+
this.addJointTriangles(v1, v1.computeParam(false, true, false, true), v1);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this._addVertex(v0, v0.computeParam(true));
|
|
131
|
+
this._addVertex(v1, v1.computeParam(false));
|
|
132
|
+
this._addVertex(v0, v0.computeParam(false));
|
|
133
|
+
this._addVertex(v0, v0.computeParam(false));
|
|
134
|
+
this._addVertex(v1, v1.computeParam(false));
|
|
135
|
+
this._addVertex(v1, v1.computeParam(true));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
addJointTriangles(v0, p0, v1) {
|
|
141
|
+
const param = v1.computeParam(false, false, true);
|
|
142
|
+
for (let i = 0; i < 3; i++) {
|
|
143
|
+
this._addVertex(v0, p0);
|
|
144
|
+
this._addVertex(v1, param + i + 1);
|
|
145
|
+
this._addVertex(v1, param + i);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
_dotProduct(v) {
|
|
149
|
+
const pos = this._position[v.vertexIndex];
|
|
150
|
+
const prevDir = Vector3d.createStartEnd(this._position[v.prevIndex], pos);
|
|
151
|
+
const nextDir = Vector3d.createStartEnd(this._position[v.nextIndex], pos);
|
|
152
|
+
return prevDir.dotProduct(nextDir);
|
|
153
|
+
}
|
|
154
|
+
_addVertex(vertex, param) {
|
|
155
|
+
this._vertIndex[this._numIndices] = vertex.vertexIndex;
|
|
156
|
+
this._prevIndex[this._numIndices] = vertex.prevIndex;
|
|
157
|
+
this._nextIndex[this._numIndices] = vertex.nextIndex;
|
|
158
|
+
this._nextParam[this._numIndices] = param;
|
|
159
|
+
this._numIndices++;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Strictly for tests. @internal */
|
|
163
|
+
export function tesselatePolyline(polylines, points, doJointTriangles) {
|
|
164
|
+
const tesselator = new PolylineTesselator(polylines, points, doJointTriangles);
|
|
165
|
+
return tesselator.tesselate();
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Describes a set of tesselated polylines.
|
|
169
|
+
* Each segment of each polyline is triangulated into a quad. Additional triangles may be inserted
|
|
170
|
+
* between segments to enable rounded corners.
|
|
171
|
+
*/
|
|
172
|
+
export class PolylineParams {
|
|
173
|
+
/** Directly construct a PolylineParams. The PolylineParams takes ownership of all input data. */
|
|
174
|
+
constructor(vertices, polyline, weight, linePixels, isPlanar, type = PolylineTypeFlags.Normal) {
|
|
175
|
+
this.vertices = vertices;
|
|
176
|
+
this.polyline = polyline;
|
|
177
|
+
this.isPlanar = isPlanar;
|
|
178
|
+
this.weight = weight;
|
|
179
|
+
this.linePixels = linePixels;
|
|
180
|
+
this.type = type;
|
|
181
|
+
}
|
|
182
|
+
/** Construct from an PolylineArgs. */
|
|
183
|
+
static create(args) {
|
|
184
|
+
assert(!args.flags.isDisjoint);
|
|
185
|
+
const vertices = VertexTable.createForPolylines(args);
|
|
186
|
+
if (undefined === vertices)
|
|
187
|
+
return undefined;
|
|
188
|
+
const tesselator = PolylineTesselator.fromPolyline(args);
|
|
189
|
+
if (undefined === tesselator)
|
|
190
|
+
return undefined;
|
|
191
|
+
return new PolylineParams(vertices, tesselator.tesselate(), args.width, args.linePixels, args.flags.isPlanar, args.flags.type);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
export function wantJointTriangles(weight, is2d) {
|
|
195
|
+
// Joints are incredibly expensive. In 3d, only generate them if the line is sufficiently wide for them to be noticeable.
|
|
196
|
+
const jointWidthThreshold = 3;
|
|
197
|
+
return is2d || weight >= jointWidthThreshold;
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=PolylineParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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;IACnB,CAAC;IAED,sCAAsC;IAC/B,MAAM,CAAC,MAAM,CAAC,IAAkB;QACrC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,SAAS,KAAK,QAAQ;YACxB,OAAO,SAAS,CAAC;QAEnB,MAAM,UAAU,GAAG,kBAAkB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,SAAS,KAAK,UAAU;YAC1B,OAAO,SAAS,CAAC;QAEnB,OAAO,IAAI,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjI,CAAC;CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,IAAa;IAC9D,yHAAyH;IACzH,MAAM,mBAAmB,GAAG,CAAC,CAAC;IAC9B,OAAO,IAAI,IAAI,MAAM,IAAI,mBAAmB,CAAC;AAC/C,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Point3d, Vector3d } from \"@itwin/core-geometry\";\r\nimport { LinePixels, PolylineData, PolylineTypeFlags, QPoint3dList } from \"@itwin/core-common\";\r\nimport { MeshArgs, PolylineArgs } from \"./mesh/MeshPrimitives\";\r\nimport { VertexIndices, VertexTable } from \"./VertexTable\";\r\n\r\n/** Parameter associated with each vertex index of a tesselated polyline. */\r\nconst enum PolylineParam { // eslint-disable-line no-restricted-syntax\r\n kNone = 0,\r\n kSquare = 1 * 3,\r\n kMiter = 2 * 3,\r\n kMiterInsideOnly = 3 * 3,\r\n kJointBase = 4 * 3,\r\n kNegatePerp = 8 * 3,\r\n kNegateAlong = 16 * 3,\r\n kNoneAdjustWeight = 32 * 3,\r\n}\r\n\r\n/**\r\n * Represents a tesselated polyline.\r\n * Given a polyline as a line string, each segment of the line string is triangulated into a quad.\r\n * Based on the angle between two segments, additional joint triangles may be inserted in between to enable smoothly-rounded corners.\r\n * @internal\r\n */\r\nexport interface TesselatedPolyline {\r\n /** 24-bit index of each vertex. */\r\n readonly indices: VertexIndices;\r\n /** 24-bit index of the previous vertex in the polyline. */\r\n readonly prevIndices: VertexIndices;\r\n /** 24-bit index of the next vertex in the polyline, plus 8-bit parameter describing the semantics of this vertex. */\r\n readonly nextIndicesAndParams: Uint8Array;\r\n}\r\n\r\nexport namespace TesselatedPolyline {\r\n export function fromMesh(args: MeshArgs): TesselatedPolyline | undefined {\r\n const tesselator = PolylineTesselator.fromMesh(args);\r\n return tesselator?.tesselate();\r\n }\r\n}\r\n\r\nclass PolylineVertex {\r\n public isSegmentStart: boolean = false;\r\n public isPolylineStartOrEnd: boolean = false;\r\n public vertexIndex: number = 0;\r\n public prevIndex: number = 0;\r\n public nextIndex: number = 0;\r\n\r\n public constructor() { }\r\n\r\n public init(isSegmentStart: boolean, isPolylineStartOrEnd: boolean, vertexIndex: number, prevIndex: number, nextIndex: number) {\r\n this.isSegmentStart = isSegmentStart;\r\n this.isPolylineStartOrEnd = isPolylineStartOrEnd;\r\n this.vertexIndex = vertexIndex;\r\n this.prevIndex = prevIndex;\r\n this.nextIndex = nextIndex;\r\n }\r\n\r\n public computeParam(negatePerp: boolean, adjacentToJoint: boolean = false, joint: boolean = false, noDisplacement: boolean = false): number {\r\n if (joint)\r\n return PolylineParam.kJointBase;\r\n\r\n let param: PolylineParam;\r\n if (noDisplacement)\r\n param = PolylineParam.kNoneAdjustWeight; // prevent getting tossed before width adjustment\r\n else if (adjacentToJoint)\r\n param = PolylineParam.kMiterInsideOnly;\r\n else\r\n param = this.isPolylineStartOrEnd ? PolylineParam.kSquare : PolylineParam.kMiter;\r\n\r\n let adjust = 0;\r\n if (negatePerp)\r\n adjust = PolylineParam.kNegatePerp;\r\n if (!this.isSegmentStart)\r\n adjust += PolylineParam.kNegateAlong;\r\n\r\n return param + adjust;\r\n }\r\n}\r\n\r\nclass PolylineTesselator {\r\n private _polylines: PolylineData[];\r\n private _points: QPoint3dList;\r\n private _doJoints: boolean;\r\n private _numIndices = 0;\r\n private _vertIndex: number[] = [];\r\n private _prevIndex: number[] = [];\r\n private _nextIndex: number[] = [];\r\n private _nextParam: number[] = [];\r\n private _position: Point3d[] = [];\r\n\r\n public constructor(polylines: PolylineData[], points: QPoint3dList, doJointTriangles: boolean) {\r\n this._polylines = polylines;\r\n this._points = points;\r\n this._doJoints = doJointTriangles;\r\n }\r\n\r\n public static fromPolyline(args: PolylineArgs): PolylineTesselator {\r\n return new PolylineTesselator(args.polylines, args.points, wantJointTriangles(args.width, args.flags.is2d));\r\n }\r\n\r\n public static fromMesh(args: MeshArgs): PolylineTesselator | undefined {\r\n if (undefined !== args.edges.polylines.lines && undefined !== args.points)\r\n return new PolylineTesselator(args.edges.polylines.lines, args.points, wantJointTriangles(args.edges.width, args.is2d));\r\n\r\n return undefined;\r\n }\r\n\r\n public tesselate(): TesselatedPolyline {\r\n for (const p of this._points.list)\r\n this._position.push(p.unquantize(this._points.params));\r\n\r\n this._tesselate();\r\n\r\n const vertIndex = VertexIndices.fromArray(this._vertIndex);\r\n const prevIndex = VertexIndices.fromArray(this._prevIndex);\r\n\r\n const nextIndexAndParam = new Uint8Array(this._numIndices * 4);\r\n for (let i = 0; i < this._numIndices; i++) {\r\n const index = this._nextIndex[i];\r\n const j = i * 4;\r\n VertexIndices.encodeIndex(index, nextIndexAndParam, j);\r\n nextIndexAndParam[j + 3] = this._nextParam[i] & 0x000000ff;\r\n }\r\n\r\n return {\r\n indices: vertIndex,\r\n prevIndices: prevIndex,\r\n nextIndicesAndParams: nextIndexAndParam,\r\n };\r\n }\r\n\r\n private _tesselate() {\r\n const v0 = new PolylineVertex(), v1 = new PolylineVertex();\r\n const maxJointDot = -0.7;\r\n\r\n for (const line of this._polylines) {\r\n if (line.numIndices < 2)\r\n continue;\r\n\r\n const last = line.numIndices - 1;\r\n const isClosed: boolean = line.vertIndices[0] === line.vertIndices[last];\r\n\r\n for (let i = 0; i < last; ++i) {\r\n const idx0 = line.vertIndices[i];\r\n const idx1 = line.vertIndices[i + 1];\r\n const isStart: boolean = (0 === i);\r\n const isEnd: boolean = (last - 1 === i);\r\n const prevIdx0 = isStart ? (isClosed ? line.vertIndices[last - 1] : idx0) : line.vertIndices[i - 1];\r\n const nextIdx1 = isEnd ? (isClosed ? line.vertIndices[1] : idx1) : line.vertIndices[i + 2];\r\n\r\n v0.init(true, isStart && !isClosed, idx0, prevIdx0, idx1);\r\n v1.init(false, isEnd && !isClosed, idx1, nextIdx1, idx0);\r\n\r\n const jointAt0: boolean = this._doJoints && (isClosed || !isStart) && this._dotProduct(v0) > maxJointDot;\r\n const jointAt1: boolean = this._doJoints && (isClosed || !isEnd) && this._dotProduct(v1) > maxJointDot;\r\n\r\n if (jointAt0 || jointAt1) {\r\n this._addVertex(v0, v0.computeParam(true, jointAt0, false, false));\r\n this._addVertex(v1, v1.computeParam(false, jointAt1, false, false));\r\n this._addVertex(v0, v0.computeParam(false, jointAt0, false, true));\r\n this._addVertex(v0, v0.computeParam(false, jointAt0, false, true));\r\n this._addVertex(v1, v1.computeParam(false, jointAt1, false, false));\r\n this._addVertex(v1, v1.computeParam(false, jointAt1, false, true));\r\n this._addVertex(v0, v0.computeParam(false, jointAt0, false, true));\r\n this._addVertex(v1, v1.computeParam(false, jointAt1, false, true));\r\n this._addVertex(v0, v0.computeParam(false, jointAt0, false, false));\r\n this._addVertex(v0, v0.computeParam(false, jointAt0, false, false));\r\n this._addVertex(v1, v1.computeParam(false, jointAt1, false, true));\r\n this._addVertex(v1, v1.computeParam(true, jointAt1, false, false));\r\n\r\n if (jointAt0)\r\n this.addJointTriangles(v0, v0.computeParam(false, true, false, true), v0);\r\n\r\n if (jointAt1)\r\n this.addJointTriangles(v1, v1.computeParam(false, true, false, true), v1);\r\n } else {\r\n this._addVertex(v0, v0.computeParam(true));\r\n this._addVertex(v1, v1.computeParam(false));\r\n this._addVertex(v0, v0.computeParam(false));\r\n this._addVertex(v0, v0.computeParam(false));\r\n this._addVertex(v1, v1.computeParam(false));\r\n this._addVertex(v1, v1.computeParam(true));\r\n }\r\n }\r\n }\r\n }\r\n\r\n private addJointTriangles(v0: PolylineVertex, p0: number, v1: PolylineVertex): void {\r\n const param = v1.computeParam(false, false, true);\r\n for (let i = 0; i < 3; i++) {\r\n this._addVertex(v0, p0);\r\n this._addVertex(v1, param + i + 1);\r\n this._addVertex(v1, param + i);\r\n }\r\n }\r\n\r\n private _dotProduct(v: PolylineVertex): number {\r\n const pos: Point3d = this._position[v.vertexIndex];\r\n const prevDir: Vector3d = Vector3d.createStartEnd(this._position[v.prevIndex], pos);\r\n const nextDir: Vector3d = Vector3d.createStartEnd(this._position[v.nextIndex], pos);\r\n return prevDir.dotProduct(nextDir);\r\n }\r\n\r\n private _addVertex(vertex: PolylineVertex, param: number): void {\r\n this._vertIndex[this._numIndices] = vertex.vertexIndex;\r\n this._prevIndex[this._numIndices] = vertex.prevIndex;\r\n this._nextIndex[this._numIndices] = vertex.nextIndex;\r\n this._nextParam[this._numIndices] = param;\r\n this._numIndices++;\r\n }\r\n}\r\n\r\n/** Strictly for tests. @internal */\r\nexport function tesselatePolyline(polylines: PolylineData[], points: QPoint3dList, doJointTriangles: boolean): TesselatedPolyline {\r\n const tesselator = new PolylineTesselator(polylines, points, doJointTriangles);\r\n return tesselator.tesselate();\r\n}\r\n\r\n/**\r\n * Describes a set of tesselated polylines.\r\n * Each segment of each polyline is triangulated into a quad. Additional triangles may be inserted\r\n * between segments to enable rounded corners.\r\n */\r\nexport class PolylineParams {\r\n public readonly vertices: VertexTable;\r\n public readonly polyline: TesselatedPolyline;\r\n public readonly isPlanar: boolean;\r\n public readonly type: PolylineTypeFlags;\r\n public readonly weight: number;\r\n public readonly linePixels: LinePixels;\r\n\r\n /** Directly construct a PolylineParams. The PolylineParams takes ownership of all input data. */\r\n public constructor(vertices: VertexTable, polyline: TesselatedPolyline, weight: number, linePixels: LinePixels, isPlanar: boolean, type: PolylineTypeFlags = PolylineTypeFlags.Normal) {\r\n this.vertices = vertices;\r\n this.polyline = polyline;\r\n this.isPlanar = isPlanar;\r\n this.weight = weight;\r\n this.linePixels = linePixels;\r\n this.type = type;\r\n }\r\n\r\n /** Construct from an PolylineArgs. */\r\n public static create(args: PolylineArgs): PolylineParams | undefined {\r\n assert(!args.flags.isDisjoint);\r\n const vertices = VertexTable.createForPolylines(args);\r\n if (undefined === vertices)\r\n return undefined;\r\n\r\n const tesselator = PolylineTesselator.fromPolyline(args);\r\n if (undefined === tesselator)\r\n return undefined;\r\n\r\n return new PolylineParams(vertices, tesselator.tesselate(), args.width, args.linePixels, args.flags.isPlanar, args.flags.type);\r\n }\r\n}\r\n\r\nexport function wantJointTriangles(weight: number, is2d: boolean): boolean {\r\n // Joints are incredibly expensive. In 3d, only generate them if the line is sufficiently wide for them to be noticeable.\r\n const jointWidthThreshold = 3;\r\n return is2d || weight >= jointWidthThreshold;\r\n}\r\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Rendering
|
|
3
|
+
*/
|
|
4
|
+
import { FillFlags, RenderMaterial, RenderTexture } from "@itwin/core-common";
|
|
5
|
+
import { VertexIndices } from "./VertexTable";
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare enum SurfaceType {
|
|
8
|
+
Unlit = 0,
|
|
9
|
+
Lit = 1,
|
|
10
|
+
Textured = 2,
|
|
11
|
+
TexturedLit = 3,
|
|
12
|
+
VolumeClassifier = 4
|
|
13
|
+
}
|
|
14
|
+
/** @internal */
|
|
15
|
+
export declare function isValidSurfaceType(value: number): boolean;
|
|
16
|
+
/** @internal */
|
|
17
|
+
export interface SurfaceRenderMaterial {
|
|
18
|
+
readonly isAtlas: false;
|
|
19
|
+
readonly material: RenderMaterial;
|
|
20
|
+
}
|
|
21
|
+
/** @internal */
|
|
22
|
+
export interface SurfaceMaterialAtlas {
|
|
23
|
+
readonly isAtlas: true;
|
|
24
|
+
readonly hasTranslucency: boolean;
|
|
25
|
+
readonly overridesAlpha: boolean;
|
|
26
|
+
readonly vertexTableOffset: number;
|
|
27
|
+
readonly numMaterials: number;
|
|
28
|
+
}
|
|
29
|
+
/** @internal */
|
|
30
|
+
export declare type SurfaceMaterial = SurfaceRenderMaterial | SurfaceMaterialAtlas;
|
|
31
|
+
/** @internal */
|
|
32
|
+
export declare function createSurfaceMaterial(source: RenderMaterial | undefined): SurfaceMaterial | undefined;
|
|
33
|
+
/** @internal */
|
|
34
|
+
export interface SurfaceParams {
|
|
35
|
+
readonly type: SurfaceType;
|
|
36
|
+
readonly indices: VertexIndices;
|
|
37
|
+
readonly fillFlags: FillFlags;
|
|
38
|
+
readonly hasBakedLighting: boolean;
|
|
39
|
+
readonly hasFixedNormals: boolean;
|
|
40
|
+
readonly textureMapping?: {
|
|
41
|
+
texture: RenderTexture;
|
|
42
|
+
alwaysDisplayed: boolean;
|
|
43
|
+
};
|
|
44
|
+
readonly material?: SurfaceMaterial;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=SurfaceParams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfaceParams.d.ts","sourceRoot":"","sources":["../../../../src/render/primitives/SurfaceParams.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,gBAAg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
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/** @packageDocumentation
|
|
6
|
+
* @module Rendering
|
|
7
|
+
*/
|
|
8
|
+
/** @internal */
|
|
9
|
+
export var SurfaceType;
|
|
10
|
+
(function (SurfaceType) {
|
|
11
|
+
SurfaceType[SurfaceType["Unlit"] = 0] = "Unlit";
|
|
12
|
+
SurfaceType[SurfaceType["Lit"] = 1] = "Lit";
|
|
13
|
+
SurfaceType[SurfaceType["Textured"] = 2] = "Textured";
|
|
14
|
+
SurfaceType[SurfaceType["TexturedLit"] = 3] = "TexturedLit";
|
|
15
|
+
SurfaceType[SurfaceType["VolumeClassifier"] = 4] = "VolumeClassifier";
|
|
16
|
+
})(SurfaceType || (SurfaceType = {}));
|
|
17
|
+
/** @internal */
|
|
18
|
+
export function isValidSurfaceType(value) {
|
|
19
|
+
switch (value) {
|
|
20
|
+
case SurfaceType.Unlit:
|
|
21
|
+
case SurfaceType.Lit:
|
|
22
|
+
case SurfaceType.Textured:
|
|
23
|
+
case SurfaceType.TexturedLit:
|
|
24
|
+
case SurfaceType.VolumeClassifier:
|
|
25
|
+
return true;
|
|
26
|
+
default:
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** @internal */
|
|
31
|
+
export function createSurfaceMaterial(source) {
|
|
32
|
+
if (undefined === source)
|
|
33
|
+
return undefined;
|
|
34
|
+
else
|
|
35
|
+
return { isAtlas: false, material: source };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=SurfaceParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfaceParams.js","sourceRoot":"","sources":["../../../../src/render/primitives/SurfaceParams.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAKH,gBAAgB;AAChB,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,+CAAK,CAAA;IACL,2CAAG,CAAA;IACH,qDAAQ,CAAA;IACR,2DAAW,CAAA;IACX,qEAAgB,CAAA;AAClB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED,gBAAgB;AAChB,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,QAAQ,KAAK,EAAE;QACb,KAAK,WAAW,CAAC,KAAK,CAAC;QACvB,KAAK,WAAW,CAAC,GAAG,CAAC;QACrB,KAAK,WAAW,CAAC,QAAQ,CAAC;QAC1B,KAAK,WAAW,CAAC,WAAW,CAAC;QAC7B,KAAK,WAAW,CAAC,gBAAgB;YAC/B,OAAO,IAAI,CAAC;QACd;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC;AAuBD,gBAAgB;AAChB,MAAM,UAAU,qBAAqB,CAAC,MAAkC;IACtE,IAAI,SAAS,KAAK,MAAM;QACtB,OAAO,SAAS,CAAC;;QAEjB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Rendering\r\n */\r\n\r\nimport { FillFlags, RenderMaterial, RenderTexture } from \"@itwin/core-common\";\r\nimport { VertexIndices } from \"./VertexTable\";\r\n\r\n/** @internal */\r\nexport enum SurfaceType {\r\n Unlit,\r\n Lit,\r\n Textured,\r\n TexturedLit,\r\n VolumeClassifier,\r\n}\r\n\r\n/** @internal */\r\nexport function isValidSurfaceType(value: number): boolean {\r\n switch (value) {\r\n case SurfaceType.Unlit:\r\n case SurfaceType.Lit:\r\n case SurfaceType.Textured:\r\n case SurfaceType.TexturedLit:\r\n case SurfaceType.VolumeClassifier:\r\n return true;\r\n default:\r\n return false;\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface SurfaceRenderMaterial {\r\n readonly isAtlas: false;\r\n readonly material: RenderMaterial;\r\n}\r\n\r\n/** @internal */\r\nexport interface SurfaceMaterialAtlas {\r\n readonly isAtlas: true;\r\n // Overrides surface alpha to be translucent. Implies `overridesAlpha`.\r\n readonly hasTranslucency: boolean;\r\n // Overrides surface alpha to be opaque or translucent.\r\n readonly overridesAlpha: boolean;\r\n // offset past the END of the vertex data; equivalently, number of 32-bit colors in color table preceding material atlas.\r\n readonly vertexTableOffset: number;\r\n readonly numMaterials: number;\r\n}\r\n\r\n/** @internal */\r\nexport type SurfaceMaterial = SurfaceRenderMaterial | SurfaceMaterialAtlas;\r\n\r\n/** @internal */\r\nexport function createSurfaceMaterial(source: RenderMaterial | undefined): SurfaceMaterial | undefined {\r\n if (undefined === source)\r\n return undefined;\r\n else\r\n return { isAtlas: false, material: source };\r\n}\r\n\r\n/** @internal */\r\nexport interface SurfaceParams {\r\n readonly type: SurfaceType;\r\n readonly indices: VertexIndices;\r\n readonly fillFlags: FillFlags;\r\n readonly hasBakedLighting: boolean;\r\n readonly hasFixedNormals: boolean;\r\n readonly textureMapping?: {\r\n texture: RenderTexture;\r\n alwaysDisplayed: boolean;\r\n };\r\n readonly material?: SurfaceMaterial;\r\n}\r\n\r\n"]}
|