pmndrs / drei

🥉 useful helpers for react-three-fiber
https://docs.pmnd.rs/drei
MIT License
8.27k stars 682 forks source link

Could not load: Property 'Image' does not exist #1946

Closed truesteps closed 5 months ago

truesteps commented 5 months ago

What is your question:

Heya! I'm trying to render a gltf model onto my scene, following https://www.youtube.com/watch?v=O8q8H9c9XZ4 this tutorial, but whenver I put my model into the Canvas in Suspense, I get the following error: Could not load: Property 'Image' does not exist. I'm pasting the model code below, generated by GltfJsx from a website that is linked in the videotutorial. Anyone could help me with thisone? I've been stuck on it for a while now and google unfortunately didn't help.

Also attaching screen of error:

Screenshot 2024-05-01 at 11 23 51

Thx in advance.

import * as THREE from 'three';
import React from 'react';
import {useGLTF} from '@react-three/drei/native';
import {GLTF} from 'three-stdlib';

type GLTFResult = GLTF & {
  nodes: {
    Couch002: THREE.Mesh;
    Couch_legs002: THREE.Mesh;
    Cube004: THREE.Mesh;
  };
  materials: {
    ['Material.005']: THREE.MeshStandardMaterial;
    ['Material.008']: THREE.MeshStandardMaterial;
    ['Material.006']: THREE.MeshStandardMaterial;
  };
};

export default function CompressedChair(props: JSX.IntrinsicElements['group']) {
  const {nodes, materials} = useGLTF(
    require('../assets/compressedChair.glb'),
  ) as GLTFResult;
  return (
    <group {...props} dispose={null}>
      <mesh
        castShadow
        receiveShadow
        geometry={nodes.Couch002.geometry}
        material={materials['Material.005']}
        position={[0.624, 0.535, 0.356]}
        rotation={[0, 1.571, 0]}
      />
      <mesh
        castShadow
        receiveShadow
        geometry={nodes.Couch_legs002.geometry}
        material={materials['Material.008']}
        position={[0.562, 0.535, 0.563]}
        rotation={[0, 1.571, 0]}
        scale={[0.808, 0.808, 0.758]}
      />
      <mesh
        castShadow
        receiveShadow
        geometry={nodes.Cube004.geometry}
        material={materials['Material.006']}
        position={[0.78, 1.044, 0.813]}
        rotation={[1.601, 0.906, -2.105]}
      />
    </group>
  );
}

useGLTF.preload(require('../assets/compressedChair.glb'));
netgfx commented 5 months ago

Can you check the network tab on the dev tools to see if there is a request that fails? Perhaps it is trying to load a texture from somewhere. Otherwise if you could make a codesandbox or something so we can see it in action it would help

truesteps commented 5 months ago

@netgfx there is also this warning that pops up:

Screenshot 2024-05-01 at 11 45 52

I'm working on setting up devtools :D i'm running this in react native

netgfx commented 5 months ago

ah ok you should have mentioned this, react-native is quite different from web react. It seems that it is trying to fetch an asset but it can't. Have you tried with another .glb file? one that has no textures or they are in-fact embedded within?

truesteps commented 5 months ago

I tried using the model in the tutorial, and it worked. Seems like there might be an issue wit the model. Thanks, i'll try and re-export it

truesteps commented 5 months ago

@netgfx ended up being some sort of issue with a compressed glb output from blender. Do you know any tips or tricks as to how to optimize glb/gltf formats without it becoming unusuable? But the issue is fixed :) thanks for pointing me in the right direction