Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite error with optimized info should be defined when use GLTFLoader in React(ThreeJS)

I use vite to build one react environment. When I import GLTFLoader from the module, and vite commandline mentioned that:

Vite Error, /node_modules/.vite/deps/three_examples_jsm_loaders_GLTFLoader.js?v=9d4ee121 optimized info should be defined

Here's my code:

import * as Three from "three"
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'

[...]

const gltfLoader = new GLTFLoader()
gltfLoader.setPath('public/')

gltfLoader.load('000.hdr', gltf => {
    gltf.scene.scale.set(0.2,0.2,0.2)
    scenes.add(gltf.scene)
})

Here's the error message: enter image description here

like image 232
Hyou Avatar asked May 15 '26 02:05

Hyou


1 Answers

For others in the future, YMMV: deleting node_modules and pnpm-lock.yaml solved the issue.

like image 97
Kyouma Avatar answered May 16 '26 15:05

Kyouma