expose View methods for transparent picking

This commit is contained in:
Nick Fisher
2025-07-01 14:20:02 +08:00
parent 83e4a5142a
commit f9a7ac49a1
6 changed files with 56 additions and 0 deletions

View File

@@ -571,6 +571,17 @@ external void View_setFogOptions(
TFogOptions tFogOptions,
);
@ffi.Native<ffi.Void Function(ffi.Pointer<TView>, ffi.Bool)>(isLeaf: true)
external void View_setTransparentPickingEnabled(
ffi.Pointer<TView> tView,
bool enabled,
);
@ffi.Native<ffi.Bool Function(ffi.Pointer<TView>)>(isLeaf: true)
external bool View_isTransparentPickingEnabled(
ffi.Pointer<TView> tView,
);
@ffi.Native<
ffi.Void Function(ffi.Pointer<TView>, ffi.Uint32, ffi.Uint32, ffi.Uint32,
PickCallback)>(isLeaf: true)

View File

@@ -720,6 +720,13 @@ extension type NativeLibrary(JSObject _) implements JSObject {
Pointer<TView> tView,
Pointer<TFogOptions> tFogOptionsPtr,
);
external void _View_setTransparentPickingEnabled(
Pointer<TView> tView,
bool enabled,
);
external int _View_isTransparentPickingEnabled(
Pointer<TView> tView,
);
external void _View_pick(
Pointer<TView> tView,
int requestId,
@@ -3008,6 +3015,21 @@ void View_setFogOptions(
return result;
}
void View_setTransparentPickingEnabled(
self.Pointer<TView> tView,
bool enabled,
) {
final result = _lib._View_setTransparentPickingEnabled(tView.cast(), enabled);
return result;
}
bool View_isTransparentPickingEnabled(
self.Pointer<TView> tView,
) {
final result = _lib._View_isTransparentPickingEnabled(tView.cast());
return result == 1;
}
void View_pick(
self.Pointer<TView> tView,
int requestId,

View File

@@ -335,4 +335,12 @@ class FFIView extends View<Pointer<TView>> {
void setName(String name) {
View_setName(getNativeHandle(), name.toNativeUtf8().cast());
}
Future setTransparentPickingEnabled(bool enabled) async {
View_setTransparentPickingEnabled(getNativeHandle(), enabled);
}
Future<bool> isTransparentPickingEnabled() async {
return View_isTransparentPickingEnabled(getNativeHandle());
}
}

View File

@@ -92,6 +92,9 @@ abstract class View<T> extends NativeHandle<T> {
Future setShadowsEnabled(bool enabled);
Future setLayerVisibility(VisibilityLayers layer, bool visible);
Future setTransparentPickingEnabled(bool enabled);
Future<bool> isTransparentPickingEnabled();
/// Renders an outline around [entity] with the given color.
Future setStencilHighlight(ThermionAsset asset,
{double r = 1.0,