fix: defer creating image entity/material/etc until actually requested
feat: expose shadow options
This commit is contained in:
@@ -796,6 +796,25 @@ external void set_post_processing(
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Bool)>()
|
||||
external void set_shadows_enabled(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
bool enabled,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Int)>()
|
||||
external void set_shadow_type(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
int shadowType,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float)>()
|
||||
external void set_soft_shadow_options(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
double penumbraScale,
|
||||
double penumbraRatioScale,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Bool, ffi.Bool, ffi.Bool)>()
|
||||
external void set_antialiasing(
|
||||
|
||||
@@ -19,6 +19,13 @@ enum LightType {
|
||||
SPOT,
|
||||
}
|
||||
|
||||
enum ShadowType {
|
||||
PCF, //!< percentage-closer filtered shadows (default)
|
||||
VSM, //!< variance shadows
|
||||
DPCF, //!< PCF with contact hardening simulation
|
||||
PCSS, //!< PCF with soft shadows and contact hardening
|
||||
}
|
||||
|
||||
// copied from filament/backened/DriverEnums.h
|
||||
enum PrimitiveType {
|
||||
// don't change the enums values (made to match GL)
|
||||
@@ -562,10 +569,25 @@ abstract class ThermionViewer {
|
||||
{bool relative = false});
|
||||
|
||||
///
|
||||
/// Enable/disable postprocessing.
|
||||
/// Enable/disable postprocessing (disabled by default).
|
||||
///
|
||||
Future setPostProcessing(bool enabled);
|
||||
|
||||
///
|
||||
/// Enable/disable shadows (disabled by default).
|
||||
///
|
||||
Future setShadowsEnabled(bool enabled);
|
||||
|
||||
///
|
||||
/// Set shadow type.
|
||||
///
|
||||
Future setShadowType(ShadowType shadowType);
|
||||
|
||||
///
|
||||
/// Set soft shadow options (ShadowType DPCF and PCSS)
|
||||
///
|
||||
Future setSoftShadowOptions(double penumbraScale, double penumbraRatioScale);
|
||||
|
||||
///
|
||||
/// Set antialiasing options.
|
||||
///
|
||||
@@ -707,6 +729,7 @@ abstract class ThermionViewer {
|
||||
/// Register a callback to be invoked when this viewer is disposed.
|
||||
///
|
||||
void onDispose(Future Function() callback);
|
||||
|
||||
}
|
||||
|
||||
abstract class AbstractGizmo {
|
||||
|
||||
@@ -198,6 +198,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
await callback.call();
|
||||
}
|
||||
_onDispose.clear();
|
||||
|
||||
}
|
||||
|
||||
///
|
||||
@@ -1063,6 +1064,29 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
set_post_processing_ffi(_viewer!, enabled);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@override
|
||||
Future setShadowsEnabled(bool enabled) async {
|
||||
set_shadows_enabled(_viewer!, enabled);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setShadowType(ShadowType shadowType) async {
|
||||
set_shadow_type(_viewer!, shadowType.index);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
Future setSoftShadowOptions(
|
||||
double penumbraScale, double penumbraRatioScale) async {
|
||||
set_soft_shadow_options(_viewer!, penumbraScale, penumbraRatioScale);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@@ -1564,8 +1588,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
// ignore: sdk_version_since
|
||||
|
||||
if (callback != null) {
|
||||
var ptr = NativeCallable<
|
||||
Void Function(Int entityId1, Int entityId2)>.listener(callback);
|
||||
var ptr =
|
||||
NativeCallable<Void Function(Int entityId1, Int entityId2)>.listener(
|
||||
callback);
|
||||
add_collision_component(
|
||||
_sceneManager!, entity, ptr.nativeFunction, affectsTransform);
|
||||
_collisions[entity] = ptr;
|
||||
|
||||
@@ -726,4 +726,22 @@ class ThermionViewerStub extends ThermionViewer {
|
||||
// TODO: implement zoomUpdate
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setShadowType(ShadowType shadowType) {
|
||||
// TODO: implement setShadowType
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setShadowsEnabled(bool enabled) {
|
||||
// TODO: implement setShadowsEnabled
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setSoftShadowOptions(double penumbraScale, double penumbraRatioScale) {
|
||||
// TODO: implement setSoftShadowOptions
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user