I even get the OBJLoader message that my model is loaded,
Does anybody has an idea of why is this happening? The scene is there, I know because if I use an { alpha: true } in my renderer it disappears to show the background of my site.
Here’s my code, thank you in advanced!
import * as THREE from './lib/three.module.js';
import { MTLLoader } from './lib/loaders/MTLLoader.js';
import { OBJLoader } from './lib/loaders/OBJLoader.js';
var scene3d = document.getElementById("scene3d");
var camera, mixer, controls, model, percent;
var scene = new THREE.Scene();
var clock = new THREE.Clock();
var renderer = new THREE.WebGLRenderer();
scene.background = new THREE.Color( 0xff0000 );
init();
function init() {
setupTHREEObjects();
ambientSetup();
sceneObjects();
}
function setupTHREEObjects() {
camera = new THREE.PerspectiveCamera( 70, (window.innerWidth/5*3) / window.innerHeight , 1, 10 );
camera.position.z = 9;
scene.add( camera );
renderer.setClearColor( 0xFF0000, 0 );
renderer.setSize(window.innerWidth/5*3, window.innerHeight);
scene3d.appendChild(renderer.domElement);
}
window.addEventListener('resize', function(){
var width = window.innerWidth/5*3;
var height = window.innerHeight;
renderer.setSize(window.innerWidth/5*3, height);
camera.aspect = window.innerWidth/5*3/height;
camera.updateProjectionMatrix();
});
function ambientSetup(){
var ambientLight = new THREE.AmbientLight( 0xcccccc, 0.8 );
scene.add( ambientLight );
var pointLight = new THREE.PointLight( 0xFFC5CB, .8 );
pointLight.position.copy( camera.position );
scene.add( pointLight );
}
function sceneObjects(){
var onError = function () { };
var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
// console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
}
};
new MTLLoader()
.setPath( './assets/modelo/' )
.load( 'flor.mtl', function ( materials ) {
materials.preload();
new OBJLoader()
.setMaterials(materials)
.setPath( './assets/modelo/' )
.load( 'flor.obj', function ( object) {
object.scale.x= .001;
object.scale.y= .001;
object.scale.z= .001;
object.position.x = 0;
object.position.y = 0;
object.position.z = 5;
object.rotation.x= -1;
object.rotation.y= -1;
scene.add( object );
}, onProgress, onError );
});
}