TwinfinityViewer
Index
Properties
Accessors
Methods
Properties
publicaddOrUpdateProductOptions
Type declaration
meshMerge: { deadline: number; sleepInMs: number }
deadline: number
sleepInMs: number
publicreadonlycanvas
publicreadonlygrid
publicreadonlykeyboard
publicreadonlyonPointerObservable
Subscribe to get access to pointer events (mouse, touchpad etc) and to determine what (if anything) a mouse click interacted with (what object was ‘picked’ in the 3D scene).
publicperformancebeta
Performance options.
Type declaration
forceRenderingTimeoutInMs: number
If <= 0 then frames are always rendered regardless if user is doing something or not. If > 0 and if idleRenderingTimeoutInMs > 0 then one frame is always rendered whenever this interval has passed. Default is 1500
idleRenderingTimeoutInMs: number
If <= 0 then frames are always rendered regardless if user is doing something or not. If > 0 and also forceRenderingTimeoutInMs > 0 then rendering stops when camera has been stationary for this many milliseconds. As soon as camera is moved rendering resumes in full again. Default is 10000
readonlyifc: { hideExpensiveMeshesOnCameraMove: { delayUntilCullingStops: number; isEnabled: boolean; keepMeshesNearPivotPoint: boolean; keepMeshesNearPointOfInterest: boolean; pickBoundingSphereRadius: number } }
Performance settings only applicable to IFC objects.
readonlyhideExpensiveMeshesOnCameraMove: { delayUntilCullingStops: number; isEnabled: boolean; keepMeshesNearPivotPoint: boolean; keepMeshesNearPointOfInterest: boolean; pickBoundingSphereRadius: number }
Hides expensive models when rotating or moving the camera to increase performance. A bounding sphere will be created around the pivot point when moving the camera, any mesh intersecting that sphere will not be hidden.
delayUntilCullingStops: number
Delay until culling stops after camera stops moving in miliseconds.
isEnabled: boolean
keepMeshesNearPivotPoint: boolean
Keeps meshes near the intersection between the pivot point and the model.
keepMeshesNearPointOfInterest: boolean
Keeps meshes near the intersecion between the 3d model and the cameras forward vector.
pickBoundingSphereRadius: number
Radius of bounding sphere that will be created around the pivot point to check for meshes to keep.
isBackfaceCullingEnabled: boolean
Specifies whether backface culling is enabled or not. Backface culling is a technique used in 3D computer graphics to improve rendering performance by discarding polygons that are not visible to the viewer. When backface culling is enabled, only the front-facing polygons are rendered, while the back-facing polygons are discarded. If geometries are not rendered correctly (they have “holes”), try setting to
false
. This will make rendering slower but geometries with incorrect polygon windingorder will be rendered correctly. This is a global setting and affects all geometries in the scene.isPaused: boolean
Set to
true
to disable rendering all together. Default istrue
.
publicreadonlyscene
publicreadonlystatistics
Type declaration
addOrUpdateProducts: { meshAllocateMemoryTime: number; meshCreationTime: number; meshMergeTime: number; totalTime: PerfCounter }
meshAllocateMemoryTime: number
meshCreationTime: number
meshMergeTime: number
totalTime: PerfCounter
mesh: { count: PerfCounter; triangleCount: PerfCounter; verticeCount: PerfCounter }
count: PerfCounter
triangleCount: PerfCounter
verticeCount: PerfCounter
publicreadonlyvisualSettings
Controls the visual settings of the viewer. See VisualSettings for more information.
Accessors
publicadaptiveMinZ
Controls wheter to automatically adapt the near plane of the camera to preserve precision when viewing far away IFC objects when there are no close IFC objects
Returns boolean
Parameters
enabled: boolean
Returns void
publicaxes
Returns boolean
Parameters
isEnabled: boolean
Returns void
publiccamera
Returns ViewerCamera
publicengine
Returns Engine
publicglobalLight
Returns HemisphericLight
publicifcRootNode
Returns TransformNode
publicisSkyboxEnabled
Returns boolean
Parameters
enabled: boolean
Returns void
publicisTouch
Returns boolean
publiclightingProperties
Gets the current lighting settings, allowing you to change them on the fly.
Returns IFCLightingEnvironment
publicselectables
Returns Selectables
Methods
publicaddOrReplaceMesh
Parameters
geometry3D: Geometry3d
Returns Mesh
publicaddOrUpdateEnvironment
Adds or updates the environment settings for the viewer.
Parameters
boundingInfo: BoundingInfo
AABB. This method calculates the starting position for the camera based on the provided
boundingInfo
. It ensures that the entireboundingInfo
is visible and sets the maximum z-coordinate of the camera to a value that allows everything to be visible. Additionally, it creates a skybox and sets its position and scaling based on theboundingInfo
. The skybox is only visible if the isSkyboxEnabled property is set totrue
.
Returns void
publicbuildingMeshes
Returns IterableIterator<Mesh>
publicclear
Returns void
publicenableDepthRenderer
Creates a renderer that that writes out the scenes depth to a render target texture which can be sampled for various uses like SSAO and line detection. Unlike Babylonjs standard depth renderer, this renderer applies a custom depth material to the IFC meshes to be able to dicard the depth writes for fragments that are invisible
Parameters
storeNonLinearDepth: boolean
Wheter or not the custom depth renderer material should write the depth linearly or logarithmic
Returns ShortFrustumDepthRenderer
The depth renderer
publicgetAndUpdatePickCamera
Parameters
optionalrayOrScreenCoordinate: Ray | CanvasPosition
Returns TargetCamera
publicgetTransparencyMode
Gets the currently active mode of transparency
Returns TransparencyMode
publicisDebugLayerEnabled
Enables or disables the debug layer. Will only be available if the module ‘import “@twinfinity/core/dist/Debug’ has also been added to the application. Adding it will generate extra .js files during bundling (which are quite large) and will increase build times. The extra files are loaded on demand though (when debug layer becomes enabled for the first time).
Parameters
optionalisEnabled: boolean
true
to enable. Otherwisefalse
. If Not specified then current state of debug layer is returned.
Returns Promise<boolean>
Promise which when resolved is
true
if layer is enabled. Otherwisefalse
publicpick
Parameters
pickingCamera: TargetCamera
textureSizePow2: number = 16
doIntersectionTestOnGeometry: boolean = false
saveRenderedGpuPickingSceneTexture: boolean = false
Returns PickResult
publicremoveMesh
Parameters
geometry3D: Geometry3dHandle
Returns undefined | Mesh
publicsetClipPlane
Enables or disables a clip plane, indexed from 1 to 6. Enabling a clip plane means that all geometry inside the clip plane will not be rendered. Note that this is only clipping for the IFC models, regular Babylon meshes needs to have clipping applied through the clip planes in Babylons scene Like this: https://doc.babylonjs.com/features/featuresDeepDive/scene/clipPlanes, the docs says that only 4 planes are available, but there are 6
Parameters
clipPlaneOptions: ClipPlaneOptions
An object with the options for enabling or disabling clip planes
Returns void
publicsetDitheringDepthDiscardMode
Set the currently used dither mode for solid objects that are dithered, never for transparent objects, even if the transparency mode is dithering
Parameters
ditherDiscardDepth: boolean
Wheter or not to discard fragments in the depth shader that are dithered, this is needed for transparent objects to not write to the depth buffer
Returns void
publicsetDitheringMode
Set the dither mode and animated frames used for dithering
Parameters
ditherMode: DitheringTextureMode
What dithering mode to use, bayer uses a bayer matrix to determine which pixels to render opaque, blue noise uses a blue noise texture
animatedFrames: number
How many frames to use for the dithering animation when moving the camera, if 1 then no animation is used. Works best with Blue Noise
Returns void
publicsetTransparencyMode
Changes how transparency is handled for transparent IFC objects
Parameters
transparencyMode: TransparencyMode
The type of rendering that will be used for all transparent IFC objects, dithering means that pixels are rendered opaque but skipping every few pixels in a screen pattern depending on the opacity Seethrough is normal alpha blending
Returns void
publicwakeRenderLoop
Forces render loop to temporarily wake up if it is sleeping
Returns void
publicstaticcreate
Parameters
canvas: HTMLCanvasElement
materials: Materials
runRenderLoop: RunRenderLoopHandler
Returns TwinfinityViewer
Represents a TwinfinityViewer, which is responsible for rendering and interacting with a 3D scene. There can only be one TwinfinityViewer.