@@ -1897,19 +1897,31 @@ export const ProteinViewer = forwardRef<ProteinViewerRef, ProteinViewerProps>(({
18971897 this . parameters = params ;
18981898
18991899 // Instantiate the base scheme (fallback)
1900- // We must handle 'standard' or other aliases if necessary, but usually NGL names match
1901- // If currentColoring is not a registered scheme, fallback to 'uniform' (white)
1902- const BaseSchemeClass = window . NGL . ColormakerRegistry . getScheme ( baseColoringForScheme ) ;
1900+ // Map our internal color names to NGL's scheme names
1901+ let nglSchemeName : any = baseColoringForScheme ;
1902+ if ( baseColoringForScheme === 'chainid' ) {
1903+ nglSchemeName = 'chainname' ;
1904+ } else if ( baseColoringForScheme === 'structure' || baseColoringForScheme === 'secondary' ) {
1905+ nglSchemeName = 'sstruc' ;
1906+ }
1907+
1908+ const BaseSchemeClass = window . NGL . ColormakerRegistry . getScheme ( nglSchemeName ) ;
19031909 this . baseScheme = BaseSchemeClass ? new BaseSchemeClass ( params ) : null ;
19041910
19051911 this . atomColor = function ( atom : any ) {
19061912 const custom = atomColorMap . get ( atom . index ) ;
19071913 if ( custom !== undefined ) return custom ;
19081914
1909- if ( this . baseScheme ) {
1915+ if ( this . baseScheme && this . baseScheme . atomColor ) {
19101916 return this . baseScheme . atomColor ( atom ) ;
19111917 }
1912- return 0xFFFFFF ; // Fallback white
1918+ // Better fallback: use element coloring instead of white
1919+ const ElementScheme = window . NGL . ColormakerRegistry . getScheme ( 'element' ) ;
1920+ if ( ElementScheme ) {
1921+ const fallbackScheme = new ElementScheme ( params ) ;
1922+ return fallbackScheme . atomColor ( atom ) ;
1923+ }
1924+ return 0xCCCCCC ; // Light gray as last resort
19131925 } ;
19141926 } , schemeId ) ;
19151927
0 commit comments