fixes
This commit is contained in:
@@ -15,7 +15,7 @@ const FilamentAsset FILAMENT_ASSET_ERROR = 0;
|
|||||||
|
|
||||||
abstract class FilamentController {
|
abstract class FilamentController {
|
||||||
Size get size;
|
Size get size;
|
||||||
late Stream<int> textureId;
|
late Stream<int?> textureId;
|
||||||
Future get initialized;
|
Future get initialized;
|
||||||
Stream get onInitializationRequested;
|
Stream get onInitializationRequested;
|
||||||
Future initialize();
|
Future initialize();
|
||||||
@@ -25,6 +25,7 @@ abstract class FilamentController {
|
|||||||
Future render();
|
Future render();
|
||||||
void setPixelRatio(double ratio);
|
void setPixelRatio(double ratio);
|
||||||
Future resize(int width, int height, {double contentScaleFactor = 1});
|
Future resize(int width, int height, {double contentScaleFactor = 1});
|
||||||
|
Future setBackgroundColor(Color color);
|
||||||
Future setBackgroundImage(String path);
|
Future setBackgroundImage(String path);
|
||||||
Future setBackgroundImagePosition(double x, double y, {bool clamp = false});
|
Future setBackgroundImagePosition(double x, double y, {bool clamp = false});
|
||||||
Future loadSkybox(String skyboxPath);
|
Future loadSkybox(String skyboxPath);
|
||||||
@@ -87,6 +88,8 @@ abstract class FilamentController {
|
|||||||
// Future setBoneTransform(FilamentAsset asset, String boneName, String meshName,
|
// Future setBoneTransform(FilamentAsset asset, String boneName, String meshName,
|
||||||
// BoneTransform transform);
|
// BoneTransform transform);
|
||||||
Future setScale(FilamentAsset asset, double scale);
|
Future setScale(FilamentAsset asset, double scale);
|
||||||
|
Future setCameraExposure(
|
||||||
|
double aperture, double shutterSpeed, double sensitivity);
|
||||||
Future setCameraFocalLength(double focalLength);
|
Future setCameraFocalLength(double focalLength);
|
||||||
Future setCameraFocusDistance(double focusDistance);
|
Future setCameraFocusDistance(double focusDistance);
|
||||||
Future setCameraPosition(double x, double y, double z);
|
Future setCameraPosition(double x, double y, double z);
|
||||||
@@ -107,8 +110,9 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
double _pixelRatio = 1.0;
|
double _pixelRatio = 1.0;
|
||||||
Size size = Size(0, 0);
|
Size size = Size(0, 0);
|
||||||
|
|
||||||
final _textureIdController = StreamController<int>();
|
int? _textureId;
|
||||||
Stream<int> get textureId => _textureIdController.stream;
|
final _textureIdController = StreamController<int?>.broadcast();
|
||||||
|
Stream<int?> get textureId => _textureIdController.stream;
|
||||||
|
|
||||||
final _onInitRequestedController = StreamController.broadcast();
|
final _onInitRequestedController = StreamController.broadcast();
|
||||||
Stream get onInitializationRequested => _onInitRequestedController.stream;
|
Stream get onInitializationRequested => _onInitRequestedController.stream;
|
||||||
@@ -121,6 +125,10 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
print("Received Filament method channel call : ${call.method}");
|
print("Received Filament method channel call : ${call.method}");
|
||||||
throw Exception("Unknown method channel invocation ${call.method}");
|
throw Exception("Unknown method channel invocation ${call.method}");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_textureIdController.onListen = () {
|
||||||
|
_textureIdController.add(_textureId);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Future initialize() async {
|
Future initialize() async {
|
||||||
@@ -148,9 +156,9 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
Future createTextureViewer(int width, int height) async {
|
Future createTextureViewer(int width, int height) async {
|
||||||
size = Size(width * _pixelRatio, height * _pixelRatio);
|
size = Size(width * _pixelRatio, height * _pixelRatio);
|
||||||
print("Creating texture of size $size");
|
print("Creating texture of size $size");
|
||||||
var textureId =
|
_textureId =
|
||||||
await _channel.invokeMethod("initialize", [size.width, size.height]);
|
await _channel.invokeMethod("initialize", [size.width, size.height]);
|
||||||
_textureIdController.add(textureId);
|
_textureIdController.add(_textureId);
|
||||||
_initialized.complete(true);
|
_initialized.complete(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,10 +166,10 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
{double contentScaleFactor = 1.0}) async {
|
{double contentScaleFactor = 1.0}) async {
|
||||||
size = Size(width * _pixelRatio, height * _pixelRatio);
|
size = Size(width * _pixelRatio, height * _pixelRatio);
|
||||||
|
|
||||||
var textureId = await _channel.invokeMethod("resize",
|
_textureId = await _channel.invokeMethod("resize",
|
||||||
[width * _pixelRatio, height * _pixelRatio, contentScaleFactor]);
|
[width * _pixelRatio, height * _pixelRatio, contentScaleFactor]);
|
||||||
print("Resized to $size with texutre Id $textureId");
|
print("Resized to $size with texutre Id $textureId");
|
||||||
_textureIdController.add(textureId);
|
_textureIdController.add(_textureId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -169,6 +177,19 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
await _channel.invokeMethod("setBackgroundImage", path);
|
await _channel.invokeMethod("setBackgroundImage", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future setBackgroundColor(Color color) async {
|
||||||
|
print(
|
||||||
|
"setting to ${color.red.toDouble() / 255.0} ${color.blue.toDouble() / 255.0} ${color.red.toDouble() / 255.0}");
|
||||||
|
await _channel.invokeMethod(
|
||||||
|
"setBackgroundColor",
|
||||||
|
Float32List.fromList([
|
||||||
|
color.red.toDouble() / 255.0,
|
||||||
|
color.green.toDouble() / 255.0,
|
||||||
|
color.blue.toDouble() / 255.0
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setBackgroundImagePosition(double x, double y,
|
Future setBackgroundImagePosition(double x, double y,
|
||||||
{bool clamp = false}) async {
|
{bool clamp = false}) async {
|
||||||
@@ -369,6 +390,12 @@ class PolyvoxFilamentController extends FilamentController {
|
|||||||
await _channel.invokeMethod("setCameraPosition", [x, y, z]);
|
await _channel.invokeMethod("setCameraPosition", [x, y, z]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future setCameraExposure(
|
||||||
|
double aperture, double shutterSpeed, double sensitivity) async {
|
||||||
|
await _channel.invokeMethod(
|
||||||
|
"setCameraExposure", [aperture, shutterSpeed, sensitivity]);
|
||||||
|
}
|
||||||
|
|
||||||
Future setCameraRotation(double rads, double x, double y, double z) async {
|
Future setCameraRotation(double rads, double x, double y, double z) async {
|
||||||
await _channel.invokeMethod("setCameraRotation", [rads, x, y, z]);
|
await _channel.invokeMethod("setCameraRotation", [rads, x, y, z]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user