Commit cb334f12 authored by amandaghassaei's avatar amandaghassaei

cleaning up

parent e5c577b3
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -727,11 +727,11 @@
<script type="text/javascript" src="dependencies/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="dependencies/jquery-ui.min.js"></script>
<script type="text/javascript" src="dependencies/flat-ui.min.js"></script>
<script type="text/javascript" src="dependencies/three.js"></script>
<script type="text/javascript" src="dependencies/three.js"></script>//todo .min
<script type="text/javascript" src="dependencies/binary_stl_writer.js"></script>
<script type="text/javascript" src="dependencies/TrackballControls.js"></script>
<script type="text/javascript" src="dependencies/Projector.js"></script>
<script type="text/javascript" src="dependencies/SVGRenderer.js"></script>
<!--<script type="text/javascript" src="dependencies/Projector.js"></script>-->
<!--<script type="text/javascript" src="dependencies/SVGRenderer.js"></script>-->
<script type="text/javascript" src="dependencies/underscore-min.js"></script>
<script type="text/javascript" src="dependencies/FileSaver.min.js"></script>
<script type="text/javascript" src="dependencies/SVGLoader.js"></script>
......@@ -751,9 +751,9 @@
<!--<script type="text/javascript" src="dependencies/RenderPass.js"></script>-->
<script type="text/javascript" src="dependencies/WebVR.js"></script>
<script type="text/javascript" src="dependencies/VREffect.js"></script>
<script type="text/javascript" src="dependencies/ViveController.js"></script>
<script type="text/javascript" src="dependencies/VRControls.js"></script>
<!--<script type="text/javascript" src="dependencies/VREffect.js"></script>-->
<!--<script type="text/javascript" src="dependencies/ViveController.js"></script>-->
<!--<script type="text/javascript" src="dependencies/VRControls.js"></script>-->
<script type="text/javascript" src="dependencies/VRController.js"></script>
<script type="text/javascript" src="js/dynamic/GLBoilerplate.js"></script>
......
......@@ -128,13 +128,14 @@ function initViveInterface(globals){
globals.vrEnabled = !display.isPresenting;
// globals.threeView.renderer.setSize( window.innerWidth, window.innerHeight );
globals.threeView.renderer.vr.enabled = globals.vrEnabled;
globals.threeView.renderer.vr.standing = true;
var y = 0;
var vrScale = 1;
if (globals.vrEnabled) {
y = yOffset;
vrScale = scale;
$link.html("EXIT VR");
globals.threeView.renderer.vr.setDevice( display );
globals.threeView.renderer.vr.standing = true;
} else {
globals.model.reset();
globals.threeView.resetCamera();
......
......@@ -78,7 +78,8 @@ function initModel(globals){
var polygonOffset = 0.5;
if (globals.colorMode == "normal") {
material = new THREE.MeshNormalMaterial({
shading:THREE.FlatShading, side: THREE.DoubleSide,
flatShading:true,
side: THREE.DoubleSide,
polygonOffset: true,
polygonOffsetFactor: polygonOffset, // positive value pushes polygon further away
polygonOffsetUnits: 1
......
......@@ -10,7 +10,7 @@ function initThreeView(globals) {
var camera = new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight, 0.1, 500);
// var camera = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, -10000, 10000);//-40, 40);
var renderer = new THREE.WebGLRenderer({antialias: true});
var svgRenderer = new THREE.SVGRenderer();
// var svgRenderer = new THREE.SVGRenderer();
var controls;
init();
......@@ -171,37 +171,37 @@ function initThreeView(globals) {
controls.enableRotate = state;
}
function saveSVG(){
// svgRenderer.setClearColor(0xffffff);
svgRenderer.setSize(window.innerWidth,window.innerHeight);
svgRenderer.sortElements = true;
svgRenderer.sortObjects = true;
svgRenderer.setQuality('high');
svgRenderer.render(scene,camera);
//get svg source.
var serializer = new XMLSerializer();
var source = serializer.serializeToString(svgRenderer.domElement);
//add name spaces.
if(!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){
source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
}
if(!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)){
source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
}
//add xml declaration
source = '<?xml version="1.0" standalone="no"?>\r\n' + source;
var svgBlob = new Blob([source], {type:"image/svg+xml;charset=utf-8"});
var svgUrl = URL.createObjectURL(svgBlob);
var downloadLink = document.createElement("a");
downloadLink.href = svgUrl;
downloadLink.download = globals.filename + " : " + parseInt(globals.creasePercent*100) + "PercentFolded.svg";
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
// function saveSVG(){
// // svgRenderer.setClearColor(0xffffff);
// svgRenderer.setSize(window.innerWidth,window.innerHeight);
// svgRenderer.sortElements = true;
// svgRenderer.sortObjects = true;
// svgRenderer.setQuality('high');
// svgRenderer.render(scene,camera);
// //get svg source.
// var serializer = new XMLSerializer();
// var source = serializer.serializeToString(svgRenderer.domElement);
//
// //add name spaces.
// if(!source.match(/^<svg[^>]+xmlns="http\:\/\/www\.w3\.org\/2000\/svg"/)){
// source = source.replace(/^<svg/, '<svg xmlns="http://www.w3.org/2000/svg"');
// }
// if(!source.match(/^<svg[^>]+"http\:\/\/www\.w3\.org\/1999\/xlink"/)){
// source = source.replace(/^<svg/, '<svg xmlns:xlink="http://www.w3.org/1999/xlink"');
// }
//
// //add xml declaration
// source = '<?xml version="1.0" standalone="no"?>\r\n' + source;
//
// var svgBlob = new Blob([source], {type:"image/svg+xml;charset=utf-8"});
// var svgUrl = URL.createObjectURL(svgBlob);
// var downloadLink = document.createElement("a");
// downloadLink.href = svgUrl;
// downloadLink.download = globals.filename + " : " + parseInt(globals.creasePercent*100) + "PercentFolded.svg";
// document.body.appendChild(downloadLink);
// downloadLink.click();
// document.body.removeChild(downloadLink);
// }
function resetModel(){
modelWrapper.rotation.set(0,0,0);
......@@ -226,7 +226,7 @@ function initThreeView(globals) {
renderer: renderer,//needed for VR
modelWrapper:modelWrapper,
saveSVG: saveSVG,//svg screenshot
// saveSVG: saveSVG,//svg screenshot
setCameraX:setCameraX,
setCameraY: setCameraY,
......
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