diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/assets/Curved/creaseMesh.txt b/assets/Curved/creaseMesh.txt old mode 100644 new mode 100755 diff --git a/assets/Curved/curvedcrease2.svg b/assets/Curved/curvedcrease2.svg old mode 100644 new mode 100755 diff --git a/assets/Origami/hypar.svg b/assets/Origami/hypar.svg old mode 100644 new mode 100755 diff --git a/assets/Origami/randlettflappingbird.svg b/assets/Origami/randlettflappingbird.svg old mode 100644 new mode 100755 diff --git a/assets/Origami/singlesquaretwist.svg b/assets/Origami/singlesquaretwist.svg old mode 100644 new mode 100755 diff --git a/assets/Origami/squaretwistManyAngles.svg b/assets/Origami/squaretwistManyAngles.svg old mode 100644 new mode 100755 diff --git a/assets/PolygonUnfolding/cubeunwrapping.svg b/assets/PolygonUnfolding/cubeunwrapping.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/honeycomb_333_cp.svg b/assets/Tessellations/honeycomb_333_cp.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/hyperbolic_limit_cp.svg b/assets/Tessellations/hyperbolic_limit_cp.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/miura-ori.svg b/assets/Tessellations/miura-ori.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/oval_tessellation_cp.svg b/assets/Tessellations/oval_tessellation_cp.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/rattanweaveLang.svg b/assets/Tessellations/rattanweaveLang.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/reschbarbell.svg b/assets/Tessellations/reschbarbell.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/reschtritessellation.svg b/assets/Tessellations/reschtritessellation.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/waterbomb.svg b/assets/Tessellations/waterbomb.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/waterbombTwist.svg b/assets/Tessellations/waterbombTwist.svg old mode 100644 new mode 100755 diff --git a/assets/Tessellations/wedged_double_faced.svg b/assets/Tessellations/wedged_double_faced.svg old mode 100644 new mode 100755 diff --git a/assets/Tests/SimpleVertex.svg b/assets/Tests/SimpleVertex.svg old mode 100644 new mode 100755 diff --git a/assets/Tests/SimpleVertex2.svg b/assets/Tests/SimpleVertex2.svg old mode 100644 new mode 100755 diff --git a/assets/Tests/TwoTri.svg b/assets/Tests/TwoTri.svg old mode 100644 new mode 100755 diff --git a/assets/attrib.txt b/assets/attrib.txt old mode 100644 new mode 100755 diff --git a/assets/examplepattern.jpg b/assets/examplepattern.jpg old mode 100644 new mode 100755 diff --git a/assets/patternwithtriangulations.jpg b/assets/patternwithtriangulations.jpg old mode 100644 new mode 100755 diff --git a/css/main.css b/css/main.css old mode 100644 new mode 100755 diff --git a/css/nav.css b/css/nav.css old mode 100644 new mode 100755 diff --git a/dependencies/CopyShader.js b/dependencies/CopyShader.js old mode 100644 new mode 100755 diff --git a/dependencies/Detector.js b/dependencies/Detector.js old mode 100644 new mode 100755 diff --git a/dependencies/EffectComposer.js b/dependencies/EffectComposer.js old mode 100644 new mode 100755 diff --git a/dependencies/FileSaver.min.js b/dependencies/FileSaver.min.js old mode 100644 new mode 100755 diff --git a/dependencies/MaskPass.js b/dependencies/MaskPass.js old mode 100644 new mode 100755 diff --git a/dependencies/OrbitControls.js b/dependencies/OrbitControls.js old mode 100644 new mode 100755 diff --git a/dependencies/OrthographicTrackballControls.js b/dependencies/OrthographicTrackballControls.js old mode 100644 new mode 100755 diff --git a/dependencies/Projector.js b/dependencies/Projector.js old mode 100644 new mode 100755 diff --git a/dependencies/RenderPass.js b/dependencies/RenderPass.js old mode 100644 new mode 100755 diff --git a/dependencies/SSAOShader.js b/dependencies/SSAOShader.js old mode 100644 new mode 100755 diff --git a/dependencies/SVGLoader.js b/dependencies/SVGLoader.js old mode 100644 new mode 100755 diff --git a/dependencies/SVGRenderer.js b/dependencies/SVGRenderer.js old mode 100644 new mode 100755 diff --git a/dependencies/ShaderPass.js b/dependencies/ShaderPass.js old mode 100644 new mode 100755 diff --git a/dependencies/TrackballControls.js b/dependencies/TrackballControls.js new file mode 100755 index 0000000..d3e6aeb --- /dev/null +++ b/dependencies/TrackballControls.js @@ -0,0 +1,623 @@ +/** + * @author Eberhard Graether / http://egraether.com/ + * @author Mark Lundin / http://mark-lundin.com + * @author Simone Manini / http://daron1337.github.io + * @author Luca Antiga / http://lantiga.github.io + */ + +THREE.TrackballControls = function ( object, domElement ) { + + var _this = this; + var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 }; + + this.object = object; + this.domElement = ( domElement !== undefined ) ? domElement : document; + + // API + + this.enabled = true; + + this.screen = { left: 0, top: 0, width: 0, height: 0 }; + + this.rotateSpeed = 1.0; + this.zoomSpeed = 1.2; + this.panSpeed = 0.3; + + this.noRotate = false; + this.noZoom = false; + this.noPan = false; + + this.staticMoving = false; + this.dynamicDampingFactor = 0.2; + + this.minDistance = 0; + this.maxDistance = Infinity; + + this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ]; + + // internals + + this.target = new THREE.Vector3(); + + var EPS = 0.000001; + + var lastPosition = new THREE.Vector3(); + + var _state = STATE.NONE, + _prevState = STATE.NONE, + + _eye = new THREE.Vector3(), + + _movePrev = new THREE.Vector2(), + _moveCurr = new THREE.Vector2(), + + _lastAxis = new THREE.Vector3(), + _lastAngle = 0, + + _zoomStart = new THREE.Vector2(), + _zoomEnd = new THREE.Vector2(), + + _touchZoomDistanceStart = 0, + _touchZoomDistanceEnd = 0, + + _panStart = new THREE.Vector2(), + _panEnd = new THREE.Vector2(); + + // for reset + + this.target0 = this.target.clone(); + this.position0 = this.object.position.clone(); + this.up0 = this.object.up.clone(); + + // events + + var changeEvent = { type: 'change' }; + var startEvent = { type: 'start' }; + var endEvent = { type: 'end' }; + + + // methods + + this.handleResize = function () { + + if ( this.domElement === document ) { + + this.screen.left = 0; + this.screen.top = 0; + this.screen.width = window.innerWidth; + this.screen.height = window.innerHeight; + + } else { + + var box = this.domElement.getBoundingClientRect(); + // adjustments come from similar code in the jquery offset() function + var d = this.domElement.ownerDocument.documentElement; + this.screen.left = box.left + window.pageXOffset - d.clientLeft; + this.screen.top = box.top + window.pageYOffset - d.clientTop; + this.screen.width = box.width; + this.screen.height = box.height; + + } + + }; + + this.handleEvent = function ( event ) { + + if ( typeof this[ event.type ] == 'function' ) { + + this[ event.type ]( event ); + + } + + }; + + var getMouseOnScreen = ( function () { + + var vector = new THREE.Vector2(); + + return function getMouseOnScreen( pageX, pageY ) { + + vector.set( + ( pageX - _this.screen.left ) / _this.screen.width, + ( pageY - _this.screen.top ) / _this.screen.height + ); + + return vector; + + }; + + }() ); + + var getMouseOnCircle = ( function () { + + var vector = new THREE.Vector2(); + + return function getMouseOnCircle( pageX, pageY ) { + + vector.set( + ( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ), + ( ( _this.screen.height + 2 * ( _this.screen.top - pageY ) ) / _this.screen.width ) // screen.width intentional + ); + + return vector; + + }; + + }() ); + + this.rotateCamera = ( function() { + + var axis = new THREE.Vector3(), + quaternion = new THREE.Quaternion(), + eyeDirection = new THREE.Vector3(), + objectUpDirection = new THREE.Vector3(), + objectSidewaysDirection = new THREE.Vector3(), + moveDirection = new THREE.Vector3(), + angle; + + return function rotateCamera() { + + moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 ); + angle = moveDirection.length(); + + if ( angle ) { + + _eye.copy( _this.object.position ).sub( _this.target ); + + eyeDirection.copy( _eye ).normalize(); + objectUpDirection.copy( _this.object.up ).normalize(); + objectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize(); + + objectUpDirection.setLength( _moveCurr.y - _movePrev.y ); + objectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x ); + + moveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) ); + + axis.crossVectors( moveDirection, _eye ).normalize(); + + angle *= _this.rotateSpeed; + quaternion.setFromAxisAngle( axis, angle ); + + _eye.applyQuaternion( quaternion ); + _this.object.up.applyQuaternion( quaternion ); + + _lastAxis.copy( axis ); + _lastAngle = angle; + + } else if ( ! _this.staticMoving && _lastAngle ) { + + _lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor ); + _eye.copy( _this.object.position ).sub( _this.target ); + quaternion.setFromAxisAngle( _lastAxis, _lastAngle ); + _eye.applyQuaternion( quaternion ); + _this.object.up.applyQuaternion( quaternion ); + + } + + _movePrev.copy( _moveCurr ); + + }; + + }() ); + + + this.zoomCamera = function () { + + var factor; + + if ( _state === STATE.TOUCH_ZOOM_PAN ) { + + factor = _touchZoomDistanceStart / _touchZoomDistanceEnd; + _touchZoomDistanceStart = _touchZoomDistanceEnd; + _eye.multiplyScalar( factor ); + + } else { + + factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed; + + if ( factor !== 1.0 && factor > 0.0 ) { + + _eye.multiplyScalar( factor ); + + } + + if ( _this.staticMoving ) { + + _zoomStart.copy( _zoomEnd ); + + } else { + + _zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor; + + } + + } + + }; + + this.panCamera = ( function() { + + var mouseChange = new THREE.Vector2(), + objectUp = new THREE.Vector3(), + pan = new THREE.Vector3(); + + return function panCamera() { + + mouseChange.copy( _panEnd ).sub( _panStart ); + + if ( mouseChange.lengthSq() ) { + + mouseChange.multiplyScalar( _eye.length() * _this.panSpeed ); + + pan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x ); + pan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) ); + + _this.object.position.add( pan ); + _this.target.add( pan ); + + if ( _this.staticMoving ) { + + _panStart.copy( _panEnd ); + + } else { + + _panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) ); + + } + + } + + }; + + }() ); + + this.checkDistances = function () { + + if ( ! _this.noZoom || ! _this.noPan ) { + + if ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) { + + _this.object.position.addVectors( _this.target, _eye.setLength( _this.maxDistance ) ); + _zoomStart.copy( _zoomEnd ); + + } + + if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) { + + _this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) ); + _zoomStart.copy( _zoomEnd ); + + } + + } + + }; + + this.update = function () { + + _eye.subVectors( _this.object.position, _this.target ); + + if ( ! _this.noRotate ) { + + _this.rotateCamera(); + + } + + if ( ! _this.noZoom ) { + + _this.zoomCamera(); + + } + + if ( ! _this.noPan ) { + + _this.panCamera(); + + } + + _this.object.position.addVectors( _this.target, _eye ); + + _this.checkDistances(); + + _this.object.lookAt( _this.target ); + + if ( lastPosition.distanceToSquared( _this.object.position ) > EPS ) { + + _this.dispatchEvent( changeEvent ); + + lastPosition.copy( _this.object.position ); + + } + + }; + + this.reset = function () { + + _state = STATE.NONE; + _prevState = STATE.NONE; + + _this.target.copy( _this.target0 ); + _this.object.position.copy( _this.position0 ); + _this.object.up.copy( _this.up0 ); + + _eye.subVectors( _this.object.position, _this.target ); + + _this.object.lookAt( _this.target ); + + _this.dispatchEvent( changeEvent ); + + lastPosition.copy( _this.object.position ); + + }; + + // listeners + + function keydown( event ) { + + if ( _this.enabled === false ) return; + + window.removeEventListener( 'keydown', keydown ); + + _prevState = _state; + + if ( _state !== STATE.NONE ) { + + return; + + } else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) { + + _state = STATE.ROTATE; + + } else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) { + + _state = STATE.ZOOM; + + } else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) { + + _state = STATE.PAN; + + } + + } + + function keyup( event ) { + + if ( _this.enabled === false ) return; + + _state = _prevState; + + window.addEventListener( 'keydown', keydown, false ); + + } + + function mousedown( event ) { + + if ( _this.enabled === false ) return; + + event.preventDefault(); + event.stopPropagation(); + + if ( _state === STATE.NONE ) { + + _state = event.button; + + } + + if ( _state === STATE.ROTATE && ! _this.noRotate ) { + + _moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) ); + _movePrev.copy( _moveCurr ); + + } else if ( _state === STATE.ZOOM && ! _this.noZoom ) { + + _zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) ); + _zoomEnd.copy( _zoomStart ); + + } else if ( _state === STATE.PAN && ! _this.noPan ) { + + _panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) ); + _panEnd.copy( _panStart ); + + } + + document.addEventListener( 'mousemove', mousemove, false ); + document.addEventListener( 'mouseup', mouseup, false ); + + _this.dispatchEvent( startEvent ); + + } + + function mousemove( event ) { + + if ( _this.enabled === false ) return; + + event.preventDefault(); + event.stopPropagation(); + + if ( _state === STATE.ROTATE && ! _this.noRotate ) { + + _movePrev.copy( _moveCurr ); + _moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) ); + + } else if ( _state === STATE.ZOOM && ! _this.noZoom ) { + + _zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) ); + + } else if ( _state === STATE.PAN && ! _this.noPan ) { + + _panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) ); + + } + + } + + function mouseup( event ) { + + if ( _this.enabled === false ) return; + + event.preventDefault(); + event.stopPropagation(); + + _state = STATE.NONE; + + document.removeEventListener( 'mousemove', mousemove ); + document.removeEventListener( 'mouseup', mouseup ); + _this.dispatchEvent( endEvent ); + + } + + function mousewheel( event ) { + + if ( _this.enabled === false ) return; + + event.preventDefault(); + event.stopPropagation(); + + switch ( event.deltaMode ) { + + case 2: + // Zoom in pages + _zoomStart.y -= event.deltaY * 0.025; + break; + + case 1: + // Zoom in lines + _zoomStart.y -= event.deltaY * 0.01; + break; + + default: + // undefined, 0, assume pixels + _zoomStart.y -= event.deltaY * 0.00025; + break; + + } + + _this.dispatchEvent( startEvent ); + _this.dispatchEvent( endEvent ); + + } + + function touchstart( event ) { + + if ( _this.enabled === false ) return; + + switch ( event.touches.length ) { + + case 1: + _state = STATE.TOUCH_ROTATE; + _moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) ); + _movePrev.copy( _moveCurr ); + break; + + default: // 2 or more + _state = STATE.TOUCH_ZOOM_PAN; + var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; + var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; + _touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy ); + + var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2; + var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2; + _panStart.copy( getMouseOnScreen( x, y ) ); + _panEnd.copy( _panStart ); + break; + + } + + _this.dispatchEvent( startEvent ); + + } + + function touchmove( event ) { + + if ( _this.enabled === false ) return; + + event.preventDefault(); + event.stopPropagation(); + + switch ( event.touches.length ) { + + case 1: + _movePrev.copy( _moveCurr ); + _moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) ); + break; + + default: // 2 or more + var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX; + var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY; + _touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy ); + + var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2; + var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2; + _panEnd.copy( getMouseOnScreen( x, y ) ); + break; + + } + + } + + function touchend( event ) { + + if ( _this.enabled === false ) return; + + switch ( event.touches.length ) { + + case 0: + _state = STATE.NONE; + break; + + case 1: + _state = STATE.TOUCH_ROTATE; + _moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) ); + _movePrev.copy( _moveCurr ); + break; + + } + + _this.dispatchEvent( endEvent ); + + } + + function contextmenu( event ) { + + event.preventDefault(); + + } + + this.dispose = function() { + + this.domElement.removeEventListener( 'contextmenu', contextmenu, false ); + this.domElement.removeEventListener( 'mousedown', mousedown, false ); + this.domElement.removeEventListener( 'wheel', mousewheel, false ); + + this.domElement.removeEventListener( 'touchstart', touchstart, false ); + this.domElement.removeEventListener( 'touchend', touchend, false ); + this.domElement.removeEventListener( 'touchmove', touchmove, false ); + + document.removeEventListener( 'mousemove', mousemove, false ); + document.removeEventListener( 'mouseup', mouseup, false ); + + window.removeEventListener( 'keydown', keydown, false ); + window.removeEventListener( 'keyup', keyup, false ); + + }; + + this.domElement.addEventListener( 'contextmenu', contextmenu, false ); + this.domElement.addEventListener( 'mousedown', mousedown, false ); + this.domElement.addEventListener( 'wheel', mousewheel, false ); + + this.domElement.addEventListener( 'touchstart', touchstart, false ); + this.domElement.addEventListener( 'touchend', touchend, false ); + this.domElement.addEventListener( 'touchmove', touchmove, false ); + + window.addEventListener( 'keydown', keydown, false ); + window.addEventListener( 'keyup', keyup, false ); + + this.handleResize(); + + // force an update at start + this.update(); + +}; + +THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype ); +THREE.TrackballControls.prototype.constructor = THREE.TrackballControls; diff --git a/dependencies/VRControls.js b/dependencies/VRControls.js old mode 100644 new mode 100755 diff --git a/dependencies/VREffect.js b/dependencies/VREffect.js old mode 100644 new mode 100755 diff --git a/dependencies/ViveController.js b/dependencies/ViveController.js old mode 100644 new mode 100755 diff --git a/dependencies/WebVR.js b/dependencies/WebVR.js old mode 100644 new mode 100755 diff --git a/dependencies/binary_stl_writer.js b/dependencies/binary_stl_writer.js old mode 100644 new mode 100755 diff --git a/dependencies/bootstrap.min.css b/dependencies/bootstrap.min.css old mode 100644 new mode 100755 diff --git a/dependencies/flat-ui.min.css b/dependencies/flat-ui.min.css old mode 100644 new mode 100755 diff --git a/dependencies/flat-ui.min.js b/dependencies/flat-ui.min.js old mode 100644 new mode 100755 diff --git a/dependencies/jquery-3.1.1.min.js b/dependencies/jquery-3.1.1.min.js old mode 100644 new mode 100755 diff --git a/dependencies/jquery-ui.min.css b/dependencies/jquery-ui.min.css old mode 100644 new mode 100755 diff --git a/dependencies/jquery-ui.min.js b/dependencies/jquery-ui.min.js old mode 100644 new mode 100755 diff --git a/dependencies/numeric-1.2.6.js b/dependencies/numeric-1.2.6.js old mode 100644 new mode 100755 diff --git a/dependencies/numeric-1.2.6.min.js b/dependencies/numeric-1.2.6.min.js old mode 100644 new mode 100755 diff --git a/favicon.ico b/favicon.ico old mode 100644 new mode 100755 diff --git a/fonts/glyphicons/flat-ui-icons-regular.ttf b/fonts/glyphicons/flat-ui-icons-regular.ttf old mode 100644 new mode 100755 diff --git a/index.html b/index.html old mode 100644 new mode 100755 index 5e6a0f1..1189e3a --- a/index.html +++ b/index.html @@ -353,7 +353,7 @@ - + diff --git a/js/3dUI.js b/js/3dUI.js old mode 100644 new mode 100755 diff --git a/js/ViveInterface.js b/js/ViveInterface.js old mode 100644 new mode 100755 index 5fc3b29..6008946 --- a/js/ViveInterface.js +++ b/js/ViveInterface.js @@ -15,7 +15,7 @@ function initViveInterface(globals){ $status.html("No device connected."); $("#VRoptions").show(); - var mesh = new THREE.Mesh(new THREE.CubeGeometry(1, 1,1 ), new THREE.MeshLambertMaterial({color:0xff0000})); + var mesh = new THREE.Mesh(new THREE.CubeGeometry(1,1,1), new THREE.MeshLambertMaterial({color:0xff0000})); var controls = new THREE.VRControls(globals.threeView.camera); controls.standing = true; @@ -44,16 +44,18 @@ function initViveInterface(globals){ document.body.appendChild(button); var callback = button.onclick; button.onclick = function () { - if (display.isPresenting) globals.vrEnabled = false; - else globals.vrEnabled = true; + globals.vrEnabled = !display.isPresenting; + var y = 0; + if (globals.vrEnabled) y = 1; + globals.threeView.modelWrapper.position.set(0,y,0); + // var scale = 0.01; + // globals.threeView.modelWrapper.scale.set(scale, scale, scale); if (callback) callback(); }; - } ); } function disconnect(){ - } function render(){ diff --git a/js/beam.js b/js/beam.js old mode 100644 new mode 100755 diff --git a/js/controls.js b/js/controls.js old mode 100644 new mode 100755 diff --git a/js/crease.js b/js/crease.js old mode 100644 new mode 100755 diff --git a/js/dynamic/GLBoilerplate.js b/js/dynamic/GLBoilerplate.js old mode 100644 new mode 100755 diff --git a/js/dynamic/GPUMath.js b/js/dynamic/GPUMath.js old mode 100644 new mode 100755 diff --git a/js/dynamic/dynamicSolver.js b/js/dynamic/dynamicSolver.js old mode 100644 new mode 100755 diff --git a/js/globals.js b/js/globals.js old mode 100644 new mode 100755 diff --git a/js/importer.js b/js/importer.js old mode 100644 new mode 100755 diff --git a/js/main.js b/js/main.js old mode 100644 new mode 100755 diff --git a/js/model.js b/js/model.js old mode 100644 new mode 100755 index 5ba53dd..0213f9e --- a/js/model.js +++ b/js/model.js @@ -174,7 +174,7 @@ function initModel(globals){ if (globals.colorMode == "axialStrain") geometry.attributes.color.needsUpdate = true; geometry.computeVertexNormals(); // geometry.computeBoundingBox(); - // geometry.computeBoundingSphere(); + geometry.computeBoundingSphere(); } var inited = false; @@ -318,7 +318,7 @@ function initModel(globals){ geometry.computeBoundingSphere(); geometry.center(); - var scale = 100/geometry.boundingSphere.radius; + var scale = 1/geometry.boundingSphere.radius; globals.scale = scale; object3D.geometry.dispose(); diff --git a/js/node.js b/js/node.js old mode 100644 new mode 100755 diff --git a/js/pattern.js b/js/pattern.js old mode 100644 new mode 100755 diff --git a/js/saveFOLD.js b/js/saveFOLD.js old mode 100644 new mode 100755 diff --git a/js/saveSTL.js b/js/saveSTL.js old mode 100644 new mode 100755 diff --git a/js/staticSolver.js b/js/staticSolver.js old mode 100644 new mode 100755 diff --git a/js/threeView.js b/js/threeView.js old mode 100644 new mode 100755 index 5ddfd48..cae7ed5 --- a/js/threeView.js +++ b/js/threeView.js @@ -6,13 +6,15 @@ function initThreeView(globals) { var scene = new THREE.Scene(); var modelWrapper = new THREE.Object3D(); - var camera = new THREE.OrthographicCamera(window.innerWidth / -2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / -2, -10000, 10000);//-40, 40); + + var camera = new THREE.PerspectiveCamera(70, window.innerWidth/window.innerHeight, 0.01, 1000); + // 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 controls; - var depthMaterial, effectComposer, depthRenderTarget; - var ssaoPass; + // var depthMaterial, effectComposer, depthRenderTarget; + // var ssaoPass; var animationRunning = false; var pauseFlag = false; @@ -45,52 +47,52 @@ function initThreeView(globals) { var directionalLight5 = new THREE.DirectionalLight(0xffffff, 0.3); directionalLight5.position.set(0, 30, -100); scene.add(directionalLight5); - var ambientLight = new THREE.AmbientLight(0xffffff, 0.1); + // var ambientLight = new THREE.AmbientLight(0xffffff, 0.1); // scene.add(ambientLight); //scene.fog = new THREE.FogExp2(0xf4f4f4, 1.7); //renderer.setClearColor(scene.fog.color); scene.add(camera); - camera.zoom = 5; + camera.zoom = 25; camera.updateProjectionMatrix(); - camera.position.x = 200; - camera.position.y = 200; - camera.position.z = 200; + camera.position.x = 10; + camera.position.y = 10; + camera.position.z = 10; - controls = new THREE.OrthographicTrackballControls(camera, renderer.domElement); - controls.rotateSpeed = 1.5; - controls.zoomSpeed = 0.8; + controls = new THREE.TrackballControls(camera, renderer.domElement); + controls.rotateSpeed = 1.0; + controls.zoomSpeed = 1.2; controls.noPan = true; controls.staticMoving = true; controls.dynamicDampingFactor = 0.3; controls.addEventListener("change", render); - var renderPass = new THREE.RenderPass( scene, camera ); + // var renderPass = new THREE.RenderPass( scene, camera ); // Setup depth pass - depthMaterial = new THREE.MeshDepthMaterial(); - depthMaterial.depthPacking = THREE.RGBADepthPacking; - depthMaterial.blending = THREE.NoBlending; - - var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter }; - depthRenderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars ); - - // Setup SSAO pass - ssaoPass = new THREE.ShaderPass( THREE.SSAOShader ); - ssaoPass.renderToScreen = true; - //ssaoPass.uniforms[ "tDiffuse" ].value will be set by ShaderPass - ssaoPass.uniforms[ "tDepth" ].value = depthRenderTarget.texture; - ssaoPass.uniforms[ 'size' ].value.set( window.innerWidth, window.innerHeight ); - ssaoPass.uniforms[ 'cameraNear' ].value = camera.near; - ssaoPass.uniforms[ 'cameraFar' ].value = camera.far; - ssaoPass.uniforms[ 'onlyAO' ].value = 0; - ssaoPass.uniforms[ 'aoClamp' ].value = 0.7; - ssaoPass.uniforms[ 'lumInfluence' ].value = 0.8; - // Add pass to effect composer - effectComposer = new THREE.EffectComposer( renderer ); - effectComposer.addPass( renderPass ); - effectComposer.addPass( ssaoPass ); + // depthMaterial = new THREE.MeshDepthMaterial(); + // depthMaterial.depthPacking = THREE.RGBADepthPacking; + // depthMaterial.blending = THREE.NoBlending; + + // var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter }; + // depthRenderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars ); + // + // // Setup SSAO pass + // ssaoPass = new THREE.ShaderPass( THREE.SSAOShader ); + // ssaoPass.renderToScreen = true; + // //ssaoPass.uniforms[ "tDiffuse" ].value will be set by ShaderPass + // ssaoPass.uniforms[ "tDepth" ].value = depthRenderTarget.texture; + // ssaoPass.uniforms[ 'size' ].value.set( window.innerWidth, window.innerHeight ); + // ssaoPass.uniforms[ 'cameraNear' ].value = camera.near; + // ssaoPass.uniforms[ 'cameraFar' ].value = camera.far; + // ssaoPass.uniforms[ 'onlyAO' ].value = 0; + // ssaoPass.uniforms[ 'aoClamp' ].value = 0.7; + // ssaoPass.uniforms[ 'lumInfluence' ].value = 0.8; + // // Add pass to effect composer + // effectComposer = new THREE.EffectComposer( renderer ); + // effectComposer.addPass( renderPass ); + // effectComposer.addPass( ssaoPass ); } function render() { @@ -126,15 +128,15 @@ function initThreeView(globals) { globals.vive.render(); return; } - if (globals.ambientOcclusion) { - // Render depth into depthRenderTarget - scene.overrideMaterial = depthMaterial; - renderer.render(scene, camera, depthRenderTarget, true); - // Render renderPass and SSAO shaderPass - scene.overrideMaterial = null; - effectComposer.render(); - return; - } + // if (globals.ambientOcclusion) { + // // Render depth into depthRenderTarget + // scene.overrideMaterial = depthMaterial; + // renderer.render(scene, camera, depthRenderTarget, true); + // // Render renderPass and SSAO shaderPass + // scene.overrideMaterial = null; + // effectComposer.render(); + // return; + // } renderer.render(scene, camera); } @@ -146,6 +148,7 @@ function initThreeView(globals) { }); return; } + controls.update();//todo put this above callback? requestAnimationFrame(function(){ if (pauseFlag) { pauseFlag = false; @@ -172,23 +175,24 @@ function initThreeView(globals) { function onWindowResize() { camera.aspect = window.innerWidth / window.innerHeight; - camera.left = -window.innerWidth / 2; - camera.right = window.innerWidth / 2; - camera.top = window.innerHeight / 2; - camera.bottom = -window.innerHeight / 2; + // camera.left = -window.innerWidth / 2; + // camera.right = window.innerWidth / 2; + // camera.top = window.innerHeight / 2; + // camera.bottom = -window.innerHeight / 2; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); + controls.handleResize(); - var width = window.innerWidth; - var height = window.innerHeight; + // var width = window.innerWidth; + // var height = window.innerHeight; - ssaoPass.uniforms[ 'size' ].value.set( width, height ); - var pixelRatio = renderer.getPixelRatio(); - var newWidth = Math.floor( width / pixelRatio ) || 1; - var newHeight = Math.floor( height / pixelRatio ) || 1; - depthRenderTarget.setSize( newWidth, newHeight ); - effectComposer.setSize( newWidth, newHeight ); + // ssaoPass.uniforms[ 'size' ].value.set( width, height ); + // var pixelRatio = renderer.getPixelRatio(); + // var newWidth = Math.floor( width / pixelRatio ) || 1; + // var newHeight = Math.floor( height / pixelRatio ) || 1; + // depthRenderTarget.setSize( newWidth, newHeight ); + // effectComposer.setSize( newWidth, newHeight ); render(); } @@ -242,6 +246,7 @@ function initThreeView(globals) { scene: scene, camera: camera, renderer: renderer, + modelWrapper:modelWrapper, running: running, setScale:setScale, saveSVG: saveSVG diff --git a/logo-active.png b/logo-active.png old mode 100644 new mode 100755 diff --git a/logo.png b/logo.png old mode 100644 new mode 100755