Commits

Anonymous committed 6946e59

Added slight angle effect

Comments (0)

Files changed (1)

src/main/resources/js/3dgalleries.js

         var zooming = false, zoomed = false;
         var selected = null;
 
+	var getSelectedIndex = function() {
+	    var selectedIndex = 0;
+	    for(var i = 0; i < objects.length; i++) {
+		if(objects[i] != selected) continue;
+
+		selectedIndex = i;
+		break;
+	    }
+
+	    return selectedIndex;
+	};
+
         $(renderer.domElement).click(function() {
             if(zooming) return;
             if(!selected) return;
 	    if(zooming) return;
 	    if(!zoomed) return;
 
-	    var selectedIndex = 0;
-	    for(var i = 0; i < objects.length; i++) {
-		if(objects[i] != selected) continue;
-
-		selectedIndex = i;
-		break;
-	    }
+	    var selectedIndex = getSelectedIndex();
 
 	    switch(e.keyCode) {
 	    case 37: // Left
                 }
             }
 
+	    $.each(objects, function(i) {
+	        this.materials[0].opacity = 0.5;
+		this.position.z = -0.05;
+		if(zoomed) {
+                    this.rotation.y = i < getSelectedIndex() ? 0.1 : -0.1;
+		} else {
+                    this.rotation.y = 0;
+		}
+            });
             if(selected) {
-                $.each(materials, function() {
-                    this.opacity = 0.5;
-                });
-
                 selected.materials[0].opacity = 1;
+		selected.rotation.y = 0;
+		selected.position.z = 0;
             }
 
             renderer.render(scene, camera);