Browse Source

mol-plugin: fix canvas bg color when setting partial renderer params

David Sehnal 4 years ago
parent
commit
3983073d6c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/mol-plugin/context.ts

+ 7 - 1
src/mol-plugin/context.ts

@@ -190,7 +190,13 @@ export class PluginContext {
             const antialias = !(this.config.get(PluginConfig.General.DisableAntialiasing) ?? false);
             (this.canvas3d as Canvas3D) = Canvas3D.fromCanvas(canvas, {}, { antialias });
             this.canvas3dInit.next(true);
-            this.canvas3d?.setProps(this.spec.components?.viewport?.canvas3d || { renderer: { backgroundColor: Color(0xFCFBF9) } });
+            const props = this.spec.components?.viewport?.canvas3d;
+            if (!props || props.renderer?.backgroundColor === void 0) {
+                this.canvas3d?.setProps({ renderer: { backgroundColor: Color(0xFCFBF9) } });
+            }
+            if (props) {
+                this.canvas3d?.setProps(props);
+            }
             this.canvas3d!.animate();
             (this.helpers.viewportScreenshot as ViewportScreenshotHelper) = new ViewportScreenshotHelper(this);
             return true;