diff --git a/example/assets/cube.bin b/example/assets/cube.bin index ff00a72c..706fd59c 100644 Binary files a/example/assets/cube.bin and b/example/assets/cube.bin differ diff --git a/example/assets/cube.gltf b/example/assets/cube.gltf index 6ba696b9..93c0108e 100644 --- a/example/assets/cube.gltf +++ b/example/assets/cube.gltf @@ -44,15 +44,15 @@ ], "name" : "Camera", "rotation" : [ - 0.5797627568244934, - 0.0033576595596969128, - -0.013425502926111221, - 0.8146679401397705 + 0.5715538859367371, + 0, + 0, + 0.8205645084381104 ], "translation" : [ 0, 6.8069868087768555, - 10.594138145446777 + 10.164137840270996 ] } ], @@ -68,6 +68,27 @@ "type" : "perspective" } ], + "animations" : [ + { + "channels" : [ + { + "sampler" : 0, + "target" : { + "node" : 0, + "path" : "translation" + } + } + ], + "name" : "FloatUp", + "samplers" : [ + { + "input" : 36, + "interpolation" : "LINEAR", + "output" : 37 + } + ] + } + ], "materials" : [ { "doubleSided" : true, @@ -589,6 +610,24 @@ "componentType" : 5126, "count" : 148, "type" : "VEC3" + }, + { + "bufferView" : 36, + "componentType" : 5126, + "count" : 60, + "max" : [ + 2.5 + ], + "min" : [ + 0.041666666666666664 + ], + "type" : "SCALAR" + }, + { + "bufferView" : 37, + "componentType" : 5126, + "count" : 60, + "type" : "VEC3" } ], "bufferViews" : [ @@ -771,11 +810,21 @@ "buffer" : 0, "byteLength" : 1776, "byteOffset" : 87020 + }, + { + "buffer" : 0, + "byteLength" : 240, + "byteOffset" : 88796 + }, + { + "buffer" : 0, + "byteLength" : 720, + "byteOffset" : 89036 } ], "buffers" : [ { - "byteLength" : 88796, + "byteLength" : 89756, "uri" : "cube.bin" } ] diff --git a/example/lib/main.dart b/example/lib/main.dart index 2233be80..56d1ba7b 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -23,6 +23,7 @@ class _MyAppState extends State { int _primitiveIndex = 0; final weights = List.filled(255, 0.0); List _targets = []; + bool _loop = false; @override void initState() { @@ -62,6 +63,7 @@ class _MyAppState extends State { onPressed: () async { await _filamentController.loadGltf( 'assets/cube.gltf', 'assets'); + print(await _filamentController.getAnimationNames()); }), ElevatedButton( child: const Text('set all weights to 1'), @@ -76,8 +78,14 @@ class _MyAppState extends State { .applyWeights(List.filled(8, 0)); }), ElevatedButton( - onPressed: () => _filamentController.playAnimation(0), + onPressed: () => + _filamentController.playAnimation(0, loop:_loop), child: const Text('play animation')), + Checkbox( + onChanged: (_) => setState(() { + _loop = !_loop; + }), + value: _loop), ElevatedButton( onPressed: () { _filamentController.zoom(-1.0); @@ -90,7 +98,7 @@ class _MyAppState extends State { child: const Text('zoom out')), ElevatedButton( onPressed: () { - _filamentController.setCamera("Camera.001"); + _filamentController.setCamera("Camera"); }, child: const Text('set camera')), ElevatedButton( @@ -105,7 +113,8 @@ class _MyAppState extends State { numWeights, frame / totalFrames)) .reduce((accum, next) => accum + next); - _filamentController.animate(frames, numWeights, framerate.toDouble()); + _filamentController.animate( + frames, numWeights, framerate.toDouble()); }, child: const Text('animate weights')), Builder(