I created a subdomain inside the host and inside this subdomain I created a folder and created an index file to call the threejs code, which is my code:
<script>
// صحنه، دوربین و رندرکننده را ایجاد کنید
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// نور به صحنه اضافه کنید
const light = new THREE.AmbientLight(0xffffff);
scene.add(light);
// دراکو بارگذار و GLTFLoader را تنظیم کنید
const dracoLoader = new THREE.DRACOLoader();
dracoLoader.setDecoderPath('/examples/jsm/libs/draco/');
const loader = new THREE.GLTFLoader();
loader.setDRACOLoader(dracoLoader);
// بارگذاری مدل GLTF
loader.load(
'https://demo.arendlighting.com/arsalan/object/scene.gltf',
function (gltf) {
scene.add(gltf.scene);
gltf.scene.position.set(0, 0, 0); // موقعیت مدل
},
function (xhr) {
console.log((xhr.loaded / xhr.total * 100) + '% loaded');
},
function (error) {
console.log('An error happened:', error);
}
);
// تنظیم دوربین
camera.position.z = 5;
// حلقه رندر
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
// تنظیم اندازهگیری صفحه
window.addEventListener('resize', function() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
</script>
</body>
</html>`
But when I run the browser page, I encounter a white screen and it shows me this error in the console: Uncaught ReferenceError: THREE is not defined.
What is wrong?!
i try in this link : https://demo.arendlighting.com/arsalan/
PlZz heeeeelppp me…