-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.dart
139 lines (128 loc) · 4.18 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import 'package:flutter/material.dart';
import 'package:simple_3d/simple_3d.dart';
import 'package:util_simple_3d/util_simple_3d.dart';
import 'package:simple_3d_renderer/simple_3d_renderer.dart';
void main() async {
runApp(const MyApp());
}
String shape = "cube";
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Index(),
);
}
}
class Index extends StatelessWidget {
const Index({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text("3D -VR")),
backgroundColor: Colors.black,
body: Column(
children: [
Sp3dRenderer(
const Size(400, 400),
const Sp3dV2D(200, 300),
shapebuilder(shape),
Sp3dCamera(Sp3dV3D(0, 0, 3000), 6000),
Sp3dLight(Sp3dV3D(0, 0, -1), syncCam: true),
),
],
),
floatingActionButton: FloatingActionButton(onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return const Settings();
}));
}, child: const Icon(Icons.settings),),
),
);
}
}
class Settings extends StatelessWidget {
const Settings({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Row(
children: [
IconButton(onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return const Index();
}));
}, icon: const Icon(Icons.arrow_back)),
const Text("Settings")
],
),
),
body: Column(
children: [
const SizedBox(height: 20,),
const Padding(
padding: EdgeInsets.all(10),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween,children: [
Text("Select shape ", style: TextStyle(fontSize: 23),),
DropDownWidget(),
],),
),
ElevatedButton(onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return const Index();
}));
}, child: const Text("Apply")),
const Text("Made by Abhineet Raj")
],
),
),
);
}
}
class DropDownWidget extends StatefulWidget {
const DropDownWidget({super.key});
@override
State<DropDownWidget> createState() => _DropDownWidgetState();
}
class _DropDownWidgetState extends State<DropDownWidget> {
@override
Widget build(BuildContext context) {
return DropdownButton(
value: shape,
items: const [
DropdownMenuItem(value: "cube", child: Text("cube")),
DropdownMenuItem(value: "capsule", child: Text("capsule")),
DropdownMenuItem(value: "cone", child: Text("cone")),
DropdownMenuItem(value: "circle", child: Text("circle")),
DropdownMenuItem(value: "sphere", child: Text("sphere")),
DropdownMenuItem(value: "pillar", child: Text("pillar")),
DropdownMenuItem(value: "tile", child: Text("tile")),
], onChanged: (value) {
setState(() {
shape = value!;
});
}
);
}
}
Sp3dWorld shapebuilder(String shape) {
if (shape == "capsule") {
return Sp3dWorld([UtilSp3dGeometry.capsule(50, 160)]);
} else if (shape == "circle") {
return Sp3dWorld([UtilSp3dGeometry.circle(100)]);
} else if (shape == "cone") {
return Sp3dWorld([UtilSp3dGeometry.cone(50, 100)]);
} else if (shape == "cube") {
return Sp3dWorld([UtilSp3dGeometry.cube(100, 100, 100, 1, 1, 1)]);
} else if (shape == "pillar") {
return Sp3dWorld([UtilSp3dGeometry.pillar(50, 50, 150)]);
} else if (shape == "sphere") {
return Sp3dWorld([UtilSp3dGeometry.sphere(100)]);
} else {
return Sp3dWorld([UtilSp3dGeometry.tile(100, 50, 40, 20)]);
}
}