Central APIs#
The webvis context is a facade that aggregates all sub-APIs. While they all serve their own purpose, some are more central than others and are likely to be used repeatedly across different parts of your app.
ContextRegistry
This is the module-level entry point and likely the only thing you call before you have a context. Use requestContext to create one, getContext to look up an existing one by name (or the default), getContexts to list them, and removeContext to dispose one. You can also observe a context's lifecycle with addContextCreatedListener / addContextRemovedListener.
Viewer
Viewers are visual windows onto the scene - the scene data itself lives in the context.
You create a viewer using context.createViewer(...). A single context can drive multiple viewers simultaneously, meaning you can have two or more independent views of the same scene running at the same time.
Each viewer renders its context into a canvas and lets you explore, style, and enrich your 3D data:
- Camera & View Control: Multiple predefined navigation modes, direct camera access, and helpers to get the right view on your data.
- Shading & Effects: Multiple lighting setups and render modes, plus effects like ambient occlusion and anti-aliasing to get the perfect look for your data.
- Advanced Features: Point clouds, heatmaps, drawings, and more to enrich your scene and visualize your external data.
- And more...
InstanceGraph
Represents the scene graph: a tree of nodes identified by numeric nodeIDs
(see CRUD with IDs). Nodes can have various
properties (label, type, enabled, etc.) which you can
read and write.
Events
Every API emits API-specific events, which are always subclasses of webvis' base event. Whenever you want to react to a change in the scene, you can subscribe and unsubscribe to the event types you care about.
Settings
webvis can handle two types of settings: context settings (hub URL, logging, query batching) and viewer settings (render mode, field of view, projection).
For viewer settings it matters where you apply the call. Calling it on the context applies it globally while calling it on a single viewer applies it to that viewer only. The same holds for reads.
// Global: applies to the context (and all its viewers)
// Note that this overwrites any viewer-local setting for the same key.
context.changeSetting(webvis.ViewerSettingStrings.RENDER_MODE, webvis.RenderMode.Faces);
// Local: applies to one viewer only
context.getViewer("my-viewer").changeSetting(
webvis.ViewerSettingStrings.RENDER_MODE, webvis.RenderMode.Topology
);
Changing a setting emits a setting-changed event like any other mutation.