|
@@ -22,6 +22,9 @@
|
|
|
<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>
|
|
|
|
|
|
<script>
|
|
|
|
|
@@ -38,6 +41,10 @@
|
|
|
var cubeGeo, cubeMaterial;
|
|
|
var i, intersector;
|
|
|
|
|
|
+ var gui, voxelConfig = {
|
|
|
+ orthographicProjection: false
|
|
|
+ };
|
|
|
+
|
|
|
init();
|
|
|
animate();
|
|
|
|
|
@@ -54,10 +61,10 @@
|
|
|
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.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
|
|
|
+ camera = new THREE.CombinedCamera( window.innerWidth, window.innerHeight, 45, 1, 10000, -2000, 10000 );
|
|
|
camera.position.y = 800;
|
|
|
-
|
|
|
- cameraTarget = new THREE.Vector3( 0, 200, 0 );
|
|
|
+
|
|
|
+ cameraTarget = new THREE.Vector3( 0, 0, 0 );
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
|
|
|
@@ -68,7 +75,6 @@
|
|
|
rollOverMesh = new THREE.Mesh( rollOverGeo, rollOverMaterial );
|
|
|
scene.add( rollOverMesh );
|
|
|
|
|
|
-
|
|
|
// cubes
|
|
|
|
|
|
cubeGeo = new THREE.CubeGeometry( 50, 50, 50 );
|
|
@@ -86,7 +92,6 @@
|
|
|
scene.add( plane );
|
|
|
|
|
|
mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
|
|
|
- ray = new THREE.Ray( camera.position, null );
|
|
|
|
|
|
// Lights
|
|
|
|
|
@@ -121,7 +126,24 @@
|
|
|
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;
|
|
|
+ camera.position.y = 707.106;
|
|
|
+ camera.position.z = 1000;
|
|
|
+ theta = 90;
|
|
|
+ } else {
|
|
|
+ camera.toPerspective();
|
|
|
+ camera.position.y = 800;
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function getRealIntersector( intersects ) {
|
|
@@ -247,8 +269,7 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- mouse3D = projector.unprojectVector( mouse2D.clone(), camera );
|
|
|
- ray.direction = mouse3D.subSelf( camera.position ).normalize();
|
|
|
+ ray = projector.pickingRay( mouse2D.clone(), camera );
|
|
|
|
|
|
var intersects = ray.intersectScene( scene );
|
|
|
|