Commit 279baaeb authored by amandaghassaei's avatar amandaghassaei
Browse files

animation settings

parent 7f2f119c
...@@ -620,11 +620,14 @@ ...@@ -620,11 +620,14 @@
</div> </div>
</div><br/> </div><br/>
View Angle:<br/> View Angle:<br/><br/>
<div class="indent"> <div class="indent">
<a href="#" id="cameraX" class="btn btn-lg btn-default">X</a> <a href="#" id="cameraZ" class="paddingBottom btn btn-lg btn-default">Front</a>
<a href="#" id="cameraY" class="btn btn-lg btn-default">Y</a> <a href="#" id="cameraMinusZ" class="paddingBottom btn btn-lg btn-default">Back</a>
<a href="#" id="cameraZ" class="btn btn-lg btn-default">Z</a> <a href="#" id="cameraX" class="paddingBottom btn btn-lg btn-default">Right</a>
<a href="#" id="cameraMinusX" class="paddingBottom btn btn-lg btn-default">Left</a><br/>
<a href="#" id="cameraY" class="btn btn-lg btn-default">Top</a>
<a href="#" id="cameraMinusY" class="btn btn-lg btn-default">Bottom</a>
<a href="#" id="cameraOrtho" class="btn btn-lg btn-default">Ortho</a> <a href="#" id="cameraOrtho" class="btn btn-lg btn-default">Ortho</a>
</div> </div>
</div> </div>
......
...@@ -25,13 +25,22 @@ function initControls(globals){ ...@@ -25,13 +25,22 @@ function initControls(globals){
}); });
setLink("#cameraX", function(){ setLink("#cameraX", function(){
globals.threeView.setCameraX(); globals.threeView.setCameraX(1);
}); });
setLink("#cameraY", function(){ setLink("#cameraY", function(){
globals.threeView.setCameraY(); globals.threeView.setCameraY(1);
}); });
setLink("#cameraZ", function(){ setLink("#cameraZ", function(){
globals.threeView.setCameraZ(); globals.threeView.setCameraZ(1);
});
setLink("#cameraMinusX", function(){
globals.threeView.setCameraX(-1);
});
setLink("#cameraMinusY", function(){
globals.threeView.setCameraY(-1);
});
setLink("#cameraMinusZ", function(){
globals.threeView.setCameraZ(-1);
}); });
setLink("#cameraOrtho", function(){ setLink("#cameraOrtho", function(){
globals.threeView.setCameraOrtho(); globals.threeView.setCameraOrtho();
......
...@@ -60,7 +60,6 @@ function initDynamicSolver(globals){ ...@@ -60,7 +60,6 @@ function initDynamicSolver(globals){
globals.gpuMath.step("zeroTexture", [], "u_lastPosition"); globals.gpuMath.step("zeroTexture", [], "u_lastPosition");
globals.gpuMath.step("zeroTexture", [], "u_velocity"); globals.gpuMath.step("zeroTexture", [], "u_velocity");
globals.gpuMath.step("zeroTexture", [], "u_lastVelocity"); globals.gpuMath.step("zeroTexture", [], "u_lastVelocity");
//todo reset theta
render(); render();
} }
......
...@@ -60,7 +60,6 @@ function initModel(globals){ ...@@ -60,7 +60,6 @@ function initModel(globals){
} }
object3D.material = material; object3D.material = material;
object3D2.material = material2; object3D2.material = material2;
globals.threeView.render();
} }
function updateEdgeVisibility(){ function updateEdgeVisibility(){
...@@ -74,7 +73,6 @@ function initModel(globals){ ...@@ -74,7 +73,6 @@ function initModel(globals){
for (var i=0;i<creases.length;i++){ for (var i=0;i<creases.length;i++){
creases[i].setVisibility(); creases[i].setVisibility();
} }
globals.threeView.render();
} }
function updateMeshVisibility(){ function updateMeshVisibility(){
...@@ -150,23 +148,21 @@ function initModel(globals){ ...@@ -150,23 +148,21 @@ function initModel(globals){
// }); // });
function pause(){ function pause(){
globals.threeView.pauseAnimation(); globals.threeView.pauseSimulation();
} }
function resume(){ function resume(){
startSolver(); globals.threeView.startSimulation();
} }
function reset(){ function reset(){
getSolver().reset(); getSolver().reset();
setGeoUpdates(); setGeoUpdates();
globals.threeView.render();
} }
function step(numSteps){ function step(numSteps){
getSolver().solve(numSteps); getSolver().solve(numSteps);
setGeoUpdates(); setGeoUpdates();
globals.threeView.render();
} }
function setGeoUpdates(){ function setGeoUpdates(){
......
...@@ -16,7 +16,7 @@ function initThreeView(globals) { ...@@ -16,7 +16,7 @@ function initThreeView(globals) {
// var depthMaterial, effectComposer, depthRenderTarget; // var depthMaterial, effectComposer, depthRenderTarget;
// var ssaoPass; // var ssaoPass;
var animationRunning = false; var simulationRunning = false;
var pauseFlag = false; var pauseFlag = false;
init(); init();
...@@ -66,7 +66,7 @@ function initThreeView(globals) { ...@@ -66,7 +66,7 @@ function initThreeView(globals) {
controls.noPan = true; controls.noPan = true;
controls.staticMoving = true; controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3; controls.dynamicDampingFactor = 0.3;
controls.addEventListener("change", render); // controls.addEventListener("change", render);
// var renderPass = new THREE.RenderPass( scene, camera ); // var renderPass = new THREE.RenderPass( scene, camera );
...@@ -95,50 +95,37 @@ function initThreeView(globals) { ...@@ -95,50 +95,37 @@ function initThreeView(globals) {
// effectComposer.addPass( ssaoPass ); // effectComposer.addPass( ssaoPass );
} }
function setCameraX(){ function setCameraX(sign){
controls.reset(new THREE.Vector3(1,0,0)); controls.reset(new THREE.Vector3(sign,0,0));
manuallySetCamera();
} }
function setCameraY(){ function setCameraY(sign){
controls.reset(new THREE.Vector3(0,1,0)); controls.reset(new THREE.Vector3(0,sign,0));
manuallySetCamera();
} }
function setCameraZ(){ function setCameraZ(sign){
controls.reset(new THREE.Vector3(0,0,1)); controls.reset(new THREE.Vector3(0,0,sign));
manuallySetCamera();
} }
function setCameraOrtho(){ function setCameraOrtho(){
controls.reset(new THREE.Vector3(1,1,1)); controls.reset(new THREE.Vector3(1,1,1));
manuallySetCamera();
}
function manuallySetCamera(){
render();
}
function render() {
if (!animationRunning) {
console.log("render");
_render();
}
} }
function startAnimation(callback){ function startAnimation(callback){
console.log("starting animation"); console.log("starting animation");
if (animationRunning){ simulationRunning = true;
console.warn("animation already running");
return;
}
animationRunning = true;
_loop(callback); _loop(callback);
} }
function pauseAnimation(){ function pauseSimulation(){
if (animationRunning) pauseFlag = true; if (simulationRunning) pauseFlag = true;
}
function startSimulation(){
console.log("starting simulation");
simulationRunning = true;
} }
function running(){ function running(){
return animationRunning; return simulationRunning;
} }
function _render(){ function _render(){
...@@ -159,7 +146,12 @@ function initThreeView(globals) { ...@@ -159,7 +146,12 @@ function initThreeView(globals) {
} }
function _loop(callback){ function _loop(callback){
callback(); if (pauseFlag) {
pauseFlag = false;
simulationRunning = false;
console.log("pausing simulation");
}
if (simulationRunning) callback();
if (globals.vrEnabled){ if (globals.vrEnabled){
globals.vive.effect.requestAnimationFrame(function(){ globals.vive.effect.requestAnimationFrame(function(){
_loop(callback); _loop(callback);
...@@ -168,13 +160,6 @@ function initThreeView(globals) { ...@@ -168,13 +160,6 @@ function initThreeView(globals) {
return; return;
} }
requestAnimationFrame(function(){ requestAnimationFrame(function(){
if (pauseFlag) {
pauseFlag = false;
animationRunning = false;
console.log("pausing animation");
render();//for good measure
return;
}
_loop(callback); _loop(callback);
}); });
controls.update(); controls.update();
...@@ -258,10 +243,10 @@ function initThreeView(globals) { ...@@ -258,10 +243,10 @@ function initThreeView(globals) {
return { return {
sceneAddModel: sceneAddModel, sceneAddModel: sceneAddModel,
sceneClearModel: sceneClearModel, sceneClearModel: sceneClearModel,
render: render,
onWindowResize: onWindowResize, onWindowResize: onWindowResize,
startAnimation: startAnimation, startAnimation: startAnimation,
pauseAnimation: pauseAnimation, startSimulation: startSimulation,
pauseSimulation: pauseSimulation,
enableControls: enableControls, enableControls: enableControls,
scene: scene, scene: scene,
camera: camera, camera: camera,
......
Supports Markdown
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