Hi Guys, I am new to three js Let me tell you What I did till now
- Downloaded parcel
- downloaded three js using npm
- added public folder and inside it added .glb file.
- created index.html and the code in it you can find it below
- created index.js file and added code inside it u can find it below
index.html
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<script src="index.js" type="module"></script>
</body>
</html>
index.js
import * as THREE from 'three';
import {GLTFLoader} from 'three/examples/jsm/loaders/GLTFLoader.js';
const loader = new GLTFLoader();
loader.load('/Cartoon_boy.glb', function(glb) {
console.log(glb);
}, undefined, function(error) {
console.error(error);
});
I am getting this kinds of wired error
index.js:9 SyntaxError: Unexpected token '<', "<html>
"... is not valid JSON
at JSON.parse (<anonymous>)
at GLTFLoader.parse (GLTFLoader.js:315:17)
at Object.onLoad (GLTFLoader.js:211:11)
at three.module.js:40387:38