Skip to main content

@novorender/api / BaseController

Class: abstract BaseController

Defined in: @novorender/src/web_app/controller/base.ts:18

Base class for all camera controllers.

Extended by​

Accessors​

axes​

Get Signature​

get axes(): ControllerAxes;

Defined in: @novorender/src/web_app/controller/base.ts:59

The input axes

See​

ControllerInput.axes

Returns​

ControllerAxes


currentFlyTo​

Get Signature​

get currentFlyTo(): undefined | Orientation;

Defined in: @novorender/src/web_app/controller/base.ts:113

The current fly-to state, if any.

Returns​

undefined | Orientation


generation​

Get Signature​

get generation(): number;

Defined in: @novorender/src/web_app/controller/base.ts:34

Camera controller state generation.

Remarks​

If the controller state changes, the generation count will be incremented once every call to renderStateChanges. This can be used to detect changes by comparing to a local generation count. The count is wrapped at 0xffffffff, so make sure you use != comparison and not < comparison.

Returns​

number


hasShift​

Get Signature​

get hasShift(): boolean;

Defined in: @novorender/src/web_app/controller/base.ts:108

The input shift button state.

See​

ControllerInput.hasShift

Returns​

boolean


height​

Get Signature​

get height(): number;

Defined in: @novorender/src/web_app/controller/base.ts:80

The input element height.

See​

ControllerInput.height

Returns​

number


moving​

Get Signature​

get moving(): boolean;

Defined in: @novorender/src/web_app/controller/base.ts:66

Whether the camera is currently considered moving or not.

See​

View.isIdleFrame

Returns​

boolean


multiplier​

Get Signature​

get multiplier(): number;

Defined in: @novorender/src/web_app/controller/base.ts:87

The input multiplier.

See​

ControllerInput.multiplier

Returns​

number


pointerTable​

Get Signature​

get pointerTable(): readonly TouchContactPoint[];

Defined in: @novorender/src/web_app/controller/base.ts:101

The input pointer table.

See​

ControllerInput.touchPoints

Returns​

readonly TouchContactPoint[]


width​

Get Signature​

get width(): number;

Defined in: @novorender/src/web_app/controller/base.ts:73

The input element width.

See​

ControllerInput.width

Returns​

number


zoomPos​

Get Signature​

get zoomPos(): number[];

Defined in: @novorender/src/web_app/controller/base.ts:94

The input zoom position.

See​

ControllerInput.zoomPos

Returns​

number[]

Constructors​

Constructor​

protected new BaseController(input): BaseController;

Defined in: @novorender/src/web_app/controller/base.ts:51

Parameters​

ParameterTypeDescription
inputControllerInputThe input source for this controller.

Returns​

BaseController

Methods​

animate()​

animate(elapsedTime): void;

Defined in: @novorender/src/web_app/controller/base.ts:140

Apply time sensitive changes to controller state.

Parameters​

ParameterTypeDescription
elapsedTimenumberThe # of milliseconds elapsed since the last update.

Returns​

void

Remarks​

Fly-to animations happens here, as well as motion based on keyboard pressed-state, such as the WASD keys.


attach()​

attach(): void;

Defined in: @novorender/src/web_app/controller/base.ts:198

Attach this controller to the input object

Returns​

void


autoFit()​

abstract autoFit(center, radius): void;

Defined in: @novorender/src/web_app/controller/base.ts:184

Attempt to fit controller position such that the specified bounding sphere is brought into view.

Parameters​

ParameterTypeDescription
centerReadonlyVec3The center of the bounding sphere, in world space.
radiusnumberThe radius of the bounding sphere, in world space.

Returns​

void


changed()​

protected changed(): void;

Defined in: @novorender/src/web_app/controller/base.ts:39

Signal changes to internal state.

Returns​

void


init()​

abstract init(params): void;

Defined in: @novorender/src/web_app/controller/base.ts:178

Initialize controller from parameters.

Parameters​

ParameterType
paramsControllerInitParams

Returns​

void

See​

serialize


mouseButtonChanged()​

abstract mouseButtonChanged(event): void | Promise<void>;

Defined in: @novorender/src/web_app/controller/base.ts:206

Handler for mouse buttons events.

Parameters​

ParameterType
eventMouseEvent

Returns​

void | Promise<void>


moveBegin()​

abstract moveBegin(event): void | Promise<void>;

