diff --git a/.gitignore b/.gitignore index d4e4394..c10fa8f 100644 --- a/.gitignore +++ b/.gitignore @@ -163,9 +163,11 @@ cython_debug/ outputs/ # Ignore folders only used for build dependencies -_Pre_Builds/_Build_Dependencies +_Pre_Builds/_Build_Dependencies _Pre_Builds/_Build_Wheels _Pre_Builds/_Libs models/ -output/ \ No newline at end of file +output/ + +.idea diff --git a/web/html/threeVisualizer.html b/web/html/threeVisualizer.html index af4a99f..cdafdc1 100644 --- a/web/html/threeVisualizer.html +++ b/web/html/threeVisualizer.html @@ -8,7 +8,7 @@ - +

@@ -48,6 +48,7 @@ ] }); + diff --git a/web/js/threeVisualizer.js b/web/js/threeVisualizer.js index aa2797c..377ab47 100644 --- a/web/js/threeVisualizer.js +++ b/web/js/threeVisualizer.js @@ -15,6 +15,7 @@ const container = document.getElementById( 'container' ); const progressDialog = document.getElementById("progress-dialog"); const progressIndicator = document.getElementById("progress-indicator"); const colorPicker = document.getElementById("color-picker"); +const downloadButton = document.getElementById("download-button"); const renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); @@ -56,9 +57,14 @@ const clock = new THREE.Clock(); var lastTimestamp = ""; var needUpdate = false; let mixer; +let currentURL; + +downloadButton.addEventListener('click', e => { + window.open(currentURL, '_blank'); +}); function frameUpdate() { - + var filepath = visualizer.getAttribute("filepath"); var timestamp = visualizer.getAttribute("timestamp"); if (timestamp == lastTimestamp){ @@ -100,12 +106,12 @@ async function main(filepath="") { if (/^.+\.[a-zA-Z]+$/.test(filepath)){ let params = {"filepath": filepath}; - const url = api.apiURL('/viewfile?' + new URLSearchParams(params)); + currentURL = api.apiURL('/viewfile?' + new URLSearchParams(params)); var filepathSplit = filepath.split('.'); var fileExt = filepathSplit.pop().toLowerCase(); - var filepathNoExt = filepathSplit.join("."); - + var filepathNoExt = filepathSplit.join("."); + if (fileExt == "obj"){ const loader = new OBJLoader(); @@ -118,8 +124,8 @@ async function main(filepath="") { mtl.preload(); loader.setMaterials( mtl ); }, onProgress, onError ); - - loader.load( url, function ( obj ) { + + loader.load( currentURL, function ( obj ) { obj.scale.setScalar( 5 ); scene.add( obj ); obj.traverse(node => { @@ -127,7 +133,7 @@ async function main(filepath="") { node.material.vertexColors = true; } }); - + }, onProgress, onError ); } else if (fileExt == "glb") { @@ -136,7 +142,7 @@ async function main(filepath="") { const loader = new GLTFLoader(); loader.setDRACOLoader( dracoLoader ); - loader.load( url, function ( gltf ) { + loader.load( currentURL, function ( gltf ) { const model = gltf.scene; //model.position.set( 1, 1, 0 ); model.scale.set( 3, 3, 3 ); @@ -146,7 +152,7 @@ async function main(filepath="") { gltf.animations.forEach((clip) => { mixer.clipAction(clip).play(); }); - + }, onProgress, onError ); } else if (fileExt == "ply") { diff --git a/web/style/sharedStyle.css b/web/style/sharedStyle.css index 32a72a7..ccd74d0 100644 --- a/web/style/sharedStyle.css +++ b/web/style/sharedStyle.css @@ -63,4 +63,12 @@ progress::-moz-progress-bar { height: 24px; border: 2px solid #aaa; border-radius: 5px; -} \ No newline at end of file +} + +#download-button { + margin-left: 5px; + margin-top: 10px; + position: absolute; + z-index: 10; + left: 180px; +}