Skip to main content
Version: 4.1.6

Settings

Following settings are exposed by the viewer. The constant is accessible from E3D.SETTING.xxx where xxx is the constant. A setting can be queried using E3D.GetSetting(CTX, SETTING_KEY) where CTX is the widget or its id and SETTING_KEY is one of the constants or their values from the list below. To set a setting you can use E3D.SetSetting(CTX, SETTING_KEY, NEW_VALUE). The settings are validated against their expected type.

ConstantValueDescription
Camera related
TRANSITION_TO_DEFAULT_ON_SCENE_LOADTransitionToDefaultOnSceneLoadIf set to true, camera will transition to default position after scene has finished loading
CAMERA_FOLLOW_OBJECTSCameraFollowObjectsIf set to true, camera will follow moving objects (dynamic objects)
CAMERA_FOLLOW_ROTATIONCameraFollowRotationIf set to true, camera will act as if it was parented to the moving object. This value depends on CameraFollowObjects
CAMERA_DEFAULT_POSITIONCameraDefaultPositionDefault camera position, gets updated when UpdateCameraDefaultTransform is called
CAMERA_DEFAULT_TARGET_POSITIONCameraDefaultTargetPositionDefault camera target position, gets updated when UpdateCameraDefaultTransform is called
CAMERA_PATH_SPEEDCameraPathSpeedCamera path animation speed in units per second
CAMERA_PANNING_SENSITIVITYCameraPanningSensitivityCamera panning sensitivity, smaller value will make the camera pan faster
CAMERA_ANGULAR_SENSITIVITYCameraAngularSensitivityCamera angular sensitivity, smaller value will make the camera turn faster
CAMERA_MIN_RADIUSCameraMinimumRadiusMinimum radius/distance from the focus point. Used for arc ball rotate camera (default camera). Set to <0 for no limit
CAMERA_MAX_RADIUSCameraMaximumRadiusMaximum radius/distance from the focus point. Used for arc ball rotate camera (default camera). Set to <0 for no limit
Mesh (from 4.1 ->)
USE_MESH_DEFAULT_CAMERA_FOCUSUse default camera focus setting for meshes true/false
MESH_DEFAULT_FOCUS_OFFSETMesh default camera focus offset (ie [-2, 6, -7])
MESH_DEFAULT_FOCUS_TARGET_OFFSETMesh default camera focus target offset (ie [0, 0, 0])
Custom mode
CUSTOM_MODECustomModeTracks the current custom mode of the viewer.
Dynamic objects
DYNAMIC_OBJECT_UNIT_SCALEDynamicObjectUnitScaleUnit scale used in dynamic object positioning, all position values are multiplied by this value
DYNAMIC_OBJECT_UNIT_OFFSETDynamicObjectUnitOffsetUnit offset used in dynamic object positioning, this value is added to all position values after scaling
DYNAMIC_OBJECT_IS_GEO_LOCATEDDynamicObjectIsGeoLocatedWhether position for a dynamic object is given as geo coordinates
General config
CANVAS_RENDERING_WIDTHCanvasRenderingWidthMaximum rendering canvas width. Needs "LimitCanvasSize" to be set to true. NOTE: The canvas will still be stretched to fit the space, reducing this will only affect the internal render size which can improve performance for the cost of quality.
CANVAS_RENDERING_HEIGHTCanvasRenderingHeightMaximum rendering canvas height. Needs "LimitCanvasSize" to be set to true. NOTE: The canvas will still be stretched to fit the space, reducing this will only affect the internal render size which can improve performance for the cost of quality."
LIMIT_CANVAS_SIZELimitCanvasSizeWhen true, the rendering canvas width and height will be limited according to configuration.
MAX_FPSMaxFPSMaximum rendered frames per second
SHOW_PERFORMANCE_TIMINGSShowPerformanceTimingsShow rendering related timings
CONSTANTLY_UPDATE_VIEWERConstantlyUpdateViewerForce update viewer even if nothing's happening
DEBUG_MODEDebugModeEnable debug features and extra logging
ENABLE_OFFLINE_SUPPORTEnableOfflineSupportEnable offline support, e.g. 3d model caching using client browser cache (.manifest files)
ENABLE_BACKGROUND_GRADIENTEnableBackgroundGradientEnable background gradient
SHOW_ONLY_SELECTED_GROUPShowOnlySelectedGroupShows only the selected group
OBJECT_DEFAULT_PICKABLEIsPickableDefaultValueAre objects pickable by default.
ATTACHED_LABELS_DEFINE_PICKABLESAttachedLabelsDefinePickablesIf set to true, only objects with attached labels will be pickable.
SCENE_NAMESceneNameUsually the name of the factory, used in various non-critical parts of the widget.
SCENE_MODEL_URLSceneModelUrlURL to the model
SCENE_MODEL_FILE_SIZESceneModelFileSizeDownload size of the model
RESET_SCENE_ON_MODEL_CHANGEResetSceneOnModelChangeReset the scene whenever the model changes
SCENE_BACKGROUND_COLOURSceneBackgroundColourThe background of the widget. Opacity is supported
Geo
GEO_FENCE_BASE_FONT_SIZEGeoFenceBaseFontSizeBase font size for the text in geo fences. NOTE: The font will be scaled based on the overall size of the scene
GEO_SCENE_UNITSSceneUnitScaleHow scene units correspond to real-world units
Label
SORT_COMPONENTS_IN_LABELSortByComponentTypeSort components in a label by their type
COMPONENT_FONT_COLOUR_FIELDComponentFontColourFieldWhich style field to use for colouring the component text/value
LABEL_STYLE_ICONSIZELabelStyleIconSizeGlobal label icon size (px) used in label styling
Layers
ACTIVE_LAYERActiveLayerActive mesh layer. Set to -1 to display all layers
Lighting
DYNAMIC_LIGHTINGDynamicLightingUse dynamic lighting instead of unlit scene
GLOBAL_LIGHT_INTENSITYGlobalLightIntensityUsed only if dynamic lighting is enabled
Logging
ENABLE_LOGGING_LIMITEnableLoggingLimitWhether to enable logging limiting or not
MIN_DURATION_BETWEEN_SAME_MESSAGEMinDurationBetweenEqualLogMessagesMinimum duration between two equal messages in ms. Only applies if EnableLoggingLimit is true
Object
OBJECT_COLOR_INTENSITYObjectColorIntensityObject overlay color intensity, "intensity" can be also set with color alpha value
Selections
SELECTED_GROUP_IDSelectedGroupIdThe id currently selected item in the scene
SELECTED_OBJECT_IDSelectedObjectIdThe currently selected group in the scene
SELECTED_LABEL_IDSelectedLabelIdThe currently selected label id, triggers changed event.
SELECTED_MESH_COLOURSelectedMeshColourColour of the outline of a selected mesh
HOVERED_MESH_COLOURHoveredMeshColourColour of the outline of a selected mesh
Authentication
PERSONAL_ACCESS_TOKENPersonalAccessTokenPersonal access token to add to scene requests

