updates
This commit is contained in:
@@ -123,25 +123,26 @@ class _MyAppState extends State<MyApp> {
|
|||||||
_filamentController.setCamera(_cube!, "Camera_Orientation");
|
_filamentController.setCamera(_cube!, "Camera_Orientation");
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
final animation = AnimationBuilder()
|
throw Exception("FIXME");
|
||||||
.setFramerate(30)
|
// final animation = AnimationBuilder()
|
||||||
.setDuration(4)
|
// .setFramerate(30)
|
||||||
.setNumMorphWeights(8)
|
// .setDuration(4)
|
||||||
.interpolateMorphWeights(0, 4, 0, 1)
|
// .setNumMorphWeights(8)
|
||||||
.interpolateBoneTransform(
|
// .interpolateMorphWeights(0, 4, 0, 1)
|
||||||
"Bone.001",
|
// .interpolateBoneTransform(
|
||||||
"Cube.001",
|
// "Bone.001",
|
||||||
2,
|
// "Cube.001",
|
||||||
4,
|
// 2,
|
||||||
v.Vector3.zero(),
|
// 4,
|
||||||
v.Vector3.zero(),
|
// v.Vector3.zero(),
|
||||||
// Vec3(x: 1, y: 1, z: 1),
|
// v.Vector3.zero(),
|
||||||
v.Quaternion(0, 0, 0, 1),
|
// // Vec3(x: 1, y: 1, z: 1),
|
||||||
v.Quaternion(1, 1, 1, 1))
|
// v.Quaternion(0, 0, 0, 1),
|
||||||
// Quaternion(x: 1, y: 1, z: 1, w: 1))
|
// v.Quaternion(1, 1, 1, 1))
|
||||||
.build();
|
// // Quaternion(x: 1, y: 1, z: 1, w: 1))
|
||||||
|
// .build();
|
||||||
|
|
||||||
_filamentController.setAnimation(_cube!, animation);
|
// _filamentController.setAnimation(_cube!, animation);
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
_targetNames =
|
_targetNames =
|
||||||
@@ -307,7 +308,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
child: FilamentGestureDetector(
|
child: FilamentGestureDetector(
|
||||||
showControls: true,
|
showControlOverlay: true,
|
||||||
controller: _filamentController,
|
controller: _filamentController,
|
||||||
child: FilamentWidget(
|
child: FilamentWidget(
|
||||||
controller: _filamentController,
|
controller: _filamentController,
|
||||||
|
|||||||
@@ -5,49 +5,56 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.9.0"
|
version: "2.10.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: boolean_selector
|
name: boolean_selector
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.1"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.1"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.16.0"
|
version: "1.17.0"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: cupertino_icons
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "486b7bc707424572cdf7bd7e812a0c146de3fd47ecadf070254cc60383f21dd8"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "1.0.3"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
flutter:
|
flutter:
|
||||||
@@ -59,7 +66,8 @@ packages:
|
|||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: flutter_lints
|
name: flutter_lints
|
||||||
url: "https://pub.dartlang.org"
|
sha256: b543301ad291598523947dc534aaddc5aaad597b709d2426d3a0e0d44c5cb493
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.4"
|
version: "1.0.4"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@@ -67,46 +75,60 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
js:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: js
|
||||||
|
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.5"
|
||||||
lints:
|
lints:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: lints
|
name: lints
|
||||||
url: "https://pub.dartlang.org"
|
sha256: a2c3d198cb5ea2e179926622d433331d8b58374ab8f29cdda6e863bd62fd369c
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.12"
|
version: "0.12.13"
|
||||||
material_color_utilities:
|
material_color_utilities:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: material_color_utilities
|
name: material_color_utilities
|
||||||
url: "https://pub.dartlang.org"
|
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.1.5"
|
version: "0.2.0"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.2"
|
version: "1.8.2"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "5aadc2af7cd403ad0b95ef654c3e628517f4cae9682b4229a66caf9df71844d2"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.0.1"
|
||||||
polyvox_filament:
|
polyvox_filament:
|
||||||
@@ -125,51 +147,58 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.9.0"
|
version: "1.9.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stack_trace
|
name: stack_trace
|
||||||
url: "https://pub.dartlang.org"
|
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.0"
|
version: "1.11.0"
|
||||||
stream_channel:
|
stream_channel:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: stream_channel
|
name: stream_channel
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.1"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.2.0"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.1"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.12"
|
version: "0.4.16"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||||
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.4"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.17.1 <3.0.0"
|
dart: ">=2.18.0 <3.0.0"
|
||||||
flutter: ">=1.20.0"
|
flutter: ">=1.20.0"
|
||||||
|
|||||||
@@ -10,14 +10,16 @@ enum GestureType { RotateCamera, PanCamera, PanBackground }
|
|||||||
class FilamentGestureDetector extends StatefulWidget {
|
class FilamentGestureDetector extends StatefulWidget {
|
||||||
final Widget? child;
|
final Widget? child;
|
||||||
final FilamentController controller;
|
final FilamentController controller;
|
||||||
final bool showControls;
|
final bool showControlOverlay;
|
||||||
|
final bool enableControls;
|
||||||
|
|
||||||
const FilamentGestureDetector({
|
const FilamentGestureDetector(
|
||||||
Key? key,
|
{Key? key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
this.child,
|
this.child,
|
||||||
this.showControls = false,
|
this.showControlOverlay = false,
|
||||||
}) : super(key: key);
|
this.enableControls = true})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _FilamentGestureDetectorState();
|
State<StatefulWidget> createState() => _FilamentGestureDetectorState();
|
||||||
@@ -68,9 +70,9 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(Widget oldWidget) {
|
void didUpdateWidget(FilamentGestureDetector oldWidget) {
|
||||||
if (widget.showControls !=
|
if (widget.showControlOverlay != oldWidget.showControlOverlay ||
|
||||||
(oldWidget as FilamentGestureDetector).showControls) {
|
widget.enableControls != oldWidget.enableControls) {
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,64 +83,93 @@ class _FilamentGestureDetectorState extends State<FilamentGestureDetector> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
print(widget.enableControls);
|
||||||
return Stack(children: [
|
return Stack(children: [
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
// pinch zoom on mobile
|
// pinch zoom on mobile
|
||||||
// couldn't find any equivalent for pointerCount in Listener so we use two widgets:
|
// couldn't find any equivalent for pointerCount in Listener so we use two widgets:
|
||||||
// - outer is a GestureDetector only for pinch zoom
|
// - outer is a GestureDetector only for pinch zoom
|
||||||
// - inner is a Listener for all other gestures
|
// - inner is a Listener for all other gestures (including scroll zoom on desktop)
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onScaleStart: (d) async {
|
onScaleStart: !widget.enableControls
|
||||||
if (d.pointerCount == 2) {
|
? null
|
||||||
await widget.controller.zoomEnd();
|
: (d) async {
|
||||||
await widget.controller.zoomBegin();
|
if (d.pointerCount == 2) {
|
||||||
}
|
await widget.controller.zoomEnd();
|
||||||
},
|
await widget.controller.zoomBegin();
|
||||||
onScaleEnd: (d) async {
|
}
|
||||||
if (d.pointerCount == 2) {
|
},
|
||||||
_lastScale = 0;
|
onScaleEnd: !widget.enableControls
|
||||||
await widget.controller.zoomEnd();
|
? null
|
||||||
}
|
: (d) async {
|
||||||
},
|
if (d.pointerCount == 2) {
|
||||||
onScaleUpdate: (d) async {
|
_lastScale = 0;
|
||||||
if (d.pointerCount == 2) {
|
await widget.controller.zoomEnd();
|
||||||
if (_lastScale != 0) {
|
}
|
||||||
await widget.controller
|
},
|
||||||
.zoomUpdate(100 * (_lastScale - d.scale));
|
onScaleUpdate: !widget.enableControls
|
||||||
}
|
? null
|
||||||
}
|
: (d) async {
|
||||||
_lastScale = d.scale;
|
if (d.pointerCount == 2) {
|
||||||
},
|
if (_lastScale != 0) {
|
||||||
|
await widget.controller
|
||||||
|
.zoomUpdate(100 * (_lastScale - d.scale));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_lastScale = d.scale;
|
||||||
|
},
|
||||||
child: Listener(
|
child: Listener(
|
||||||
onPointerSignal: (pointerSignal) async {
|
onPointerSignal: !widget.enableControls
|
||||||
// scroll-wheel zoom on desktop
|
? null
|
||||||
if (pointerSignal is PointerScrollEvent) {
|
: (pointerSignal) async {
|
||||||
_scrollTimer?.cancel();
|
// scroll-wheel zoom on desktop
|
||||||
await widget.controller.zoomBegin();
|
if (pointerSignal is PointerScrollEvent) {
|
||||||
await widget.controller.zoomUpdate(
|
_scrollTimer?.cancel();
|
||||||
pointerSignal.scrollDelta.dy > 0 ? 10 : -10);
|
await widget.controller.zoomBegin();
|
||||||
_scrollTimer = Timer(Duration(milliseconds: 100), () {
|
await widget.controller.zoomUpdate(
|
||||||
widget.controller.zoomEnd();
|
pointerSignal.scrollDelta.dy > 0 ? 10 : -10);
|
||||||
_scrollTimer = null;
|
_scrollTimer =
|
||||||
});
|
Timer(Duration(milliseconds: 100), () {
|
||||||
} else {
|
widget.controller.zoomEnd();
|
||||||
print(pointerSignal);
|
_scrollTimer = null;
|
||||||
}
|
});
|
||||||
},
|
}
|
||||||
onPointerPanZoomStart: (pzs) {},
|
},
|
||||||
onPointerDown: (d) async {
|
onPointerPanZoomStart:
|
||||||
await _functionStart(
|
!widget.enableControls ? null : (pzs) {},
|
||||||
d.localPosition.dx, d.localPosition.dy);
|
onPointerDown: !widget.enableControls
|
||||||
},
|
? null
|
||||||
onPointerMove: (d) async {
|
: (d) async {
|
||||||
await _functionUpdate(
|
if (d.buttons == kTertiaryButton) {
|
||||||
d.localPosition.dx, d.localPosition.dy);
|
await widget.controller.rotateStart(
|
||||||
},
|
d.localPosition.dx, d.localPosition.dy);
|
||||||
onPointerUp: (d) async {
|
} else {
|
||||||
await _functionEnd();
|
await _functionStart(
|
||||||
},
|
d.localPosition.dx, d.localPosition.dy);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPointerMove: !widget.enableControls
|
||||||
|
? null
|
||||||
|
: (d) async {
|
||||||
|
if (d.buttons == kTertiaryButton) {
|
||||||
|
await widget.controller.rotateUpdate(
|
||||||
|
d.localPosition.dx, d.localPosition.dy);
|
||||||
|
} else {
|
||||||
|
await _functionUpdate(
|
||||||
|
d.localPosition.dx, d.localPosition.dy);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onPointerUp: !widget.enableControls
|
||||||
|
? null
|
||||||
|
: (d) async {
|
||||||
|
if (d.buttons == kTertiaryButton) {
|
||||||
|
await widget.controller.rotateEnd();
|
||||||
|
} else {
|
||||||
|
await _functionEnd();
|
||||||
|
}
|
||||||
|
},
|
||||||
child: widget.child))),
|
child: widget.child))),
|
||||||
widget.showControls
|
widget.showControlOverlay
|
||||||
? Align(
|
? Align(
|
||||||
alignment: Alignment.bottomRight,
|
alignment: Alignment.bottomRight,
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ class FilamentWidget extends StatefulWidget {
|
|||||||
class _FilamentWidgetState extends State<FilamentWidget> {
|
class _FilamentWidgetState extends State<FilamentWidget> {
|
||||||
StreamSubscription? _listener;
|
StreamSubscription? _listener;
|
||||||
|
|
||||||
|
bool _resizing = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_listener = widget.controller.onInitializationRequested.listen((_) {
|
_listener = widget.controller.onInitializationRequested.listen((_) {
|
||||||
@@ -85,7 +87,7 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamBuilder(
|
return StreamBuilder(
|
||||||
stream: widget.controller.textureId,
|
stream: widget.controller.textureId,
|
||||||
builder: (ctx, AsyncSnapshot<int> textureId) {
|
builder: (ctx, AsyncSnapshot<int?> textureId) {
|
||||||
if (textureId.data == null) {
|
if (textureId.data == null) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
@@ -101,14 +103,23 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
width: constraints.maxWidth,
|
width: constraints.maxWidth,
|
||||||
child: ResizeObserver(
|
child: ResizeObserver(
|
||||||
onResized: (Size oldSize, Size newSize) async {
|
onResized: (Size oldSize, Size newSize) async {
|
||||||
|
setState(() {
|
||||||
|
_resizing = true;
|
||||||
|
});
|
||||||
|
|
||||||
await widget.controller.resize(
|
await widget.controller.resize(
|
||||||
newSize.width.toInt(), newSize.height.toInt());
|
newSize.width.toInt(), newSize.height.toInt());
|
||||||
|
setState(() {
|
||||||
|
_resizing = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: Platform.isLinux
|
child: Platform.isLinux
|
||||||
? Transform(
|
? _resizing
|
||||||
alignment: Alignment.center,
|
? Container()
|
||||||
transform: Matrix4.rotationX(pi),
|
: Transform(
|
||||||
child: texture)
|
alignment: Alignment.center,
|
||||||
|
transform: Matrix4.rotationX(pi),
|
||||||
|
child: texture)
|
||||||
: texture))));
|
: texture))));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ link_directories("${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|||||||
|
|
||||||
add_library(FILAMENT_SHADERS SHARED
|
add_library(FILAMENT_SHADERS SHARED
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/image_material.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/image_material.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/unlitopaque.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../ios/include/material/unlit_opaque.c"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Define the plugin library target. Its name must not be changed (see comment
|
# Define the plugin library target. Its name must not be changed (see comment
|
||||||
|
|||||||
178
materials/unlit_fade.mat
Normal file
178
materials/unlit_fade.mat
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
material {
|
||||||
|
name : unlit_fade,
|
||||||
|
requires : [ uv0, uv1, color ],
|
||||||
|
shadingModel : ${SHADINGMODEL},
|
||||||
|
blending : ${BLENDING},
|
||||||
|
doubleSided : ${DOUBLESIDED},
|
||||||
|
transparency : ${TRANSPARENCY},
|
||||||
|
flipUV : false,
|
||||||
|
specularAmbientOcclusion : simple,
|
||||||
|
specularAntiAliasing : true,
|
||||||
|
clearCoatIorChange : false,
|
||||||
|
reflections : screenspace,
|
||||||
|
parameters : [
|
||||||
|
|
||||||
|
{ type : float3, name : specularFactor },
|
||||||
|
{ type : float, name : glossinessFactor },
|
||||||
|
|
||||||
|
// Base Color
|
||||||
|
{ type : int, name : baseColorIndex },
|
||||||
|
{ type : float4, name : baseColorFactor },
|
||||||
|
{ type : sampler2d, name : baseColorMap },
|
||||||
|
{ type : mat3, name : baseColorUvMatrix, precision: high },
|
||||||
|
|
||||||
|
// Metallic-Roughness Map
|
||||||
|
{ type : int, name : metallicRoughnessIndex },
|
||||||
|
{ type : float, name : metallicFactor },
|
||||||
|
{ type : float, name : roughnessFactor },
|
||||||
|
{ type : sampler2d, name : metallicRoughnessMap },
|
||||||
|
{ type : mat3, name : metallicRoughnessUvMatrix, precision: high },
|
||||||
|
|
||||||
|
// Normal Map
|
||||||
|
{ type : int, name : normalIndex },
|
||||||
|
{ type : float, name : normalScale },
|
||||||
|
{ type : sampler2d, name : normalMap },
|
||||||
|
{ type : mat3, name : normalUvMatrix, precision: high },
|
||||||
|
|
||||||
|
// Ambient Occlusion
|
||||||
|
{ type : int, name : aoIndex },
|
||||||
|
{ type : float, name : aoStrength },
|
||||||
|
{ type : sampler2d, name : occlusionMap },
|
||||||
|
{ type : mat3, name : occlusionUvMatrix, precision: high },
|
||||||
|
|
||||||
|
// Emissive Map
|
||||||
|
{ type : int, name : emissiveIndex },
|
||||||
|
{ type : float3, name : emissiveFactor },
|
||||||
|
{ type : float, name : emissiveStrength },
|
||||||
|
{ type : sampler2d, name : emissiveMap },
|
||||||
|
{ type : mat3, name : emissiveUvMatrix, precision: high },
|
||||||
|
|
||||||
|
// Clear coat
|
||||||
|
{ type : float, name : clearCoatFactor },
|
||||||
|
{ type : float, name : clearCoatRoughnessFactor },
|
||||||
|
{ type : int, name : clearCoatIndex },
|
||||||
|
{ type : sampler2d, name : clearCoatMap },
|
||||||
|
{ type : mat3, name : clearCoatUvMatrix, precision: high },
|
||||||
|
{ type : int, name : clearCoatRoughnessIndex },
|
||||||
|
{ type : sampler2d, name : clearCoatRoughnessMap },
|
||||||
|
{ type : mat3, name : clearCoatRoughnessUvMatrix, precision: high },
|
||||||
|
{ type : int, name : clearCoatNormalIndex },
|
||||||
|
{ type : sampler2d, name : clearCoatNormalMap },
|
||||||
|
{ type : mat3, name : clearCoatNormalUvMatrix, precision: high },
|
||||||
|
{ type : float, name : clearCoatNormalScale },
|
||||||
|
|
||||||
|
// Reflectance
|
||||||
|
{ type : float, name : reflectance }
|
||||||
|
|
||||||
|
${CUSTOM_PARAMS}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
vertex {
|
||||||
|
void materialVertex(inout MaterialVertexInputs material) {
|
||||||
|
${CUSTOM_VERTEX}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment {
|
||||||
|
void material(inout MaterialInputs material) {
|
||||||
|
highp float2 uvs[2];
|
||||||
|
uvs[0] = getUV0();
|
||||||
|
uvs[1] = getUV1();
|
||||||
|
|
||||||
|
#if !defined(SHADING_MODEL_UNLIT)
|
||||||
|
if (materialParams.normalIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.normalIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.normalUvMatrix).xy;
|
||||||
|
material.normal = texture(materialParams_normalMap, uv).xyz * 2.0 - 1.0;
|
||||||
|
material.normal.xy *= materialParams.normalScale;
|
||||||
|
}
|
||||||
|
#if defined(SHADING_MODEL_LIT)
|
||||||
|
if (materialParams.clearCoatNormalIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.clearCoatNormalIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.clearCoatNormalUvMatrix).xy;
|
||||||
|
material.clearCoatNormal = texture(materialParams_clearCoatNormalMap, uv).xyz * 2.0 - 1.0;
|
||||||
|
material.clearCoatNormal.xy *= materialParams.clearCoatNormalScale;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
prepareMaterial(material);
|
||||||
|
material.baseColor = materialParams.baseColorFactor;
|
||||||
|
|
||||||
|
if (materialParams.baseColorIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.baseColorIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.baseColorUvMatrix).xy;
|
||||||
|
material.baseColor *= texture(materialParams_baseColorMap, uv);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(BLEND_MODE_TRANSPARENT)
|
||||||
|
material.baseColor.rgb *= material.baseColor.a;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
material.baseColor *= getColor();
|
||||||
|
|
||||||
|
#if !defined(SHADING_MODEL_UNLIT)
|
||||||
|
|
||||||
|
#if defined(SHADING_MODEL_LIT)
|
||||||
|
material.roughness = materialParams.roughnessFactor;
|
||||||
|
material.metallic = materialParams.metallicFactor;
|
||||||
|
|
||||||
|
// KHR_materials_clearcoat forbids clear coat from
|
||||||
|
// being applied in the specular/glossiness model
|
||||||
|
material.clearCoat = materialParams.clearCoatFactor;
|
||||||
|
material.clearCoatRoughness = materialParams.clearCoatRoughnessFactor;
|
||||||
|
|
||||||
|
if (materialParams.clearCoatIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.clearCoatIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.clearCoatUvMatrix).xy;
|
||||||
|
material.clearCoat *= texture(materialParams_clearCoatMap, uv).r;
|
||||||
|
}
|
||||||
|
if (materialParams.clearCoatRoughnessIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.clearCoatRoughnessIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.clearCoatRoughnessUvMatrix).xy;
|
||||||
|
material.clearCoatRoughness *= texture(materialParams_clearCoatRoughnessMap, uv).g;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
material.emissive = vec4(materialParams.emissiveStrength *
|
||||||
|
materialParams.emissiveFactor.rgb, 0.0);
|
||||||
|
|
||||||
|
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||||
|
material.glossiness = materialParams.glossinessFactor;
|
||||||
|
material.specularColor = materialParams.specularFactor;
|
||||||
|
#else
|
||||||
|
material.reflectance = materialParams.reflectance;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (materialParams.metallicRoughnessIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.metallicRoughnessIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.metallicRoughnessUvMatrix).xy;
|
||||||
|
|
||||||
|
#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)
|
||||||
|
vec4 sg = texture(materialParams_metallicRoughnessMap, uv);
|
||||||
|
material.specularColor *= sg.rgb;
|
||||||
|
material.glossiness *= sg.a;
|
||||||
|
#else
|
||||||
|
vec4 mr = texture(materialParams_metallicRoughnessMap, uv);
|
||||||
|
material.roughness *= mr.g;
|
||||||
|
material.metallic *= mr.b;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (materialParams.aoIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.aoIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.occlusionUvMatrix).xy;
|
||||||
|
float occlusion = texture(materialParams_occlusionMap, uv).r;
|
||||||
|
material.ambientOcclusion = 1.0 + materialParams.aoStrength * (occlusion - 1.0);
|
||||||
|
}
|
||||||
|
if (materialParams.emissiveIndex > -1) {
|
||||||
|
highp float2 uv = uvs[materialParams.emissiveIndex];
|
||||||
|
uv = (vec3(uv, 1.0) * materialParams.emissiveUvMatrix).xy;
|
||||||
|
material.emissive.rgb *= texture(materialParams_emissiveMap, uv).rgb;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
${CUSTOM_FRAGMENT}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
materials/unlit_opaque.mat
Normal file
15
materials/unlit_opaque.mat
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
material {
|
||||||
|
name : BakedColor,
|
||||||
|
requires : [
|
||||||
|
color
|
||||||
|
],
|
||||||
|
shadingModel : unlit,
|
||||||
|
culling : none
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment {
|
||||||
|
void material(inout MaterialInputs material) {
|
||||||
|
prepareMaterial(material);
|
||||||
|
material.baseColor = getColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
53
pubspec.lock
53
pubspec.lock
@@ -7,7 +7,7 @@ packages:
|
|||||||
name: async
|
name: async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.2"
|
version: "2.9.0"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -21,35 +21,28 @@ packages:
|
|||||||
name: characters
|
name: characters
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.2.1"
|
||||||
charcode:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: charcode
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.1"
|
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: clock
|
name: clock
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.1"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: collection
|
name: collection
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.16.0"
|
||||||
fake_async:
|
fake_async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: fake_async
|
name: fake_async
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.3.1"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -80,28 +73,35 @@ packages:
|
|||||||
name: matcher
|
name: matcher
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.12.11"
|
version: "0.12.12"
|
||||||
|
material_color_utilities:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: material_color_utilities
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.5"
|
||||||
meta:
|
meta:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: meta
|
name: meta
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.8.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path
|
name: path
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.2"
|
||||||
plugin_platform_interface:
|
plugin_platform_interface:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.1"
|
version: "2.1.3"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -113,7 +113,7 @@ packages:
|
|||||||
name: source_span
|
name: source_span
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.1"
|
version: "1.9.0"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -134,35 +134,28 @@ packages:
|
|||||||
name: string_scanner
|
name: string_scanner
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.0"
|
version: "1.1.1"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: term_glyph
|
name: term_glyph
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.1"
|
||||||
test_api:
|
test_api:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: test_api
|
name: test_api
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3"
|
version: "0.4.12"
|
||||||
typed_data:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: typed_data
|
|
||||||
url: "https://pub.dartlang.org"
|
|
||||||
source: hosted
|
|
||||||
version: "1.3.0"
|
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: vector_math
|
name: vector_math
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.2"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.12.0 <3.0.0"
|
dart: ">=2.17.1 <3.0.0"
|
||||||
flutter: ">=1.20.0"
|
flutter: ">=1.20.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user