diff --git a/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_export_type.dart b/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_export_type.dart index 7d335e4c..8749b690 100644 --- a/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_export_type.dart +++ b/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_export_type.dart @@ -88,10 +88,31 @@ class DartFilamentJSExportViewer { double dirX, double dirY, double dirZ, + double falloffRadius, + double spotLightConeInner, + double spotLightConeOuter, + double sunAngularRadius, + double sunHaloSize, + double sunHaloFallof, bool castShadows) { return viewer - .addLight(type, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, - castShadows) + .addLight( + LightType.values[type], + colour, + intensity, + posX, + posY, + posZ, + dirX, + dirY, + dirZ, + falloffRadius:falloffRadius, + spotLightConeInner:spotLightConeInner, + spotLightConeOuter: spotLightConeOuter, + sunAngularRadius: sunAngularRadius, + sunHaloSize: sunHaloSize, + sunHaloFallof: sunHaloFallof, + castShadows: castShadows) .then((entity) => entity.toJS) .toJS; } diff --git a/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_extension_type.dart b/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_extension_type.dart index 5daa72c9..2a7ce79a 100644 --- a/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_extension_type.dart +++ b/dart_filament/lib/dart_filament/compatibility/web/interop/dart_filament_js_extension_type.dart @@ -63,7 +63,13 @@ extension type DartFilamentJSShim(JSObject _) implements JSObject { double dirX, double dirY, double dirZ, - bool castShadows, + double falloffRadius, + double spotLightConeInner, + double spotLightConeOuter, + double sunAngularRadius, + double sunHaloSize, + double sunHaloFallof, + bool castShadows ); @JS('removeLight') diff --git a/dart_filament/lib/dart_filament/compatibility/web/interop/js_interop_filament_viewer.dart b/dart_filament/lib/dart_filament/compatibility/web/interop/js_interop_filament_viewer.dart index b54dfb06..14bb7dd5 100644 --- a/dart_filament/lib/dart_filament/compatibility/web/interop/js_interop_filament_viewer.dart +++ b/dart_filament/lib/dart_filament/compatibility/web/interop/js_interop_filament_viewer.dart @@ -1,5 +1,6 @@ import 'dart:js_interop'; import 'dart:js_interop_unsafe'; +import 'dart:math'; import 'package:animation_tools_dart/animation_tools_dart.dart'; import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart'; @@ -103,7 +104,7 @@ class JsInteropFilamentViewer implements AbstractFilamentViewer { @override Future addLight( - int type, + LightType type, double colour, double intensity, double posX, @@ -112,10 +113,18 @@ class JsInteropFilamentViewer implements AbstractFilamentViewer { double dirX, double dirY, double dirZ, - bool castShadows) async { + { + double falloffRadius=1.0, + double spotLightConeInner=pi/8, + double spotLightConeOuter=pi/4, + double sunAngularRadius=0.545, + double sunHaloSize=10.0, + double sunHaloFallof=80.0, + bool castShadows=true + }) async { return (await _jsObject - .addLight(type, colour, intensity, posX, posY, posZ, dirX, dirY, - dirZ, castShadows) + .addLight(type.index, colour, intensity, posX, posY, posZ, dirX, dirY, + dirZ, falloffRadius, spotLightConeInner, spotLightConeOuter, sunAngularRadius, sunHaloSize, sunHaloFallof, castShadows) .toDart) .toDartInt; } diff --git a/dart_filament/lib/dart_filament/filament_viewer_impl.dart b/dart_filament/lib/dart_filament/filament_viewer_impl.dart index d494e66a..cf33f4fc 100644 --- a/dart_filament/lib/dart_filament/filament_viewer_impl.dart +++ b/dart_filament/lib/dart_filament/filament_viewer_impl.dart @@ -125,10 +125,10 @@ class FilamentViewer extends AbstractFilamentViewer { await setCameraManipulatorOptions(zoomSpeed: 10.0); - final out = calloc(3); + final out = allocator(3); get_gizmo(_sceneManager!, out); _gizmo = Gizmo(out[0], out[1], out[2], this); - calloc.free(out); + allocator.free(out); this._initialized.complete(true); }