11import macro from 'vtk.js/Sources/macros' ;
2+ import { getProfileForClass , getSuggestedProfile } from './profileHints' ;
3+ import 'vtk.js/Sources/Rendering/OpenGL/Profiles/profileHintManifest' ;
4+ import 'vtk.js/Sources/Rendering/WebGPU/Profiles/profileHintManifest' ;
5+
6+ const { vtkOnceErrorMacro } = macro ;
7+
8+ function listClassHierarchy ( dataObject ) {
9+ const classNames = [ ] ;
10+ let depth = 0 ;
11+ let className = dataObject . getClassName ( depth ++ ) ;
12+ while ( className ) {
13+ classNames . push ( className ) ;
14+ className = dataObject . getClassName ( depth ++ ) ;
15+ }
16+ return classNames ;
17+ }
18+
19+ function buildMissingImplementationMessage ( factoryName , classNames ) {
20+ const classList = classNames . join ( ' → ' ) ;
21+ const suggestedClass = getSuggestedProfile ( classNames ) ;
22+ const suggestedProfile = suggestedClass && getProfileForClass ( suggestedClass ) ;
23+
24+ if ( suggestedProfile ) {
25+ return [
26+ `No ${ factoryName } implementation found for ${ classNames [ 0 ] } .` ,
27+ `Class hierarchy: ${ classList } .` ,
28+ 'This usually means the rendering profile import is missing.' ,
29+ `Try importing '@kitware/vtk.js/Rendering/Profiles/${ suggestedProfile } ' or 'vtk.js/Sources/Rendering/Profiles/${ suggestedProfile } '.` ,
30+ "You can also use the full profile imports '@kitware/vtk.js/Rendering/Profiles/All' or 'vtk.js/Sources/Rendering/Profiles/All'." ,
31+ ] . join ( '\n' ) ;
32+ }
33+
34+ return [
35+ `No ${ factoryName } implementation found for ${ classNames [ 0 ] } .` ,
36+ `Class hierarchy: ${ classList } .` ,
37+ 'If this is a built-in renderable, a rendering profile import may be missing.' ,
38+ "Try importing '@kitware/vtk.js/Rendering/Profiles/All' or 'vtk.js/Sources/Rendering/Profiles/All'," ,
39+ 'or import the specific rendering profile needed by this renderable.' ,
40+ 'If this is a custom renderable, register a matching override with the view node factory.' ,
41+ ] . join ( '\n' ) ;
42+ }
243
344// ----------------------------------------------------------------------------
445// vtkViewNodeFactory methods
@@ -18,8 +59,9 @@ function vtkViewNodeFactory(publicAPI, model) {
1859 return null ;
1960 }
2061
62+ const classNames = listClassHierarchy ( dataObject ) ;
2163 let cpt = 0 ;
22- let className = dataObject . getClassName ( cpt ++ ) ;
64+ let className = classNames [ cpt ++ ] ;
2365 let isObject = false ;
2466 const keys = Object . keys ( model . overrides ) ;
2567 while ( className && ! isObject ) {
@@ -31,6 +73,9 @@ function vtkViewNodeFactory(publicAPI, model) {
3173 }
3274
3375 if ( ! isObject ) {
76+ vtkOnceErrorMacro (
77+ buildMissingImplementationMessage ( publicAPI . getClassName ( ) , classNames )
78+ ) ;
3479 return null ;
3580 }
3681 const vn = model . overrides [ className ] ( ) ;
0 commit comments