Defined in: @novorender/src/web_app/controller/base.ts:218

Handler for mouse/touch move events.

Parameters​

ParameterType
eventMouseEvent | TouchEvent

Returns​

void | Promise<void>


moveTo()​

abstract moveTo(
targetPosition,
flyTime?,
rotation?): void;

Defined in: @novorender/src/web_app/controller/base.ts:227

Move controller to specified position/rotation.

Parameters​

ParameterTypeDescription
targetPositionReadonlyVec3The position to move to, in world space.
flyTime?numberThe time, in milliseconds, for the transition animation to last, or 0 for instant update. Default should be 1000.
rotation?ReadonlyQuatOptional target rotation, or undefined to retain current rotation.

Returns​

void


renderStateChanges()​

renderStateChanges(state, elapsedTime): 
| undefined
| RecursivePartial<RenderState>;

Defined in: @novorender/src/web_app/controller/base.ts:247

Retrieve the state changes to be applied to the specified render state.

Parameters​

ParameterTypeDescription
stateRenderStateCameraThe baseline render state.
elapsedTimenumberThe time elapsed since last call, in milliseconds.

Returns​

| undefined | RecursivePartial<RenderState>


resetFlyTo()​

protected resetFlyTo(): void;

Defined in: @novorender/src/web_app/controller/base.ts:117

Returns​

void


serialize()​

abstract serialize(includeDerived?): ControllerInitParams;

Defined in: @novorender/src/web_app/controller/base.ts:173

Serialize the state of this controller into init parameters.

Parameters​

ParameterTypeDescription
includeDerived?booleanInclude derived state which may not be intrinsic to this controller, such as orbit controller position.

Returns​

ControllerInitParams

See​

init


setFlyTo()​

protected setFlyTo(flyTo): void;

Defined in: @novorender/src/web_app/controller/base.ts:124

Initialize a fly-to transition.

Parameters​

ParameterTypeDescription
flyToFlyToParamsThe transition parameters

Returns​

void


stateChanges()​

abstract stateChanges(state?): Partial<RenderStateCamera>;

Defined in: @novorender/src/web_app/controller/base.ts:195

Retrieve changes to render state from derived class, if any.

Parameters​

ParameterTypeDescription
state?RenderStateCameraThe baseline state to apply changes to.

Returns​

Partial<RenderStateCamera>

See​

View.modifyRenderState

Remarks​

If there are no changes, the returned object will be empty, i.e. .


touchChanged()​

abstract touchChanged(event): void | Promise<void>;

Defined in: @novorender/src/web_app/controller/base.ts:212

Handler for touch events.

Parameters​

ParameterType
eventTouchEvent

Returns​

void | Promise<void>


update()​

abstract update(): void;

Defined in: @novorender/src/web_app/controller/base.ts:187

Update internal controller state

Returns​

void


zoomTo()​

abstract zoomTo(boundingSphere, flyTime?): void;

Defined in: @novorender/src/web_app/controller/base.ts:241

Bring the specified bounding sphere into view.

Parameters​

ParameterTypeDescription
boundingSphereBoundingSphereThe bounding sphere to move into view.
flyTime?numberThe time, in milliseconds, for the transition animation to last, or 0 for instant update. Default should be 1000.

Returns​

void

Remarks​

This function will retain the current camera controller rotation.


getDistanceFromViewPlane()​

protected static getDistanceFromViewPlane(
point,
cameraPosition,
cameraRotation): number;

Defined in: @novorender/src/web_app/controller/base.ts:281

Compute the distance to a point from the specified view plane.

Parameters​

ParameterTypeDescription
pointReadonlyVec3The point to measure distance too
cameraPositionReadonlyVec3The position of the camera/view plane.
cameraRotationReadonlyQuatThe rotation of the camera/view plane.

Returns​

number

A signed distance from the point to the view plane, i.e. positive for points in front of the plane and negative otherwise.

Properties​

input​

readonly input: ControllerInput;

Defined in: @novorender/src/web_app/controller/base.ts:53

The input source for this controller.


kind​

abstract readonly kind: string;

Defined in: @novorender/src/web_app/controller/base.ts:20

The controller type id.


projection​

abstract readonly projection: undefined | "pinhole" | "orthographic";

Defined in: @novorender/src/web_app/controller/base.ts:25

The camera projection kind.

See​

RenderStateCamera.kind.