fix: model shading
This commit is contained in:
@@ -11,32 +11,40 @@ 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();
|
||||
|
||||
// A cheesy yellow
|
||||
const defaultMaterial = new THREE.MeshStandardMaterial({ color: 0xffc539, roughness: 1.0, metalness: 0.0 });
|
||||
|
||||
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;
|
||||
|
||||
|
||||
object.traverse(function (child) {
|
||||
if (child instanceof THREE.Mesh) {
|
||||
child.material = defaultMaterial
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var animate = function (timestamp) {
|
||||
let speed = 1.2;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Blender MTL File: 'cheese.blend'
|
||||
# Material Count: 1
|
||||
# Blender 4.3.2 MTL File: 'cheese.blend'
|
||||
# www.blender.org
|
||||
|
||||
newmtl Material
|
||||
Ns 359.999993
|
||||
Ns 360.000000
|
||||
Ka 1.000000 1.000000 1.000000
|
||||
Kd 1.000000 0.805747 0.067960
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user