【发布时间】:2012-08-02 17:39:45
【问题描述】:
所以我一直在玩 Three.JS(图形/动画不是我的强项)并想出了这个,改编自一个教程:
如您所见,我几乎可以肯定是 3D 动画天才。我跑题了……
我的问题是:如何让对象围绕其中心旋转 - 而不是像目前那样围绕肢体旋转?
我知道particle.rotation.set 方法,但我不知道要传递什么值,而且我似乎在 Three.JS 文档中找不到这个方法。环顾四周,我看到人们将0 值传递给它,其他人传递Math.PI 派生值。简而言之,我不确定我在做什么。显然这应该在makeParticles函数中使用(如下所示):
function makeParticles() {
var particle, material;
// add random particles from close up to far away
for ( var zpos= -1000; zpos < 1000; zpos+=20 ) {
// create particle, setting random colour and calling particle renderer
material = new THREE.ParticleCanvasMaterial({
color: '0x'+(function() {
var ret = '';
for (var i=0; i<6; i++)
ret += hex_chars.charAt(Math.floor(Math.random() * hex_chars.length));
return ret;
})(),
program: particleRender
});
// make the particle and set positional properties (random X / Y)
particle = new THREE.Particle(material);
particle.position.x = Math.random() * 1000 - 500;
particle.position.y = Math.random() * 1000 - 500;
particle.position.z = zpos;
// scale and add to scene
particle.scale.x = particle.scale.y = 50;
scene.add( particle );
// and to the array of particles.
particles.push(particle);
}
}
【问题讨论】:
标签: canvas rotation webgl three.js