Commit 279baaeb authored by amandaghassaei's avatar amandaghassaei

animation settings

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