add createLight method to FilamentApp
This commit is contained in:
@@ -1036,6 +1036,32 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
|
|||||||
return FFIAsset(assetPtr, this, animationManager.cast<TAnimationManager>());
|
return FFIAsset(assetPtr, this, animationManager.cast<TAnimationManager>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
Future<ThermionEntity> createDirectLight(DirectLight directLight) async {
|
||||||
|
var entity =
|
||||||
|
LightManager_createLight(engine, lightManager, directLight.type.index);
|
||||||
|
if (entity == FILAMENT_ASSET_ERROR) {
|
||||||
|
throw Exception("Failed to add light to scene");
|
||||||
|
}
|
||||||
|
|
||||||
|
LightManager_setColor(lightManager, entity, directLight.color);
|
||||||
|
LightManager_setIntensity(lightManager, entity, directLight.intensity);
|
||||||
|
LightManager_setPosition(lightManager, entity, directLight.position.x,
|
||||||
|
directLight.position.y, directLight.position.z);
|
||||||
|
LightManager_setDirection(lightManager, entity, directLight.direction.x,
|
||||||
|
directLight.direction.y, directLight.direction.z);
|
||||||
|
LightManager_setFalloff(lightManager, entity, directLight.falloffRadius);
|
||||||
|
LightManager_setSpotLightCone(lightManager, entity,
|
||||||
|
directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
||||||
|
// LightManager_setSunAngularRadius(lightManager, entity, directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
||||||
|
// LightManager_setSunHaloSize(lightManager, entity, directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
||||||
|
// LightManager_setSunHaloFalloff(lightManager, entity, directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
||||||
|
LightManager_setShadowCaster(lightManager, entity, directLight.castShadows);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -306,6 +306,11 @@ abstract class FilamentApp<T> {
|
|||||||
Future<ThermionAsset> createGeometry(Geometry geometry, T animationManager,
|
Future<ThermionAsset> createGeometry(Geometry geometry, T animationManager,
|
||||||
{List<MaterialInstance>? materialInstances, bool keepData = false});
|
{List<MaterialInstance>? materialInstances, bool keepData = false});
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
Future<ThermionEntity> createDirectLight(DirectLight directLight);
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -318,32 +318,13 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> addDirectLight(DirectLight directLight) async {
|
Future<ThermionEntity> addDirectLight(DirectLight directLight) async {
|
||||||
var entity = LightManager_createLight(
|
var light = await FilamentApp.instance!.createDirectLight(directLight);
|
||||||
app.engine, app.lightManager, directLight.type.index);
|
|
||||||
if (entity == FILAMENT_ASSET_ERROR) {
|
|
||||||
throw Exception("Failed to add light to scene");
|
|
||||||
}
|
|
||||||
LightManager_setColor(app.lightManager, entity, directLight.color);
|
|
||||||
LightManager_setIntensity(app.lightManager, entity, directLight.intensity);
|
|
||||||
LightManager_setPosition(app.lightManager, entity, directLight.position.x,
|
|
||||||
directLight.position.y, directLight.position.z);
|
|
||||||
LightManager_setDirection(app.lightManager, entity, directLight.direction.x,
|
|
||||||
directLight.direction.y, directLight.direction.z);
|
|
||||||
LightManager_setFalloff(
|
|
||||||
app.lightManager, entity, directLight.falloffRadius);
|
|
||||||
LightManager_setSpotLightCone(app.lightManager, entity,
|
|
||||||
directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
|
||||||
// LightManager_setSunAngularRadius(app.lightManager, entity, directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
|
||||||
// LightManager_setSunHaloSize(app.lightManager, entity, directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
|
||||||
// LightManager_setSunHaloFalloff(app.lightManager, entity, directLight.spotLightConeInner, directLight.spotLightConeOuter);
|
|
||||||
LightManager_setShadowCaster(
|
|
||||||
app.lightManager, entity, directLight.castShadows);
|
|
||||||
|
|
||||||
Scene_addEntity(scene.scene, entity);
|
await scene.addEntity(light);
|
||||||
|
|
||||||
_lights.add(entity);
|
_lights.add(light);
|
||||||
|
|
||||||
return entity;
|
return light;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
Reference in New Issue
Block a user