简体   繁体   English

球体与Threejs的立方体颠簸

[英]Sphere with cube bumps with threejs

i'm surfing on the web trying to solve this problem. 我正在网上尝试解决此问题。 I'm following this example which is pretty cool btw, http://threejs.org/examples/css3d_periodictable.html my question i convert the squares to css cubes but the sphere still cutting them, what i need is to let the cubes bump over the sphere. 我正在跟随这个非常酷的示例, http://threejs.org/examples/css3d_periodictable.html我的问题是我将正方形转换为css立方体,但球体仍在切割它们,我需要的是让立方体碰撞在球上。 Please anyone who can help me with an advice or path to follow or maybe telling me that i using the wrong example to start. 请任何可以帮助我提供建议或方法的人,或者告诉我我使用错误的示例开始的人。 :) I'm new using threejs. :)我是使用Threejs的新手。

Thanks. 谢谢。

As Lee Tylor suggest here is more info about my accomplish: 正如李·泰勒(Lee Tylor)建议的那样,这是有关我的成就的更多信息:

Like i said before i'm following the periodic sample on Threejs, so here is the thing i'm initializing the sphere exactly how the example does except when a words are typed on the inputs the one who matches are transform into cubes, that part is working but on the sides we can see the cubes are flat that what im trying to achive make the cube bumps over the sphere. 就像我之前在Threejs上进行定期采样之前所说的那样,这就是我正在初始化球体的事情,示例的工作方式完全一样,除了在输入中键入单词时,将匹配的单词转换为多维数据集,该部分正在工作,但在侧面我们可以看到立方体是扁平的,我试图达到的效果使立方体在球体上颠簸。 So i'm not sure if this is a css problem or threejs issue. 所以我不确定这是css问题还是threejs问题。

example running: http://dev.certatim.com/panhaptic/sphere_js/ 运行示例: http : //dev.certatim.com/panhaptic/sphere_js/

this is the file were everything happens: dev.certatim.com/panhaptic/sphere_js/app/javascripts/functions.js 这是发生一切的文件:dev.certatim.com/panhaptic/sphere_js/app/javascripts/functions.js

I hope this helps, :( 我希望这有帮助, :(

You can create a cube with CSS3DRenderer like so: 您可以使用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 );

}

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

three.js r.64 three.js r.64

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM