Changeset 26883
- Timestamp:
- 2013-02-14T10:43:45+13:00 (11 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/panoramaViewer.js
r26872 r26883 28 28 } 29 29 30 30 var panoContainer, camera, scene, renderer, projector; 31 31 32 32 var mouse = { x: 0, y: 0 }; … … 40 40 phi = 0, theta = 0, 41 41 mesh, sphereRadius = 500, 42 meshRotation = Math.PI ,42 meshRotation = Math.PI / 2 * 3, 43 43 panoSelectionRadius = 40; 44 45 44 46 45 var panoDocList = new Array(); … … 52 51 var nearbyPanoList = new Array(); 53 52 nearbyPanoList.ids = new Array(); 54 nearbyPanoList.pos = new Array();55 56 53 57 54 function initPanoramaViewer() { 58 59 55 //Creating the document list to store data about the panoramams 60 56 var jsonNodeDiv = $("#jsonPanoNodes"); … … 73 69 74 70 panoContainer = document.getElementById( 'pano-container' ); 75 76 71 // Creating the camera 77 72 // Setting width and height variables as the container dimensions changes when fov is changed 78 width = panoContainer.offsetWidth; 79 height = panoContainer.offsetHeight; 80 aspect = width / height; 81 82 // camera = new THREE.PerspectiveCamera( fov, window.innerWidth / window.innerHeight, 1, 1100 ); 83 // camera = new THREE.PerspectiveCamera( fov, container.offsetWidth / container.offsetHeight, 1, 1100 ); 73 if(panoContainer.className == "pano_canvas_fullscreen") { 74 width = window.innerWidth; 75 height = window.innerHeight; 76 aspect = width / height; 77 } else if(panoContainer.className == "pano_canvas_half") { 78 width = panoContainer.offsetWidth; 79 height = panoContainer.offsetHeight; 80 aspect = width / height; 81 } 84 82 camera = new THREE.PerspectiveCamera( fov, aspect, 1, 1100 ); 85 83 camera.target = new THREE.Vector3(0, 0, 0 ); … … 90 88 projector = new THREE.Projector(); 91 89 90 var sourceFile = gs.documentMetadata[panoDocList.ids[0]].Image; 91 var assocfilepath = gs.documentMetadata[panoDocList.ids[0]].assocfilepath; 92 var httpPath = gs.collectionMetadata.httpPath; 93 94 var fullPanoURL = httpPath + "/index/assoc/" + assocfilepath + "/" + sourceFile; 95 92 96 // Creating a sphere with the panorama applied as a texture 93 97 if (Detector.webgl) { 94 mesh = new THREE.Mesh( new THREE.SphereGeometry( sphereRadius, 60, 40 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( gs.collectionMetadata.httpPath + '/import/panorama/' + 'panorama0.jpg' ), wireframe: false} ) );98 mesh = new THREE.Mesh( new THREE.SphereGeometry( sphereRadius, 60, 40 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( fullPanoURL ), wireframe: false, overdraw: true, opacity:0 } ) ); 95 99 } else { 96 mesh = new THREE.Mesh( new THREE.SphereGeometry( sphereRadius, 30, 20 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( gs.collectionMetadata.httpPath + '/import/panorama/' + 'panorama0.jpg' ), wireframe: false, overdraw: true } ) ); 97 } 100 mesh = new THREE.Mesh( new THREE.SphereGeometry( sphereRadius, 30, 20 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( fullPanoURL ), wireframe: false, overdraw: true, opacity:0 } ) ); 101 } 102 98 103 mesh.scale.x = -1; 99 // mesh.rotation.y = meshRotation + (90 * Math.PI / 180);100 scene.add( mesh ); // Adding the sphere to the scene104 // Adding the sphere to the scene 105 scene.add( mesh ); 101 106 102 107 switchPanorama(panoDocList.ids[0]); 103 108 104 109 renderer = Detector.webgl? new THREE.WebGLRenderer(): new THREE.CanvasRenderer(); 105 //renderer.setSize( window.innerWidth, window.innerHeight );106 //renderer.setSize(container.offsetWidth,container.offsetHeight);107 110 renderer.setSize(width,height); 108 111 … … 115 118 panoContainer.addEventListener( 'mousewheel', onDocumentMouseWheel, false ); 116 119 panoContainer.addEventListener( 'DOMMouseScroll', onDocumentMouseWheel, false); 117 118 // window.addEventListener( 'resize', onWindowResize, false ); 120 121 if(panoContainer.className == "pano_canvas_fullscreen") 122 window.addEventListener( 'resize', onWindowResize, false ); 119 123 } 120 124 … … 153 157 } 154 158 155 /*156 function fullscreenToggle () {157 console.log("blah");158 if( THREEx.FullScreen.activated() ){159 THREEx.FullScreen.cancel();160 161 camera.aspect = width / height;162 camera.updateProjectionMatrix();163 164 renderer.setSize( width, height );165 166 }else{167 console.log("Fullscreen");168 THREEx.FullScreen.request(document.getElementById( 'asdf' ));169 170 //THREEx.FullScreen.request(panoContainer);171 172 // THREEx.FullScreen.request(document.getElementById( renderer ));173 camera.aspect = window.innerWidth / window.innerHeight;174 camera.updateProjectionMatrix();175 176 //renderer.setSize( window.innerWidth, window.innerHeight );177 178 }179 }180 */181 182 159 function switchPanorama( panoramaID, destMarker ) { 183 160 // Building the file path 184 var sourceFile = gs.documentMetadata[panoramaID]. SourceFile;161 var sourceFile = gs.documentMetadata[panoramaID].Image; 185 162 var assocfilepath = gs.documentMetadata[panoramaID].assocfilepath; 186 163 var httpPath = gs.collectionMetadata.httpPath; … … 188 165 var fullPanoURL = httpPath + "/index/assoc/" + assocfilepath + "/" + sourceFile; 189 166 190 console.log("pano URL = " + fullPanoURL);191 192 167 // Creating the material 193 168 if (Detector.webgl) { … … 205 180 206 181 new TWEEN.Tween(mesh.materials[0]).to({opacity: 0}, 500).onComplete(function () { 182 // Rotation 183 if (gs.documentMetadata[panoramaID].Angle) { 184 var temp = 360 + parseFloat(gs.documentMetadata[panoramaID].Angle); 185 temp = temp % 360; 186 console.log(temp); 187 mesh.rotation.y = meshRotation + (gs.documentMetadata[panoramaID].Angle * Math.PI / 180); 188 } else if (gs.documentMetadata[panoramaID].cv_rotation) 189 mesh.rotation.y = meshRotation + (gs.documentMetadata[panoramaID].cv_rotation * Math.PI / 180); 190 else 191 mesh.rotation.y = meshRotation; 192 207 193 mesh.materials[0] = texture; 208 194 new TWEEN.Tween(mesh.materials[0]).to({opacity: 1}, 500).start(); 209 195 }).start(); 210 196 211 // Setting the mesh material 212 213 214 // Rotation 215 if (gs.documentMetadata[panoramaID].cv_rotation) 216 mesh.rotation.y = meshRotation + (gs.documentMetadata[panoramaID].cv_rotation * Math.PI / 180); 217 else 218 mesh.rotation.y = meshRotation; 219 197 220 198 // Checking if there are markers to remove 221 if (nearbyPanoList.length > 1) {199 if (nearbyPanoList.length > 0) { 222 200 for(var i = 0; i < nearbyPanoList.length; i++) { 223 201 panoContainer.removeChild(nearbyPanoList[i]); … … 241 219 if(calculateDistance(startPanoLonLat,endPanoLonLat) < panoSelectionRadius) { 242 220 var bearing = calculateBearing(startPanoLonLat,endPanoLonLat); 243 console.log(bearing);244 221 var pos = degreesToCoords(bearing, sphereRadius); 245 222 var navMarker = NavMarker.create(panoDocList.ids[i],pos); … … 260 237 } 261 238 262 /* 239 263 240 function onWindowResize() { 264 241 camera.aspect = window.innerWidth / window.innerHeight; … … 267 244 renderer.setSize( window.innerWidth, window.innerHeight ); 268 245 } 269 */ 246 270 247 271 248 function onDocumentMouseDown( event ) { 272 249 event.preventDefault(); 273 274 250 isUserInteracting = true; 275 276 251 onPointerDownPointerX = event.clientX; 277 252 onPointerDownPointerY = event.clientY; 278 279 253 onPointerDownLon = lon; 280 254 onPointerDownLat = lat; … … 284 258 function onDocumentMouseMove( event ) { 285 259 if ( isUserInteracting ) { 286 287 260 lon = ( onPointerDownPointerX - event.clientX ) * 0.1 + onPointerDownLon; 288 261 lat = ( event.clientY - onPointerDownPointerY ) * 0.1 + onPointerDownLat; … … 297 270 298 271 function onDocumentMouseWheel( event ) { 299 300 // WebKit301 302 272 if ( event.wheelDeltaY ) { 303 273 // WebKit 304 274 fov -= event.wheelDeltaY * 0.05; 305 306 // Opera / Explorer 9307 308 275 } else if ( event.wheelDelta ) { 309 276 // Opera / Explorer 9 310 277 fov -= event.wheelDelta * 0.05; 311 312 // Firefox313 314 278 } else if ( event.detail ) { 315 279 // Firefox 316 280 fov += event.detail * 1.0; 317 318 281 } 319 282 … … 324 287 } 325 288 326 // camera.projectionMatrix.makePerspective( fov, container.offsetWidth / container.offsetHeight, 1, 1100 );327 289 camera.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect , 1, 1100 ); 328 290 _render(); 329 330 291 } 331 292 332 293 function _animate() { 333 334 294 requestAnimationFrame( _animate ); 335 295 _render(); … … 339 299 340 300 function _render() { 341 /*342 lat = Math.max( - 85, Math.min( 85, lat ) );343 phi = THREE.Math.degToRad( 90 - lat );344 theta = THREE.Math.degToRad( lon );345 */346 347 301 lat = Math.max( - 85, Math.min( 85, lat ) ); 348 302 phi = ( 90 - lat ) * Math.PI / 180; … … 365 319 var i, angle, sameSide, p2D, marker; 366 320 321 // Snippet of code from Thanh Tran from in2ideas 322 // [email protected] 367 323 for (i = 0; i < nearbyPanoList.length; ++i) { 368 324 marker = nearbyPanoList[i]; … … 372 328 p2D.y = - (p2D.y - 1)/2 * height; 373 329 374 //my trick375 330 angle = Math.acos(camUnitVector.dot(marker.unitVector)) * 180 / 3.14; 376 331 sameSide = (angle < 90); … … 384 339 } 385 340 } 386 387 388 341 renderer.render( scene, camera ); 389 390 } 342 } -
main/trunk/greenstone3/web/interfaces/default/style/core.css
r26871 r26883 817 817 818 818 .pano_canvas_fullscreen{ 819 margin:0px auto; 820 width:1280px; 821 height:720px; 819 margin-left:0px auto; 820 margin-right:0px auto; 821 width:1024px; 822 height:768px;; 822 823 } 823 824 -
main/trunk/greenstone3/web/interfaces/default/transform/pages/classifier.xsl
r26871 r26883 157 157 <xsl:text>{</xsl:text> 158 158 <xsl:text disable-output-escaping="yes">"nodeID":"</xsl:text><xsl:value-of select="@nodeID"/><xsl:text disable-output-escaping="yes">",</xsl:text> 159 <xsl:text disable-output-escaping="yes">"title":"</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/><xsl:text disable-output-escaping="yes">",</xsl:text>160 <xsl:text disable-output-escaping="yes">"lat":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Latitude']"/><xsl:text>,</xsl:text>161 <xsl:text disable-output-escaping="yes">"lng":</xsl:text><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Longitude']"/>162 159 <xsl:text>}</xsl:text> 163 160 <xsl:if test="not(position() = count(//documentNode))"> … … 199 196 <gsf:metadata name="Latitude" hidden="true"/> 200 197 <gsf:metadata name="Longitude" hidden="true"/> 198 <gsf:metadata name="Image" hidden="true"/> 201 199 <gsf:metadata name="SourceFile" hidden="true"/> 202 200 <gsf:metadata name="assocfilepath" hidden="true"/> 203 201 <gsf:metadata name="PhotoType" hidden="true"/> 204 202 <gsf:metadata name="cv.rotation" hidden="true"/> 205 </xsl:template> 203 <gsf:metadata name="ex.Angle" hidden="true"/> 204 <gsf:metadata name="Angle" hidden="true"/> 205 206 </xsl:template> 206 207 207 208 <xsl:template name="panoramaViewerFeatures"> -
main/trunk/greenstone3/web/interfaces/default/transform/pages/query.xsl
r26871 r26883 569 569 <gsf:metadata name="Latitude" hidden="true"/> 570 570 <gsf:metadata name="Longitude" hidden="true"/> 571 <gsf:metadata name="Image" hidden="true"/> 572 <gsf:metadata name="SourceFile" hidden="true"/> 573 <gsf:metadata name="assocfilepath" hidden="true"/> 574 <gsf:metadata name="PhotoType" hidden="true"/> 575 <gsf:metadata name="cv.rotation" hidden="true"/> 576 <gsf:metadata name="Angle" hidden="true"/> 577 578 571 579 </xsl:template> 572 580
Note:
See TracChangeset
for help on using the changeset viewer.