I don’t know why but my houses are diapering form certain angle as I applied instancing on my GLBs to optimize the overall performance.
Here is the code for instancing the models
interface HouseConfig {
houses: any,
asset: string
}
export const HouseTwo: FC = ({ houses, asset }) => {
const { nodes } = useGLTF(asset);
console.log(nodes);
const meshes = useMemo(() => ({
Tabley001_1: (nodes.Tabley001_1 as THREE.Mesh),
Tabley001_2: (nodes.Tabley001_2 as THREE.Mesh),
Tabley001_3: (nodes.Tabley001_3 as THREE.Mesh),
Tabley001_4: (nodes.Tabley001_4 as THREE.Mesh),
Tabley001_5: (nodes.Tabley001_5 as THREE.Mesh),
Tabley001_6: (nodes.Tabley001_6 as THREE.Mesh),
Tabley001_7: (nodes.Tabley001_7 as THREE.Mesh),
Tabley001_8: (nodes.Tabley001_8 as THREE.Mesh),
Tabley001_9: (nodes.Tabley001_9 as THREE.Mesh),
Tabley001_10: (nodes.Tabley001_10 as THREE.Mesh),
Tabley001_11: (nodes.Tabley001_11 as THREE.Mesh),
Tabley001_12: (nodes.Tabley001_12 as THREE.Mesh),
Tabley001_13: (nodes.Tabley001_13 as THREE.Mesh),
Tabley001_14: (nodes.Tabley001_14 as THREE.Mesh),
}), [nodes]);
return (
{(models:any) => {
return (
{houses.map((house: any, i: any) => {
return ;
})}
);
}}
);
};
const Model = ({ models, data }: { models: any, data: any }) => {
return (
<group
position={[data.position.x, data.position.y, data.position.z]}
rotation={[degreesToRadians(data.rotation.x), degreesToRadians(data.rotation.y), degreesToRadians(data.rotation.z)]}
scale={[0.001, 0.001, 0.001]}
frustumCulled={false}
>
<models.Tabley001_1 />
<models.Tabley001_2 />
<models.Tabley001_3 />
<models.Tabley001_4 />
<models.Tabley001_5 />
<models.Tabley001_6 />
<models.Tabley001_7 />
<models.Tabley001_8 />
<models.Tabley001_9 />
<models.Tabley001_10 />
<models.Tabley001_11 />
<models.Tabley001_12 />
<models.Tabley001_13 />
<models.Tabley001_14 />
);
};