|
@@ -45,54 +45,49 @@
|
|
|
|
|
|
function init() {
|
|
function init() {
|
|
|
|
|
|
- camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 );
|
|
|
|
- camera.position.set( 200, 100, 200 );
|
|
|
|
|
|
+ camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 100 );
|
|
|
|
+ camera.position.set( 4, 2, 4 );
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
scene = new THREE.Scene();
|
|
scene.background = new THREE.Color( 0xa0a0a0 );
|
|
scene.background = new THREE.Color( 0xa0a0a0 );
|
|
- scene.fog = new THREE.Fog( 0xa0a0a0, 200, 1000 );
|
|
|
|
|
|
+ scene.fog = new THREE.Fog( 0xa0a0a0, 4, 20 );
|
|
|
|
|
|
exporter = new DRACOExporter();
|
|
exporter = new DRACOExporter();
|
|
|
|
|
|
//
|
|
//
|
|
|
|
|
|
- const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444 );
|
|
|
|
- hemiLight.position.set( 0, 200, 0 );
|
|
|
|
|
|
+ const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444, 3 );
|
|
|
|
+ hemiLight.position.set( 0, 20, 0 );
|
|
scene.add( hemiLight );
|
|
scene.add( hemiLight );
|
|
|
|
|
|
- const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
|
|
|
|
- directionalLight.position.set( 0, 200, 100 );
|
|
|
|
|
|
+ const directionalLight = new THREE.DirectionalLight( 0xffffff, 3 );
|
|
|
|
+ directionalLight.position.set( 0, 20, 10 );
|
|
directionalLight.castShadow = true;
|
|
directionalLight.castShadow = true;
|
|
- directionalLight.shadow.camera.top = 180;
|
|
|
|
- directionalLight.shadow.camera.bottom = - 100;
|
|
|
|
- directionalLight.shadow.camera.left = - 120;
|
|
|
|
- directionalLight.shadow.camera.right = 120;
|
|
|
|
|
|
+ directionalLight.shadow.camera.top = 2;
|
|
|
|
+ directionalLight.shadow.camera.bottom = - 2;
|
|
|
|
+ directionalLight.shadow.camera.left = - 2;
|
|
|
|
+ directionalLight.shadow.camera.right = 2;
|
|
scene.add( directionalLight );
|
|
scene.add( directionalLight );
|
|
|
|
|
|
// ground
|
|
// ground
|
|
|
|
|
|
- const ground = new THREE.Mesh(
|
|
|
|
- new THREE.PlaneGeometry( 2000, 2000 ),
|
|
|
|
- new THREE.MeshPhongMaterial( { color: 0xbbbbbb, depthWrite: false } )
|
|
|
|
- );
|
|
|
|
|
|
+ const ground = new THREE.Mesh( new THREE.PlaneGeometry( 40, 40 ), new THREE.MeshPhongMaterial( { color: 0xbbbbbb, depthWrite: false } ) );
|
|
ground.rotation.x = - Math.PI / 2;
|
|
ground.rotation.x = - Math.PI / 2;
|
|
- ground.position.y = - 75;
|
|
|
|
ground.receiveShadow = true;
|
|
ground.receiveShadow = true;
|
|
scene.add( ground );
|
|
scene.add( ground );
|
|
|
|
|
|
- const grid = new THREE.GridHelper( 2000, 20, 0x000000, 0x000000 );
|
|
|
|
|
|
+ const grid = new THREE.GridHelper( 40, 20, 0x000000, 0x000000 );
|
|
grid.material.opacity = 0.2;
|
|
grid.material.opacity = 0.2;
|
|
grid.material.transparent = true;
|
|
grid.material.transparent = true;
|
|
- grid.position.y = - 75;
|
|
|
|
scene.add( grid );
|
|
scene.add( grid );
|
|
|
|
|
|
// export mesh
|
|
// export mesh
|
|
|
|
|
|
- const geometry = new THREE.TorusKnotGeometry( 50, 15, 200, 30 );
|
|
|
|
|
|
+ const geometry = new THREE.TorusKnotGeometry( 0.75, 0.2, 200, 30 );
|
|
const material = new THREE.MeshPhongMaterial( { color: 0x00ff00 } );
|
|
const material = new THREE.MeshPhongMaterial( { color: 0x00ff00 } );
|
|
mesh = new THREE.Mesh( geometry, material );
|
|
mesh = new THREE.Mesh( geometry, material );
|
|
mesh.castShadow = true;
|
|
mesh.castShadow = true;
|
|
- mesh.position.y = 25;
|
|
|
|
|
|
+ mesh.position.y = 1.5;
|
|
scene.add( mesh );
|
|
scene.add( mesh );
|
|
|
|
|
|
//
|
|
//
|
|
@@ -100,13 +95,14 @@
|
|
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
+ renderer.useLegacyLights = false;
|
|
renderer.shadowMap.enabled = true;
|
|
renderer.shadowMap.enabled = true;
|
|
document.body.appendChild( renderer.domElement );
|
|
document.body.appendChild( renderer.domElement );
|
|
|
|
|
|
//
|
|
//
|
|
|
|
|
|
const controls = new OrbitControls( camera, renderer.domElement );
|
|
const controls = new OrbitControls( camera, renderer.domElement );
|
|
- controls.target.set( 0, 25, 0 );
|
|
|
|
|
|
+ controls.target.set( 0, 1.5, 0 );
|
|
controls.update();
|
|
controls.update();
|
|
|
|
|
|
//
|
|
//
|