diff --git a/thermion_dart/lib/thermion_dart/thermion_viewer.dart b/thermion_dart/lib/thermion_dart/thermion_viewer.dart index fbde2d28..1cb115a2 100644 --- a/thermion_dart/lib/thermion_dart/thermion_viewer.dart +++ b/thermion_dart/lib/thermion_dart/thermion_viewer.dart @@ -203,10 +203,11 @@ abstract class ThermionViewer { /// 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 loadGlb(String path, {int numInstances = 1, bool keepData = false}); + Future loadGlb(String path, + {int numInstances = 1, bool keepData = false}); /// - /// Create a new instance of [entity]. + /// Create a new instance of [entity]. /// Future createInstance(ThermionEntity entity); @@ -224,7 +225,7 @@ abstract class ThermionViewer { /// Load the .gltf asset at the given path and insert into 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 loadGltf(String path, String relativeResourcePath, @@ -609,12 +610,20 @@ abstract class ThermionViewer { ThermionEntity entity, double x, double y, double z, {bool relative = false}); + /// + /// TODO + /// + Future queuePositionUpdateFromViewportCoords( + ThermionEntity entity, double x, double y); + /// /// TODO /// Future queueRelativePositionUpdateWorldAxis(ThermionEntity entity, double viewportX, double viewportY, double x, double y, double z); + + /// /// Queues an update to the worldspace rotation for [entity]. /// The actual update will occur on the next frame, and will be subject to collision detection. @@ -818,7 +827,13 @@ abstract class ThermionViewer { Future setGizmoVisibility(bool visible); /// - /// Outlines [entity]. - /// - Future setStencilHighlight(ThermionEntity entity); + /// 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); } diff --git a/thermion_dart/lib/thermion_dart/thermion_viewer_ffi.dart b/thermion_dart/lib/thermion_dart/thermion_viewer_ffi.dart index ed48c139..47f0a526 100644 --- a/thermion_dart/lib/thermion_dart/thermion_viewer_ffi.dart +++ b/thermion_dart/lib/thermion_dart/thermion_viewer_ffi.dart @@ -444,8 +444,8 @@ class ThermionViewerFFI extends ThermionViewer { throw Exception("Not yet implemented"); } final pathPtr = path.toNativeUtf8(allocator: allocator).cast(); - var entity = await withIntCallback((callback) => - load_glb_ffi(_sceneManager!, pathPtr, numInstances, keepData, callback)); + var entity = await withIntCallback((callback) => load_glb_ffi( + _sceneManager!, pathPtr, numInstances, keepData, callback)); allocator.free(pathPtr); if (entity == _FILAMENT_ASSET_ERROR) { throw Exception("An error occurred loading the asset at $path"); @@ -1334,6 +1334,9 @@ class ThermionViewerFFI extends ThermionViewer { set_scale(_sceneManager!, entity, scale); } + /// + /// + /// Future queueRotationUpdateQuat(ThermionEntity entity, Quaternion rotation, {bool relative = false}) async { queue_rotation_update(_sceneManager!, entity, rotation.radians, rotation.x, @@ -1361,6 +1364,18 @@ class ThermionViewerFFI extends ThermionViewer { queue_position_update(_sceneManager!, entity, x, y, z, relative); } + /// + /// Queues an update to the worldspace position for [entity] to the viewport coordinates {x,y}. + /// The actual update will occur on the next frame, and will be subject to collision detection. + /// + Future queuePositionUpdateFromViewportCoords( + ThermionEntity entity, double x, double y) async { + queue_position_update_from_viewport_coords(_sceneManager!, entity, x, y); + } + + /// + /// + /// Future queueRelativePositionUpdateWorldAxis(ThermionEntity entity, double viewportX, double viewportY, double x, double y, double z) async { queue_relative_position_update_world_axis( @@ -1742,7 +1757,7 @@ class ThermionViewerFFI extends ThermionViewer { } var entity = await withIntCallback((callback) => create_geometry_ffi( - _viewer!, + _sceneManager!, vertexPtr, vertices.length, indicesPtr, @@ -1830,7 +1845,18 @@ class ThermionViewerFFI extends ThermionViewer { set_gizmo_visibility(_sceneManager!, visible); } - Future setStencilHighlight(ThermionEntity entity) async { - set_stencil_highlight(_sceneManager!, entity); + /// + /// + /// + Future setStencilHighlight(ThermionEntity entity, + {double r = 1.0, double g = 0.0, double b = 0.0}) async { + set_stencil_highlight(_sceneManager!, entity, r, g, b); + } + + /// + /// + /// + Future removeStencilHighlight(ThermionEntity entity) async { + remove_stencil_highlight(_sceneManager!, entity); } }