Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not load files like gltf png #2

Open
rasulali opened this issue May 25, 2021 · 3 comments
Open

Can not load files like gltf png #2

rasulali opened this issue May 25, 2021 · 3 comments

Comments

@rasulali
Copy link

rasulali commented May 25, 2021

I'm using webpack as a bundler and I can load 3d objects from three's own basic shapes and change color and everything but whenever I have to load files from an external source like gltf, png files from the project's own folder It doesn't show. I'm running it on dev server btw. I'm quite new to overall web design so I don't know what more info I should give right now.
edit: I managed to get it working with npm webpack --watch and live server. Its something to do with dev server. Although I can use it with live server (extension) anyway I would be glad to use it with dev server as well

@rasulali
Copy link
Author

I'm using webpack as a bundler and I can load 3d objects from three's own basic shapes and change color and everything but whenever I have to load files from an external source like gltf, png files from the project's own folder It doesn't show. I'm running it on dev server btw. I'm quite new to overall web design so I don't know what more info I should give right now.

@Bonnysartaz
Copy link

maybe the problem is cors , try with cors enabled

@SunlightWings
Copy link

Type the following to import glb loader:
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';

Then use the 3d object (say glass) in your code as:
let glass;
const gltfLoader = new GLTFLoader();
gltfLoader.load('glass.glb', (gltf) => {
glass = gltf.scene;
scene.add(earth);
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants