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

View File

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

View File

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

View File

@@ -8,5 +8,5 @@ _OUTLINE_PACKAGE:
_OUTLINE_OUTLINE_OFFSET: _OUTLINE_OUTLINE_OFFSET:
.int 0 .int 0
_OUTLINE_OUTLINE_SIZE: _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 { test('render two views, change material instance in between', () async {
final viewportDimensions = (width: 500, height: 500); final viewportDimensions = (width: 500, height: 500);
final swapChain = await FilamentApp.instance!.createHeadlessSwapChain( final swapChain = await FilamentApp.instance!.createHeadlessSwapChain(
@@ -402,24 +412,24 @@ void main() async {
test('show/hide stencil highlight', () async { test('show/hide stencil highlight', () async {
await testHelper.withViewer((viewer) async { await testHelper.withViewer((viewer) async {
var cube = await FilamentApp.instance! var cube = await FilamentApp.instance!
.createGeometry(GeometryHelper.cube(flipUvs: true), nullptr); .createGeometry(GeometryHelper.cube(flipUvs: true), nullptr);
await viewer.addToScene(cube); await viewer.addToScene(cube);
await viewer.view.setStencilHighlight(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 FilamentApp.instance!.requestFrame();
await testHelper.capture( await testHelper.capture(null, "stencil_highlight_enabled",
null, "stencil_highlight_enabled", render:false); render: false);
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 viewer.view.removeStencilHighlight(cube); await viewer.view.removeStencilHighlight(cube);
await FilamentApp.instance!.requestFrame(); await FilamentApp.instance!.requestFrame();
await testHelper.capture(null, "stencil_highlight_removed",
await testHelper.capture( render: false);
null, "stencil_highlight_removed", render:false);
}, postProcessing: false); }, postProcessing: false);
}); });
} }