enable camera rotate
This commit is contained in:
@@ -21,7 +21,7 @@ class MyApp extends StatefulWidget {
|
|||||||
class _MyAppState extends State<MyApp> {
|
class _MyAppState extends State<MyApp> {
|
||||||
final FilamentController _filamentController = MimeticFilamentController();
|
final FilamentController _filamentController = MimeticFilamentController();
|
||||||
|
|
||||||
double _zoomValue = 0;
|
bool _rotate = false;
|
||||||
int _primitiveIndex = 0;
|
int _primitiveIndex = 0;
|
||||||
double _weight = 0.0;
|
double _weight = 0.0;
|
||||||
|
|
||||||
@@ -40,19 +40,27 @@ class _MyAppState extends State<MyApp> {
|
|||||||
body: GestureDetector(
|
body: GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onPanDown: (details) {
|
onPanDown: (details) {
|
||||||
_filamentController.panStart(
|
_rotate
|
||||||
details.localPosition.dx, details.localPosition.dy);
|
? _filamentController.rotateStart(
|
||||||
|
details.localPosition.dx, details.localPosition.dy)
|
||||||
|
: _filamentController.panStart(
|
||||||
|
details.localPosition.dx, details.localPosition.dy);
|
||||||
},
|
},
|
||||||
onPanUpdate: (details) {
|
onPanUpdate: (details) {
|
||||||
_filamentController.panUpdate(
|
_rotate
|
||||||
details.localPosition.dx, details.localPosition.dy);
|
? _filamentController.rotateUpdate(
|
||||||
|
details.localPosition.dx, details.localPosition.dy)
|
||||||
|
: _filamentController.panUpdate(
|
||||||
|
details.localPosition.dx, details.localPosition.dy);
|
||||||
},
|
},
|
||||||
onPanEnd: (d) {
|
onPanEnd: (d) {
|
||||||
_filamentController.panEnd();
|
_rotate
|
||||||
|
? _filamentController.rotateEnd()
|
||||||
|
: _filamentController.panEnd();
|
||||||
},
|
},
|
||||||
child: Stack(children: [
|
child: Stack(children: [
|
||||||
FilamentWidget(controller: _filamentController),
|
FilamentWidget(controller: _filamentController),
|
||||||
Column(children: [
|
Column(mainAxisSize: MainAxisSize.min, children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
child: Text("initialize"),
|
child: Text("initialize"),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -63,9 +71,9 @@ class _MyAppState extends State<MyApp> {
|
|||||||
"assets/default_env/default_env_ibl.ktx");
|
"assets/default_env/default_env_ibl.ktx");
|
||||||
_filamentController.loadGltf(
|
_filamentController.loadGltf(
|
||||||
"assets/guy.gltf", "assets", "Material");
|
"assets/guy.gltf", "assets", "Material");
|
||||||
_filamentController.createMorpher(
|
// _filamentController.createMorpher(
|
||||||
"CC_Base_Body.003", "CC_Base_Body.003",
|
// "CC_Base_Body.003", "CC_Base_Body.003",
|
||||||
materialName: "Material");
|
// materialName: "Material");
|
||||||
}),
|
}),
|
||||||
// ElevatedButton(
|
// ElevatedButton(
|
||||||
// child: Text("load skybox"),
|
// child: Text("load skybox"),
|
||||||
@@ -121,13 +129,20 @@ class _MyAppState extends State<MyApp> {
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
Row(children: [
|
Row(children: [
|
||||||
|
Checkbox(
|
||||||
|
value: _rotate,
|
||||||
|
onChanged: (v) {
|
||||||
|
setState(() {
|
||||||
|
_rotate = v == true;
|
||||||
|
});
|
||||||
|
}),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => _filamentController.zoom(1.0),
|
onPressed: () => _filamentController.zoom(100.0),
|
||||||
child: Text("+")),
|
child: Text("+")),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => _filamentController.zoom(-1.0),
|
onPressed: () => _filamentController.zoom(-100.0),
|
||||||
child: Text("-"))
|
child: Text("-"))
|
||||||
])
|
]),
|
||||||
]),
|
]),
|
||||||
])),
|
])),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -71,6 +71,18 @@ static void* freeResourceGlobal(void* mem, size_t size, void* misc) {
|
|||||||
if(!_viewer)
|
if(!_viewer)
|
||||||
return;
|
return;
|
||||||
_viewer->manipulator->grabEnd();
|
_viewer->manipulator->grabEnd();
|
||||||
|
} else if([@"rotateStart" isEqualToString:call.method]) {
|
||||||
|
if(!_viewer)
|
||||||
|
return;
|
||||||
|
_viewer->manipulator->grabBegin([call.arguments[0] intValue], [call.arguments[1] intValue], false);
|
||||||
|
} else if([@"rotateUpdate" isEqualToString:call.method]) {
|
||||||
|
if(!_viewer)
|
||||||
|
return;
|
||||||
|
_viewer->manipulator->grabUpdate([call.arguments[0] intValue], [call.arguments[1] intValue]);
|
||||||
|
} else if([@"rotate End" isEqualToString:call.method]) {
|
||||||
|
if(!_viewer)
|
||||||
|
return;
|
||||||
|
_viewer->manipulator->grabEnd();
|
||||||
} else if([@"createMorpher" isEqualToString:call.method]) {
|
} else if([@"createMorpher" isEqualToString:call.method]) {
|
||||||
_viewer->createMorpher([call.arguments[0] UTF8String], [call.arguments[1] UTF8String],[call.arguments[2] UTF8String]);
|
_viewer->createMorpher([call.arguments[0] UTF8String], [call.arguments[1] UTF8String],[call.arguments[2] UTF8String]);
|
||||||
} else if([@"applyWeights" isEqualToString:call.method]) {
|
} else if([@"applyWeights" isEqualToString:call.method]) {
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ abstract class FilamentController {
|
|||||||
Future panStart(double x, double y);
|
Future panStart(double x, double y);
|
||||||
Future panUpdate(double x, double y);
|
Future panUpdate(double x, double y);
|
||||||
Future panEnd();
|
Future panEnd();
|
||||||
|
Future rotateStart(double x, double y);
|
||||||
|
Future rotateUpdate(double x, double y);
|
||||||
|
Future rotateEnd();
|
||||||
Future applyWeights(List<double> weights, int primitiveIndex);
|
Future applyWeights(List<double> weights, int primitiveIndex);
|
||||||
Future createMorpher(String meshName, String entityName,
|
Future createMorpher(String meshName, String entityName,
|
||||||
{String? materialName});
|
{String? materialName});
|
||||||
@@ -58,6 +61,18 @@ class MimeticFilamentController extends FilamentController {
|
|||||||
await _channel.invokeMethod("panEnd");
|
await _channel.invokeMethod("panEnd");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future rotateStart(double x, double y) async {
|
||||||
|
await _channel.invokeMethod("rotateStart", [x.toInt(), y.toInt()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future rotateUpdate(double x, double y) async {
|
||||||
|
await _channel.invokeMethod("rotateUpdate", [x.toInt(), y.toInt()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future rotateEnd() async {
|
||||||
|
await _channel.invokeMethod("rotateEnd");
|
||||||
|
}
|
||||||
|
|
||||||
Future applyWeights(List<double> weights, int primitiveIndex) async {
|
Future applyWeights(List<double> weights, int primitiveIndex) async {
|
||||||
await _channel.invokeMethod("applyWeights", [weights, primitiveIndex]);
|
await _channel.invokeMethod("applyWeights", [weights, primitiveIndex]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user