feat: expose setLightDirection and setLightPosition
This commit is contained in:
@@ -183,6 +183,28 @@ external void clear_lights(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<ffi.Void>, EntityId, ffi.Float, ffi.Float, ffi.Float)>()
|
||||
external void set_light_position(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
int light,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<ffi.Void>, EntityId, ffi.Float, ffi.Float, ffi.Float)>()
|
||||
external void set_light_direction(
|
||||
ffi.Pointer<ffi.Void> viewer,
|
||||
int light,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
EntityId Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, ffi.Int)>()
|
||||
external int load_glb(
|
||||
|
||||
@@ -2256,4 +2256,28 @@ class ThermionViewerWasm implements ThermionViewer {
|
||||
[_sceneManager!, visible.toJS].toJS,
|
||||
null);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setLightDirection(ThermionEntity lightEntity, Vector3 direction) async {
|
||||
direction.normalize();
|
||||
_module!.ccall(
|
||||
"set_light_direction",
|
||||
"void",
|
||||
["void*".toJS, "double".toJS, "double".toJS, "double".toJS].toJS,
|
||||
[_viewer!, direction.x.toJS, direction.y.toJS, direction.z.toJS]
|
||||
.toJS,
|
||||
null);
|
||||
}
|
||||
|
||||
@override
|
||||
Future setLightPosition(
|
||||
ThermionEntity lightEntity, double x, double y, double z) async {
|
||||
_module!.ccall(
|
||||
"set_light_position",
|
||||
"void",
|
||||
["void*".toJS, "double".toJS, "double".toJS, "double".toJS].toJS,
|
||||
[_viewer!, x.toJS,y.toJS,z.toJS]
|
||||
.toJS,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,10 +570,20 @@ abstract class ThermionViewer {
|
||||
Future transformToUnitCube(ThermionEntity entity);
|
||||
|
||||
///
|
||||
/// Directly sets the world space position for [entity] to the given coordinates, skipping all collision detection.
|
||||
/// Directly sets the world space position for [entity] to the given coordinates.
|
||||
///
|
||||
Future setPosition(ThermionEntity entity, double x, double y, double z);
|
||||
|
||||
///
|
||||
/// Set the world space position for [lightEntity] to the given coordinates.
|
||||
///
|
||||
Future setLightPosition(ThermionEntity lightEntity, double x, double y, double z);
|
||||
|
||||
///
|
||||
/// Sets the world space direction for [lightEntity] to the given vector.
|
||||
///
|
||||
Future setLightDirection(ThermionEntity lightEntity, Vector3 direction);
|
||||
|
||||
///
|
||||
/// Directly sets the scale for [entity], skipping all collision detection.
|
||||
///
|
||||
|
||||
@@ -1287,6 +1287,24 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
set_position(_sceneManager!, entity, x, y, z);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@override
|
||||
Future setLightPosition(
|
||||
ThermionEntity lightEntity, double x, double y, double z) async {
|
||||
set_light_position(_viewer!, lightEntity, x, y, z);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
@override
|
||||
Future setLightDirection(ThermionEntity lightEntity, Vector3 direction) async {
|
||||
direction.normalize();
|
||||
set_light_direction(_viewer!, lightEntity, direction.x, direction.y, direction.z);
|
||||
}
|
||||
|
||||
///
|
||||
///
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user