Skip to content

Materials not loading #9

@lifaon74

Description

@lifaon74

Hello,

I'm trying to load material on an obj but it seems not working :
assets.zip

import * as THREE from 'three';
import * as OBJLoader from 'three-obj-loader';
OBJLoader(THREE);
import * as MTLLoader from 'three-mtl-loader';
MTLLoader(THREE);
THREE.MTLLoader = MTLLoader;
// the modules are properly loaded

/*** BASIC SCENE ***/

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 10000);
const renderer = new THREE.WebGLRenderer();

renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(this.renderer.domElement);

const center = new THREE.AxisHelper(10);
scene.add(this.center);

const alight = new THREE.AmbientLight(0x404040); // soft white light
scene.add(alight);

const light = new THREE.DirectionalLight(0xffffff, 1.0);
light.position.set(1000, 1000, 1000);
scene.add(light);

const light2 = new THREE.DirectionalLight(0xffffff, 1.0);
light2.position.set(-1000, 1000, -1000);
scene.add(light2);

/*** BASIC SCENE END  ***/

const obj = 'assets/siege.obj';
const mtl = 'assets/siege.mtl';

const mtlLoader = new THREE.MTLLoader();
mtlLoader.load(mtl, (materials) => {
  materials.preload();
  const objLoader = new THREE.OBJLoader();
  objLoader.setMaterials(materials);
  objLoader.load(obj, (object) => {
    this.scene.add(object);
  });
});

It result in a pure white seat without materials:
image

But should be :
image

Any idea why ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions