|
@@ -34,8 +34,9 @@
|
|
|
const renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
+ renderer.useLegacyLights = false;
|
|
|
|
|
|
- const camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 2000 );
|
|
|
+ const camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 0.1, 100 );
|
|
|
|
|
|
const controls = new OrbitControls( camera, renderer.domElement );
|
|
|
|
|
@@ -44,14 +45,14 @@
|
|
|
const matFloor = new THREE.MeshPhongMaterial( { color: 0x808080 } );
|
|
|
const matBox = new THREE.MeshPhongMaterial( { color: 0xaaaaaa } );
|
|
|
|
|
|
- const geoFloor = new THREE.PlaneGeometry( 2000, 2000 );
|
|
|
- const geoBox = new THREE.BoxGeometry( 3, 1, 2 );
|
|
|
+ const geoFloor = new THREE.PlaneGeometry( 100, 100 );
|
|
|
+ const geoBox = new THREE.BoxGeometry( 0.3, 0.1, 0.2 );
|
|
|
|
|
|
const mshFloor = new THREE.Mesh( geoFloor, matFloor );
|
|
|
mshFloor.rotation.x = - Math.PI * 0.5;
|
|
|
const mshBox = new THREE.Mesh( geoBox, matBox );
|
|
|
|
|
|
- const ambient = new THREE.AmbientLight( 0x111111 );
|
|
|
+ const ambient = new THREE.AmbientLight( 0x444444 );
|
|
|
|
|
|
const spotLight1 = createSpotlight( 0xFF7F00 );
|
|
|
const spotLight2 = createSpotlight( 0x00FF7F );
|
|
@@ -64,11 +65,11 @@
|
|
|
renderer.shadowMap.enabled = true;
|
|
|
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
|
|
|
|
|
- camera.position.set( 46, 22, - 21 );
|
|
|
+ camera.position.set( 4.6, 2.2, - 2.1 );
|
|
|
|
|
|
- spotLight1.position.set( 15, 40, 45 );
|
|
|
- spotLight2.position.set( 0, 40, 35 );
|
|
|
- spotLight3.position.set( - 15, 40, 45 );
|
|
|
+ spotLight1.position.set( 1.5, 4, 4.5 );
|
|
|
+ spotLight2.position.set( 0, 4, 3.5 );
|
|
|
+ spotLight3.position.set( - 1.5, 4, 4.5 );
|
|
|
|
|
|
lightHelper1 = new THREE.SpotLightHelper( spotLight1 );
|
|
|
lightHelper2 = new THREE.SpotLightHelper( spotLight2 );
|
|
@@ -79,7 +80,7 @@
|
|
|
|
|
|
mshBox.castShadow = true;
|
|
|
mshBox.receiveShadow = true;
|
|
|
- mshBox.position.set( 0, 5, 0 );
|
|
|
+ mshBox.position.set( 0, 0.5, 0 );
|
|
|
|
|
|
scene.add( mshFloor );
|
|
|
scene.add( mshBox );
|
|
@@ -90,15 +91,17 @@
|
|
|
document.body.appendChild( renderer.domElement );
|
|
|
window.addEventListener( 'resize', onWindowResize );
|
|
|
|
|
|
- controls.target.set( 0, 7, 0 );
|
|
|
+ controls.target.set( 0, 0.5, 0 );
|
|
|
controls.maxPolarAngle = Math.PI / 2;
|
|
|
+ controls.minDistance = 1;
|
|
|
+ controls.maxDistance = 10;
|
|
|
controls.update();
|
|
|
|
|
|
}
|
|
|
|
|
|
function createSpotlight( color ) {
|
|
|
|
|
|
- const newObj = new THREE.SpotLight( color, 2 );
|
|
|
+ const newObj = new THREE.SpotLight( color, 10 );
|
|
|
|
|
|
newObj.castShadow = true;
|
|
|
newObj.angle = 0.3;
|
|
@@ -127,9 +130,9 @@
|
|
|
.easing( TWEEN.Easing.Quadratic.Out ).start();
|
|
|
|
|
|
new TWEEN.Tween( light.position ).to( {
|
|
|
- x: ( Math.random() * 30 ) - 15,
|
|
|
- y: ( Math.random() * 10 ) + 15,
|
|
|
- z: ( Math.random() * 30 ) - 15
|
|
|
+ x: ( Math.random() * 3 ) - 1.5,
|
|
|
+ y: ( Math.random() * 1 ) + 1.5,
|
|
|
+ z: ( Math.random() * 3 ) - 1.5
|
|
|
}, Math.random() * 3000 + 2000 )
|
|
|
.easing( TWEEN.Easing.Quadratic.Out ).start();
|
|
|
|