feat: working implementation of multiple widgets on macos
This commit is contained in:
@@ -69,11 +69,15 @@ class DelegateInputHandler implements InputHandler {
|
||||
});
|
||||
|
||||
factory DelegateInputHandler.flight(ThermionViewer viewer,
|
||||
{PickDelegate? pickDelegate, bool freeLook=false, double? clampY, ThermionEntity? entity}) =>
|
||||
{PickDelegate? pickDelegate,
|
||||
bool freeLook = false,
|
||||
double? clampY,
|
||||
ThermionEntity? entity}) =>
|
||||
DelegateInputHandler(
|
||||
viewer: viewer,
|
||||
pickDelegate: pickDelegate,
|
||||
transformDelegate: FreeFlightInputHandlerDelegate(viewer, clampY:clampY, entity:entity),
|
||||
transformDelegate: FreeFlightInputHandlerDelegate(viewer,
|
||||
clampY: clampY, entity: entity),
|
||||
actions: {
|
||||
InputType.MMB_HOLD_AND_MOVE: InputAction.ROTATE,
|
||||
InputType.SCROLLWHEEL: InputAction.TRANSLATE,
|
||||
@@ -82,8 +86,7 @@ class DelegateInputHandler implements InputHandler {
|
||||
InputType.KEYDOWN_W: InputAction.TRANSLATE,
|
||||
InputType.KEYDOWN_S: InputAction.TRANSLATE,
|
||||
InputType.KEYDOWN_D: InputAction.TRANSLATE,
|
||||
if(freeLook)
|
||||
InputType.POINTER_MOVE: InputAction.ROTATE,
|
||||
if (freeLook) InputType.POINTER_MOVE: InputAction.ROTATE,
|
||||
});
|
||||
|
||||
bool _processing = false;
|
||||
@@ -160,15 +163,13 @@ class DelegateInputHandler implements InputHandler {
|
||||
}
|
||||
if (isMiddle) {
|
||||
_inputDeltas[InputType.MMB_HOLD_AND_MOVE] =
|
||||
(_inputDeltas[InputType.MMB_HOLD_AND_MOVE] ?? Vector3.zero()) + Vector3(delta.x, delta.y, 0.0);
|
||||
(_inputDeltas[InputType.MMB_HOLD_AND_MOVE] ?? Vector3.zero()) +
|
||||
Vector3(delta.x, delta.y, 0.0);
|
||||
} else {
|
||||
_inputDeltas[InputType.LMB_HOLD_AND_MOVE] =
|
||||
(_inputDeltas[InputType.LMB_HOLD_AND_MOVE] ?? Vector3.zero()) + Vector3(delta.x, delta.y, 0.0);
|
||||
(_inputDeltas[InputType.LMB_HOLD_AND_MOVE] ?? Vector3.zero()) +
|
||||
Vector3(delta.x, delta.y, 0.0);
|
||||
}
|
||||
// else {
|
||||
// _inputDeltas[InputType.POINTER_MOVE] =
|
||||
// (_inputDeltas[InputType.POINTER_MOVE] ?? Vector3.zero()) + delta;
|
||||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -180,7 +181,8 @@ class DelegateInputHandler implements InputHandler {
|
||||
return;
|
||||
}
|
||||
_inputDeltas[InputType.POINTER_MOVE] =
|
||||
(_inputDeltas[InputType.POINTER_MOVE] ?? Vector3.zero()) + Vector3(delta.x, delta.y, 0.0);
|
||||
(_inputDeltas[InputType.POINTER_MOVE] ?? Vector3.zero()) +
|
||||
Vector3(delta.x, delta.y, 0.0);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -191,8 +193,8 @@ class DelegateInputHandler implements InputHandler {
|
||||
}
|
||||
try {
|
||||
_inputDeltas[InputType.SCROLLWHEEL] =
|
||||
(_inputDeltas[InputType.SCROLLWHEEL] ?? Vector3.zero())
|
||||
+ Vector3(0,0, scrollDelta > 0 ? 1 : -1);
|
||||
(_inputDeltas[InputType.SCROLLWHEEL] ?? Vector3.zero()) +
|
||||
Vector3(0, 0, scrollDelta > 0 ? 1 : -1);
|
||||
} catch (e) {
|
||||
_logger.warning("Error during scroll accumulation: $e");
|
||||
}
|
||||
|
||||
@@ -39,4 +39,18 @@ class FFIView extends View {
|
||||
final engine = Viewer_getEngine(viewer);
|
||||
return FFICamera(View_getCamera(view), engine);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setAntiAliasing(bool msaa, bool fxaa, bool taa) async {
|
||||
View_setAntiAliasing(view, msaa, fxaa, taa);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setPostProcessing(bool enabled) async {
|
||||
View_setPostProcessing(view, enabled);
|
||||
}
|
||||
|
||||
Future setRenderable(bool renderable) async {
|
||||
Viewer_markViewRenderable(viewer, view, renderable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ external void Viewer_destroySwapChain(
|
||||
@ffi.Native<
|
||||
ffi.Bool Function(
|
||||
ffi.Pointer<TViewer>,
|
||||
ffi.Pointer<TView>,
|
||||
ffi.Pointer<TSwapChain>,
|
||||
ffi.Uint64,
|
||||
ffi.Pointer<ffi.Void>,
|
||||
@@ -76,7 +75,6 @@ external void Viewer_destroySwapChain(
|
||||
ffi.Pointer<ffi.Void>)>(isLeaf: true)
|
||||
external bool Viewer_render(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<TView> view,
|
||||
ffi.Pointer<TSwapChain> swapChain,
|
||||
int frameTimeInNanos,
|
||||
ffi.Pointer<ffi.Void> pixelBuffer,
|
||||
@@ -146,6 +144,15 @@ external ffi.Pointer<TSwapChain> Viewer_getSwapChainAt(
|
||||
int index,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TViewer>, ffi.Pointer<TView>, ffi.Bool)>(isLeaf: true)
|
||||
external void Viewer_markViewRenderable(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<TView> view,
|
||||
bool renderable,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Pointer<TEngine> Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external ffi.Pointer<TEngine> Viewer_getEngine(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
@@ -1451,6 +1458,15 @@ external void Viewer_captureRenderTargetRenderThread(
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>, ffi.Pointer<TSwapChain>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void Viewer_requestFrameRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<TSwapChain> tSwapChain,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void destroy_filament_viewer_render_thread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
@@ -1471,19 +1487,6 @@ external void set_rendering_render_thread(
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TViewer>,
|
||||
ffi.Pointer<TView>,
|
||||
ffi.Pointer<TSwapChain>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void Viewer_requestFrameRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<TView> view,
|
||||
ffi.Pointer<TSwapChain> tSwapChain,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>, ffi.Float)>(isLeaf: true)
|
||||
external void set_frame_interval_render_thread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
@@ -1888,14 +1891,25 @@ external void View_setBloom(
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TView>, ffi.Pointer<TEngine>, ffi.Int32)>(isLeaf: true)
|
||||
external void View_setToneMapping(
|
||||
ffi.Void Function(ffi.Pointer<TView>, ffi.Pointer<TEngine>,
|
||||
ffi.UnsignedInt)>(symbol: "View_setToneMapping", isLeaf: true)
|
||||
external void _View_setToneMapping(
|
||||
ffi.Pointer<TView> tView,
|
||||
ffi.Pointer<TEngine> tEngine,
|
||||
int toneMapping,
|
||||
);
|
||||
|
||||
void View_setToneMapping(
|
||||
ffi.Pointer<TView> tView,
|
||||
ffi.Pointer<TEngine> tEngine,
|
||||
ToneMapping toneMapping,
|
||||
) =>
|
||||
_View_setToneMapping(
|
||||
tView,
|
||||
tEngine,
|
||||
toneMapping.value,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TView>, ffi.Bool, ffi.Bool, ffi.Bool)>(isLeaf: true)
|
||||
@@ -2224,10 +2238,20 @@ final class TViewport extends ffi.Struct {
|
||||
external int height;
|
||||
}
|
||||
|
||||
abstract class ToneMapping {
|
||||
static const int ACES = 0;
|
||||
static const int FILMIC = 1;
|
||||
static const int LINEAR = 2;
|
||||
enum ToneMapping {
|
||||
ACES(0),
|
||||
FILMIC(1),
|
||||
LINEAR(2);
|
||||
|
||||
final int value;
|
||||
const ToneMapping(this.value);
|
||||
|
||||
static ToneMapping fromValue(int value) => switch (value) {
|
||||
0 => ACES,
|
||||
1 => FILMIC,
|
||||
2 => LINEAR,
|
||||
_ => throw ArgumentError("Unknown value for ToneMapping: $value"),
|
||||
};
|
||||
}
|
||||
|
||||
typedef GizmoPickCallback
|
||||
|
||||
@@ -2040,10 +2040,8 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
});
|
||||
|
||||
final swapChain = Viewer_getSwapChainAt(_viewer!, 0);
|
||||
final view = Viewer_getViewAt(_viewer!, 0);
|
||||
|
||||
Viewer_requestFrameRenderThread(
|
||||
_viewer!, view, swapChain, callback.nativeFunction);
|
||||
Viewer_requestFrameRenderThread(_viewer!, swapChain, callback.nativeFunction);
|
||||
|
||||
await completer.future;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
library shared_types;
|
||||
|
||||
export 'swap_chain.dart';
|
||||
export 'view.dart';
|
||||
export 'render_target.dart';
|
||||
export 'camera.dart';
|
||||
export 'material.dart';
|
||||
|
||||
@@ -15,4 +15,7 @@ abstract class View {
|
||||
Future setRenderTarget(covariant RenderTarget? renderTarget);
|
||||
Future setCamera(covariant Camera camera);
|
||||
Camera getCamera();
|
||||
Future setPostProcessing(bool enabled);
|
||||
Future setAntiAliasing(bool msaa, bool fxaa, bool taa);
|
||||
Future setRenderable(bool renderable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user