update tests
This commit is contained in:
@@ -4,9 +4,9 @@ import 'package:dart_filament/dart_filament/swift/swift_bindings.g.dart';
|
|||||||
import 'package:dart_filament/dart_filament/utils/dart_resources.dart';
|
import 'package:dart_filament/dart_filament/utils/dart_resources.dart';
|
||||||
import 'package:ffi/ffi.dart';
|
import 'package:ffi/ffi.dart';
|
||||||
import 'package:dart_filament/dart_filament.dart';
|
import 'package:dart_filament/dart_filament.dart';
|
||||||
import 'package:dart_filament/dart_filament/dart_filament.g.dart';
|
import 'package:dart_filament/dart_filament/compatibility/compatibility.dart';
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||||
|
|
||||||
/// Test files are run in a variety of ways, find this package root in all.
|
/// Test files are run in a variety of ways, find this package root in all.
|
||||||
///
|
///
|
||||||
@@ -47,28 +47,33 @@ extension on Uri {
|
|||||||
String get name => pathSegments.where((e) => e != '').last;
|
String get name => pathSegments.where((e) => e != '').last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
late String testDir;
|
||||||
void main() async {
|
void main() async {
|
||||||
final packageUri = findPackageRoot('dart_filament');
|
final packageUri = findPackageRoot('dart_filament');
|
||||||
var testDir = Directory("${packageUri.toFilePath()}/test").path;
|
testDir = Directory("${packageUri.toFilePath()}/test").path;
|
||||||
final lib = DartFilamentTexture1(DynamicLibrary.open(
|
final lib = DartFilamentTexture1(DynamicLibrary.open(
|
||||||
'${packageUri.toFilePath()}/native/lib/macos/swift/libdartfilamenttexture.dylib'));
|
'${packageUri.toFilePath()}/native/lib/macos/swift/libdartfilamenttexture.dylib'));
|
||||||
final object = DartFilamentTexture.new1(lib);
|
final object = DartFilamentTexture.new1(lib);
|
||||||
object.initWithWidth_height_(500, 500);
|
object.initWithWidth_height_(500, 500);
|
||||||
|
|
||||||
final resourceLoader = calloc<ResourceLoaderWrapper>(1);
|
final resourceLoader = calloc<ResourceLoaderWrapper>(1);
|
||||||
resourceLoader.ref.loadResource =
|
var loadToOut = NativeCallable<
|
||||||
Pointer.fromFunction(DartResourceLoader.loadResource);
|
Void Function(Pointer<Char>,
|
||||||
resourceLoader.ref.freeResource =
|
Pointer<ResourceBuffer>)>.listener(DartResourceLoader.loadResource);
|
||||||
Pointer.fromFunction(DartResourceLoader.freeResource);
|
|
||||||
|
|
||||||
var viewer = FilamentViewer(resourceLoader: resourceLoader);
|
resourceLoader.ref.loadToOut = loadToOut.nativeFunction;
|
||||||
|
var freeResource = NativeCallable<Void Function(ResourceBuffer)>.listener(
|
||||||
|
DartResourceLoader.freeResource);
|
||||||
|
resourceLoader.ref.freeResource = freeResource.nativeFunction;
|
||||||
|
|
||||||
|
var viewer = FilamentViewer(resourceLoader: resourceLoader.cast<Void>());
|
||||||
|
|
||||||
await viewer.initialized;
|
await viewer.initialized;
|
||||||
await viewer.createSwapChain(500, 500);
|
await viewer.createSwapChain(500, 500);
|
||||||
await viewer.createRenderTarget(500, 500, object.metalTextureAddress);
|
await viewer.createRenderTarget(500, 500, object.metalTextureAddress);
|
||||||
await viewer.updateViewportAndCameraProjection(500, 500);
|
await viewer.updateViewportAndCameraProjection(500, 500);
|
||||||
|
|
||||||
group('String', () {
|
group('background', () {
|
||||||
test('set background color', () async {
|
test('set background color', () async {
|
||||||
var outDir = Directory("$testDir/bgcolor");
|
var outDir = Directory("$testDir/bgcolor");
|
||||||
outDir.createSync();
|
outDir.createSync();
|
||||||
@@ -88,6 +93,24 @@ void main() async {
|
|||||||
await viewer.loadSkybox(
|
await viewer.loadSkybox(
|
||||||
"file:///$testDir/../../flutter_filament/example/assets/default_env/default_env_skybox.ktx");
|
"file:///$testDir/../../flutter_filament/example/assets/default_env/default_env_skybox.ktx");
|
||||||
await viewer.render();
|
await viewer.render();
|
||||||
|
await viewer.render();
|
||||||
|
await viewer.setRecording(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
group('animations', () {
|
||||||
|
test('get bone names', () async {
|
||||||
|
var model = await viewer.loadGlb("$testDir/assets/shapes.glb");
|
||||||
|
var names = await viewer.getBoneNames(model);
|
||||||
|
expect(names.first, "Bone");
|
||||||
|
});
|
||||||
|
test('set from BVH', () async {
|
||||||
|
var model = await viewer.loadGlb("$testDir/assets/shapes.glb");
|
||||||
|
var animation = BVHParser.parse(
|
||||||
|
File("$testDir/assets/animation.bvh").readAsStringSync(),
|
||||||
|
["Cylinder"],
|
||||||
|
boneRegex: RegExp(r"Bone$"));
|
||||||
|
await viewer.addBoneAnimation(model, animation);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user