首页 > 代码库 > 一些关于three.js的摘抄笔记

一些关于three.js的摘抄笔记

加载多个geometry的方式:

(可以利用three.js自带convert_obj_three.py文件将obj文件转换成json文件)

function loadModel() {
    loader = new THREE.JSONLoader();
    loader.load("js/your_model.js", function( geometry ) {
    box = [];

    group = new THREE.Object3D();
    scene.add(group);

            // here i‘m creating 3 objects of same model
    for (var i = 0; i < 3; i++)
    {
        box[i] = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture("js/your_texture.jpg")}));
        box[i].scale.set(20,20,20);
        box[i].position.x = (120*i) - 150;
        group.add(box[i]);
    }
        callSomeFunctionOnceLoaded();
        },"js"
    );
}

 

附一个学习地址:

http://stemkoski.github.io/Three.js/

http://helloenjoy.com/2013/from-unity-to-three-js/

一些关于three.js的摘抄笔记