I get a model from https://sketchfab.com/3d-models/ftm-0970f30574d047b1976ba0aa6f2ef855.But I fail to load it,though console doesn’t show any error. I test it on chrome with VSCode plugin Live Server. Here is console output.
My questions are
-
I wonder what went wrong.
-
How to use MongoDB to store 3D model? Is there a tutorial?
My code is below. GLTFLoader.js is from https://github.com/mrdoob/three.js/blob/be0a6d6e55692360a39d038fd32d6800531a26b1/examples/js/loaders/GLTFLoader.js
<script src="three.js"></script>
<script src="GLTFLoader.js"></script>
<script>
let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
10,
5000
);
var loader = new THREE.GLTFLoader();
loader.load(
'scene.gltf',
function (gltf) {
console.log(gltf.scene);
console.log(gltf.scenes);
// I think problem is here.
scene.add(gltf.scene);
},
undefined,
function (error) {
console.error(error);
}
);
camera.position.z = 100;
</script>