我在THREE.js中有这段代码
var RASToLPS = new THREE.Matrix4();
RASToLPS.set(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
mesh.applyMatrix(RASToLPS);
scene.add(mesh);我想把它转换成react-three-fiber。我尝试了下面的代码,但它不起作用:
<mesh
{...props}
geometry = {bufferGeometry}
material = {material}
applyMatrix4 = {matrix4 => {
matrix4.set(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
}}
>
</mesh>发布于 2020-12-30 03:08:54
我使用下面的代码在没有applyMatrix4 mesh属性的情况下让它工作:
const Component = ({
bufferGeometry,
material,
}) => {
const mesh = useRef<THREE.Mesh>()
useEffect(() => {
if (mesh.current) {
const RASToLPS = new THREE.Matrix4()
RASToLPS.set(-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
mesh.current.applyMatrix4(RASToLPS)
}
}, [mesh])
return (
<mesh
geometry = {bufferGeometry}
material = {material}
ref={mesh}
>
</mesh>
)
}如果有人知道如何使用applyMatrix4,请回答。
发布于 2021-01-02 14:13:42
不是全部答案(我也有类似的问题),但是在你的原始代码mesh attrs上试试以下代码:
applyMatrix4替换为matrix (applyMatrix4可能已失效?)https://stackoverflow.com/questions/65496749
复制相似问题