DrawingViewport
Represents a framed orthographic window into a TechnicalDrawing.
Constructorsβ
new DrawingViewport()β
new DrawingViewport(
config):DrawingViewport
The viewport lives in the drawing's local coordinate system (XZ plane, Y = 0). Its camera must be added as a child of the drawing's container so that any world-space transform applied to the container automatically moves the camera.
The camera uses layer 1 exclusively, so only geometry explicitly assigned to layer 1 (projection lines, dimensions) is visible in paper-space renders.
Local coordinate convention:
- X right β world +X
- Y up (screen) β world -Z
- Normal (out of plane) β world +Y
Parametersβ
| Parameter | Type |
|---|---|
config | DrawingViewportConfig |
Returnsβ
Propertiesβ
cameraβ
readonlycamera:OrthographicCamera
The Three.js orthographic camera for this viewport. Add it to the drawing container via DrawingViewports.add.
nameβ
name:
string
Human-readable label for this viewport.
onDisposedβ
readonlyonDisposed:Event<void>
uuidβ
readonlyuuid:string
Unique identifier for this viewport instance.
Accessorsβ
bboxβ
getbbox():Box3
Axis-aligned bounding box of this viewport in world drawing space (Y = 0). Used by clipLine and PDF/DXF exporters.
Because screen-up = world βZ, the world Z range visible to the camera is [βtop, βbottom], not [bottom, top].
Returnsβ
Box3
drawingScaleβ
getdrawingScale():number
Drawing scale denominator (e.g. 100 = 1:100).
Returnsβ
number
helperβ
gethelper():DrawingViewportHelper
The DrawingViewportHelper for this viewport.
The helper is created lazily on first access and cached. It is a
THREE.Group on layer 0, so it is visible to the perspective camera but
invisible to the viewport's own orthographic camera (layer 1 only).
Use helperVisible to attach/detach it to the drawing container
automatically, or manage it manually with drawing.three.add/remove.
Returnsβ
helperVisibleβ
gethelperVisible():boolean
Shows or hides the DrawingViewportHelper by attaching it to or removing it from the drawing's container group.
Setting this to true before the viewport has been registered via
DrawingViewports.add() has no effect until registration occurs.
Returnsβ
boolean
localXAxisβ
getlocalXAxis():Vector3
Local X axis direction (world +X).
Returnsβ
Vector3
localYAxisβ
getlocalYAxis():Vector3
Local Y axis direction (world -Z).
Returnsβ
Vector3
normalβ
getnormal():Vector3
Drawing plane normal (world +Y).
Returnsβ
Vector3
sizeβ
getsize():Vector2
Viewport size in millimetres (based on local units Γ 1000).
Returnsβ
Vector2
Methodsβ
clipLine()β
clipLine(
line):null|Line3
Clips a line segment to this viewport's bounding box.
Returns null when the line is entirely outside the viewport.
Parametersβ
| Parameter | Type |
|---|---|
line | Line3 |
Returnsβ
null | Line3
dispose()β
dispose():
void
Destroys this viewport. The camera must be removed from its parent separately.
Returnsβ
void
setContainer()β
Internal
setContainer(
container):void
Called by DrawingViewports.add after the viewport is registered.
Stores a reference to the drawing container so that helperVisible
can attach the helper automatically.
Parametersβ
| Parameter | Type |
|---|---|
container | Group<Object3DEventMap> |
Returnsβ
void