From d92ad4ef127f6558ec60ae188f76d1bccf8727df Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Thu, 17 Jul 2025 12:10:55 +0800 Subject: [PATCH] feat: allow passing renderTargetColorTextureFormat via ThermionFlutterOptions --- ...rmion_flutter_method_channel_platform.dart | 4 ++-- .../thermion_flutter_platform_interface.dart | 24 ++++++++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart b/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart index 6412f69d..9725dd3a 100644 --- a/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart +++ b/thermion_flutter/thermion_flutter_method_channel/lib/src/thermion_flutter_method_channel_platform.dart @@ -212,7 +212,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform { TextureUsage.TEXTURE_USAGE_COLOR_ATTACHMENT, TextureUsage.TEXTURE_USAGE_SAMPLEABLE, }, - textureFormat: TextureFormat.RGBA32F, + textureFormat: options.renderTargetColorTextureFormat, textureSamplerType: TextureSamplerType.SAMPLER_2D, ); final depth = await FilamentApp.instance!.createTexture( @@ -225,7 +225,7 @@ class ThermionFlutterMethodChannelPlatform extends ThermionFlutterPlatform { TextureUsage.TEXTURE_USAGE_STENCIL_ATTACHMENT }, textureFormat: - TextureFormat.DEPTH24_STENCIL8, // TextureFormat.DEPTH32F, + options.renderTargetDepthTextureFormat, textureSamplerType: TextureSamplerType.SAMPLER_2D, ); diff --git a/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart b/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart index 6a233683..c136c2b8 100644 --- a/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart +++ b/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart @@ -7,13 +7,25 @@ import 'thermion_flutter_texture.dart'; class ThermionFlutterOptions { final String? uberarchivePath; final Backend? backend; + + /// The format to use for the default render target color attachment. + /// Currently only applicable on iOS/macOS. + /// + final TextureFormat renderTargetColorTextureFormat; + + /// The format to use for the default render target depth attachment. + /// Currently only applicable on iOS/macOS. + /// + final TextureFormat renderTargetDepthTextureFormat; const ThermionFlutterOptions( - {this.uberarchivePath = null, this.backend = null}); + {this.uberarchivePath = null, + this.backend = null, + this.renderTargetColorTextureFormat = TextureFormat.RGBA32F, + this.renderTargetDepthTextureFormat = TextureFormat.DEPTH24_STENCIL8}); } class ThermionFlutterWebOptions extends ThermionFlutterOptions { - final bool createCanvas; final bool importCanvasAsWidget; @@ -22,8 +34,6 @@ class ThermionFlutterWebOptions extends ThermionFlutterOptions { this.createCanvas = true, String? uberarchivePath}) : super(uberarchivePath: uberarchivePath); - - } abstract class ThermionFlutterPlatform extends PlatformInterface { @@ -42,15 +52,11 @@ abstract class ThermionFlutterPlatform extends PlatformInterface { _options ??= const ThermionFlutterOptions(); return _options!; } - + /// /// /// void setOptions(covariant ThermionFlutterOptions options) { - if (_options != null) { - throw Exception( - "Options can only be set once for the entire app lifecycle."); - } _options = options; }