refactoring + texture projection
This commit is contained in:
@@ -42,6 +42,11 @@ abstract class ThermionAsset {
|
||||
///
|
||||
Future<ThermionEntity?> getChildEntity(String childName);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<MaterialInstance> getMaterialInstanceAt({ThermionEntity? entity, int index = 0});
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:typed_data';
|
||||
import 'package:thermion_dart/src/filament/src/engine.dart';
|
||||
import 'package:thermion_dart/src/filament/src/scene.dart';
|
||||
import 'package:thermion_dart/src/viewer/src/ffi/src/callbacks.dart';
|
||||
import 'package:thermion_dart/src/viewer/src/ffi/src/ffi_material.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
class FilamentConfig<T, U> {
|
||||
@@ -59,6 +61,16 @@ abstract class FilamentApp<T> {
|
||||
///
|
||||
Future<SwapChain> createSwapChain(T handle, {bool hasStencilBuffer = false});
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<View> createView();
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<Scene> createScene();
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@@ -98,7 +110,7 @@ abstract class FilamentApp<T> {
|
||||
int levels = 1,
|
||||
Set<TextureUsage> flags = const {TextureUsage.TEXTURE_USAGE_SAMPLEABLE},
|
||||
TextureSamplerType textureSamplerType = TextureSamplerType.SAMPLER_2D,
|
||||
TextureFormat textureFormat = TextureFormat.RGBA16F,
|
||||
TextureFormat textureFormat = TextureFormat.RGBA32F,
|
||||
int? importedTextureHandle});
|
||||
|
||||
///
|
||||
@@ -185,12 +197,17 @@ abstract class FilamentApp<T> {
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setRenderable(covariant View view, bool renderable);
|
||||
Future register(covariant SwapChain swapChain, covariant View view);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future register(covariant SwapChain swapChain, covariant View view);
|
||||
Future unregister(covariant SwapChain swapChain, covariant View view);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future updateRenderOrder();
|
||||
|
||||
///
|
||||
///
|
||||
@@ -239,10 +256,19 @@ abstract class FilamentApp<T> {
|
||||
Future<MaterialInstance> createImageMaterialInstance();
|
||||
|
||||
///
|
||||
/// Returns pixel buffer(s) for [view] (or, if null, all views associated
|
||||
/// with [swapChain] by calling [register]).
|
||||
///
|
||||
/// Pixel buffers will be returned in RGBA float32 format.
|
||||
///
|
||||
///
|
||||
Future<Uint8List> capture(covariant View view,
|
||||
{bool captureRenderTarget = false});
|
||||
Future<List<(View,Uint8List)>> capture(covariant SwapChain swapChain,
|
||||
{
|
||||
covariant View? view,
|
||||
bool captureRenderTarget = false,
|
||||
PixelDataFormat pixelDataFormat = PixelDataFormat.RGBA,
|
||||
PixelDataType pixelDataType = PixelDataType.UBYTE,
|
||||
Future Function(View)? beforeRender}
|
||||
);
|
||||
|
||||
///
|
||||
///
|
||||
@@ -269,5 +295,14 @@ abstract class FilamentApp<T> {
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<GizmoAsset> createGizmo(covariant View view, T animationManager, GizmoType type);
|
||||
Future<GizmoAsset> createGizmo(
|
||||
covariant View view, T animationManager, GizmoType type);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future<ThermionAsset> createGeometry(Geometry geometry, T animationManager,
|
||||
{List<MaterialInstance>? materialInstances,
|
||||
bool keepData = false});
|
||||
|
||||
}
|
||||
|
||||
@@ -363,85 +363,113 @@ abstract class Texture {
|
||||
Future dispose();
|
||||
}
|
||||
|
||||
/// Pixel data format enum, representing different channel combinations
|
||||
enum PixelDataFormat {
|
||||
R,
|
||||
|
||||
/// One Red channel, float
|
||||
R_INTEGER,
|
||||
R(0),
|
||||
|
||||
/// One Red channel, integer
|
||||
RG,
|
||||
R_INTEGER(1),
|
||||
|
||||
/// Two Red and Green channels, float
|
||||
RG_INTEGER,
|
||||
RG(2),
|
||||
|
||||
/// Two Red and Green channels, integer
|
||||
RGB,
|
||||
RG_INTEGER(3),
|
||||
|
||||
/// Three Red, Green and Blue channels, float
|
||||
RGB_INTEGER,
|
||||
RGB(4),
|
||||
|
||||
/// Three Red, Green and Blue channels, integer
|
||||
RGBA,
|
||||
RGB_INTEGER(5),
|
||||
|
||||
/// Four Red, Green, Blue and Alpha channels, float
|
||||
RGBA_INTEGER,
|
||||
RGBA(6),
|
||||
|
||||
/// Four Red, Green, Blue and Alpha channels, integer
|
||||
UNUSED,
|
||||
RGBA_INTEGER(7),
|
||||
|
||||
/// Used to be rgbm
|
||||
DEPTH_COMPONENT,
|
||||
/// Unused format
|
||||
UNUSED(8),
|
||||
|
||||
/// Depth, 16-bit or 24-bits usually
|
||||
DEPTH_STENCIL,
|
||||
DEPTH_COMPONENT(9),
|
||||
|
||||
/// Two Depth (24-bits) + Stencil (8-bits) channels
|
||||
ALPHA
|
||||
DEPTH_STENCIL(10),
|
||||
|
||||
/// One Alpha channel, float
|
||||
/// Alpha channel only
|
||||
ALPHA(11);
|
||||
|
||||
/// The integer value of the enum
|
||||
final int value;
|
||||
|
||||
/// Constructor with the integer value
|
||||
const PixelDataFormat(this.value);
|
||||
|
||||
/// Factory constructor to create a PixelDataFormat from an integer value
|
||||
factory PixelDataFormat.fromValue(int value) {
|
||||
return PixelDataFormat.values.firstWhere(
|
||||
(format) => format.value == value,
|
||||
orElse: () => throw ArgumentError('Invalid PixelDataFormat value: $value'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Pixel Data Type
|
||||
/// Pixel data type enum, representing different data types for pixel values
|
||||
enum PixelDataType {
|
||||
UBYTE,
|
||||
|
||||
/// Unsigned byte
|
||||
BYTE,
|
||||
UBYTE(0),
|
||||
|
||||
/// Signed byte
|
||||
USHORT,
|
||||
BYTE(1),
|
||||
|
||||
/// Unsigned short (16-bit)
|
||||
SHORT,
|
||||
USHORT(2),
|
||||
|
||||
/// Signed short (16-bit)
|
||||
UINT,
|
||||
SHORT(3),
|
||||
|
||||
/// Unsigned int (32-bit)
|
||||
INT,
|
||||
UINT(4),
|
||||
|
||||
/// Signed int (32-bit)
|
||||
HALF,
|
||||
INT(5),
|
||||
|
||||
/// Half-float (16-bit float)
|
||||
FLOAT,
|
||||
HALF(6),
|
||||
|
||||
/// Float (32-bits float)
|
||||
COMPRESSED,
|
||||
FLOAT(7),
|
||||
|
||||
/// Compressed pixels, see CompressedPixelDataType
|
||||
UINT_10F_11F_11F_REV,
|
||||
/// Compressed pixels
|
||||
COMPRESSED(8),
|
||||
|
||||
/// Three low precision floating-point numbers
|
||||
USHORT_565,
|
||||
UINT_10F_11F_11F_REV(9),
|
||||
|
||||
/// Unsigned int (16-bit), encodes 3 RGB channels
|
||||
UINT_2_10_10_10_REV,
|
||||
USHORT_565(10),
|
||||
|
||||
/// Unsigned normalized 10 bits RGB, 2 bits alpha
|
||||
UINT_2_10_10_10_REV(11);
|
||||
|
||||
/// The integer value of the enum
|
||||
final int value;
|
||||
|
||||
/// Constructor with the integer value
|
||||
const PixelDataType(this.value);
|
||||
|
||||
/// Factory constructor to create a PixelDataType from an integer value
|
||||
factory PixelDataType.fromValue(int value) {
|
||||
return PixelDataType.values.firstWhere(
|
||||
(type) => type.value == value,
|
||||
orElse: () => throw ArgumentError('Invalid PixelDataType value: $value'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@deprecated
|
||||
typedef ThermionTexture = Texture;
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ abstract class View {
|
||||
Future setViewport(int width, int height);
|
||||
Future<RenderTarget?> getRenderTarget();
|
||||
Future setRenderTarget(covariant RenderTarget? renderTarget);
|
||||
int get renderOrder;
|
||||
Future setRenderOrder(int order);
|
||||
Future setCamera(covariant Camera camera);
|
||||
Future<Camera> getCamera();
|
||||
Future setPostProcessing(bool enabled);
|
||||
|
||||
Reference in New Issue
Block a user