freealise commited on
Commit
f160c87
·
verified ·
1 Parent(s): c565970

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -5
app.py CHANGED
@@ -749,9 +749,9 @@ async(c, o, p, d, n, m)=>{
749
  function requestMap() {
750
  ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
751
  if (buffer) {
 
 
752
  applyDisplacementMapFromBuffer(sceneToRender.meshes[sceneToRender.meshes.length-1], buffer, video.videoWidth, video.videoHeight, 0, -1, null, null, true);
753
- counter++;
754
- if (counter == coords.length) {counter = 0;}
755
  }
756
  buffer = ctx.getImageData(0, 0, video.videoWidth, video.videoHeight).data;
757
  applyDisplacementMapFromBuffer(BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1], buffer, video.videoWidth, video.videoHeight, 0, 1, null, null, true);
@@ -774,8 +774,7 @@ async(c, o, p, d, n, m)=>{
774
  });
775
 
776
  videoDome.videoTexture.video.oncanplaythrough = function () {
777
- videoDome.videoTexture.video.play();
778
- video.play();
779
  videoDome.videoTexture.video.oncanplaythrough = null;
780
  video.oncanplaythrough = null;
781
  };
@@ -945,6 +944,21 @@ function stop_recording() {
945
  }
946
  window.stop_recording = stop_recording;
947
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
 
949
  function applyDisplacementMapFromBuffer(
950
  mesh,
@@ -1270,7 +1284,9 @@ with gr.Blocks(css=css, js=js, head=head) as demo:
1270
  snapshot = gr.HTML(value="""
1271
  <a href='#' onclick='snapshot();'>Screenshot</a>
1272
  <a href='#' onclick='record_video();'>Record</a>
1273
- <a href='#' onclick='stop_recording();'>Stop</a><br/>
 
 
1274
  <img src='' id='img_out' onload='var ctxt = document.getElementById(\"cnv_out\").getContext(\"2d\");ctxt.drawImage(this, 0, 0);'/><br/>
1275
  <canvas id='cnv_out'></canvas>
1276
  <div id='compass_box'><div id='compass'><a id='fullscreen' onclick='
 
749
  function requestMap() {
750
  ctx.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
751
  if (buffer) {
752
+ counter = parseInt(video.currentTime);
753
+ if (!coords[counter]) {counter = coords.length-1;}
754
  applyDisplacementMapFromBuffer(sceneToRender.meshes[sceneToRender.meshes.length-1], buffer, video.videoWidth, video.videoHeight, 0, -1, null, null, true);
 
 
755
  }
756
  buffer = ctx.getImageData(0, 0, video.videoWidth, video.videoHeight).data;
757
  applyDisplacementMapFromBuffer(BABYLON.Engine.LastCreatedScene.meshes[BABYLON.Engine.LastCreatedScene.meshes.length-1], buffer, video.videoWidth, video.videoHeight, 0, 1, null, null, true);
 
774
  });
775
 
776
  videoDome.videoTexture.video.oncanplaythrough = function () {
777
+ play();
 
778
  videoDome.videoTexture.video.oncanplaythrough = null;
779
  video.oncanplaythrough = null;
780
  };
 
944
  }
945
  window.stop_recording = stop_recording;
946
 
947
+ function seek() {
948
+ videoDome.videoTexture.video.pause();
949
+ video.pause();
950
+ var t = Math.random();
951
+ videoDome.videoTexture.video.currentTime = t * videoDome.videoTexture.video.duration;
952
+ video.currentTime = t * video.duration;
953
+ }
954
+ window.seek = seek;
955
+
956
+ function play() {
957
+ videoDome.videoTexture.video.play();
958
+ video.play();
959
+ }
960
+ window.play = play;
961
+
962
 
963
  function applyDisplacementMapFromBuffer(
964
  mesh,
 
1284
  snapshot = gr.HTML(value="""
1285
  <a href='#' onclick='snapshot();'>Screenshot</a>
1286
  <a href='#' onclick='record_video();'>Record</a>
1287
+ <a href='#' onclick='stop_recording();'>Stop rec.</a>
1288
+ <a href='#' onclick='seek();'>Seek</a>
1289
+ <a href='#' onclick='play();'>Play</a><br/>
1290
  <img src='' id='img_out' onload='var ctxt = document.getElementById(\"cnv_out\").getContext(\"2d\");ctxt.drawImage(this, 0, 0);'/><br/>
1291
  <canvas id='cnv_out'></canvas>
1292
  <div id='compass_box'><div id='compass'><a id='fullscreen' onclick='