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 =
23+ suggestedClass && getProfileForClass ( suggestedClass ) ;
24+
25+ if ( suggestedProfile ) {
26+ return [
27+ `No ${ factoryName } implementation found for ${ classNames [ 0 ] } .` ,
28+ `Class hierarchy: ${ classList } .` ,
29+ 'This usually means the rendering profile import is missing.' ,
30+ `Try importing '@kitware/vtk.js/Rendering/Profiles/${ suggestedProfile } ' or 'vtk.js/Sources/Rendering/Profiles/${ suggestedProfile } '.` ,
31+ "You can also use the full profile imports '@kitware/vtk.js/Rendering/Profiles/All' or 'vtk.js/Sources/Rendering/Profiles/All'." ,
32+ ] . join ( '\n' ) ;
33+ }
34+
35+ return [
36+ `No ${ factoryName } implementation found for ${ classNames [ 0 ] } .` ,
37+ `Class hierarchy: ${ classList } .` ,
38+ 'If this is a built-in renderable, a rendering profile import may be missing.' ,
39+ "Try importing '@kitware/vtk.js/Rendering/Profiles/All' or 'vtk.js/Sources/Rendering/Profiles/All'," ,
40+ 'or import the specific rendering profile needed by this renderable.' ,
41+ 'If this is a custom renderable, register a matching override with the view node factory.' ,
42+ ] . join ( '\n' ) ;
43+ }
244
345// ----------------------------------------------------------------------------
446// vtkViewNodeFactory methods
@@ -18,8 +60,9 @@ function vtkViewNodeFactory(publicAPI, model) {
1860 return null ;
1961 }
2062
63+ const classNames = listClassHierarchy ( dataObject ) ;
2164 let cpt = 0 ;
22- let className = dataObject . getClassName ( cpt ++ ) ;
65+ let className = classNames [ cpt ++ ] ;
2366 let isObject = false ;
2467 const keys = Object . keys ( model . overrides ) ;
2568 while ( className && ! isObject ) {
@@ -31,6 +74,9 @@ function vtkViewNodeFactory(publicAPI, model) {
3174 }
3275
3376 if ( ! isObject ) {
77+ vtkOnceErrorMacro (
78+ buildMissingImplementationMessage ( publicAPI . getClassName ( ) , classNames )
79+ ) ;
3480 return null ;
3581 }
3682 const vn = model . overrides [ className ] ( ) ;
0 commit comments