@kitware/vtk.js 22.5.7 → 22.5.8
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/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +261 -218
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/OpenGL/CubeAxesActor.js +61 -0
- package/Rendering/OpenGL/Profiles/All.js +1 -0
- package/Rendering/OpenGL/Profiles/Geometry.js +1 -0
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Rendering/OpenGL.js +1 -0
- package/Rendering/Profiles/All.js +2 -0
- package/Rendering/Profiles/Geometry.js +2 -0
- package/Rendering/WebGPU/CubeAxesActor.js +61 -0
- package/Rendering/WebGPU/Profiles/All.js +1 -0
- package/Rendering/WebGPU/Profiles/Geometry.js +1 -0
- package/Rendering/WebGPU.js +1 -0
- package/package.json +1 -1
|
@@ -2329,4 +2329,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2329
2329
|
'default': vtkMath
|
|
2330
2330
|
});
|
|
2331
2331
|
|
|
2332
|
-
export { binomial as $, clampValue as A, projectVector as B, arrayRange as C, getMajorAxisIndex as D, isInf as E, rgb2hsv as F, rgb2lab as G, lab2rgb as H, floor as I, round as J,
|
|
2332
|
+
export { binomial as $, clampValue as A, projectVector as B, arrayRange as C, getMajorAxisIndex as D, isInf as E, rgb2hsv as F, rgb2lab as G, lab2rgb as H, floor as I, round as J, normalize2D as K, nearestPowerOfTwo as L, createUninitializedBounds as M, multiply3x3_vect3 as N, areBoundsInitialized as O, isPowerOfTwo as P, multiplyAccumulate as Q, angleBetweenVectors as R, signedAngleBetweenVectors as S, Pi as T, ceil as U, min as V, max as W, arrayMin as X, arrayMax as Y, ceilLog2 as Z, factorial as _, areMatricesEqual as a, beginCombination as a0, nextCombination as a1, randomSeed as a2, getSeed as a3, gaussian as a4, multiplyScalar2D as a5, multiplyAccumulate2D as a6, outer as a7, dot2D as a8, projectVector2D as a9, hex2float as aA, lab2xyz as aB, xyz2lab as aC, xyz2rgb as aD, rgb2xyz as aE, clampAndNormalizeValue as aF, getScalarTypeFittingRange as aG, getAdjustedScalarRange as aH, extentIsWithinOtherExtent as aI, boundsIsWithinOtherBounds as aJ, pointIsWithinBounds as aK, solve3PointCircle as aL, inf as aM, negInf as aN, isFinite as aO, isNaN as aP, floatToHex2 as aQ, floatRGB2HexCode as aR, float2CssRGBA as aS, gaussianAmplitude as aa, gaussianWeight as ab, outer2D as ac, norm2D as ad, LUFactor3x3 as ae, LUSolve3x3 as af, linearSolve3x3 as ag, multiply3x3_mat3 as ah, multiplyMatrix as ai, transpose3x3 as aj, invert3x3 as ak, identity3x3 as al, quaternionToMatrix3x3 as am, roundNumber as an, matrix3x3ToQuaternion as ao, multiplyQuaternion as ap, orthogonalize3x3 as aq, diagonalize3x3 as ar, singularValueDecomposition3x3 as as, luFactorLinearSystem as at, luSolveLinearSystem as au, invertMatrix as av, estimateMatrixCondition as aw, jacobi as ax, solveHomogeneousLeastSquares as ay, solveLeastSquares as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints as f, subtract as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, determinant2x2 as m, norm as n, jacobiN as o, perpendiculars as p, vtkMath as q, radiansFromDegrees as r, solveLinearSystem as s, multiplyScalar as t, uninitializeBounds as u, vtkMath$1 as v, random as w, determinant3x3 as x, degreesFromRadians as y, areEquals as z };
|
package/Common/Core/Math.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import 'seedrandom';
|
|
3
3
|
import '../../macros.js';
|
|
4
|
-
export { ae as LUFactor3x3, af as LUSolve3x3, T as Pi, k as add, R as angleBetweenVectors, O as areBoundsInitialized, z as areEquals, a as areMatricesEqual, Y as arrayMax, X as arrayMin, C as arrayRange, a0 as beginCombination, $ as binomial, aJ as boundsIsWithinOtherBounds, U as ceil, Z as ceilLog2, aF as clampAndNormalizeValue, A as clampValue, e as clampVector, c as computeBoundsFromPoints, M as createUninitializedBounds, j as cross, q as default, y as degreesFromRadians, m as determinant2x2, x as determinant3x3, ar as diagonalize3x3, f as distance2BetweenPoints, d as dot, a8 as dot2D, aw as estimateMatrixCondition, aI as extentIsWithinOtherExtent, _ as factorial, aS as float2CssRGBA, aR as floatRGB2HexCode, aQ as floatToHex2, I as floor, a4 as gaussian, aa as gaussianAmplitude, ab as gaussianWeight, aH as getAdjustedScalarRange, D as getMajorAxisIndex, aG as getScalarTypeFittingRange, a3 as getSeed, aA as hex2float, h as hsv2rgb, al as identity3x3, aM as inf, ak as invert3x3, av as invertMatrix, aO as isFinite, E as isInf, aP as isNaN, i as isNan, P as isPowerOfTwo, ax as jacobi, o as jacobiN, H as lab2rgb, aB as lab2xyz, ag as linearSolve3x3, at as luFactorLinearSystem, au as luSolveLinearSystem, ao as matrix3x3ToQuaternion, W as max, V as min, ah as multiply3x3_mat3, N as multiply3x3_vect3, Q as multiplyAccumulate, a6 as multiplyAccumulate2D, ai as multiplyMatrix, ap as multiplyQuaternion, t as multiplyScalar, a5 as multiplyScalar2D,
|
|
4
|
+
export { ae as LUFactor3x3, af as LUSolve3x3, T as Pi, k as add, R as angleBetweenVectors, O as areBoundsInitialized, z as areEquals, a as areMatricesEqual, Y as arrayMax, X as arrayMin, C as arrayRange, a0 as beginCombination, $ as binomial, aJ as boundsIsWithinOtherBounds, U as ceil, Z as ceilLog2, aF as clampAndNormalizeValue, A as clampValue, e as clampVector, c as computeBoundsFromPoints, M as createUninitializedBounds, j as cross, q as default, y as degreesFromRadians, m as determinant2x2, x as determinant3x3, ar as diagonalize3x3, f as distance2BetweenPoints, d as dot, a8 as dot2D, aw as estimateMatrixCondition, aI as extentIsWithinOtherExtent, _ as factorial, aS as float2CssRGBA, aR as floatRGB2HexCode, aQ as floatToHex2, I as floor, a4 as gaussian, aa as gaussianAmplitude, ab as gaussianWeight, aH as getAdjustedScalarRange, D as getMajorAxisIndex, aG as getScalarTypeFittingRange, a3 as getSeed, aA as hex2float, h as hsv2rgb, al as identity3x3, aM as inf, ak as invert3x3, av as invertMatrix, aO as isFinite, E as isInf, aP as isNaN, i as isNan, P as isPowerOfTwo, ax as jacobi, o as jacobiN, H as lab2rgb, aB as lab2xyz, ag as linearSolve3x3, at as luFactorLinearSystem, au as luSolveLinearSystem, ao as matrix3x3ToQuaternion, W as max, V as min, ah as multiply3x3_mat3, N as multiply3x3_vect3, Q as multiplyAccumulate, a6 as multiplyAccumulate2D, ai as multiplyMatrix, ap as multiplyQuaternion, t as multiplyScalar, a5 as multiplyScalar2D, L as nearestPowerOfTwo, aN as negInf, a1 as nextCombination, n as norm, ad as norm2D, l as normalize, K as normalize2D, aq as orthogonalize3x3, a7 as outer, ac as outer2D, p as perpendiculars, aK as pointIsWithinBounds, B as projectVector, a9 as projectVector2D, am as quaternionToMatrix3x3, r as radiansFromDegrees, w as random, a2 as randomSeed, F as rgb2hsv, G as rgb2lab, aE as rgb2xyz, J as round, an as roundNumber, b as roundVector, S as signedAngleBetweenVectors, as as singularValueDecomposition3x3, aL as solve3PointCircle, ay as solveHomogeneousLeastSquares, az as solveLeastSquares, s as solveLinearSystem, g as subtract, aj as transpose3x3, u as uninitializeBounds, aC as xyz2lab, aD as xyz2rgb } from './Math/index.js';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import {
|
|
3
|
+
import { vec3, mat4 } from 'gl-matrix';
|
|
4
4
|
import * as d3 from 'd3-scale';
|
|
5
|
-
import { K as
|
|
5
|
+
import { K as normalize2D, L as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import macro from '../../macros.js';
|
|
7
7
|
import vtkActor from './Actor.js';
|
|
8
8
|
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
9
9
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
10
10
|
import vtkMapper from './Mapper.js';
|
|
11
|
-
import vtkPixelSpaceCallbackMapper from './PixelSpaceCallbackMapper.js';
|
|
12
11
|
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
13
12
|
import vtkTexture from './Texture.js';
|
|
14
13
|
|
|
@@ -24,7 +23,17 @@ var faceNormals = [[-1, 0, 0], [1, 0, 0], [0, -1, 0], [0, 1, 0], [0, 0, -1], [0,
|
|
|
24
23
|
var faceEdges = [[8, 7, 11, 3], [9, 1, 10, 5], [4, 9, 0, 8], [2, 11, 6, 10], [0, 3, 2, 1], [4, 5, 6, 7]];
|
|
25
24
|
var edgePoints = [[0, 1], [1, 3], [2, 3], [0, 2], [4, 5], [5, 7], [6, 7], [4, 6], [0, 4], [1, 5], [3, 7], [2, 6]];
|
|
26
25
|
var edgeAxes = [0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2];
|
|
27
|
-
var faceAxes = [[1, 2], [1, 2], [0, 2], [0, 2], [0, 1], [0, 1]]; //
|
|
26
|
+
var faceAxes = [[1, 2], [1, 2], [0, 2], [0, 2], [0, 1], [0, 1]]; //
|
|
27
|
+
// Developer note: This class is broken into the main class and a helper
|
|
28
|
+
// class. The main class holds view independent properties (those properties
|
|
29
|
+
// that do not change as the view's resolution/aspect ratio change). The
|
|
30
|
+
// helper class is instantiated one per view and holds properties that can
|
|
31
|
+
// depend on view specific values such as resolution. The helper class code
|
|
32
|
+
// could have been left to the View specific implementation (such as
|
|
33
|
+
// vtkWebGPUCubeAxesActor) but is instead placed here to it can be shared by
|
|
34
|
+
// multiple rendering backends.
|
|
35
|
+
//
|
|
36
|
+
// some shared temp variables to reduce heap allocs
|
|
28
37
|
|
|
29
38
|
var ptv3 = new Float64Array(3);
|
|
30
39
|
var pt2v3 = new Float64Array(3);
|
|
@@ -39,8 +48,238 @@ function applyTextStyle(ctx, style) {
|
|
|
39
48
|
ctx.lineWidth = style.strokeSize;
|
|
40
49
|
ctx.fillStyle = style.fontColor;
|
|
41
50
|
ctx.font = "".concat(style.fontStyle, " ").concat(style.fontSize, "px ").concat(style.fontFamily);
|
|
51
|
+
} // many properties of this actor depend on the API specific view The main
|
|
52
|
+
// dependency being the resolution as that drives what font sizes to use.
|
|
53
|
+
// Bacause of this we need to do some of the calculations in a API specific
|
|
54
|
+
// subclass. But... we don't want a lot of duplicated code between WebGL and
|
|
55
|
+
// WebGPU for example so we have this helper class, that is designed to be
|
|
56
|
+
// fairly API independent so that API specific views can call this to do
|
|
57
|
+
// most of the work.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function vtkCubeAxesActorHelper(publicAPI, model) {
|
|
61
|
+
// Set our className
|
|
62
|
+
model.classHierarchy.push('vtkCubeAxesActorHelper');
|
|
63
|
+
|
|
64
|
+
publicAPI.setRenderable = function (renderable) {
|
|
65
|
+
if (model.renderable === renderable) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
model.renderable = renderable;
|
|
70
|
+
model.tmActor.addTexture(model.renderable.getTmTexture());
|
|
71
|
+
model.tmActor.setProperty(renderable.getProperty());
|
|
72
|
+
model.tmActor.setParentProp(renderable);
|
|
73
|
+
publicAPI.modified();
|
|
74
|
+
}; // called by updateTexturePolyData
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
publicAPI.createPolyDataForOneLabel = function (text, pos, cmat, imat, dir, offset, results) {
|
|
78
|
+
var value = model.renderable.get_tmAtlas().get(text);
|
|
79
|
+
|
|
80
|
+
if (!value) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var coords = model.renderable.getTextPolyData().getPoints().getData(); // compute pixel to distance factors
|
|
85
|
+
|
|
86
|
+
var size = model.lastSize;
|
|
87
|
+
ptv3[0] = coords[pos * 3];
|
|
88
|
+
ptv3[1] = coords[pos * 3 + 1];
|
|
89
|
+
ptv3[2] = coords[pos * 3 + 2];
|
|
90
|
+
vec3.transformMat4(tmpv3, ptv3, cmat); // moving 0.1 in NDC
|
|
91
|
+
|
|
92
|
+
tmpv3[0] += 0.1;
|
|
93
|
+
vec3.transformMat4(pt2v3, tmpv3, imat); // results in WC move of
|
|
94
|
+
|
|
95
|
+
vec3.subtract(xDir, pt2v3, ptv3);
|
|
96
|
+
tmpv3[0] -= 0.1;
|
|
97
|
+
tmpv3[1] += 0.1;
|
|
98
|
+
vec3.transformMat4(pt2v3, tmpv3, imat); // results in WC move of
|
|
99
|
+
|
|
100
|
+
vec3.subtract(yDir, pt2v3, ptv3);
|
|
101
|
+
|
|
102
|
+
for (var i = 0; i < 3; i++) {
|
|
103
|
+
xDir[i] /= 0.5 * 0.1 * size[0];
|
|
104
|
+
yDir[i] /= 0.5 * 0.1 * size[1];
|
|
105
|
+
} // have to find the four corners of the texture polygon for this label
|
|
106
|
+
// convert anchor point to View Coords
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
var ptIdx = results.ptIdx;
|
|
110
|
+
var cellIdx = results.cellIdx;
|
|
111
|
+
ptv3[0] = coords[pos * 3];
|
|
112
|
+
ptv3[1] = coords[pos * 3 + 1];
|
|
113
|
+
ptv3[2] = coords[pos * 3 + 2]; // horizontal left, right, or middle alignment based on dir[0]
|
|
114
|
+
|
|
115
|
+
if (dir[0] < -0.5) {
|
|
116
|
+
vec3.scale(tmpv3, xDir, dir[0] * offset - value.width);
|
|
117
|
+
} else if (dir[0] > 0.5) {
|
|
118
|
+
vec3.scale(tmpv3, xDir, dir[0] * offset);
|
|
119
|
+
} else {
|
|
120
|
+
vec3.scale(tmpv3, xDir, dir[0] * offset - value.width / 2.0);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
vec3.add(ptv3, ptv3, tmpv3);
|
|
124
|
+
vec3.scale(tmpv3, yDir, dir[1] * offset - value.height / 2.0);
|
|
125
|
+
vec3.add(ptv3, ptv3, tmpv3);
|
|
126
|
+
results.points[ptIdx * 3] = ptv3[0];
|
|
127
|
+
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
128
|
+
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
129
|
+
results.tcoords[ptIdx * 2] = value.tcoords[0];
|
|
130
|
+
results.tcoords[ptIdx * 2 + 1] = value.tcoords[1];
|
|
131
|
+
ptIdx++;
|
|
132
|
+
vec3.scale(tmpv3, xDir, value.width);
|
|
133
|
+
vec3.add(ptv3, ptv3, tmpv3);
|
|
134
|
+
results.points[ptIdx * 3] = ptv3[0];
|
|
135
|
+
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
136
|
+
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
137
|
+
results.tcoords[ptIdx * 2] = value.tcoords[2];
|
|
138
|
+
results.tcoords[ptIdx * 2 + 1] = value.tcoords[3];
|
|
139
|
+
ptIdx++;
|
|
140
|
+
vec3.scale(tmpv3, yDir, value.height);
|
|
141
|
+
vec3.add(ptv3, ptv3, tmpv3);
|
|
142
|
+
results.points[ptIdx * 3] = ptv3[0];
|
|
143
|
+
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
144
|
+
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
145
|
+
results.tcoords[ptIdx * 2] = value.tcoords[4];
|
|
146
|
+
results.tcoords[ptIdx * 2 + 1] = value.tcoords[5];
|
|
147
|
+
ptIdx++;
|
|
148
|
+
vec3.scale(tmpv3, xDir, value.width);
|
|
149
|
+
vec3.subtract(ptv3, ptv3, tmpv3);
|
|
150
|
+
results.points[ptIdx * 3] = ptv3[0];
|
|
151
|
+
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
152
|
+
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
153
|
+
results.tcoords[ptIdx * 2] = value.tcoords[6];
|
|
154
|
+
results.tcoords[ptIdx * 2 + 1] = value.tcoords[7];
|
|
155
|
+
ptIdx++; // add the two triangles to represent the quad
|
|
156
|
+
|
|
157
|
+
results.polys[cellIdx * 4] = 3;
|
|
158
|
+
results.polys[cellIdx * 4 + 1] = ptIdx - 4;
|
|
159
|
+
results.polys[cellIdx * 4 + 2] = ptIdx - 3;
|
|
160
|
+
results.polys[cellIdx * 4 + 3] = ptIdx - 2;
|
|
161
|
+
cellIdx++;
|
|
162
|
+
results.polys[cellIdx * 4] = 3;
|
|
163
|
+
results.polys[cellIdx * 4 + 1] = ptIdx - 4;
|
|
164
|
+
results.polys[cellIdx * 4 + 2] = ptIdx - 2;
|
|
165
|
+
results.polys[cellIdx * 4 + 3] = ptIdx - 1;
|
|
166
|
+
results.ptIdx += 4;
|
|
167
|
+
results.cellIdx += 2;
|
|
168
|
+
}; // update the polydata associated with drawing the text labels
|
|
169
|
+
// specifically the quads used for each label and their associated tcoords
|
|
170
|
+
// etc. This changes every time the camera viewpoint changes
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
publicAPI.updateTexturePolyData = function () {
|
|
174
|
+
var cmat = model.camera.getCompositeProjectionMatrix(model.lastAspectRatio, -1, 1);
|
|
175
|
+
mat4.transpose(cmat, cmat); // update the polydata
|
|
176
|
+
|
|
177
|
+
var numLabels = model.renderable.getTextValues().length;
|
|
178
|
+
var numPts = numLabels * 4;
|
|
179
|
+
var numTris = numLabels * 2;
|
|
180
|
+
var points = new Float64Array(numPts * 3);
|
|
181
|
+
var polys = new Uint16Array(numTris * 4);
|
|
182
|
+
var tcoords = new Float32Array(numPts * 2);
|
|
183
|
+
mat4.invert(invmat, cmat);
|
|
184
|
+
var results = {
|
|
185
|
+
ptIdx: 0,
|
|
186
|
+
cellIdx: 0,
|
|
187
|
+
polys: polys,
|
|
188
|
+
points: points,
|
|
189
|
+
tcoords: tcoords
|
|
190
|
+
};
|
|
191
|
+
var ptIdx = 0;
|
|
192
|
+
var textIdx = 0;
|
|
193
|
+
var axisIdx = 0;
|
|
194
|
+
var coords = model.renderable.getTextPolyData().getPoints().getData();
|
|
195
|
+
var textValues = model.renderable.getTextValues();
|
|
196
|
+
|
|
197
|
+
while (ptIdx < coords.length / 3) {
|
|
198
|
+
// compute the direction to move out
|
|
199
|
+
ptv3[0] = coords[ptIdx * 3];
|
|
200
|
+
ptv3[1] = coords[ptIdx * 3 + 1];
|
|
201
|
+
ptv3[2] = coords[ptIdx * 3 + 2];
|
|
202
|
+
vec3.transformMat4(tmpv3, ptv3, cmat);
|
|
203
|
+
ptv3[0] = coords[ptIdx * 3 + 3];
|
|
204
|
+
ptv3[1] = coords[ptIdx * 3 + 4];
|
|
205
|
+
ptv3[2] = coords[ptIdx * 3 + 5];
|
|
206
|
+
vec3.transformMat4(tmp2v3, ptv3, cmat);
|
|
207
|
+
vec3.subtract(tmpv3, tmpv3, tmp2v3);
|
|
208
|
+
var dir = [tmpv3[0], tmpv3[1]];
|
|
209
|
+
normalize2D(dir); // write the axis label
|
|
210
|
+
|
|
211
|
+
publicAPI.createPolyDataForOneLabel(textValues[textIdx], ptIdx, cmat, invmat, dir, model.renderable.getAxisTitlePixelOffset(), results);
|
|
212
|
+
ptIdx += 2;
|
|
213
|
+
textIdx++; // write the tick labels
|
|
214
|
+
|
|
215
|
+
for (var t = 0; t < model.renderable.getTickCounts()[axisIdx]; t++) {
|
|
216
|
+
publicAPI.createPolyDataForOneLabel(textValues[textIdx], ptIdx, cmat, invmat, dir, model.renderable.getTickLabelPixelOffset(), results);
|
|
217
|
+
ptIdx++;
|
|
218
|
+
textIdx++;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
axisIdx++;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var tcoordDA = vtkDataArray.newInstance({
|
|
225
|
+
numberOfComponents: 2,
|
|
226
|
+
values: tcoords,
|
|
227
|
+
name: 'TextureCoordinates'
|
|
228
|
+
});
|
|
229
|
+
model.tmPolyData.getPointData().setTCoords(tcoordDA);
|
|
230
|
+
model.tmPolyData.getPoints().setData(points, 3);
|
|
231
|
+
model.tmPolyData.getPoints().modified();
|
|
232
|
+
model.tmPolyData.getPolys().setData(polys, 1);
|
|
233
|
+
model.tmPolyData.getPolys().modified();
|
|
234
|
+
model.tmPolyData.modified();
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
publicAPI.updateAPISpecificData = function (size, camera, renderWindow) {
|
|
238
|
+
// has the size changed?
|
|
239
|
+
if (model.lastSize[0] !== size[0] || model.lastSize[1] !== size[1]) {
|
|
240
|
+
model.lastSize[0] = size[0];
|
|
241
|
+
model.lastSize[1] = size[1];
|
|
242
|
+
model.lastAspectRatio = size[0] / size[1];
|
|
243
|
+
model.forceUpdate = true;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
model.camera = camera; // compute bounds for label quads whenever the camera changes
|
|
247
|
+
|
|
248
|
+
publicAPI.updateTexturePolyData();
|
|
249
|
+
};
|
|
42
250
|
}
|
|
43
251
|
|
|
252
|
+
var newCubeAxesActorHelper = macro.newInstance(function (publicAPI, model) {
|
|
253
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
254
|
+
renderable: null
|
|
255
|
+
};
|
|
256
|
+
Object.assign(model, {}, initialValues); // Inheritance
|
|
257
|
+
|
|
258
|
+
macro.obj(publicAPI, model);
|
|
259
|
+
model.tmPolyData = vtkPolyData.newInstance();
|
|
260
|
+
model.tmMapper = vtkMapper.newInstance();
|
|
261
|
+
model.tmMapper.setInputData(model.tmPolyData);
|
|
262
|
+
model.tmActor = vtkActor.newInstance({
|
|
263
|
+
parentProp: publicAPI
|
|
264
|
+
});
|
|
265
|
+
model.tmActor.setMapper(model.tmMapper);
|
|
266
|
+
macro.setGet(publicAPI, model, ['renderable']);
|
|
267
|
+
macro.get(publicAPI, model, ['lastSize', 'lastAspectRatio', 'axisTextStyle', 'tickTextStyle', 'tmActor', 'ticks']);
|
|
268
|
+
model.forceUpdate = false;
|
|
269
|
+
model.lastRedrawTime = {};
|
|
270
|
+
macro.obj(model.lastRedrawTime, {
|
|
271
|
+
mtime: 0
|
|
272
|
+
});
|
|
273
|
+
model.lastRebuildTime = {};
|
|
274
|
+
macro.obj(model.lastRebuildTime, {
|
|
275
|
+
mtime: 0
|
|
276
|
+
});
|
|
277
|
+
model.lastSize = [-1, -1]; // internal variables
|
|
278
|
+
|
|
279
|
+
model.lastTickBounds = [];
|
|
280
|
+
vtkCubeAxesActorHelper(publicAPI, model);
|
|
281
|
+
}, 'vtkCubeAxesActorHelper');
|
|
282
|
+
|
|
44
283
|
function vtkCubeAxesActor(publicAPI, model) {
|
|
45
284
|
// Set our className
|
|
46
285
|
model.classHierarchy.push('vtkCubeAxesActor');
|
|
@@ -341,10 +580,8 @@ function vtkCubeAxesActor(publicAPI, model) {
|
|
|
341
580
|
if (boundsChanged || model.forceUpdate) {
|
|
342
581
|
publicAPI.updateTextureAtlas(tickStrings);
|
|
343
582
|
}
|
|
344
|
-
}
|
|
345
|
-
|
|
583
|
+
}
|
|
346
584
|
|
|
347
|
-
publicAPI.updateTexturePolyData();
|
|
348
585
|
model.forceUpdate = false;
|
|
349
586
|
}; // create the texture map atlas that contains the rendering of
|
|
350
587
|
// all the text strings. Only needs to be called when the text strings
|
|
@@ -428,178 +665,8 @@ function vtkCubeAxesActor(publicAPI, model) {
|
|
|
428
665
|
model.tmContext.fillText(key, 1, value.startingHeight + value.height - 1);
|
|
429
666
|
});
|
|
430
667
|
|
|
431
|
-
|
|
432
|
-
image.src = model.tmCanvas.toDataURL('image/png');
|
|
433
|
-
model.tmTexture.setImage(image);
|
|
668
|
+
model.tmTexture.setCanvas(model.tmCanvas);
|
|
434
669
|
model.tmTexture.modified();
|
|
435
|
-
}; // called by updateTexturePolyData
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
publicAPI.createPolyDataForOneLabel = function (text, pos, cmat, imat, dir, offset, results) {
|
|
439
|
-
var value = model._tmAtlas.get(text);
|
|
440
|
-
|
|
441
|
-
if (!value) {
|
|
442
|
-
return;
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
var coords = model.textPolyData.getPoints().getData(); // compute pixel to distance factors
|
|
446
|
-
|
|
447
|
-
var size = model.lastSize;
|
|
448
|
-
ptv3[0] = coords[pos * 3];
|
|
449
|
-
ptv3[1] = coords[pos * 3 + 1];
|
|
450
|
-
ptv3[2] = coords[pos * 3 + 2];
|
|
451
|
-
vec3.transformMat4(tmpv3, ptv3, cmat); // moving 0.1 in NDC
|
|
452
|
-
|
|
453
|
-
tmpv3[0] += 0.1;
|
|
454
|
-
vec3.transformMat4(pt2v3, tmpv3, imat); // results in WC move of
|
|
455
|
-
|
|
456
|
-
vec3.subtract(xDir, pt2v3, ptv3);
|
|
457
|
-
tmpv3[0] -= 0.1;
|
|
458
|
-
tmpv3[1] += 0.1;
|
|
459
|
-
vec3.transformMat4(pt2v3, tmpv3, imat); // results in WC move of
|
|
460
|
-
|
|
461
|
-
vec3.subtract(yDir, pt2v3, ptv3);
|
|
462
|
-
|
|
463
|
-
for (var i = 0; i < 3; i++) {
|
|
464
|
-
xDir[i] /= 0.5 * 0.1 * size[0];
|
|
465
|
-
yDir[i] /= 0.5 * 0.1 * size[1];
|
|
466
|
-
} // have to find the four corners of the texture polygon for this label
|
|
467
|
-
// convert anchor point to View Coords
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
var ptIdx = results.ptIdx;
|
|
471
|
-
var cellIdx = results.cellIdx;
|
|
472
|
-
ptv3[0] = coords[pos * 3];
|
|
473
|
-
ptv3[1] = coords[pos * 3 + 1];
|
|
474
|
-
ptv3[2] = coords[pos * 3 + 2]; // horizontal left, right, or middle alignment based on dir[0]
|
|
475
|
-
|
|
476
|
-
if (dir[0] < -0.5) {
|
|
477
|
-
vec3.scale(tmpv3, xDir, dir[0] * offset - value.width);
|
|
478
|
-
} else if (dir[0] > 0.5) {
|
|
479
|
-
vec3.scale(tmpv3, xDir, dir[0] * offset);
|
|
480
|
-
} else {
|
|
481
|
-
vec3.scale(tmpv3, xDir, dir[0] * offset - value.width / 2.0);
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
vec3.add(ptv3, ptv3, tmpv3);
|
|
485
|
-
vec3.scale(tmpv3, yDir, dir[1] * offset - value.height / 2.0);
|
|
486
|
-
vec3.add(ptv3, ptv3, tmpv3);
|
|
487
|
-
results.points[ptIdx * 3] = ptv3[0];
|
|
488
|
-
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
489
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
490
|
-
results.tcoords[ptIdx * 2] = value.tcoords[0];
|
|
491
|
-
results.tcoords[ptIdx * 2 + 1] = value.tcoords[1];
|
|
492
|
-
ptIdx++;
|
|
493
|
-
vec3.scale(tmpv3, xDir, value.width);
|
|
494
|
-
vec3.add(ptv3, ptv3, tmpv3);
|
|
495
|
-
results.points[ptIdx * 3] = ptv3[0];
|
|
496
|
-
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
497
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
498
|
-
results.tcoords[ptIdx * 2] = value.tcoords[2];
|
|
499
|
-
results.tcoords[ptIdx * 2 + 1] = value.tcoords[3];
|
|
500
|
-
ptIdx++;
|
|
501
|
-
vec3.scale(tmpv3, yDir, value.height);
|
|
502
|
-
vec3.add(ptv3, ptv3, tmpv3);
|
|
503
|
-
results.points[ptIdx * 3] = ptv3[0];
|
|
504
|
-
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
505
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
506
|
-
results.tcoords[ptIdx * 2] = value.tcoords[4];
|
|
507
|
-
results.tcoords[ptIdx * 2 + 1] = value.tcoords[5];
|
|
508
|
-
ptIdx++;
|
|
509
|
-
vec3.scale(tmpv3, xDir, value.width);
|
|
510
|
-
vec3.subtract(ptv3, ptv3, tmpv3);
|
|
511
|
-
results.points[ptIdx * 3] = ptv3[0];
|
|
512
|
-
results.points[ptIdx * 3 + 1] = ptv3[1];
|
|
513
|
-
results.points[ptIdx * 3 + 2] = ptv3[2];
|
|
514
|
-
results.tcoords[ptIdx * 2] = value.tcoords[6];
|
|
515
|
-
results.tcoords[ptIdx * 2 + 1] = value.tcoords[7];
|
|
516
|
-
ptIdx++; // add the two triangles to represent the quad
|
|
517
|
-
|
|
518
|
-
results.polys[cellIdx * 4] = 3;
|
|
519
|
-
results.polys[cellIdx * 4 + 1] = ptIdx - 4;
|
|
520
|
-
results.polys[cellIdx * 4 + 2] = ptIdx - 3;
|
|
521
|
-
results.polys[cellIdx * 4 + 3] = ptIdx - 2;
|
|
522
|
-
cellIdx++;
|
|
523
|
-
results.polys[cellIdx * 4] = 3;
|
|
524
|
-
results.polys[cellIdx * 4 + 1] = ptIdx - 4;
|
|
525
|
-
results.polys[cellIdx * 4 + 2] = ptIdx - 2;
|
|
526
|
-
results.polys[cellIdx * 4 + 3] = ptIdx - 1;
|
|
527
|
-
results.ptIdx += 4;
|
|
528
|
-
results.cellIdx += 2;
|
|
529
|
-
}; // update the polydata associated with drawing the text labels
|
|
530
|
-
// specifically the quads used for each label and their associated tcoords
|
|
531
|
-
// etc. This changes every time the camera viewpoint changes
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
publicAPI.updateTexturePolyData = function () {
|
|
535
|
-
var cmat = model.camera.getCompositeProjectionMatrix(model.lastAspectRatio, -1, 1);
|
|
536
|
-
mat4.transpose(cmat, cmat); // update the polydata
|
|
537
|
-
|
|
538
|
-
var numLabels = model.textValues.length;
|
|
539
|
-
var numPts = numLabels * 4;
|
|
540
|
-
var numTris = numLabels * 2;
|
|
541
|
-
var points = new Float64Array(numPts * 3);
|
|
542
|
-
var polys = new Uint16Array(numTris * 4);
|
|
543
|
-
var tcoords = new Float32Array(numPts * 2);
|
|
544
|
-
mat4.invert(invmat, cmat);
|
|
545
|
-
var results = {
|
|
546
|
-
ptIdx: 0,
|
|
547
|
-
cellIdx: 0,
|
|
548
|
-
polys: polys,
|
|
549
|
-
points: points,
|
|
550
|
-
tcoords: tcoords
|
|
551
|
-
};
|
|
552
|
-
var ptIdx = 0;
|
|
553
|
-
var textIdx = 0;
|
|
554
|
-
var axisIdx = 0;
|
|
555
|
-
var coords = model.textPolyData.getPoints().getData();
|
|
556
|
-
|
|
557
|
-
while (ptIdx < coords.length / 3) {
|
|
558
|
-
// compute the direction to move out
|
|
559
|
-
ptv3[0] = coords[ptIdx * 3];
|
|
560
|
-
ptv3[1] = coords[ptIdx * 3 + 1];
|
|
561
|
-
ptv3[2] = coords[ptIdx * 3 + 2];
|
|
562
|
-
vec3.transformMat4(tmpv3, ptv3, cmat);
|
|
563
|
-
ptv3[0] = coords[ptIdx * 3 + 3];
|
|
564
|
-
ptv3[1] = coords[ptIdx * 3 + 4];
|
|
565
|
-
ptv3[2] = coords[ptIdx * 3 + 5];
|
|
566
|
-
vec3.transformMat4(tmp2v3, ptv3, cmat);
|
|
567
|
-
vec3.subtract(tmpv3, tmpv3, tmp2v3);
|
|
568
|
-
var dir = [tmpv3[0], tmpv3[1]];
|
|
569
|
-
normalize2D(dir); // write the axis label
|
|
570
|
-
|
|
571
|
-
publicAPI.createPolyDataForOneLabel(model.textValues[textIdx], ptIdx, cmat, invmat, dir, model.axisTitlePixelOffset, results);
|
|
572
|
-
ptIdx += 2;
|
|
573
|
-
textIdx++; // write the tick labels
|
|
574
|
-
|
|
575
|
-
for (var t = 0; t < model.tickCounts[axisIdx]; t++) {
|
|
576
|
-
publicAPI.createPolyDataForOneLabel(model.textValues[textIdx], ptIdx, cmat, invmat, dir, model.tickLabelPixelOffset, results);
|
|
577
|
-
ptIdx++;
|
|
578
|
-
textIdx++;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
axisIdx++;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
var tcoordDA = vtkDataArray.newInstance({
|
|
585
|
-
numberOfComponents: 2,
|
|
586
|
-
values: tcoords,
|
|
587
|
-
name: 'TextureCoordinates'
|
|
588
|
-
});
|
|
589
|
-
model.tmPolyData.getPointData().setTCoords(tcoordDA);
|
|
590
|
-
model.tmPolyData.getPoints().setData(points, 3);
|
|
591
|
-
model.tmPolyData.getPoints().modified();
|
|
592
|
-
model.tmPolyData.getPolys().setData(polys, 1);
|
|
593
|
-
model.tmPolyData.getPolys().modified();
|
|
594
|
-
model.tmPolyData.modified();
|
|
595
|
-
};
|
|
596
|
-
|
|
597
|
-
publicAPI.getActors = function () {
|
|
598
|
-
return [model.pixelActor, model.tmActor];
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
publicAPI.getNestedProps = function () {
|
|
602
|
-
return publicAPI.getActors();
|
|
603
670
|
}; // Make sure the data is correct
|
|
604
671
|
|
|
605
672
|
|
|
@@ -607,11 +674,6 @@ function vtkCubeAxesActor(publicAPI, model) {
|
|
|
607
674
|
model.forceUpdate = true;
|
|
608
675
|
publicAPI.update();
|
|
609
676
|
});
|
|
610
|
-
var setVisibility = macro.chain(publicAPI.setVisibility, model.pixelActor.setVisibility, model.tmActor.setVisibility);
|
|
611
|
-
|
|
612
|
-
publicAPI.setVisibility = function () {
|
|
613
|
-
return setVisibility.apply(void 0, arguments).some(Boolean);
|
|
614
|
-
};
|
|
615
677
|
|
|
616
678
|
publicAPI.setTickTextStyle = function (tickStyle) {
|
|
617
679
|
model.tickTextStyle = _objectSpread(_objectSpread({}, model.tickTextStyle), tickStyle);
|
|
@@ -658,51 +720,31 @@ function extend(publicAPI, model) {
|
|
|
658
720
|
|
|
659
721
|
vtkActor.extend(publicAPI, model, initialValues); // internal variables
|
|
660
722
|
|
|
661
|
-
model.lastSize = [800, 800];
|
|
662
|
-
model.lastAspectRatio = 1.0;
|
|
663
723
|
model.lastFacesToDraw = [false, false, false, false, false, false];
|
|
664
724
|
model.axisLabels = ['X-Axis', 'Y-Axis', 'Z-Axis'];
|
|
665
725
|
model.tickCounts = [];
|
|
666
726
|
model.textValues = [];
|
|
667
727
|
model.lastTickBounds = [];
|
|
668
|
-
model.
|
|
669
|
-
model.
|
|
670
|
-
model.
|
|
671
|
-
model.mapper.setInputData(model.polyData);
|
|
672
|
-
publicAPI.getProperty().setDiffuse(0.0);
|
|
673
|
-
publicAPI.getProperty().setAmbient(1.0);
|
|
674
|
-
model.textPolyData = vtkPolyData.newInstance(); // for texture atlas
|
|
728
|
+
model.tmCanvas = document.createElement('canvas');
|
|
729
|
+
model.tmContext = model.tmCanvas.getContext('2d');
|
|
730
|
+
model._tmAtlas = new Map(); // for texture atlas
|
|
675
731
|
|
|
676
|
-
model.tmPolyData = vtkPolyData.newInstance();
|
|
677
|
-
model.tmMapper = vtkMapper.newInstance();
|
|
678
|
-
model.tmMapper.setInputData(model.tmPolyData);
|
|
679
732
|
model.tmTexture = vtkTexture.newInstance();
|
|
680
733
|
model.tmTexture.setInterpolate(false);
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
model.
|
|
685
|
-
model.
|
|
686
|
-
model.
|
|
687
|
-
model.
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
model.pixelMapper = vtkPixelSpaceCallbackMapper.newInstance();
|
|
692
|
-
model.pixelMapperPolyData = vtkPolyData.newInstance();
|
|
693
|
-
model.pixelMapper.setInputData(model.pixelMapperPolyData);
|
|
694
|
-
model.pixelMapper.setCallback(function (coords, camera, aspect, depthValues, size) {
|
|
695
|
-
model.lastSize = size;
|
|
696
|
-
model.lastAspectRatio = size[0] / size[1];
|
|
697
|
-
});
|
|
698
|
-
model.pixelActor = vtkActor.newInstance({
|
|
699
|
-
parentProp: publicAPI
|
|
700
|
-
});
|
|
701
|
-
model.pixelActor.setMapper(model.pixelMapper);
|
|
734
|
+
publicAPI.getProperty().setDiffuse(0.0);
|
|
735
|
+
publicAPI.getProperty().setAmbient(1.0);
|
|
736
|
+
model.gridMapper = vtkMapper.newInstance();
|
|
737
|
+
model.polyData = vtkPolyData.newInstance();
|
|
738
|
+
model.gridMapper.setInputData(model.polyData);
|
|
739
|
+
model.gridActor = vtkActor.newInstance();
|
|
740
|
+
model.gridActor.setMapper(model.gridMapper);
|
|
741
|
+
model.gridActor.setProperty(publicAPI.getProperty());
|
|
742
|
+
model.gridActor.setParentProp(publicAPI);
|
|
743
|
+
model.textPolyData = vtkPolyData.newInstance();
|
|
702
744
|
macro.setGet(publicAPI, model, ['axisTitlePixelOffset', 'faceVisibilityAngle', 'gridLines', 'tickLabelPixelOffset']);
|
|
703
745
|
macro.setGetArray(publicAPI, model, ['dataBounds'], 6);
|
|
704
746
|
macro.setGetArray(publicAPI, model, ['axisLabels'], 3);
|
|
705
|
-
macro.get(publicAPI, model, ['axisTextStyle', 'tickTextStyle', 'camera']); // Object methods
|
|
747
|
+
macro.get(publicAPI, model, ['axisTextStyle', 'tickTextStyle', 'camera', 'tmTexture', 'textValues', 'textPolyData', '_tmAtlas', 'tickCounts', 'gridActor']); // Object methods
|
|
706
748
|
|
|
707
749
|
vtkCubeAxesActor(publicAPI, model);
|
|
708
750
|
} // ----------------------------------------------------------------------------
|
|
@@ -711,7 +753,8 @@ var newInstance = macro.newInstance(extend, 'vtkCubeAxesActor'); // ------------
|
|
|
711
753
|
|
|
712
754
|
var vtkCubeAxesActor$1 = {
|
|
713
755
|
newInstance: newInstance,
|
|
714
|
-
extend: extend
|
|
756
|
+
extend: extend,
|
|
757
|
+
newCubeAxesActorHelper: newCubeAxesActorHelper
|
|
715
758
|
};
|
|
716
759
|
|
|
717
760
|
export { vtkCubeAxesActor$1 as default, extend, newInstance };
|
|
@@ -2,7 +2,7 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import { vec3, mat4 } from 'gl-matrix';
|
|
4
4
|
import * as d3 from 'd3-scale';
|
|
5
|
-
import {
|
|
5
|
+
import { L as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
6
6
|
import macro from '../../macros.js';
|
|
7
7
|
import vtkActor from './Actor.js';
|
|
8
8
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { newInstance as newInstance$1 } from '../../macros.js';
|
|
2
|
+
import vtkCubeAxesActor from '../Core/CubeAxesActor.js';
|
|
3
|
+
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
4
|
+
import { registerOverride } from './ViewNodeFactory.js';
|
|
5
|
+
|
|
6
|
+
// vtkOpenGLCubeAxesActor methods
|
|
7
|
+
// ----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
function vtkOpenGLCubeAxesActor(publicAPI, model) {
|
|
10
|
+
model.classHierarchy.push('vtkOpenGLCubeAxesActor'); // Builds myself.
|
|
11
|
+
|
|
12
|
+
publicAPI.buildPass = function (prepass) {
|
|
13
|
+
if (prepass) {
|
|
14
|
+
model.openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
15
|
+
model.openGLRenderWindow = model.openGLRenderer.getParent();
|
|
16
|
+
|
|
17
|
+
if (!model.CubeAxesActorHelper.getRenderable()) {
|
|
18
|
+
model.CubeAxesActorHelper.setRenderable(model.renderable);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
publicAPI.prepareNodes();
|
|
22
|
+
publicAPI.addMissingNode(model.CubeAxesActorHelper.getTmActor());
|
|
23
|
+
publicAPI.addMissingNode(model.renderable.getGridActor());
|
|
24
|
+
publicAPI.removeUnusedNodes();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
publicAPI.opaquePass = function (prepass, renderPass) {
|
|
29
|
+
if (prepass) {
|
|
30
|
+
var camera = model.openGLRenderer ? model.openGLRenderer.getRenderable().getActiveCamera() : null;
|
|
31
|
+
var tsize = model.openGLRenderer.getTiledSizeAndOrigin();
|
|
32
|
+
model.CubeAxesActorHelper.updateAPISpecificData([tsize.usize, tsize.vsize], camera, model.openGLRenderWindow.getRenderable());
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
} // ----------------------------------------------------------------------------
|
|
36
|
+
// Object factory
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var DEFAULT_VALUES = {}; // ----------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
function extend(publicAPI, model) {
|
|
43
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
44
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
45
|
+
|
|
46
|
+
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
47
|
+
model.CubeAxesActorHelper = vtkCubeAxesActor.newCubeAxesActorHelper(); // Object methods
|
|
48
|
+
|
|
49
|
+
vtkOpenGLCubeAxesActor(publicAPI, model);
|
|
50
|
+
} // ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
var newInstance = newInstance$1(extend, 'vtkOpenGLCubeAxesActor'); // ----------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
var index = {
|
|
55
|
+
newInstance: newInstance,
|
|
56
|
+
extend: extend
|
|
57
|
+
}; // Register ourself to OpenGL backend if imported
|
|
58
|
+
|
|
59
|
+
registerOverride('vtkCubeAxesActor', newInstance);
|
|
60
|
+
|
|
61
|
+
export { index as default, extend, newInstance };
|
|
@@ -3,7 +3,7 @@ import Constants from './Texture/Constants.js';
|
|
|
3
3
|
import HalfFloat from '../../Common/Core/HalfFloat.js';
|
|
4
4
|
import { newInstance as newInstance$1, obj, set, setGet, get, newTypedArray, vtkDebugMacro as vtkDebugMacro$1, vtkErrorMacro as vtkErrorMacro$1, vtkWarningMacro as vtkWarningMacro$1 } from '../../macros.js';
|
|
5
5
|
import vtkDataArray from '../../Common/Core/DataArray.js';
|
|
6
|
-
import { P as isPowerOfTwo,
|
|
6
|
+
import { P as isPowerOfTwo, L as nearestPowerOfTwo } from '../../Common/Core/Math/index.js';
|
|
7
7
|
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
8
8
|
import { registerOverride } from './ViewNodeFactory.js';
|
|
9
9
|
|
package/Rendering/OpenGL.js
CHANGED
|
@@ -4,6 +4,7 @@ import vtkBufferObject from './OpenGL/BufferObject.js';
|
|
|
4
4
|
import vtkCamera from './OpenGL/Camera.js';
|
|
5
5
|
import vtkCellArrayBufferObject from './OpenGL/CellArrayBufferObject.js';
|
|
6
6
|
import vtkConvolution2DPass from './OpenGL/Convolution2DPass.js';
|
|
7
|
+
import './OpenGL/CubeAxesActor.js';
|
|
7
8
|
import vtkForwardPass from './OpenGL/ForwardPass.js';
|
|
8
9
|
import vtkOpenGLFramebuffer from './OpenGL/Framebuffer.js';
|
|
9
10
|
import vtkGlyph3DMapper from './OpenGL/Glyph3DMapper.js';
|
|
@@ -2,6 +2,7 @@ import '../OpenGL/Camera.js';
|
|
|
2
2
|
import '../OpenGL/Renderer.js';
|
|
3
3
|
import '../OpenGL/Actor.js';
|
|
4
4
|
import '../OpenGL/Actor2D.js';
|
|
5
|
+
import '../OpenGL/CubeAxesActor.js';
|
|
5
6
|
import '../OpenGL/PolyDataMapper.js';
|
|
6
7
|
import '../OpenGL/PolyDataMapper2D.js';
|
|
7
8
|
import '../OpenGL/ScalarBarActor.js';
|
|
@@ -19,6 +20,7 @@ import '../OpenGL/StickMapper.js';
|
|
|
19
20
|
import '../WebGPU/Camera.js';
|
|
20
21
|
import '../WebGPU/Renderer.js';
|
|
21
22
|
import '../WebGPU/Actor.js';
|
|
23
|
+
import '../WebGPU/CubeAxesActor.js';
|
|
22
24
|
import '../WebGPU/PolyDataMapper.js';
|
|
23
25
|
import '../WebGPU/ScalarBarActor.js';
|
|
24
26
|
import '../WebGPU/Texture.js';
|
|
@@ -2,6 +2,7 @@ import '../OpenGL/Camera.js';
|
|
|
2
2
|
import '../OpenGL/Renderer.js';
|
|
3
3
|
import '../OpenGL/Actor.js';
|
|
4
4
|
import '../OpenGL/Actor2D.js';
|
|
5
|
+
import '../OpenGL/CubeAxesActor.js';
|
|
5
6
|
import '../OpenGL/PolyDataMapper.js';
|
|
6
7
|
import '../OpenGL/PolyDataMapper2D.js';
|
|
7
8
|
import '../OpenGL/ScalarBarActor.js';
|
|
@@ -11,6 +12,7 @@ import '../OpenGL/PixelSpaceCallbackMapper.js';
|
|
|
11
12
|
import '../WebGPU/Camera.js';
|
|
12
13
|
import '../WebGPU/Renderer.js';
|
|
13
14
|
import '../WebGPU/Actor.js';
|
|
15
|
+
import '../WebGPU/CubeAxesActor.js';
|
|
14
16
|
import '../WebGPU/PolyDataMapper.js';
|
|
15
17
|
import '../WebGPU/ScalarBarActor.js';
|
|
16
18
|
import '../WebGPU/Texture.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { newInstance as newInstance$1 } from '../../macros.js';
|
|
2
|
+
import vtkCubeAxesActor from '../Core/CubeAxesActor.js';
|
|
3
|
+
import vtkViewNode from '../SceneGraph/ViewNode.js';
|
|
4
|
+
import { registerOverride } from './ViewNodeFactory.js';
|
|
5
|
+
|
|
6
|
+
// vtkWebGPUCubeAxesActor methods
|
|
7
|
+
// ----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
function vtkWebGPUCubeAxesActor(publicAPI, model) {
|
|
10
|
+
model.classHierarchy.push('vtkWebGPUCubeAxesActor'); // Builds myself.
|
|
11
|
+
|
|
12
|
+
publicAPI.buildPass = function (prepass) {
|
|
13
|
+
if (prepass) {
|
|
14
|
+
model.WebGPURenderer = publicAPI.getFirstAncestorOfType('vtkWebGPURenderer');
|
|
15
|
+
model.WebGPURenderWindow = model.WebGPURenderer.getParent();
|
|
16
|
+
|
|
17
|
+
if (!model.CubeAxesActorHelper.getRenderable()) {
|
|
18
|
+
model.CubeAxesActorHelper.setRenderable(model.renderable);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
publicAPI.prepareNodes();
|
|
22
|
+
publicAPI.addMissingNode(model.CubeAxesActorHelper.getTmActor());
|
|
23
|
+
publicAPI.addMissingNode(model.renderable.getGridActor());
|
|
24
|
+
publicAPI.removeUnusedNodes();
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
publicAPI.opaquePass = function (prepass, renderPass) {
|
|
29
|
+
if (prepass) {
|
|
30
|
+
var camera = model.WebGPURenderer ? model.WebGPURenderer.getRenderable().getActiveCamera() : null;
|
|
31
|
+
var tsize = model.WebGPURenderer.getTiledSizeAndOrigin();
|
|
32
|
+
model.CubeAxesActorHelper.updateAPISpecificData([tsize.usize, tsize.vsize], camera, model.WebGPURenderWindow.getRenderable());
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
} // ----------------------------------------------------------------------------
|
|
36
|
+
// Object factory
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
var DEFAULT_VALUES = {}; // ----------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
function extend(publicAPI, model) {
|
|
43
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
44
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
45
|
+
|
|
46
|
+
vtkViewNode.extend(publicAPI, model, initialValues);
|
|
47
|
+
model.CubeAxesActorHelper = vtkCubeAxesActor.newCubeAxesActorHelper(); // Object methods
|
|
48
|
+
|
|
49
|
+
vtkWebGPUCubeAxesActor(publicAPI, model);
|
|
50
|
+
} // ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
var newInstance = newInstance$1(extend, 'vtkWebGPUCubeAxesActor'); // ----------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
var index = {
|
|
55
|
+
newInstance: newInstance,
|
|
56
|
+
extend: extend
|
|
57
|
+
}; // Register ourself to WebGPU backend if imported
|
|
58
|
+
|
|
59
|
+
registerOverride('vtkCubeAxesActor', newInstance);
|
|
60
|
+
|
|
61
|
+
export { index as default, extend, newInstance };
|
package/Rendering/WebGPU.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import vtkRenderWindow from './WebGPU/RenderWindow.js';
|
|
2
2
|
import './WebGPU/Actor.js';
|
|
3
3
|
import './WebGPU/Camera.js';
|
|
4
|
+
import './WebGPU/CubeAxesActor.js';
|
|
4
5
|
import './WebGPU/ForwardPass.js';
|
|
5
6
|
import './WebGPU/Glyph3DMapper.js';
|
|
6
7
|
import './WebGPU/HardwareSelector.js';
|