repo: janusweb
action: commit
revision: 
path_from: 
revision_from: db987b38a40d2dc008a7c92131ceee47b4d85528:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit db987b38a40d2dc008a7c92131ceee47b4d85528
Author: James Baicoianu 
Date:   Mon Apr 11 02:27:10 2016 -0700

    Cleaned up and fixed janusvideo class

diff --git a/scripts/video.js b/scripts/video.js
index d9be08fe490bb2476564082102eb0dd4bcfc4c11..
index ..d4e803afa49b38508f3fc93ae18a70623c35e63e 100644
--- a/scripts/video.js
+++ b/scripts/video.js
@@ -4,20 +4,39 @@ elation.require(['engine.things.theaterscreen'], function() {
       elation.engine.things.janusvideo.extendclass.postinit.call(this);
       this.defineProperties({
         //src: { type: 'string' },
+        video_id: { type: 'string' },
         loop: { type: 'boolean', default: false },
         color: { type: 'color', default: 0xffffff },
         lighting: { type: 'boolean', default: true },
       });
     }
     this.createObject3D = function() {
-      var plane = new THREE.PlaneBufferGeometry(1,1);
-      plane.applyMatrix(new THREE.Matrix4().makeTranslation(0, 0, 0.1));
+      this.asset = elation.engine.assets.find('video', this.properties.video_id, true);
+      if (this.asset) {
+        elation.events.add(this.texture, 'asset_load', elation.bind(this, this.imageloaded));

-      if (!this.video) {
-        this.createVideo();
+        var geo = this.createGeometry();
+        var mat = this.createMaterial();
+        return new THREE.Mesh(geo, mat);
+      } else {
+        console.log('ERROR - could not find video ' + this.properties.video_id);
+      }
+    }
+    this.createMaterial = function() {
+      if (this.asset) {
+        var texture = this.texture = this.asset.getAsset();
+        if (this.asset.sbs3d) {
+          texture.repeat.x = 0.5;
+        }
+        if (this.asset.ou3d) {
+          texture.repeat.y = 0.5;
+        }
+        if (true || this.asset.auto_play) {
+          texture.image.play();
+        }
+        elation.events.add(texture, 'videoframe', elation.bind(this, this.refresh));
       }

-      this.texture = new THREE.Texture( this.video );
       this.texture.minFilter = THREE.LinearFilter;
       this.texture.magFilter = THREE.LinearFilter;
       this.texture.format = THREE.RGBFormat;
@@ -32,12 +51,9 @@ elation.require(['engine.things.theaterscreen'], function() {
         side: THREE.DoubleSide
       };
       //plane.applyMatrix(new THREE.Matrix4().makeTranslation(.5,-.5,0));
-      //var mat = new THREE.MeshBasicMaterial(matargs);
       var mat = (this.properties.lighting ? new THREE.MeshPhongMaterial(matargs) : new THREE.MeshBasicMaterial(matargs));
-      var mesh = new THREE.Mesh(plane, mat);
-      mesh.renderOrder = 2;
-      return mesh;
+      return mat;
     }
-  }, elation.engine.things.theaterscreen);
+  }, elation.engine.things.janusimage);
 });

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