Commit f1b48c14 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

+ download model with textures as a single zip

parent 5746e1ca
<?php
/*
Copyright (C) 2017 Elphel Inc.
SPDX-License-Identifier: AGPL-3.0+
https://www.elphel.com
*/
// https://stackoverflow.com/questions/1061710/php-zip-files-on-the-fly
// * solution for ZipArchive worked only from a command line
// * solution that worked: command line zip
// contstants
$TEXTURE_EXTENSIONS = ['png','jpeg','jpg','tif','tiff','gif'];
// check if file parameter is specified
if (!isset($_GET['file'])) die("-1");
$file = $_GET['file'];
$patterns = ['/(\.)+\//','/^\//'];
$replacements = ['',''];
// check if file exists
if (!is_file($file)) die("-2");
if (substr($file,-4)!=".x3d") die("-3");
$pathinfo = pathinfo($file);
$path = $pathinfo['dirname'];
$tmp = explode("/",$path);
$zipfile = $tmp[1]."_".$tmp[2].".zip";
// alright, there's this file
$contents = file_get_contents($file);
// extract file list
preg_match_all('/url="([^\s]+('.implode('|',$TEXTURE_EXTENSIONS).'))"/i',$contents,$matches);
// make a string
foreach($matches[1] as $v){
$file .= " $path/$v";
}
$zipped_data = `zip -qj - $file `;
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zipfile.'"');
echo $zipped_data;
?>
\ No newline at end of file
...@@ -187,10 +187,10 @@ html, body, #x3d_wrapper { ...@@ -187,10 +187,10 @@ html, body, #x3d_wrapper {
height:25px; height:25px;
} }
#exit_button{ #exit_button,#align_button,#align_tr_button,#download_button{
background-image:url('images/ic_exit_to_app_black_48dp_1x.png');
background-size: 32px 32px; background-size: 32px 32px;
background-repeat: no-repeat; background-repeat: no-repeat;
background-position: center;
background-color:white; background-color:white;
width: 32px; width: 32px;
...@@ -200,37 +200,29 @@ html, body, #x3d_wrapper { ...@@ -200,37 +200,29 @@ html, body, #x3d_wrapper {
margin-bottom: 2px; margin-bottom: 2px;
} }
#exit_button{
background-image:url('images/ic_exit_to_app_black_48dp_1x.png');
}
#download_button{
background-image:url('images/ic_file_download_black_48dp_1x.png');
background-size: 26px 26px;
}
#align_button{ #align_button{
background-image:url('images/ic_explore_black_48dp_1x.png'); background-image:url('images/ic_explore_black_48dp_1x.png');
background-size: 32px 32px;
background-repeat: no-repeat;
background-color:white;
width: 32px;
height: 32px;
border: 0px solid white;
border-radius: 2px;
margin-bottom: 2px;
} }
#align_tr_button{ #align_tr_button{
background-image:url('images/ic_horizon_black_48dp_1x.png'); background-image:url('images/ic_horizon_black_48dp_1x.png');
background-size: 32px 32px;
background-repeat: no-repeat;
background-color:white;
width: 32px;
height: 32px;
border: 0px solid white;
border-radius: 2px;
margin-bottom: 2px;
} }
#exit_button:hover{ #exit_button:hover{
background-color: rgba(240,150,150,1); background-color: rgba(240,150,150,1);
} }
#align_button:hover, #align_tr_button:hover{ #align_button:hover, #align_tr_button:hover, #download_button:hover{
/* background-image:url('images/align.png'); */ /* background-image:url('images/align.png'); */
background-color: rgba(240,240,240,1); background-color: rgba(240,240,240,1);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (C) 2017 Elphel Inc. Copyright (C) 2017 Elphel Inc.
License: GPLv3 SPDX-License-Identifier: GPL-3.0+
https://www.elphel.com https://www.elphel.com
...@@ -67,6 +67,10 @@ function menu_init(){ ...@@ -67,6 +67,10 @@ function menu_init(){
window.location.href = origin+path; window.location.href = origin+path;
}); });
$("#download_button").on("click",function(){
window.location.href = "download.php?file="+SETTINGS.files.x3d;
});
// changing a checkbox will not close menu // changing a checkbox will not close menu
menu.on('click',function(e){ menu.on('click',function(e){
var test = $(e.target).hasClass("donothide"); var test = $(e.target).hasClass("donothide");
......
...@@ -55,9 +55,9 @@ ...@@ -55,9 +55,9 @@
<x3d id="x3d_id" width='1600px' height='800px' showProgress="true" showStat="false" showLog="false" disableDoubleClick="true" keysEnabled="true"> <x3d id="x3d_id" width='1600px' height='800px' showProgress="true" showStat="false" showLog="false" disableDoubleClick="true" keysEnabled="true">
<scene> <scene>
<navigationInfo id="navInfo" type='"examine"' speed='0.01'></navigationInfo> <navigationInfo id="navInfo" type='"examine"' speed='0.01'></navigationInfo>
<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' ></Viewpoint> <!--<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' ></Viewpoint>-->
<!-- in x3dom 1.7.2 - big zNear does not work properly --> <!-- in x3dom 1.7.2 - big zNear does not work properly -->
<!--<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' zNear='2'></Viewpoint>--> <Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' zNear='3'></Viewpoint>
<!-- <group> <!-- <group>
<inline name="back" namespacename="back" url="models/m1/v1/background.x3d"/> <inline name="back" namespacename="back" url="models/m1/v1/background.x3d"/>
</group>--> </group>-->
...@@ -70,9 +70,10 @@ ...@@ -70,9 +70,10 @@
<div id='crosshair_h' class='crosshair'></div> <div id='crosshair_h' class='crosshair'></div>
<div id='crosshair_v' class='crosshair'></div> <div id='crosshair_v' class='crosshair'></div>
<div id='help_wrapper'> <div id='help_wrapper'>
<div id='menu_button'></div>
<div id='help_button'>?</div>
<div id='exit_button' title='Exit to models index'></div> <div id='exit_button' title='Exit to models index'></div>
<div id='help_button'>?</div>
<div id='download_button' title='Download 3d model'></div>
<div id='menu_button'></div>
<div id='align_button' title='Run alignment algorithm for camera heading and location using markers. <div id='align_button' title='Run alignment algorithm for camera heading and location using markers.
Instructions: Instructions:
1. Use approximate location control on the map to change initial approximation for the algorithm. 1. Use approximate location control on the map to change initial approximation for the algorithm.
...@@ -83,6 +84,7 @@ Instructions: ...@@ -83,6 +84,7 @@ Instructions:
<!--<div id='align_tr_button' title='Align tilt and roll' class='edit'></div>--> <!--<div id='align_tr_button' title='Align tilt and roll' class='edit'></div>-->
<div id='align_tr_button' title='Align tilt and roll' class='experimental'></div> <div id='align_tr_button' title='Align tilt and roll' class='experimental'></div>
</div> </div>
<div id='info-wrapper'> <div id='info-wrapper'>
<div id='window-info'></div> <div id='window-info'></div>
<div id='window-markinfo'></div> <div id='window-markinfo'></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment