Viewport
The viewport of the desktop window, from PluginContext.viewport. Positions are in model coordinates, and screen positions in logical pixels from the viewport’s top left.
Properties
Section titled “Properties”camera
Section titled “camera”
readonlycamera:Camera
The camera the viewport shows the model with, as of now.
height
Section titled “height”
readonlyheight:number
readonlywidth:number
Logical pixels; 0 while the window has no size.
Methods
Section titled “Methods”project()
Section titled “project()”project(
point): readonly [number,number] |null
Where a point shows in the viewport, as [x, y], or null when it is behind the camera.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”readonly [number, number] | null
The ray from the camera through a viewport position, or null while the viewport has no size.
Parameters
Section titled “Parameters”number
number
Returns
Section titled “Returns”{ direction: Vector3d; origin: Point3d; } | null
setCamera()
Section titled “setCamera()”setCamera(
camera,options?):void
Moves the camera, gliding over duration seconds when given. The move starts after the
plugin’s code for this frame, so camera returns the camera as shown until then,
and PluginContext.onCameraChanged listeners hear each step. The user’s own
navigation stops a glide, as do the plugin stopping and another model opening.
Parameters
Section titled “Parameters”camera
Section titled “camera”options?
Section titled “options?”Returns
Section titled “Returns”void
Example
Section titled “Example”// Looks at the origin from the front, in a parallel projection, over half a second.const front = new modlumi.Camera([0, -20, 1.5], [0, 0, 1.5], { perspective: false });context.viewport.setCamera(front, { duration: 0.5 });