@kitware/vtk.js 34.15.1 → 34.15.2
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/Rendering/Core/Viewport.js +13 -9
- package/Rendering/OpenGL/HardwareSelector.js +2 -2
- package/Rendering/OpenGL/ImageCPRMapper.js +1 -1
- package/Rendering/OpenGL/ImageMapper.js +1 -1
- package/Rendering/OpenGL/ImageResliceMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/Skybox.js +1 -1
- package/Rendering/OpenGL/VolumeMapper.js +1 -1
- package/Rendering/SceneGraph/ViewNode.d.ts +2 -1
- package/Rendering/SceneGraph/ViewNode.js +33 -8
- package/Rendering/WebGPU/Renderer.js +1 -1
- package/package.json +1 -1
|
@@ -47,19 +47,23 @@ function vtkViewport(publicAPI, model) {
|
|
|
47
47
|
}
|
|
48
48
|
publicAPI.getViewPropsWithNestedProps = () => {
|
|
49
49
|
let allPropsArray = [];
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
// Repopulate the actor2D list to minimize browsing operations.
|
|
51
|
+
model.actors2D = [];
|
|
52
|
+
for (let i = 0; i < model.props.length; i++) {
|
|
53
|
+
// Handle actor2D instances separately so that they can be overlayed and layered
|
|
54
|
+
const isActor2D = model.props[i].getActors2D();
|
|
55
|
+
if (isActor2D && (!Array.isArray(isActor2D) || isActor2D.length > 0)) {
|
|
56
|
+
model.actors2D = model.actors2D.concat(isActor2D);
|
|
57
|
+
} else {
|
|
58
|
+
gatherProps(model.props[i], allPropsArray);
|
|
59
|
+
}
|
|
58
60
|
}
|
|
61
|
+
// Actor2D must be rendered by layer number order
|
|
62
|
+
model.actors2D.sort((a, b) => a.getLayerNumber() - b.getLayerNumber());
|
|
59
63
|
// Finally, add the actor2D props at the end of the list
|
|
60
64
|
// This works because, when traversing the render pass in vtkOpenGLRenderer, the children are
|
|
61
65
|
// traversed in the order that they are added to the list
|
|
62
|
-
allPropsArray = allPropsArray.concat(actors2D);
|
|
66
|
+
allPropsArray = allPropsArray.concat(model.actors2D);
|
|
63
67
|
return allPropsArray;
|
|
64
68
|
};
|
|
65
69
|
publicAPI.addActor2D = publicAPI.addViewProp;
|
|
@@ -231,7 +231,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
231
231
|
|
|
232
232
|
//----------------------------------------------------------------------------
|
|
233
233
|
publicAPI.beginSelection = () => {
|
|
234
|
-
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model._renderer);
|
|
234
|
+
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model._renderer, model._openGLRenderer);
|
|
235
235
|
model.maxAttributeId = 0;
|
|
236
236
|
const size = model._openGLRenderWindow.getSize();
|
|
237
237
|
if (!model.framebuffer) {
|
|
@@ -339,7 +339,7 @@ function vtkOpenGLHardwareSelector(publicAPI, model) {
|
|
|
339
339
|
vtkErrorMacro('Renderer and view must be set before calling Select.');
|
|
340
340
|
return false;
|
|
341
341
|
}
|
|
342
|
-
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model._renderer);
|
|
342
|
+
model._openGLRenderer = model._openGLRenderWindow.getViewNodeFor(model._renderer, model._openGLRenderer);
|
|
343
343
|
|
|
344
344
|
// todo revisit making selection part of core
|
|
345
345
|
// then we can do this in core
|
|
@@ -43,7 +43,7 @@ function vtkOpenGLImageCPRMapper(publicAPI, model) {
|
|
|
43
43
|
unregisterGraphicsResources(oldOglRenderWindow);
|
|
44
44
|
}
|
|
45
45
|
model.context = model._openGLRenderWindow.getContext();
|
|
46
|
-
model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera());
|
|
46
|
+
model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera(), model.openGLCamera);
|
|
47
47
|
model.tris.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
48
48
|
}
|
|
49
49
|
};
|
|
@@ -70,7 +70,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
|
|
|
70
70
|
model.context = model._openGLRenderWindow.getContext();
|
|
71
71
|
model.tris.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
72
72
|
const ren = model._openGLRenderer.getRenderable();
|
|
73
|
-
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera());
|
|
73
|
+
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera(), model.openGLCamera);
|
|
74
74
|
// is slice set by the camera
|
|
75
75
|
if (model.renderable.isA('vtkImageMapper') && model.renderable.getSliceAtFocalPoint()) {
|
|
76
76
|
model.renderable.setSliceFromCamera(ren.getActiveCamera());
|
|
@@ -93,7 +93,7 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) {
|
|
|
93
93
|
model._openGLImageSlice = publicAPI.getFirstAncestorOfType('vtkOpenGLImageSlice');
|
|
94
94
|
model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
95
95
|
const ren = model._openGLRenderer.getRenderable();
|
|
96
|
-
model._openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera());
|
|
96
|
+
model._openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera(), model.openGLCamera);
|
|
97
97
|
const oldOglRenderWindow = model._openGLRenderWindow;
|
|
98
98
|
model._openGLRenderWindow = model._openGLRenderer.getLastAncestorOfType('vtkOpenGLRenderWindow');
|
|
99
99
|
if (oldOglRenderWindow && !oldOglRenderWindow.isDeleted() && oldOglRenderWindow !== model._openGLRenderWindow) {
|
|
@@ -70,7 +70,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
|
|
|
70
70
|
model.openGLActor = publicAPI.getFirstAncestorOfType('vtkOpenGLActor');
|
|
71
71
|
model._openGLRenderer = model.openGLActor.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
72
72
|
model._openGLRenderWindow = model._openGLRenderer.getLastAncestorOfType('vtkOpenGLRenderWindow');
|
|
73
|
-
model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera());
|
|
73
|
+
model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera(), model.openGLCamera);
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
|
|
@@ -42,7 +42,7 @@ function vtkOpenGLPolyDataMapper2D(publicAPI, model) {
|
|
|
42
42
|
model.openGLActor2D = publicAPI.getFirstAncestorOfType('vtkOpenGLActor2D');
|
|
43
43
|
model._openGLRenderer = model.openGLActor2D.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
44
44
|
model._openGLRenderWindow = model._openGLRenderer.getLastAncestorOfType('vtkOpenGLRenderWindow');
|
|
45
|
-
model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera());
|
|
45
|
+
model.openGLCamera = model._openGLRenderer.getViewNodeFor(model._openGLRenderer.getRenderable().getActiveCamera(), model.openGLCamera);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
publicAPI.overlayPass = prepass => {
|
|
@@ -28,7 +28,7 @@ function vtkOpenGLSkybox(publicAPI, model) {
|
|
|
28
28
|
model.tris.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
29
29
|
model.openGLTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
|
|
30
30
|
const ren = model._openGLRenderer.getRenderable();
|
|
31
|
-
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera());
|
|
31
|
+
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera(), model.openGLCamera);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
publicAPI.queryPass = (prepass, renderPass) => {
|
|
@@ -124,7 +124,7 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
|
|
|
124
124
|
const actor = model.openGLVolume.getRenderable();
|
|
125
125
|
model._openGLRenderer = publicAPI.getFirstAncestorOfType('vtkOpenGLRenderer');
|
|
126
126
|
const ren = model._openGLRenderer.getRenderable();
|
|
127
|
-
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera());
|
|
127
|
+
model.openGLCamera = model._openGLRenderer.getViewNodeFor(ren.getActiveCamera(), model.openGLCamera);
|
|
128
128
|
publicAPI.renderPiece(ren, actor);
|
|
129
129
|
}
|
|
130
130
|
};
|
|
@@ -100,8 +100,9 @@ export interface vtkViewNode extends vtkObject {
|
|
|
100
100
|
* Returns the view node that corresponding to the provided object
|
|
101
101
|
* Will return NULL if a match is not found in self or descendents
|
|
102
102
|
* @param dataObject
|
|
103
|
+
* @param [hint] the previously found node (for optimization)
|
|
103
104
|
*/
|
|
104
|
-
getViewNodeFor(dataObject: any): any;
|
|
105
|
+
getViewNodeFor(dataObject: any, hint?: any): any;
|
|
105
106
|
|
|
106
107
|
/**
|
|
107
108
|
*
|
|
@@ -13,6 +13,25 @@ function vtkViewNode(publicAPI, model) {
|
|
|
13
13
|
// Set our className
|
|
14
14
|
model.classHierarchy.push('vtkViewNode');
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Convenient method to move a child to a specific index.
|
|
18
|
+
* @param {*} child the child to move
|
|
19
|
+
* @param {*} toIndex the index to move the child to
|
|
20
|
+
* @returns true if the child was moved, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
function moveChild(child, toIndex) {
|
|
23
|
+
for (let i = 0; i < model.children.length; ++i) {
|
|
24
|
+
// Start browsing from toIndex + 1
|
|
25
|
+
const childIndex = (toIndex + 1 + i) % model.children.length;
|
|
26
|
+
if (model.children[childIndex] === child) {
|
|
27
|
+
model.children[childIndex] = model.children[toIndex];
|
|
28
|
+
model.children[toIndex] = child;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
16
35
|
// Builds myself.
|
|
17
36
|
publicAPI.build = prepass => {};
|
|
18
37
|
|
|
@@ -41,7 +60,11 @@ function vtkViewNode(publicAPI, model) {
|
|
|
41
60
|
customRenderPass(prepass, renderPass);
|
|
42
61
|
}
|
|
43
62
|
};
|
|
44
|
-
publicAPI.getViewNodeFor = dataObject
|
|
63
|
+
publicAPI.getViewNodeFor = function (dataObject) {
|
|
64
|
+
let hint = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
65
|
+
if (hint && hint.renderable === dataObject) {
|
|
66
|
+
return hint;
|
|
67
|
+
}
|
|
45
68
|
if (model.renderable === dataObject) {
|
|
46
69
|
return publicAPI;
|
|
47
70
|
}
|
|
@@ -110,17 +133,19 @@ function vtkViewNode(publicAPI, model) {
|
|
|
110
133
|
if (!dataObjs || !dataObjs.length) {
|
|
111
134
|
return;
|
|
112
135
|
}
|
|
136
|
+
let nextIndex;
|
|
113
137
|
for (let index = 0; index < dataObjs.length; ++index) {
|
|
114
138
|
const dobj = dataObjs[index];
|
|
115
139
|
const node = publicAPI.addMissingNode(dobj);
|
|
116
|
-
if (enforceOrder && node !== undefined
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
140
|
+
if (enforceOrder && node !== undefined) {
|
|
141
|
+
if (nextIndex === undefined) {
|
|
142
|
+
// First node can be anywhere
|
|
143
|
+
nextIndex = model.children.lastIndexOf(node); // node is likely the list child
|
|
144
|
+
} else if (model.children[nextIndex] !== node) {
|
|
145
|
+
moveChild(model.children, node);
|
|
123
146
|
}
|
|
147
|
+
// Next node must follow current node
|
|
148
|
+
nextIndex++;
|
|
124
149
|
}
|
|
125
150
|
}
|
|
126
151
|
};
|
|
@@ -122,7 +122,7 @@ function vtkWebGPURenderer(publicAPI, model) {
|
|
|
122
122
|
publicAPI.addMissingNode(model.camera);
|
|
123
123
|
publicAPI.addMissingNodes(model.renderable.getViewPropsWithNestedProps());
|
|
124
124
|
publicAPI.removeUnusedNodes();
|
|
125
|
-
model.webgpuCamera = publicAPI.getViewNodeFor(model.camera);
|
|
125
|
+
model.webgpuCamera = publicAPI.getViewNodeFor(model.camera, model.webgpuCamera);
|
|
126
126
|
publicAPI.updateStabilizedMatrix();
|
|
127
127
|
}
|
|
128
128
|
};
|