Wynnyy
1
Hi guys,
I tried everything what I found, but nothing happen.
Here is my GitHub code : GITHUB CODE
First error is
GET http://127.0.0.1:5500/ThreeD/ThreeD/shiba/scene.gltf 404 (Not Found)
ProgressEvent {isTrusted: true, lengthComputable: true, loaded: 169, total: 169, type: 'load', …}
and when I add back slash behind ThreeD here
loader.load( '/ThreeD/shiba/scene.gltf
got this
Uncaught (in promise) ReferenceError: scene is not defined
at main.js:8:2
at GLTFLoader.js:119:11
at GLTFLoader.js:1178:9
do you know where is probably problem ?
Wynnyy
3
this is not solution, if I remove that endpoint ThreeD, have same problem
for example without ThreeD when I use “/shiba/scene.gltf”
three.js:20044 GET http://127.0.0.1:5500/shiba/scene.gltf 404 (Not Found)
load @ three.js:20044
load @ GLTFLoader.js:116
(anonymous) @ main.js:6
main.js:12 ProgressEvent {isTrusted: true, lengthComputable: true, loaded: 155, total: 155, type: 'load', …}
I tried rewrite code to
const loader = new GLTFLoader();
var scene = new THREE.Scene();
loader.load( 'shiba/scene.gltf', function ( gltf ) {
scene.add( gltf.scene );
}, undefined, function ( error ) {
console.error( error );
} );
add scene because wasn’t defined,now I don’t have any error, but nothing appear on my screen.
Wynnyy
4
I fix this solution by this code
anyway, always I have to add camera background screen and render ?
import * as THREE from 'https://cdn.skypack.dev/three@0.129.0/build/three.module.js';
import { GLTFLoader } from 'https://cdn.skypack.dev/three@0.129.0/examples/jsm/loaders/GLTFLoader.js';
const loader = new GLTFLoader();
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 25, window.innerWidth / window.innerHeight, 1, 20000 );
camera.position.set( 1, 1, 20 );
var renderer = new THREE.WebGLRenderer({ alpha: false });
renderer.setClearColor( 0xC5C5C3 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
loader.load( 'shiba/scene.gltf', function ( gltf ) {
gltf.scene.scale.set( 1, 1, 1 );
gltf.scene.position.x = 0; //Position (x = right+ left-)
gltf.scene.position.y = 0; //Position (y = up+, down-)
gltf.scene.position.z = 0;
scene.add( gltf.scene );
}, undefined, function ( error ) {
console.error( error );
} );
function animate() {
render();
requestAnimationFrame( animate );
}
function render() {
renderer.render( scene, camera );
}
render();
animate();
makc3d
5
that is easy to test - do not add it, and observe the result - if it turns out not the way you wanted it - then yes, you had to add it.
Wynnyy
6
yap, anyway thanks @makc3d