|
@@ -38,13 +38,13 @@
|
|
|
|
|
|
var camera, scene, renderer;
|
|
|
|
|
|
- var fov = 75,
|
|
|
- texture_placeholder,
|
|
|
+ var texture_placeholder,
|
|
|
isUserInteracting = false,
|
|
|
onMouseDownMouseX = 0, onMouseDownMouseY = 0,
|
|
|
lon = 90, onMouseDownLon = 0,
|
|
|
lat = 0, onMouseDownLat = 0,
|
|
|
- phi = 0, theta = 0;
|
|
|
+ phi = 0, theta = 0,
|
|
|
+ target = new THREE.Vector3();
|
|
|
|
|
|
init();
|
|
|
|
|
@@ -54,8 +54,7 @@
|
|
|
|
|
|
container = document.getElementById( 'container' );
|
|
|
|
|
|
- camera = new THREE.Camera( fov, window.innerWidth / window.innerHeight, 1, 1100 );
|
|
|
- camera.useTarget = true;
|
|
|
+ camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1100 );
|
|
|
|
|
|
scene = new THREE.Scene();
|
|
|
|
|
@@ -109,20 +108,18 @@
|
|
|
|
|
|
function loadTexture( path ) {
|
|
|
|
|
|
- var texture = new THREE.Texture( texture_placeholder ),
|
|
|
- material = new THREE.MeshBasicMaterial( { map: texture } );
|
|
|
+ var texture = new THREE.Texture( texture_placeholder );
|
|
|
+ var material = new THREE.MeshBasicMaterial( { map: texture } );
|
|
|
|
|
|
var image = new Image();
|
|
|
-
|
|
|
image.onload = function () {
|
|
|
|
|
|
texture.needsUpdate = true;
|
|
|
material.map.image = this;
|
|
|
-
|
|
|
+
|
|
|
render();
|
|
|
|
|
|
};
|
|
|
-
|
|
|
image.src = path;
|
|
|
|
|
|
return material;
|
|
@@ -167,23 +164,24 @@
|
|
|
|
|
|
if ( event.wheelDeltaY ) {
|
|
|
|
|
|
- fov -= event.wheelDeltaY * 0.05;
|
|
|
+ camera.fov -= event.wheelDeltaY * 0.05;
|
|
|
|
|
|
// Opera / Explorer 9
|
|
|
|
|
|
} else if ( event.wheelDelta ) {
|
|
|
|
|
|
- fov -= event.wheelDelta * 0.05;
|
|
|
+ camera.fov -= event.wheelDelta * 0.05;
|
|
|
|
|
|
// Firefox
|
|
|
|
|
|
} else if ( event.detail ) {
|
|
|
|
|
|
- fov += event.detail * 1.0;
|
|
|
+ camera.fov -= event.detail * 0.05;
|
|
|
|
|
|
}
|
|
|
|
|
|
- camera.projectionMatrix = THREE.Matrix4.makePerspective( fov, window.innerWidth / window.innerHeight, 1, 1100 );
|
|
|
+ camera.updateProjectionMatrix();
|
|
|
+
|
|
|
render();
|
|
|
|
|
|
}
|
|
@@ -191,7 +189,7 @@
|
|
|
|
|
|
function onDocumentTouchStart( event ) {
|
|
|
|
|
|
- if( event.touches.length == 1 ) {
|
|
|
+ if ( event.touches.length == 1 ) {
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
@@ -200,12 +198,14 @@
|
|
|
|
|
|
onPointerDownLon = lon;
|
|
|
onPointerDownLat = lat;
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function onDocumentTouchMove( event ) {
|
|
|
|
|
|
- if( event.touches.length == 1 ) {
|
|
|
+ if ( event.touches.length == 1 ) {
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
@@ -215,6 +215,7 @@
|
|
|
render();
|
|
|
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function render() {
|
|
@@ -223,13 +224,14 @@
|
|
|
phi = ( 90 - lat ) * Math.PI / 180;
|
|
|
theta = lon * Math.PI / 180;
|
|
|
|
|
|
- camera.target.position.x = 500 * Math.sin( phi ) * Math.cos( theta );
|
|
|
- camera.target.position.y = 500 * Math.cos( phi );
|
|
|
- camera.target.position.z = 500 * Math.sin( phi ) * Math.sin( theta );
|
|
|
+ target.x = 500 * Math.sin( phi ) * Math.cos( theta );
|
|
|
+ target.y = 500 * Math.cos( phi );
|
|
|
+ target.z = 500 * Math.sin( phi ) * Math.sin( theta );
|
|
|
|
|
|
- camera.position.x = - camera.target.position.x;
|
|
|
- camera.position.y = - camera.target.position.y;
|
|
|
- camera.position.z = - camera.target.position.z;
|
|
|
+ camera.position.x = - target.x;
|
|
|
+ camera.position.y = - target.y;
|
|
|
+ camera.position.z = - target.z;
|
|
|
+ camera.lookAt( target );
|
|
|
|
|
|
renderer.render( scene, camera );
|
|
|
|