test fixes
This commit is contained in:
@@ -2,28 +2,46 @@ import 'dart:async';
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
import 'package:thermion_dart/src/viewer/src/ffi/src/callbacks.dart';
|
||||||
|
import 'package:thermion_dart/src/viewer/src/ffi/src/ffi_asset.dart';
|
||||||
|
import 'package:thermion_dart/src/viewer/src/ffi/src/thermion_viewer_ffi.dart';
|
||||||
|
import 'package:thermion_dart/thermion_dart.dart';
|
||||||
import 'helpers.dart';
|
import 'helpers.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
final testHelper = TestHelper("animation");
|
final testHelper = TestHelper("animation");
|
||||||
|
await testHelper.setup();
|
||||||
group('morph animation tests', () {
|
group('morph animation tests', () {
|
||||||
test('set morph animation', () async {
|
test('retrieve morph target names', () async {
|
||||||
await testHelper.withViewer((viewer) async {
|
await testHelper.withViewer((viewer) async {
|
||||||
final cube = await viewer.loadGlb(
|
final cube = await viewer.loadGltf(
|
||||||
"${testHelper.testDir}/assets/cube_with_morph_targets.glb");
|
"${testHelper.testDir}/assets/cube_with_morph_targets.glb");
|
||||||
var morphData = MorphAnimationData(
|
final childEntities = await cube.getChildEntities();
|
||||||
Float32List.fromList(List<double>.generate(60, (i) => i / 60)),
|
var morphTargets =
|
||||||
["Key 1"]);
|
await cube.getMorphTargetNames(entity: childEntities.first);
|
||||||
|
expect(morphTargets.length, 1);
|
||||||
await viewer.setMorphAnimationData(cube, morphData);
|
expect(morphTargets.first, "Key 1");
|
||||||
for (int i = 0; i < 60; i++) {
|
|
||||||
await viewer.requestFrame();
|
|
||||||
await Future.delayed(Duration(milliseconds: 17));
|
|
||||||
}
|
|
||||||
|
|
||||||
await testHelper.capture(viewer, "morph_animation");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('set morph target weights', () async {
|
||||||
|
await testHelper.withViewer((viewer) async {
|
||||||
|
final cube = await viewer.loadGltf(
|
||||||
|
"${testHelper.testDir}/assets/cube_with_morph_targets.glb");
|
||||||
|
print(await cube.getChildEntityNames());
|
||||||
|
await viewer.addToScene(cube);
|
||||||
|
await testHelper.capture(viewer.view, "cube_no_morph");
|
||||||
|
|
||||||
|
final childEntities = await cube.getChildEntities();
|
||||||
|
|
||||||
|
var morphData = MorphAnimationData(
|
||||||
|
Float32List.fromList([1.0]), ["Key 1"],
|
||||||
|
frameLengthInMs: 1000.0 / 60.0);
|
||||||
|
await cube.addAnimationComponent(childEntities.first);
|
||||||
|
await cube.setMorphAnimationData(morphData);
|
||||||
|
await viewer.render();
|
||||||
|
await testHelper.capture(viewer.view, "cube_with_morph");
|
||||||
|
}, bg: kRed);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
// just for investigating crashes on GitHub actions
|
|
||||||
import 'package:test/test.dart';
|
|
||||||
|
|
||||||
import 'helpers.dart';
|
|
||||||
|
|
||||||
void main() async {
|
|
||||||
group("test", () {
|
|
||||||
test("test", () async {
|
|
||||||
print("Creating test helper");
|
|
||||||
final testHelper = TestHelper("dummy");
|
|
||||||
var viewer = await testHelper.createViewer();
|
|
||||||
|
|
||||||
expect(1, 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
import 'dart:ffi';
|
|
||||||
import 'package:test/test.dart';
|
|
||||||
|
|
||||||
import 'helpers.dart';
|
|
||||||
|
|
||||||
void main() async {
|
|
||||||
final testHelper = TestHelper("render_thread");
|
|
||||||
group("render thread/capture", () {
|
|
||||||
test("request frame on render thread", () async {
|
|
||||||
var viewer = await testHelper.createViewer();
|
|
||||||
await viewer.setBackgroundColor(1.0, 0.0, 0.0, 1.0);
|
|
||||||
|
|
||||||
var texture = await testHelper.createTexture(500, 500);
|
|
||||||
var renderTarget = await viewer.createRenderTarget(
|
|
||||||
500, 500, texture.metalTextureAddress);
|
|
||||||
|
|
||||||
final view = await viewer.getViewAt(0);
|
|
||||||
await view.setRenderTarget(renderTarget);
|
|
||||||
|
|
||||||
await viewer.render();
|
|
||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 1));
|
|
||||||
|
|
||||||
var data = texture.getTextureBytes()!;
|
|
||||||
var pixels = data.bytes.cast<Uint8>().asTypedList(data.length);
|
|
||||||
|
|
||||||
savePixelBufferToBmp(
|
|
||||||
pixels, 500, 500, "${testHelper.testDir}/request_frame.bmp");
|
|
||||||
await viewer.dispose();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import 'package:test/test.dart';
|
|
||||||
|
|
||||||
import 'helpers.dart';
|
|
||||||
|
|
||||||
void main() async {
|
|
||||||
final testHelper = TestHelper("integration");
|
|
||||||
|
|
||||||
group("skybox", () {
|
|
||||||
test('load skybox', () async {
|
|
||||||
var viewer = await testHelper.createViewer();
|
|
||||||
await viewer.loadSkybox(
|
|
||||||
"file://${testHelper.testDir}/assets/default_env_skybox.ktx");
|
|
||||||
await testHelper.capture(viewer, "load_skybox");
|
|
||||||
await viewer.removeSkybox();
|
|
||||||
await testHelper.capture(viewer, "remove_skybox");
|
|
||||||
await viewer.dispose();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user