- GltfView
GltfView represents a view on a gltf, e.g. in a canvas
- GltfState
GltfState containing a state for visualization in GltfView
- ResourceLoader
ResourceLoader can be used to load resources for the GltfState that are then used to display the loaded data with GltfView
- UserCamera
GltfView represents a view on a gltf, e.g. in a canvas
Kind: global class
GltfView representing one WebGl 2.0 context or in other words one 3D rendering of the Gltf. You can create multiple views for example when multiple canvases should be shown on the same webpage.
Param | Type | Description |
---|---|---|
context | * |
WebGl 2.0 context. Get it from a canvas with canvas.getContext("webgl2") |
gltfView.createState() ⇒ GltfState
createState constructs a new GltfState for the GltfView. The resources referenced in a gltf state can directly be stored as resources on the WebGL context of GltfView, therefore GltfStates cannot not be shared between GltfViews.
Kind: instance method of GltfView
Returns: GltfState
- GltfState
gltfView.createResourceLoader([externalDracoLib], [externalKtxLib], [libPath]) ⇒ ResourceLoader
createResourceLoader creates a resource loader with which glTFs and environments can be loaded for the view
Kind: instance method of GltfView
Returns: ResourceLoader
- ResourceLoader
Param | Type | Description |
---|---|---|
[externalDracoLib] | Object |
optional object of an external Draco library, e.g. from a CDN |
[externalKtxLib] | Object |
optional object of an external KTX library, e.g. from a CDN |
[libPath] | string |
optional path to the libraries. Used to define the path to the WASM files on repackaging |
renderFrame to the context's default frame buffer Call this function in the javascript animation update loop for continuous rendering to a canvas
Kind: instance method of GltfView
Param | Type | Description |
---|---|---|
state | * |
GltfState that is be used for rendering |
width | * |
of the viewport |
height | * |
of the viewport |
gatherStatistics collects information about the GltfState such as the number of rendered meshes or triangles
Kind: instance method of GltfView
Returns: Object
- an object containing statistics information
Param | Type | Description |
---|---|---|
state | * |
GltfState about which the statistics should be collected |
GltfState containing a state for visualization in GltfView
Kind: global class
- GltfState
GltfState represents all state that can be visualized in a view. You could have multiple GltfStates configured and switch between them on demand.
Param | Type | Description |
---|---|---|
view | * |
GltfView to which this state belongs |
loaded gltf data @see ResourceLoader.loadGltf
Kind: instance property of GltfState
loaded environment data @see ResourceLoader.loadEnvironment
Kind: instance property of GltfState
user camera @see UserCamera, convenient camera controls
Kind: instance property of GltfState
gltf scene that is visible in the view
Kind: instance property of GltfState
index of the camera that is used to render the view. a value of 'undefined' enables the user camera
Kind: instance property of GltfState
indices of active animations
Kind: instance property of GltfState
animation timer allows to control the animation time
Kind: instance property of GltfState
KHR_materials_variants
Kind: instance property of GltfState
parameters used to configure the rendering
Kind: instance property of GltfState
morphing between vertices
Kind: static property of renderingParameters
skin / skeleton
Kind: static property of renderingParameters
clear color expressed as list of ints in the range [0, 255]
Kind: static property of renderingParameters
exposure factor
Kind: static property of renderingParameters
KHR_lights_punctual
Kind: static property of renderingParameters
image based lighting
Kind: static property of renderingParameters
image based lighting intensity
Kind: static property of renderingParameters
render the environment map in the background
Kind: static property of renderingParameters
apply blur to the background environment map
Kind: static property of renderingParameters
which tonemap to use, use KHR_PBR_NEUTRAL for best color reproduction
Kind: static property of renderingParameters
render some debug output channes, such as for example the normals
Kind: static property of renderingParameters
By default the front face of the environment is +Z (90) Front faces: +X = 0 +Z = 90 -X = 180 -Z = 270
Kind: static property of renderingParameters
If this is set to true, directional lights will be generated if IBL is disabled
Kind: static property of renderingParameters
MSAA used for cases which are not handled by the browser (e.g. Transmission)
Kind: static property of renderingParameters
ToneMaps enum for the different tonemappings that are supported by gltf sample viewer
Kind: static property of GltfState
Khronos PBR neutral tone mapping, see https://github.com/KhronosGroup/ToneMapping, https://modelviewer.dev/examples/tone-mapping
Kind: static property of ToneMaps
ACES sRGB RRT+ODT implementation for 3D Commerce based on Stephen Hill's implementation with a exposure factor of 1.0 / 0.6
Kind: static property of ToneMaps
fast implementation of the ACES sRGB RRT+ODT based on Krzysztof Narkowicz' implementation
Kind: static property of ToneMaps
more accurate implementation of the ACES sRGB RRT+ODT based on Stephen Hill's implementation
Kind: static property of ToneMaps
Linear mapping, clamped at 1.0 per channel
Kind: static property of ToneMaps
DebugOutput enum for selecting debug output channels such as "NORMAL"
Kind: static property of GltfState
- .DebugOutput
standard rendering - debug output is disabled
Kind: static property of DebugOutput
generic debug outputs
Kind: static property of DebugOutput
output the texture coordinates 0
Kind: static property of generic
output the texture coordinates 1
Kind: static property of generic
output the world space normals (i.e. with TBN applied)
Kind: static property of generic
output the normal from the TBN
Kind: static property of generic
output the tangent from the TBN
Kind: static property of generic
output the bitangent from the TBN
Kind: static property of generic
output the world space normals (i.e. with TBN applied)
Kind: static property of generic
output the alpha value
Kind: static property of generic
output the occlusion value
Kind: static property of generic
output the emissive value
Kind: static property of generic
metallic roughness
Kind: static property of DebugOutput
output the base color value
Kind: static property of mr
output the metallic value from pbr metallic roughness
Kind: static property of mr
output the roughness value from pbr metallic roughness
Kind: static property of mr
KHR_materials_clearcoat
Kind: static property of DebugOutput
output the clear coat strength
Kind: static property of clearcoat
output the clear coat roughness
Kind: static property of clearcoat
output the clear coat normal
Kind: static property of clearcoat
KHR_materials_sheen
Kind: static property of DebugOutput
output the sheen color
Kind: static property of sheen
output the sheen roughness
Kind: static property of sheen
KHR_materials_specular
Kind: static property of DebugOutput
output the specular strength
Kind: static property of specular
output the specular color
Kind: static property of specular
KHR_materials_transmission
Kind: static property of DebugOutput
output the transmission strength
Kind: static property of transmission
output the volume thickness
Kind: static property of transmission
KHR_materials_diffuse_tranmission
Kind: static property of DebugOutput
output the diffuse tranmission strength
Kind: static property of diffuseTransmission
output the diffuse tranmission color factor
Kind: static property of diffuseTransmission
KHR_materials_iridescence
Kind: static property of DebugOutput
output the iridescence strength
Kind: static property of iridescence
output the iridescence thickness
Kind: static property of iridescence
KHR_materials_anisotropy
Kind: static property of DebugOutput
output the anisotropic strength
Kind: static property of anisotropy
output final direction as defined by the anisotropyTexture and rotation
Kind: static property of anisotropy
ResourceLoader can be used to load resources for the GltfState that are then used to display the loaded data with GltfView
Kind: global class
ResourceLoader class that provides an interface to load resources into the view. Typically this is created with GltfView.createResourceLoader() You cannot share resource loaders between GltfViews as some of the resources are allocated directly on the WebGl2 Context
Param | Type | Default | Description |
---|---|---|---|
view | Object |
the GltfView for which the resources are loaded | |
libPath | String |
./libs/ |
path to the lib folder. This can be used to find the WASM files if sample viewer is repackaged |
loadGltf asynchroneously and create resources for rendering
Kind: instance method of ResourceLoader
Returns: Promise
- a promise that fulfills when the gltf file was loaded
Param | Type | Description |
---|---|---|
gltfFile | String | ArrayBuffer | File |
the .gltf or .glb file either as path or as preloaded resource. In node.js environments, only ArrayBuffer types are accepted. |
[externalFiles] | Array.<File> |
additional files containing resources that are referenced in the gltf |
loadEnvironment asynchroneously, run IBL sampling and create resources for rendering
Kind: instance method of ResourceLoader
Returns: Promise
- a promise that fulfills when the environment file was loaded
Param | Type | Description |
---|---|---|
environmentFile | String | ArrayBuffer | File |
the .hdr file either as path or resource |
[lutFiles] | Object |
object containing paths or resources for the environment look up textures. Keys are lut_ggx_file, lut_charlie_file and lut_sheen_E_file |
initKtxLib must be called before loading gltf files with ktx2 assets
Kind: instance method of ResourceLoader
Param | Type | Description |
---|---|---|
[externalKtxLib] | Object |
external ktx library (for example from a CDN) |
initDracoLib must be called before loading gltf files with draco meshes
Kind: instance method of ResourceLoader
Param | Type | Description |
---|---|---|
[externalDracoLib] | * |
external draco library (for example from a CDN) |
Kind: global class
- UserCamera
- new UserCamera()
- .setVerticalFoV(yfov)
- .getPosition()
- .getRotation()
- .getLookDirection()
- .getTarget()
- .lookAt(from, to)
- .setPosition(position)
- .setTarget(target)
- .setRotation(yaw, pitch)
- .setDistanceFromTarget(distance, target)
- .zoomBy(value)
- .orbit(x, y)
- .pan(x, y)
- .resetView(gltf, sceneIndex)
- .fitViewToScene(gltf, sceneIndex)
Create a new user camera.
Sets the vertical FoV of the user camera.
Kind: instance method of UserCamera
Param | Type |
---|---|
yfov | number |
Returns the current position of the user camera as a vec3.
Kind: instance method of UserCamera
Returns the current rotation of the user camera as quat.
Kind: instance method of UserCamera
Returns the normalized direction the user camera looks at as vec3.
Kind: instance method of UserCamera
Returns the current target the camera looks at as vec3. This multiplies the viewing direction with the distance. For distance 0 the normalized viewing direction is used.
Kind: instance method of UserCamera
Look from user camera to target. This changes the transformation of the user camera.
Kind: instance method of UserCamera
Param | Type |
---|---|
from | vec3 |
to | vec3 |
Sets the position of the user camera.
Kind: instance method of UserCamera
Param | Type |
---|---|
position | vec3 |
This rotates the user camera towards the target and sets the position of the user camera according to the current distance.
Kind: instance method of UserCamera
Param | Type |
---|---|
target | vec3 |
Sets the rotation of the camera. Yaw and pitch in euler angles (degrees).
Kind: instance method of UserCamera
Param | Type |
---|---|
yaw | number |
pitch | number |
Transforms the user camera to look at a target from a specfic distance using the current rotation. This will only change the position of the user camera, not the rotation. Use this function to set the distance.
Kind: instance method of UserCamera
Param | Type |
---|---|
distance | number |
target | vec3 |
Zoom exponentially according to this.zoomFactor and this.zoomExponent. The default zoomFactor provides good zoom speed for values from [-1,1].
Kind: instance method of UserCamera
Param | Type |
---|---|
value | number |
Orbit around the target. x and y should be in radient and are added to the current rotation. The rotation around the x-axis is limited to 180 degree. The axes are inverted: e.g. if y is positive the camera will look further down.
Kind: instance method of UserCamera
Param | Type |
---|---|
x | number |
y | number |
Pan the user camera. The axes are inverted: e.g. if y is positive the camera will move down.
Kind: instance method of UserCamera
Param | Type |
---|---|
x | number |
y | number |
Calculates a camera position which looks at the center of the scene from an appropriate distance. This calculates near and far plane as well.
Kind: instance method of UserCamera
Param | Type |
---|---|
gltf | Gltf |
sceneIndex | number |
Fit view to updated canvas size without changing rotation if distance is incorrect
Kind: instance method of UserCamera
Param | Type |
---|---|
gltf | Gltf |
sceneIndex | number |