Hyou
Hyou

Reputation: 77

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

Upvotes: 3

Views: 10010

Answers (4)

Edvan Souza
Edvan Souza

Reputation: 1128

I have had this problem, the problem it was happening, because in the path to the project where my project was, had a directory with name "Project c#". /Path/to/Project/Project c#/myproject. I just rename the path to remove # from the directory name and works.

Upvotes: 1

Samdvich
Samdvich

Reputation: 1

this is usually caused by lockfiles or node_modules/.cache/vite (or maybe in your case node_modules/.vite)

Upvotes: 0

Kyouma
Kyouma

Reputation: 400

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

Upvotes: 7

Hyou
Hyou

Reputation: 77

Already solve this question.

When the commandline mentioned vite error, just need to close dev-server, then reload. Vite would clean the cache tmp files in .vite.

Upvotes: 0

Related Questions