1

我正在寻找示例代码,它将展示如何THREE.CubeGeometry在 ThreeJS 中使用CSS3DRenderer. 像下面的东西

var my_cube = new **CSS3dCubeGeometry**( cube_width, cube_height, cube_depth)

var object = new THREE.CSS3DObject( my_cube );

scene.add( object );

THREE.CSS3DObject不存在,我正在寻找它的潜在实现。

4

1 回答 1

4

您可以像这样创建一个多维数据集CSS3DRenderer

// params
var r = Math.PI / 2;
var d = 50;
var pos = [ [ d, 0, 0 ], [ -d, 0, 0 ], [ 0, d, 0 ], [ 0, -d, 0 ], [ 0, 0, d ], [ 0, 0, -d ] ];
var rot = [ [ 0, r, 0 ], [ 0, -r, 0 ], [ -r, 0, 0 ], [ r, 0, 0 ], [ 0, 0, 0 ], [ 0, 0, 0 ] ];

// cube
var cube = new THREE.Object3D();
scene.add( cube );

// sides
for ( var i = 0; i < 6; i ++ ) {

    var element = document.createElement( 'div' );
    element.style.width = '100px';
    element.style.height = '100px';
    element.style.background = new THREE.Color( Math.random() * 0xffffff ).getStyle();
    element.style.opacity = '0.50';

    var object = new THREE.CSS3DObject( element );
    object.position.fromArray( pos[ i ] );
    object.rotation.fromArray( rot[ i ] );
    cube.add( object );

}

小提琴:http: //jsfiddle.net/MdPrb/7

三.js r.64

于 2013-05-31T19:51:46.963 回答