|
@@ -22,7 +22,7 @@
|
|
|
<script src="js/Detector.js"></script>
|
|
|
<script src="js/RequestAnimationFrame.js"></script>
|
|
|
<script src="js/Stats.js"></script>
|
|
|
-
|
|
|
+
|
|
|
<link href="js/gui/gui.css" media="screen" rel="stylesheet" type="text/css" />
|
|
|
<script src="js/gui/gui.min.js"></script>
|
|
|
|
|
@@ -44,7 +44,7 @@
|
|
|
var gui, voxelConfig = {
|
|
|
orthographicProjection: false
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
init();
|
|
|
animate();
|
|
|
|
|
@@ -58,12 +58,12 @@
|
|
|
info.style.top = '10px';
|
|
|
info.style.width = '100%';
|
|
|
info.style.textAlign = 'center';
|
|
|
- info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter - webgl<br /><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>';
|
|
|
+ info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter - webgl<br><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>';
|
|
|
container.appendChild( info );
|
|
|
|
|
|
camera = new THREE.CombinedCamera( window.innerWidth, window.innerHeight, 45, 1, 10000, -2000, 10000 );
|
|
|
camera.position.y = 800;
|
|
|
-
|
|
|
+
|
|
|
cameraTarget = new THREE.Vector3( 0, 0, 0 );
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
@@ -99,20 +99,10 @@
|
|
|
scene.add( ambientLight );
|
|
|
|
|
|
var directionalLight = new THREE.DirectionalLight( 0xffffff );
|
|
|
- directionalLight.position.x = Math.random() - 0.5;
|
|
|
- directionalLight.position.y = Math.random() - 0.5;
|
|
|
- directionalLight.position.z = Math.random() - 0.5;
|
|
|
- directionalLight.position.normalize();
|
|
|
- scene.add( directionalLight );
|
|
|
-
|
|
|
- var directionalLight = new THREE.DirectionalLight( 0x808080 );
|
|
|
- directionalLight.position.x = Math.random() - 0.5;
|
|
|
- directionalLight.position.y = Math.random() - 0.5;
|
|
|
- directionalLight.position.z = Math.random() - 0.5;
|
|
|
- directionalLight.position.normalize();
|
|
|
+ directionalLight.position.set( 1, 0.75, 0.5 ).normalize();
|
|
|
scene.add( directionalLight );
|
|
|
|
|
|
- renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
|
+ renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer : true } );
|
|
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
|
|
container.appendChild( renderer.domElement );
|
|
@@ -126,11 +116,11 @@
|
|
|
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
|
|
|
document.addEventListener( 'keydown', onDocumentKeyDown, false );
|
|
|
document.addEventListener( 'keyup', onDocumentKeyUp, false );
|
|
|
-
|
|
|
+
|
|
|
// add GUI
|
|
|
gui = new GUI();
|
|
|
gui.add(voxelConfig, 'orthographicProjection').onChange(function(){
|
|
|
-
|
|
|
+
|
|
|
if ( voxelConfig.orthographicProjection ) {
|
|
|
camera.toOrthographic();
|
|
|
camera.position.x = 1000;
|
|
@@ -141,9 +131,9 @@
|
|
|
camera.toPerspective();
|
|
|
camera.position.y = 800;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function getRealIntersector( intersects ) {
|