@kitware/vtk.js 21.2.1 → 21.4.0
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.d.ts +233 -218
- package/IO/Geometry/STLReader.js +2 -2
- package/Interaction/Style/InteractorStyleTrackballCamera.js +5 -4
- package/Rendering/Core/Actor2D.js +1 -3
- package/Rendering/Core/Mapper2D.d.ts +402 -0
- package/Rendering/Core/Mapper2D.js +213 -0
- package/Rendering/Core/Property2D/Constants.js +9 -0
- package/Rendering/Core/Property2D.js +30 -2
- package/Rendering/Core/RenderWindowInteractor/Constants.js +15 -3
- package/Rendering/Core/RenderWindowInteractor.js +27 -21
- package/Rendering/Core.js +2 -0
- package/Rendering/OpenGL/Actor2D.js +74 -30
- package/Rendering/OpenGL/ForwardPass.js +11 -0
- package/Rendering/OpenGL/PolyDataMapper.js +3 -2
- package/Rendering/OpenGL/PolyDataMapper2D.js +667 -0
- package/Rendering/OpenGL/Profiles/All.js +1 -0
- package/Rendering/OpenGL/Profiles/Geometry.js +1 -0
- package/Rendering/OpenGL/RenderWindow.js +2 -1
- package/Rendering/OpenGL/glsl/vtkPolyData2DFS.glsl.js +3 -0
- package/Rendering/OpenGL/glsl/vtkPolyData2DVS.glsl.js +3 -0
- package/Rendering/OpenGL.js +2 -0
- package/Rendering/Profiles/All.js +1 -0
- package/Rendering/Profiles/Geometry.js +1 -0
- package/macros.js +6 -2
- package/package.json +1 -1
- package/types.d.ts +5 -0
package/IO/Geometry/STLReader.js
CHANGED
|
@@ -182,8 +182,8 @@ function vtkSTLReader(publicAPI, model) {
|
|
|
182
182
|
var headerStr = BinaryHelper.arrayBufferToString(headerData);
|
|
183
183
|
var header = parseHeader(headerStr); // Data
|
|
184
184
|
|
|
185
|
-
var dataView = new DataView(content, 84);
|
|
186
|
-
|
|
185
|
+
var dataView = new DataView(content, 84); // global.dataview = dataView;
|
|
186
|
+
|
|
187
187
|
var nbFaces = (content.byteLength - 84) / 50;
|
|
188
188
|
var pointValues = new Float32Array(nbFaces * 9);
|
|
189
189
|
var normalValues = new Float32Array(nbFaces * 3);
|
|
@@ -53,12 +53,12 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
publicAPI.handleButton3D = function (ed) {
|
|
56
|
-
if (ed && ed.pressed && ed.device === Device.RightController && ed.input === Input.TrackPad) {
|
|
56
|
+
if (ed && ed.pressed && ed.device === Device.RightController && (ed.input === Input.Trigger || ed.input === Input.TrackPad)) {
|
|
57
57
|
publicAPI.startCameraPose();
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if (ed && !ed.pressed && ed.device === Device.RightController && ed.input === Input.TrackPad && model.state === States.IS_CAMERA_POSE) {
|
|
61
|
+
if (ed && !ed.pressed && ed.device === Device.RightController && (ed.input === Input.Trigger || ed.input === Input.TrackPad) && model.state === States.IS_CAMERA_POSE) {
|
|
62
62
|
publicAPI.endCameraPose(); // return;
|
|
63
63
|
}
|
|
64
64
|
};
|
|
@@ -77,11 +77,12 @@ function vtkInteractorStyleTrackballCamera(publicAPI, model) {
|
|
|
77
77
|
var camera = ed.pokedRenderer.getActiveCamera();
|
|
78
78
|
var oldTrans = camera.getPhysicalTranslation(); // look at the y axis to determine how fast / what direction to move
|
|
79
79
|
|
|
80
|
-
var speed = ed.gamepad.axes[1];
|
|
80
|
+
var speed = 0.5; // ed.gamepad.axes[1];
|
|
81
|
+
// 0.05 meters / frame movement
|
|
81
82
|
|
|
82
83
|
var pscale = speed * 0.05 * camera.getPhysicalScale(); // convert orientation to world coordinate direction
|
|
83
84
|
|
|
84
|
-
var dir = camera.physicalOrientationToWorldDirection(ed.orientation);
|
|
85
|
+
var dir = camera.physicalOrientationToWorldDirection([ed.orientation.x, ed.orientation.y, ed.orientation.z, ed.orientation.w]);
|
|
85
86
|
camera.setPhysicalTranslation(oldTrans[0] + dir[0] * pscale, oldTrans[1] + dir[1] * pscale, oldTrans[2] + dir[2] * pscale);
|
|
86
87
|
}; //----------------------------------------------------------------------------
|
|
87
88
|
|
|
@@ -24,9 +24,7 @@ function vtkActor2D(publicAPI, model) {
|
|
|
24
24
|
|
|
25
25
|
var isOpaque = model.property.getOpacity() >= 1.0; // are we using an opaque texture, if any?
|
|
26
26
|
|
|
27
|
-
isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent());
|
|
28
|
-
|
|
29
|
-
isOpaque = isOpaque && (!model.mapper || model.mapper.getIsOpaque());
|
|
27
|
+
isOpaque = isOpaque && (!model.texture || !model.texture.isTranslucent());
|
|
30
28
|
return isOpaque;
|
|
31
29
|
};
|
|
32
30
|
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
import vtkAbstractMapper, { IAbstractMapperInitialValues } from '@kitware/vtk.js/Rendering/Core/AbstractMapper';
|
|
2
|
+
|
|
3
|
+
export enum ColorMode {
|
|
4
|
+
DEFAULT,
|
|
5
|
+
MAP_SCALARS,
|
|
6
|
+
DIRECT_SCALARS,
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum ScalarMode {
|
|
10
|
+
DEFAULT,
|
|
11
|
+
USE_POINT_DATA,
|
|
12
|
+
USE_CELL_DATA,
|
|
13
|
+
USE_POINT_FIELD_DATA,
|
|
14
|
+
USE_CELL_FIELD_DATA,
|
|
15
|
+
USE_FIELD_DATA,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export enum GetArray {
|
|
19
|
+
BY_ID,
|
|
20
|
+
BY_NAME,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface IPrimitiveCount {
|
|
24
|
+
points: number;
|
|
25
|
+
verts: number;
|
|
26
|
+
lines: number;
|
|
27
|
+
triangles: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface IAbstractScalars {
|
|
31
|
+
cellFlag: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface IScalarToTextureCoordinate {
|
|
35
|
+
texCoordS: number;
|
|
36
|
+
texCoordT: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IMapper2DInitialValues extends IAbstractMapperInitialValues{
|
|
40
|
+
arrayAccessMode?: number;
|
|
41
|
+
colorMode?: number;
|
|
42
|
+
customShaderAttributes?: any;
|
|
43
|
+
renderTime?: number;
|
|
44
|
+
scalarMode?: number;
|
|
45
|
+
scalarRange?: Range;
|
|
46
|
+
scalarVisibility?: boolean;
|
|
47
|
+
static?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface vtkMapper2D extends vtkAbstractMapper {
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create default lookup table. Generally used to create one when
|
|
54
|
+
* none is available with the scalar data.
|
|
55
|
+
*/
|
|
56
|
+
createDefaultLookupTable(): void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param input
|
|
61
|
+
* @param {ScalarMode} scalarMode
|
|
62
|
+
* @param arrayAccessMode
|
|
63
|
+
* @param arrayId
|
|
64
|
+
* @param arrayName
|
|
65
|
+
*/
|
|
66
|
+
getAbstractScalars(input: any, scalarMode: ScalarMode, arrayAccessMode: number, arrayId: any, arrayName: any): IAbstractScalars;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
getArrayAccessMode(): number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get the array name to color by.
|
|
75
|
+
*/
|
|
76
|
+
getColorByArrayName(): string | null;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Provide read access to the color array.
|
|
80
|
+
*/
|
|
81
|
+
getColorMapColors(): Uint8Array | null;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Return the method of coloring scalar data.
|
|
85
|
+
*/
|
|
86
|
+
getColorMode(): number;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Return the method of coloring scalar data.
|
|
90
|
+
*/
|
|
91
|
+
getColorModeAsString(): string;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @default []
|
|
96
|
+
*/
|
|
97
|
+
getCustomShaderAttributes(): any
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get a lookup table for the mapper to use.
|
|
101
|
+
*/
|
|
102
|
+
getLookupTable(): any;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get the transformCoordinate.
|
|
106
|
+
*/
|
|
107
|
+
getTransformCoordinate(): any;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Return the method for obtaining scalar data.
|
|
111
|
+
*/
|
|
112
|
+
getScalarMode(): number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Return the method for obtaining scalar data.
|
|
116
|
+
*/
|
|
117
|
+
getScalarModeAsString(): string;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @default [0, 1]
|
|
122
|
+
*/
|
|
123
|
+
getScalarRange(): number[];
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
*
|
|
127
|
+
* @default [0, 1]
|
|
128
|
+
*/
|
|
129
|
+
getScalarRangeByReference(): number[];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Check whether scalar data is used to color objects.
|
|
133
|
+
* @default true
|
|
134
|
+
*/
|
|
135
|
+
getScalarVisibility(): boolean;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Check whether the mapper’s data is static.
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
141
|
+
getStatic(): boolean;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
*
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
getUseLookupTableScalarRange(): boolean;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
*
|
|
151
|
+
* @default null
|
|
152
|
+
*/
|
|
153
|
+
getViewSpecificProperties(): object;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Map the scalars (if there are any scalars and ScalarVisibility is on)
|
|
157
|
+
* through the lookup table, returning an unsigned char RGBA array. This is
|
|
158
|
+
* typically done as part of the rendering process. The alpha parameter
|
|
159
|
+
* allows the blending of the scalars with an additional alpha (typically
|
|
160
|
+
* which comes from a vtkActor, etc.)
|
|
161
|
+
* {
|
|
162
|
+
* rgba: Uint8Array(),
|
|
163
|
+
* location: 0/1/2, // Points/Cells/Fields
|
|
164
|
+
* }
|
|
165
|
+
* @param input
|
|
166
|
+
* @param {Number} alpha
|
|
167
|
+
*/
|
|
168
|
+
mapScalars(input: any, alpha: number): void;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
*
|
|
172
|
+
* @param {Number} arrayAccessMode
|
|
173
|
+
*/
|
|
174
|
+
setArrayAccessMode(arrayAccessMode: number): boolean;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set the array name to color by.
|
|
178
|
+
* @param {String} colorByArrayName
|
|
179
|
+
*/
|
|
180
|
+
setColorByArrayName(colorByArrayName: string): boolean;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
*
|
|
184
|
+
* @param {Number} colorMode
|
|
185
|
+
*/
|
|
186
|
+
setColorMode(colorMode: number): boolean;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Sets colorMode to `DEFAULT`
|
|
190
|
+
*/
|
|
191
|
+
setColorModeToDefault(): boolean;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Sets colorMode to `MAP_SCALARS`
|
|
195
|
+
*/
|
|
196
|
+
setColorModeToMapScalars(): boolean;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Sets colorMode to `DIRECT_SCALARS`
|
|
200
|
+
*/
|
|
201
|
+
setColorModeToDirectScalars(): boolean;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Sets point data array names that will be transferred to the VBO
|
|
205
|
+
* @param {String[]} customShaderAttributes
|
|
206
|
+
*/
|
|
207
|
+
setCustomShaderAttributes(customShaderAttributes: string[]): boolean
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Set a lookup table for the mapper to use.
|
|
211
|
+
*/
|
|
212
|
+
setLookupTable(lookupTable: any): boolean;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Set the transformCoordinate.
|
|
216
|
+
*/
|
|
217
|
+
setTransformCoordinate(coordinate: any): boolean;
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Control how the filter works with scalar point data and cell attribute
|
|
221
|
+
* data. By default (ScalarModeToDefault), the filter will use point data,
|
|
222
|
+
* and if no point data is available, then cell data is used. Alternatively
|
|
223
|
+
* you can explicitly set the filter to use point data
|
|
224
|
+
* (ScalarModeToUsePointData) or cell data (ScalarModeToUseCellData).
|
|
225
|
+
* You can also choose to get the scalars from an array in point field
|
|
226
|
+
* data (ScalarModeToUsePointFieldData) or cell field data
|
|
227
|
+
* (ScalarModeToUseCellFieldData). If scalars are coming from a field
|
|
228
|
+
* data array, you must call SelectColorArray before you call GetColors.
|
|
229
|
+
*
|
|
230
|
+
* When ScalarMode is set to use Field Data (ScalarModeToFieldData),
|
|
231
|
+
* you must call SelectColorArray to choose the field data array to
|
|
232
|
+
* be used to color cells. In this mode, the default behavior is to
|
|
233
|
+
* treat the field data tuples as being associated with cells. If
|
|
234
|
+
* the poly data contains triangle strips, the array is expected to
|
|
235
|
+
* contain the cell data for each mini-cell formed by any triangle
|
|
236
|
+
* strips in the poly data as opposed to treating them as a single
|
|
237
|
+
* tuple that applies to the entire strip. This mode can also be
|
|
238
|
+
* used to color the entire poly data by a single color obtained by
|
|
239
|
+
* mapping the tuple at a given index in the field data array
|
|
240
|
+
* through the color map. Use SetFieldDataTupleId() to specify
|
|
241
|
+
* the tuple index.
|
|
242
|
+
*
|
|
243
|
+
* @param scalarMode
|
|
244
|
+
*/
|
|
245
|
+
setScalarMode(scalarMode: number): boolean;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Sets scalarMode to DEFAULT
|
|
249
|
+
*/
|
|
250
|
+
setScalarModeToDefault(): boolean;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Sets scalarMode to USE_CELL_DATA
|
|
254
|
+
*/
|
|
255
|
+
setScalarModeToUseCellData(): boolean;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Sets scalarMode to USE_CELL_FIELD_DATA
|
|
259
|
+
*/
|
|
260
|
+
setScalarModeToUseCellFieldData(): boolean;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Sets scalarMode to USE_FIELD_DATA
|
|
264
|
+
*/
|
|
265
|
+
setScalarModeToUseFieldData(): boolean;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Sets scalarMode to USE_POINT_DATA
|
|
269
|
+
*/
|
|
270
|
+
setScalarModeToUsePointData(): boolean;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Sets scalarMode to USE_POINT_FIELD_DATA
|
|
274
|
+
*/
|
|
275
|
+
setScalarModeToUsePointFieldData(): boolean;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Specify range in terms of scalar minimum and maximum (smin,smax). These
|
|
279
|
+
* values are used to map scalars into lookup table. Has no effect when
|
|
280
|
+
* UseLookupTableScalarRange is true.
|
|
281
|
+
*
|
|
282
|
+
* @param min
|
|
283
|
+
* @param max
|
|
284
|
+
* @default [0, 1]
|
|
285
|
+
*/
|
|
286
|
+
setScalarRange(min: number, max: number): boolean;
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Specify range in terms of scalar minimum and maximum (smin,smax). These
|
|
290
|
+
* values are used to map scalars into lookup table. Has no effect when
|
|
291
|
+
* UseLookupTableScalarRange is true.
|
|
292
|
+
*
|
|
293
|
+
* @param scalarRange
|
|
294
|
+
* @default [0, 1]
|
|
295
|
+
*/
|
|
296
|
+
setScalarRange(scalarRange: number[]): boolean;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* @param scalarRange
|
|
301
|
+
* @default [0, 1]
|
|
302
|
+
*/
|
|
303
|
+
setScalarRangeFrom(scalarRange: number[]): boolean;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Turn on/off flag to control whether scalar data is used to color objects.
|
|
307
|
+
* @param {Boolean} scalarVisibility
|
|
308
|
+
* @default true
|
|
309
|
+
*/
|
|
310
|
+
setScalarVisibility(scalarVisibility: boolean): boolean;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Turn on/off flag to control whether the mapper’s data is static. Static data
|
|
314
|
+
* means that the mapper does not propagate updates down the pipeline, greatly
|
|
315
|
+
* decreasing the time it takes to update many mappers. This should only be
|
|
316
|
+
* used if the data never changes.
|
|
317
|
+
*
|
|
318
|
+
* @param {Boolean} static
|
|
319
|
+
* @default false
|
|
320
|
+
*/
|
|
321
|
+
setStatic(static: boolean): boolean;
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Control whether the mapper sets the lookuptable range based on its
|
|
325
|
+
* own ScalarRange, or whether it will use the LookupTable ScalarRange
|
|
326
|
+
* regardless of it’s own setting. By default the Mapper is allowed to set
|
|
327
|
+
* the LookupTable range, but users who are sharing LookupTables between
|
|
328
|
+
* mappers/actors will probably wish to force the mapper to use the
|
|
329
|
+
* LookupTable unchanged.
|
|
330
|
+
*
|
|
331
|
+
* @param {Boolean} useLookupTableScalarRange
|
|
332
|
+
* @default false
|
|
333
|
+
*/
|
|
334
|
+
setUseLookupTableScalarRange(useLookupTableScalarRange: boolean): boolean;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* If you want to provide specific properties for rendering engines you can use
|
|
338
|
+
* viewSpecificProperties.
|
|
339
|
+
*
|
|
340
|
+
* You can go and have a look in the rendering backend of your choice for details
|
|
341
|
+
* on specific properties.
|
|
342
|
+
* For example, for OpenGL/WebGL see OpenGL/PolyDataMapper/api.md
|
|
343
|
+
* If there is no details, viewSpecificProperties is not supported.
|
|
344
|
+
* @param viewSpecificProperties
|
|
345
|
+
*/
|
|
346
|
+
setViewSpecificProperties(viewSpecificProperties: object): boolean;
|
|
347
|
+
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Method used to decorate a given object (publicAPI+model) with vtkMapper2D characteristics.
|
|
352
|
+
*
|
|
353
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
354
|
+
* @param model object on which data structure will be bounds (protected)
|
|
355
|
+
* @param {IMapper2DInitialValues} [initialValues] (default: {})
|
|
356
|
+
*/
|
|
357
|
+
export function extend(publicAPI: object, model: object, initialValues?: IMapper2DInitialValues): void;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Method used to create a new instance of vtkMapper2D
|
|
361
|
+
* @param {IMapper2DInitialValues} [initialValues] for pre-setting some of its content
|
|
362
|
+
*/
|
|
363
|
+
export function newInstance(initialValues?: IMapper2DInitialValues): vtkMapper2D;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* vtkMapper2D is an abstract class to specify interface between data and
|
|
367
|
+
* graphics primitives. Subclasses of vtkMapper map data through a
|
|
368
|
+
* lookuptable and control the creation of rendering primitives that
|
|
369
|
+
* interface to the graphics library. The mapping can be controlled by
|
|
370
|
+
* supplying a lookup table and specifying a scalar range to map data
|
|
371
|
+
* through.
|
|
372
|
+
*
|
|
373
|
+
* There are several important control mechanisms affecting the behavior of
|
|
374
|
+
* this object. The ScalarVisibility flag controls whether scalar data (if
|
|
375
|
+
* any) controls the color of the associated actor(s) that refer to the
|
|
376
|
+
* mapper. The ScalarMode ivar is used to determine whether scalar point data
|
|
377
|
+
* or cell data is used to color the object. By default, point data scalars
|
|
378
|
+
* are used unless there are none, then cell scalars are used. Or you can
|
|
379
|
+
* explicitly control whether to use point or cell scalar data. Finally, the
|
|
380
|
+
* mapping of scalars through the lookup table varies depending on the
|
|
381
|
+
* setting of the ColorMode flag. See the documentation for the appropriate
|
|
382
|
+
* methods for an explanation.
|
|
383
|
+
*
|
|
384
|
+
* Another important feature of this class is whether to use immediate mode
|
|
385
|
+
* rendering (ImmediateModeRenderingOn) or display list rendering
|
|
386
|
+
* (ImmediateModeRenderingOff). If display lists are used, a data structure
|
|
387
|
+
* is constructed (generally in the rendering library) which can then be
|
|
388
|
+
* rapidly traversed and rendered by the rendering library. The disadvantage
|
|
389
|
+
* of display lists is that they require additional memory which may affect
|
|
390
|
+
* the performance of the system.
|
|
391
|
+
*
|
|
392
|
+
* Another important feature of the mapper is the ability to shift the
|
|
393
|
+
* Z-buffer to resolve coincident topology. For example, if you’d like to
|
|
394
|
+
* draw a mesh with some edges a different color, and the edges lie on the
|
|
395
|
+
* mesh, this feature can be useful to get nice looking lines. (See the
|
|
396
|
+
* ResolveCoincidentTopology-related methods.)
|
|
397
|
+
*/
|
|
398
|
+
export declare const vtkMapper2D: {
|
|
399
|
+
newInstance: typeof newInstance;
|
|
400
|
+
extend: typeof extend;
|
|
401
|
+
}
|
|
402
|
+
export default vtkMapper2D;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import macro from '../../macros.js';
|
|
2
|
+
import vtkAbstractMapper from './AbstractMapper.js';
|
|
3
|
+
import vtkLookupTable from '../../Common/Core/LookupTable.js';
|
|
4
|
+
import Constants from './Mapper/Constants.js';
|
|
5
|
+
|
|
6
|
+
var ColorMode = Constants.ColorMode,
|
|
7
|
+
ScalarMode = Constants.ScalarMode,
|
|
8
|
+
GetArray = Constants.GetArray; // ---------------------------------------------------------------------------
|
|
9
|
+
// vtkMapper2D methods
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
function vtkMapper2D(publicAPI, model) {
|
|
13
|
+
// Set out className
|
|
14
|
+
model.classHierarchy.push('vtkMapper2D');
|
|
15
|
+
|
|
16
|
+
publicAPI.createDefaultLookupTable = function () {
|
|
17
|
+
model.lookupTable = vtkLookupTable.newInstance();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
publicAPI.getColorModeAsString = function () {
|
|
21
|
+
return macro.enumToString(ColorMode, model.colorMode);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
publicAPI.setColorModeToDefault = function () {
|
|
25
|
+
return publicAPI.setColorMode(0);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
publicAPI.setColorModeToMapScalars = function () {
|
|
29
|
+
return publicAPI.setColorMode(1);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
publicAPI.setColorModeToDirectScalars = function () {
|
|
33
|
+
return publicAPI.setColorMode(2);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
publicAPI.getScalarModeAsString = function () {
|
|
37
|
+
return macro.enumToString(ScalarMode, model.scalarMode);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
publicAPI.setScalarModeToDefault = function () {
|
|
41
|
+
return publicAPI.setScalarMode(0);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
publicAPI.setScalarModeToUsePointData = function () {
|
|
45
|
+
return publicAPI.setScalarMode(1);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
publicAPI.setScalarModeToUseCellData = function () {
|
|
49
|
+
return publicAPI.setScalarMode(2);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
publicAPI.setScalarModeToUsePointFieldData = function () {
|
|
53
|
+
return publicAPI.setScalarMode(3);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
publicAPI.setScalarModeToUseCellFieldData = function () {
|
|
57
|
+
return publicAPI.setScalarMode(4);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
publicAPI.setScalarModeToUseFieldData = function () {
|
|
61
|
+
return publicAPI.setScalarMode(5);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
publicAPI.getAbstractScalars = function (input, scalarMode, arrayAccessMode, arrayId, arrayName) {
|
|
65
|
+
// make sure we have an input
|
|
66
|
+
if (!input || !model.scalarVisibility) {
|
|
67
|
+
return {
|
|
68
|
+
scalars: null,
|
|
69
|
+
cellFLag: false
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var scalars = null;
|
|
74
|
+
var cellFlag = false; // get scalar data and point/cell attribute according to scalar mode
|
|
75
|
+
|
|
76
|
+
if (scalarMode === ScalarMode.DEFAULT) {
|
|
77
|
+
scalars = input.getPointData().getScalars();
|
|
78
|
+
|
|
79
|
+
if (!scalars) {
|
|
80
|
+
scalars = input.getCellData().getScalars();
|
|
81
|
+
cellFlag = true;
|
|
82
|
+
}
|
|
83
|
+
} else if (scalarMode === ScalarMode.USE_POINT_DATA) {
|
|
84
|
+
scalars = input.getPointData().getScalars();
|
|
85
|
+
} else if (scalarMode === ScalarMode.USE_CELL_DATA) {
|
|
86
|
+
scalars = input.getCellData().getScalars();
|
|
87
|
+
cellFlag = true;
|
|
88
|
+
} else if (scalarMode === ScalarMode.USE_POINT_FIELD_DATA) {
|
|
89
|
+
var pd = input.getPointData();
|
|
90
|
+
|
|
91
|
+
if (arrayAccessMode === GetArray.BY_ID) {
|
|
92
|
+
scalars = pd.getArrayByIndex(arrayId);
|
|
93
|
+
} else {
|
|
94
|
+
scalars = pd.getArrayByName(arrayName);
|
|
95
|
+
}
|
|
96
|
+
} else if (scalarMode === ScalarMode.USE_CELL_FIELD_DATA) {
|
|
97
|
+
var cd = input.getCellData();
|
|
98
|
+
cellFlag = true;
|
|
99
|
+
|
|
100
|
+
if (arrayAccessMode === GetArray.BY_ID) {
|
|
101
|
+
scalars = cd.getArrayByIndex(arrayId);
|
|
102
|
+
} else {
|
|
103
|
+
scalars = cd.getArrayByName(arrayName);
|
|
104
|
+
}
|
|
105
|
+
} else if (scalarMode === ScalarMode.USE_FIELD_DATA) {
|
|
106
|
+
var fd = input.getFieldData();
|
|
107
|
+
|
|
108
|
+
if (arrayAccessMode === GetArray.BY_ID) {
|
|
109
|
+
scalars = fd.getArrayByIndex(arrayId);
|
|
110
|
+
} else {
|
|
111
|
+
scalars = fd.getArrayByName(arrayName);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
scalars: scalars,
|
|
117
|
+
cellFlag: cellFlag
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
publicAPI.getLookupTable = function () {
|
|
122
|
+
if (!model.lookupTable) {
|
|
123
|
+
publicAPI.createDefaultLookupTable();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return model.lookupTable;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
publicAPI.getMTime = function () {
|
|
130
|
+
var mt = model.mtime;
|
|
131
|
+
|
|
132
|
+
if (model.lookupTable !== null) {
|
|
133
|
+
var time = model.lookupTable.getMTime();
|
|
134
|
+
mt = time > mt ? time : mt;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return mt;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
publicAPI.mapScalars = function (input, alpha) {
|
|
141
|
+
var scalars = publicAPI.getAbstractScalars(input, model.scalarMode, model.arrayAccessMode, model.arrayId, model.colorByArrayName).scalars;
|
|
142
|
+
|
|
143
|
+
if (!scalars) {
|
|
144
|
+
model.colorMapColors = null;
|
|
145
|
+
return;
|
|
146
|
+
} // we want to only recompute when something has changed
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
var toString = "".concat(publicAPI.getMTime()).concat(scalars.getMTime()).concat(alpha);
|
|
150
|
+
if (model.colorBuildString === toString) return;
|
|
151
|
+
|
|
152
|
+
if (!model.useLookupTableScalarRange) {
|
|
153
|
+
publicAPI.getLookupTable().setRange(model.scalarRange[0], model.scalarRange[1]);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
var lut = publicAPI.getLookupTable();
|
|
157
|
+
|
|
158
|
+
if (lut) {
|
|
159
|
+
// Ensure that the lookup table is built
|
|
160
|
+
lut.build();
|
|
161
|
+
model.colorMapColors = lut.mapScalars(scalars, model.colorMode, -1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
model.colorBuildString = "".concat(publicAPI.getMTime()).concat(scalars.getMTime()).concat(alpha);
|
|
165
|
+
};
|
|
166
|
+
} // ----------------------------------------------------------------------------
|
|
167
|
+
// Object factory
|
|
168
|
+
// ----------------------------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
var DEFAULT_VALUES = {
|
|
172
|
+
static: false,
|
|
173
|
+
lookupTable: null,
|
|
174
|
+
scalarVisibility: false,
|
|
175
|
+
scalarRange: [0, 1],
|
|
176
|
+
useLookupTableScalarRange: false,
|
|
177
|
+
colorMode: 0,
|
|
178
|
+
scalarMode: 0,
|
|
179
|
+
arrayAccessMode: 1,
|
|
180
|
+
// By_NAME
|
|
181
|
+
renderTime: 0,
|
|
182
|
+
colorByArrayName: null,
|
|
183
|
+
transformCoordinate: null,
|
|
184
|
+
viewSpecificProperties: null,
|
|
185
|
+
customShaderAttributes: []
|
|
186
|
+
}; // ----------------------------------------------------------------------------
|
|
187
|
+
|
|
188
|
+
function extend(publicAPI, model) {
|
|
189
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
190
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
191
|
+
|
|
192
|
+
vtkAbstractMapper.extend(publicAPI, model, initialValues);
|
|
193
|
+
macro.get(publicAPI, model, ['colorMapColors']);
|
|
194
|
+
macro.setGet(publicAPI, model, ['arrayAccessMode', 'colorByArrayName', 'colorMode', 'lookupTable', 'renderTime', 'scalarMode', 'scalarVisibility', 'static', 'transformCoordinate', 'useLookupTableScalarRange', 'viewSpecificProperties', 'customShaderAttributes' // point data array names that will be transferred to the VBO
|
|
195
|
+
]);
|
|
196
|
+
macro.setGetArray(publicAPI, model, ['scalarRange'], 2);
|
|
197
|
+
|
|
198
|
+
if (!model.viewSpecificProperties) {
|
|
199
|
+
model.viewSpecificProperties = {};
|
|
200
|
+
} // Object methods
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
vtkMapper2D(publicAPI, model);
|
|
204
|
+
} // ----------------------------------------------------------------------------
|
|
205
|
+
|
|
206
|
+
var newInstance = macro.newInstance(extend, 'vtkMapper2D'); // ----------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
var vtkMapper2D$1 = {
|
|
209
|
+
newInstance: newInstance,
|
|
210
|
+
extend: extend
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export { vtkMapper2D$1 as default, extend, newInstance };
|