This commit is contained in:
Nick Fisher
2023-04-18 14:17:05 +08:00
parent 67ac8990b8
commit 8298e473c2
13 changed files with 431 additions and 175 deletions

View File

@@ -1,12 +1,12 @@
import 'dart:async';
import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/services.dart';
import 'animations/animation_builder.dart';
import 'animations/animations.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
// this is confusing - "FilamentAsset" actually defines a pointer to a SceneAsset, whereas FilamentLight is an Entity ID.
// should make this consistent
typedef FilamentAsset = int;
@@ -26,11 +26,12 @@ abstract class FilamentController {
void setPixelRatio(double ratio);
Future resize(int width, int height, {double contentScaleFactor = 1});
Future setBackgroundColor(Color color);
Future clearBackgroundImage();
Future setBackgroundImage(String path);
Future setBackgroundImagePosition(double x, double y, {bool clamp = false});
Future loadSkybox(String skyboxPath);
Future removeSkybox();
Future loadIbl(String path);
Future loadIbl(String path, {double intensity = 30000});
Future removeIbl();
// copied from LightManager.h
@@ -54,7 +55,7 @@ abstract class FilamentController {
bool castShadows);
Future removeLight(FilamentLight light);
Future clearLights();
Future<FilamentAsset> loadGlb(String path);
Future<FilamentAsset> loadGlb(String path, {bool unlit = false});
Future<FilamentAsset> loadGltf(String path, String relativeResourcePath);
Future zoomBegin();
Future zoomUpdate(double z);
@@ -172,6 +173,11 @@ class PolyvoxFilamentController extends FilamentController {
_textureIdController.add(_textureId);
}
@override
Future clearBackgroundImage() async {
await _channel.invokeMethod("clearBackgroundImage");
}
@override
Future setBackgroundImage(String path) async {
await _channel.invokeMethod("setBackgroundImage", path);
@@ -179,15 +185,12 @@ class PolyvoxFilamentController extends FilamentController {
@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
]));
await _channel.invokeMethod("setBackgroundColor", [
color.red.toDouble() / 255.0,
color.green.toDouble() / 255.0,
color.blue.toDouble() / 255.0,
color.alpha.toDouble() / 255.0
]);
}
@override
@@ -253,9 +256,9 @@ class PolyvoxFilamentController extends FilamentController {
return _channel.invokeMethod("clearLights");
}
Future<FilamentAsset> loadGlb(String path) async {
Future<FilamentAsset> loadGlb(String path, {bool unlit = false}) async {
print("Loading GLB at $path ");
var asset = await _channel.invokeMethod("loadGlb", path);
var asset = await _channel.invokeMethod("loadGlb", [path, unlit]);
if (asset == FILAMENT_ASSET_ERROR) {
throw Exception("An error occurred loading the asset at $path");
}