implement TSkybox and use setColor method to set the background color, rather than the image
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_camera.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_skybox.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_asset.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_gizmo.dart';
|
||||
@@ -10,6 +11,7 @@ import 'package:thermion_dart/src/filament/src/implementation/ffi_scene.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_swapchain.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_texture.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_view.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/skybox.dart';
|
||||
import 'package:thermion_dart/src/utils/src/matrix.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
@@ -1207,5 +1209,17 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
|
||||
Vector3(bb.halfExtentX, bb.halfExtentY, bb.halfExtentZ));
|
||||
}
|
||||
|
||||
|
||||
/// Builds an (empty) [Skybox] instance. This will not be attached to any scene until
|
||||
/// [setSkybox] is called.
|
||||
///
|
||||
Future<Skybox> buildSkybox({Texture? texture = null}) async {
|
||||
final ptr = await withPointerCallback<TSkybox>((cb) {
|
||||
Engine_buildSkyboxRenderThread(
|
||||
engine,
|
||||
(texture as FFITexture?)?.pointer ?? nullptr,
|
||||
cb,
|
||||
);
|
||||
});
|
||||
return FFISkybox(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_asset.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_indirect_light.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_skybox.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/skybox.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
@@ -153,4 +155,11 @@ class FFIScene extends Scene {
|
||||
Future<IndirectLight?> getIndirectLight() async {
|
||||
return _indirectLight;
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setSkybox(Skybox skybox) async {
|
||||
Scene_setSkybox(scene, (skybox as FFISkybox).pointer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/skybox.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
class FFISkybox extends Skybox {
|
||||
final Pointer<TSkybox> pointer;
|
||||
|
||||
FFISkybox(this.pointer);
|
||||
|
||||
@override
|
||||
Future setColor(double r, double g, double b, double a) async {
|
||||
Skybox_setColor(pointer, r, g, b, a);
|
||||
}
|
||||
|
||||
@override
|
||||
Future destroy() async {
|
||||
await withVoidCallback(
|
||||
(requestId, cb) => Engine_destroySkyboxRenderThread(
|
||||
(FilamentApp.instance as FFIFilamentApp).engine,
|
||||
pointer,
|
||||
requestId,
|
||||
cb,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/skybox.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
class FilamentConfig<T, U> {
|
||||
@@ -344,19 +345,23 @@ abstract class FilamentApp<T> {
|
||||
Future<Matrix4> getWorldTransform(ThermionEntity entity);
|
||||
|
||||
/// Sets the render priority for [entity].
|
||||
/// [priority] should be be between 0 and 7, with 0 meaning highest priority
|
||||
/// [priority] should be be between 0 and 7, with 0 meaning highest priority
|
||||
/// (rendered first) and 7 meaning lowest priority (rendered last).
|
||||
///
|
||||
Future setPriority(ThermionEntity entity, int priority);
|
||||
|
||||
/// Gets the number of primitives for [entity] (which is assumed to be
|
||||
/// Gets the number of primitives for [entity] (which is assumed to be
|
||||
/// have a renderable component attached)
|
||||
///
|
||||
Future<int> getPrimitiveCount(ThermionEntity entity);
|
||||
|
||||
/// Gets the bounding box for [entity] (which is assumed to be
|
||||
/// Gets the bounding box for [entity] (which is assumed to be
|
||||
/// have a renderable component attached).
|
||||
///
|
||||
Future<Aabb3> getBoundingBox(ThermionEntity entity);
|
||||
|
||||
/// Builds a [Skybox] instance. This will not be attached to any scene until
|
||||
/// [setSkybox] is called.
|
||||
///
|
||||
Future<Skybox> buildSkybox({Texture? texture = null});
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:thermion_dart/src/filament/src/interface/skybox.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
abstract class Scene {
|
||||
@@ -49,4 +50,11 @@ abstract class Scene {
|
||||
Future<IndirectLight?> getIndirectLight() {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setSkybox(Skybox skybox) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
11
thermion_dart/lib/src/filament/src/interface/skybox.dart
Normal file
11
thermion_dart/lib/src/filament/src/interface/skybox.dart
Normal file
@@ -0,0 +1,11 @@
|
||||
abstract class Skybox {
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setColor(double r, double g, double b, double a);
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future destroy();
|
||||
}
|
||||
Reference in New Issue
Block a user