Open
Conversation
5f88757 to
93f4a3a
Compare
93f4a3a to
5e23b91
Compare
finetjul
reviewed
Mar 26, 2026
| publicAPI.registerOverride = (className, fn) => { | ||
| model.overrides[className] = fn; | ||
| }; | ||
|
|
Member
There was a problem hiding this comment.
method definition should be moved in vtkOpenGLViewNodeFactory()
Collaborator
|
@sedghi do you have an opnion on this ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Are folks intersted in putting this in the vtk.js repo? Its an uncommon use case. We could get away with simply doing something to keep
vtkOpenGLRenderWindowfrom resizing the canvas and put SharedRenderWindow in another repo/package.Context
This PR adds an OpenGL shared-context rendering path for vtk.js so it can render into a
WebGL2RenderingContextowned by another library, instead of always creating and managing its own canvas/context.The immediate use case is interleaving vtk.js content with host renderers such as MapLibre custom layers, including depth-tested rendering into the host scene. vtk.js also needs an explicit way to opt out of canvas DOM management when the canvas is externally owned.
Results
Before this change:
vtkOpenGLRenderWindowassumed ownership of the canvas and could resize/restyle it.After this change:
WebGL2context throughvtkSharedRenderWindow.createFromContext(canvas, gl).manageCanvasonvtkOpenGLRenderWindow.Changes
Added
manageCanvastovtkOpenGLRenderWindow(defaulttrue) so externally owned canvases can opt out of vtk.js canvas sizing/styling.Added
vtkSharedRenderWindowfor rendering into an externally providedWebGL2RenderingContext.Added
vtkSharedRendererfor the shared-context rendering path.Added
vtkSharedRenderWindow.createFromContext(canvas, gl, options)for creating a shared render window from a host-owned canvas/context.Added shared-rendering options for automatic clearing control (
autoClear,autoClearColor,autoClearDepth).Scoped the vtkSharedRenderer override to the shared render-window instance rather than changing the global OpenGL view-node factory. This avoids leaking shared-context behavior into unrelated normal OpenGL render windows.
Added a MapLibre example showing shared-context rendering on terrain using vtk.js cones, spheres, and a connecting line.
Documentation and TypeScript definitions were updated to match those changes
PR and Code Checklist
npm run reformatto have correctly formatted codeTesting
npm run example -- SharedContext