Skip to content

Commit fbe19e9

Browse files
committed
feat(Rendering): report missing view node profile imports
fixes #3343
1 parent 9d00695 commit fbe19e9

File tree

3 files changed

+81
-2
lines changed

3 files changed

+81
-2
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
title: Rendering Profiles
3+
---
4+
5+
# Rendering Profiles
6+
7+
VTK.js rendering profiles are side-effect imports that register rendering implementations for classes used by the scene graph. They keep applications smaller by letting you import only the rendering backends and mapper support you need.
8+
9+
## Why profiles exist
10+
11+
Many VTK.js classes are pure pipeline or data-model classes. They only become renderable after a matching rendering profile registers the view-node overrides required by the active backend such as OpenGL or WebGPU.
12+
13+
Without the relevant profile import, VTK.js can still construct the data objects, actors, mappers, and pipeline, but rendering may fail when the scene graph asks `ViewNodeFactory` to create a backend-specific implementation for one of those classes.
14+
15+
## Typical usage
16+
17+
Import a profile near your application entry point before creating the render window content:
18+
19+
```js
20+
import '@kitware/vtk.js/Rendering/Profiles/Geometry';
21+
```
22+
23+
If you need broader coverage, import the combined profile:
24+
25+
```js
26+
import '@kitware/vtk.js/Rendering/Profiles/All';
27+
```
28+
29+
## Common profiles
30+
31+
- `Geometry`: core polygonal rendering support.
32+
- `Volume`: image and volume rendering support.
33+
- `Glyph`: glyph-specific mapper support.
34+
- `Molecule`: sphere and stick mapper support.
35+
- `LIC`: line integral convolution rendering support.
36+
- `All`: imports all supported profiles.
37+
38+
## When a profile is missing
39+
40+
A missing profile often shows up as a warning from `Rendering/SceneGraph/ViewNodeFactory` saying that no implementation was found for a class and that a rendering profile is likely missing.
41+
42+
That warning means one of these is true:
43+
44+
- A built-in renderable class is being used without importing the profile that registers its rendering implementation.
45+
- A custom renderable class has not been registered with the view-node factory.
46+
47+
If you are unsure which profile is required, importing `Rendering/Profiles/All` is the easiest way to confirm that the issue is profile-related. After that, you can narrow it back down to the smallest profile set your application needs.

Documentation/scripts/generate-sidebar-config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ const docsMenu = [
3636
},
3737
{
3838
text: 'Concepts',
39-
items: [{ text: 'Widgets', link: 'concepts_widgets.html' }],
39+
items: [
40+
{ text: 'Widgets', link: 'concepts_widgets.html' },
41+
{ text: 'Profiles', link: 'concepts_profile.html' },
42+
],
4043
},
4144
{
4245
text: 'Miscellaneous',

Sources/Rendering/SceneGraph/ViewNodeFactory/index.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
import macro from 'vtk.js/Sources/macros';
22

3+
const { vtkWarningMacro } = macro;
4+
5+
function listClassHierarchy(dataObject) {
6+
const classNames = [];
7+
let depth = 0;
8+
let className = dataObject.getClassName(depth++);
9+
while (className) {
10+
classNames.push(className);
11+
className = dataObject.getClassName(depth++);
12+
}
13+
return classNames;
14+
}
15+
16+
function buildMissingImplementationMessage(factoryName, classNames) {
17+
const classList = classNames.join(' → ');
18+
return [
19+
`No ${factoryName} implementation found for ${classNames[0]}.`,
20+
`Class hierarchy: ${classList}.`,
21+
`A rendering Profile is likely missing for ${classNames[0]}.`,
22+
"Try importing '@kitware/vtk.js/Rendering/Profiles/All' or 'vtk.js/Sources/Rendering/Profiles/All',",
23+
'or import the specific rendering profile needed by this renderable if known.',
24+
'See https://kitware.github.io/vtk-js/docs/concepts_profile.html for details.',
25+
].join('\n');
26+
}
27+
328
// ----------------------------------------------------------------------------
429
// vtkViewNodeFactory methods
530
// ----------------------------------------------------------------------------
@@ -18,8 +43,9 @@ function vtkViewNodeFactory(publicAPI, model) {
1843
return null;
1944
}
2045

46+
const classNames = listClassHierarchy(dataObject);
2147
let cpt = 0;
22-
let className = dataObject.getClassName(cpt++);
48+
let className = classNames[cpt++];
2349
let isObject = false;
2450
const keys = Object.keys(model.overrides);
2551
while (className && !isObject) {
@@ -31,6 +57,9 @@ function vtkViewNodeFactory(publicAPI, model) {
3157
}
3258

3359
if (!isObject) {
60+
vtkWarningMacro(
61+
buildMissingImplementationMessage(publicAPI.getClassName(), classNames)
62+
);
3463
return null;
3564
}
3665
const vn = model.overrides[className]();

0 commit comments

Comments
 (0)