requestAnimFrame未定义

时间:2017-06-17 04:54:51

标签: javascript

我正在使用javascript构建自己的自定义引擎(不要问为什么)

我的代码工作正常,直到我添加了bline算法进行线条绘制(比使用递归函数快得多)然后突然这个代码坏了,我不完全确定为什么

这是控制台中显示的错误

Uncaught ReferenceError: requestAnimFrame is not defined at HTMLDocument.init (main.js?v=0.0.6:40)

这是代码

function init() {
    canvas = document.getElementById("frontBuffer");
    mera = new GameCore.Camera();
    device = new GameCore.Device(canvas);
    mesh = new GameCore.Mesh("Cube", 8, 12);
    meshes.push(mesh);
    mesh.Vertices[0] = new BABYLON.Vector3(-1, 1, 1);
    mesh.Vertices[1] = new BABYLON.Vector3(1, 1, 1);
    mesh.Vertices[2] = new BABYLON.Vector3(-1, -1, 1);
    mesh.Vertices[3] = new BABYLON.Vector3(1, -1, 1);
    mesh.Vertices[4] = new BABYLON.Vector3(-1, 1, -1);
    mesh.Vertices[5] = new BABYLON.Vector3(1, 1, -1);
    mesh.Vertices[6] = new BABYLON.Vector3(1, -1, -1);
    mesh.Vertices[7] = new BABYLON.Vector3(-1, -1, -1);
    mesh.Faces[0] = { A:0, B:1, C:2 };
    mesh.Faces[1] = { A:1, B:2, C:3 };
    mesh.Faces[2] = { A:1, B:3, C:6 };
    mesh.Faces[3] = { A:1, B:5, C:6 };
    mesh.Faces[4] = { A:0, B:1, C:4 };
    mesh.Faces[5] = { A:1, B:4, C:5 };

    mesh.Faces[6] = { A:2, B:3, C:7 };
    mesh.Faces[7] = { A:3, B:6, C:7 };
    mesh.Faces[8] = { A:0, B:2, C:7 };
    mesh.Faces[9] = { A:0, B:4, C:7 };
    mesh.Faces[10] = { A:4, B:5, C:6 };
    mesh.Faces[11] = { A:4, B:6, C:7 };

    mera.Position = new BABYLON.Vector3(0, 0, 10);
    mera.Target = new BABYLON.Vector3(0, 0, 0);

    requestAnimFrame(drawingLoop);
}

1 个答案:

答案 0 :(得分:1)

实际上它是requestAnimationFrame()