factor out debug widgets
This commit is contained in:
@@ -37,56 +37,16 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
child: const Text('Find Cylinder entity by name')),
|
child: const Text('Find Cylinder entity by name')),
|
||||||
MenuItemButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await widget.controller.viewer.addBoneAnimation(
|
|
||||||
widget.controller.viewer.scene.listEntities().last,
|
|
||||||
BoneAnimationData([
|
|
||||||
"Bone"
|
|
||||||
], [
|
|
||||||
"Cylinder"
|
|
||||||
], [
|
|
||||||
[v.Quaternion.axisAngle(v.Vector3(1, 1, 1), pi / 2)]
|
|
||||||
], [
|
|
||||||
[v.Vector3.zero()]
|
|
||||||
], 16));
|
|
||||||
},
|
|
||||||
child:
|
|
||||||
const Text('Set bone transform for Cylinder (pi/2 rotation X)')),
|
|
||||||
MenuItemButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await widget.controller.viewer
|
|
||||||
.resetBones(widget.controller.viewer.scene.listEntities().last);
|
|
||||||
},
|
|
||||||
child: const Text('Reset bones for Cylinder')),
|
|
||||||
MenuItemButton(
|
|
||||||
onPressed: () async {
|
|
||||||
await widget.controller.viewer.addBoneAnimation(
|
|
||||||
widget.controller.viewer.scene.listEntities().last,
|
|
||||||
BoneAnimationData(
|
|
||||||
["Bone"],
|
|
||||||
["Cylinder"],
|
|
||||||
List.generate(
|
|
||||||
60,
|
|
||||||
(idx) => [
|
|
||||||
v.Quaternion.axisAngle(
|
|
||||||
v.Vector3(0, 0, 1), pi * 8 * (idx / 60))
|
|
||||||
.normalized()
|
|
||||||
]),
|
|
||||||
List.generate(60, (idx) => [v.Vector3.zero()]),
|
|
||||||
1000.0 / 60.0));
|
|
||||||
},
|
|
||||||
child: const Text('Set bone transform animation for Cylinder')),
|
|
||||||
|
|
||||||
|
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
widget.controller.viewer.setPosition(
|
widget.controller.viewer.setPosition(
|
||||||
widget.controller.viewer.scene.listEntities().last, 1.0, 1.0, -1.0);
|
widget.controller.viewer.scene.listEntities().last,
|
||||||
|
1.0,
|
||||||
|
1.0,
|
||||||
|
-1.0);
|
||||||
},
|
},
|
||||||
child: const Text('Set position to 1, 1, -1'),
|
child: const Text('Set position to 1, 1, -1'),
|
||||||
),
|
),
|
||||||
|
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final color = Colors.purple;
|
final color = Colors.purple;
|
||||||
@@ -100,7 +60,6 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
1.0);
|
1.0);
|
||||||
},
|
},
|
||||||
child: const Text("Set cone material color to purple")),
|
child: const Text("Set cone material color to purple")),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return SubmenuButton(menuChildren: children, child: const Text("Shapes"));
|
return SubmenuButton(menuChildren: children, child: const Text("Shapes"));
|
||||||
@@ -126,7 +85,8 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
-1.0,
|
-1.0,
|
||||||
];
|
];
|
||||||
var indices = [0, 1, 2, 2, 3, 0];
|
var indices = [0, 1, 2, 2, 3, 0];
|
||||||
var geom = await widget.controller.viewer.createGeometry(verts, indices,
|
var geom = await widget.controller.viewer.createGeometry(
|
||||||
|
verts, indices,
|
||||||
materialPath: "asset://assets/solidcolor.filamat");
|
materialPath: "asset://assets/solidcolor.filamat");
|
||||||
},
|
},
|
||||||
child: const Text("Quad")),
|
child: const Text("Quad")),
|
||||||
@@ -158,22 +118,26 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
_geometrySubmenu(),
|
_geometrySubmenu(),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.controller.viewer
|
await widget.controller.viewer.addLight(
|
||||||
.addLight(LightType.DIRECTIONAL, 6500, 100000, 0, 1, 0, 0, -1, 0);
|
LightType.DIRECTIONAL, 6500, 100000, 0, 1, 0, 0, -1, 0);
|
||||||
},
|
},
|
||||||
child: const Text("Add directional light"),
|
child: const Text("Add directional light"),
|
||||||
),
|
),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.controller.viewer
|
await widget.controller.viewer.addLight(
|
||||||
.addLight(LightType.POINT, 6500, 100000, 0, 1, 0, 0, -1, 0, falloffRadius: 1.0);
|
LightType.POINT, 6500, 100000, 0, 1, 0, 0, -1, 0,
|
||||||
|
falloffRadius: 1.0);
|
||||||
},
|
},
|
||||||
child: const Text("Add point light"),
|
child: const Text("Add point light"),
|
||||||
),
|
),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.controller.viewer
|
await widget.controller.viewer.addLight(
|
||||||
.addLight(LightType.SPOT, 6500, 1000000, 0, 0, 0, 0, 1, 0,spotLightConeInner: 0.1, spotLightConeOuter: 0.4, falloffRadius: 100.0);
|
LightType.SPOT, 6500, 1000000, 0, 0, 0, 0, 1, 0,
|
||||||
|
spotLightConeInner: 0.1,
|
||||||
|
spotLightConeOuter: 0.4,
|
||||||
|
falloffRadius: 100.0);
|
||||||
},
|
},
|
||||||
child: const Text("Add spot light"),
|
child: const Text("Add spot light"),
|
||||||
),
|
),
|
||||||
@@ -192,12 +156,14 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
child: const Text("Set background color")),
|
child: const Text("Set background color")),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.controller.viewer.setBackgroundImage('assets/background.ktx');
|
widget.controller.viewer
|
||||||
|
.setBackgroundImage('assets/background.ktx');
|
||||||
},
|
},
|
||||||
child: const Text("Load background image")),
|
child: const Text("Load background image")),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
widget.controller.viewer.setBackgroundImage('assets/background.ktx',
|
widget.controller.viewer.setBackgroundImage(
|
||||||
|
'assets/background.ktx',
|
||||||
fillHeight: true);
|
fillHeight: true);
|
||||||
},
|
},
|
||||||
child: const Text("Load background image (fill height)")),
|
child: const Text("Load background image (fill height)")),
|
||||||
@@ -225,7 +191,7 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
widget.controller.viewer.removeIbl();
|
widget.controller.viewer.removeIbl();
|
||||||
},
|
},
|
||||||
child: const Text('Remove IBL')),
|
child: const Text('Remove IBL')),
|
||||||
MenuItemButton(
|
MenuItemButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await widget.controller.viewer.clearEntities();
|
await widget.controller.viewer.clearEntities();
|
||||||
},
|
},
|
||||||
@@ -236,7 +202,6 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// _item(() async {
|
// _item(() async {
|
||||||
// var frameData = Float32List.fromList(
|
// var frameData = Float32List.fromList(
|
||||||
// List<double>.generate(120, (i) => i / 120).expand((x) {
|
// List<double>.generate(120, (i) => i / 120).expand((x) {
|
||||||
@@ -296,4 +261,3 @@ class _AssetSubmenuState extends State<AssetSubmenu> {
|
|||||||
// .build();
|
// .build();
|
||||||
// widget.controller!.setMorphAnimationData(_shapes!, animation);
|
// widget.controller!.setMorphAnimationData(_shapes!, animation);
|
||||||
// }, "animate shapes morph weights #1 and #2"),
|
// }, "animate shapes morph weights #1 and #2"),
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import 'package:animation_tools_dart/animation_tools_dart.dart';
|
|||||||
import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart';
|
import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart';
|
||||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_filament/filament/widgets/debug/skeleton_menu_item_widget.dart';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
class ChildRenderableWidget extends StatelessWidget {
|
class ChildRenderableWidget extends StatelessWidget {
|
||||||
final AbstractFilamentViewer controller;
|
final AbstractFilamentViewer controller;
|
||||||
@@ -13,6 +15,7 @@ class ChildRenderableWidget extends StatelessWidget {
|
|||||||
Widget _childRenderable(FilamentEntity childEntity) {
|
Widget _childRenderable(FilamentEntity childEntity) {
|
||||||
var name = controller.getNameForEntity(childEntity) ?? "<none>";
|
var name = controller.getNameForEntity(childEntity) ?? "<none>";
|
||||||
var names = controller.getMorphTargetNames(entity, childEntity);
|
var names = controller.getMorphTargetNames(entity, childEntity);
|
||||||
|
|
||||||
return FutureBuilder(
|
return FutureBuilder(
|
||||||
future: names,
|
future: names,
|
||||||
builder: (_, morphTargetsSnapshot) {
|
builder: (_, morphTargetsSnapshot) {
|
||||||
@@ -70,7 +73,39 @@ class ChildRenderableWidget extends StatelessWidget {
|
|||||||
var children = snapshot.data!;
|
var children = snapshot.data!;
|
||||||
return SubmenuButton(
|
return SubmenuButton(
|
||||||
child: Text("Renderable entities"),
|
child: Text("Renderable entities"),
|
||||||
menuChildren: children.map(_childRenderable).toList());
|
menuChildren: <Widget>[
|
||||||
|
MenuItemButton(
|
||||||
|
child: Text("Set children transforms to identity"),
|
||||||
|
onPressed: () async {
|
||||||
|
var childEntities =
|
||||||
|
await controller.getChildEntities(entity, true);
|
||||||
|
for (final child in childEntities) {
|
||||||
|
await controller.setTransform(
|
||||||
|
child, Matrix4.identity());
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
MenuItemButton(
|
||||||
|
child: Text("Set children transforms to 90/X"),
|
||||||
|
onPressed: () async {
|
||||||
|
var childEntities =
|
||||||
|
await controller.getChildEntities(entity, true);
|
||||||
|
for (final child in childEntities) {
|
||||||
|
await controller.setTransform(
|
||||||
|
child, Matrix4.rotationX(pi / 2));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
MenuItemButton(
|
||||||
|
child: Text("Set children transforms to 90/Y"),
|
||||||
|
onPressed: () async {
|
||||||
|
var childEntities =
|
||||||
|
await controller.getChildEntities(entity, true);
|
||||||
|
for (final child in childEntities) {
|
||||||
|
await controller.setTransform(
|
||||||
|
child, Matrix4.rotationY(pi / 2));
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
] +
|
||||||
|
children.map(_childRenderable).toList());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart';
|
|||||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||||
import 'package:flutter_filament/filament/widgets/debug/child_renderable_widget.dart';
|
import 'package:flutter_filament/filament/widgets/debug/child_renderable_widget.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_filament/filament/widgets/debug/skeleton_menu_item_widget.dart';
|
||||||
|
|
||||||
class EntityListWidget extends StatefulWidget {
|
class EntityListWidget extends StatefulWidget {
|
||||||
final AbstractFilamentViewer? controller;
|
final AbstractFilamentViewer? controller;
|
||||||
@@ -67,7 +68,9 @@ class _EntityListWidget extends State<EntityListWidget> {
|
|||||||
menuChildren: animations.data!
|
menuChildren: animations.data!
|
||||||
.map((a) => MenuItemButton(
|
.map((a) => MenuItemButton(
|
||||||
child: Text(a),
|
child: Text(a),
|
||||||
onPressed: () {
|
onPressed: () async {
|
||||||
|
await widget.controller!
|
||||||
|
.addAnimationComponent(entity);
|
||||||
widget.controller!.playAnimation(
|
widget.controller!.playAnimation(
|
||||||
entity, animations.data!.indexOf(a));
|
entity, animations.data!.indexOf(a));
|
||||||
},
|
},
|
||||||
@@ -75,6 +78,8 @@ class _EntityListWidget extends State<EntityListWidget> {
|
|||||||
.toList()),
|
.toList()),
|
||||||
ChildRenderableWidget(
|
ChildRenderableWidget(
|
||||||
controller: widget.controller!, entity: entity),
|
controller: widget.controller!, entity: entity),
|
||||||
|
SkeletonMenuItemWidget(
|
||||||
|
controller: widget.controller!, entity: entity)
|
||||||
])
|
])
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
@@ -135,15 +140,16 @@ class _EntityListWidget extends State<EntityListWidget> {
|
|||||||
borderRadius: BorderRadius.circular(30),
|
borderRadius: BorderRadius.circular(30),
|
||||||
color: Colors.white.withOpacity(0.25),
|
color: Colors.white.withOpacity(0.25),
|
||||||
),
|
),
|
||||||
child: SingleChildScrollView(child:Column(
|
child: SingleChildScrollView(
|
||||||
// reverse: true,
|
child: Column(
|
||||||
children: widget.controller!.scene
|
// reverse: true,
|
||||||
.listLights()
|
children: widget.controller!.scene
|
||||||
.map(_light)
|
.listLights()
|
||||||
.followedBy(widget.controller!.scene
|
.map(_light)
|
||||||
.listEntities()
|
.followedBy(widget.controller!.scene
|
||||||
.map(_entity))
|
.listEntities()
|
||||||
.cast<Widget>()
|
.map(_entity))
|
||||||
.toList())))));
|
.cast<Widget>()
|
||||||
|
.toList())))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user