add setBackgroundImageFromTexture method to ThermionViewer

This commit is contained in:
Nick Fisher
2025-07-01 10:23:25 +08:00
parent 2545bbbd35
commit 45c4cea6aa
2 changed files with 28 additions and 14 deletions

View File

@@ -223,6 +223,14 @@ class ThermionViewerFFI extends ThermionViewer {
return _backgroundImage!;
}
///
///
///
Future setBackgroundImageFromTexture(Texture texture) async {
var backgroundImage = await getBackgroundImage();
await backgroundImage.setImageFromTexture(texture);
}
///
///
///
@@ -683,6 +691,7 @@ class ThermionViewerFFI extends ThermionViewer {
///
Future setGridOverlayVisibility(bool visible) async {
_grid ??= _grid = await GridOverlay.create(app, animationManager);
if (visible) {
await scene.add(_grid!);
await view.setLayerVisibility(VisibilityLayers.OVERLAY, true);

View File

@@ -59,13 +59,18 @@ abstract class ThermionViewer {
Future dispose();
///
/// Set the background image to [path] (which should have a file extension .png, .jpg, or .ktx).
/// This will be rendered at the maximum depth (i.e. behind all other objects including the skybox).
/// Set the background image to [path] (which should be .png, .jpg, or .ktx
/// file). This will be rendered at the maximum depth (i.e. behind all other objects including the skybox).
/// If [fillHeight] is false, the image will be rendered at its original size. Note this may cause issues with pixel density so be sure to specify the correct resolution
/// If [fillHeight] is true, the image will be stretched/compressed to fit the height of the viewport.
///
Future setBackgroundImage(String path, {bool fillHeight = false});
///
/// Set the background image from [texture].
///
Future setBackgroundImageFromTexture(Texture texture);
///
/// Moves the background image to the relative offset from the origin (bottom-left) specified by [x] and [y].
/// If [clamp] is true, the image cannot be positioned outside the bounds of the viewport.
@@ -300,7 +305,7 @@ abstract class ThermionViewer {
/// If [destroy] is true, the geometry and material instance for the asset
/// will also be destroyed.
///
Future hideBoundingBox(ThermionAsset asset, { bool destroy = false});
Future hideBoundingBox(ThermionAsset asset, {bool destroy = false});
///
/// Gets the 2D bounding box (in viewport coordinates) for the given entity.