Data

Data is something that the viewer can use to generate views/content to the scene. It's also something that the viewer will generate when using the features inside the viewer during runtime. You can read the current data from the viewer using E3D.GetData(CTX, DATA_KEY) where CTX is the widget and DATA_KEY is the constant or value from the table below. To set data to the viewer use E3D.SetData(CTX, DATA_KEY, DATA) where DATA is the new dataset for the key. The constants can be access through E3D.DATA.xxx where xxx is the constant.

ConstantValueDescriptionExpected input data
ASSET_LIBRARYAnimationStateArray containing the data for mesh animation state(s)AssetLibraryData[]
DYNAMIC_OBJECTDynamicObjectDataAn array containing the dynamic object dataDynamicObjectData[]
CAMERA_PATHCameraPathDataAn array containing camera path dataCameraPathData[]
GEOGeoDataAn object containing data for geo markers and fencesGeoData
GROUPGroupDataAn array containing the group dataGroupData[]
LABELLabelDataAn array containing the label dataILabelData[]
CAMERA_FOCUSCameraFocusDataAn array containing camera focus data, defining the view for camera to transition to when a given object is selectedCameraFocusData[]
SCENESceneDataAn array containing the scene dataSceneData[]

The type definitions for the expected types are as follows:

// Asset library
interface AssetLibraryData
{
name: string;
url: string;
thumbnail: string;
category: string;
tag: string;
}

// Camera focus
interface CameraFocusData
{
id: string;
relativePosition: Array<number>;
relativeTargetPosition: Array<number>;
}

// Camera path
interface CameraPathData
{
position: Array<number>;
direction: Array<number>;
}

// Dynamic object
interface DynamicObjectData
{
id: string;
url: string;
scale: Array<number>;
rotation: Array<number>;
position: Array<number> | Coordinate;
}

interface Coordinate
{
latitude: number;
longitude: number;
elevation: number;
}

// Geo
interface GeoData
{
markers: GeoMarkerData[]
, fences: GeoFenceData[]
}

interface GeoMarkerData
{
coordinates: Coordinate;
scenePosition: Array<number>;
}
interface GeoFenceData
{
name: string;
colour: string;
coordinates: Coordinate[];
}

// Group
interface GroupData
{
name: string;
id: string;
nodes: Array<string>;
}

// Label
interface ILabelData
{
id: string
, title?: string
, isGroupLabel?: boolean
, collapsedTitle?: string
, group?: string
, meshId?: string
, objectButtonText?: string
, layout?: LABEL_LAYOUT
, status?: Style
, components?: ComponentData[]
}

// Scene
interface SceneData
{
name: string
, position: Array<number>
, scale: Array<number>
, rotation: Array<number>
, modelName: string
, url: string
}

ILabelData

  • LABEL_LAYOUT
