我是初学者,不明白为什么我的模型没有显示出来。其尺寸为 0.252、0.279、0.243。我改变了它的大小和缩放比例 - 没有帮助。模型成功加载到页面,但没有显示。
document.addEventListener('DOMContentLoaded', function() {
// Creating a scene and a camera var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
// Creating a renderer var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
// Get the container and add the renderer to the pagevar container =
document.getElementById("model-container");
if (container) {
container.appendChild(renderer.domElement);
}
// Creating a model loader
var loader = new THREE.OBJLoader();
// Loading the model from a file
loader.load('C:/Users/AloneWasser/Desktop/Diplom/asd/Etan.obj', function (object) {
// Scaling the model
object.scale.set(0.252, 0.279, 0.243);
// Adding a model to the scene
scene.add(object); }, function (xhr) { console.log((xhr.loaded / xhr.total * 100) + '% загружено'); }, function (error) { console.log('Ошибка загрузки модели', error); } );
// Position the camera and set the direction of view of the model
camera.position.z = 10;
// Updating the scene and rendering it
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
});