- 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]) ⇒ 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 |
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
- Classes
- GltfView
- GltfState
- new GltfState(view)
- gltfState.gltf
- gltfState.environment
- gltfState.userCamera
- gltfState.sceneIndex
- gltfState.cameraIndex
- gltfState.animationIndices
- gltfState.animationTimer
- gltfState.variant
- gltfState.renderingParameters
- renderingParameters.morphing
- renderingParameters.skinning
- renderingParameters.clearColor
- renderingParameters.exposure
- renderingParameters.usePunctual
- renderingParameters.useIBL
- renderingParameters.iblIntensity
- renderingParameters.renderEnvironmentMap
- renderingParameters.blurEnvironmentMap
- renderingParameters.toneMap
- renderingParameters.debugOutput
- renderingParameters.environmentRotation
- renderingParameters.useDirectionalLightsWithDisabledIBL
- renderingParameters.internalMSAA
- GltfState.ToneMaps
- GltfState.DebugOutput
- ResourceLoader
- UserCamera
- new UserCamera()
- userCamera.setVerticalFoV(yfov)
- userCamera.getPosition()
- userCamera.getRotation()
- userCamera.getLookDirection()
- userCamera.getTarget()
- userCamera.lookAt(from, to)
- userCamera.setPosition(position)
- userCamera.setTarget(target)
- userCamera.setRotation(yaw, pitch)
- userCamera.setDistanceFromTarget(distance, target)
- userCamera.zoomBy(value)
- userCamera.orbit(x, y)
- userCamera.pan(x, y)
- userCamera.fitViewToScene(gltf, sceneIndex)
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 ACES for a filmic effect
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
don't apply 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
DebugOutput enum for selecting debug output channels such as "NORMAL"
Kind: static property of GltfState
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
output metallic roughness
Kind: static property of DebugOutput
output the combined metallic roughness
Kind: static property of mr
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
output clearcoat lighting
Kind: static property of DebugOutput
output the combined clear coat
Kind: static property of clearcoat
output the clear coat factor
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
output sheen lighting
Kind: static property of DebugOutput
output the combined sheen
Kind: static property of sheen
output the sheen color
Kind: static property of sheen
output the sheen roughness
Kind: static property of sheen
output specular lighting
Kind: static property of DebugOutput
output the combined specular
Kind: static property of specular
output the specular factor
Kind: static property of specular
output the specular color
Kind: static property of specular
output tranmission lighting
Kind: static property of DebugOutput
output the combined transmission/volume
Kind: static property of transmission
output the transmission factor
Kind: static property of transmission
output the volume thickness
Kind: static property of transmission
output tranmission lighting
Kind: static property of DebugOutput
output the combined iridescence
Kind: static property of iridescence
output the iridescence factor
Kind: static property of iridescence
output the iridescence thickness
Kind: static property of iridescence
output the anisotropy strength
Kind: static property of anisotropy
output the final anisotropic direction as defined by the anisotropicTexture and anisotropic 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 | Description |
---|---|---|
view | Object |
the GltfView for which the resources are loaded |
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)
- .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 |