pmndrs / drei

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

ERROR: url.lastIndexOf is not a function #1942

Open branaust opened 5 months ago

branaust commented 5 months ago

Problem description:

Recieving url.lastIndexOf is not a function on initialization

Relevant code:

/*
Auto-generated by: https://github.com/pmndrs/gltfjsx
*/

import * as THREE from "three";
import React from "react";
import { useGLTF } from "@react-three/drei/native";
import { GLTF } from "three-stdlib";
import modelPath from "../assets/model.glb";

type GLTFResult = GLTF & {
  nodes: {
    Torus002: THREE.Mesh;
  };
  materials: {
    Material: THREE.MeshStandardMaterial;
  };
};

const Model = (props: JSX.IntrinsicElements["group"]) => {
  const { nodes, materials } = useGLTF(modelPath) as GLTFResult;

  return (
    <group {...props} dispose={null} scale={2}>
      <mesh
        castShadow
        receiveShadow
        geometry={nodes.Torus002.geometry}
        material={materials.Material}
      />
    </group>
  );
};

useGLTF.preload(modelPath);

export default Model;
import Model from "@/components/Model";
import { View } from "@/components/Themed";
import { Canvas } from "@react-three/fiber/native";
import { Suspense } from "react";

const Home = () => {
  return (
    <View style={{ flex: 1 }}>
      <Canvas>
        <Suspense fallback={null}>
          <Model />
        </Suspense>
      </Canvas>
    </View>
  );
};

export default Home;
dmitryshostak commented 2 months ago

Any updates on this issue?

netgfx commented 2 months ago

Does the error occur if you do const { nodes, materials } = useGLTF('../assets/model.glb') as GLTFResult; ?