From f3a74c35adc5047b87d75f462dbd16f2a18ff6c6 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Tue, 29 Mar 2022 15:50:07 +0800 Subject: [PATCH] update example projet --- example/assets/cube.bin | Bin 88796 -> 89756 bytes example/assets/cube.gltf | 61 +++++++++++++++++++++++++++++++++++---- example/lib/main.dart | 15 ++++++++-- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/example/assets/cube.bin b/example/assets/cube.bin index ff00a72ca6e5622ba8c98a21ccde4c28d101303a..706fd59cf0671c2203f992d8c55c9152d38a3eba 100644 GIT binary patch delta 979 zcmYMzUr19?90%}UlhGIkwKQ~~DHzEFK_m^`?rxw2;zI@WBLMl+u?aNJig##cvl5=kq=1_v3O7_pZ-6hu%7k znG@?FJz@F+3DXRShyp8`rYRx@<^g0AUVu~ZHY~w}=?-dIZcwBM_Q9866>fkvxCM^D zcVPqbedHMY5FUV^!f|*UHg$wagjs}ncmZC7m*B5(3Qoft@D{uc@4*@P02Vc2I#f+_ zsv<7f4WEKf!yY&n&V#*h0bGQ^#}Ls)-uGUt#S((Zi=hktV=tA?(VIZJplk z^~Aiiq!jM0N_kLiiS=k&_NOS(BcMMn$Y&^u^&K45 zM{niR*BbQ#hL)US`pa|)JyTLj*R+<=(R=0e@bwD%U8a(DgsbS@2bbwcXU&nXipcjo ZKQ}hI0`z3RLf;Mr>B80j#t&ex{{s!&+PnY& delta 11 ScmbQUm-Wt8)`l&NccK6xqy=CA 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(