3d
unknown
dart
2 years ago
3.8 kB
11
Indexable
import 'package:flutter/material.dart'; import 'package:flutter_cube/flutter_cube.dart'; import 'package:get/get.dart'; import 'main.dart'; class Balik3d extends StatefulWidget { const Balik3d({Key? key}) : super(key: key); @override State<Balik3d> createState() => _Balik3dState(); } class _Balik3dState extends State<Balik3d> with SingleTickerProviderStateMixin { final Degiskenler d = Get.find(); late Object isci; late Object isci2; late Scene _scene; late AnimationController _animasyon; @override void initState() { isci = Object(fileName: '3d/workermanOBJ.obj'); isci2 = Object(fileName: '3d/workermanOBJ.obj'); // isci.position.setValues(d.x.value, d.y.value, d.z.value); _animasyon = AnimationController( duration: const Duration(milliseconds: 200), vsync: this) ..addListener(() { if (isci != null) { isci!.rotation.z = d.z.value; //_controller.value * 360; isci!.rotation.y = d.y.value; isci!.rotation.x = d.x.value; _scene.camera.zoom = d.zoom.value; //isci 2 isci2!.rotation.z = d.z.value; isci2!.rotation.y = d.y.value; isci2!.rotation.x = d.x.value; _scene.camera.zoom = d.zoom.value; isci2!.updateTransform(); isci!.updateTransform(); _scene.update(); } }) ..repeat(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("3D"), ), body: Column( children: [ SizedBox( width: 300, height: 300, child: Container( child: Cube( // interactive: true, onSceneCreated: (Scene scene) { scene.world.add(isci); scene.world.add(isci2); scene.camera.zoom = d.zoom.value; isci.position.setValues(d.x.value, d.y.value, d.z.value); isci2.position .setValues(d.x.value + 1, d.y.value + 1, d.z.value + 1); _scene = scene; isci.updateTransform(); isci2.updateTransform(); }, ), ), ), Row( children: [ ElevatedButton( onPressed: () { d.x.value = d.x.value + 5; }, child: const Text("x +")), ElevatedButton( onPressed: () { d.x.value = d.x.value - 5; }, child: const Text("x -")), ElevatedButton( onPressed: () { d.y.value = d.y.value + 5; }, child: const Text("y +")), ElevatedButton( onPressed: () { d.y.value = d.y.value - 5; }, child: const Text("y -")), ElevatedButton( onPressed: () { d.z.value = d.z.value + 5; }, child: const Text("z +")), ElevatedButton( onPressed: () { d.z.value = d.z.value - 5; }, child: const Text("z -")), ElevatedButton( onPressed: () { d.zoom.value = d.zoom.value - 1; }, child: const Text("zoom -")), ElevatedButton( onPressed: () { d.zoom.value = d.zoom.value + 1; }, child: const Text("zoom +")), ], ) ], ), ); } }
Editor is loading...