From f87c27fe205a4b1a440740d3be86c6b94d3c2bf0 Mon Sep 17 00:00:00 2001 From: Adnane Belmadiaf Date: Thu, 26 Dec 2024 00:03:09 +0100 Subject: [PATCH] fix(CanvasView): allow setting canvas element --- Sources/Rendering/Misc/CanvasView/index.js | 6 ++++-- Sources/Rendering/Misc/RemoteView/index.js | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Sources/Rendering/Misc/CanvasView/index.js b/Sources/Rendering/Misc/CanvasView/index.js index 799b2d8a1d0..23facc6023b 100644 --- a/Sources/Rendering/Misc/CanvasView/index.js +++ b/Sources/Rendering/Misc/CanvasView/index.js @@ -148,8 +148,10 @@ export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Create internal instances - model.canvas = document.createElement('canvas'); - model.canvas.style.width = '100%'; + if (!model.canvas) { + model.canvas = document.createElement('canvas'); + model.canvas.style.width = '100%'; + } // Create internal bgImage model.bgImage = new Image(); diff --git a/Sources/Rendering/Misc/RemoteView/index.js b/Sources/Rendering/Misc/RemoteView/index.js index a60e8e96646..5dc583e1a84 100644 --- a/Sources/Rendering/Misc/RemoteView/index.js +++ b/Sources/Rendering/Misc/RemoteView/index.js @@ -17,7 +17,9 @@ function vtkRemoteView(publicAPI, model) { model.classHierarchy.push('vtkRemoteView'); // Constructor - model.canvasView = vtkCanvasView.newInstance(); + model.canvasView = vtkCanvasView.newInstance({ + canvas: model.canvasElement, + }); model.interactorStyle = vtkInteractorStyleRemoteMouse.newInstance(); model.interactor = vtkRenderWindowInteractor.newInstance();