API Docs for: 2.0.0
Show:

Camera Class

Extends Component
Module: camera
Parent Module: BIMSURFER

A Camera defines a viewpoint within a Viewer.

Overview

Example

In this example we define multiple Cameras looking at a TeapotObject, then periodically switch between the Cameras.

// Create a Viewer
var viewer = new BIMSURFER.Viewer({ element: "myDiv" });

// Create an object
var box = new BIMSURFER.TeapotObject(viewer);

// Create some Cameras
var cameras = [

new BIMSURFER.Camera(viewer, {
       eye: [5, 5, 5],
       active: false
   }),

new BIMSURFER.Camera(viewer, {
       eye: [-5, 5, 5],
       active: false
   }),

new BIMSURFER.Camera(viewer, {
       eye: [5, -5, 5],
       active: false
   }),

new BIMSURFER.Camera(viewer, {
       eye: [5, 5, -5],
       active: false
   }),

new BIMSURFER.Camera(viewer, {
       eye: [-5, -5, 5],
       active: false
   })
];

// Periodically switch between the Cameras

var i = -1;
var last = -1;

setInterval(function () {

       if (last > -1) {
           cameras[last].active = false
       }

       i = (i + 1) % (cameras.length - 1);

       cameras[i].active = true;

       last = i;

   }, 1000);

Constructor

Camera

(
  • [viewer]
  • [cfg]
)

Parameters:

  • [viewer] Viewer optional

    Parent Viewer.

  • [cfg] optional

    Configs

    • [id] String optional

      Optional ID, unique among all components in the parent viewer, generated automatically when omitted.

    • [meta] String:Object optional

      Optional map of user-defined metadata to attach to this Camera.

    • [eye=[0,0,-10]] Array of Number optional

      Eye position.

    • [look=[0,0,0]] Array of Number optional

      The position of the point-of-interest we're looking at.

    • [up=[0,1,0]] Array of Number optional

      The "up" vector.

    • [fovy=60.0] Number optional

      Field-of-view angle, in degrees, on Y-axis.

    • [aspect=1.0] Number optional

      Aspect ratio.

    • [near=0.1] Number optional

      Position of the near plane on the View-space Z-axis.

    • [far=10000] Number optional

      Position of the far plane on the View-space Z-axis.

Methods

destroy

()

Destroys this component.

Removes this Component from its Viewer.

Fires a destroyed event on this Component.

error

(
  • message
)

Logs an error for this component to the JavaScript console.

The console message will have this format: [ERROR] <component id>: <message>

Parameters:

  • message String

    The message to log

fire

(
  • event
  • value
  • [forget=false]
)

Fires an event on this component.

Notifies existing subscribers to the event, retains the event to give to any subsequent notifications on that location as they are made.

Parameters:

  • event String

    The event type name

  • value Object

    The event

  • [forget=false] Boolean optional

    When true, does not retain for subsequent subscribers

log

(
  • message
)

Logs a console debugging message for this component.

The console message will have this format: [LOG] <component id>: <message>

Parameters:

  • message String

    The message to log

off

(
  • handle
)

Cancels an event subscription that was previously made with on or once.

Parameters:

  • handle String

    Subscription handle

on

(
  • event
  • callback
  • [scope=this]
)
String

Subscribes to an event on this component.

The callback is be called with this component as scope.

Parameters:

  • event String

    Publication event

  • callback Function

    Called when fresh data is available at the event

  • [scope=this] Object optional

    Scope for the callback

Returns:

String:

Handle to the subscription, which may be used to unsubscribe with {@link #off}.

once

(
  • event
  • callback
  • [scope=this]
)

Subscribes to the next occurrence of the given event, then un-subscribes as soon as the event is handled.

Parameters:

  • event String

    Data event to listen to

  • callback Function(data)

    Called when fresh data is available at the event

  • [scope=this] Object optional

    Scope for the callback

warn

(
  • message
)

Logs a warning for this component to the JavaScript console.

The console message will have this format: [WARN] <component id>: <message>

Parameters:

  • message String

    The message to log

Properties

active

Boolean

Flag which indicates whether this Camera is active or not.

Fires an active event on change.

className

String final

Inherited from Component but overwritten in src/viewer/camera/camera.js:102

JavaScript class name for this Component.

destroyed

Boolean

True as soon as this Component has been destroyed

exclusive

Boolean final

Indicates that only one instance of a Camera may be active within its Viewer at a time. When a Camera is activated, that has a true value for this flag, then any other active Camera will be deactivated first.

eye

Array(Number)

Position of the eye. Fires an Camera/eye:event event on change.

Default: [0,0,-10]

far

Number

Distance to far clip plane in normalized device coordinates [0..1]. Fires an far event on change.

Default: 10000

id

String final

Unique ID for this Component within its parent Viewer.

Items in this map

Unknown

look

Array(Number)

Position of the point-of-interest. Fires a Camera/look:event event on change.

Default: [0,0,0]

metadata

Object

Metadata on this component.

near

Number

Distance to near clip plane in normalized device coordinates [0..1]. Fires an near event on change.

Default: 0.1

up

Number

Field-of-view angle on Y-axis. Fires an fovy event on change.

Default: 60

up

Array(Number)

Direction of the "up" vector. Fires an Camera/up:event event on change.

Default: [0,1,0]

viewer

Viewer final

The Viewer that contains this Component.

Events

active

Fired whenever this Camera's active property changes.

Event Payload:

  • value Object

    The property's new value

destroyed

Fired when this Component is destroyed.

far

Fired whenever this Camera's far property changes.

Event Payload:

  • value Object

    The property's new value

fovy

Fired whenever this Camera's Camera/fovy:property property changes.

Event Payload:

  • value Object

    The property's new value

near

Fired whenever this Camera's near property changes.

Event Payload:

  • value Object

    The property's new value