chore: rearrange library/export structure

This commit is contained in:
Nick Fisher
2024-09-26 16:35:33 +08:00
parent f023810859
commit 3dffaddfe8
74 changed files with 119 additions and 810 deletions

View File

@@ -1,250 +1,16 @@
# Change Log # Change Log
All notable changes to this project will be documented in this file. v0.2.0
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
- **BREAKING** Dart SDK 3.6.0 required
## 2024-09-25 - **BREAKING** Libraries have been restructured so you should only need to import `package:thermion_dart/thermion_dart.dart`, `package:thermion_flutter/thermion_flutter.dart`
- **BREAKING** The former GestureDetector widgets and EntityControllerMouseWidget/EntityTransformController have been removed and replaced with ThermionListenerWidget. that accepts an InputHandler.
### Changes - **BREAKING** The former debugging widgets and Scene class have been removed.
- **REFACTOR** The creation of the main camera has been refactored; the default projection & near/far planes should not have changed, but pay close attention.
--- - **REFACTOR**: add methods for create/destroy material instance, add priority/layer to load_glb_from_buffer.
- **FEAT**: Translation gizmo, stencil highlight & overlays.
Packages with breaking changes: - **FEAT**: new setLightDirection and setLightPosition.
- **FEAT**: move HighlightOverlay to nested class, move createGeometry to SceneManager, add queueRelativePositionUpdateFromViewportVector.
- [`thermion_dart` - `v0.2.0-dev.7.0`](#thermion_dart---v020-dev70)
Packages with other changes:
- [`thermion_flutter_web` - `v0.1.0-dev.7.0`](#thermion_flutter_web---v010-dev70)
- [`thermion_flutter` - `v0.2.0-dev.7.0`](#thermion_flutter---v020-dev70)
- [`thermion_flutter_platform_interface` - `v0.2.0-dev.7.0`](#thermion_flutter_platform_interface---v020-dev70)
- [`thermion_flutter_ffi` - `v0.2.0-dev.7.0`](#thermion_flutter_ffi---v020-dev70)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `thermion_flutter_web` - `v0.1.0-dev.7.0`
- `thermion_flutter` - `v0.2.0-dev.7.0`
- `thermion_flutter_platform_interface` - `v0.2.0-dev.7.0`
- `thermion_flutter_ffi` - `v0.2.0-dev.7.0`
---
#### `thermion_dart` - `v0.2.0-dev.7.0`
- **BREAKING** **FIX**: fix min SDK for thermion_dart.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_dart` - `v0.2.0-dev.6.0`](#thermion_dart---v020-dev60)
Packages with other changes:
- [`thermion_flutter_web` - `v0.1.0-dev.6.0`](#thermion_flutter_web---v010-dev60)
- [`thermion_flutter` - `v0.2.0-dev.6.0`](#thermion_flutter---v020-dev60)
- [`thermion_flutter_platform_interface` - `v0.2.0-dev.6.0`](#thermion_flutter_platform_interface---v020-dev60)
- [`thermion_flutter_ffi` - `v0.2.0-dev.6.0`](#thermion_flutter_ffi---v020-dev60)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `thermion_flutter_web` - `v0.1.0-dev.6.0`
- `thermion_flutter` - `v0.2.0-dev.6.0`
- `thermion_flutter_platform_interface` - `v0.2.0-dev.6.0`
- `thermion_flutter_ffi` - `v0.2.0-dev.6.0`
---
#### `thermion_dart` - `v0.2.0-dev.6.0`
- **BREAKING** **CHORE**: cleanup deleted export.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_flutter` - `v0.2.0-dev.6.0`](#thermion_flutter---v020-dev60)
Packages with other changes:
- There are no other changes in this release.
---
#### `thermion_flutter` - `v0.2.0-dev.6.0`
- **BREAKING** **CHORE**: remove superseded HardwareKeyboard* classes.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_dart` - `v0.2.0-dev.5.0`](#thermion_dart---v020-dev50)
Packages with other changes:
- [`thermion_flutter_web` - `v0.1.0-dev.5.0`](#thermion_flutter_web---v010-dev50)
- [`thermion_flutter` - `v0.2.0-dev.5.0`](#thermion_flutter---v020-dev50)
- [`thermion_flutter_platform_interface` - `v0.2.0-dev.5.0`](#thermion_flutter_platform_interface---v020-dev50)
- [`thermion_flutter_ffi` - `v0.2.0-dev.5.0`](#thermion_flutter_ffi---v020-dev50)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `thermion_flutter_web` - `v0.1.0-dev.5.0`
- `thermion_flutter` - `v0.2.0-dev.5.0`
- `thermion_flutter_platform_interface` - `v0.2.0-dev.5.0`
- `thermion_flutter_ffi` - `v0.2.0-dev.5.0`
---
#### `thermion_dart` - `v0.2.0-dev.5.0`
- **BREAKING** **CHORE**: remove EntityTransformController (requires replacement).
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_dart` - `v0.2.0-dev.4.0`](#thermion_dart---v020-dev40)
- [`thermion_flutter_web` - `v0.1.0-dev.4.0`](#thermion_flutter_web---v010-dev40)
Packages with other changes:
- [`thermion_flutter` - `v0.2.0-dev.4.0`](#thermion_flutter---v020-dev40)
- [`thermion_flutter_platform_interface` - `v0.2.0-dev.4.0`](#thermion_flutter_platform_interface---v020-dev40)
- [`thermion_flutter_ffi` - `v0.2.0-dev.4.0`](#thermion_flutter_ffi---v020-dev40)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `thermion_flutter` - `v0.2.0-dev.4.0`
- `thermion_flutter_platform_interface` - `v0.2.0-dev.4.0`
- `thermion_flutter_ffi` - `v0.2.0-dev.4.0`
---
#### `thermion_dart` - `v0.2.0-dev.4.0`
- **BREAKING** **FIX**: (web/wasm) free pick callbacks on dispose.
- **BREAKING** **CHORE**: restructure viewer folders as libraries to only export the public interface.
#### `thermion_flutter_web` - `v0.1.0-dev.4.0`
- **BREAKING** **CHORE**: restructure viewer folders as libraries to only export the public interface.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_flutter` - `v0.2.0-dev.3.0`](#thermion_flutter---v020-dev30)
Packages with other changes:
- There are no other changes in this release.
---
#### `thermion_flutter` - `v0.2.0-dev.3.0`
- **BREAKING** **FIX**: remove EntityControllerMouseWidget (replace with GestureHandler).
- **BREAKING** **CHORE**: (flutter) cleanup for pub.dev publishing.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_flutter` - `v0.2.0-dev.2.0`](#thermion_flutter---v020-dev20)
Packages with other changes:
- There are no other changes in this release.
---
#### `thermion_flutter` - `v0.2.0-dev.2.0`
- **BREAKING** **CHORE**: remove EntityListWidget - will replace with new Scene.
## 2024-09-25
### Changes
---
Packages with breaking changes:
- [`thermion_dart` - `v0.2.0-dev.1.0`](#thermion_dart---v020-dev10)
- [`thermion_flutter` - `v0.2.0-dev.1.0`](#thermion_flutter---v020-dev10)
- [`thermion_flutter_ffi` - `v0.2.0-dev.1.0`](#thermion_flutter_ffi---v020-dev10)
- [`thermion_flutter_platform_interface` - `v0.2.0-dev.1.0`](#thermion_flutter_platform_interface---v020-dev10)
- [`thermion_flutter_web` - `v0.1.0-dev.1.0`](#thermion_flutter_web---v010-dev10)
Packages with other changes:
- There are no other changes in this release.
---
#### `thermion_dart` - `v0.2.0-dev.1.0`
- **REFACTOR**: native types.
- **REFACTOR**: native types.
- **REFACTOR**: move native types to own header, add methods for create/destroy material instance, add priority/layer to load_glb_from_buffer.
- **REFACTOR**: Dart types.
- **FIX**: (web) add emscripten guards for flushAndWait call when swapchain destroyed.
- **FIX**: ignore pick results directly on axis.
- **FIX**: properly destroy entities/material/etc in Gizmo on destruction, remove custom scene creation logic.
- **FIX**: add check for nan NDC coordinates for viewport translation.
- **FIX**: (wasm) use correct coords for pick, free memory correctly, keep pixelratio copy.
- **FIX**: add more nan checks for gizmo manipulation.
- **FIX**: emscripten export visibility for add_light.
- **FIX**: add Fence to capture() and set stencil buffer by default.
- **FEAT**: add removeStencilHighlight, queuePositionUpdateFromViewportCoords to ThermionViewer.
- **FEAT**: add removeStencilHighlight, accept color param for setStencilHighlight, queuePositionUpdateFromViewportCoords to ThermionDartApi.
- **FEAT**: add flag for keepData for gltf instancing, add highlightScene, add stencilHighlight method.
- **FEAT**: grid uses own material.
- **FEAT**: parent the cloned entity instance when setting stencil highlight.
- **FEAT**: add grid material.
- **FEAT**: expose setLightDirection and setLightPosition.
- **FEAT**: move HighlightOverlay to nested class, move createGeometry to SceneManager, add queueRelativePositionUpdateFromViewportVector.
- **FEAT**: move createGeometry to SceneManager, add queueRelativePositionUpdateFromViewportVector and removeStencilHighlight. - **FEAT**: move createGeometry to SceneManager, add queueRelativePositionUpdateFromViewportVector and removeStencilHighlight.
- **FEAT**: add setGizmoVisibility/pickGizmo methods to ThermionViewer. - **FEAT**: add setGizmoVisibility/pickGizmo methods to ThermionViewer.
- **FEAT**: remove gizmo view references, exclude gizmo entities from picking, add createIbl. - **FEAT**: remove gizmo view references, exclude gizmo entities from picking, add createIbl.
@@ -272,9 +38,6 @@ Packages with other changes:
- **FEAT**: createIbl. - **FEAT**: createIbl.
- **BREAKING** **FEAT**: (web) (flutter) create canvas when createViewer is called (no longer need to manually add canvas element to web HTML). - **BREAKING** **FEAT**: (web) (flutter) create canvas when createViewer is called (no longer need to manually add canvas element to web HTML).
- **BREAKING** **FEAT**: update web/http dependencies. - **BREAKING** **FEAT**: update web/http dependencies.
#### `thermion_flutter` - `v0.2.0-dev.1.0`
- **FIX**: (flutter) pass ThermionFlutterOptions to ThermionWidget, use dpr for resizeTexture, delete unnecessary TransparencyPainter class. - **FIX**: (flutter) pass ThermionFlutterOptions to ThermionWidget, use dpr for resizeTexture, delete unnecessary TransparencyPainter class.
- **FIX**: (flutter/web) use window.devicePixelRatio for viewport. - **FIX**: (flutter/web) use window.devicePixelRatio for viewport.
- **FIX**: (flutter) desktop gesture detector changes for new Gizmo methods. - **FIX**: (flutter) desktop gesture detector changes for new Gizmo methods.
@@ -288,20 +51,11 @@ Packages with other changes:
- **BREAKING** **FEAT**: (web) (flutter) create canvas when createViewer is called (no longer need to manually add canvas element to web HTML). - **BREAKING** **FEAT**: (web) (flutter) create canvas when createViewer is called (no longer need to manually add canvas element to web HTML).
- **BREAKING** **FEAT**: resize canvas on web. - **BREAKING** **FEAT**: resize canvas on web.
- **BREAKING** **CHORE**: rename controller to viewer in gesture detector widgets. - **BREAKING** **CHORE**: rename controller to viewer in gesture detector widgets.
#### `thermion_flutter_ffi` - `v0.2.0-dev.1.0`
- **FEAT**: (flutter) move DPR calculation to resizeTexture and add createViewerWithOptions method to ThermionFlutterFFI. - **FEAT**: (flutter) move DPR calculation to resizeTexture and add createViewerWithOptions method to ThermionFlutterFFI.
- **BREAKING** **FIX**: (flutter) pass pixelRatio to createTexture. - **BREAKING** **FIX**: (flutter) pass pixelRatio to createTexture.
#### `thermion_flutter_platform_interface` - `v0.2.0-dev.1.0`
- **FEAT**: add createViewerWithOptions to ThermionFlutterPlugin and mark createViewer as deprecated. - **FEAT**: add createViewerWithOptions to ThermionFlutterPlugin and mark createViewer as deprecated.
- **FEAT**: add ThermionFlutterOptions classes, rename interface parameter for offsetTop and ensure pixelRatio is passed to resizeTexture. - **FEAT**: add ThermionFlutterOptions classes, rename interface parameter for offsetTop and ensure pixelRatio is passed to resizeTexture.
- **BREAKING** **FIX**: (flutter) pass pixelRatio to createTexture. - **BREAKING** **FIX**: (flutter) pass pixelRatio to createTexture.
#### `thermion_flutter_web` - `v0.1.0-dev.1.0`
- **FIX**: (flutter/web) use window.devicePixelRatio for viewport. - **FIX**: (flutter/web) use window.devicePixelRatio for viewport.
- **FEAT**: (flutter) (web) use options to determine whether to create canvas, and set fixed position + offset. - **FEAT**: (flutter) (web) use options to determine whether to create canvas, and set fixed position + offset.
- **FEAT**: add ThermionFlutterOptions classes, rename interface parameter for offsetTop and ensure pixelRatio is passed to resizeTexture. - **FEAT**: add ThermionFlutterOptions classes, rename interface parameter for offsetTop and ensure pixelRatio is passed to resizeTexture.
@@ -310,35 +64,7 @@ Packages with other changes:
- **BREAKING** **FEAT**: resize canvas on web. - **BREAKING** **FEAT**: resize canvas on web.
## 2024-07-23 ## v0.1.3
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`thermion_dart` - `v0.1.3`](#thermion_dart---v013)
- [`thermion_flutter_ffi` - `v0.1.0+12`](#thermion_flutter_ffi---v01012)
- [`thermion_flutter_web` - `v0.0.3`](#thermion_flutter_web---v003)
- [`thermion_flutter_platform_interface` - `v0.1.0+11`](#thermion_flutter_platform_interface---v01011)
- [`thermion_flutter` - `v0.1.1+13`](#thermion_flutter---v01113)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `thermion_flutter_platform_interface` - `v0.1.0+11`
- `thermion_flutter` - `v0.1.1+13`
---
#### `thermion_dart` - `v0.1.3`
- **FIX**: manually remove leading slash for compiler path on Windows when building for Android. - **FIX**: manually remove leading slash for compiler path on Windows when building for Android.
- **FIX**: web/JS bool checks need to compare to int. - **FIX**: web/JS bool checks need to compare to int.
- **FIX**: shadow JS<->WASM bridge methods. - **FIX**: shadow JS<->WASM bridge methods.

View File

@@ -1,6 +1,7 @@
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../thermion_dart.dart';
abstract class AbstractGizmo { abstract class AbstractGizmo {
bool get isVisible; bool get isVisible;

View File

@@ -1,7 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart'; import 'package:thermion_dart/src/entities/abstract_gizmo.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../thermion_viewer.dart'; import '../viewer/viewer.dart';
class Gizmo extends AbstractGizmo { class Gizmo extends AbstractGizmo {
final ThermionEntity x; final ThermionEntity x;

View File

@@ -1,12 +1,10 @@
import 'dart:async'; import 'dart:async';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:thermion_dart/thermion_dart/input/src/delegates.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../viewer/thermion_viewer_base.dart';
import 'implementations/fixed_orbit_camera_rotation_delegate.dart'; import 'implementations/fixed_orbit_camera_rotation_delegate.dart';
import 'implementations/free_flight_camera_delegate.dart'; import 'implementations/free_flight_camera_delegate.dart';
import 'input_handler.dart';
class DelegateInputHandler implements InputHandler { class DelegateInputHandler implements InputHandler {
final ThermionViewer viewer; final ThermionViewer viewer;

View File

@@ -1,8 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:thermion_dart/thermion_dart/input/src/delegates.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../../viewer/shared_types/camera.dart'; import '../../../viewer/src/shared_types/camera.dart';
import '../../../viewer/viewer.dart';
import '../../input.dart';
import '../input_handler.dart'; import '../input_handler.dart';
class FixedOrbitRotateInputHandlerDelegate implements InputHandlerDelegate { class FixedOrbitRotateInputHandlerDelegate implements InputHandlerDelegate {

View File

@@ -1,8 +1,8 @@
import 'dart:async'; import 'dart:async';
import 'package:thermion_dart/thermion_dart/input/src/input_handler.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../../viewer/viewer.dart';
import '../delegates.dart'; import '../delegates.dart';
import '../input_handler.dart';
class FreeFlightInputHandlerDelegate implements InputHandlerDelegate { class FreeFlightInputHandlerDelegate implements InputHandlerDelegate {

View File

@@ -1,7 +1,8 @@
import 'dart:convert'; import 'dart:convert';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../thermion_dart.dart';
class SceneV2 { class SceneV2 {
final Map<String, AssetInfo> assets; final Map<String, AssetInfo> assets;
final List<LightInfo> lights; final List<LightInfo> lights;

View File

@@ -2,7 +2,8 @@ import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
import '../viewer/src/ffi/src/thermion_dart.g.dart';
class DartResourceLoader { class DartResourceLoader {
static final _assets = <int, Pointer>{}; static final _assets = <int, Pointer>{};

View File

@@ -1,7 +1,7 @@
import 'dart:math'; import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/geometry.dart';
import 'package:thermion_dart/thermion_dart/viewer/thermion_viewer_base.dart'; import '../../thermion_dart.dart';
class GeometryHelper { class GeometryHelper {
static Geometry sphere({bool normals = true, bool uvs = true}) { static Geometry sphere({bool normals = true, bool uvs = true}) {

View File

@@ -1,5 +1,5 @@
// Helper function to convert double4x4 to Matrix4 // Helper function to convert double4x4 to Matrix4
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart'; import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_dart.g.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'dart:ffi'; import 'dart:ffi';

View File

@@ -1,4 +1,3 @@
import 'package:thermion_dart/thermion_dart/viewer/shared_types/entities.dart';
import 'shared_types/shared_types.dart'; import 'shared_types/shared_types.dart';
/// ///

View File

@@ -1,11 +1,11 @@
import 'dart:ffi'; import 'dart:ffi';
import 'package:thermion_dart/thermion_dart/utils/matrix.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../../../utils/matrix.dart';
import '../../shared_types/camera.dart';
import '../../thermion_viewer_base.dart'; import '../../thermion_viewer_base.dart';
import 'thermion_dart.g.dart';
class ThermionFFICamera extends Camera { class ThermionFFICamera extends Camera {
final Pointer<TCamera> camera; final Pointer<TCamera> camera;

View File

@@ -1,19 +1,20 @@
import 'dart:async'; import 'dart:async';
import 'dart:ffi';
import 'dart:math'; import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:thermion_dart/thermion_dart/entities/gizmo.dart';
import 'package:thermion_dart/thermion_dart/utils/matrix.dart';
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/callbacks.dart';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'package:vector_math/vector_math_64.dart' as v64; import 'package:vector_math/vector_math_64.dart' as v64;
import '../../../../entities/gizmo.dart';
import '../../../../utils/matrix.dart';
import '../../events.dart';
import '../../shared_types/camera.dart';
import '../../thermion_viewer_base.dart'; import '../../thermion_viewer_base.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'callbacks.dart';
import 'camera_ffi.dart'; import 'camera_ffi.dart';
import 'thermion_dart.g.dart';
// ignore: constant_identifier_names // ignore: constant_identifier_names
const ThermionEntity _FILAMENT_ASSET_ERROR = 0; const ThermionEntity _FILAMENT_ASSET_ERROR = 0;

View File

@@ -1,6 +1,6 @@
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:thermion_dart/thermion_dart/viewer/thermion_viewer_base.dart'; import '../../viewer.dart';
class Geometry { class Geometry {
final Float32List vertices; final Float32List vertices;

View File

@@ -1,5 +1,5 @@
// "picking" means clicking/tapping on the viewport, and unprojecting the X/Y coordinate to determine whether any renderable entities were present at those coordinates. // "picking" means clicking/tapping on the viewport, and unprojecting the X/Y coordinate to determine whether any renderable entities were present at those coordinates.
import 'package:thermion_dart/thermion_dart/viewer/shared_types/shared_types.dart'; import '../../viewer.dart';
typedef FilamentPickResult = ({ThermionEntity entity, double x, double y}); typedef FilamentPickResult = ({ThermionEntity entity, double x, double y});
typedef ThermionPickResult = FilamentPickResult; typedef ThermionPickResult = FilamentPickResult;

View File

@@ -1,5 +1,6 @@
library shared_types; library shared_types;
export 'camera.dart';
export 'material.dart'; export 'material.dart';
export 'texture.dart'; export 'texture.dart';
export 'entities.dart'; export 'entities.dart';

View File

@@ -1,12 +1,11 @@
import 'package:thermion_dart/thermion_dart/viewer/events.dart'; import 'package:thermion_dart/src/viewer/src/events.dart';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart'; import '../../entities/abstract_gizmo.dart';
import 'shared_types/camera.dart';
import 'shared_types/shared_types.dart'; import 'shared_types/shared_types.dart';
export 'shared_types/shared_types.dart'; export 'shared_types/shared_types.dart';
import 'dart:math'; import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'dart:async'; import 'dart:async';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';

View File

@@ -1,15 +1,15 @@
import 'dart:math'; import 'dart:math';
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
import 'package:thermion_dart/thermion_dart/viewer/thermion_viewer_base.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'dart:async'; import 'dart:async';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import '../../entities/abstract_gizmo.dart';
import 'events.dart';
import 'shared_types/camera.dart';
class ThermionViewerStub extends ThermionViewer { class ThermionViewerStub extends ThermionViewer {
@override @override
Future addAnimationComponent(ThermionEntity entity) { Future addAnimationComponent(ThermionEntity entity) {

View File

@@ -3,14 +3,12 @@ library thermion_flutter_js;
import 'dart:js_interop'; import 'dart:js_interop';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:thermion_dart/thermion_dart/viewer/web_js/src/thermion_viewer_js_shim.dart';
import 'package:vector_math/vector_math_64.dart' as v64; import 'package:vector_math/vector_math_64.dart' as v64;
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'dart:js_interop_unsafe'; import 'dart:js_interop_unsafe';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../../viewer.dart';
import 'thermion_viewer_js_shim.dart';
/// ///
/// A (Dart) class that wraps a (Dart) instance of [ThermionViewer], /// A (Dart) class that wraps a (Dart) instance of [ThermionViewer],

View File

@@ -5,13 +5,11 @@ import 'dart:typed_data';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
import 'package:thermion_dart/thermion_dart/scene.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../../../entities/abstract_gizmo.dart';
import '../../../viewer.dart';
import '../../events.dart';
import '../../shared_types/camera.dart';
import 'thermion_viewer_js_shim.dart'; import 'thermion_viewer_js_shim.dart';
/// ///

View File

@@ -3,7 +3,7 @@ library thermion_flutter_js;
import 'dart:js_interop'; import 'dart:js_interop';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; import '../../shared_types/shared_types.dart';
/// ///
/// An extension type on [JSObject] that represents a /// An extension type on [JSObject] that represents a

View File

@@ -1,6 +1,6 @@
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import '../../shared_types/camera.dart';
import '../../thermion_viewer_base.dart'; import '../../thermion_viewer_base.dart';
class ThermionWasmCamera extends Camera { class ThermionWasmCamera extends Camera {
@@ -33,4 +33,16 @@ class ThermionWasmCamera extends Camera {
// TODO: implement setTransform // TODO: implement setTransform
throw UnimplementedError(); throw UnimplementedError();
} }
@override
ThermionEntity getEntity() {
// TODO: implement getEntity
throw UnimplementedError();
}
@override
Future setModelMatrix(Matrix4 matrix) {
// TODO: implement setModelMatrix
throw UnimplementedError();
}
} }

View File

@@ -1,4 +1,4 @@
import 'package:thermion_dart/thermion_dart/viewer/shared_types/material.dart'; import '../../../viewer.dart';
class ThermionWasmMaterialInstance extends MaterialInstance { class ThermionWasmMaterialInstance extends MaterialInstance {
final int pointer; final int pointer;

View File

@@ -5,16 +5,17 @@ import 'dart:math';
import 'dart:typed_data' as td; import 'dart:typed_data' as td;
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
import 'package:thermion_dart/thermion_dart/entities/gizmo.dart';
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
import 'package:web/web.dart'; import 'package:web/web.dart';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'dart:convert'; import 'dart:convert';
import '../../../../entities/abstract_gizmo.dart';
import '../../../../entities/gizmo.dart';
import '../../../viewer.dart';
import '../../events.dart';
import '../../shared_types/camera.dart';
import 'camera.dart'; import 'camera.dart';
import 'material_instance.dart'; import 'material_instance.dart';

View File

@@ -0,0 +1,7 @@
library thermion_viewer;
export 'src/shared_types/shared_types.dart';
export 'src/thermion_viewer_base.dart';
export 'src/thermion_viewer_stub.dart'
if (dart.library.io) 'src/ffi/thermion_viewer_ffi.dart'
if (dart.library.js_interop) 'src/web_wasm/thermion_viewer_web_wasm.dart';

View File

@@ -1,5 +1,5 @@
library filament_dart; library filament_dart;
export 'thermion_dart/input/input.dart'; export 'src/viewer/viewer.dart';
export 'thermion_dart/thermion_viewer.dart'; export 'src/input/input.dart';
export 'thermion_dart/utils/geometry.dart'; export 'src/utils/geometry.dart';

View File

@@ -1,6 +0,0 @@
library thermion_viewer;
export 'viewer/thermion_viewer_base.dart';
export 'viewer/thermion_viewer_stub.dart'
if (dart.library.io) 'viewer/ffi/thermion_viewer_ffi.dart'
if (dart.library.js_interop) 'viewer/web/thermion_viewer_wasm.dart';

View File

@@ -1,6 +1,5 @@
import 'package:thermion_dart/thermion_dart.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:thermion_dart/thermion_dart/utils/geometry.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'helpers.dart'; import 'helpers.dart';

View File

@@ -5,12 +5,11 @@ import 'package:image/image.dart' as img;
import 'dart:typed_data'; import 'dart:typed_data';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:image/image.dart'; import 'package:image/image.dart';
import 'package:thermion_dart/src/swift/swift_bindings.g.dart';
import 'package:thermion_dart/src/utils/dart_resources.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/src/viewer/src/ffi/thermion_viewer_ffi.dart';
import 'package:thermion_dart/thermion_dart.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:thermion_dart/thermion_dart/swift/swift_bindings.g.dart';
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;

View File

@@ -1,9 +1,8 @@
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:mockito/annotations.dart'; import 'package:mockito/annotations.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:thermion_dart/thermion_dart/input/src/input_handler.dart'; import 'package:thermion_dart/src/input/src/implementations/fixed_orbit_camera_rotation_delegate.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:thermion_dart/thermion_dart/input/src/implementations/fixed_orbit_camera_rotation_delegate.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
// Generate mocks // Generate mocks
@@ -30,7 +29,6 @@ void main() {
delegate = FixedOrbitRotateInputHandlerDelegate( delegate = FixedOrbitRotateInputHandlerDelegate(
mockViewer, mockViewer,
entity: mockEntity,
minimumDistance: 1.0, minimumDistance: 1.0,
); );
}); });

View File

@@ -8,13 +8,11 @@ import 'dart:typed_data' as _i8;
import 'package:animation_tools_dart/animation_tools_dart.dart' as _i9; import 'package:animation_tools_dart/animation_tools_dart.dart' as _i9;
import 'package:mockito/mockito.dart' as _i1; import 'package:mockito/mockito.dart' as _i1;
import 'package:thermion_dart/thermion_dart/viewer/events.dart' as _i7; import 'package:thermion_dart/src/viewer/src/events.dart' as _i7;
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart' import 'package:thermion_dart/src/viewer/src/shared_types/camera.dart' as _i3;
as _i3; import 'package:thermion_dart/src/viewer/src/shared_types/shared_types.dart'
import 'package:thermion_dart/thermion_dart/viewer/shared_types/shared_types.dart'
as _i4; as _i4;
import 'package:thermion_dart/thermion_dart/viewer/thermion_viewer_base.dart' import 'package:thermion_dart/src/viewer/src/thermion_viewer_base.dart' as _i5;
as _i5;
import 'package:vector_math/vector_math_64.dart' as _i2; import 'package:vector_math/vector_math_64.dart' as _i2;
// ignore_for_file: type=lint // ignore_for_file: type=lint

View File

@@ -1,14 +1,11 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'dart:typed_data'; import 'package:thermion_dart/src/viewer/src/events.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_viewer_ffi.dart';
import 'package:image/image.dart';
import 'package:thermion_dart/thermion_dart.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
import 'helpers.dart'; import 'helpers.dart';

View File

@@ -2,16 +2,12 @@ import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'dart:math'; import 'dart:math';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:thermion_dart/thermion_dart/swift/swift_bindings.g.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
import 'package:test/test.dart'; import 'package:test/test.dart';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:thermion_dart/src/swift/swift_bindings.g.dart';
import 'package:thermion_dart/thermion_dart/utils/geometry.dart'; import 'package:thermion_dart/src/utils/dart_resources.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart'; import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart'; import 'package:thermion_dart/src/viewer/src/ffi/thermion_viewer_ffi.dart';
import 'package:thermion_dart/thermion_dart.dart';
import 'package:vector_math/vector_math_64.dart'; import 'package:vector_math/vector_math_64.dart';
/// Test files are run in a variety of ways, find this package root in all. /// Test files are run in a variety of ways, find this package root in all.

View File

@@ -1,17 +1,10 @@
import 'dart:ffi'; import 'dart:ffi';
import 'dart:io'; import 'dart:io';
import 'dart:math';
import 'package:ffi/ffi.dart'; import 'package:ffi/ffi.dart';
import 'package:thermion_dart/thermion_dart/swift/swift_bindings.g.dart'; import 'package:thermion_dart/src/swift/swift_bindings.g.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; import 'package:thermion_dart/src/utils/dart_resources.dart';
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart'; import 'package:thermion_dart/src/viewer/src/ffi/thermion_viewer_ffi.dart';
import 'package:test/test.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
import 'package:vector_math/vector_math_64.dart';
/// Test files are run in a variety of ways, find this package root in all. /// Test files are run in a variety of ways, find this package root in all.
/// ///

View File

@@ -8,7 +8,7 @@ import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dar
/// Handles all platform-specific initialization to create a backing rendering /// Handles all platform-specific initialization to create a backing rendering
/// surface in a Flutter application and lifecycle listeners to pause rendering /// surface in a Flutter application and lifecycle listeners to pause rendering
/// when the app is inactive or in the background. /// when the app is inactive or in the background.
/// Call [createViewer] to create an instance of [ThermionViewer]. /// Call [createViewerWithOptions] to create an instance of [ThermionViewer].
/// ///
class ThermionFlutterPlugin { class ThermionFlutterPlugin {
ThermionFlutterPlugin._(); ThermionFlutterPlugin._();

View File

@@ -1,5 +1,6 @@
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';import 'package:flutter/material.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:flutter/material.dart';
import '../../../utils/camera_orientation.dart'; import '../../../utils/camera_orientation.dart';
import 'dart:math'; import 'dart:math';

View File

@@ -1,28 +0,0 @@
// import 'package:flutter/widgets.dart';
// import 'package:thermion_dart/thermion_dart/input/input_handler.dart';
// class MobileGestureHandlerSelectorWidget extends StatelessWidget {
// final InputHandler handler;
// const MobileGestureHandlerSelectorWidget({super.key, required this.handler});
// @override
// Widget build(BuildContext context) {
// throw Exception("TODO");
// // return GestureDetector(
// // onTap: () {
// // var curIdx =
// // InputType.values.indexOf(handler.gestureType);
// // var nextIdx =
// // curIdx == InputType.values.length - 1 ? 0 : curIdx + 1;
// // handler.setInputType(InputType.values[nextIdx]);
// // });
// // },
// // child: Container(
// // padding: const EdgeInsets.all(50),
// // child: Icon(_icons[widget.gestureHandler.gestureType],
// // color: Colors.green),
// // ),
// // );
// }
// }

View File

@@ -1,86 +0,0 @@
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:flutter/material.dart';
///
/// A widget that translates finger/mouse gestures to zoom/pan/rotate actions.
///
@Deprecated("Use ThermionListenerWidget instead")
class ThermionGestureDetector extends StatelessWidget {
///
/// The content to display below the gesture detector/listener widget.
/// This will usually be a ThermionWidget (so you can navigate by directly interacting with the viewport), but this is not necessary.
/// It is equally possible to render the viewport/gesture controls elsewhere in the widget hierarchy. The only requirement is that they share the same [FilamentController].
///
final Widget? child;
///
/// The [controller] attached to the [ThermionWidget] you wish to control.
///
final ThermionViewer controller;
///
/// If true, an overlay will be shown with buttons to toggle whether pointer movements are interpreted as:
/// 1) rotate or a pan (mobile only),
/// 2) moving the camera or the background image (TODO).
///
final bool showControlOverlay;
///
/// If false, gestures will not manipulate the active camera.
///
final bool enableCamera;
///
/// If false, pointer down events will not trigger hit-testing (picking).
///
final bool enablePicking;
final void Function(ScaleStartDetails)? onScaleStart;
final void Function(ScaleUpdateDetails)? onScaleUpdate;
final void Function(ScaleEndDetails)? onScaleEnd;
const ThermionGestureDetector(
{Key? key,
required this.controller,
this.child,
this.showControlOverlay = false,
this.enableCamera = true,
this.enablePicking = false,
this.onScaleStart,
this.onScaleUpdate,
this.onScaleEnd})
: super(key: key);
@override
Widget build(BuildContext context) {
throw Exception("TODO");
// return FutureBuilder(
// future: controller.initialized,
// builder: (_, initialized) {
// if (initialized.data != true) {
// return child ?? Container();
// }
// if (kIsWeb || Platform.isLinux ||
// Platform.isWindows ||
// Platform.isMacOS) {
// return ThermionGestureDetectorDesktop(
// controller: controller,
// child: child,
// showControlOverlay: showControlOverlay,
// enableCamera: enableCamera,
// enablePicking: enablePicking,
// );
// } else {
// return ThermionGestureDetectorMobile(
// controller: controller,
// child: child,
// showControlOverlay: showControlOverlay,
// enableCamera: enableCamera,
// enablePicking: enablePicking,
// onScaleStart: onScaleStart,
// onScaleUpdate: onScaleUpdate,
// onScaleEnd: onScaleEnd);
// }
// });
}
}

View File

@@ -1,60 +0,0 @@
// import 'package:thermion_dart/thermion_dart.dart';
// import 'package:flutter/gestures.dart';
// import 'package:flutter/material.dart';
// import 'package:vector_math/vector_math_64.dart';
// import 'dart:ui' show Offset;
// extension OffsetExtension on Offset {
// Vector2 toVector2() {
// return Vector2(dx, dy);
// }
// }
// class ThermionGestureDetectorDesktop extends StatefulWidget {
// final Widget? child;
// final InputHandler gestureHandler;
// final bool showControlOverlay;
// final bool enableCamera;
// final bool enablePicking;
// const ThermionGestureDetectorDesktop({
// Key? key,
// required this.gestureHandler,
// this.child,
// this.showControlOverlay = false,
// this.enableCamera = true,
// this.enablePicking = true,
// }) : super(key: key);
// @override
// State<StatefulWidget> createState() => _ThermionGestureDetectorDesktopState();
// }
// class _ThermionGestureDetectorDesktopState
// extends State<ThermionGestureDetectorDesktop> {
// @override
// Widget build(BuildContext context) {
// return Listener(
// onPointerHover: (event) =>
// widget.gestureHandler.onPointerHover(event.localPosition.toVector2(), event.delta.toVector2()),
// onPointerSignal: (PointerSignalEvent pointerSignal) {
// if (pointerSignal is PointerScrollEvent) {
// widget.gestureHandler.onPointerScroll(
// pointerSignal.localPosition.toVector2(), pointerSignal.scrollDelta.dy);
// }
// },
// onPointerPanZoomStart: (pzs) {
// throw Exception("TODO - is this a pinch zoom on laptop trackpad?");
// },
// onPointerDown: (d) =>
// widget.gestureHandler.onPointerDown(d.localPosition.toVector2(), d.buttons & kMiddleMouseButton != 0),
// onPointerMove: (PointerMoveEvent d) =>
// widget.gestureHandler.onPointerMove(d.localPosition.toVector2(), d.delta.toVector2(), d.buttons & kMiddleMouseButton != 0),
// onPointerUp: (d) => widget.gestureHandler.onPointerUp(d.buttons),
// child: widget.child,
// );
// }
// }

View File

@@ -1,234 +0,0 @@
import 'dart:async';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:flutter/material.dart';
enum InputType { rotateCamera, panCamera, panBackground }
///
/// A widget that translates finger/mouse gestures to zoom/pan/rotate actions.
///
class ThermionGestureDetectorMobile extends StatefulWidget {
///
/// The content to display below the gesture detector/listener widget.
/// This will usually be a ThermionWidget (so you can navigate by directly interacting with the viewport), but this is not necessary.
/// It is equally possible to render the viewport/gesture controls elsewhere in the widget hierarchy. The only requirement is that they share the same [Filamentviewer].
///
final Widget? child;
///
/// The [viewer] attached to the [ThermionWidget] you wish to control.
///
final ThermionViewer viewer;
///
/// If true, an overlay will be shown with buttons to toggle whether pointer movements are interpreted as:
/// 1) rotate or a pan (mobile only),
/// 2) moving the camera or the background image (TODO).
///
final bool showControlOverlay;
///
/// If false, gestures will not manipulate the active camera.
///
final bool enableCamera;
///
/// If false, pointer down events will not trigger hit-testing (picking).
///
final bool enablePicking;
final double zoomDelta;
final void Function(ScaleStartDetails)? onScaleStart;
final void Function(ScaleUpdateDetails)? onScaleUpdate;
final void Function(ScaleEndDetails)? onScaleEnd;
const ThermionGestureDetectorMobile(
{Key? key,
required this.viewer,
this.child,
this.showControlOverlay = false,
this.enableCamera = true,
this.enablePicking = true,
this.onScaleStart,
this.onScaleUpdate,
this.onScaleEnd,
this.zoomDelta = 1})
: super(key: key);
@override
State<StatefulWidget> createState() => _ThermionGestureDetectorMobileState();
}
class _ThermionGestureDetectorMobileState
extends State<ThermionGestureDetectorMobile> {
InputType gestureType = InputType.panCamera;
final _icons = {
InputType.panBackground: Icons.image,
InputType.panCamera: Icons.pan_tool,
InputType.rotateCamera: Icons.rotate_90_degrees_ccw
};
// on mobile, we can't differentiate between pointer down events like we do on desktop with primary/secondary/tertiary buttons
// we allow the user to toggle between panning and rotating by double-tapping the widget
bool _rotateOnPointerMove = false;
//
//
//
bool _scaling = false;
// to avoid duplicating code for pan/rotate (panStart, panUpdate, panEnd, rotateStart, rotateUpdate etc)
// we have only a single function for start/update/end.
// when the gesture type is changed, these properties are updated to point to the correct function.
// ignore: unused_field
late Function(double x, double y) _functionStart;
// ignore: unused_field
late Function(double x, double y) _functionUpdate;
// ignore: unused_field
late Function() _functionEnd;
@override
void initState() {
_setFunction();
super.initState();
}
void _setFunction() {
switch (gestureType) {
case InputType.rotateCamera:
_functionStart = widget.viewer.rotateStart;
_functionUpdate = widget.viewer.rotateUpdate;
_functionEnd = widget.viewer.rotateEnd;
break;
case InputType.panCamera:
_functionStart = widget.viewer.panStart;
_functionUpdate = widget.viewer.panUpdate;
_functionEnd = widget.viewer.panEnd;
break;
// TODO
case InputType.panBackground:
_functionStart = (x, y) async {};
_functionUpdate = (x, y) async {};
_functionEnd = () async {};
}
}
@override
void didUpdateWidget(ThermionGestureDetectorMobile oldWidget) {
if (widget.showControlOverlay != oldWidget.showControlOverlay ||
widget.enableCamera != oldWidget.enableCamera ||
widget.enablePicking != oldWidget.enablePicking) {
setState(() {});
}
super.didUpdateWidget(oldWidget);
}
// ignore: unused_field
Timer? _scrollTimer;
double _lastScale = 0;
// pinch zoom on mobile
// couldn't find any equivalent for pointerCount in Listener (?) so we use a GestureDetector
@override
Widget build(BuildContext context) {
return Stack(children: [
Positioned.fill(
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTapDown: (d) {
if (!widget.enablePicking) {
return;
}
widget.viewer.pick(
d.globalPosition.dx.toInt(), d.globalPosition.dy.toInt());
},
onDoubleTap: () {
setState(() {
_rotateOnPointerMove = !_rotateOnPointerMove;
});
},
onScaleStart: (d) async {
if (widget.onScaleStart != null) {
widget.onScaleStart!.call(d);
return;
}
if (d.pointerCount == 2 && widget.enableCamera) {
_scaling = true;
await widget.viewer.zoomBegin();
} else if (!_scaling && widget.enableCamera) {
if (_rotateOnPointerMove) {
widget.viewer.rotateStart(
d.localFocalPoint.dx, d.localFocalPoint.dy);
} else {
widget.viewer
.panStart(d.localFocalPoint.dx, d.localFocalPoint.dy);
}
}
},
onScaleUpdate: (ScaleUpdateDetails d) async {
if (widget.onScaleUpdate != null) {
widget.onScaleUpdate!.call(d);
return;
}
if (d.pointerCount == 2 && widget.enableCamera) {
if (d.horizontalScale != _lastScale) {
widget.viewer.zoomUpdate(
d.localFocalPoint.dx,
d.localFocalPoint.dy,
d.horizontalScale > _lastScale ? 0.1 : -0.1);
_lastScale = d.horizontalScale;
}
} else if (!_scaling && widget.enableCamera) {
if (_rotateOnPointerMove) {
widget.viewer
.rotateUpdate(d.focalPoint.dx, d.focalPoint.dy);
} else {
widget.viewer
.panUpdate(d.focalPoint.dx, d.focalPoint.dy);
}
}
},
onScaleEnd: (d) async {
if (widget.onScaleEnd != null) {
widget.onScaleEnd!.call(d);
return;
}
if (d.pointerCount == 2 && widget.enableCamera) {
widget.viewer.zoomEnd();
} else if (!_scaling && widget.enableCamera) {
if (_rotateOnPointerMove) {
widget.viewer.rotateEnd();
} else {
widget.viewer.panEnd();
}
}
_scaling = false;
},
child: widget.child)),
widget.showControlOverlay
? Align(
alignment: Alignment.bottomRight,
child: GestureDetector(
onTap: () {
setState(() {
var curIdx = InputType.values.indexOf(gestureType);
var nextIdx = curIdx == InputType.values.length - 1
? 0
: curIdx + 1;
gestureType = InputType.values[nextIdx];
_setFunction();
});
},
child: Container(
padding: const EdgeInsets.all(50),
child: Icon(_icons[gestureType], color: Colors.green)),
))
: Container()
]);
}
}

View File

@@ -1,5 +1,5 @@
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:math'; import 'dart:math';

View File

@@ -1,7 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:thermion_dart/thermion_dart.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:animation_tools_dart/animation_tools_dart.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';

View File

@@ -1,6 +1,6 @@
import 'dart:math'; import 'dart:math';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:thermion_dart/thermion_dart.dart';
import 'package:vector_math/vector_math_64.dart' as v; import 'package:vector_math/vector_math_64.dart' as v;
class IblRotationSliderWidget extends StatefulWidget { class IblRotationSliderWidget extends StatefulWidget {

View File

@@ -1,4 +1,4 @@
library; library;
export 'src/thermion_widget.dart'; export 'src/thermion_widget.dart';
export 'src/camera/gestures/thermion_listener_widget.dart'; export 'src/thermion_listener_widget.dart';

View File

@@ -2,7 +2,7 @@ import 'dart:async';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'dart:ffi'; import 'dart:ffi';
import 'package:thermion_dart/thermion_dart.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_viewer_ffi.dart'; import 'package:thermion_dart/src/viewer/src/ffi/thermion_viewer_ffi.dart';
import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart'; import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart';
import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart'; import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';

View File

@@ -1,7 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:thermion_dart/thermion_dart.dart';
import 'thermion_flutter_texture.dart'; import 'thermion_flutter_texture.dart';
class ThermionFlutterOptions { class ThermionFlutterOptions {

View File

@@ -1,5 +1,4 @@
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart'; import 'package:thermion_dart/thermion_dart.dart';
import 'package:thermion_dart/thermion_dart/viewer/web_wasm/src/thermion_viewer_wasm.dart';
import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart'; import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart';
import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart'; import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart';
import 'package:flutter_web_plugins/flutter_web_plugins.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart';