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>")
Extends
EventTarget
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.
maxModelsCache
maxModelsCache:
number
Maximum number of models that will be saved to the browser cache for faster later opening.
models
models:
Map
<string
,SceneModel
>
Loaded models info.
originalIndices
originalIndices:
Map
<string
,Uint32Array
<ArrayBufferLike
>>
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.
useWasmLzma
useWasmLzma:
boolean
Determines whether to use the WebAssembly (WASM) implementation of LZMA.
When true, the system will use the optimized lzma-wasm library for decompression. When false, it will fall back to the default JavaScript implementation WLZMAWeb.
Default
false
Methods
addAutoEventListener()
addAutoEventListener(
eventType
,eventListener
,signal
):void
Add event listener with automatic dispose.
Parameters
eventType
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
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
elNums
number
[]
Elements numbers.
Returns
number
[]
getBoundings()
getBoundings(
elNums
):Box3
Get bounding box for given element numbers.
Parameters
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
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
ids
Model version GUID or model version GUIDs with comma separator or GUIDs array.
string
| string
[]
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
server?
string
server URI.
Returns
SceneManager
setServerPath()
setServerPath(
path
?):SceneManager
Set server path to RESt point for data loading.
Parameters
path?
string
path to server REST point.
Returns
SceneManager
setToken()
setToken(
token
):SceneManager
Set acces token for manager`s requests.
Parameters
token
string
access token.
Returns
SceneManager
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
callbacks
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
elNums
number
[]
Elements numbers for for gathering.
callbacks
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
elNums
number
[]
Elements numbers for for gathering.
elVals
any
Elements values for gathering.
callbacks
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
ids
Model version GUID or model version GUIDs with comma separator or GUIDs array.
string
| string
[]
Returns
void
updateSelection()
updateSelection(
elNums
?,forceAdd
?,forceEvent
?,source
?):void
Select one or many elements in scene.
Parameters
elNums?
number
[]
Elements numbers for selection.
forceAdd?
boolean
Add new selection to current or replace.
forceEvent?
boolean
Force SceneEvents.Selected event dispatching.
source?
any
Source object which call updateSelection(). Will be pass in "selected" event.
Returns
void
Callbacks
onAllLoaded()
onAllLoaded(
allLoadedCallback
):SceneManager
Set callback function for event when all models will be loaded.
Parameters
allLoadedCallback
Function
function with plain Function signature.
Returns
SceneManager
onError()
onError(
errorCallback
):SceneManager
Set a callback for an event when a model will not be loaded due to an error.
Parameters
errorCallback
function with ErrorCallbackFunction signature.
Returns
SceneManager
onLoaded()
onLoaded(
loadedCallback
):SceneManager
Set a callback for an event when each model will be loaded.
Parameters
loadedCallback
function with LoadedCallbackFunction signature.
Returns
SceneManager
onNotFound()
onNotFound(
notFoundCallback
):SceneManager
Set a callback for an event when some model will not be founded.
Parameters
notFoundCallback
function with NotFoundCallbackFunction signature.
Returns
SceneManager
onProgress()
onProgress(
progressCallback
):SceneManager
Set a callback for an model loading progress event.
Parameters
progressCallback
function with ProgressCallbackFunction signature.
Returns
SceneManager