当我们使用three.js loader.load()时,如何在全局变量中保存回调的参数

时间:2017-03-03 11:59:15

标签: javascript three.js

请先查看代码:

    var o = null;
    var loader = new THREE.STLLoader();
    loader.load("../model/Ban.stl",function(obj){
        o = obj;
        objectSTL = new THREE.Mesh(obj,mesh3);
        objectSTL.scale.set(0.06,0.06,0.06)
        wheelCenterPoint.add(objectSTL);
        console.log(1)
    });
    console.log(o);

chrome输出的信息是: enter image description here

chrome首先打印“null”,然后“1”,所以,我想问一下如何使“o”保存“obj”?

0 个答案:

没有答案