repo: janusweb
action: commit
revision: 
path_from: 
revision_from: bed2c2da2a6f733c851af1fa2746d011ed46e068:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit bed2c2da2a6f733c851af1fa2746d011ed46e068
Author: James Baicoianu 
Date:   Thu Apr 28 03:35:48 2016 -0700

    video.loop, fix blend_dest, click to pause, convert image to canvas

diff --git a/scripts/object.js b/scripts/object.js
index 52b778e4cb571e156245dceeeb484b5626ac33d2..
index ..859537084e86a17419b80f5c9d56cfe5771fc2c6 100644
--- a/scripts/object.js
+++ b/scripts/object.js
@@ -11,6 +11,7 @@ elation.require(['janusweb.janusbase'], function() {
         room: { type: 'object' },
         image_id: { type: 'string' },
         video_id: { type: 'string' },
+        loop: { type: 'boolean' },
         collision_id: { type: 'string' },
         websurface_id: { type: 'string' },
         lighting: { type: 'boolean', default: true },
@@ -101,10 +102,17 @@ console.log('assign textures', this.name, this);
           if (videoasset.sbs3d) {
             texture.repeat.x = 0.5;
           }
+          if (videoasset.loop || this.properties.loop) {
+            texture.image.loop = true;
+          }
           if (videoasset.auto_play) {
             texture.image.play();
           }
+          texture.minFilter = THREE.LinearFilter;
+          texture.magFilter = THREE.LinearFilter;
           elation.events.add(texture, 'videoframe', elation.bind(this, this.refresh));
+          elation.events.add(this, 'click', elation.bind(this, this.pauseVideo));
+          this.videotexture = texture;
         }
       }
       if (this.properties.col) {
@@ -121,14 +129,16 @@ console.log('assign textures', this.name, this);
         'one': THREE.OneFactor,
         'src_color': THREE.SrcColorFactor,
         'one_minus_src_color': THREE.OneMinusSrcColorFactor,
+        'one_minus_src_alpha': THREE.OneMinusSrcAlphaFactor,
         'dst_color': THREE.DstColorFactor,
         'one_minus_dst_color': THREE.OneMinusDstColorFactor,
+        'one_minus_dst_alpha': THREE.OneMinusDstAlphaFactor,
       }
       if (srcfactors[this.properties.blend_src]) {
         blend_src = srcfactors[this.properties.blend_src];
       }
-      if (srcfactors[this.properties.blend_dst]) {
-        blend_dst = srcfactors[this.properties.blend_dst];
+      if (srcfactors[this.properties.blend_dest]) {
+        blend_dest = srcfactors[this.properties.blend_dest];
       }

       var hasalpha = {};
@@ -174,6 +184,7 @@ console.log('go canvas');
                     ctx.drawImage(m.map.image, 0, 0);

                     hasalpha[ev.target.src] = this.canvasHasAlpha(canvas);
+                    m.map.image = canvas;
                   }
     //console.log(m.map, this, ev.target.src + '? ', hasalpha);
                   if (hasalpha[ev.target.src]) {
@@ -193,7 +204,7 @@ console.log('go canvas');
             }
             if (blend_src) m.blendSrc = blend_src;
             if (blend_dest) m.blendDst = blend_dest;
-            m.needsUpdate = true;
+            //m.needsUpdate = true;
           }));
           if (n.geometry) {
 /*
@@ -229,5 +240,16 @@ console.log('go canvas');
       }
       return false;
     }
+    this.pauseVideo = function() {
+      if (this.videotexture) {
+        var video = this.videotexture.image;
+        if (video.paused) {
+        if (video.currentTime > 0 && !video.paused && !video.ended) {
+          video.pause();
+        } else {
+          video.play();
+        }
+      }
+    }
   }, elation.engine.things.janusbase);
 });

-----END OF PAGE-----