Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing error, adapting dart2 #3

Merged
merged 1 commit into from
Jul 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions lib/flutter_3d_obj.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class _ObjectPainter extends CustomPainter {
_viewPortY = (size.height / 2).toDouble();
}

Map<String, List<List<int>>> _parseObjString(String objString) {
Map _parseObjString(String objString) {
List vertices = <Vector3>[];
List faces = <List<int>>[];
List<int> face = [];
Expand All @@ -175,9 +175,10 @@ class _ObjectPainter extends CustomPainter {

Vector3 vertex;

lines.forEach((String line) {
line = line.replaceAll(new RegExp(r"\s+$"), "");
List<String> chars = line.split(" ");
lines.forEach((dynamic line) {
String lline = line;
lline = lline.replaceAll(new RegExp(r"\s+$"), "");
List<String> chars = lline.split(" ");

// vertex
if (chars[0] == "v") {
Expand Down Expand Up @@ -296,8 +297,9 @@ class _ObjectPainter extends CustomPainter {
path.lineTo(secondVertexX, secondVertexY);
}
var z = 0.0;
face.forEach((int x) {
z += verticesToDraw[x - 1].z;
face.forEach((dynamic x) {
int xx = x;
z += verticesToDraw[xx - 1].z;
});

path.close();
Expand All @@ -322,12 +324,13 @@ class _ObjectPainter extends CustomPainter {
verticesToDraw[i] = _calcDefaultVertex(verticesToDraw[i]);
}

final List avgOfZ = <Map>[];
final List<Map> avgOfZ = List();
for (int i = 0; i < faces.length; i++) {
List face = faces[i];
double z = 0.0;
face.forEach((int x) {
z += verticesToDraw[x - 1].z;
face.forEach((dynamic x) {
int xx = x;
z += verticesToDraw[xx - 1].z;
});
Map data = <String, dynamic>{
"index": i,
Expand Down