add setFogOptions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_texture.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_filament_app.dart';
|
||||
import 'package:thermion_dart/src/filament/src/implementation/ffi_render_target.dart';
|
||||
@@ -189,7 +190,8 @@ class FFIView extends View {
|
||||
var viewport = await getViewport();
|
||||
y = viewport.height - y;
|
||||
if (FILAMENT_WASM) {
|
||||
View_pickRenderThread(view, pickRequestId, x, y, _onPickResultHolder.pointer);
|
||||
View_pickRenderThread(
|
||||
view, pickRequestId, x, y, _onPickResultHolder.pointer);
|
||||
} else {
|
||||
View_pick(view, pickRequestId, x, y, _onPickResultHolder.pointer);
|
||||
}
|
||||
@@ -218,4 +220,25 @@ class FFIView extends View {
|
||||
fragZ: fragZ,
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Future setFogOptions(FogOptions options) async {
|
||||
final tFogOptions = Struct.create<TFogOptions>();
|
||||
tFogOptions.cutOffDistance = options.cutOffDistance;
|
||||
tFogOptions.enabled = options.enabled;
|
||||
tFogOptions.density = options.density;
|
||||
tFogOptions.distance = options.distance;
|
||||
tFogOptions.fogColorFromIbl = options.fogColorFromIbl;
|
||||
tFogOptions.height = options.height;
|
||||
tFogOptions.heightFalloff = options.heightFalloff;
|
||||
tFogOptions.inScatteringSize = options.inScatteringSize;
|
||||
tFogOptions.inScatteringStart = options.inScatteringStart;
|
||||
tFogOptions.maximumOpacity = options.maximumOpacity;
|
||||
tFogOptions.skyColor =
|
||||
(options.skyColor as FFITexture?)?.pointer ?? nullptr;
|
||||
tFogOptions.linearColor.x = options.linearColor.r;
|
||||
tFogOptions.linearColor.y = options.linearColor.x;
|
||||
tFogOptions.linearColor.z = options.linearColor.x;
|
||||
View_setFogOptions(this.view, tFogOptions.address);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,39 @@ import 'package:thermion_dart/src/filament/src/interface/layers.dart';
|
||||
import 'package:thermion_dart/src/filament/src/interface/scene.dart';
|
||||
import 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
enum BlendMode {
|
||||
opaque,
|
||||
transparent
|
||||
class FogOptions {
|
||||
final double distance;
|
||||
final double cutOffDistance;
|
||||
final double maximumOpacity;
|
||||
final double height;
|
||||
final double heightFalloff;
|
||||
late final Vector3 linearColor;
|
||||
final double density;
|
||||
final double inScatteringStart;
|
||||
final double inScatteringSize;
|
||||
final bool fogColorFromIbl;
|
||||
final Texture? skyColor;
|
||||
final bool enabled;
|
||||
|
||||
FogOptions(
|
||||
{this.enabled = false,
|
||||
this.distance = 0.0,
|
||||
this.cutOffDistance = double.infinity,
|
||||
this.maximumOpacity = 1.0,
|
||||
this.height = 0,
|
||||
this.heightFalloff = 1,
|
||||
Vector3? linearColor = null,
|
||||
this.density = 0.1,
|
||||
this.inScatteringStart = 0,
|
||||
this.inScatteringSize = -1,
|
||||
this.fogColorFromIbl = false,
|
||||
this.skyColor = null}) {
|
||||
this.linearColor = linearColor ?? Vector3(1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
enum BlendMode { opaque, transparent }
|
||||
|
||||
///
|
||||
/// The viewport currently attached to a [View].
|
||||
///
|
||||
@@ -23,6 +52,10 @@ class Viewport {
|
||||
enum QualityLevel { LOW, MEDIUM, HIGH, ULTRA }
|
||||
|
||||
abstract class View {
|
||||
|
||||
/// Gets the scene currently associated with this View.
|
||||
///
|
||||
///
|
||||
Future<Scene> getScene();
|
||||
Future<Viewport> getViewport();
|
||||
Future setViewport(int width, int height);
|
||||
@@ -43,24 +76,26 @@ abstract class View {
|
||||
Future setBloom(bool enabled, double strength);
|
||||
Future setBlendMode(BlendMode blendMode);
|
||||
Future setRenderQuality(QualityLevel quality);
|
||||
|
||||
Future setLayerVisibility(VisibilityLayers layer, bool visible);
|
||||
|
||||
|
||||
|
||||
/// Sets the fog options for this view.
|
||||
/// Fog is disabled by default
|
||||
///
|
||||
Future setFogOptions(FogOptions options);
|
||||
|
||||
///
|
||||
/// Call [pick] to hit-test renderable entities at given viewport coordinates
|
||||
/// (or use one of the provided [InputHandler] classes which does this for you under the hood)
|
||||
///
|
||||
/// Call [pick] to hit-test renderable entities at given viewport coordinates
|
||||
/// (or use one of the provided [InputHandler] classes which does this for you under the hood)
|
||||
///
|
||||
/// Picking is an asynchronous operation that will usually take 2-3 frames to complete (so ensure you are calling render).
|
||||
///
|
||||
/// [x] and [y] must be in local logical coordinates (i.e. where 0,0 is at top-left of the viewport).
|
||||
///
|
||||
Future pick(int x, int y, void Function(PickResult) resultHandler);
|
||||
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future dispose();
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user