Viewer Class
A Viewer is a WebGL-based 3D viewer for the visualisation and evaluation of BIM models.
Overview
Example
In the example below we'll create a Viewer with a Camera,
a CameraControl and a TeapotGeometry,
which is used by an Object.
Finally, we make the Camera orbit on each "tick" event emitted by the Viewer.
// Create a Viewer
var viewer = new BIMSURFER.Viewer({
// ID of the DIV element
element: "myDiv"
});
// Create a Camera
var camera = new BIMSURFER.Camera(viewer, {
eye: [5, 5, -5]
});
// Create a CameraControl to control our Camera with mouse and keyboard
var cameraControl = new BIMSURFER.CameraControl(viewer, {
camera: camera
});
// Create a Geometry
var geometry = new BIMSURFER.TeapotGeometry(viewer, {
id: "myGeometry"
});
// Create an Object that uses the Geometry
var object1 = new BIMSURFER.Object(viewer, {
id: "myObject1",
type: "IfcCovering",
geometries: [ geometry ]
});
// Spin the camera
viewer.on("tick", function () {
camera.rotateEyeY(0.2);
});
Constructor
Viewer
-
[cfg]
Parameters:
-
[cfg]
optionalConfigs
-
[id]
String optionalOptional ID, unique among all components in the parent viewer, generated automatically when omitted.
-
[meta]
String:Object optionalOptional map of user-defined metadata to attach to this Object.
-
element
String | HTMLElementID or instance of a DIV element in the page.
-
bimServerApi
The BIMServer API.
-
Item Index
Properties
Methods
error
-
message
Logs an error for this View to the JavaScript console.
The console message will have this format: [ERROR] BIMSERVER.Viewer: <message>
Parameters:
-
message
StringThe message to log
fire
-
event
-
value
-
[forget=false]
Fires an event on this Viewer.
Notifies existing subscribers to the event, retains the event to give to any subsequent notifications on that location as they are made.
Parameters:
-
event
StringThe event type name
-
value
ObjectThe event
-
[forget=false]
Boolean optionalWhen true, does not retain for subsequent subscribers
log
-
message
Logs a console debugging message for this View.
The console message will have this format: [LOG] BIMSERVER.Viewer: <message>
Parameters:
-
message
StringThe message to log
off
-
handle
Parameters:
-
handle
StringPublication handle
on
-
event
-
callback
-
[scope=this]
Subscribes to an event on this Viewer.
The callback is be called with this Viewer as scope.
Parameters:
-
event
StringPublication event
-
callback
FunctionCalled when fresh data is available at the event
-
[scope=this]
Object optionalScope for the callback
Returns:
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 on this Viewer, then un-subscribes as soon as the event is handled.
Parameters:
-
event
StringData event to listen to
-
callback
Function(data)Called when fresh data is available at the event
-
[scope=this]
Object optionalScope for the callback
Properties
bimServerApi
Object
final
The BIMServer API
boundary
final
Boundary of all bounded components in this Viewer.
camera
BIMSURFER.Camera
final
canvas
BIMSURFER.Canvas
final
Canvas manager for this Viewer.
canvas
HTMLCanvasElement
final
The HTML Canvas that this Viewer renders to. This is inserted into the element we configured this Viewer with.
center
final
Center of all bounded components in this Viewer.
classes
String:String:Component
final
The Components within this Viewer, mapped to their class names.
cursor
BIMSURFER.Cursor
final
Cursor icon control for this Viewer.
element
HTMLElement
final
The HTML element ocupied by the Viewer
geometryLoaders
Array of
final
Geometry loaders
id
String
final
ID of this Viewer
input
BIMSURFER.Input
final
Input handling for this Viewer.
numObjects
Number
The number of Objects within this ObjectSet.
origin
final
World-space origin.
projMatrix
Array of Number
final
This Viewer's projection transformation matrix.
Default: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]
scene
SceneJS.Scene
final
The SceneJS scene graph that renders 3D content for this Viewer.
types
String:String:Component
final
The Components within this Viewer, mapped to their IFC type names.
viewMatrix
Array of Number
final
This Viewer's view transformation matrix.
Default: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]