I'm working with 3D objects, and suddenly have this issue. I am saving my scene in the server so that when I refresh my the webpage the objects inside the scene will not disappear, but the problem is the objects inside the scene aren't in the right position, they always go in the (0, 0, 0) position, which, I think, shouldn't happen because I already set its position before render, but I don't know if I'm doing it the right way.
const ObjectBuilder = (props) => {
const { geometry, object } = props;
const objRef = useRef();
const matrix = new THREE.Matrix4();
const loader = new THREE.BufferGeometryLoader();
const position = new THREE.Vector3();
const parsedGeom = loader.parse( geometry );
matrix.set(...object.matrix);
position.setFromMatrixPosition( matrix );
const handleClick = (e) => {
e.stopPropagation();
props.click({ data: objRef });
}
console.log('matrix', matrix); //elements: [0, 0, 1111, 0, 50, 0, 0, 0, 0, 50, 0, 0, 0, 0, 1]
console.log('position:', position); // x: 0, y:0, z:0
return(
<mesh
name="map_object"
ref={objRef}
onClick={handleClick}
receiveShadow
castShadow
scale={50}
geometry={parsedGeom}
position={position}
matrix={matrix}
>
<meshStandardMaterial
color="white"
metalness={0.3}
roughness={0.5}
/>
</mesh>
);
}
Thank you guys so much in advance!