Skip to content

RenderingPlugin ​

Thin plugin-facing wrapper around RenderingService and the optional PostProcessingService. Use it to drive renders, change quality, manage effects and post-process passes, and take screenshots.

Usage ​

RenderingService is registered by ViewerCore. Load the plugin to expose the same API through pluginManager.

ts
import { ViewerCore, RenderingPlugin } from "@optellix/xviewr-sdk";

const viewer = new ViewerCore(container, config);
await viewer.ready();
await viewer.loadPlugin(new RenderingPlugin());

const rendering = viewer.pluginManager.getPlugin("rendering") as RenderingPlugin;
rendering.setQuality("high");
rendering.renderFrame();

Service dependencies: rendering (required), postprocessing (optional). Post-processing methods no-op if the service is not registered.

Public API ​

MethodDescription
updateConfig(config)Partial update of RenderingConfig on the service.
renderFrame()Render the current scene/camera once.
addEffect(id, effect)Register a RenderEffect by id.
removeEffect(id)Remove a previously registered effect.
setPostProcessingEnabled(enabled)Toggle post-processing globally.
updatePostProcessingConfig(config)Partial update of PostProcessingConfig.
addPostProcessPass(pass)Add a PostProcessPass to the chain.
removePostProcessPass(id)Remove a pass by id. Returns boolean.
takeScreenshot(width?, height?)Returns a data URL of the current frame.
createRenderTarget(width, height, options?)Create a THREE.WebGLRenderTarget.
renderToTarget(target, scene, camera, clear?)Render an arbitrary scene/camera into a target.
getStats()Returns RenderingStats (draw calls, triangles, FPS, etc.).
setWireframe(enabled)Toggle global wireframe mode.
setQuality(quality)Switch RenderQuality preset.

Events ​

The plugin does not emit events of its own. See RenderingService events on the bus for render-state changes.

Example ​

ts
const rendering = viewer.pluginManager.getPlugin("rendering") as RenderingPlugin;

rendering.updateConfig({ shadowMapEnabled: true });
rendering.setQuality("high");

const dataUrl = rendering.takeScreenshot(2048, 1536);

const stats = rendering.getStats();
console.log(stats.fps, stats.triangles);

XViewr SDK and xConvert CLI documentation.