Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在three.js中旋转精灵对象?_Three.js_Rotation_Sprite - Fatal编程技术网

如何在three.js中旋转精灵对象?

如何在three.js中旋转精灵对象?,three.js,rotation,sprite,Three.js,Rotation,Sprite,我需要旋转一个精灵对象,但这似乎是不可行的,如果不可行,有没有办法实现旋转效果,可能是通过spriteMaterial的UV坐标,或者自定义着色器?最好的方法是什么?精灵的旋转由其材质的旋转参数设置。例如,像这样: var material = new THREE.SpriteMaterial( { color: 0xffffff, map: texture, rotation: Math.PI / 4 } ); var sprite = new THREE.Spri

我需要旋转一个精灵对象,但这似乎是不可行的,如果不可行,有没有办法实现旋转效果,可能是通过spriteMaterial的UV坐标,或者自定义着色器?最好的方法是什么?

精灵的旋转由其材质的
旋转
参数设置。例如,像这样:

var material = new THREE.SpriteMaterial( {
    color: 0xffffff, 
    map: texture,
    rotation: Math.PI / 4
} );

var sprite = new THREE.Sprite( material );

three.js r.67

我花了很长时间,但结果是需要旋转精灵材质,而不是精灵本身。像这样:

var scale = 1;

function animate() {
    requestAnimationFrame(animate);

    // Rotate the sprite:
    sprite.material.rotation += 0.01;

    // Resize the sprite:
    scale += 0.01
    sprite.scale.set(scale, scale, 0);

    // Move the sprite:
    sprite.position.x += 0.01;

    renderer.render(scene, camera);
}

你要找的是
SpriteMaterial.rotation
吗@谢谢你!快速提示:如果要设置旋转参数的动画,可以更改
sprite.material.rotation