update example projet

This commit is contained in:
Nick Fisher
2022-03-29 15:50:07 +08:00
parent e3abf9a548
commit c258b0ebce
3 changed files with 67 additions and 9 deletions

Binary file not shown.

View File

@@ -44,15 +44,15 @@
], ],
"name" : "Camera", "name" : "Camera",
"rotation" : [ "rotation" : [
0.5797627568244934, 0.5715538859367371,
0.0033576595596969128, 0,
-0.013425502926111221, 0,
0.8146679401397705 0.8205645084381104
], ],
"translation" : [ "translation" : [
0, 0,
6.8069868087768555, 6.8069868087768555,
10.594138145446777 10.164137840270996
] ]
} }
], ],
@@ -68,6 +68,27 @@
"type" : "perspective" "type" : "perspective"
} }
], ],
"animations" : [
{
"channels" : [
{
"sampler" : 0,
"target" : {
"node" : 0,
"path" : "translation"
}
}
],
"name" : "FloatUp",
"samplers" : [
{
"input" : 36,
"interpolation" : "LINEAR",
"output" : 37
}
]
}
],
"materials" : [ "materials" : [
{ {
"doubleSided" : true, "doubleSided" : true,
@@ -589,6 +610,24 @@
"componentType" : 5126, "componentType" : 5126,
"count" : 148, "count" : 148,
"type" : "VEC3" "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" : [ "bufferViews" : [
@@ -771,11 +810,21 @@
"buffer" : 0, "buffer" : 0,
"byteLength" : 1776, "byteLength" : 1776,
"byteOffset" : 87020 "byteOffset" : 87020
},
{
"buffer" : 0,
"byteLength" : 240,
"byteOffset" : 88796
},
{
"buffer" : 0,
"byteLength" : 720,
"byteOffset" : 89036
} }
], ],
"buffers" : [ "buffers" : [
{ {
"byteLength" : 88796, "byteLength" : 89756,
"uri" : "cube.bin" "uri" : "cube.bin"
} }
] ]

View File

@@ -23,6 +23,7 @@ class _MyAppState extends State<MyApp> {
int _primitiveIndex = 0; int _primitiveIndex = 0;
final weights = List.filled(255, 0.0); final weights = List.filled(255, 0.0);
List<String> _targets = []; List<String> _targets = [];
bool _loop = false;
@override @override
void initState() { void initState() {
@@ -62,6 +63,7 @@ class _MyAppState extends State<MyApp> {
onPressed: () async { onPressed: () async {
await _filamentController.loadGltf( await _filamentController.loadGltf(
'assets/cube.gltf', 'assets'); 'assets/cube.gltf', 'assets');
print(await _filamentController.getAnimationNames());
}), }),
ElevatedButton( ElevatedButton(
child: const Text('set all weights to 1'), child: const Text('set all weights to 1'),
@@ -76,8 +78,14 @@ class _MyAppState extends State<MyApp> {
.applyWeights(List.filled(8, 0)); .applyWeights(List.filled(8, 0));
}), }),
ElevatedButton( ElevatedButton(
onPressed: () => _filamentController.playAnimation(0), onPressed: () =>
_filamentController.playAnimation(0, loop:_loop),
child: const Text('play animation')), child: const Text('play animation')),
Checkbox(
onChanged: (_) => setState(() {
_loop = !_loop;
}),
value: _loop),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
_filamentController.zoom(-1.0); _filamentController.zoom(-1.0);
@@ -90,7 +98,7 @@ class _MyAppState extends State<MyApp> {
child: const Text('zoom out')), child: const Text('zoom out')),
ElevatedButton( ElevatedButton(
onPressed: () { onPressed: () {
_filamentController.setCamera("Camera.001"); _filamentController.setCamera("Camera");
}, },
child: const Text('set camera')), child: const Text('set camera')),
ElevatedButton( ElevatedButton(
@@ -105,7 +113,8 @@ class _MyAppState extends State<MyApp> {
numWeights, frame / totalFrames)) numWeights, frame / totalFrames))
.reduce((accum, next) => accum + next); .reduce((accum, next) => accum + next);
_filamentController.animate(frames, numWeights, framerate.toDouble()); _filamentController.animate(
frames, numWeights, framerate.toDouble());
}, },
child: const Text('animate weights')), child: const Text('animate weights')),
Builder( Builder(