more camera work
This commit is contained in:
@@ -3,11 +3,11 @@ import 'dart:ffi';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import '../../../../utils/matrix.dart';
|
||||
import '../../shared_types/camera.dart';
|
||||
import '../../thermion_viewer_base.dart';
|
||||
import 'thermion_dart.g.dart';
|
||||
|
||||
class ThermionFFICamera extends Camera {
|
||||
|
||||
final Pointer<TCamera> camera;
|
||||
final Pointer<TEngine> engine;
|
||||
late ThermionEntity _entity;
|
||||
@@ -51,4 +51,14 @@ class ThermionFFICamera extends Camera {
|
||||
Future setModelMatrix(Matrix4 matrix) async {
|
||||
Camera_setModelMatrix(camera, matrix4ToDouble4x4(matrix));
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) =>
|
||||
identical(this, other) ||
|
||||
other is ThermionFFICamera &&
|
||||
runtimeType == other.runtimeType &&
|
||||
camera == other.camera;
|
||||
|
||||
@override
|
||||
int get hashCode => camera.hashCode;
|
||||
}
|
||||
|
||||
@@ -970,6 +970,19 @@ external void SceneManager_setCamera(
|
||||
ffi.Pointer<TCamera> camera,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Size Function(ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
external int SceneManager_getCameraCount(
|
||||
ffi.Pointer<TSceneManager> sceneManager,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TCamera> Function(
|
||||
ffi.Pointer<TSceneManager>, ffi.Size)>(isLeaf: true)
|
||||
external ffi.Pointer<TCamera> SceneManager_getCameraAt(
|
||||
ffi.Pointer<TSceneManager> sceneManager,
|
||||
int index,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Int Function(ffi.Pointer<TSceneManager>, EntityId,
|
||||
ffi.Pointer<ffi.Char>)>(isLeaf: true)
|
||||
|
||||
@@ -2205,6 +2205,25 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
_hooks.remove(hook);
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
int getCameraCount() {
|
||||
return SceneManager_getCameraCount(_sceneManager!);
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the camera specified by the given index. Note that the camera at
|
||||
/// index 0 is always the main camera; this cannot be destroyed.
|
||||
///
|
||||
Camera getCameraAt(int index) {
|
||||
final camera = SceneManager_getCameraAt(_sceneManager!, index);
|
||||
if (camera == nullptr) {
|
||||
throw Exception("No camera at index $index");
|
||||
}
|
||||
return ThermionFFICamera(camera, Viewer_getEngine(_viewer!));
|
||||
}
|
||||
}
|
||||
|
||||
class ThermionFFITexture extends ThermionTexture {
|
||||
|
||||
@@ -979,4 +979,15 @@ abstract class ThermionViewer {
|
||||
///
|
||||
///
|
||||
Future unregisterRequestFrameHook(Future Function() hook);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
int getCameraCount();
|
||||
|
||||
///
|
||||
/// Returns the camera specified by the given index. Note that the camera at
|
||||
/// index 0 is always the main camera; this cannot be destroyed.
|
||||
///
|
||||
Camera getCameraAt(int index);
|
||||
}
|
||||
|
||||
@@ -995,6 +995,18 @@ class ThermionViewerStub extends ThermionViewer {
|
||||
// TODO: implement unregisterRequestFrameHook
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Camera getCameraAt(int index) {
|
||||
// TODO: implement getCameraAt
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
int getCameraCount() {
|
||||
// TODO: implement getCameraCount
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +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';
|
||||
export 'src/shared_types/shared_types.dart';
|
||||
Reference in New Issue
Block a user