fix: model shading
This commit is contained in:
@@ -11,33 +11,41 @@ renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
document.body.appendChild( renderer.domElement );
|
||||
|
||||
|
||||
let keyLight = new THREE.DirectionalLight(0xffffff, 0.8);
|
||||
let keyLight = new THREE.DirectionalLight(0xffffff, 0.3);
|
||||
keyLight.position.set(-10, 10, 10);
|
||||
scene.add(keyLight);
|
||||
|
||||
let fillLight = new THREE.DirectionalLight(0xffffff, 0.3);
|
||||
fillLight.position.set(10, 10, 10);
|
||||
|
||||
let ambientLight = new THREE.AmbientLight(0xffffff, 0.3);
|
||||
|
||||
scene.add(keyLight);
|
||||
scene.add(fillLight);
|
||||
|
||||
let fillLight2 = new THREE.DirectionalLight(0xffffff, 0.3);
|
||||
fillLight2.position.set(-10, 10, 10);
|
||||
scene.add(fillLight2);
|
||||
|
||||
let ambientLight = new THREE.AmbientLight(0xffffff, 0.4);
|
||||
scene.add(ambientLight);
|
||||
|
||||
var mtlLoader = new THREE.MTLLoader();
|
||||
mtlLoader.setPath('models/');
|
||||
mtlLoader.load('cheese.mtl', function (materials) {
|
||||
materials.preload();
|
||||
|
||||
var objLoader = new THREE.OBJLoader();
|
||||
objLoader.setMaterials(materials);
|
||||
objLoader.setPath('models/');
|
||||
objLoader.load('cheese.obj', function (object) {
|
||||
object.name = "cheese";
|
||||
scene.add(object);
|
||||
object.position.y -= 0.75;
|
||||
});
|
||||
// A cheesy yellow
|
||||
const defaultMaterial = new THREE.MeshStandardMaterial({ color: 0xffc539, roughness: 1.0, metalness: 0.0 });
|
||||
|
||||
var objLoader = new THREE.OBJLoader();
|
||||
objLoader.setPath('models/');
|
||||
objLoader.load('cheese.obj', function (object) {
|
||||
object.name = "cheese";
|
||||
scene.add(object);
|
||||
object.position.y -= 0.75;
|
||||
|
||||
|
||||
object.traverse(function (child) {
|
||||
if (child instanceof THREE.Mesh) {
|
||||
child.material = defaultMaterial
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
var animate = function (timestamp) {
|
||||
let speed = 1.2;
|
||||
let iTime = ((timestamp / 1000) * speed) % (Math.PI * 2);
|
||||
@@ -61,4 +69,4 @@ window.addEventListener( 'resize', () => {
|
||||
camera.aspect = window.innerWidth / window.innerHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize( window.innerWidth, window.innerHeight );
|
||||
}, false );
|
||||
}, false );
|
||||
|
||||
Reference in New Issue
Block a user