我正在尝试旋转四面体,使它们的一侧朝下,就像它们放置在地板上的物理对象一样。
通过为四面体提供 applyMatrix 属性应用接受的答案后,我的代码如下所示:
const Triangle = ({ position, color }) => {
const mesh = useRef(null);
return (
<mesh castShadow ref={mesh} position={position}>
<tetrahedronGeometry
attach="geometry"
args={[0.6, 0]}
applyMatrix={new THREE.Matrix4().makeRotationAxis(
new THREE.Vector3(2, 0, -1).normalize(),
Math.atan(Math.sqrt(2))
)}
/>
<meshStandardMaterial attach="material" color={color} />
</mesh>
);
};
然而,我的四面体的旋转并没有改变。我究竟做错了什么?
这是我当前的代码:小提琴