Hey ive been having a few problems with npm run build it seems that texture from useTextures seem to go missing after the build but work fine in test:
I had some earlier problems with the glb files but i fixed them by importing them directly like so:
i tried to do the same with the textures but it said that they were not iterable straight after as a result is there a correct way that i can get vite build/rollup to recognise the texture and include them in the build?
At the moment heres how im importing them is there something i’m missing like something in the props or maybe the vite js config?
function CardZf() {
const [tex1] = useTexture(["/src/components/threeComp/img/pp3front.jpg"]);
return (
<mesh>
<planeGeometry args={[12, 17]} />
<meshStandardMaterial map={tex1} transparent={true} />
</mesh>
);
}
function CardZb() {
const [tex1] = useTexture(["/src/components/threeComp/img/joshpx2.jpg"]);
return (
<mesh>
<boxGeometry args={[12, 17, 0.1]} />
<meshStandardMaterial
side={BackSide}
transparent={true}
map={tex1}
toneMapped={false}
/>
</mesh>
);
}
return (
<group {...props} rotation={[0, 0, 0.4]} ref={ref}>
<CardZf />
<CardZb />
</group>
);
}
my config:
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
glsl(),
svgr(),
Unfonts({
custom: {
display: "swap",
families: {
Glusp: {
src: "./public/fOnt/OTF® Glusp.ttf",
},
},
},
}),
],
assetsInclude: ["**/*.glb", "**/*.svg"],
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes("node_modules")) {
return id
.toString()
.split("node_modules/")[1]
.split("/")[0]
.toString();
}
},
},
},
},
});