All type names in this reference belong to the Filament namespace. For example, init actually refers to Filament.init.
Low level buffer wrapper.
- bufferDescriptor.getBytes()
- Gets a view of the WASM heap referenced by the buffer descriptor.
- returns Uint8Array
Clients should use the Buffer helper function to contruct BufferDescriptor objects.
Represents a single GPU buffer.
- bufferObject.setBuffer(engine, buffer, byteOffset)
- engine Engine
- buffer asset string, or Uint8Array, or Buffer
- byteOffset non-negative integer
Represents the eye through which the scene is viewed.
See also the Engine methods createCamera
and destroyCamera
.
Central manager and resource owner.
- engine.addEntities(entities)
- entities array of entities
- Engine.create(canvas, options)
- Creates an Engine instance for the given canvas.
- canvas the canvas DOM element
- options optional WebGL 2.0 context configuration
- returns an instance of Engine
- engine.createAssetLoader()
- engine.createCamera(entity)
- entity the Entity to add the camera component to
- returns an instance of Camera
- engine.createIblFromKtx1(buffer, options)
- Utility that creates an [IndirectLight] from a KTX file.
- buffer asset string, or Uint8Array, or Buffer with KTX file contents
- options Options dictionary.
- returns IndirectLight
- engine.createMaterial(package)
- package asset string, or Uint8Array, or Buffer with filamat contents
- returns an instance of createMaterial
- engine.createRenderer()
- engine.createScene()
- returns an instance of Scene
- engine.createSkyFromKtx1(buffer, options)
- Utility function that creates a [Skybox] from a KTX file.
- buffer asset string, or Uint8Array, or Buffer with KTX file contents
- options Options dictionary.
- returns Skybox
- engine.createSwapChain()
- engine.createTextureFromJpeg(buffer, options)
- Creates a 2D [Texture] from the contents of a JPEG file.
- buffer asset string, or Uint8Array, or Buffer with JPEG file contents
- options JavaScript object with optional
srgb
and nomips
keys.
- returns Texture
- engine.createTextureFromKtx1(buffer, options)
- Utility function that creates a [Texture] from a KTX1 file.
- buffer asset string, or Uint8Array, or Buffer with KTX1 file contents
- options Options dictionary.
- returns Texture
- engine.createTextureFromKtx2(buffer, options)
- Utility function that creates a [Texture] from a KTX2 file.
- buffer asset string, or Uint8Array, or Buffer with KTX2 file contents
- options Options dictionary.
- returns Texture
- engine.createTextureFromPng(buffer, options)
- Creates a 2D [Texture] from the raw contents of a PNG file.
- buffer asset string, or Uint8Array, or Buffer with PNG file contents
- options object with optional
srgb
, noalpha
, and nomips
keys.
- returns Texture
- engine.createView()
- returns an instance of View
- Engine.destroy(engine)
- Destroys an engine instance and cleans up resources.
- engine the instance to destroy
- engine.destroyCameraComponent(camera)
- camera an Entity with a camera component
- engine.destroyColorGrading(entity)
- engine.destroyEntity(entity)
- engine.destroyIndexBuffer(ib)
- engine.destroyIndirectLight(light)
- engine.destroyMaterial(material)
- engine.destroyMaterial(instance)
- engine.destroyRenderTarget(rt)
- engine.destroyRenderer(renderer)
- engine.destroyScene(scene)
- scene an instance of Scene
- engine.destroySkybox(skybox)
- engine.destroySwapChain(swapChain)
- engine.destroyTexture(texture)
- engine.destroyVertexBuffer(vb)
- engine.destroyView(view)
- engine.getCameraComponent()
- engine.getEntityManager()
- engine.getLightManager()
- engine.getRenderableManager()
- engine.getTransformManager()
- engine.loadFilamesh(buffer, definstance, matinstances)
- Consumes the contents of a filamesh file and creates a renderable.
- buffer asset string, or Uint8Array, or Buffer with filamesh contents
- definstance Optional default MaterialInstance
- matinstances Optional in-out object that gets populated with a name-to-MaterialInstance mapping. Clients can also optionally provide individual material instances using this argument.
- returns JavaScript object with keys
renderable
, vertexBuffer
, and indexBuffer
. These are of type Entity, VertexBuffer, and IndexBuffer.
- engine.removeEntities(entities)
- entities array of entities
- engine.setAmbientOcclusionOptions()
- engine.setBloomOptions()
- engine.setClearOptions(overrides)
- overrides Dictionary with one or more of the following properties: clearColor, clear, discard.
- engine.setDepthOfFieldOptions()
- engine.setFogOptions()
- engine.setGuardBandOptions()
- engine.setMultiSampleAntiAliasingOptions()
- engine.setScreenSpaceReflectionsOptions()
- engine.setShadowOptions(instance, overrides)
- instance Instance of a light component obtained from
getInstance
.
- overrides Dictionary with one or more of the following properties: mapSize, shadowCascades, constantBias, normalBias, shadowFar, shadowNearHint, shadowFarHint, stable, polygonOffsetConstant, polygonOffsetSlope, \
- engine.setStereoscopicOptions()
- engine.setTemporalAntiAliasingOptions()
- engine.setVignetteOptions()
Handle to an object consisting of a set of components.
To create an entity with no components, use EntityManager.
TODO: It would be better to expose these as JS numbers rather than as JS objects.
This would also be more consistent with Filament's Java bindings.
Singleton used for constructing entities in Filament's ECS.
- entityManager.create()
- returns an Entity without any components
- EntityManager.get()
- Gets the singleton entity manager instance.
- returns the one and only entity manager
Represents the six planes of a truncated viewing pyramid
Utility class for constructing spheres (requires glMatrix).
The constructor takes an integer subdivision level, with 0 being an icosahedron.
Exposes three arrays as properties:
icosphere.vertices
Float32Array of XYZ coordinates.
icosphere.tangents
Uint16Array (interpreted as half-floats) encoding the surface orientation
as quaternions.
icosphere.triangles
Uint16Array with triangle indices.
Array of 16-bit or 32-bit unsigned integers consumed by the GPU.
- indexBuffer.setBuffer(engine, buffer, byteOffset)
- engine Engine
- buffer asset string, or Uint8Array, or Buffer
- byteOffset non-negative integer
In-memory representation of a KTX file.
- ktx1Bundle.getArrayLength()
- Obtains length of the texture array.
- returns The number of elements in the texture array
- ktx1Bundle.getCompressedPixelDataType()
- ktx1Bundle.getInternalFormat(srgb)
- ktx1Bundle.getMetadata(key)
- Obtains arbitrary metadata from the KTX file.
- key string
- returns string
- ktx1Bundle.getPixelDataFormat()
- ktx1Bundle.getPixelDataType()
- ktx1Bundle.info()
- Obtains properties of the KTX header.
- returns The KtxInfo property accessor object.
- ktx1Bundle.info()
- Obtains properties of the KTX header.
- returns The KtxInfo property accessor object.
- ktx1Bundle.isCompressed()
Most clients should use one of the create*FromKtx
utility methods in the JavaScript Engine
wrapper rather than interacting with Ktx1Bundle
directly.
Property accessor for KTX1 header.
- ktxInfo.createAsset(buffer)
- ktxInfo.createInstancedAsset(buffer)
For example, Ktx1Bundle.info().pixelWidth
. See the
KTX spec for the list of
properties.
Component instance returned by LightManager
- lightManager$Instance.delete()
- Frees an instance obtained via
getInstance
Be sure to call the instance's delete
method when you're done with it.
Low level pixel buffer wrapper.
- pixelBufferDescriptor.getBytes()
- Gets a view of the WASM heap referenced by the buffer descriptor.
- returns Uint8Array
Clients should use the PixelBuffer helper function to contruct PixelBufferDescriptor objects.
Allows access to properties of drawable objects.
- renderableManager.getInstance(entity)
- Gets an instance of the renderable component for an entity.
- entity an Entity
- returns a renderable component
Component instance returned by RenderableManager
- renderableManager$Instance.delete()
- Frees an instance obtained via
getInstance
Be sure to call the instance's delete
method when you're done with it.
Represents the platform's native window.
- renderer.render(swapChain, view)
- requests rendering for a single frame on the given [View]
- swapChain the SwapChain corresponding to the canvas
- view the View corresponding to the canvas
See also the Engine methods createRenderer
and destroyRenderer
.
Flat container of renderables and lights.
See also the Engine methods createScene
and destroyScene
.
Represents the platform's native rendering surface.
See also the Engine methods createSwapChain
and destroySwapChain
.
2D image or cubemap that can be sampled by the GPU, possibly mipmapped.
Adds transform components to entities.
- transformManager.getInstance(entity)
- Gets an instance representing the transform component for an entity.
- entity an Entity
- returns a transform component that can be passed to
setTransform
.
- transformManager.setTransform(instance, matrix)
- Sets the mat4 value of a transform component.
- instance The transform instance of entity, obtained via
getInstance
.
- matrix Array of 16 numbers (mat4)
Component instance returned by TransformManager
- transformManager$Instance.delete()
- Frees an instance obtained via
getInstance
- transformManager$Instance.getInstance(entity)
- Gets an instance of the light component for an entity.
- entity an Entity
- returns a light source component
Be sure to call the instance's delete
method when you're done with it.
Bundle of buffers and associated vertex attributes.
- vertexBuffer.setBufferAt(engine, bufferIndex, buffer, byteOffset)
- engine Engine
- bufferIndex non-negative integer
- buffer asset string, or Uint8Array, or Buffer
- byteOffset non-negative integer
Encompasses all the state needed for rendering a Scene.
A view is associated with a particular Scene, Camera, and viewport.
See also the Engine methods createView
and destroyView
.
function Buffer(typedarray)
Constructs a BufferDescriptor by copying a typed array into the WASM heap.
- typedarray
- Data to consume (e.g. Uint8Array, Uint16Array, Float32Array)
- returns
Constructs a PixelBufferDescriptor for compressed texture
- typedarray
- Data to consume (e.g. Uint8Array, Uint16Array, Float32Array)
- cdatatype
- faceSize
- Number of bytes in each face (cubemaps only)
- returns
data by copying a typed array into the WASM heap.
function PixelBuffer(typedarray, format, datatype)
Constructs a PixelBufferDescriptor by copying a typed array into the WASM heap.
- typedarray
- Data to consume (e.g. Uint8Array, Uint16Array, Float32Array)
- format
- datatype
- returns
function fetch(assets, onDone, onFetched)
Downloads assets and invokes a callback when done.
- assets
- Array of strings containing URL's of required assets.
- onDone
- callback that gets invoked after all assets have been downloaded.
- onFetched
- optional callback that's invoked after each asset is downloaded.
This utility consumes an array of URI strings and invokes callbacks after each asset is
downloaded. Additionally, each downloaded asset becomes available in the Filament.assets
global object, which is a mapping from URI strings to Uint8Array
. If desired, clients can
pre-populate entries in Filament.assets
to circumvent HTTP requests (this should be done after
calling Filament.init
).
This function is used internally by Filament.init
and gltfio$FilamentAsset.loadResources
.
Generate a file suffix according to the texture format.
- desiredFormats
- space-delimited string of desired formats
- returns
- empty string if there is no intersection of supported and desired formats.
Consumes a string describing desired formats and produces a file suffix depending on
which (if any) of the formats are actually supported by the WebGL implementation. This is
useful for compressed textures. For example, some platforms accept ETC and others accept S3TC.
Queries WebGL to check which compressed formats are supported.
- returns
- object with boolean values and the following keys: s3tc, astc, etc
function init(assets, onready)
Downloads assets, loads the Filament module, and invokes a callback when done.
- assets
- Array of strings containing URL's of required assets.
- onready
- callback that gets invoked after all assets have been downloaded and the Filament WebAssembly module has been loaded.
All JavaScript clients must call the init function, passing in a list of asset URL's and a
callback. This callback gets invoked only after all assets have been downloaded and the Filament
WebAssembly module has been loaded. Clients should only pass asset URL's that absolutely must
be ready at initialization time.
When the callback is called, each downloaded asset is available in the Filament.assets
global
object, which contains a mapping from URL's to Uint8Array objects.
Extends the glMatrix math library.
Filament does not require its clients to use glMatrix, but if its usage is detected then
the init function will automatically call loadMathExtensions
.
This defines the following functions:
- vec4.packSnorm16 can be used to create half-floats (see packSnorm16)
- mat3.fromRotation now takes an arbitrary axis
Converts a float in [-1, +1] into a half-float.
- LINEAR
- ACES_LEGACY
- ACES
- FILMIC
- DISPLAY_RANGE
- LESS_EQUAL
- GREATER_EQUAL
- LESS
- GREATER
- EQUAL
- NOT_EQUAL
- ALWAYS
- NEVER
- EAC_R11
- EAC_R11_SIGNED
- EAC_RG11
- EAC_RG11_SIGNED
- ETC2_RGB8
- ETC2_SRGB8
- ETC2_RGB8_A1
- ETC2_SRGB8_A1
- ETC2_EAC_RGBA8
- ETC2_EAC_SRGBA8
- DXT1_RGB
- DXT1_RGBA
- DXT3_RGBA
- DXT5_RGBA
- DXT1_SRGB
- DXT1_SRGBA
- DXT3_SRGBA
- DXT5_SRGBA
- RGBA_ASTC_4x4
- RGBA_ASTC_5x4
- RGBA_ASTC_5x5
- RGBA_ASTC_6x5
- RGBA_ASTC_6x6
- RGBA_ASTC_8x5
- RGBA_ASTC_8x6
- RGBA_ASTC_8x8
- RGBA_ASTC_10x5
- RGBA_ASTC_10x6
- RGBA_ASTC_10x8
- RGBA_ASTC_10x10
- RGBA_ASTC_12x10
- RGBA_ASTC_12x12
- SRGB8_ALPHA8_ASTC_4x4
- SRGB8_ALPHA8_ASTC_5x4
- SRGB8_ALPHA8_ASTC_5x5
- SRGB8_ALPHA8_ASTC_6x5
- SRGB8_ALPHA8_ASTC_6x6
- SRGB8_ALPHA8_ASTC_8x5
- SRGB8_ALPHA8_ASTC_8x6
- SRGB8_ALPHA8_ASTC_8x8
- SRGB8_ALPHA8_ASTC_10x5
- SRGB8_ALPHA8_ASTC_10x6
- SRGB8_ALPHA8_ASTC_10x8
- SRGB8_ALPHA8_ASTC_10x10
- SRGB8_ALPHA8_ASTC_12x10
- SRGB8_ALPHA8_ASTC_12x12
- NONE
- FRONT
- BACK
- FRONT_AND_BACK
- FEATURE_LEVEL_1
- FEATURE_LEVEL_2
- LEFT
- RIGHT
- BOTTOM
- TOP
- FAR
- NEAR
- SUCCESS
- COMPRESSED_TRANSCODE_FAILURE
- UNCOMPRESSED_TRANSCODE_FAILURE
- FORMAT_UNSUPPORTED
- FORMAT_ALREADY_REQUESTED
- SUN
- DIRECTIONAL
- POINT
- FOCUSED_SPOT
- SPOT
- NEAREST
- LINEAR
- NEAREST_MIPMAP_NEAREST
- LINEAR_MIPMAP_NEAREST
- NEAREST_MIPMAP_LINEAR
- LINEAR_MIPMAP_LINEAR
- R
- R_INTEGER
- RG
- RG_INTEGER
- RGB
- RGB_INTEGER
- RGBA
- RGBA_INTEGER
- DEPTH_COMPONENT
- DEPTH_STENCIL
- ALPHA
- UBYTE
- BYTE
- USHORT
- SHORT
- UINT
- INT
- HALF
- FLOAT
- UINT_10F_11F_11F_REV
- USHORT_565
- COLOR0
- COLOR1
- COLOR2
- COLOR3
- COLOR
- DEPTH
- POINTS
- LINES
- LINE_STRIP
- TRIANGLES
- TRIANGLE_STRIP
- sRGB
- LINEAR
- PREMULTIPLIED_sRGB
- PREMULTIPLIED_LINEAR
- FRONT
- BACK
- FRONT_AND_BACK
- KEEP
- ZERO
- REPLACE
- INCR_CLAMP
- INCR_WRAP
- DECR_CLAMP
- DECR_WRAP
- INVERT
- POSITIVE_X
- NEGATIVE_X
- POSITIVE_Y
- NEGATIVE_Y
- POSITIVE_Z
- NEGATIVE_Z
- SAMPLER_2D
- SAMPLER_CUBEMAP
- SAMPLER_EXTERNAL
- DEFAULT
- COLOR_ATTACHMENT
- DEPTH_ATTACHMENT
- STENCIL_ATTACHMENT
- UPLOADABLE
- SAMPLEABLE
- BLIT_SRC
- BLIT_DST
- SUBPASS_INPUT
- DEFAULT
- TWO_PASSES_ONE_SIDE
- TWO_PASSES_TWO_SIDES
- POSITION
- TANGENTS
- COLOR
- UV0
- UV1
- BONE_INDICES
- BONE_WEIGHTS
- CUSTOM0
- CUSTOM1
- CUSTOM2
- CUSTOM3
- CUSTOM4
- CUSTOM5
- CUSTOM6
- CUSTOM7
- MORPH_POSITION_0
- MORPH_POSITION_1
- MORPH_POSITION_2
- MORPH_POSITION_3
- MORPH_TANGENTS_0
- MORPH_TANGENTS_1
- MORPH_TANGENTS_2
- MORPH_TANGENTS_3
- BYTE
- BYTE2
- BYTE3
- BYTE4
- UBYTE
- UBYTE2
- UBYTE3
- UBYTE4
- SHORT
- SHORT2
- SHORT3
- SHORT4
- USHORT
- USHORT2
- USHORT3
- USHORT4
- INT
- UINT
- FLOAT
- FLOAT2
- FLOAT3
- FLOAT4
- HALF
- HALF2
- HALF3
- HALF4
- CLAMP_TO_EDGE
- REPEAT
- MIRRORED_REPEAT