feature!:

This is a breaking change needed to fully implement instancing and stencil highlighting.

Previously, users would work directly with entities (on the Dart side, ThermionEntity), e.g.

final entity = await viewer.loadGlb("some.glb");

However, Filament "entities" are a lower-level abstraction.

Loading a glTF file, for example, inserts multiple entities into the scene.

For example, each mesh, light, and camera within a glTF asset will be assigned an entity. A top-level (non-renderable) entity will also be created for the glTF asset, which can be used to transform the entire hierarchy.

"Asset" is a better representation for loading/inserting objects into the scene; think of this as a bundle of entities.

Unless you need to work directly with transforms, instancing, materials and renderables, you can work directly with ThermionAsset.
This commit is contained in:
Nick Fisher
2024-11-21 15:04:10 +08:00
parent 9ada6aae64
commit ed444b0615
195 changed files with 18061 additions and 12628 deletions

View File

@@ -1,85 +0,0 @@
import 'shared_types/shared_types.dart';
///
/// To ensure we can easily store/recreate a particular, [ThermionViewer] will raise an event whenever an
/// entity is added/removed.
///
enum EventType { EntityAdded, EntityRemoved, EntityHidden, EntityRevealed, ClearLights }
///
/// An "entity added" event must provide sufficient detail to enable that asset to be reloaded in future.
/// This requires a bit more legwork because entities may be lights (direct/indirect), geometry or gltf.
///
enum EntityType { Geometry, Gltf, DirectLight, IBL }
class SceneUpdateEvent {
late final ThermionEntity? entity;
late final EventType eventType;
EntityType get addedEntityType {
if (_directLight != null) {
return EntityType.DirectLight;
} else if (_ibl != null) {
return EntityType.IBL;
} else if (_gltf != null) {
return EntityType.Gltf;
} else if (_geometry != null) {
return EntityType.Geometry;
} else {
throw Exception("Unknown entity type");
}
}
DirectLight? _directLight;
IBL? _ibl;
GLTF? _gltf;
Geometry? _geometry;
SceneUpdateEvent.remove(this.entity) {
this.eventType = EventType.EntityRemoved;
}
SceneUpdateEvent.reveal(this.entity) {
this.eventType = EventType.EntityRevealed;
}
SceneUpdateEvent.hide(this.entity) {
this.eventType = EventType.EntityHidden;
}
SceneUpdateEvent.addDirectLight(this.entity, this._directLight) {
this.eventType = EventType.EntityAdded;
}
SceneUpdateEvent.addIbl(this.entity, this._ibl) {
this.eventType = EventType.EntityAdded;
}
SceneUpdateEvent.addGltf(this.entity, this._gltf) {
this.eventType = EventType.EntityAdded;
}
SceneUpdateEvent.addGeometry(this.entity, this._geometry) {
this.eventType = EventType.EntityAdded;
}
SceneUpdateEvent.clearLights() {
this.eventType = EventType.ClearLights;
}
DirectLight getDirectLight() {
return _directLight!;
}
IBL getAsIBL() {
return _ibl!;
}
GLTF getAsGLTF() {
return _gltf!;
}
Geometry getAsGeometry() {
return _geometry!;
}
}

View File

@@ -0,0 +1,186 @@
import 'dart:typed_data';
import 'package:thermion_dart/src/viewer/src/ffi/src/callbacks.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_viewer_ffi.dart';
import 'package:thermion_dart/thermion_dart.dart';
import 'ffi_material_instance.dart';
class FFIAsset extends ThermionAsset {
final Pointer<TSceneAsset> pointer;
final Pointer<TSceneManager> sceneManager;
Pointer<TRenderableManager> get renderableManager =>
Engine_getRenderableManager(engine);
final Pointer<TEngine> engine;
FFIAsset? _highlight;
final Pointer<TMaterialProvider> _unlitMaterialProvider;
final bool isInstance;
late final ThermionEntity entity;
FFIAsset(
this.pointer, this.sceneManager, this.engine, this._unlitMaterialProvider,
{this.isInstance = false}) {
entity = SceneAsset_getEntity(pointer);
}
@override
Future<List<ThermionEntity>> getChildEntities() async {
var count = SceneAsset_getChildEntityCount(pointer);
var children = Int32List(count);
SceneAsset_getChildEntities(pointer, children.address);
return children;
}
@override
Future<ThermionAsset> getInstance(int index) async {
if (isInstance) {
throw Exception(
"This is itself an instance. Call getInstance on the original asset that this instance was created from");
}
var instance = SceneAsset_getInstance(pointer, index);
if (instance == nullptr) {
throw Exception("No instance available at index $index");
}
return FFIAsset(instance, sceneManager, engine, _unlitMaterialProvider);
}
///
///
///
@override
Future<FFIAsset> createInstance(
{covariant List<MaterialInstance>? materialInstances = null}) async {
var created = await withPointerCallback<TSceneAsset>((cb) {
var ptrList = Int64List(materialInstances?.length ?? 0);
if (materialInstances != null && materialInstances.isNotEmpty) {
ptrList.setRange(
0,
materialInstances.length,
materialInstances
.cast<ThermionFFIMaterialInstance>()
.map((mi) => mi.pointer.address)
.toList());
}
SceneAsset_createInstanceRenderThread(
pointer,
ptrList.address.cast<Pointer<TMaterialInstance>>(),
materialInstances?.length ?? 0,
cb);
});
if (created == FILAMENT_ASSET_ERROR) {
throw Exception("Failed to create instance");
}
return FFIAsset(created, sceneManager, engine, _unlitMaterialProvider);
}
///
///
///
@override
Future<int> getInstanceCount() async {
return SceneAsset_getInstanceCount(pointer);
}
///
///
///
@override
Future<List<ThermionAsset>> getInstances() async {
var count = await getInstanceCount();
final result = List<ThermionAsset>.generate(count, (i) {
return FFIAsset(SceneAsset_getInstance(pointer, i), sceneManager, engine,
_unlitMaterialProvider);
});
return result;
}
@override
Future removeStencilHighlight() async {
if (_highlight != null) {
SceneManager_removeFromScene(sceneManager, _highlight!.entity);
final childEntities = await _highlight!.getChildEntities();
for (final child in childEntities) {
SceneManager_removeFromScene(sceneManager, child);
}
}
}
@override
Future setStencilHighlight(
{double r = 1.0,
double g = 0.0,
double b = 0.0,
int? entityIndex}) async {
if (_highlight == null) {
var targetEntity = this.entity;
if (entityIndex != null) {
final childEntities = await this.getChildEntities();
targetEntity = childEntities[entityIndex!];
}
var sourceMaterialInstance = ThermionFFIMaterialInstance(
RenderableManager_getMaterialInstanceAt(
renderableManager, targetEntity, 0));
await sourceMaterialInstance.setStencilWriteEnabled(true);
await sourceMaterialInstance.setDepthWriteEnabled(true);
await sourceMaterialInstance
.setStencilOpDepthStencilPass(StencilOperation.REPLACE);
await sourceMaterialInstance.setStencilReferenceValue(1);
final materialInstancePtr =
await withPointerCallback<TMaterialInstance>((cb) {
final key = Struct.create<TMaterialKey>();
MaterialProvider_createMaterialInstanceRenderThread(
_unlitMaterialProvider, key.address, cb);
});
final highlightMaterialInstance =
ThermionFFIMaterialInstance(materialInstancePtr);
await highlightMaterialInstance
.setStencilCompareFunction(SamplerCompareFunction.NE);
await highlightMaterialInstance.setStencilReferenceValue(1);
await highlightMaterialInstance.setDepthCullingEnabled(false);
await highlightMaterialInstance.setParameterFloat("vertexScale", 1.03);
await highlightMaterialInstance.setParameterFloat4(
"baseColorFactor", r, g, b, 1.0);
var highlightInstance = await this
.createInstance(materialInstances: [highlightMaterialInstance]);
_highlight = highlightInstance;
var targetHighlightEntity = _highlight!.entity;
if (entityIndex != null) {
var highlightChildEntities = await _highlight!.getChildEntities();
targetHighlightEntity = highlightChildEntities[entityIndex!];
}
RenderableManager_setPriority(
renderableManager, targetHighlightEntity, 7);
RenderableManager_setPriority(renderableManager, targetEntity, 0);
await highlightMaterialInstance.setStencilReferenceValue(1);
SceneManager_addToScene(sceneManager, targetHighlightEntity);
}
}
@override
Future addToScene() async {
SceneAsset_addToScene(pointer, SceneManager_getScene(sceneManager));
}
@override
Future removeFromScene() async {
SceneManager_removeFromScene(sceneManager, entity);
for (final child in await getChildEntities()) {
SceneManager_removeFromScene(sceneManager, child);
}
}
}

