I am trying to load a usdz file in browser using React and THreejs. Here is my code implementation. However, I keep getting error in console that could not load test.usdz
import React, { useState } from “react”;
import { useLoader } from “@react-three/fiber”;
import { USDZLoader } from “three/examples/jsm/loaders/USDZLoader”;
function App() {
const [usdz, setUsdz] = useState(null);
So saeukkang.usdz does not work for you? It seems it is the file from the official example and it should load without issues (see three.js webgl - loaders - USDZLoader).
However, Room.usdz throws an error:
ncaught (in promise) TypeError: Cannot read properties of undefined (reading 'replace')
at findMeshGeometry (USDZLoader.js:242:29)
at buildObject (USDZLoader.js:577:36)
at buildHierarchy (USDZLoader.js:605:19)
at buildHierarchy (USDZLoader.js:615:6)
at buildHierarchy (USDZLoader.js:615:6)
at buildHierarchy (USDZLoader.js:615:6)
at USDZLoader.parse (USDZLoader.js:625:3)
at FileReader.<anonymous> (Loader.js:670:37)
Is the room asset generated with Apple’s RoomPlan?
Thanks for sharing the live example! After debugging, it seems your issue is related to how you use react-three-fiber. I’m not familiar with this project so I hope somebody else from the community can have a look at your code.
@Mugen87 - Thanks. I was able to implement the usecase. However, I have a few issues. I downloaded this file (https://solarsystem.nasa.gov/resources/2401/cassini-3d-model/) but in console, it says no USDA file found. And also Room.usdz is not working. Any idea what’s going on here? All I can run is the file used in your example. Room.usdz (33.8 KB)