ThermionViewerWasm class

A ThermionViewer implementation that forwards calls to the (Emscripten-generated) ThermionDart JS module.

Implemented types

Constructors

ThermionViewerWasm({JSObject? module, String moduleName = "thermion_dart", String? assetPathPrefix})
Construct an instance of this class by explicitly passing the module instance via the module property, or by specifying moduleName, being the name of the window property where the module has already been loaded.

Properties

gizmo AbstractGizmo?
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
initialized Future<bool>
no setteroverride
pickResult Stream<FilamentPickResult>
The result(s) of calling pick (see below). This may be a broadcast stream, so you should ensure you have subscribed to this stream before calling pick. If pick is called without an active subscription to this stream, the results will be silently discarded.
no setteroverride
rendering bool
Whether the controller is currently rendering at framerate.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scene Scene
The Scene holds all loaded entities/lights.
no setteroverride

Methods

addAnimationComponent(ThermionEntity entity) Future
An entity will only be animatable after an animation component is attached. Any calls to playAnimation/setBoneAnimation/setMorphAnimation will have no visual effect until addAnimationComponent has been called on the instance.
override
addBoneAnimation(ThermionEntity entity, BoneAnimationData animation, {int skinIndex = 0, double fadeInInSecs = 0.0, double fadeOutInSecs = 0.0, double maxDelta = 1.0}) Future
Enqueues and plays the animation for the specified bone(s). By default, frame data is interpreted as being in parent bone space; a 45 degree around Y means the bone will rotate 45 degrees around the Y axis of the parent bone in its current orientation. (i.e NOT the parent bone's rest position!). Currently, only Space.ParentBone and Space.Model are supported; if you want to transform to another space, you will need to do so manually.
override
addCollisionComponent(ThermionEntity entity, {void callback(int entityId1, int entityId2)?, bool affectsTransform = false}) Future
Makes entity collidable. This allows you to call testCollisions with any other entity ("entity B") to see if entity has collided with entity B. The callback will be invoked if so. Alternatively, if affectsTransform is true and this entity collides with another entity, any queued position updates to the latter entity will be ignored.
override
addLight(LightType type, double colour, double intensity, double posX, double posY, double posZ, double dirX, double dirY, double dirZ, {double falloffRadius = 1.0, double spotLightConeInner = pi / 8, double spotLightConeOuter = pi / 4, double sunAngularRadius = 0.545, double sunHaloSize = 10.0, double sunHaloFallof = 80.0, bool castShadows = true}) Future<ThermionEntity>
Add a light to the scene. See LightManager.h for details Note that sunAngularRadius is in degrees, whereas spotLightConeInner and spotLightConeOuter are in radians
override
clearBackgroundImage() Future
Removes the background image.
override
clearEntities() Future
Removes/destroys all renderable entities from the scene (including cameras). All ThermionEntity handles will no longer be valid after this method is called; ensure you immediately discard all references to all entities once this method is complete.
override
clearLights() Future
Remove all lights (excluding IBL) from the scene.
override
createGeometry(List<double> vertices, List<int> indices, {String? materialPath, PrimitiveType primitiveType = PrimitiveType.TRIANGLES}) Future
Creates a (renderable) entity with the specified geometry and adds to the scene.
override
createInstance(ThermionEntity entity) Future<ThermionEntity>
Create a new instance of entity.
override
createSwapChain(int width, int height) Future
destroySwapChain() Future
dispose() Future
Destroys/disposes the viewer (including the entire scene). You cannot use the viewer after calling this method.
override
getAnimationCount(ThermionEntity entity) Future<int>
getAnimationDuration(ThermionEntity entity, int animationIndex) Future<double>
Returns the length (in seconds) of the animation at the given index.
override
getAnimationNames(ThermionEntity entity) Future<List<String>>
Gets the names of all glTF animations embedded in the specified entity.
override
getBone(ThermionEntity parent, int boneIndex, {int skinIndex = 0}) Future<ThermionEntity>
Gets the entity representing the bone at boneIndex/skinIndex. The returned entity is only intended for use with getWorldTransform.
override
getBoneNames(ThermionEntity entity, {int skinIndex = 0}) Future<List<String>>
Gets the names of all bones for the armature at skinIndex under the specified entity.
override
getBones(ThermionEntity entity, {int skinIndex = 0}) Future<List<ThermionEntity>>
getCameraCullingFar() Future<double>
Get the distance (in world units) to the far culling plane for the active camera.
override
getCameraCullingNear() Future<double>
Get the distance (in world units) to the near culling plane for the active camera.
override
getCameraCullingProjectionMatrix() Future<Matrix4>
Get the camera's culling projection matrix. See Camera.h for more details.
override
getCameraFrustum() Future<Frustum>
Get the camera's culling frustum in world space. Returns a (vector_math) Frustum instance where plane0-plane6 define the left, right, bottom, top, far and near planes respectively. See Camera.h and (filament) Frustum.h for more details.
override
getCameraModelMatrix() Future<Matrix4>
Get the camera's model matrix.
override
getCameraPosition() Future<Vector3>
Get the camera position in world space.
override
getCameraProjectionMatrix() Future<Matrix4>
Get the camera's projection matrix. See Camera.h for more details.
override
getCameraRotation() Future<Matrix3>
Get the camera rotation matrix.
override
getCameraViewMatrix() Future<Matrix4>
Get the camera's view matrix. See Camera.h for more details.
override
getChildEntities(ThermionEntity parent, bool renderableOnly) Future<List<ThermionEntity>>
Returns all child entities under parent.
override
getChildEntity(ThermionEntity parent, String childName) Future<ThermionEntity>
Finds the child entity named childName associated with the given parent. Usually, parent will be the return value from loadGlb/loadGltf and childName will be the name of a node/mesh.
override
getChildEntityNames(ThermionEntity entity, {bool renderableOnly = true}) Future<List<String>>
List the name of all child entities under the given entity.
override
getInstanceCount(ThermionEntity entity) Future<int>
Returns the number of instances of the asset associated with entity.
override
getInstances(ThermionEntity entity) Future<List<ThermionEntity>>
Returns all instances of entity.
override
getInverseBindMatrix(ThermionEntity parent, int boneIndex, {int skinIndex = 0}) Future<Matrix4>
Gets the inverse bind (pose) matrix for the bone. Note that parent must be the ThermionEntity returned by loadGlb/loadGltf, not any other method (getChildEntity etc). This is because all joint information is internally stored with the parent entity.
override
getLocalTransform(ThermionEntity entity) Future<Matrix4>
Gets the local (relative to parent) transform for entity.
override
getMainCamera() Future<ThermionEntity>
Returns the entity associated with the main camera.
override
getMorphTargetNames(ThermionEntity entity, ThermionEntity childEntity) Future<List<String>>
Gets the names of all morph targets for the child renderable childEntity under entity.
override
getNameForEntity(ThermionEntity entity) String?
Retrieves the name assigned to the given ThermionEntity (usually corresponds to the glTF mesh name).
override
getParent(ThermionEntity child) Future<ThermionEntity?>
Gets the parent transform of child.
override
getRestLocalTransforms(ThermionEntity entity, {int skinIndex = 0}) Future<List<Matrix4>>
getWorldTransform(ThermionEntity entity) Future<Matrix4>
Gets the world transform for entity.
override
hide(ThermionEntity entity, String? meshName) Future
If meshName is provided, hide the node meshName under entity, otherwise hide the root node for entity. The entity still exists in memory, but is no longer being rendered into the scene. Call reveal to re-commence rendering.
override
initialize(int width, int height, {String? uberArchivePath}) Future
loadGlb(String path, {int numInstances = 1}) Future<ThermionEntity>
Load the .glb asset at the given path and insert into the scene.
override
loadGlbFromBuffer(Uint8List data, {int numInstances = 1}) Future<ThermionEntity>
loadGltf(String path, String relativeResourcePath, {bool force = false}) Future<ThermionEntity>
Load the .gltf asset at the given path and insert into the scene. relativeResourcePath is the folder path where the glTF resources are stored; this is usually the parent directory of the .gltf file itself.
override
loadIbl(String lightingPath, {double intensity = 30000}) Future
Loads an image-based light from the specified path at the given intensity. Only one IBL can be active at any given time; if an IBL has already been loaded, it will be replaced.
override
loadSkybox(String skyboxPath) Future
Load a skybox from skyboxPath (which must be a .ktx file)
override
moveCameraToAsset(ThermionEntity entity) Future
Repositions the camera to the last vertex of the bounding box of entity, looking at the penultimate vertex.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onDispose(Future callback()) → void
override
panEnd() Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
panStart(double x, double y) Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
panUpdate(double x, double y) Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
pick(int x, int y) → void
Used to select the entity in the scene at the given viewport coordinates. Called by FilamentGestureDetector on a mouse/finger down event. You probably don't want to call this yourself. This is asynchronous and will require 2-3 frames to complete - subscribe to the pickResult stream to receive the results of this method. x and y must be in local logical coordinates (i.e. where 0,0 is at top-left of the ThermionWidget).
override
playAnimation(ThermionEntity entity, int index, {bool loop = false, bool reverse = false, bool replaceActive = true, double crossfade = 0.0}) Future
Schedules the glTF animation at index in entity to start playing on the next frame.
override
playAnimationByName(ThermionEntity entity, String name, {bool loop = false, bool reverse = false, bool replaceActive = true, double crossfade = 0.0}) Future
Schedules the glTF animation at index in entity to start playing on the next frame.
override
queuePositionUpdate(ThermionEntity entity, double x, double y, double z, {bool relative = false}) Future
Queues an update to the worldspace position for entity to {x,y,z}. The actual update will occur on the next frame, and will be subject to collision detection.
override
queueRotationUpdate(ThermionEntity entity, double rads, double x, double y, double z, {bool relative = false}) Future
Queues an update to the worldspace rotation for entity. The actual update will occur on the next frame, and will be subject to collision detection.
override
queueRotationUpdateQuat(ThermionEntity entity, Quaternion quat, {bool relative = false}) Future
Same as queueRotationUpdate.
override
removeAnimationComponent(ThermionEntity entity) Future
Removes an animation component from entity.
override
removeCollisionComponent(ThermionEntity entity) Future
Removes the collision component from entity, meaning this will no longer be tested when testCollisions or queuePositionUpdate is called with another entity.
override
removeEntity(ThermionEntity entity) Future
Removes/destroys the specified entity from the scene. entity will no longer be a valid handle after this method is called; ensure you immediately discard all references once this method is complete.
override
removeIbl() Future
Removes the image-based light from the scene.
override
removeLight(ThermionEntity light) Future
override
removeSkybox() Future
Removes the skybox from the scene.
override
render() Future
Render a single frame.
override
resetBones(ThermionEntity entity) Future
Resets all bones in the given entity to their rest pose. This should be done before every call to addBoneAnimation.
override
reveal(ThermionEntity entity, String? meshName) Future
Reveal the node meshName under entity. Only applicable if hide had previously been called; this is a no-op otherwise.
override
rotateEnd() Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
rotateIbl(Matrix3 rotation) Future
Rotates the IBL & skybox.
override
rotateStart(double x, double y) Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
rotateUpdate(double x, double y) Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
setAnimationFrame(ThermionEntity entity, int index, int animationFrame) Future
override
setAntiAliasing(bool msaa, bool fxaa, bool taa) Future
Set antialiasing options.
override
setBackgroundColor(double r, double g, double b, double alpha) Future
Sets the color for the background plane (positioned at the maximum depth, i.e. behind all other objects including the skybox).
override
setBackgroundImage(String path, {bool fillHeight = false}) Future
Set the background image to path (which should have a file extension .png, .jpg, or .ktx). This will be rendered at the maximum depth (i.e. behind all other objects including the skybox). If fillHeight is false, the image will be rendered at its original size. Note this may cause issues with pixel density so be sure to specify the correct resolution If fillHeight is true, the image will be stretched/compressed to fit the height of the viewport.
override
setBackgroundImagePosition(double x, double y, {bool clamp = false}) Future
Moves the background image to the relative offset from the origin (bottom-left) specified by x and y. If clamp is true, the image cannot be positioned outside the bounds of the viewport.
override
setBloom(double bloom) Future
Sets the strength of the bloom.
override
setBoneTransform(ThermionEntity entity, int boneIndex, Matrix4 transform, {int skinIndex = 0}) Future
Directly set the bone matrix for the bone at the given index. Don't call this manually unless you know what you're doing.
override
setCamera(ThermionEntity entity, String? name) Future
Sets the current scene camera to the glTF camera under name in entity.
override
setCameraCulling(double near, double far) Future
Sets the distance (in world units) to the near/far planes for the active camera. Default values are 0.05/1000.0. See Camera.h for details.
override
setCameraExposure(double aperture, double shutterSpeed, double sensitivity) Future
Sets the camera exposure.
override
setCameraFocalLength(double focalLength) Future
Sets the focal length of the camera. Default value is 28.0.
override
setCameraFocusDistance(double focusDistance) Future
Sets the focus distance for the camera.
override
setCameraFov(double degrees, double width, double height) Future
Sets the current scene camera to the glTF camera under name in entity.
override
setCameraManipulatorOptions({ManipulatorMode mode = ManipulatorMode.ORBIT, double orbitSpeedX = 0.01, double orbitSpeedY = 0.01, double zoomSpeed = 0.01}) Future
Sets the options for manipulating the camera via the viewport. ManipulatorMode.FREE_FLIGHT and ManipulatorMode.MAP are currently unsupported and will throw an exception.
override
setCameraModelMatrix(List<double> matrix) Future
Sets the camera model matrix.
override
setCameraPosition(double x, double y, double z) Future
Set the camera position in world space. Note this is not persistent - any viewport navigation will reset the camera transform.
override
setCameraRotation(Quaternion quaternion) Future
Rotate the camera by rads around the given axis. Note this is not persistent - any viewport navigation will reset the camera transform.
override
setFrameRate(int framerate) Future
Sets the framerate for continuous rendering when setRendering is enabled.
override
setMainCamera() Future
Sets the current scene camera to the main camera (which is always available and added to every scene by default).
override
setMaterialColor(ThermionEntity entity, String meshName, int materialIndex, double r, double g, double b, double a) Future
Sets the baseColorFactor property for the material at index materialIndex in entity under node meshName to color.
override
setMorphAnimationData(ThermionEntity entity, MorphAnimationData animation, {List<String>? targetMeshNames, bool useNextEntity = false}) Future
Animate the morph targets in entity. See MorphTargetAnimation for an explanation as to how to construct the animation frame data. This method will check the morph target names specified in animation against the morph target names that actually exist exist under meshName in entity, throwing an exception if any cannot be found. It is permissible for animation to omit any targets that do exist under meshName; these simply won't be animated.
override
setMorphTargetWeights(ThermionEntity entity, List<double> weights) Future
Set the weights for all morph targets in entity to weights. Note that weights must contain values for ALL morph targets, but no exception will be thrown if you don't do so (you'll just get incorrect results). If you only want to set one value, set all others to zero (check getMorphTargetNames if you need the get a list of all morph targets). IMPORTANT - this accepts the actual ThermionEntity with the relevant morph targets (unlike getMorphTargetNames, which uses the parent entity and the child mesh name). Use getChildEntityByName if you are setting the weights for a child mesh.
override
setParent(ThermionEntity child, ThermionEntity parent) Future
Sets the parent transform of child to parent.
override
setPosition(ThermionEntity entity, double x, double y, double z) Future
Directly sets the world space position for entity to the given coordinates, skipping all collision detection.
override
setPostProcessing(bool enabled) Future
Enable/disable postprocessing (disabled by default).
override
setPriority(ThermionEntity entityId, int priority) Future
Sets the draw priority for the given entity. See RenderableManager.h for more details.
override
setRecording(bool recording) Future
If recording is set to true, each frame the framebuffer/texture will be written to /tmp/output_*.png. This will impact performance; handle with care.
override
setRecordingOutputDirectory(String outputDirectory) Future
Sets the output directory where recorded PNGs will be placed.
override
setRendering(bool render) Future
Set to true to continuously render the scene at the framerate specified by setFrameRate (60 fps by default).
override
setRotation(ThermionEntity entity, double rads, double x, double y, double z) Future
Directly sets the rotation for entity to rads around the axis {x,y,z}, skipping all collision detection.
override
setRotationQuat(ThermionEntity entity, Quaternion rotation) Future
Sets the rotation for entity to the specified quaternion.
override
setScale(ThermionEntity entity, double scale) Future
Directly sets the scale for entity, skipping all collision detection.
override
setShadowsEnabled(bool enabled) Future
Enable/disable shadows (disabled by default).
override
setShadowType(ShadowType shadowType) Future
Set shadow type.
override
setSoftShadowOptions(double penumbraScale, double penumbraRatioScale) Future
Set soft shadow options (ShadowType DPCF and PCSS)
override
setToneMapping(ToneMapper mapper) Future
Sets the tone mapping (requires postprocessing).
override
setTransform(ThermionEntity entity, Matrix4 transform) Future
Sets the transform (relative to its parent) for entity.
override
setViewFrustumCulling(bool enabled) Future
Enables/disables frustum culling. Currently we don't expose a method for manipulating the camera projection/culling matrices so this is your only option to deal with unwanted near/far clipping.
override
stopAnimation(ThermionEntity entity, int animationIndex) Future
override
stopAnimationByName(ThermionEntity entity, String name) Future
override
testCollisions(ThermionEntity entity) Future
Test all collidable entities against this entity to see if any have collided. This method returns void; the relevant callback passed to addCollisionComponent will be fired if a collision is detected.
override
toString() String
A string representation of this object.
inherited
transformToUnitCube(ThermionEntity entity) Future
Scale entity to fit within the unit cube.
override
updateBoneMatrices(ThermionEntity entity) Future
Updates the bone matrices for entity (which must be the ThermionEntity returned by loadGlb/loadGltf). Under the hood, this just calls updateBoneMatrices on the Animator instance of the relevant FilamentInstance (which uses the local bone transform and the inverse bind matrix to set the bone matrix).
override
zoomBegin() Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
zoomEnd() Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override
zoomUpdate(double x, double y, double z) Future
Called by FilamentGestureDetector. You probably don't want to call this yourself.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited