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.
Constant | Value | Description |
---|---|---|
Camera related | ||
TRANSITION_TO_DEFAULT_ON_SCENE_LOAD | TransitionToDefaultOnSceneLoad | If set to true, camera will transition to default position after scene has finished loading |
CAMERA_FOLLOW_OBJECTS | CameraFollowObjects | If set to true, camera will follow moving objects (dynamic objects) |
CAMERA_FOLLOW_ROTATION | CameraFollowRotation | If set to true, camera will act as if it was parented to the moving object. This value depends on CameraFollowObjects |
CAMERA_DEFAULT_POSITION | CameraDefaultPosition | Default camera position, gets updated when UpdateCameraDefaultTransform is called |
CAMERA_DEFAULT_TARGET_POSITION | CameraDefaultTargetPosition | Default camera target position, gets updated when UpdateCameraDefaultTransform is called |
CAMERA_PATH_SPEED | CameraPathSpeed | Camera path animation speed in units per second |
CAMERA_PANNING_SENSITIVITY | CameraPanningSensitivity | Camera panning sensitivity, smaller value will make the camera pan faster |
CAMERA_ANGULAR_SENSITIVITY | CameraAngularSensitivity | Camera angular sensitivity, smaller value will make the camera turn faster |
CAMERA_MIN_RADIUS | CameraMinimumRadius | Minimum radius/distance from the focus point. Used for arc ball rotate camera (default camera). Set to <0 for no limit |
CAMERA_MAX_RADIUS | CameraMaximumRadius | Maximum 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_FOCUS | Use default camera focus setting for meshes true/false | |
MESH_DEFAULT_FOCUS_OFFSET | Mesh default camera focus offset (ie [-2, 6, -7]) | |
MESH_DEFAULT_FOCUS_TARGET_OFFSET | Mesh default camera focus target offset (ie [0, 0, 0]) | |
Custom mode | ||
CUSTOM_MODE | CustomMode | Tracks the current custom mode of the viewer. |
Dynamic objects | ||
DYNAMIC_OBJECT_UNIT_SCALE | DynamicObjectUnitScale | Unit scale used in dynamic object positioning, all position values are multiplied by this value |
DYNAMIC_OBJECT_UNIT_OFFSET | DynamicObjectUnitOffset | Unit offset used in dynamic object positioning, this value is added to all position values after scaling |
DYNAMIC_OBJECT_IS_GEO_LOCATED | DynamicObjectIsGeoLocated | Whether position for a dynamic object is given as geo coordinates |
General config | ||
CANVAS_RENDERING_WIDTH | CanvasRenderingWidth | Maximum 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_HEIGHT | CanvasRenderingHeight | Maximum 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_SIZE | LimitCanvasSize | When true, the rendering canvas width and height will be limited according to configuration. |
MAX_FPS | MaxFPS | Maximum rendered frames per second |
SHOW_PERFORMANCE_TIMINGS | ShowPerformanceTimings | Show rendering related timings |
CONSTANTLY_UPDATE_VIEWER | ConstantlyUpdateViewer | Force update viewer even if nothing's happening |
DEBUG_MODE | DebugMode | Enable debug features and extra logging |
ENABLE_OFFLINE_SUPPORT | EnableOfflineSupport | Enable offline support, e.g. 3d model caching using client browser cache (.manifest files) |
ENABLE_BACKGROUND_GRADIENT | EnableBackgroundGradient | Enable background gradient |
SHOW_ONLY_SELECTED_GROUP | ShowOnlySelectedGroup | Shows only the selected group |
OBJECT_DEFAULT_PICKABLE | IsPickableDefaultValue | Are objects pickable by default. |
ATTACHED_LABELS_DEFINE_PICKABLES | AttachedLabelsDefinePickables | If set to true, only objects with attached labels will be pickable. |
SCENE_NAME | SceneName | Usually the name of the factory, used in various non-critical parts of the widget. |
SCENE_MODEL_URL | SceneModelUrl | URL to the model |
SCENE_MODEL_FILE_SIZE | SceneModelFileSize | Download size of the model |
RESET_SCENE_ON_MODEL_CHANGE | ResetSceneOnModelChange | Reset the scene whenever the model changes |
SCENE_BACKGROUND_COLOUR | SceneBackgroundColour | The background of the widget. Opacity is supported |
Geo | ||
GEO_FENCE_BASE_FONT_SIZE | GeoFenceBaseFontSize | Base font size for the text in geo fences. NOTE: The font will be scaled based on the overall size of the scene |
GEO_SCENE_UNITS | SceneUnitScale | How scene units correspond to real-world units |
Label | ||
SORT_COMPONENTS_IN_LABEL | SortByComponentType | Sort components in a label by their type |
COMPONENT_FONT_COLOUR_FIELD | ComponentFontColourField | Which style field to use for colouring the component text/value |
LABEL_STYLE_ICONSIZE | LabelStyleIconSize | Global label icon size (px) used in label styling |
Layers | ||
ACTIVE_LAYER | ActiveLayer | Active mesh layer. Set to -1 to display all layers |
Lighting | ||
DYNAMIC_LIGHTING | DynamicLighting | Use dynamic lighting instead of unlit scene |
GLOBAL_LIGHT_INTENSITY | GlobalLightIntensity | Used only if dynamic lighting is enabled |
Logging | ||
ENABLE_LOGGING_LIMIT | EnableLoggingLimit | Whether to enable logging limiting or not |
MIN_DURATION_BETWEEN_SAME_MESSAGE | MinDurationBetweenEqualLogMessages | Minimum duration between two equal messages in ms. Only applies if EnableLoggingLimit is true |
Object | ||
OBJECT_COLOR_INTENSITY | ObjectColorIntensity | Object overlay color intensity, "intensity" can be also set with color alpha value |
Selections | ||
SELECTED_GROUP_ID | SelectedGroupId | The id currently selected item in the scene |
SELECTED_OBJECT_ID | SelectedObjectId | The currently selected group in the scene |
SELECTED_LABEL_ID | SelectedLabelId | The currently selected label id, triggers changed event. |
SELECTED_MESH_COLOUR | SelectedMeshColour | Colour of the outline of a selected mesh |
HOVERED_MESH_COLOUR | HoveredMeshColour | Colour of the outline of a selected mesh |
Authentication | ||
PERSONAL_ACCESS_TOKEN | PersonalAccessToken | Personal 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.
Constant | Value | Description | Expected input data |
---|---|---|---|
ASSET_LIBRARY | AnimationState | Array containing the data for mesh animation state(s) | AssetLibraryData[] |
DYNAMIC_OBJECT | DynamicObjectData | An array containing the dynamic object data | DynamicObjectData[] |
CAMERA_PATH | CameraPathData | An array containing camera path data | CameraPathData[] |
GEO | GeoData | An object containing data for geo markers and fences | GeoData |
GROUP | GroupData | An array containing the group data | GroupData[] |
LABEL | LabelData | An array containing the label data | ILabelData[] |
CAMERA_FOCUS | CameraFocusData | An array containing camera focus data, defining the view for camera to transition to when a given object is selected | CameraFocusData[] |
SCENE | SceneData | An array containing the scene data | SceneData[] |
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
Name | Description |
---|---|
LAYOUT_DEFAULT | default mode |
LAYOUT_HIDDEN | icon and label hidden |
LAYOUT_COLLAPSED | label collapsed and only icon visible |
LAYOUT_TITLE | title and icon visible, collapsed when zoomed out |
LAYOUT_FULL | icon, title and content visible, collapsed when zoomed out |
LAYOUT_FULL_ALWAYS_SHOW | icon, title and content always visble |
- COMPONENT_TYPE
Name | Description | Visual |
---|---|---|
CUSTOM_INFO | Shows only title text | |
HYPERLINK | Creates hyperlink from the URL | |
DEFAULT | Show title and value | |
PROGRESS | Progress indicator | |
SPEEDOMETER | Speedometer indicator | |
SPEEDBAR | Speedbar indicator | |
BUTTON | Sends button clicked event | |
ICONANDTITLE | Icon and title |
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
Constant | Value | Event arguments |
---|---|---|
Asset library events | ||
SCENE_DATA_UPDATED | SceneDataUpdated | data: SceneData[] |
Camera events | ||
CAMERA_TRANSITION_STOPPED | CameraTransitionStopped | - |
CAMERA_TRANSITION_DONE | CameraTransitionDone | - |
CAMERA_TRANSITION_TO_MESH_DONE | CameraTransitionToMeshDone | `mesh: BABYLON.Mesh |
CAMERA_TRANSITION_TO_HOME_DONE | CameraTransitionToHomeDone | - |
CAMERA_PATH_UPDATED | CameraPathUpdated | data: CameraPathData[] |
CAMERA_TRANSFORM_UPDATED | CameraTransformUpdated | - |
CAMERA_DEFAULT_TRANSFORM_UPDATED | CameraDefaultTransformUpdated | position: number[], target: number[] |
Geo events | ||
GEO_DATA_UPDATED | GeoDataUpdated | data: GeoData |
Group events | ||
GROUP_HOVERED | GroupHovered | group: GroupLabel |
GROUP_CLICKED | GroupClicked | - |
Label events | ||
LABEL_HOVERED | LabelHovered | label: Label |
LABEL_CLICKED | LabelClicked | label: Label |
Object events | ||
OBJECT_HOVERED | ObjectHovered | mesh: BABYLON.Mesh |
OBJECT_CLICKED | ObjectClicked | mesh: BABYLON.Mesh |
Scene/mesh | ||
MODEL_LOAD_DONE | ModelLoadDone | - |
MODEL_LOAD_ERROR | ModelLoadError | - |
MESH_LOAD_DONE | MeshLoadDone | - |
MESH_LOAD_ERROR | MeshLoadError | - |
Selections | ||
SELECTED_LABEL_CHANGED | SelectedLabelChanged | label: UiElement |
SELECTED_OBJECT_CHANGED | SelectedObjectChanged | objectId: string |
SELECTED_GROUP_CHANGED | SelectedGroupChanged | groupName: string |
Misc | ||
HOME_CLICKED | HomeClicked | - |
CUSTOM_MODE_CHANGED | CustomModeChanged | customMode: CUSTOM_MODE |
HYPERLINK_COMPONENT_CLICKED | HyperlinkComponentClicked | id: string |
BUTTON_COMPONENT_CLICKED | ButtonComponentClicked | id: string, value: string |
EXPORT_READY | ExportReady | zipData: 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;
});