Class: SceneManager
Class: SceneManager
Loads models (geometric data) from buckets and provides functions to manage elements from these models (selection, traversing and so on).
Example
const sceneManager = new SceneManager()
.onProgress((progress:number)=>{
console.log('Loading progress: '+ progress +'%')
})
.onLoaded((modelId: string)=>{
console.log('Model: '+ modelId +' is loaded')
})
.onAllLoaded(()=>{
console.log('All models are loaded')
})
.load("<GEOMETRY_GUID>")
Hierarchy
EventTarget
↳
SceneManager
Properties
clippingTools
• clippingTools: ClippingTools
Tools class for operations with clipping planes.
edgesMaterial
• edgesMaterial: Material
Material for element edges. *
elementDatas
• elementDatas: Map
<number
, ElementData
>
Additional elements data like bounding box.
groupEdges
• groupEdges: Group
<Object3DEventMap
>
Element`s edges scene group.
groupElements
• groupElements: Group
<Object3DEventMap
>
General elements (meshes and lines and phantoms) scene group.
groupLights
• groupLights: Group
<Object3DEventMap
>
Lines scene group.
groupLines
• groupLines: Group
<Object3DEventMap
>
Line meshes scene group.
groupMeshes
• groupMeshes: Group
<Object3DEventMap
>
Meshes scene group.
groupOpaque
• groupOpaque: Group
<Object3DEventMap
>
Not transparent meshes scene group.
groupPhantoms
• groupPhantoms: Group
<Object3DEventMap
>
Phantom meshes scene group.
groupTrans
• groupTrans: Group
<Object3DEventMap
>
Transparent meshes scene group.
isNavigationStarted
• isNavigationStarted: boolean
Is navigation process has been started by active controller extension.
isNoData
• isNoData: boolean
Is any geometry data loaded.
isProgressive
• isProgressive: boolean
Is progressive render mode on.
loadProgress
• loadProgress: number
Load progress when models are loading.
loadProgressShow
• loadProgressShow: boolean
Are models loading.
materials
• materials: Map
<string
, Material
>
Materials catalog for loaded models.
models
• models: Map
<string
, SceneModel
>
Loaded models info.
originalIndices
• originalIndices: Map
<string
, Uint32Array
>
Map for original indices of all geometry objects. Used to restore elements visibility.
originalMatrices
• originalMatrices: Map
<string
, Matrix4
[]>
Map for original matrices for instance objects. Could be used to restore elements visibility.
scene
• scene: Scene
Main scene for general geometry objects.
sceneBox
• sceneBox: Box3
Scene bounding box.
selBox
• selBox: Box3
Scene temporary bounding box.
selElNums
• selElNums: number
[]
Geometry numbers for selected elements.
showFog
• showFog: boolean
Show fog effect or not.
showGroundShadow
• showGroundShadow: boolean
Show earth shadow effect or not.
tools
• tools: SceneTools
Tools class for elements management.
totalDegradedChilds
• totalDegradedChilds: number
Total elements hided by degradation system in navigation process.
Methods
addAutoEventListener
▸ addAutoEventListener(eventType
, eventListener
, signal
): void
Add event listener with automatic dispose.
Parameters
Name | Type | Description |
---|---|---|
eventType | SceneEvents | event type. |
eventListener | EventListenerOrEventListenerObject | event listener. |
signal | AbortSignal | optional abort signal for manual aborting event listener. |
Returns
void
calculateSceneBox
▸ calculateSceneBox(): void
Calculate whole scene bounding box.
Returns
void
clear
▸ clear(): void
Clear scene assets.
Returns
void
degradeScene
▸ degradeScene(force?
): void
Process scene degradation when progressive render mode is on.
Parameters
Name | Type | Description |
---|---|---|
force? | boolean | force manual degradation. |
Returns
void
destroy
▸ destroy(): void
Destroy scene assets and dispose resources.
Returns
void
gatherSubElements
▸ gatherSubElements(elNums
): number
[]
Gather sub-elements for given element numbers.
Parameters
Name | Type | Description |
---|---|---|
elNums | number [] | Elements numbers. |
Returns
number
[]
getBoundings
▸ getBoundings(elNums
): Box3
Get bounding box for given element numbers.
Parameters
Name | Type | Description |
---|---|---|
elNums | number [] | Elements numbers. |
Returns
Box3
getGlobalOrigin
▸ getGlobalOrigin(): Vector3
Get scene global origin coordinates.
Returns
Vector3
getSceneChldren
▸ getSceneChldren(getOpaqueChildren?
, getTransparentChildren?
, getLineChildren?
): Object3D
<Object3DEventMap
>[]
Get all children elements and meshes from all scenes.
Parameters
Name | Type | Description |
---|---|---|
getOpaqueChildren? | boolean | should function add children from opaque group. |
getTransparentChildren? | boolean | should function add children from transparent scene (transparent meshes). |
getLineChildren? | boolean | should function add children from line scene (lines). |
Returns
Object3D
<Object3DEventMap
>[]
load
▸ load(ids
, crossOriginWorkerMode?
, isShared?
, vIds?
): void
Load models into scene.
Parameters
Name | Type | Description |
---|---|---|
ids | string | string [] | Model version GUID or model version GUIDs with comma separator or GUIDs array. |
crossOriginWorkerMode? | boolean | Mode for SceneWorker loading. Use this flag if you are experiencing problems loading the worker due to CORS or Origin policies. |
isShared? | boolean | - |
vIds? | string [] | - |
Returns
void
setServer
▸ setServer(server?
): SceneManager
Set server URI for data loading.
Parameters
Name | Type | Description |
---|---|---|
server? | string | server URI. |
Returns
setServerPath
▸ setServerPath(path?
): SceneManager
Set server path to RESt point for data loading.
Parameters
Name | Type | Description |
---|---|---|
path? | string | path to server REST point. |
Returns
setToken
▸ setToken(token
): SceneManager
Set acces token for manager`s requests.
Parameters
Name | Type | Description |
---|---|---|
token | string | access token. |
Returns
traverseAllElements
▸ traverseAllElements(callbacks
): void
Scan and gather scene geometry buffers and return buffer data for all elements. Used for changing buffers data for particular elements in model.
Parameters
Name | Type | Description |
---|---|---|
callbacks | TraverseCallbackOptions | See SceneCallbacks.TraverseCallbackOptions |
Returns
void
traverseElements
▸ traverseElements(elNums
, callbacks
): void
Scan and gather scene geometry buffers and return buffer data only for elements list. Used for changing buffers data for particular elements in model.
Parameters
Name | Type | Description |
---|---|---|
elNums | number [] | Elements numbers for for gathering. |
callbacks | TraverseCallbackOptions | See SceneCallbacks.TraverseCallbackOptions |
Returns
void
traverseElementsWithValues
▸ traverseElementsWithValues(elNums
, elVals
, callbacks
): void
Scan and gather scene geometry buffers and return buffer data only for elements list associated with custom values array. Used for changing buffers data for particular elements in model.
Parameters
Name | Type | Description |
---|---|---|
elNums | number [] | Elements numbers for for gathering. |
elVals | any | Elements values for gathering. |
callbacks | TraverseCallbackOptions | See SceneCallbacks.TraverseCallbackOptions |
Returns
void
undegradeScene
▸ undegradeScene(): void
Reset scene degradation when progressive render mode is active.
Returns
void
unload
▸ unload(ids
): void
Unload models geometry from scene.
Parameters
Name | Type | Description |
---|---|---|
ids | string | string [] | Model version GUID or model version GUIDs with comma separator or GUIDs array. |
Returns
void
updateSelection
▸ updateSelection(elNums?
, forceAdd?
, forceEvent?
): void
Select one or many elements in scene.
Parameters
Name | Type | Description |
---|---|---|
elNums? | number [] | Elements numbers for selection. |
forceAdd? | boolean | Add new selection to current or replace. |
forceEvent? | boolean | Force SceneEvents.Selected event dispatching. |
Returns
void
Callbacks
onAllLoaded
▸ onAllLoaded(allLoadedCallback
): SceneManager
Set callback function for event when all models will be loaded.
Parameters
Name | Type | Description |
---|---|---|
allLoadedCallback | Function | function with plain Function signature. |
Returns
onError
▸ onError(errorCallback
): SceneManager
Set a callback for an event when a model will not be loaded due to an error.
Parameters
Name | Type | Description |
---|---|---|
errorCallback | ErrorCallbackFunction | function with ErrorCallbackFunction signature. |
Returns
onLoaded
▸ onLoaded(loadedCallback
): SceneManager
Set a callback for an event when each model will be loaded.
Parameters
Name | Type | Description |
---|---|---|
loadedCallback | LoadedCallbackFunction | function with LoadedCallbackFunction signature. |
Returns
onNotFound
▸ onNotFound(notFoundCallback
): SceneManager
Set a callback for an event when some model will not be founded.
Parameters
Name | Type | Description |
---|---|---|
notFoundCallback | NotFoundCallbackFunction | function with NotFoundCallbackFunction signature. |
Returns
onProgress
▸ onProgress(progressCallback
): SceneManager
Set a callback for an model loading progress event.
Parameters
Name | Type | Description |
---|---|---|
progressCallback | ProgressCallbackFunction | function with ProgressCallbackFunction signature. |