@kitware/vtk.js 34.15.1 → 34.15.3
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/CONTRIBUTING.md +12 -5
- package/IO/Geometry/IFCImporter.js +29 -35
- 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
package/CONTRIBUTING.md
CHANGED
|
@@ -33,7 +33,7 @@ Please follow the coding style:
|
|
|
33
33
|
$ git checkout -b new_feature
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
6. Start hacking. Additional information on how to create class/test/example can be found
|
|
37
37
|
[here](https://kitware.github.io/vtk-js/docs/) in the __Development__ section.
|
|
38
38
|
|
|
39
39
|
```sh
|
|
@@ -41,19 +41,26 @@ Please follow the coding style:
|
|
|
41
41
|
$ git add file1 file2 file3
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
7. Verify you have correctly formatted code, and that all tests pass:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
$ npm run reformat
|
|
48
|
+
$ npm run test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
8. Use Commitizen to create commits
|
|
45
52
|
|
|
46
53
|
```sh
|
|
47
54
|
$ npm run commit
|
|
48
55
|
```
|
|
49
56
|
|
|
50
|
-
|
|
57
|
+
9. Push commits in your feature branch to your fork in GitHub:
|
|
51
58
|
|
|
52
59
|
```sh
|
|
53
60
|
$ git push origin new_feature
|
|
54
61
|
```
|
|
55
62
|
|
|
56
|
-
|
|
63
|
+
10. Visit your fork in Github, browse to the "**Pull Requests**" link on the left, and use the
|
|
57
64
|
"**New Pull Request**" button in the upper right to create a Pull Request.
|
|
58
65
|
|
|
59
66
|
For more information see:
|
|
@@ -62,7 +69,7 @@ Please follow the coding style:
|
|
|
62
69
|
If committing changes to `vtk.js@next` or `vtk.js@next-major`, then set your base branch to be `next`
|
|
63
70
|
or `next-major`, respectively. For more info see the section on release channels below.
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
11. vtk.js uses GitHub for code review and Github Actions to validate proposed patches before they are merged.
|
|
66
73
|
|
|
67
74
|
## Release Channels
|
|
68
75
|
|
|
@@ -40,13 +40,13 @@ function vtkIFCImporter(publicAPI, model) {
|
|
|
40
40
|
const cells = vtkCellArray.newInstance();
|
|
41
41
|
const pointValues = new Float32Array(vertices.length / 2);
|
|
42
42
|
const normalsArray = new Float32Array(vertices.length / 2);
|
|
43
|
-
for (let i = 0; i < vertices.length;
|
|
44
|
-
pointValues[
|
|
45
|
-
pointValues[
|
|
46
|
-
pointValues[
|
|
47
|
-
normalsArray[
|
|
48
|
-
normalsArray[
|
|
49
|
-
normalsArray[
|
|
43
|
+
for (let i = 0, p = 0; i < vertices.length; p += 3) {
|
|
44
|
+
pointValues[p] = vertices[i++];
|
|
45
|
+
pointValues[p + 1] = vertices[i++];
|
|
46
|
+
pointValues[p + 2] = vertices[i++];
|
|
47
|
+
normalsArray[p] = vertices[i++];
|
|
48
|
+
normalsArray[p + 1] = vertices[i++];
|
|
49
|
+
normalsArray[p + 2] = vertices[i++];
|
|
50
50
|
}
|
|
51
51
|
const nCells = indices.length;
|
|
52
52
|
cells.resize(3 * nCells / 3);
|
|
@@ -82,36 +82,30 @@ function vtkIFCImporter(publicAPI, model) {
|
|
|
82
82
|
const normalsArray = new Float32Array(vertices.length / 2);
|
|
83
83
|
const colorArray = new Float32Array(vertices.length / 2);
|
|
84
84
|
if (userMatrix) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
normalsArray[i / 2] = normal[0];
|
|
96
|
-
normalsArray[i / 2 + 1] = normal[1];
|
|
97
|
-
normalsArray[i / 2 + 2] = normal[2];
|
|
98
|
-
const colorIndex = i / 2;
|
|
99
|
-
colorArray[colorIndex] = color.x;
|
|
100
|
-
colorArray[colorIndex + 1] = color.y;
|
|
101
|
-
colorArray[colorIndex + 2] = color.z;
|
|
85
|
+
for (let i = 0, p = 0; i < vertices.length; p += 3) {
|
|
86
|
+
pointValues[p] = vertices[i++];
|
|
87
|
+
pointValues[p + 1] = vertices[i++];
|
|
88
|
+
pointValues[p + 2] = vertices[i++];
|
|
89
|
+
normalsArray[p] = vertices[i++];
|
|
90
|
+
normalsArray[p + 1] = vertices[i++];
|
|
91
|
+
normalsArray[p + 2] = vertices[i++];
|
|
92
|
+
colorArray[p] = color.x;
|
|
93
|
+
colorArray[p + 1] = color.y;
|
|
94
|
+
colorArray[p + 2] = color.z;
|
|
102
95
|
}
|
|
96
|
+
vtkMatrixBuilder.buildFromRadian().setMatrix(userMatrix).apply(pointValues);
|
|
97
|
+
vtkMatrixBuilder.buildFromRadian().multiply3x3(mat3.fromMat4(mat3.create(), userMatrix)).apply(normalsArray);
|
|
103
98
|
} else {
|
|
104
|
-
for (let i = 0; i < vertices.length;
|
|
105
|
-
pointValues[
|
|
106
|
-
pointValues[
|
|
107
|
-
pointValues[
|
|
108
|
-
normalsArray[
|
|
109
|
-
normalsArray[
|
|
110
|
-
normalsArray[
|
|
111
|
-
|
|
112
|
-
colorArray[
|
|
113
|
-
colorArray[
|
|
114
|
-
colorArray[colorIndex + 2] = color.z;
|
|
99
|
+
for (let i = 0, p = 0; i < vertices.length; p += 3) {
|
|
100
|
+
pointValues[p] = vertices[i++];
|
|
101
|
+
pointValues[p + 1] = vertices[i++];
|
|
102
|
+
pointValues[p + 2] = vertices[i++];
|
|
103
|
+
normalsArray[p] = vertices[i++];
|
|
104
|
+
normalsArray[p + 1] = vertices[i++];
|
|
105
|
+
normalsArray[p + 2] = vertices[i++];
|
|
106
|
+
colorArray[p] = color.x;
|
|
107
|
+
colorArray[p + 1] = color.y;
|
|
108
|
+
colorArray[p + 2] = color.z;
|
|
115
109
|
}
|
|
116
110
|
}
|
|
117
111
|
const nCells = indices.length;
|
|
@@ -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
|
};
|