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:
@@ -4,4 +4,6 @@ export 'src/input_handler.dart';
|
||||
export 'src/delegates.dart';
|
||||
export 'src/delegate_input_handler.dart';
|
||||
export 'src/implementations/default_pick_delegate.dart';
|
||||
export 'src/implementations/gizmo_pick_delegate.dart';
|
||||
export 'src/implementations/gizmo_input_handler.dart';
|
||||
export 'src/implementations/third_person_camera_delegate.dart';
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
@@ -54,6 +53,13 @@ class DelegateInputHandler implements InputHandler {
|
||||
_actions = actions;
|
||||
}
|
||||
|
||||
if (pickDelegate != null) {
|
||||
if (_actions[InputType.LMB_DOWN] != null) {
|
||||
throw Exception();
|
||||
}
|
||||
_actions[InputType.LMB_DOWN] = InputAction.PICK;
|
||||
}
|
||||
|
||||
for (var gestureType in InputType.values) {
|
||||
_inputDeltas[gestureType] = Vector3.zero();
|
||||
}
|
||||
@@ -94,7 +100,7 @@ class DelegateInputHandler implements InputHandler {
|
||||
clampY: clampY,
|
||||
entity: entity,
|
||||
rotationSensitivity: rotateSensitivity,
|
||||
zoomSensitivity:zoomSensitivity,
|
||||
zoomSensitivity: zoomSensitivity,
|
||||
panSensitivity: panSensitivity,
|
||||
movementSensitivity: movementSensitivity),
|
||||
actions: {
|
||||
@@ -265,7 +271,8 @@ class DelegateInputHandler implements InputHandler {
|
||||
Future<void> onScaleEnd(int pointerCount, double velocity) async {}
|
||||
|
||||
@override
|
||||
Future<void> onScaleStart(Vector2 localPosition, int pointerCount, Duration? sourceTimestamp ) async {
|
||||
Future<void> onScaleStart(Vector2 localPosition, int pointerCount,
|
||||
Duration? sourceTimestamp) async {
|
||||
// noop
|
||||
}
|
||||
|
||||
|
||||
@@ -24,4 +24,5 @@ abstract class VelocityDelegate {
|
||||
abstract class PickDelegate {
|
||||
const PickDelegate();
|
||||
void pick(Vector2 location);
|
||||
Future dispose();
|
||||
}
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
class DefaultPickDelegate extends PickDelegate {
|
||||
final ThermionViewer viewer;
|
||||
|
||||
const DefaultPickDelegate(this.viewer);
|
||||
DefaultPickDelegate(this.viewer);
|
||||
|
||||
final _picked = StreamController<ThermionEntity>();
|
||||
Stream<ThermionEntity> get picked => _picked.stream;
|
||||
|
||||
Future dispose() async {
|
||||
_picked.close();
|
||||
}
|
||||
|
||||
@override
|
||||
void pick(Vector2 location) {
|
||||
viewer.pick(location.x.toInt(), location.y.toInt());
|
||||
viewer.pick(location.x.toInt(), location.y.toInt(), (result) {
|
||||
_picked.sink.add(result.entity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,13 +86,14 @@ class FreeFlightInputHandlerDelegate implements InputHandlerDelegate {
|
||||
if (_queuedRotationDelta.length2 > 0.0) {
|
||||
double deltaX = _queuedRotationDelta.x * rotationSensitivity;
|
||||
double deltaY = _queuedRotationDelta.y * rotationSensitivity;
|
||||
relativeRotation = Quaternion.axisAngle(current.up, -deltaX) * Quaternion.axisAngle(current.right, -deltaY);
|
||||
relativeRotation = Quaternion.axisAngle(current.up, -deltaX) *
|
||||
Quaternion.axisAngle(current.right, -deltaY);
|
||||
_queuedRotationDelta = Vector2.zero();
|
||||
}
|
||||
|
||||
// Apply (mouse) pan
|
||||
if (_queuedTranslateDelta.length2 > 0.0) {
|
||||
double deltaX = _queuedTranslateDelta.x * panSensitivity;
|
||||
double deltaX = -_queuedTranslateDelta.x * panSensitivity;
|
||||
double deltaY = _queuedTranslateDelta.y * panSensitivity;
|
||||
double deltaZ = -_queuedTranslateDelta.z * panSensitivity;
|
||||
|
||||
@@ -104,8 +105,9 @@ class FreeFlightInputHandlerDelegate implements InputHandlerDelegate {
|
||||
|
||||
// Apply zoom
|
||||
if (_queuedZoomDelta != 0.0) {
|
||||
relativeTranslation += current.forward
|
||||
..scaled(_queuedZoomDelta * zoomSensitivity);
|
||||
var zoomTranslation = current.forward..scaled(zoomSensitivity);
|
||||
zoomTranslation.scale(_queuedZoomDelta);
|
||||
relativeTranslation += zoomTranslation;
|
||||
_queuedZoomDelta = 0.0;
|
||||
}
|
||||
|
||||
@@ -128,11 +130,10 @@ class FreeFlightInputHandlerDelegate implements InputHandlerDelegate {
|
||||
|
||||
await viewer.setTransform(
|
||||
await entity,
|
||||
|
||||
Matrix4.compose(
|
||||
relativeTranslation, relativeRotation, Vector3(1, 1, 1)) * current );
|
||||
Matrix4.compose(
|
||||
relativeTranslation, relativeRotation, Vector3(1, 1, 1)) *
|
||||
current);
|
||||
|
||||
_executing = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
import 'dart:async';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
class _Gizmo {
|
||||
bool isVisible = false;
|
||||
|
||||
final ThermionViewer viewer;
|
||||
final nonPickable = <ThermionEntity>{};
|
||||
final GizmoAsset _asset;
|
||||
|
||||
_Gizmo(this._asset, this.viewer);
|
||||
|
||||
Axis? _active;
|
||||
Axis? get active => _active;
|
||||
|
||||
Vector3? _activeCords;
|
||||
|
||||
void checkHover(int x, int y) async {
|
||||
_asset.pick(x, y, handler: (result, coords) async {
|
||||
switch (result) {
|
||||
case GizmoPickResultType.None:
|
||||
await _asset.unhighlight();
|
||||
_active = null;
|
||||
break;
|
||||
case GizmoPickResultType.AxisX:
|
||||
_active = Axis.X;
|
||||
_activeCords = coords;
|
||||
|
||||
case GizmoPickResultType.AxisY:
|
||||
_active = Axis.Y;
|
||||
_activeCords = coords;
|
||||
|
||||
case GizmoPickResultType.AxisZ:
|
||||
_active = Axis.Z;
|
||||
_activeCords = coords;
|
||||
|
||||
default:
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Matrix4? gizmoTransform;
|
||||
|
||||
Future attach(ThermionEntity entity) async {
|
||||
if (_asset.nonPickableEntities.contains(entity)) {
|
||||
return;
|
||||
}
|
||||
final transform = await viewer.getWorldTransform(entity);
|
||||
transform.setRotation(Matrix3.identity());
|
||||
transform.setDiagonal(Vector4.all(1.0));
|
||||
await viewer.setTransform(_asset.entity, transform);
|
||||
await viewer.setParent(entity, _asset.entity);
|
||||
if (!isVisible) {
|
||||
await _asset.addToScene();
|
||||
isVisible = true;
|
||||
}
|
||||
gizmoTransform = await viewer.getWorldTransform(_asset.entity);
|
||||
}
|
||||
|
||||
Future detach() async {
|
||||
await _asset.removeFromScene();
|
||||
_active = null;
|
||||
isVisible = false;
|
||||
}
|
||||
|
||||
void _updateTransform(Vector2 currentPosition, Vector2 delta) async {
|
||||
if (gizmoTransform == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var view = await viewer.getViewAt(0);
|
||||
var camera = await viewer.getActiveCamera();
|
||||
|
||||
var viewport = await view.getViewport();
|
||||
|
||||
var projectionMatrix = await viewer.getCameraProjectionMatrix();
|
||||
var viewMatrix = await camera.getViewMatrix();
|
||||
var inverseViewMatrix = await camera.getModelMatrix();
|
||||
var inverseProjectionMatrix = projectionMatrix.clone()..invert();
|
||||
|
||||
// get gizmo position in screenspace
|
||||
var gizmoPositionWorldSpace = gizmoTransform!.getTranslation();
|
||||
Vector4 gizmoClipSpace = projectionMatrix *
|
||||
viewMatrix *
|
||||
Vector4(gizmoPositionWorldSpace.x, gizmoPositionWorldSpace.y,
|
||||
gizmoPositionWorldSpace.z, 1.0);
|
||||
|
||||
var gizmoNdc = gizmoClipSpace / gizmoClipSpace.w;
|
||||
|
||||
var gizmoScreenSpace = Vector2(((gizmoNdc.x / 2) + 0.5) * viewport.width,
|
||||
viewport.height - (((gizmoNdc.y / 2) + 0.5) * viewport.height));
|
||||
|
||||
gizmoScreenSpace += delta;
|
||||
|
||||
gizmoNdc = Vector4(((gizmoScreenSpace.x / viewport.width) - 0.5) * 2,
|
||||
(((gizmoScreenSpace.y / viewport.height)) - 0.5) * -2, gizmoNdc.z, 1.0);
|
||||
|
||||
var gizmoViewSpace = inverseProjectionMatrix * gizmoNdc;
|
||||
gizmoViewSpace /= gizmoViewSpace.w;
|
||||
|
||||
var newPosition = (inverseViewMatrix * gizmoViewSpace).xyz;
|
||||
|
||||
Vector3 worldSpaceDelta = newPosition - gizmoTransform!.getTranslation();
|
||||
worldSpaceDelta.multiply(_active!.asVector());
|
||||
|
||||
gizmoTransform!.setTranslation(gizmoTransform!.getTranslation() + worldSpaceDelta);
|
||||
|
||||
await viewer.setTransform(_asset.entity, gizmoTransform!);
|
||||
}
|
||||
}
|
||||
|
||||
class GizmoInputHandler extends InputHandler {
|
||||
final InputHandler wrapped;
|
||||
final ThermionViewer viewer;
|
||||
late final _Gizmo translationGizmo;
|
||||
|
||||
GizmoInputHandler({required this.wrapped, required this.viewer}) {
|
||||
initialize();
|
||||
}
|
||||
|
||||
final _initialized = Completer<bool>();
|
||||
Future initialize() async {
|
||||
if (_initialized.isCompleted) {
|
||||
throw Exception("Already initialized");
|
||||
}
|
||||
await viewer.initialized;
|
||||
final view = await viewer.getViewAt(0);
|
||||
var translationGizmoAsset =
|
||||
await viewer.createGizmo(view, GizmoType.translation);
|
||||
this.translationGizmo = _Gizmo(translationGizmoAsset, viewer);
|
||||
_initialized.complete(true);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream get cameraUpdated => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future dispose() async {
|
||||
await viewer.removeEntity(translationGizmo._asset);
|
||||
}
|
||||
|
||||
@override
|
||||
InputAction? getActionForType(InputType gestureType) {
|
||||
if (gestureType == InputType.LMB_DOWN) {
|
||||
return InputAction.PICK;
|
||||
}
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> get initialized => _initialized.future;
|
||||
|
||||
@override
|
||||
void keyDown(PhysicalKey key) {
|
||||
wrapped.keyDown(key);
|
||||
}
|
||||
|
||||
@override
|
||||
void keyUp(PhysicalKey key) {
|
||||
wrapped.keyDown(key);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onPointerDown(Vector2 localPosition, bool isMiddle) async {
|
||||
if (!_initialized.isCompleted) {
|
||||
return;
|
||||
}
|
||||
await viewer.pick(localPosition.x.toInt(), localPosition.y.toInt(),
|
||||
(result) {
|
||||
translationGizmo.attach(result.entity);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onPointerHover(Vector2 localPosition, Vector2 delta) async {
|
||||
if (!_initialized.isCompleted) {
|
||||
return;
|
||||
}
|
||||
translationGizmo.checkHover(
|
||||
localPosition.x.floor(), localPosition.y.floor());
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onPointerMove(
|
||||
Vector2 localPosition, Vector2 delta, bool isMiddle) async {
|
||||
if (!isMiddle && translationGizmo._active != null) {
|
||||
final scaledDelta = Vector2(
|
||||
delta.x,
|
||||
delta.y,
|
||||
);
|
||||
translationGizmo._updateTransform(localPosition, scaledDelta);
|
||||
return;
|
||||
}
|
||||
return wrapped.onPointerMove(localPosition, delta, isMiddle);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onPointerScroll(
|
||||
Vector2 localPosition, double scrollDelta) async {
|
||||
return wrapped.onPointerScroll(localPosition, scrollDelta);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onPointerUp(bool isMiddle) async {
|
||||
await wrapped.onPointerUp(isMiddle);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onScaleEnd(int pointerCount, double velocity) {
|
||||
return wrapped.onScaleEnd(pointerCount, velocity);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onScaleStart(
|
||||
Vector2 focalPoint, int pointerCount, Duration? sourceTimestamp) {
|
||||
return wrapped.onScaleStart(focalPoint, pointerCount, sourceTimestamp);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> onScaleUpdate(
|
||||
Vector2 focalPoint,
|
||||
Vector2 focalPointDelta,
|
||||
double horizontalScale,
|
||||
double verticalScale,
|
||||
double scale,
|
||||
int pointerCount,
|
||||
double rotation,
|
||||
Duration? sourceTimestamp) {
|
||||
return wrapped.onScaleUpdate(focalPoint, focalPointDelta, horizontalScale,
|
||||
verticalScale, scale, pointerCount, rotation, sourceTimestamp);
|
||||
}
|
||||
|
||||
@override
|
||||
void setActionForType(InputType gestureType, InputAction gestureAction) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// import 'dart:async';
|
||||
|
||||
// import 'package:thermion_dart/thermion_dart.dart';
|
||||
// import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
// class GizmoPickDelegate extends PickDelegate {
|
||||
// final ThermionViewer viewer;
|
||||
// late final GizmoAsset translationGizmo;
|
||||
|
||||
// GizmoPickDelegate(this.viewer) {
|
||||
// initialize();
|
||||
// }
|
||||
|
||||
// bool _initialized = false;
|
||||
// Future initialize() async {
|
||||
// if (_initialized) {
|
||||
// throw Exception("Already initialized");
|
||||
// }
|
||||
// final view = await viewer.getViewAt(0);
|
||||
// translationGizmo = await viewer.createGizmo(view, GizmoType.translation);
|
||||
// await translationGizmo.addToScene();
|
||||
// _initialized = true;
|
||||
// }
|
||||
|
||||
// final _picked = StreamController<ThermionEntity>();
|
||||
// Stream<ThermionEntity> get picked => _picked.stream;
|
||||
|
||||
// Future dispose() async {
|
||||
// _picked.close();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void pick(Vector2 location) {
|
||||
// if (!_initialized) {
|
||||
// return;
|
||||
// }
|
||||
// viewer.pick(location.x.toInt(), location.y.toInt(), (result) {
|
||||
// translationGizmo.attach(result.entity);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
@@ -1,230 +1,329 @@
|
||||
// import 'dart:async';
|
||||
|
||||
// import 'package:flutter/gestures.dart';
|
||||
// import 'package:flutter/services.dart';
|
||||
// import 'package:logging/logging.dart';
|
||||
// import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
|
||||
// import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
||||
// import 'dart:ui';
|
||||
// import 'package:thermion_dart/thermion_dart/input/input_handler.dart';
|
||||
// import 'package:thermion_dart/thermion_dart.dart';
|
||||
// import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
// // Renamed implementation
|
||||
// class PickingCameraGestureHandler implements InputHandler {
|
||||
// import '../input_handler.dart';
|
||||
|
||||
// class GizmoPickingHandler implements InputHandler {
|
||||
// final ThermionViewer viewer;
|
||||
// final bool enableCamera;
|
||||
// final bool enablePicking;
|
||||
// final Logger _logger = Logger("PickingCameraGestureHandler");
|
||||
// late final GizmoAsset _translationGizmo;
|
||||
|
||||
// AbstractGizmo? _gizmo;
|
||||
// Timer? _scrollTimer;
|
||||
// ThermionEntity? _highlightedEntity;
|
||||
// StreamSubscription<FilamentPickResult>? _pickResultSubscription;
|
||||
// GizmoPickingHandler(this.viewer) {}
|
||||
|
||||
// bool _gizmoAttached = false;
|
||||
// final _initialized = Completer<bool>();
|
||||
|
||||
// PickingCameraGestureHandler({
|
||||
// required this.viewer,
|
||||
// this.enableCamera = true,
|
||||
// this.enablePicking = true,
|
||||
// }) {
|
||||
// try {
|
||||
// _gizmo = viewer.gizmo;
|
||||
// } catch (err) {
|
||||
// _logger.warning(
|
||||
// "Failed to get gizmo. If you are running on WASM, this is expected");
|
||||
// Future initialize() async {
|
||||
// if (_initialized.isCompleted) {
|
||||
// throw Exception("Already initialized");
|
||||
// }
|
||||
// final view = await viewer.getViewAt(0);
|
||||
// _translationGizmo = await viewer.createGizmo(view, GizmoType.translation);
|
||||
// _initialized.complete(true);
|
||||
// }
|
||||
|
||||
// _pickResultSubscription = viewer.pickResult.listen(_onPickResult);
|
||||
|
||||
// // Add keyboard listener
|
||||
// RawKeyboard.instance.addListener(_handleKeyEvent);
|
||||
// Future dispose() async {
|
||||
// await viewer.removeEntity(_translationGizmo);
|
||||
// }
|
||||
|
||||
// @override
|
||||
// ThermionGestureState get currentState => _currentState;
|
||||
|
||||
// void _handleKeyEvent(RawKeyEvent event) {
|
||||
// if (event is RawKeyDownEvent &&
|
||||
// event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
// _resetToNullState();
|
||||
// }
|
||||
// }
|
||||
|
||||
// void _resetToNullState() async {
|
||||
// _currentState = ThermionGestureState.NULL;
|
||||
// if (_highlightedEntity != null) {
|
||||
// await viewer.removeStencilHighlight(_highlightedEntity!);
|
||||
// _highlightedEntity = null;
|
||||
// }
|
||||
// }
|
||||
|
||||
// void _onPickResult(FilamentPickResult result) async {
|
||||
// var targetEntity = await viewer.getAncestor(result.entity) ?? result.entity;
|
||||
|
||||
// if (_highlightedEntity != targetEntity) {
|
||||
// if (_highlightedEntity != null) {
|
||||
// await viewer.removeStencilHighlight(_highlightedEntity!);
|
||||
// }
|
||||
|
||||
// _highlightedEntity = targetEntity;
|
||||
// if (_highlightedEntity != null) {
|
||||
// await viewer.setStencilHighlight(_highlightedEntity!);
|
||||
// _gizmo?.attach(_highlightedEntity!);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Stream get cameraUpdated => throw UnimplementedError();
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerHover(Offset localPosition, Offset delta) async {
|
||||
// if (_gizmoAttached) {
|
||||
// _gizmo?.checkHover(localPosition.dx, localPosition.dy);
|
||||
// }
|
||||
|
||||
// if (_highlightedEntity != null) {
|
||||
// await viewer.queuePositionUpdateFromViewportCoords(
|
||||
// _highlightedEntity!,
|
||||
// localPosition.dx,
|
||||
// localPosition.dy,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerScroll(Offset localPosition, double scrollDelta) async {
|
||||
// if (!enableCamera) {
|
||||
// return;
|
||||
// }
|
||||
// if (_currentState == ThermionGestureState.NULL ||
|
||||
// _currentState == ThermionGestureState.ZOOMING) {
|
||||
// await _zoom(localPosition, scrollDelta);
|
||||
// }
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerDown(Offset localPosition, int buttons) async {
|
||||
// if (_highlightedEntity != null) {
|
||||
// _resetToNullState();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (enablePicking && buttons != kMiddleMouseButton) {
|
||||
// viewer.pick(localPosition.dx.toInt(), localPosition.dy.toInt());
|
||||
// }
|
||||
|
||||
// if (buttons == kMiddleMouseButton && enableCamera) {
|
||||
// await viewer.rotateStart(localPosition.dx, localPosition.dy);
|
||||
// _currentState = ThermionGestureState.ROTATING;
|
||||
// } else if (buttons == kPrimaryMouseButton && enableCamera) {
|
||||
// await viewer.panStart(localPosition.dx, localPosition.dy);
|
||||
// _currentState = ThermionGestureState.PANNING;
|
||||
// }
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerMove(
|
||||
// Offset localPosition, Offset delta, int buttons) async {
|
||||
// if (_highlightedEntity != null) {
|
||||
// await _handleEntityHighlightedMove(localPosition);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// switch (_currentState) {
|
||||
// case ThermionGestureState.NULL:
|
||||
// break;
|
||||
|
||||
// case ThermionGestureState.ROTATING:
|
||||
// if (enableCamera) {
|
||||
// await viewer.rotateUpdate(localPosition.dx, localPosition.dy);
|
||||
// }
|
||||
// break;
|
||||
// case ThermionGestureState.PANNING:
|
||||
// if (enableCamera) {
|
||||
// await viewer.panUpdate(localPosition.dx, localPosition.dy);
|
||||
// }
|
||||
// break;
|
||||
// case ThermionGestureState.ZOOMING:
|
||||
// // ignore
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerUp(int buttons) async {
|
||||
// switch (_currentState) {
|
||||
// case ThermionGestureState.ROTATING:
|
||||
// await viewer.rotateEnd();
|
||||
// _currentState = ThermionGestureState.NULL;
|
||||
// break;
|
||||
// case ThermionGestureState.PANNING:
|
||||
// await viewer.panEnd();
|
||||
// _currentState = ThermionGestureState.NULL;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<void> _handleEntityHighlightedMove(Offset localPosition) async {
|
||||
// if (_highlightedEntity != null) {
|
||||
// await viewer.queuePositionUpdateFromViewportCoords(
|
||||
// _highlightedEntity!,
|
||||
// localPosition.dx,
|
||||
// localPosition.dy,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// Future<void> _zoom(Offset localPosition, double scrollDelta) async {
|
||||
// _scrollTimer?.cancel();
|
||||
// _currentState = ThermionGestureState.ZOOMING;
|
||||
// await viewer.zoomBegin();
|
||||
// await viewer.zoomUpdate(
|
||||
// localPosition.dx, localPosition.dy, scrollDelta > 0 ? 1 : -1);
|
||||
|
||||
// _scrollTimer = Timer(const Duration(milliseconds: 100), () async {
|
||||
// await viewer.zoomEnd();
|
||||
// _currentState = ThermionGestureState.NULL;
|
||||
// });
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void dispose() {
|
||||
// _pickResultSubscription?.cancel();
|
||||
// if (_highlightedEntity != null) {
|
||||
// viewer.removeStencilHighlight(_highlightedEntity!);
|
||||
// }
|
||||
// RawKeyboard.instance.removeListener(_handleKeyEvent);
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<bool> get initialized => viewer.initialized;
|
||||
|
||||
// @override
|
||||
// InputAction getActionForType(InputType type) {
|
||||
// // TODO: implement getActionForType
|
||||
// InputAction? getActionForType(InputType gestureType) {
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onScaleEnd() {
|
||||
// Future<bool> get initialized => _initialized.future;
|
||||
|
||||
// @override
|
||||
// void keyDown(PhysicalKey key) {}
|
||||
|
||||
// @override
|
||||
// void keyUp(PhysicalKey key) {}
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerDown(Vector2 localPosition, bool isMiddle) {
|
||||
// viewer.pick(localPosition.x.floor(), localPosition.y.floor(), (axis) {
|
||||
|
||||
// })
|
||||
// // _translationGizmo.pick(
|
||||
// // localPosition.x.floor(), localPosition.y.floor(), (axis) {});
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerHover(Vector2 localPosition, Vector2 delta) {
|
||||
// // TODO: implement onPointerHover
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerMove(
|
||||
// Vector2 localPosition, Vector2 delta, bool isMiddle) {
|
||||
// // TODO: implement onPointerMove
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerScroll(Vector2 localPosition, double scrollDelta) {
|
||||
// // TODO: implement onPointerScroll
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onPointerUp(bool isMiddle) {
|
||||
// // TODO: implement onPointerUp
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onScaleEnd(int pointerCount, double velocity) {
|
||||
// // TODO: implement onScaleEnd
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onScaleStart() {
|
||||
// Future<void> onScaleStart(
|
||||
// Vector2 focalPoint, int pointerCount, Duration? sourceTimestamp) {
|
||||
// // TODO: implement onScaleStart
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> onScaleUpdate() {
|
||||
// Future<void> onScaleUpdate(
|
||||
// Vector2 focalPoint,
|
||||
// Vector2 focalPointDelta,
|
||||
// double horizontalScale,
|
||||
// double verticalScale,
|
||||
// double scale,
|
||||
// int pointerCount,
|
||||
// double rotation,
|
||||
// Duration? sourceTimestamp) {
|
||||
// // TODO: implement onScaleUpdate
|
||||
// throw UnimplementedError();
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void setActionForType(InputType type, InputAction action) {
|
||||
// void setActionForType(InputType gestureType, InputAction gestureAction) {
|
||||
// // TODO: implement setActionForType
|
||||
// }
|
||||
// }
|
||||
// // final ThermionViewer viewer;
|
||||
// // final bool enableCamera;
|
||||
// // final bool enablePicking;
|
||||
// // final Logger _logger = Logger("PickingCameraGestureHandler");
|
||||
|
||||
// // AbstractGizmo? _gizmo;
|
||||
// // Timer? _scrollTimer;
|
||||
// // ThermionEntity? _highlightedEntity;
|
||||
// // StreamSubscription<FilamentPickResult>? _pickResultSubscription;
|
||||
|
||||
// // bool _gizmoAttached = false;
|
||||
|
||||
// // PickingCameraGestureHandler({
|
||||
// // required this.viewer,
|
||||
// // this.enableCamera = true,
|
||||
// // this.enablePicking = true,
|
||||
// // }) {
|
||||
// // try {
|
||||
// // _gizmo = viewer.gizmo;
|
||||
// // } catch (err) {
|
||||
// // _logger.warning(
|
||||
// // "Failed to get gizmo. If you are running on WASM, this is expected");
|
||||
// // }
|
||||
|
||||
// // _pickResultSubscription = viewer.pickResult.listen(_onPickResult);
|
||||
|
||||
// // // Add keyboard listener
|
||||
// // RawKeyboard.instance.addListener(_handleKeyEvent);
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // ThermionGestureState get currentState => _currentState;
|
||||
|
||||
// // void _handleKeyEvent(RawKeyEvent event) {
|
||||
// // if (event is RawKeyDownEvent &&
|
||||
// // event.logicalKey == LogicalKeyboardKey.escape) {
|
||||
// // _resetToNullState();
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // void _resetToNullState() async {
|
||||
// // _currentState = ThermionGestureState.NULL;
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // await viewer.removeStencilHighlight(_highlightedEntity!);
|
||||
// // _highlightedEntity = null;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // void _onPickResult(FilamentPickResult result) async {
|
||||
// // var targetEntity = await viewer.getAncestor(result.entity) ?? result.entity;
|
||||
|
||||
// // if (_highlightedEntity != targetEntity) {
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // await viewer.removeStencilHighlight(_highlightedEntity!);
|
||||
// // }
|
||||
|
||||
// // _highlightedEntity = targetEntity;
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // await viewer.setStencilHighlight(_highlightedEntity!);
|
||||
// // _gizmo?.attach(_highlightedEntity!);
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onPointerHover(Offset localPosition, Offset delta) async {
|
||||
// // if (_gizmoAttached) {
|
||||
// // _gizmo?.checkHover(localPosition.dx, localPosition.dy);
|
||||
// // }
|
||||
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // await viewer.queuePositionUpdateFromViewportCoords(
|
||||
// // _highlightedEntity!,
|
||||
// // localPosition.dx,
|
||||
// // localPosition.dy,
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onPointerScroll(Offset localPosition, double scrollDelta) async {
|
||||
// // if (!enableCamera) {
|
||||
// // return;
|
||||
// // }
|
||||
// // if (_currentState == ThermionGestureState.NULL ||
|
||||
// // _currentState == ThermionGestureState.ZOOMING) {
|
||||
// // await _zoom(localPosition, scrollDelta);
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onPointerDown(Offset localPosition, int buttons) async {
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // _resetToNullState();
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// // if (enablePicking && buttons != kMiddleMouseButton) {
|
||||
// // viewer.pick(localPosition.dx.toInt(), localPosition.dy.toInt());
|
||||
// // }
|
||||
|
||||
// // if (buttons == kMiddleMouseButton && enableCamera) {
|
||||
// // await viewer.rotateStart(localPosition.dx, localPosition.dy);
|
||||
// // _currentState = ThermionGestureState.ROTATING;
|
||||
// // } else if (buttons == kPrimaryMouseButton && enableCamera) {
|
||||
// // await viewer.panStart(localPosition.dx, localPosition.dy);
|
||||
// // _currentState = ThermionGestureState.PANNING;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onPointerMove(
|
||||
// // Offset localPosition, Offset delta, int buttons) async {
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // await _handleEntityHighlightedMove(localPosition);
|
||||
// // return;
|
||||
// // }
|
||||
|
||||
// // switch (_currentState) {
|
||||
// // case ThermionGestureState.NULL:
|
||||
// // break;
|
||||
|
||||
// // case ThermionGestureState.ROTATING:
|
||||
// // if (enableCamera) {
|
||||
// // await viewer.rotateUpdate(localPosition.dx, localPosition.dy);
|
||||
// // }
|
||||
// // break;
|
||||
// // case ThermionGestureState.PANNING:
|
||||
// // if (enableCamera) {
|
||||
// // await viewer.panUpdate(localPosition.dx, localPosition.dy);
|
||||
// // }
|
||||
// // break;
|
||||
// // case ThermionGestureState.ZOOMING:
|
||||
// // // ignore
|
||||
// // break;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onPointerUp(int buttons) async {
|
||||
// // switch (_currentState) {
|
||||
// // case ThermionGestureState.ROTATING:
|
||||
// // await viewer.rotateEnd();
|
||||
// // _currentState = ThermionGestureState.NULL;
|
||||
// // break;
|
||||
// // case ThermionGestureState.PANNING:
|
||||
// // await viewer.panEnd();
|
||||
// // _currentState = ThermionGestureState.NULL;
|
||||
// // break;
|
||||
// // default:
|
||||
// // break;
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // Future<void> _handleEntityHighlightedMove(Offset localPosition) async {
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // await viewer.queuePositionUpdateFromViewportCoords(
|
||||
// // _highlightedEntity!,
|
||||
// // localPosition.dx,
|
||||
// // localPosition.dy,
|
||||
// // );
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // Future<void> _zoom(Offset localPosition, double scrollDelta) async {
|
||||
// // _scrollTimer?.cancel();
|
||||
// // _currentState = ThermionGestureState.ZOOMING;
|
||||
// // await viewer.zoomBegin();
|
||||
// // await viewer.zoomUpdate(
|
||||
// // localPosition.dx, localPosition.dy, scrollDelta > 0 ? 1 : -1);
|
||||
|
||||
// // _scrollTimer = Timer(const Duration(milliseconds: 100), () async {
|
||||
// // await viewer.zoomEnd();
|
||||
// // _currentState = ThermionGestureState.NULL;
|
||||
// // });
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // void dispose() {
|
||||
// // _pickResultSubscription?.cancel();
|
||||
// // if (_highlightedEntity != null) {
|
||||
// // viewer.removeStencilHighlight(_highlightedEntity!);
|
||||
// // }
|
||||
// // RawKeyboard.instance.removeListener(_handleKeyEvent);
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<bool> get initialized => viewer.initialized;
|
||||
|
||||
// // @override
|
||||
// // InputAction getActionForType(InputType type) {
|
||||
// // // TODO: implement getActionForType
|
||||
// // throw UnimplementedError();
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onScaleEnd() {
|
||||
// // // TODO: implement onScaleEnd
|
||||
// // throw UnimplementedError();
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onScaleStart() {
|
||||
// // // TODO: implement onScaleStart
|
||||
// // throw UnimplementedError();
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // Future<void> onScaleUpdate() {
|
||||
// // // TODO: implement onScaleUpdate
|
||||
// // throw UnimplementedError();
|
||||
// // }
|
||||
|
||||
// // @override
|
||||
// // void setActionForType(InputType type, InputAction action) {
|
||||
// // // TODO: implement setActionForType
|
||||
// // }
|
||||
// // }
|
||||
|
||||
@@ -4,41 +4,40 @@ import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import '../../viewer/viewer.dart';
|
||||
|
||||
class Axis {
|
||||
class AxisWidget {
|
||||
final ThermionViewer _viewer;
|
||||
final ThermionEntity xAxis;
|
||||
final ThermionEntity yAxis;
|
||||
final ThermionEntity zAxis;
|
||||
|
||||
Axis._(this.xAxis, this.yAxis, this.zAxis, this._viewer);
|
||||
AxisWidget._(this.xAxis, this.yAxis, this.zAxis, this._viewer);
|
||||
|
||||
static Future<Axis> create(ThermionViewer viewer) async {
|
||||
final xAxis = await viewer!.createGeometry(
|
||||
final xAxis = await viewer.createGeometry(
|
||||
Geometry(Float32List.fromList([0, 0, 0, 10, 0, 0]), [0, 1],
|
||||
primitiveType: PrimitiveType.LINES),
|
||||
materialInstance: await viewer!.createUnlitMaterialInstance());
|
||||
final yAxis = await viewer!.createGeometry(
|
||||
materialInstances: [await viewer.createUnlitMaterialInstance()]);
|
||||
final yAxis = await viewer.createGeometry(
|
||||
Geometry(Float32List.fromList([0, 0, 0, 0, 10, 0]), [0, 1],
|
||||
primitiveType: PrimitiveType.LINES),
|
||||
materialInstance: await viewer!.createUnlitMaterialInstance());
|
||||
final zAxis = await viewer!.createGeometry(
|
||||
materialInstances: [await viewer.createUnlitMaterialInstance()]);
|
||||
final zAxis = await viewer.createGeometry(
|
||||
Geometry(Float32List.fromList([0, 0, 0, 0, 0, 10]), [0, 1],
|
||||
primitiveType: PrimitiveType.LINES),
|
||||
materialInstance: await viewer!.createUnlitMaterialInstance());
|
||||
|
||||
await viewer!.setMaterialPropertyFloat4(
|
||||
xAxis, "baseColorFactor", 0, 1.0, 0.0, 0.0, 1.0);
|
||||
await viewer!.setMaterialPropertyFloat4(
|
||||
yAxis, "baseColorFactor", 0, 0.0, 1.0, 0.0, 1.0);
|
||||
await viewer!.setMaterialPropertyFloat4(
|
||||
zAxis, "baseColorFactor", 0, 0.0, 0.0, 1.0, 1.0);
|
||||
return Axis._(xAxis, yAxis, zAxis, viewer);
|
||||
materialInstances: [await viewer.createUnlitMaterialInstance()]);
|
||||
throw Exception("TODO");
|
||||
// await viewer!.setMaterialPropertyFloat4(
|
||||
// xAxis, "baseColorFactor", 0, 1.0, 0.0, 0.0, 1.0);
|
||||
// await viewer!.setMaterialPropertyFloat4(
|
||||
// yAxis, "baseColorFactor", 0, 0.0, 1.0, 0.0, 1.0);
|
||||
// await viewer!.setMaterialPropertyFloat4(
|
||||
// zAxis, "baseColorFactor", 0, 0.0, 0.0, 1.0, 1.0);
|
||||
// return Axis._(xAxis, yAxis, zAxis, viewer);
|
||||
}
|
||||
|
||||
Future setTransform(Matrix4 transform) async {
|
||||
await _viewer.setTransform(xAxis, transform);
|
||||
await _viewer.setTransform(yAxis, transform);
|
||||
await _viewer.setTransform(zAxis, transform);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,127 +1,120 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:thermion_dart/src/viewer/viewer.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
abstract class Gizmo {
|
||||
bool get isVisible;
|
||||
bool get isHovered;
|
||||
|
||||
void reset();
|
||||
|
||||
Future attach(ThermionEntity entity);
|
||||
Future detach();
|
||||
// abstract class BaseGizmo extends Gizmo {
|
||||
// final ThermionEntity x;
|
||||
// final ThermionEntity y;
|
||||
// final ThermionEntity z;
|
||||
// final ThermionEntity center;
|
||||
|
||||
Stream<Aabb2> get boundingBox;
|
||||
// ThermionEntity? _activeAxis;
|
||||
// ThermionEntity? _activeEntity;
|
||||
// ThermionViewer viewer;
|
||||
|
||||
void checkHover(int x, int y);
|
||||
}
|
||||
// bool _visible = false;
|
||||
// bool get isVisible => _visible;
|
||||
|
||||
abstract class BaseGizmo extends Gizmo {
|
||||
final ThermionEntity x;
|
||||
final ThermionEntity y;
|
||||
final ThermionEntity z;
|
||||
final ThermionEntity center;
|
||||
// bool _isHovered = false;
|
||||
// bool get isHovered => _isHovered;
|
||||
|
||||
ThermionEntity? _activeAxis;
|
||||
ThermionEntity? _activeEntity;
|
||||
ThermionViewer viewer;
|
||||
// final Set<ThermionEntity> ignore;
|
||||
|
||||
bool _visible = false;
|
||||
bool get isVisible => _visible;
|
||||
// Stream<Aabb2> get boundingBox => _boundingBoxController.stream;
|
||||
// final _boundingBoxController = StreamController<Aabb2>.broadcast();
|
||||
|
||||
bool _isHovered = false;
|
||||
bool get isHovered => _isHovered;
|
||||
// ThermionEntity get entity => center;
|
||||
|
||||
final Set<ThermionEntity> ignore;
|
||||
// BaseGizmo(
|
||||
// {required this.x,
|
||||
// required this.y,
|
||||
// required this.z,
|
||||
// required this.center,
|
||||
// required this.viewer,
|
||||
// this.ignore = const <ThermionEntity>{}}) {
|
||||
// onPick(_onGizmoPickResult);
|
||||
// }
|
||||
|
||||
Stream<Aabb2> get boundingBox => _boundingBoxController.stream;
|
||||
final _boundingBoxController = StreamController<Aabb2>.broadcast();
|
||||
// final _stopwatch = Stopwatch();
|
||||
|
||||
BaseGizmo({required this.x, required this.y, required this.z, required this.center, required this.viewer,
|
||||
this.ignore = const <ThermionEntity>{}}) {
|
||||
onPick(_onGizmoPickResult);
|
||||
}
|
||||
// double _transX = 0.0;
|
||||
// double _transY = 0.0;
|
||||
|
||||
final _stopwatch = Stopwatch();
|
||||
// Future translate(double transX, double transY) async {
|
||||
// if (!_stopwatch.isRunning) {
|
||||
// _stopwatch.start();
|
||||
// }
|
||||
|
||||
double _transX = 0.0;
|
||||
double _transY = 0.0;
|
||||
// _transX += transX;
|
||||
// _transY += transY;
|
||||
|
||||
Future translate(double transX, double transY) async {
|
||||
if (!_stopwatch.isRunning) {
|
||||
_stopwatch.start();
|
||||
}
|
||||
// if (_stopwatch.elapsedMilliseconds < 16) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
_transX += transX;
|
||||
_transY += transY;
|
||||
// final axis = Vector3(_activeAxis == x ? 1.0 : 0.0,
|
||||
// _activeAxis == y ? 1.0 : 0.0, _activeAxis == z ? 1.0 : 0.0);
|
||||
|
||||
if (_stopwatch.elapsedMilliseconds < 16) {
|
||||
return;
|
||||
}
|
||||
// await viewer.queueRelativePositionUpdateWorldAxis(
|
||||
// _activeEntity!,
|
||||
// _transX,
|
||||
// -_transY, // flip the sign because "up" in NDC Y axis is positive, but negative in Flutter
|
||||
// axis.x,
|
||||
// axis.y,
|
||||
// axis.z);
|
||||
// _transX = 0;
|
||||
// _transY = 0;
|
||||
// _stopwatch.reset();
|
||||
// }
|
||||
|
||||
final axis = Vector3(_activeAxis == x ? 1.0 : 0.0,
|
||||
_activeAxis == y ? 1.0 : 0.0, _activeAxis == z ? 1.0 : 0.0);
|
||||
// void reset() {
|
||||
// _activeAxis = null;
|
||||
// }
|
||||
|
||||
await viewer.queueRelativePositionUpdateWorldAxis(
|
||||
_activeEntity!,
|
||||
_transX,
|
||||
-_transY, // flip the sign because "up" in NDC Y axis is positive, but negative in Flutter
|
||||
axis.x,
|
||||
axis.y,
|
||||
axis.z);
|
||||
_transX = 0;
|
||||
_transY = 0;
|
||||
_stopwatch.reset();
|
||||
}
|
||||
// void _onGizmoPickResult(FilamentPickResult result) async {
|
||||
// if (result.entity == x || result.entity == y || result.entity == z) {
|
||||
// _activeAxis = result.entity;
|
||||
// _isHovered = true;
|
||||
// } else if (result.entity == 0) {
|
||||
// _activeAxis = null;
|
||||
// _isHovered = false;
|
||||
// } else {
|
||||
// throw Exception("Unexpected gizmo pick result");
|
||||
// }
|
||||
// }
|
||||
|
||||
void reset() {
|
||||
_activeAxis = null;
|
||||
}
|
||||
// Future attach(ThermionEntity entity) async {
|
||||
// _activeAxis = null;
|
||||
// if (entity == _activeEntity) {
|
||||
// return;
|
||||
// }
|
||||
// if (entity == center) {
|
||||
// _activeEntity = null;
|
||||
// return;
|
||||
// }
|
||||
// _visible = true;
|
||||
|
||||
void _onGizmoPickResult(FilamentPickResult result) async {
|
||||
if (result.entity == x || result.entity == y || result.entity == z) {
|
||||
_activeAxis = result.entity;
|
||||
_isHovered = true;
|
||||
} else if (result.entity == 0) {
|
||||
_activeAxis = null;
|
||||
_isHovered = false;
|
||||
} else {
|
||||
throw Exception("Unexpected gizmo pick result");
|
||||
}
|
||||
}
|
||||
// if (_activeEntity != null) {
|
||||
// // await viewer.removeStencilHighlight(_activeEntity!);
|
||||
// }
|
||||
// _activeEntity = entity;
|
||||
|
||||
Future attach(ThermionEntity entity) async {
|
||||
_activeAxis = null;
|
||||
if (entity == _activeEntity) {
|
||||
return;
|
||||
}
|
||||
if (entity == center) {
|
||||
_activeEntity = null;
|
||||
return;
|
||||
}
|
||||
_visible = true;
|
||||
// await viewer.setParent(center, entity, preserveScaling: false);
|
||||
// _boundingBoxController.sink.add(await viewer.getViewportBoundingBox(x));
|
||||
// }
|
||||
|
||||
if (_activeEntity != null) {
|
||||
await viewer.removeStencilHighlight(_activeEntity!);
|
||||
}
|
||||
_activeEntity = entity;
|
||||
// Future detach() async {
|
||||
// await setVisibility(false);
|
||||
// }
|
||||
|
||||
await viewer.setParent(center, entity, preserveScaling: false);
|
||||
_boundingBoxController.sink.add(await viewer.getViewportBoundingBox(x));
|
||||
}
|
||||
// @override
|
||||
// void checkHover(int x, int y) {
|
||||
// pick(x, y);
|
||||
// }
|
||||
|
||||
Future detach() async {
|
||||
await setVisibility(false);
|
||||
}
|
||||
// Future pick(int x, int y);
|
||||
|
||||
@override
|
||||
void checkHover(int x, int y) {
|
||||
pick(x, y);
|
||||
}
|
||||
|
||||
Future pick(int x, int y);
|
||||
|
||||
Future setVisibility(bool visible);
|
||||
void onPick(void Function(PickResult result) callback);
|
||||
}
|
||||
// Future setVisibility(bool visible);
|
||||
// void onPick(void Function(PickResult result) callback);
|
||||
// }
|
||||
|
||||
@@ -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!;
|
||||
}
|
||||
}
|
||||
186
thermion_dart/lib/src/viewer/src/ffi/src/ffi_asset.dart
Normal file
186
thermion_dart/lib/src/viewer/src/ffi/src/ffi_asset.dart
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
///
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user