THREE.JS立方体渲染

时间:2014-01-29 00:41:16

标签: three.js cube

是否可以使用Three / Cube渲染更改某些内容?

这是Y轴上的旋转立方体。 是否可以保留多维数据集背面的东西?

像这样的东西 (糟糕的绘图) 是否也可以删除那些小的白线? 我觉得那些很烦人的

我很久以前使用的代码。 R34或者其他什么,如果我没有误会。 任何人都知道R65中是否仍有可能吗?

var camera, scene, renderer;
    init();
    setInterval( loop, 1000 / 60 );
    function init() {
    var height = 300;
    var width = 300;
    camera = new THREE.Camera(10, height/width,10, 1000);
    scene = new THREE.Scene();
    var hat_materials = [
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') }),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') }),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') }),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') }),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') }),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') })
    ];
    hat = new THREE.Mesh( new Cube(8, 8, 8, 1, 1, hat_materials), new THREE.MeshFaceMaterial());
    hat.position.x = 0;
    hat.position.y = -10;
    hat.position.z = 0;
    scene.addObject(hat);  
    renderer = new THREE.CanvasRenderer();
    renderer.setSize( width,height);
    document.getElementById("holder").appendChild(renderer.domElement);

}
var xvar = 0;
function loop() {
    var speed = $("#speed").val() 
    xvar += Math.PI/speed
    camera.target.position.x = 0;
    camera.target.position.y = -11;
    camera.target.position.z = 0;
    camera.position.x = 0 - 100*Math.sin(xvar);
    camera.position.y = 20;
    camera.position.z = 0 - 100*Math.cos(xvar);
    renderer.render( scene, camera );
}

1 个答案:

答案 0 :(得分:0)

尝试双面制作材料:

var material = new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png'),side:THREE.DoubleSide});

所以你的代码是:

var camera, scene, renderer;
    init();
    setInterval( loop, 1000 / 60 );
    function init() {
    var height = 300;
    var width = 300;
    camera = new THREE.Camera(10, height/width,10, 1000);
    scene = new THREE.Scene();
    var hat_materials = [
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') },side:THREE.DoubleSide),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') },side:THREE.DoubleSide),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') },side:THREE.DoubleSide),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') },side:THREE.DoubleSide),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') },side:THREE.DoubleSide),
        new THREE.MeshBasicMaterial({map:ImageUtils.loadTexture('crate1.png') ,side:THREE.DoubleSide})
    ];
    hat = new THREE.Mesh( new Cube(8, 8, 8, 1, 1, hat_materials), new THREE.MeshFaceMaterial());
    hat.position.x = 0;
    hat.position.y = -10;
    hat.position.z = 0;
    scene.addObject(hat);  
    renderer = new THREE.CanvasRenderer();
    renderer.setSize( width,height);
    document.getElementById("holder").appendChild(renderer.domElement);

}
var xvar = 0;
function loop() {
    var speed = $("#speed").val() 
    xvar += Math.PI/speed
    camera.target.position.x = 0;
    camera.target.position.y = -11;
    camera.target.position.z = 0;
    camera.position.x = 0 - 100*Math.sin(xvar);
    camera.position.y = 20;
    camera.position.z = 0 - 100*Math.cos(xvar);
    renderer.render( scene, camera );
}