View File

@@ -9,9 +9,10 @@ import 'thermion_dart.g.dart' as g;
class FFICamera extends Camera {
final Pointer<g.TCamera> camera;
final Pointer<g.TEngine> engine;
final Pointer<g.TTransformManager> transformManager;
late ThermionEntity _entity;
FFICamera(this.camera, this.engine) {
FFICamera(this.camera, this.engine, this.transformManager) {
_entity = g.Camera_getEntity(camera);
}
@@ -29,7 +30,7 @@ class FFICamera extends Camera {
@override
Future setTransform(Matrix4 transform) async {
var entity = g.Camera_getEntity(camera);
g.Engine_setTransform(engine, entity, matrix4ToDouble4x4(transform));
g.TransformManager_setTransform(transformManager, entity, matrix4ToDouble4x4(transform));
}
@override

View File

@@ -1,50 +1,69 @@
import 'dart:async';
import 'dart:ffi';
import 'package:thermion_dart/src/viewer/src/ffi/src/callbacks.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/ffi_asset.dart';
import 'package:thermion_dart/src/viewer/src/shared_types/entities.dart';
import 'package:thermion_dart/thermion_dart.dart';
import 'package:vector_math/vector_math_64.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_dart.g.dart';
import '../../../../utils/src/gizmo.dart';
import '../../../viewer.dart';
class FFIGizmo extends BaseGizmo {
Pointer<TGizmo> pointer;
import 'ffi_view.dart';
class FFIGizmo extends FFIAsset implements GizmoAsset {
final Set<ThermionEntity> nonPickableEntities;
late NativeCallable<GizmoPickCallbackFunction> _nativeCallback;
void Function(GizmoPickResultType axis, Vector3 coords)? _callback;
late FFIView _view;
void _onPickResult(int resultType, double x, double y, double z) {
_callback?.call(GizmoPickResultType.values[resultType], Vector3(x, y, z));
}
FFIGizmo(
this.pointer, ThermionViewer viewer) : super(x: 0, y: 0, z: 0, center: 0, viewer: viewer) {
this._view,
super.pointer,
super.sceneManager,
super.renderableManager,
super.unlitMaterialProvider,
this.nonPickableEntities
) {
_nativeCallback =
NativeCallable<GizmoPickCallbackFunction>.listener(_onPickResult);
}
///
/// The result(s) of calling [pickGizmo] (see below).
///
// Stream<PickResult> get onPick => _pickResultController.stream;
// final _pickResultController = StreamController<PickResult>.broadcast();
void Function(PickResult)? _callback;
void onPick(void Function(PickResult) callback) {
_callback = callback;
}
void _onPickResult(DartEntityId entityId, int x, int y, Pointer<TView> view) {
_callback?.call((entity: entityId, x: x, y: y, depth: 0, fragX: 0, fragY: 0, fragZ: 0));
}
///
/// Used to test whether a Gizmo is 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 [gizmoPickResult] 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
Future pick(int x, int y) async {
Gizmo_pick(pointer, x.toInt(), y, _nativeCallback.nativeFunction);
Future removeStencilHighlight() async {
throw Exception("Not supported for gizmo");
}
@override
Future setVisibility(bool visible) async {
Gizmo_setVisibility(pointer, visible);
Future setStencilHighlight(
{double r = 1.0,
double g = 0.0,
double b = 0.0,
int? entityIndex}) async {
throw Exception("Not supported for gizmo");
}
@override
Future pick(int x, int y,
{Future Function(GizmoPickResultType result, Vector3 coords)?
handler}) async {
_callback = handler;
final viewport = await _view.getViewport();
y = viewport.height - y;
Gizmo_pick(pointer.cast<TGizmo>(), x, y, _nativeCallback.nativeFunction);
}
@override
Future highlight(Axis axis) async {
Gizmo_unhighlight(pointer.cast<TGizmo>());
Gizmo_highlight(pointer.cast<TGizmo>(), TGizmoAxis.values[axis.index]);
}
@override
Future unhighlight() async {
Gizmo_unhighlight(pointer.cast<TGizmo>());
}
}

View File

@@ -0,0 +1,116 @@
import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/thermion_dart.dart';
class ThermionFFIMaterialInstance extends MaterialInstance {
final Pointer<TMaterialInstance> pointer;
ThermionFFIMaterialInstance(this.pointer) {
if (pointer == nullptr) {
throw Exception("MaterialInstance not found");
}
}
@override
Future setDepthCullingEnabled(bool enabled) async {
MaterialInstance_setDepthCulling(this.pointer, enabled);
}
@override
Future setDepthWriteEnabled(bool enabled) async {
MaterialInstance_setDepthWrite(this.pointer, enabled);
}
@override
Future setParameterFloat4(
String name, double x, double y, double z, double w) async {
MaterialInstance_setParameterFloat4(
pointer, name.toNativeUtf8().cast<Char>(), x, y, z, w);
}
@override
Future setParameterFloat2(String name, double x, double y) async {
MaterialInstance_setParameterFloat2(
pointer, name.toNativeUtf8().cast<Char>(), x, y);
}
@override
Future setParameterFloat(String name, double value) async {
MaterialInstance_setParameterFloat(
pointer, name.toNativeUtf8().cast<Char>(), value);
}
@override
Future setParameterInt(String name, int value) async {
MaterialInstance_setParameterInt(
pointer, name.toNativeUtf8().cast<Char>(), value);
}
@override
Future setDepthFunc(SamplerCompareFunction depthFunc) async {
MaterialInstance_setDepthFunc(pointer, TSamplerCompareFunc.values[depthFunc.index]);
}
@override
Future setStencilCompareFunction(SamplerCompareFunction func,
[StencilFace face = StencilFace.FRONT_AND_BACK]) async {
MaterialInstance_setStencilCompareFunction(
pointer, TSamplerCompareFunc.values[func.index], TStencilFace.values[face.index]);
}
@override
Future setStencilOpDepthFail(StencilOperation op,
[StencilFace face = StencilFace.FRONT_AND_BACK]) async {
MaterialInstance_setStencilOpDepthFail(pointer,
TStencilOperation.values[op.index], TStencilFace.values[face.index]);
}
@override
Future setStencilOpDepthStencilPass(StencilOperation op,
[StencilFace face = StencilFace.FRONT_AND_BACK]) async {
MaterialInstance_setStencilOpDepthStencilPass(pointer,
TStencilOperation.values[op.index], TStencilFace.values[face.index]);
}
@override
Future setStencilOpStencilFail(StencilOperation op,
[StencilFace face = StencilFace.FRONT_AND_BACK]) async {
MaterialInstance_setStencilOpStencilFail(pointer,
TStencilOperation.values[op.index], TStencilFace.values[face.index]);
}
@override
Future setStencilReferenceValue(int value,
[StencilFace face = StencilFace.FRONT_AND_BACK]) async {
MaterialInstance_setStencilReferenceValue(
pointer, value, TStencilFace.values[face.index]);
}
@override
Future setStencilWriteEnabled(bool enabled) async {
MaterialInstance_setStencilWrite(pointer, enabled);
}
@override
Future setCullingMode(CullingMode cullingMode) async {
MaterialInstance_setCullingMode(
pointer, TCullingMode.values[cullingMode.index]);
}
@override
Future<bool> isStencilWriteEnabled() async {
return MaterialInstance_isStencilWriteEnabled(pointer);
}
@override
Future setStencilReadMask(int mask) async {
MaterialInstance_setStencilReadMask(pointer, mask);
}
@override
Future setStencilWriteMask(int mask) async {
MaterialInstance_setStencilWriteMask(pointer, mask);
}
}

View File

@@ -18,7 +18,7 @@ class FFIView extends View {
@override
Future setRenderTarget(covariant FFIRenderTarget? renderTarget) async {
if(renderTarget != null) {
if (renderTarget != null) {
View_setRenderTarget(view, renderTarget.renderTarget);
} else {
View_setRenderTarget(view, nullptr);
@@ -39,8 +39,9 @@ class FFIView extends View {
@override
Future<Camera> getCamera() async {
final engine = Viewer_getEngine(viewer);
final cameraPtr = View_getCamera(view);
return FFICamera(cameraPtr, engine);
final transformManager = Engine_getTransformManager(engine);
final cameraPtr = View_getCamera(view);
return FFICamera(cameraPtr, engine, transformManager);
}
@override
@@ -72,4 +73,12 @@ class FFIView extends View {
final engine = await Viewer_getEngine(viewer);
View_setToneMappingRenderThread(view, engine, mapper.index);
}
Future setStencilBufferEnabled(bool enabled) async {
return View_setStencilBufferEnabled(view, enabled);
}
Future<bool> isStencilBufferEnabled() async {
return View_isStencilBufferEnabled(view);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,85 @@
library;
import 'package:thermion_dart/thermion_dart.dart';
import 'package:vector_math/vector_math_64.dart';
export 'geometry.dart';
export 'gltf.dart';
export 'light_options.dart';
// a handle that can be safely passed back to the rendering layer to manipulate an Entity
// repre handle that can be safely passed back to the rendering layer to manipulate an Entity
typedef ThermionEntity = int;
abstract class ThermionAsset {
ThermionEntity get entity;
Future<List<ThermionEntity>> getChildEntities();
///
/// Renders an outline around [entity] with the given color.
///
Future setStencilHighlight(
{double r = 1.0, double g = 0.0, double b = 0.0, int? entityIndex});
///
/// Removes the outline around [entity]. Noop if there was no highlight.
///
Future removeStencilHighlight();
///
///
///
Future<ThermionAsset> getInstance(int index);
///
/// Create a new instance of [entity].
/// Instances are not automatically added to the scene; you must
/// call [addToScene].
///
Future<ThermionAsset> createInstance(
{covariant List<MaterialInstance>? materialInstances = null});
///
/// Returns the number of instances associated with this asset.
///
Future<int> getInstanceCount();
///
/// Returns all instances of associated with this asset.
///
Future<List<ThermionAsset>> getInstances();
///
/// Adds all entities (renderable, lights and cameras) under [asset] to the scene.
///
Future addToScene();
///
/// Removes all entities (renderable, lights and cameras) under [asset] from the scene.
///
Future removeFromScene();
}
enum Axis {
X(const [1.0, 0.0, 0.0]),
Y(const [0.0, 1.0, 0.0]),
Z(const [0.0, 0.0, 1.0]);
const Axis(this.vector);
final List<double> vector;
Vector3 asVector() => Vector3(vector[0], vector[1], vector[2]);
}
enum GizmoPickResultType { AxisX, AxisY, AxisZ, Parent, None }
enum GizmoType { translation, rotation }
abstract class GizmoAsset extends ThermionAsset {
Future pick(int x, int y,
{Future Function(GizmoPickResultType axis, Vector3 coords)? handler});
Future highlight(Axis axis);
Future unhighlight();
Set<ThermionEntity> get nonPickableEntities;
}

View File

@@ -1,32 +1,112 @@
import 'package:thermion_dart/src/viewer/src/ffi/src/callbacks.dart';
enum SamplerCompareFunction {
enum SamplerCompareFunction {
/// !< Less or equal
LE,
/// !< Greater or equal
GE,
/// !< Strictly less than
L,
/// !< Strictly greater than
G,
/// !< Equal
E,
/// !< Not equal
NE,
/// !< Always. Depth / stencil testing is deactivated.
A,
/// !< Never. The depth / stencil test always fails.
N;
}
abstract class MaterialInstance {
Future setDepthWriteEnabled(bool enabled);
Future setDepthFunc(SamplerCompareFunction depthFunc);
Future setDepthCullingEnabled(bool enabled);
Future setParameterFloat4(String name, double x, double y, double z, double w);
Future setParameterFloat2(String name, double x, double y);
Future setParameterFloat(String name, double x);
Future setParameterInt(String name, int value);
/// Defines stencil operations
enum StencilOperation {
/// Keep the current value
KEEP,
/// Set the value to zero
ZERO,
/// Set the value to reference value
REPLACE,
/// Increment the current value with saturation
INCR,
/// Increment the current value without saturation
INCR_WRAP,
/// Decrement the current value with saturation
DECR,
/// Decrement the current value without saturation
DECR_WRAP,
/// Invert the current value
INVERT
}
enum CullingMode {
NONE, // No culling
FRONT, // Cull front faces
BACK, // Cull back faces
FRONT_AND_BACK // Cull both front and back faces
}
/// Defines which face(s) the stencil operation affects
enum StencilFace {
/// Front face only
FRONT,
/// Back face only
BACK,
/// Both front and back faces
FRONT_AND_BACK
}
enum AlphaMode { OPAQUE, MASK, BLEND }
abstract class MaterialInstance {
Future<bool> isStencilWriteEnabled();
Future setDepthWriteEnabled(bool enabled);
Future setDepthFunc(SamplerCompareFunction depthFunc);
Future setDepthCullingEnabled(bool enabled);
Future setParameterFloat4(
String name, double x, double y, double z, double w);
Future setParameterFloat2(String name, double x, double y);
Future setParameterFloat(String name, double x);
Future setParameterInt(String name, int value);
/// Sets the stencil operation to be performed when the stencil test fails
Future setStencilOpStencilFail(StencilOperation op,
[StencilFace face = StencilFace.FRONT_AND_BACK]);
/// Sets the stencil operation to be performed when the depth test fails
Future setStencilOpDepthFail(StencilOperation op,
[StencilFace face = StencilFace.FRONT_AND_BACK]);
/// Sets the stencil operation to be performed when both depth and stencil tests pass
Future setStencilOpDepthStencilPass(StencilOperation op,
[StencilFace face = StencilFace.FRONT_AND_BACK]);
/// Sets the stencil test comparison function
Future setStencilCompareFunction(SamplerCompareFunction func,
[StencilFace face = StencilFace.FRONT_AND_BACK]);
/// Sets the reference value used for stencil testing
Future setStencilReferenceValue(int value,
[StencilFace face = StencilFace.FRONT_AND_BACK]);
Future setStencilWriteEnabled(bool enabled);
Future setCullingMode(CullingMode cullingMode);
Future setStencilReadMask(int mask);
Future setStencilWriteMask(int mask);
}

View File

@@ -1,5 +1,5 @@
import 'package:thermion_dart/thermion_dart.dart';
import 'swap_chain.dart';
///
/// The viewport currently attached to a [View].
@@ -27,4 +27,6 @@ abstract class View {
Future setFrustumCullingEnabled(bool enabled);
Future setToneMapper(ToneMapper mapper);
Future setBloom(double strength);
Future setStencilBufferEnabled(bool enabled);
Future<bool> isStencilBufferEnabled();
}

View File

@@ -1,4 +1,3 @@
import 'package:thermion_dart/src/viewer/src/events.dart';
import '../../utils/src/gizmo.dart';
import 'shared_types/shared_types.dart';
export 'shared_types/shared_types.dart';
@@ -9,30 +8,30 @@ import 'package:vector_math/vector_math_64.dart';
import 'dart:async';
import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'shared_types/view.dart';
const double kNear = 0.05;
const double kFar = 1000.0;
const double kFocalLength = 28.0;
enum VisibilityLayers {
DEFAULT_ASSET(0),
LAYER_1(1),
LAYER_2(2),
LAYER_3(3),
LAYER_4(4),
LAYER_5(5),
BACKGROUND(6),
OVERLAY(7);
final int value;
const VisibilityLayers(this.value);
}
abstract class ThermionViewer {
///
/// A Future that resolves when the underlying rendering context has been successfully created.
///
Future<bool> get initialized;
///
/// 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.
///
Stream<FilamentPickResult> get pickResult;
///
/// A Stream containing entities added/removed to/from to the scene.
///
Stream<SceneUpdateEvent> get sceneUpdated;
///
/// Whether the controller is currently rendering at [framerate].
///
@@ -74,8 +73,7 @@ abstract class ThermionViewer {
///
///
///
Future destroySwapChain(
covariant SwapChain swapChain);
Future destroySwapChain(covariant SwapChain swapChain);
///
///
@@ -86,8 +84,7 @@ abstract class ThermionViewer {
///
///
///
Future destroyRenderTarget(
covariant RenderTarget renderTarget);
Future destroyRenderTarget(covariant RenderTarget renderTarget);
///
///
@@ -215,24 +212,24 @@ abstract class ThermionViewer {
Future clearLights();
///
/// Load the .glb asset at the given path and insert into the scene.
/// Load the .glb asset at the given path, adding all entities to the scene.
/// Specify [numInstances] to create multiple instances (this is more efficient than dynamically instantating at a later time). You can then retrieve the created instances with [getInstances].
/// If you want to be able to call [createInstance] at a later time, you must pass true for [keepData].
/// If [keepData] is false, the source glTF data will be released and [createInstance] will throw an exception.
///
Future<ThermionEntity> loadGlb(String path,
Future<ThermionAsset> loadGlb(String path,
{int numInstances = 1, bool keepData = false});
///
/// Load the .glb asset from the specified buffer and insert into the scene.
/// Load the .glb asset from the specified buffer, adding all entities to the scene.
/// Specify [numInstances] to create multiple instances (this is more efficient than dynamically instantating at a later time). You can then retrieve the created instances with [getInstances].
/// If you want to be able to call [createInstance] at a later time, you must pass true for [keepData].
/// If [keepData] is false, the source glTF data will be released and [createInstance] will throw an exception.
/// If [loadResourcesAsync] is true, resources (textures, materials, etc) will
/// If [loadResourcesAsync] is true, resources (textures, materials, etc) will
/// be loaded asynchronously (so expect some material/texture pop-in);
///
///
Future<ThermionEntity> loadGlbFromBuffer(Uint8List data,
Future<ThermionAsset> loadGlbFromBuffer(Uint8List data,
{int numInstances = 1,
bool keepData = false,
int priority = 4,
@@ -240,28 +237,13 @@ abstract class ThermionViewer {
bool loadResourcesAsync});
///
/// Create a new instance of [entity].
///
Future<ThermionEntity> createInstance(ThermionEntity entity);
///
/// Returns the number of instances of the asset associated with [entity].
///
Future<int> getInstanceCount(ThermionEntity entity);
///
/// Returns all instances of [entity].
///
Future<List<ThermionEntity>> getInstances(ThermionEntity entity);
///
/// Load the .gltf asset at the given path and insert into the scene.
/// Load the .gltf asset at the given path, adding all entities to the scene.
/// [relativeResourcePath] is the folder path where the glTF resources are stored;
/// this is usually the parent directory of the .gltf file itself.
///
/// See [loadGlb] for an explanation of [keepData].
///
Future<ThermionEntity> loadGltf(String path, String relativeResourcePath,
Future<ThermionAsset> loadGltf(String path, String relativeResourcePath,
{bool keepData = false});
///
@@ -277,32 +259,34 @@ abstract class ThermionViewer {
/// Gets the names of all morph targets for the child renderable [childEntity] under [entity].
///
Future<List<String>> getMorphTargetNames(
ThermionEntity entity, ThermionEntity childEntity);
covariant ThermionAsset asset, ThermionEntity childEntity);
///
/// Gets the names of all bones for the armature at [skinIndex] under the specified [entity].
///
Future<List<String>> getBoneNames(ThermionEntity entity, {int skinIndex = 0});
Future<List<String>> getBoneNames(covariant ThermionAsset asset,
{int skinIndex = 0});
///
/// Gets the names of all glTF animations embedded in the specified entity.
///
Future<List<String>> getAnimationNames(ThermionEntity entity);
Future<List<String>> getAnimationNames(covariant ThermionAsset asset);
///
/// Returns the length (in seconds) of the animation at the given index.
///
Future<double> getAnimationDuration(
ThermionEntity entity, int animationIndex);
covariant ThermionAsset asset, int animationIndex);
///
/// Animate the morph targets in [entity]. See [MorphTargetAnimation] for an explanation as to how to construct the animation frame data.
/// Construct animation(s) for every entity under [asset]. If [targetMeshNames] is provided, only entities with matching names will be animated.
/// [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.
///
Future setMorphAnimationData(
ThermionEntity entity, MorphAnimationData animation,
covariant ThermionAsset asset, MorphAnimationData animation,
{List<String>? targetMeshNames});
///
@@ -314,7 +298,7 @@ abstract class ThermionViewer {
/// Resets all bones in the given entity to their rest pose.
/// This should be done before every call to addBoneAnimation.
///
Future resetBones(ThermionEntity entity);
Future resetBones(ThermionAsset asset);
///
/// Enqueues and plays the [animation] for the specified bone(s).
@@ -334,7 +318,7 @@ abstract class ThermionViewer {
/// This will be applied in reverse after [fadeOutInSecs].
///
///
Future addBoneAnimation(ThermionEntity entity, BoneAnimationData animation,
Future addBoneAnimation(ThermionAsset asset, BoneAnimationData animation,
{int skinIndex = 0,
double fadeInInSecs = 0.0,
double fadeOutInSecs = 0.0,
@@ -344,7 +328,7 @@ abstract class ThermionViewer {
/// Gets the entity representing the bone at [boneIndex]/[skinIndex].
/// The returned entity is only intended for use with [getWorldTransform].
///
Future<ThermionEntity> getBone(ThermionEntity parent, int boneIndex,
Future<ThermionEntity> getBone(covariant ThermionAsset asset, int boneIndex,
{int skinIndex = 0});
///
@@ -362,7 +346,8 @@ abstract class ThermionViewer {
/// 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.
///
Future<Matrix4> getInverseBindMatrix(ThermionEntity parent, int boneIndex,
Future<Matrix4> getInverseBindMatrix(
covariant ThermionAsset asset, int boneIndex,
{int skinIndex = 0});
///
@@ -398,7 +383,7 @@ abstract class ThermionViewer {
/// 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.
///
Future removeEntity(ThermionEntity entity);
Future removeEntity(ThermionAsset asset);
///
/// Removes/destroys all renderable entities from the scene (including cameras).
@@ -407,9 +392,9 @@ abstract class ThermionViewer {
Future clearEntities();
///
/// Schedules the glTF animation at [index] in [entity] to start playing on the next frame.
/// Schedules the glTF animation at [index] in [asset] to start playing on the next frame.
///
Future playAnimation(ThermionEntity entity, int index,
Future playAnimation(ThermionAsset asset, int index,
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
@@ -419,17 +404,27 @@ abstract class ThermionViewer {
///
/// Schedules the glTF animation at [index] in [entity] to start playing on the next frame.
///
Future playAnimationByName(ThermionEntity entity, String name,
Future playAnimationByName(covariant ThermionAsset asset, String name,
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0});
Future setAnimationFrame(
ThermionEntity entity, int index, int animationFrame);
///
///
///
Future setGltfAnimationFrame(
covariant ThermionAsset asset, int index, int animationFrame);
Future stopAnimation(ThermionEntity entity, int animationIndex);
Future stopAnimationByName(ThermionEntity entity, String name);
///
///
///
Future stopAnimation(covariant ThermionAsset asset, int animationIndex);
///
///
///
Future stopAnimationByName(covariant ThermionAsset asset, String name);
///
/// Sets the current scene camera to the glTF camera under [name] in [entity].
@@ -576,44 +571,11 @@ abstract class ThermionViewer {
///
Future setCameraModelMatrix4(Matrix4 matrix);
///
/// Sets the `baseColorFactor` property for the material at index [materialIndex] in [entity] under node [meshName] to [color].
///
@Deprecated("Use setMaterialPropertyFloat4 instead")
Future setMaterialColor(ThermionEntity entity, String meshName,
int materialIndex, double r, double g, double b, double a);
///
/// Sets the material property [propertyName] under material [materialIndex] for [entity] to [value].
/// [entity] must have a Renderable attached.
///
Future setMaterialPropertyFloat4(ThermionEntity entity, String propertyName,
int materialIndex, double f1, double f2, double f3, double f4);
///
/// Sets the material property [propertyName] under material [materialIndex] for [entity] to [value].
/// [entity] must have a Renderable attached.
///
Future setMaterialPropertyFloat(ThermionEntity entity, String propertyName,
int materialIndex, double value);
///
/// Sets the material property [propertyName] under material [materialIndex] for [entity] to [value].
/// [entity] must have a Renderable attached.
///
Future setMaterialPropertyInt(
ThermionEntity entity, String propertyName, int materialIndex, int value);
///
/// Scale [entity] to fit within the unit cube.
///
Future transformToUnitCube(ThermionEntity entity);
///
/// Directly sets the world space position for [entity] to the given coordinates.
///
Future setPosition(ThermionEntity entity, double x, double y, double z);
///
/// Set the world space position for [lightEntity] to the given coordinates.
///
@@ -625,17 +587,6 @@ abstract class ThermionViewer {
///
Future setLightDirection(ThermionEntity lightEntity, Vector3 direction);
///
/// Directly sets the scale for [entity], skipping all collision detection.
///
Future setScale(ThermionEntity entity, double scale);
///
/// Directly sets the rotation for [entity] to [rads] around the axis {x,y,z}, skipping all collision detection.
///
Future setRotation(
ThermionEntity entity, double rads, double x, double y, double z);
///
/// TODO
///
@@ -674,28 +625,22 @@ abstract class ThermionViewer {
Future setAntiAliasing(bool msaa, bool fxaa, bool taa);
///
/// Sets the rotation for [entity] to the specified quaternion.
/// Adds a single [entity] to the scene.
///
Future setRotationQuat(ThermionEntity entity, Quaternion rotation);
Future addEntityToScene(ThermionEntity entity);
///
/// Reveal the node [meshName] under [entity]. Only applicable if [hide] had previously been called; this is a no-op otherwise.
/// Removes a single [entity] from the scene.
///
Future reveal(ThermionEntity entity, String? meshName);
Future removeEntityFromScene(ThermionEntity entity);
///
/// 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.
///
Future hide(ThermionEntity entity, String? meshName);
///
/// 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.
/// Hit test the viewport at the given coordinates. If the coordinates intersect
/// with a renderable entity, [resultHandler] will be called.
/// This is asynchronous and will require 2-3 frames to complete (so ensure you are calling render())
/// [x] and [y] must be in local logical coordinates (i.e. where 0,0 is at top-left of the ThermionWidget).
///
Future pick(int x, int y);
Future pick(int x, int y, void Function(PickResult) resultHandler);
///
/// Retrieves the name assigned to the given ThermionEntity (usually corresponds to the glTF mesh name).
@@ -703,23 +648,16 @@ abstract class ThermionViewer {
String? getNameForEntity(ThermionEntity entity);
///
/// Returns all child entities under [parent].
/// Returns all child entities under [asset].
///
Future<List<ThermionEntity>> getChildEntities(
ThermionEntity parent, bool renderableOnly);
Future<List<ThermionEntity>> getChildEntities(covariant ThermionAsset asset);
///
/// 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.
///
Future<ThermionEntity> getChildEntity(
ThermionEntity parent, String childName);
///
/// List the name of all child entities under the given entity.
///
Future<List<String>> getChildEntityNames(ThermionEntity entity,
{bool renderableOnly = true});
Future<ThermionEntity?> getChildEntity(
covariant ThermionAsset asset, String childName);
///
/// An [entity] will only be animatable after an animation component is attached.
@@ -750,8 +688,9 @@ abstract class ThermionViewer {
/// Creates a (renderable) entity with the specified geometry and adds to the scene.
/// If [keepData] is true, the source data will not be released.
///
Future createGeometry(Geometry geometry,
{MaterialInstance? materialInstance, bool keepData = false});
Future<ThermionAsset> createGeometry(Geometry geometry,
{covariant List<MaterialInstance>? materialInstances,
bool keepData = false});
///
/// Gets the parent entity of [entity]. Returns null if the entity has no parent.
@@ -783,7 +722,8 @@ abstract class ThermionViewer {
///
/// The gizmo for translating/rotating objects. Only one gizmo can be active for a given view.
///
Future<Gizmo> createGizmo(covariant View view);
Future<GizmoAsset> createGizmo(covariant View view,
GizmoType type);
///
/// Register a callback to be invoked when this viewer is disposed.
@@ -803,34 +743,23 @@ abstract class ThermionViewer {
///
/// Toggles the visibility of the respective layer.
///
Future setLayerVisibility(int layer, bool visible);
Future setLayerVisibility(VisibilityLayers layer, bool visible);
///
/// All renderable entities are assigned a layer mask.
///
/// By calling [setLayerVisibility], all renderable entities allocated to
/// the given layer can be efficiently hidden/revealed.
///
/// By default, all renderable entities are assigned to layer 0 (and this
/// layer is enabled by default). Call [setVisibilityLayer] to change the
/// All renderable entities are assigned a layer mask.
///
/// By calling [setLayerVisibility], all renderable entities allocated to
/// the given layer can be efficiently hidden/revealed.
///
/// By default, all renderable entities are assigned to layer 0 (and this
/// layer is enabled by default). Call [setVisibilityLayer] to change the
/// layer for the specified entity.
///
/// Note that we currently also assign gizmos to layer 1 (enabled by default)
/// and the world grid to layer 2 (disabled by default). We suggest you avoid
///
/// Note that we currently also assign gizmos to layer 1 (enabled by default)
/// and the world grid to layer 2 (disabled by default). We suggest you avoid
/// using these layers.
///
Future setVisibilityLayer(ThermionEntity entity, int layer);
///
/// Renders an outline around [entity] with the given color.
///
Future setStencilHighlight(ThermionEntity entity,
{double r = 1.0, double g = 0.0, double b = 0.0});
///
/// Removes the outline around [entity]. Noop if there was no highlight.
///
Future removeStencilHighlight(ThermionEntity entity);
Future setVisibilityLayer(ThermionEntity entity, VisibilityLayers layer);
///
/// Decodes the specified image data and creates a texture.
@@ -908,7 +837,7 @@ abstract class ThermionViewer {
///
///
///
Future<MaterialInstance?> getMaterialInstanceAt(
Future<MaterialInstance> getMaterialInstanceAt(
ThermionEntity entity, int index);
///

View File

@@ -8,7 +8,7 @@ import 'package:thermion_dart/thermion_dart.dart';
import 'package:vector_math/vector_math_64.dart';
import 'dart:async';
import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'events.dart';
import 'shared_types/camera.dart';
class ThermionViewerStub extends ThermionViewer {
@@ -18,16 +18,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future addBoneAnimation(ThermionEntity entity, BoneAnimationData animation,
{int skinIndex = 0,
double fadeInInSecs = 0.0,
double fadeOutInSecs = 0.0,
double maxDelta = 1.0}) {
// TODO: implement addBoneAnimation
throw UnimplementedError();
}
@override
Future addCollisionComponent(ThermionEntity entity,
{void Function(int entityId1, int entityId2)? callback,
@@ -77,44 +67,12 @@ class ThermionViewerStub extends ThermionViewer {
}
@override
Future<ThermionEntity> createInstance(ThermionEntity entity) {
// TODO: implement createInstance
throw UnimplementedError();
}
@override
Future dispose() {
// TODO: implement dispose
throw UnimplementedError();
}
@override
Future<double> getAnimationDuration(
ThermionEntity entity, int animationIndex) {
// TODO: implement getAnimationDuration
throw UnimplementedError();
}
@override
Future<List<String>> getAnimationNames(ThermionEntity entity) {
// TODO: implement getAnimationNames
throw UnimplementedError();
}
@override
Future<ThermionEntity> getBone(ThermionEntity parent, int boneIndex,
{int skinIndex = 0}) {
// TODO: implement getBone
throw UnimplementedError();
}
@override
Future<List<String>> getBoneNames(ThermionEntity entity,
{int skinIndex = 0}) {
// TODO: implement getBoneNames
throw UnimplementedError();
}
@override
Future<double> getCameraCullingFar() {
@@ -170,58 +128,12 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future<List<ThermionEntity>> getChildEntities(
ThermionEntity parent, bool renderableOnly) {
// TODO: implement getChildEntities
throw UnimplementedError();
}
@override
Future<ThermionEntity> getChildEntity(
ThermionEntity parent, String childName) {
// TODO: implement getChildEntity
throw UnimplementedError();
}
@override
Future<List<String>> getChildEntityNames(ThermionEntity entity,
{bool renderableOnly = true}) {
// TODO: implement getChildEntityNames
throw UnimplementedError();
}
@override
Future<int> getInstanceCount(ThermionEntity entity) {
// TODO: implement getInstanceCount
throw UnimplementedError();
}
@override
Future<List<ThermionEntity>> getInstances(ThermionEntity entity) {
// TODO: implement getInstances
throw UnimplementedError();
}
@override
Future<Matrix4> getInverseBindMatrix(ThermionEntity parent, int boneIndex,
{int skinIndex = 0}) {
// TODO: implement getInverseBindMatrix
throw UnimplementedError();
}
@override
Future<Matrix4> getLocalTransform(ThermionEntity entity) {
// TODO: implement getLocalTransform
throw UnimplementedError();
}
@override
Future<List<String>> getMorphTargetNames(
ThermionEntity entity, ThermionEntity childEntity) {
// TODO: implement getMorphTargetNames
throw UnimplementedError();
}
@override
String? getNameForEntity(ThermionEntity entity) {
@@ -241,11 +153,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future hide(ThermionEntity entity, String? meshName) {
// TODO: implement hide
throw UnimplementedError();
}
@override
// TODO: implement initialized
@@ -296,27 +203,6 @@ class ThermionViewerStub extends ThermionViewer {
// TODO: implement pickResult
Stream<FilamentPickResult> get pickResult => throw UnimplementedError();
@override
Future playAnimation(ThermionEntity entity, int index,
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0,
double startOffset=0.0}) {
// TODO: implement playAnimation
throw UnimplementedError();
}
@override
Future playAnimationByName(ThermionEntity entity, String name,
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0}) {
// TODO: implement playAnimationByName
throw UnimplementedError();
}
@override
Future queuePositionUpdate(
ThermionEntity entity, double x, double y, double z,
@@ -352,12 +238,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future removeEntity(ThermionEntity entity) {
// TODO: implement removeEntity
throw UnimplementedError();
}
@override
Future removeIbl() {
// TODO: implement removeIbl
@@ -381,17 +261,6 @@ class ThermionViewerStub extends ThermionViewer {
// TODO: implement rendering
bool get rendering => throw UnimplementedError();
@override
Future resetBones(ThermionEntity entity) {
// TODO: implement resetBones
throw UnimplementedError();
}
@override
Future reveal(ThermionEntity entity, String? meshName) {
// TODO: implement reveal
throw UnimplementedError();
}
@override
Future rotateEnd() {
@@ -417,12 +286,7 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future setAnimationFrame(
ThermionEntity entity, int index, int animationFrame) {
// TODO: implement setAnimationFrame
throw UnimplementedError();
}
@override
Future setAntiAliasing(bool msaa, bool fxaa, bool taa) {
@@ -546,24 +410,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future clearMorphAnimationData(ThermionEntity entity) {
throw UnimplementedError();
}
@override
Future setMorphAnimationData(
ThermionEntity entity, MorphAnimationData animation,
{List<String>? targetMeshNames}) {
// TODO: implement setMorphAnimationData
throw UnimplementedError();
}
@override
Future setMorphTargetWeights(ThermionEntity entity, List<double> weights) {
// TODO: implement setMorphTargetWeights
throw UnimplementedError();
}
@override
Future setParent(ThermionEntity child, ThermionEntity parent, { bool preserveScaling = false}) {
@@ -644,17 +490,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future stopAnimation(ThermionEntity entity, int animationIndex) {
// TODO: implement stopAnimation
throw UnimplementedError();
}
@override
Future stopAnimationByName(ThermionEntity entity, String name) {
// TODO: implement stopAnimationByName
throw UnimplementedError();
}
@override
Future testCollisions(ThermionEntity entity) {
@@ -811,18 +646,7 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future<ThermionEntity> loadGlb(String path, {int numInstances = 1, bool keepData = false}) {
// TODO: implement loadGlb
throw UnimplementedError();
}
@override
Future<ThermionEntity> loadGltf(String path, String relativeResourcePath, {bool keepData = false}) {
// TODO: implement loadGltf
throw UnimplementedError();
}
@override
Future setMaterialPropertyFloat(ThermionEntity entity, String propertyName, int materialIndex, double value) {
@@ -836,9 +660,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
// TODO: implement sceneUpdated
Stream<SceneUpdateEvent> get sceneUpdated => throw UnimplementedError();
@override
Future<ThermionEntity> addDirectLight(DirectLight light) {
@@ -882,14 +703,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future createGeometry(Geometry geometry, {MaterialInstance? materialInstance, bool keepData = false}) {
// TODO: implement createGeometry
throw UnimplementedError();
}
@override
Future setMaterialPropertyInt(ThermionEntity entity, String propertyName, int materialIndex, int value) {
// TODO: implement setMaterialPropertyInt
@@ -1052,12 +865,6 @@ class ThermionViewerStub extends ThermionViewer {
throw UnimplementedError();
}
@override
Future<ThermionEntity> loadGlbFromBuffer(Uint8List data, {int numInstances = 1, bool keepData = false, int priority = 4, int layer = 0, bool loadResourcesAsync= false}) {
// TODO: implement loadGlbFromBuffer
throw UnimplementedError();
}
@override
Future destroyRenderTarget(covariant RenderTarget renderTarget) {
// TODO: implement destroyRenderTarget
@@ -1081,6 +888,189 @@ class ThermionViewerStub extends ThermionViewer {
// TODO: implement getRenderableBoundingBox
throw UnimplementedError();
}
@override
Future pick(int x, int y) {
// TODO: implement pick
throw UnimplementedError();
}
@override
Future<ThermionAsset> createInstance(covariant ThermionAsset asset, {covariant List<MaterialInstance>? materialInstances = null}) {
// TODO: implement createInstance
throw UnimplementedError();
}
@override
Future<int> getInstanceCount(covariant ThermionAsset entity) {
// TODO: implement getInstanceCount
throw UnimplementedError();
}
@override
Future<List<ThermionEntity>> getInstances(covariant ThermionAsset entity) {
// TODO: implement getInstances
throw UnimplementedError();
}
@override
Future hide(ThermionEntity entity) {
// TODO: implement hide
throw UnimplementedError();
}
@override
Future<ThermionAsset> loadGlb(String path, {int numInstances = 1, bool keepData = false}) {
// TODO: implement loadGlb
throw UnimplementedError();
}
@override
Future<ThermionAsset> loadGltf(String path, String relativeResourcePath, {bool keepData = false}) {
// TODO: implement loadGltf
throw UnimplementedError();
}
@override
Future reveal(ThermionEntity entity) {
// TODO: implement reveal
throw UnimplementedError();
}
@override
Future<ThermionAsset> loadGlbFromBuffer(Uint8List data, {int numInstances = 1, bool keepData = false, int priority = 4, int layer = 0, bool loadResourcesAsync=false}) {
// TODO: implement loadGlbFromBuffer
throw UnimplementedError();
}
@override
Future addBoneAnimation(ThermionAsset asset, BoneAnimationData animation, {int skinIndex = 0, double fadeInInSecs = 0.0, double fadeOutInSecs = 0.0, double maxDelta = 1.0}) {
// TODO: implement addBoneAnimation
throw UnimplementedError();
}
@override
Future<double> getAnimationDuration(covariant ThermionAsset asset, int animationIndex) {
// TODO: implement getAnimationDuration
throw UnimplementedError();
}
@override
Future<List<String>> getAnimationNames(covariant ThermionAsset asset) {
// TODO: implement getAnimationNames
throw UnimplementedError();
}
@override
Future<ThermionEntity> getBone(covariant ThermionAsset asset, int boneIndex, {int skinIndex = 0}) {
// TODO: implement getBone
throw UnimplementedError();
}
@override
Future<List<String>> getBoneNames(covariant ThermionAsset asset, {int skinIndex = 0}) {
// TODO: implement getBoneNames
throw UnimplementedError();
}
@override
Future<List<ThermionEntity>> getChildEntities(covariant ThermionAsset asset) {
// TODO: implement getChildEntities
throw UnimplementedError();
}
@override
Future<ThermionEntity?> getChildEntity(covariant ThermionAsset asset, String childName) {
// TODO: implement getChildEntity
throw UnimplementedError();
}
@override
Future<Matrix4> getInverseBindMatrix(covariant ThermionAsset asset, int boneIndex, {int skinIndex = 0}) {
// TODO: implement getInverseBindMatrix
throw UnimplementedError();
}
@override
Future<List<String>> getMorphTargetNames(covariant ThermionAsset asset, ThermionEntity childEntity) {
// TODO: implement getMorphTargetNames
throw UnimplementedError();
}
@override
Future playAnimationByName(covariant ThermionAsset asset, String name, {bool loop = false, bool reverse = false, bool replaceActive = true, double crossfade = 0.0}) {
// TODO: implement playAnimationByName
throw UnimplementedError();
}
@override
Future setAnimationFrame(covariant ThermionAsset asset, int index, int animationFrame) {
// TODO: implement setAnimationFrame
throw UnimplementedError();
}
@override
Future setMorphAnimationData(ThermionAsset asset, MorphAnimationData animation, {List<String>? targetMeshNames}) {
// TODO: implement setMorphAnimationData
throw UnimplementedError();
}
@override
Future stopAnimation(covariant ThermionAsset asset, int animationIndex) {
// TODO: implement stopAnimation
throw UnimplementedError();
}
@override
Future stopAnimationByName(covariant ThermionAsset asset, String name) {
// TODO: implement stopAnimationByName
throw UnimplementedError();
}
@override
Future playAnimation(ThermionAsset asset, int index, {bool loop = false, bool reverse = false, bool replaceActive = true, double crossfade = 0.0, double startOffset = 0.0}) {
// TODO: implement playAnimation
throw UnimplementedError();
}
@override
Future removeEntity(ThermionAsset asset) {
// TODO: implement removeEntity
throw UnimplementedError();
}
@override
Future resetBones(ThermionAsset asset) {
// TODO: implement resetBones
throw UnimplementedError();
}
@override
Future clearMorphAnimationData(ThermionEntity entity) {
// TODO: implement clearMorphAnimationData
throw UnimplementedError();
}
@override
Future<ThermionAsset> createGeometry(Geometry geometry, {covariant List<MaterialInstance>? materialInstances, bool keepData = false}) {
// TODO: implement createGeometry
throw UnimplementedError();
}
@override
Future setGltfAnimationFrame(covariant ThermionAsset asset, int index, int animationFrame) {
// TODO: implement setGltfAnimationFrame
throw UnimplementedError();
}
@override
Future setMorphTargetWeights(ThermionEntity entity, List<double> weights) {
// TODO: implement setMorphTargetWeights
throw UnimplementedError();
}
}

View File

@@ -4,17 +4,6 @@ class ThermionWasmMaterialInstance extends MaterialInstance {
final int pointer;
ThermionWasmMaterialInstance(this.pointer);
@override
Future setDepthCullingEnabled(bool enabled) {
// TODO: implement setDepthCullingEnabled
throw UnimplementedError();
}
@override
Future setDepthWriteEnabled(bool enabled) {
// TODO: implement setDepthWriteEnabled
throw UnimplementedError();
}
@override
Future setParameterFloat2(String name, double x, double y) {
@@ -45,4 +34,64 @@ class ThermionWasmMaterialInstance extends MaterialInstance {
// TODO: implement setParameterInt
throw UnimplementedError();
}
@override
Future setDepthCullingEnabled(enabled) {
// TODO: implement setDepthCullingEnabled
throw UnimplementedError();
}
@override
Future setDepthWriteEnabled(enabled) {
// TODO: implement setDepthWriteEnabled
throw UnimplementedError();
}
@override
Future setStencilCompareFunction(SamplerCompareFunction func, [StencilFace face = StencilFace.FRONT_AND_BACK]) {
// TODO: implement setStencilCompareFunction
throw UnimplementedError();
}
@override
Future setStencilOpDepthFail(StencilOperation op, [StencilFace face = StencilFace.FRONT_AND_BACK]) {
// TODO: implement setStencilOpDepthFail
throw UnimplementedError();
}
@override
Future setStencilOpDepthStencilPass(StencilOperation op, [StencilFace face = StencilFace.FRONT_AND_BACK]) {
// TODO: implement setStencilOpDepthStencilPass
throw UnimplementedError();
}
@override
Future setStencilOpStencilFail(StencilOperation op, [StencilFace face = StencilFace.FRONT_AND_BACK]) {
// TODO: implement setStencilOpStencilFail
throw UnimplementedError();
}
@override
Future setStencilReferenceValue(int value, [StencilFace face = StencilFace.FRONT_AND_BACK]) {
// TODO: implement setStencilReferenceValue
throw UnimplementedError();
}
@override
Future<bool> isStencilWriteEnabled() {
// TODO: implement isStencilWriteEnabled
throw UnimplementedError();
}
@override
Future setCullingMode(CullingMode cullingMode) {
// TODO: implement setCullingMode
throw UnimplementedError();
}
@override
Future setStencilWriteEnabled(bool enabled) {
// TODO: implement setStencilWriteEnabled
throw UnimplementedError();
}
}