Skip to content

Commit

Permalink
read too many vertices
Browse files Browse the repository at this point in the history
  • Loading branch information
timknip committed Jan 27, 2010
1 parent 92a8c1a commit 9143014
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README
Expand Up @@ -7,6 +7,12 @@ if you have experience with lib3ds, many objects will look familiar (Lib3dsMesh
At the moment only meshes are read: vertices, faces and texels.
No materials etc. yet.

NOTE:
I didn't actually test this, so... one thing: Endian.
Default is now little endian, You might want to pass 'true' as
first argument to the BinaryParser constructor to setup big endian.


TODO
=======================================================
Much :-)
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -25,7 +25,7 @@
}
</script>
</head>
<body onload="loadFile('MIG-21.3ds')">
<body onload="loadFile('bobafett.3ds')">
<div id="dbg"></div>
</body>
</html>
10 changes: 6 additions & 4 deletions js/lib3ds.js
Expand Up @@ -305,13 +305,11 @@ with ({p:Lib3ds.prototype}) {
case POINT_ARRAY:
mesh.points = this.readWord(data);
mesh.pointL = [];
this.log (" -> #points: " + mesh.points);
for (i = 0; i < mesh.points; i++) {
this.log (" -> #points: " + mesh.points + " " + this.position);
for (i = 0; i < mesh.points-1; i++) {
var vec = [];
for (j = 0; j < 3; j++) {
vec.push(this.readFloat(data));
vec.push(this.readFloat(data));
vec.push(this.readFloat(data));
}
mesh.pointL.push(vec);
}
Expand Down Expand Up @@ -432,9 +430,13 @@ with ({p:Lib3ds.prototype}) {
}

p.readFloat = function(data) {
try {
var v = this.parser.toFloat(data.substr(this.position, 4));
this.position += 4;
return v;
} catch(e) {
this.log("" + e + " " + this.position + " " + data.length);
}
}

p.readInt = function(data) {
Expand Down

0 comments on commit 9143014

Please sign in to comment.