Эх сурвалжийг харах

Fixed STL Viewer position error

TC pushbot 5 4 жил өмнө
parent
commit
dfaa7e6ae8

+ 7 - 1
file_system.go

@@ -2089,7 +2089,7 @@ func system_fs_handleList(w http.ResponseWriter, r *http.Request) {
 		} else {
 			//Folder not exists
 			log.Println("[File Explorer] Requested path: ", realpath, " does not exists!")
-			sendJSONResponse(w, "{\"error\":\"Folder not exists\"}")
+			sendErrorResponse(w, "Folder not exists")
 			return
 		}
 
@@ -2111,6 +2111,12 @@ func system_fs_handleList(w http.ResponseWriter, r *http.Request) {
 			continue
 		}
 
+		//Check if this is an aodb file
+		if filepath.Base(v) == "aofs.db" || filepath.Base(v) == "aofs.db.lock" {
+			//Database file (reserved)
+			continue
+		}
+
 		//Check if it is shortcut file. If yes, render a shortcut data struct
 		if filepath.Ext(v) == ".shortcut" {
 			//This is a shortcut file

+ 20 - 10
web/SystemAO/utilities/stlViewer.html

@@ -114,24 +114,29 @@
 			function round(value){
 				return Math.round(value * 100) / 100;
 			}
+
+			var stlMesh = undefined;
 			function init() {
 
 				container = document.createElement( 'div' );
 				document.body.appendChild( container );
 
 				camera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 1, 1500 );
-				camera.position.set( 0, 0, 30 );
-				cameraTarget = new THREE.Vector3( 0, 0, 0 );
+				camera.position.set( 0, 30, 30 );
+				//cameraTarget = new THREE.Vector3( 0, 0, 0 );
 
+				
 				scene = new THREE.Scene();
 				scene.background = new THREE.Color( 0xf7f7f7 );
 				//scene.fog = new THREE.Fog( 0xc9c9c9, 2, 15 );
 
 				var loader = new THREE.STLLoader();
+				
 				loader.load( filename, function ( geometry ) {
 
 					var material = new THREE.MeshPhongMaterial( { color: 0x70721e, specular: 0x0c0c0c, shininess: 100 } );
 					var mesh = new THREE.Mesh( geometry, material );
+					stlMesh = mesh;
 					const center = new THREE.Vector3();
 
 					//Scsale it down to original's 10%
@@ -141,12 +146,14 @@
 					//Move the mesh to scene center
 					console.log(bbox);
 					mesh.updateMatrixWorld();
-					console.log(-1 * (bbox.max.x + bbox.min.x));
-					mesh.position.set(-1 * (bbox.max.x + bbox.min.x) / 2, -1 * (bbox.max.y + bbox.min.y) / 2, -1 * (bbox.max.z + bbox.min.z) / 2);
+					console.log((bbox.max.x - bbox.min.x));
+					mesh.rotateOnAxis(new THREE.Vector3( 1, 0, 0 ), -1.57079633);
+					//mesh.position.set(-1 * (bbox.max.x + bbox.min.x) / 2, -1 * (bbox.max.y + bbox.min.y) / 2, -1 * (bbox.max.z + bbox.min.z) / 2);
+					mesh.geometry.center()
+				
 					mesh.updateMatrixWorld();
 					console.log("Setting mesh world position: ", mesh.getWorldPosition())
-					mesh.rotation.set( 0,  0, 0);
-					
+					//mesh.rotation.set( 0,  0, 0);
 					render();
 
 					var box = new THREE.Box3().setFromObject(mesh);
@@ -160,6 +167,9 @@
 					mesh.castShadow = true;
 					mesh.receiveShadow = true;
 					scene.add( mesh );
+
+					controls.target = mesh.getWorldPosition();
+					
 				} );
 
 
@@ -167,8 +177,8 @@
 				scene.add( new THREE.HemisphereLight( 0x898989, 0x3f3f3f ) );
 				addShadowedLight( 1, 1, 1, 0x898989, 1.35 );
 				addShadowedLight( 0.5, 1, - 1, 0xcccccc, 1 );
-				// renderer
 
+				//Create renderer
 				renderer = new THREE.WebGLRenderer( { antialias: true } );
 				renderer.setPixelRatio( window.devicePixelRatio );
 				renderer.setSize( window.innerWidth, window.innerHeight );
@@ -184,6 +194,7 @@
 				controls = new THREE.OrbitControls( camera, renderer.domElement );
 				controls.minDistance = 3;
 				controls.maxDistance = 100;
+				controls.update();
 			}
 
 			function addShadowedLight( x, y, z, color, intensity ) {
@@ -220,9 +231,7 @@
 			}
 
 			function animate() {
-
 				requestAnimationFrame( animate );
-
 				render();
 
 			}
@@ -234,7 +243,8 @@
 				//camera.position.x = Math.cos( timer ) * 3;
 				//camera.position.z = Math.sin( timer ) * 3;
 
-				camera.lookAt( cameraTarget );
+				//camera.lookAt( cameraTarget );
+				controls.update();
 				renderer.render( scene, camera );
 
 			}

+ 1 - 1
web/login.system

@@ -113,7 +113,7 @@
             </div>
            
             <div class="bottombar">
-                CopyRight © <a href="https://arozos.com">ArozOS</a> 2017 - <span class="thisyear"></span><br>
+                © <a href="https://arozos.com">ArozOS</a> 2017 - <span class="thisyear"></span><br>
                 <small style="font-size: 80%">Request Time: <span id="requestTime"></span></small>
             </div>
         </div>