fix: model shading
This commit is contained in:
@@ -11,33 +11,41 @@ renderer.setSize( window.innerWidth, window.innerHeight );
|
|||||||
document.body.appendChild( renderer.domElement );
|
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);
|
keyLight.position.set(-10, 10, 10);
|
||||||
|
scene.add(keyLight);
|
||||||
|
|
||||||
let fillLight = new THREE.DirectionalLight(0xffffff, 0.3);
|
let fillLight = new THREE.DirectionalLight(0xffffff, 0.3);
|
||||||
fillLight.position.set(10, 10, 10);
|
fillLight.position.set(10, 10, 10);
|
||||||
|
|
||||||
let ambientLight = new THREE.AmbientLight(0xffffff, 0.3);
|
|
||||||
|
|
||||||
scene.add(keyLight);
|
|
||||||
scene.add(fillLight);
|
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);
|
scene.add(ambientLight);
|
||||||
|
|
||||||
var mtlLoader = new THREE.MTLLoader();
|
|
||||||
mtlLoader.setPath('models/');
|
|
||||||
mtlLoader.load('cheese.mtl', function (materials) {
|
|
||||||
materials.preload();
|
|
||||||
|
|
||||||
var objLoader = new THREE.OBJLoader();
|
// A cheesy yellow
|
||||||
objLoader.setMaterials(materials);
|
const defaultMaterial = new THREE.MeshStandardMaterial({ color: 0xffc539, roughness: 1.0, metalness: 0.0 });
|
||||||
objLoader.setPath('models/');
|
|
||||||
objLoader.load('cheese.obj', function (object) {
|
var objLoader = new THREE.OBJLoader();
|
||||||
object.name = "cheese";
|
objLoader.setPath('models/');
|
||||||
scene.add(object);
|
objLoader.load('cheese.obj', function (object) {
|
||||||
object.position.y -= 0.75;
|
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) {
|
var animate = function (timestamp) {
|
||||||
let speed = 1.2;
|
let speed = 1.2;
|
||||||
let iTime = ((timestamp / 1000) * speed) % (Math.PI * 2);
|
let iTime = ((timestamp / 1000) * speed) % (Math.PI * 2);
|
||||||
@@ -61,4 +69,4 @@ window.addEventListener( 'resize', () => {
|
|||||||
camera.aspect = window.innerWidth / window.innerHeight;
|
camera.aspect = window.innerWidth / window.innerHeight;
|
||||||
camera.updateProjectionMatrix();
|
camera.updateProjectionMatrix();
|
||||||
renderer.setSize( window.innerWidth, window.innerHeight );
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
||||||
}, false );
|
}, false );
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Blender MTL File: 'cheese.blend'
|
# Blender 4.3.2 MTL File: 'cheese.blend'
|
||||||
# Material Count: 1
|
# www.blender.org
|
||||||
|
|
||||||
newmtl Material
|
newmtl Material
|
||||||
Ns 359.999993
|
Ns 360.000000
|
||||||
Ka 1.000000 1.000000 1.000000
|
Ka 1.000000 1.000000 1.000000
|
||||||
Kd 1.000000 0.805747 0.067960
|
Kd 1.000000 0.805747 0.067960
|
||||||
Ks 0.500000 0.500000 0.500000
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user