add scale parameter to outline material

This commit is contained in:
Nick Fisher
2025-07-01 14:28:19 +08:00
parent f9a7ac49a1
commit e731556e6f
7 changed files with 5187 additions and 5060 deletions

View File

@@ -276,6 +276,7 @@ class FFIView extends View<Pointer<TView>> {
double g = 0.0,
double b = 0.0,
int? entity,
double scale = 1.05,
int primitiveIndex = 0}) async {
entity ??= asset.entity;
@@ -297,6 +298,7 @@ class FFIView extends View<Pointer<TView>> {
}
var highlightMaterialInstance = await highlightMaterial!.createInstance();
await highlightMaterialInstance.setParameterFloat("scale", scale);
await highlightMaterialInstance.setDepthCullingEnabled(true);
await highlightMaterialInstance.setDepthWriteEnabled(true);

View File

@@ -101,6 +101,7 @@ abstract class View<T> extends NativeHandle<T> {
double g = 0.0,
double b = 0.0,
int? entity,
double scale = 1.05,
int primitiveIndex = 0});
/// Removes the outline around [entity]. Noop if there was no highlight.

View File

@@ -8,5 +8,5 @@ OUTLINE_PACKAGE:
OUTLINE_OUTLINE_OFFSET:
.int 0
OUTLINE_OUTLINE_SIZE:
.int 112782
.int 115064

View File

@@ -8,5 +8,5 @@ _OUTLINE_PACKAGE:
_OUTLINE_OUTLINE_OFFSET:
.int 0
_OUTLINE_OUTLINE_SIZE:
.int 112782
.int 115064

File diff suppressed because it is too large Load Diff

View File

@@ -28,6 +28,16 @@ void main() async {
});
});
test('toggle transparent picking', () async {
await testHelper.withViewer((viewer) async {
expect(await viewer.view.isTransparentPickingEnabled(), false);
await viewer.view.setTransparentPickingEnabled(true);
expect(await viewer.view.isTransparentPickingEnabled(), true);
await viewer.view.setTransparentPickingEnabled(false);
expect(await viewer.view.isTransparentPickingEnabled(), false);
});
});
test('render two views, change material instance in between', () async {
final viewportDimensions = (width: 500, height: 500);
final swapChain = await FilamentApp.instance!.createHeadlessSwapChain(
@@ -402,24 +412,24 @@ void main() async {
test('show/hide stencil highlight', () async {
await testHelper.withViewer((viewer) async {
var cube = await FilamentApp.instance!
.createGeometry(GeometryHelper.cube(flipUvs: true), nullptr);
await viewer.addToScene(cube);
await viewer.view.setStencilHighlight(cube);
await FilamentApp.instance!.setClearOptions(1, 1, 1, 0, clear: true, discard: false);
await FilamentApp.instance!
.setClearOptions(1, 1, 1, 0, clear: true, discard: false);
await FilamentApp.instance!.requestFrame();
await testHelper.capture(
null, "stencil_highlight_enabled", render:false);
await FilamentApp.instance!.setClearOptions(1, 1, 1, 0, clear: true, discard: false);
await testHelper.capture(null, "stencil_highlight_enabled",
render: false);
await FilamentApp.instance!
.setClearOptions(1, 1, 1, 0, clear: true, discard: false);
await viewer.view.removeStencilHighlight(cube);
await FilamentApp.instance!.requestFrame();
await testHelper.capture(
null, "stencil_highlight_removed", render:false);
await testHelper.capture(null, "stencil_highlight_removed",
render: false);
}, postProcessing: false);
});
}