add option for resize to example project
This commit is contained in:
@@ -41,7 +41,7 @@ class ExampleWidget extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _ExampleWidgetState extends State<ExampleWidget> {
|
class _ExampleWidgetState extends State<ExampleWidget> {
|
||||||
FilamentControllerFFI? _filamentController;
|
FilamentController? _filamentController;
|
||||||
|
|
||||||
FilamentEntity? _shapes;
|
FilamentEntity? _shapes;
|
||||||
FilamentEntity? _flightHelmet;
|
FilamentEntity? _flightHelmet;
|
||||||
@@ -54,11 +54,13 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
final weights = List.filled(255, 0.0);
|
final weights = List.filled(255, 0.0);
|
||||||
|
|
||||||
bool _loop = false;
|
bool _loop = false;
|
||||||
bool _vertical = false;
|
EdgeInsets _viewportMargin = EdgeInsets.zero;
|
||||||
|
|
||||||
|
bool _readyForScene = false;
|
||||||
|
|
||||||
bool _rendering = false;
|
bool _rendering = false;
|
||||||
int _framerate = 60;
|
int _framerate = 60;
|
||||||
bool _postProcessing = true;
|
bool _postProcessing = true;
|
||||||
bool _active = false;
|
|
||||||
|
|
||||||
bool _coneHidden = false;
|
bool _coneHidden = false;
|
||||||
bool _frustumCulling = true;
|
bool _frustumCulling = true;
|
||||||
@@ -87,7 +89,12 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
FilamentControllerFFI(uberArchivePath: uberArchivePath);
|
FilamentControllerFFI(uberArchivePath: uberArchivePath);
|
||||||
_filamentController!.pickResult.listen((entityId) {
|
_filamentController!.pickResult.listen((entityId) {
|
||||||
setState(() {
|
setState(() {
|
||||||
picked = _filamentController!.getNameForEntity(entityId);
|
picked = _filamentController!.getNameForEntity(entityId!);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
_filamentController!.isReadyForScene.then((readyForScene) {
|
||||||
|
setState(() {
|
||||||
|
_readyForScene = readyForScene;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -108,17 +115,14 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
: "assets/lit_opaque_43.uberz");
|
: "assets/lit_opaque_43.uberz");
|
||||||
}, "create viewer (custom ubershader - lit opaque only)"),
|
}, "create viewer (custom ubershader - lit opaque only)"),
|
||||||
]);
|
]);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (_readyForScene) {
|
||||||
children.addAll([
|
children.addAll([
|
||||||
_item(() {
|
_item(() {
|
||||||
_filamentController!.destroy();
|
_filamentController!.destroy();
|
||||||
_filamentController = null;
|
_filamentController = null;
|
||||||
}, "destroy viewer/texture")
|
}, "destroy viewer/texture"),
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_filamentController != null) {
|
|
||||||
children.addAll([
|
|
||||||
_item(() {
|
_item(() {
|
||||||
_filamentController!.render();
|
_filamentController!.render();
|
||||||
}, "render"),
|
}, "render"),
|
||||||
@@ -152,6 +156,13 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
_filamentController!
|
_filamentController!
|
||||||
.loadIbl('assets/default_env/default_env_ibl.ktx');
|
.loadIbl('assets/default_env/default_env_ibl.ktx');
|
||||||
}, 'load IBL'),
|
}, 'load IBL'),
|
||||||
|
_item(() async {
|
||||||
|
_light = await _filamentController!
|
||||||
|
.addLight(1, 6500, 150000, 0, 1, 0, 0, -1, 0, true);
|
||||||
|
}, "add directional light"),
|
||||||
|
_item(() async {
|
||||||
|
await _filamentController!.clearLights();
|
||||||
|
}, "clear lights"),
|
||||||
_item(() {
|
_item(() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_postProcessing = !_postProcessing;
|
_postProcessing = !_postProcessing;
|
||||||
@@ -290,7 +301,14 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
_item(() {
|
_item(() {
|
||||||
_loop = !_loop;
|
_loop = !_loop;
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}, "toggle animation looping ${_loop ? "OFF" : "ON"}")
|
}, "toggle animation looping ${_loop ? "OFF" : "ON"}"),
|
||||||
|
_item(() {
|
||||||
|
setState(() {
|
||||||
|
_viewportMargin = _viewportMargin == EdgeInsets.zero
|
||||||
|
? EdgeInsets.all(50)
|
||||||
|
: EdgeInsets.zero;
|
||||||
|
});
|
||||||
|
}, "resize")
|
||||||
]);
|
]);
|
||||||
if (_animations != null) {
|
if (_animations != null) {
|
||||||
children.addAll(_animations!.map((a) => _item(() {
|
children.addAll(_animations!.map((a) => _item(() {
|
||||||
@@ -323,28 +341,34 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
return Stack(children: [
|
return Stack(children: [
|
||||||
_filamentController != null
|
_filamentController != null
|
||||||
? Positioned.fill(
|
? Positioned.fill(
|
||||||
child: FilamentGestureDetector(
|
child: Padding(
|
||||||
showControlOverlay: true,
|
padding: _viewportMargin,
|
||||||
controller: _filamentController!,
|
child: FilamentGestureDetector(
|
||||||
child: FilamentWidget(
|
showControlOverlay: true,
|
||||||
controller: _filamentController!,
|
controller: _filamentController!,
|
||||||
)))
|
child: FilamentWidget(
|
||||||
|
controller: _filamentController!,
|
||||||
|
))))
|
||||||
: Container(),
|
: Container(),
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 50,
|
right: 50,
|
||||||
top: 50,
|
top: 50,
|
||||||
child: Text(picked ?? "",
|
child: Text(picked ?? "",
|
||||||
style: TextStyle(color: Colors.green, fontSize: 24))),
|
style: const TextStyle(color: Colors.green, fontSize: 24))),
|
||||||
Positioned(
|
Align(
|
||||||
bottom: 0,
|
alignment: Alignment.bottomCenter,
|
||||||
left: 0,
|
child: OrientationBuilder(builder: (ctx, orientation) {
|
||||||
right: 0,
|
return Container(
|
||||||
height: 200,
|
alignment: Alignment.bottomCenter,
|
||||||
child: Container(
|
height: orientation == Orientation.landscape ? 100 : 200,
|
||||||
color: Colors.white.withOpacity(0.75),
|
color: Colors.white.withOpacity(0.75),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(child: Wrap(children: children)));
|
||||||
child: Wrap(children: children
|
}))
|
||||||
// _item(24 () async { 'rotate by pi around Y axis'),
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// _item(24 () async { 'rotate by pi around Y axis'),
|
||||||
// _item(5 () async { 'load flight helmet'),
|
// _item(5 () async { 'load flight helmet'),
|
||||||
|
|
||||||
// _item(7 () async { 'set all weights to 1'),
|
// _item(7 () async { 'set all weights to 1'),
|
||||||
@@ -375,10 +399,6 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
// _item(30 () async { 'remove light'),
|
// _item(30 () async { 'remove light'),
|
||||||
// _item(31 () async { 'clear all lights'),
|
// _item(31 () async { 'clear all lights'),
|
||||||
// _item(32 () async { 'set camera model matrix'),
|
// _item(32 () async { 'set camera model matrix'),
|
||||||
))))
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// case -1:
|
// case -1:
|
||||||
|
|
||||||
@@ -455,11 +475,6 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
// case 24:
|
// case 24:
|
||||||
// _filamentController!.setRotation(_shapes!, pi / 2, 0.0, 1.0, 0.0);
|
// _filamentController!.setRotation(_shapes!, pi / 2, 0.0, 1.0, 0.0);
|
||||||
// break;
|
// break;
|
||||||
// case 25:
|
|
||||||
// setState(() {
|
|
||||||
// _vertical = !_vertical;
|
|
||||||
// });
|
|
||||||
// break;
|
|
||||||
// case 26:
|
// case 26:
|
||||||
// _filamentController!.setCameraPosition(0, 0, 3);
|
// _filamentController!.setCameraPosition(0, 0, 3);
|
||||||
// _filamentController!.setCameraRotation(0, 0, 1, 0);
|
// _filamentController!.setCameraRotation(0, 0, 1, 0);
|
||||||
@@ -471,10 +486,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
// case 28:
|
// case 28:
|
||||||
// _filamentController!.setBackgroundImagePosition(25, 25);
|
// _filamentController!.setBackgroundImagePosition(25, 25);
|
||||||
// break;
|
// break;
|
||||||
// case 29:
|
|
||||||
// _light = await _filamentController!.addLight(
|
|
||||||
// 1, 6500, 15000000, 0, 1, 0, 0, -1, 0, true);
|
|
||||||
// break;
|
|
||||||
// case 30:
|
// case 30:
|
||||||
// if (_light != null) {
|
// if (_light != null) {
|
||||||
// _filamentController!.removeLight(_light!);
|
// _filamentController!.removeLight(_light!);
|
||||||
@@ -482,7 +494,7 @@ class _ExampleWidgetState extends State<ExampleWidget> {
|
|||||||
// }
|
// }
|
||||||
// break;
|
// break;
|
||||||
// case 31:
|
// case 31:
|
||||||
// _filamentController!.clearLights();
|
|
||||||
// break;
|
// break;
|
||||||
// case 32:
|
// case 32:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user