add moveCameraToAsset

This commit is contained in:
Nick Fisher
2023-09-25 22:30:07 +08:00
parent 64cfea2952
commit 833022e4e0
15 changed files with 79 additions and 13 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:ui' as ui;
import 'package:flutter/services.dart';
import 'package:polyvox_filament/animations/bone_animation_data.dart';
import 'package:polyvox_filament/animations/morph_animation_data.dart';
import 'package:polyvox_filament/generated_bindings_web.dart';
typedef AssetManager = int;
typedef FilamentEntity = int;
@@ -519,6 +520,13 @@ class FilamentController {
await _channel.invokeMethod("setCameraPosition", [x, y, z]);
}
Future moveCameraToAsset(FilamentEntity asset) async {
if (_viewer == null || _resizing) {
throw Exception("No viewer available, ignoring");
}
await _channel.invokeMethod("moveCameraToAsset", asset);
}
Future setCameraExposure(
double aperture, double shutterSpeed, double sensitivity) async {
if (_viewer == null || _resizing) {

View File

@@ -104,8 +104,11 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
? null
: (d) async {
if (d.buttons == kTertiaryButton || _rotating) {
widget.controller
.rotateStart(d.localPosition.dx, d.localPosition.dy);
print("Starting at ${d.position}");
widget.controller.rotateStart(
d.position.dx * 2.0,
d.position.dy *
2.0); // multiply by 2.0 to account for pixel density, TODO don't hardcode
} else {
widget.controller
.panStart(d.localPosition.dx, d.localPosition.dy);
@@ -115,8 +118,9 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
? null
: (PointerMoveEvent d) async {
if (d.buttons == kTertiaryButton || _rotating) {
print("Updating at ${d.position}");
widget.controller
.rotateUpdate(d.localPosition.dx, d.localPosition.dy);
.rotateUpdate(d.position.dx * 2.0, d.position.dy * 2.0);
} else {
widget.controller
.panUpdate(d.localPosition.dx, d.localPosition.dy);

View File

@@ -143,7 +143,6 @@ class _FilamentWidgetState extends State<FilamentWidget> {
if (_textureId == null) {
return Container(color: Colors.transparent);
}
var texture = Texture(
key: ObjectKey("texture_$_textureId"),
textureId: _textureId!,