1

我有这个代码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>
4

2 回答 2

1

我设法使用以下代码使其在没有applyMatrix4网格属性的情况下工作:

    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请回答。

于 2020-12-29T19:08:54.450 回答
0

不是全部答案(我遇到了类似的问题),但在您的原始代码mesh属性上尝试以下操作:

  • 替换applyMatrix4matrix(applyMatrix4 可能已失效?)
于 2021-01-02T06:13:41.647 回答