这是我的代码的相关部分:
ajax({
url: "TeaPot.obj",
success: function(data) {
var Script = data.split("\n");
for (var I in Script) {
var Line = Script[I];
console.log(Line);
//If Vertice Line
if (Line.substring(0, 2) == "v ") {
//console.log("CORRECT");
var Row = Line.substring(2).split(" ");
console.log(Row[0]);
verts[verts.length] = new Vector3(parseFloat(Row[0]),parseFloat(Row[1]), parseFloat(Row[2]));
}
}
现在这应该遍历每一行并寻找“v”,但我的 verts 数组仍然没有,有什么理由吗?
哦,obj文件也看起来像这样
v -0.3393 0.0000 -12.3639
v 1.8409 3.7515 -8.3253
我现在有了它,它会将 verts 的长度增加到 96,这是正确的,但是数组没有存储任何内容???
newX = parseFloat(row[1]);
newY = parseFloat(row[2]);
newZ = parseFloat(row[3])
verts.push = new Vector3(newX, newY, newZ);
console.log(verts[verts.length-1]);