NameDescription
LAYOUT_DEFAULTdefault mode
LAYOUT_HIDDENicon and label hidden
LAYOUT_COLLAPSEDlabel collapsed and only icon visible
LAYOUT_TITLEtitle and icon visible, collapsed when zoomed out
LAYOUT_FULLicon, title and content visible, collapsed when zoomed out
LAYOUT_FULL_ALWAYS_SHOWicon, title and content always visble
  • COMPONENT_TYPE
NameDescriptionVisual
CUSTOM_INFOShows only title textImgur1
HYPERLINKCreates hyperlink from the URLImgur2
DEFAULTShow title and valueImgur3
PROGRESSProgress indicatorImgur4
SPEEDOMETERSpeedometer indicatorImgur5
SPEEDBARSpeedbar indicatorImgur6
BUTTONSends button clicked eventImgur7
ICONANDTITLEIcon and titleImgur8

Events

The viewer has events that are triggered when something in the viewer happens. Events can be listened to or propagated forward if wanted. The propagation and listening can be accessed using E3D.EventDispatcher. The constants can be accessed through E3D.EventName.xxx where xxx is the constant. The event arguments can be caught within the callback

ConstantValueEvent arguments
Asset library events
SCENE_DATA_UPDATEDSceneDataUpdateddata: SceneData[]
Camera events
CAMERA_TRANSITION_STOPPEDCameraTransitionStopped-
CAMERA_TRANSITION_DONECameraTransitionDone-
CAMERA_TRANSITION_TO_MESH_DONECameraTransitionToMeshDone`mesh: BABYLON.Mesh
CAMERA_TRANSITION_TO_HOME_DONECameraTransitionToHomeDone-
CAMERA_PATH_UPDATEDCameraPathUpdateddata: CameraPathData[]
CAMERA_TRANSFORM_UPDATEDCameraTransformUpdated-
CAMERA_DEFAULT_TRANSFORM_UPDATEDCameraDefaultTransformUpdatedposition: number[], target: number[]
Geo events
GEO_DATA_UPDATEDGeoDataUpdateddata: GeoData
Group events
GROUP_HOVEREDGroupHoveredgroup: GroupLabel
GROUP_CLICKEDGroupClicked-
Label events
LABEL_HOVEREDLabelHoveredlabel: Label
LABEL_CLICKEDLabelClickedlabel: Label
Object events
OBJECT_HOVEREDObjectHoveredmesh: BABYLON.Mesh
OBJECT_CLICKEDObjectClickedmesh: BABYLON.Mesh
Scene/mesh
MODEL_LOAD_DONEModelLoadDone-
MODEL_LOAD_ERRORModelLoadError-
MESH_LOAD_DONEMeshLoadDone-
MESH_LOAD_ERRORMeshLoadError-
Selections
SELECTED_LABEL_CHANGEDSelectedLabelChangedlabel: UiElement
SELECTED_OBJECT_CHANGEDSelectedObjectChangedobjectId: string
SELECTED_GROUP_CHANGEDSelectedGroupChangedgroupName: string
Misc
HOME_CLICKEDHomeClicked-
CUSTOM_MODE_CHANGEDCustomModeChangedcustomMode: CUSTOM_MODE
HYPERLINK_COMPONENT_CLICKEDHyperlinkComponentClickedid: string
BUTTON_COMPONENT_CLICKEDButtonComponentClickedid: string, value: string
EXPORT_READYExportReadyzipData: Blob, sceneName: string
// To add a listener to an event, you can use the following method (shown its signature)
// Where eventName is the event to listen to
// callback is a function that will be called when the event happens
// owner is the owner of the callback function (if need be), can be set to window if the function's just generic
EventDispatcher.registerEventListener(ctx: ElemIdOrObject, eventName: EventName, callback: Function, owner: any): number

// If you want to propagate the events further (e.g. call something when any even occurs)
// You can use the EventDispatcher.registerEventDispatcher method to register an event dispatcher
EventDispatcher.registerEventDispatcher(ctx: ElemIdOrObject, dispatcher: Function, owner: any): number

// Both of the above methods return a handle to the listener/dispatcher which can be used to unregister
// from the events if wanted/need be with the following methods
EventDispatcher.unregisterEventDispatcher(ctx: ElemIdOrObject, handle: number)
EventDispatcher.unregisterEventListener(ctx: ElemIdOrObject, eventName: EventName, handle: number)

// The widget can be used as the ctx for the above methods

// Real example, if you want to download the resulting export when the export is ready
EventDispatcher.registerEventListener(widget, EventName.EXPORT_READY, (content: Blob, name: string) =>
{
BABYLON.Tools.Download(content, `${name}.zip`);
}, null);

Localisation

The viewer supports simple localisation using tokens. To support localisation, implement a localisation function for the widget before viewer is initialised

// Simple example of what the localisation implementation could be like
ImplLocalisationFunction(function (token: string, defaultValue: string): string
{
return PlatformSpecificLocalisationFunction(token) || defaultValue;
});