don't allow creating instances for GridOverlay asset and only expose a single entity
This commit is contained in:
@@ -12,16 +12,39 @@ class GridOverlay extends FFIAsset {
|
||||
static Future<GridOverlay> create(
|
||||
FFIFilamentApp app, Pointer<TAnimationManager> animationManager) async {
|
||||
if (_overlay == null) {
|
||||
_gridMaterial ??= FFIMaterial(Material_createGridMaterial(app.engine), app);
|
||||
|
||||
_gridMaterial ??=
|
||||
FFIMaterial(Material_createGridMaterial(app.engine), app);
|
||||
|
||||
final asset = await withPointerCallback<TSceneAsset>((cb) =>
|
||||
SceneAsset_createGridRenderThread(
|
||||
app.engine, _gridMaterial!.getNativeHandle(), cb));
|
||||
|
||||
_overlay = GridOverlay(asset, app, animationManager);
|
||||
var materialInstance = await _overlay!.getMaterialInstanceAt();
|
||||
await materialInstance.setParameterFloat3("gridColor", 0.1, 0.1, 0.1);
|
||||
await materialInstance
|
||||
.setTransparencyMode(TransparencyMode.TWO_PASSES_TWO_SIDES);
|
||||
await materialInstance.setCullingMode(CullingMode.NONE);
|
||||
|
||||
await materialInstance.setParameterFloat3("gridColor", 0.3, 0.35, 0.3);
|
||||
|
||||
final ffiAsset =
|
||||
FFIAsset(asset, FilamentApp.instance as FFIFilamentApp, nullptr);
|
||||
await FilamentApp.instance!.setPriority(ffiAsset.entity, 0);
|
||||
for (final child in await ffiAsset.getChildEntities()) {
|
||||
await FilamentApp.instance!.setPriority(child, 7);
|
||||
}
|
||||
// await materialInstance.setParameterFloat("distance", 10.0);
|
||||
}
|
||||
return _overlay!;
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@override
|
||||
Future<FFIAsset> createInstance(
|
||||
{List<MaterialInstance>? materialInstances = null}) async {
|
||||
throw Exception(
|
||||
"Only a single instance of the grid overlay can be created");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,10 @@ public:
|
||||
MaterialInstance** getMaterialInstances() override { return &_materialInstance; }
|
||||
size_t getMaterialInstanceCount() override { return 1; }
|
||||
|
||||
utils::Entity getEntity() override {
|
||||
return _gridEntity;
|
||||
}
|
||||
|
||||
void addAllEntities(Scene* scene) override;
|
||||
void removeAllEntities(Scene* scene) override;
|
||||
|
||||
|
||||
@@ -209,10 +209,7 @@ namespace thermion
|
||||
|
||||
SceneAsset *GridOverlay::createInstance(MaterialInstance **materialInstances, size_t materialInstanceCount)
|
||||
{
|
||||
auto instance = std::make_unique<GridOverlay>(_engine, _material);
|
||||
auto *raw = instance.get();
|
||||
_instances.push_back(std::move(instance));
|
||||
return reinterpret_cast<SceneAsset *>(raw);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GridOverlay::addAllEntities(Scene *scene)
|
||||
@@ -250,7 +247,7 @@ namespace thermion
|
||||
}
|
||||
|
||||
size_t GridOverlay::getChildEntityCount() {
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Entity GridOverlay::findEntityByName(const char *name)
|
||||
|
||||
Reference in New Issue
Block a user