Răsfoiți Sursa

Merge remote-tracking branch 'upstream/lcs-2020.1-5'

Nikolay Suslov 4 ani în urmă
părinte
comite
ce59c0c9d5

+ 21 - 6
public/vwf/model/aframe/addon/aframe-components.js

@@ -8,8 +8,6 @@ if (typeof AFRAME === 'undefined') {
 }
 
 AFRAME.registerComponent('avatar', {
-
-
     init: function () {
     },
     tick: function () {  
@@ -23,6 +21,7 @@ AFRAME.registerComponent('scene-utils', {
 
     init: function () {
         this.mirrors = {};
+        this.interpolationComponents = {};
 
         //this.setCameraControl();
         const sceneEnterVR = (e) => {
@@ -36,7 +35,7 @@ AFRAME.registerComponent('scene-utils', {
 
             if (driver.threeDoFMobile || _app.config.d3DoF ) {
                 driver.threeDoF = true;
-                 vwf_view.kernel.callMethod(avatarID, "updateYPositionForXR", [0.0]);
+                 //vwf_view.kernel.callMethod(avatarID, "updateYPositionForXR", [0.0]);
             } else if (driver.sixDoFMobile || driver.sixDoFDesktop || _app.config.d6DoF ) {
                 driver.sixDoF = true;
             }
@@ -52,7 +51,7 @@ AFRAME.registerComponent('scene-utils', {
             
             if (driver.threeDoFMobile || _app.config.d3DoF ) {
                 driver.threeDoF = false;
-                vwf_view.kernel.callMethod(avatarID, "updateYPositionForXR", [-1.6]);
+                //vwf_view.kernel.callMethod(avatarID, "updateYPositionForXR", [-1.6]);
 
             } else if (driver.sixDoFMobile || driver.sixDoFDesktop || _app.config.d6DoF ) {
                 driver.sixDoF = false;
@@ -98,11 +97,23 @@ AFRAME.registerComponent('scene-utils', {
 
     },
 
-     tick: function (t) {
+     tick: function (t, dt) {
 
             Object.values(this.mirrors).forEach(el => {
                 el.mirrorTick.call(el)
-            })
+            });
+            
+            // Object.values(this.interpolationComponents).forEach(el => {
+            //     el.interpolationTick.call(el, t, dt)
+            // });
+
+     },
+
+     tock: function (t, dt) {
+
+        // Object.values(this.interpolationComponents).forEach(el => {
+        //     el.interpolationTock.call(el, t, dt)
+        // });
 
      }
 })
@@ -567,20 +578,24 @@ AFRAME.registerComponent('xrcontroller', {
 
         this.el.addEventListener('triggerdown', function (event) { //pointdown 'triggerdown'
             vwf_view.kernel.callMethod(self.controllerID, "triggerdown", []);
+            //this.emit('teleportstart');
         });
         this.el.addEventListener('triggerup', function (event) { //pointup 'triggerup'
             vwf_view.kernel.callMethod(self.controllerID, "triggerup", []);
+            //this.emit('teleportend');
         });
 
          //X-buttorn Pressed 
          this.el.addEventListener('xbuttondown', function (e) { //xbuttondown
             //Start pointing position to teleport  
+            console.log('TELEPORT START: ', e);
             this.emit('teleportstart');
         });
 
         //X-buttorn Released 
         this.el.addEventListener('xbuttonup', function (e) { //xbuttonup
             //Jump to pointed position
+            console.log('TELEPORT END: ', e);
             this.emit('teleportend');
         });
 

+ 8 - 1
public/vwf/model/aframe/addon/aframe-interpolation.js

@@ -19,6 +19,7 @@ AFRAME.registerComponent('interpolation', {
   init: function () {
 
     this.driver = vwf.views["vwf/view/aframeComponent"];
+    //this.el.sceneEl.components['scene-utils'].interpolationComponents[this.el.id] = this;
 
   },
 
@@ -39,11 +40,16 @@ AFRAME.registerComponent('interpolation', {
    * Called when a component is removed (e.g., via removeAttribute).
    * Generally undoes all modifications to the entity.
    */
-  remove: function () { },
+  remove: function () { 
+
+    //delete this.el.sceneEl.components['scene-utils'].interpolationComponents[this.el.id]
+
+  },
 
   /**
    * Called on each scene tick.
    */
+  // interpolationTick
   tick: function (t, dt) {
 
 
@@ -72,6 +78,7 @@ AFRAME.registerComponent('interpolation', {
 
   },
 
+  //interpolationTock
   tock: function (t, dt) {
     if (this.node) {
       if (this.enabled && this.node.interpolate && this.driver.interpolateView) {

+ 1 - 1
public/vwf/model/aframe/addon/aframe-teleport-controls.js

@@ -548,7 +548,7 @@
 	  this.uvs = new Float32Array(numPoints * 2 * 2);
 	  this.width = width;
 
-	  this.geometry.setAttribute('position', new THREE.BufferAttribute(this.vertices, 3).setUsage(true));
+	  this.geometry.setAttribute('position', new THREE.BufferAttribute(this.vertices, 3).setUsage(THREE.DynamicDrawUsage));
 
 	  this.material = new THREE.MeshBasicMaterial({
 	    side: THREE.DoubleSide,

+ 30 - 32
public/vwf/view/aframe.js

@@ -651,23 +651,22 @@ define(["module", "vwf/view"], function (module, view) {
         if (!node.aframeObj) return;
 
        let el = document.querySelector('#avatarControl');
-        if (el) {
-            //let position = el.object3D.getWorldPosition(); //el.getAttribute('position');
-
-            //var position;
-            // if((self.hmd && self.sixDoF) || _app.config.d6DoF){
-            //     position = el.getAttribute('position');
-            // } else {
-            //     position = new THREE.Vector3();
-            //     el.object3D.getWorldPosition(position);
-            // }
-            //let position = el.getAttribute('position');
+       let elA = document.querySelector('#avatarControlParent');
+        if (el && elA) {
+
+            var position;
+
+             if((self.hmd && self.sixDoF) || (self.hmd && self.threeDoF) || _app.config.d6DoF || _app.config.d3DoF){
 
-            //let position = el.getAttribute('position');
-            //let position = el.object3D.position.clone();
-            let position = new THREE.Vector3();
-            el.object3D.localToWorld(position);
+                let positionC = el.object3D.position.clone();
+                let positionA = elA.object3D.position.clone();
+
+                position = positionC.add(positionA);
+            } else {
+                position = el.object3D.position;
+            }
 
+            //let position = el.object3D.position.add(elA.object3D.position);
             let rotation = el.getAttribute('rotation'); //getWorldRotation(el, 'YXZ');
 
             let lastRotation = self.nodes[avatarName].selfTickRotation;
@@ -684,7 +683,7 @@ define(["module", "vwf/view"], function (module, view) {
 
                 if (distance > delta)
                 {
-                    console.log("position not equal");
+                   // console.log("position not equal");
                     self.kernel.setProperty(avatarName, "position", position);
                 }
             }
@@ -692,7 +691,7 @@ define(["module", "vwf/view"], function (module, view) {
             if (rotation && lastRotation) {
                 let distance = Math.abs(rotation.y - lastRotation.y);
                 if ( distance > delta) {
-                    console.log("rotation not equal")
+                    //console.log("rotation not equal")
                     self.kernel.callMethod(avatarName, "updateAvatarRotation", [rotation]);
                 }
             }
@@ -714,20 +713,14 @@ define(["module", "vwf/view"], function (module, view) {
         if (!node) return;
         if (!node.aframeObj) return;
 
+        let elA = document.querySelector('#avatarControlParent');
         let el = document.querySelector(aSelector);
-        if (el) {
-            //let position = el.object3D.getWorldPosition() //el.getAttribute('position');
+        if (el && elA) {
 
-            // let position = new THREE.Vector3();
-            // el.object3D.getWorldPosition(position);
-            // let rotation = getWorldRotation(el, 'XYZ');
+            let positionC = el.object3D.position.clone();
+            let positionA = elA.object3D.position.clone();
+            let position = positionC.add(positionA);
 
-            // let position = el.getAttribute('position');
-            // let rotation = el.getAttribute('rotation');
-
-           // let position = el.object3D.position;
-           let position = new THREE.Vector3();
-           el.object3D.localToWorld(position);
             let rotation = el.getAttribute('rotation'); //getWorldRotation(el, 'YXZ');
 
             let lastRotation = self.nodes[avatarName].selfTickRotation;
@@ -741,7 +734,7 @@ define(["module", "vwf/view"], function (module, view) {
 
                 if (distance > delta)
                 {
-                    console.log("position not equal");
+                   // console.log("position not equal");
                     self.kernel.setProperty(avatarName, "position", position);
                     self.kernel.callMethod(avatarName, "moveVRController",[]);
                 }
@@ -752,7 +745,7 @@ define(["module", "vwf/view"], function (module, view) {
 
                 if (distance)
                 {
-                    console.log("rotation not equal");
+                    //console.log("rotation not equal");
                     self.kernel.setProperty(avatarName, "rotation", rotation);
                     self.kernel.callMethod(avatarName, "moveVRController",[]);
                 }
@@ -833,10 +826,11 @@ define(["module", "vwf/view"], function (module, view) {
         avatarEl.setAttribute('id', 'avatarControlParent');
 
 
+
         if (self.d3DoF || _app.config.d3DoF) {
             //avatarEl.setAttribute('gearvr-controls', {}); 
             avatarEl.setAttribute('movement-controls', {});//{'controls': 'gamepad'});
-           // avatarEl.setAttribute("gamepad-controls", {});
+            //avatarEl.setAttribute("gamepad-controls", {});
             //avatarEl.setAttribute('position', '0 0 0');
         }
 
@@ -882,12 +876,12 @@ define(["module", "vwf/view"], function (module, view) {
 
         avatarEl.appendChild(controlEl);
 
-        //avatarEl.setAttribute('avatar', {});
 
         aScene.appendChild(avatarEl);
 
         controlEl.setAttribute('camera', 'active', true);
 
+        //avatarEl.setAttribute('avatar', {});
 
         // let arControl = document.createElement('a-entity');
         // arControl.setAttribute('id', 'arControlParent');
@@ -1094,6 +1088,7 @@ define(["module", "vwf/view"], function (module, view) {
             'hand': 'right',
             'model': true
         });
+        //el.setAttribute('laser-controls', {hand: "right"});
     
         // gearvr.setAttribute('gearvr-controls', 'hand', 'right');
 
@@ -1122,6 +1117,9 @@ define(["module", "vwf/view"], function (module, view) {
             'color': '#ffcccc'
         });
 
+        el.setAttribute('laser-controls', {hand: hand, model:false});
+        //el.setAttribute('raycaster', {objects: ".collidable", far: 5, showLine: false});
+
         // wmrvr.setAttribute('windows-motion-controls', '');
         // wmrvr.setAttribute('windows-motion-controls', 'hand', hand);