Просмотр исходного кода

Merge branch 'master' of http://192.168.0.115:3000/xushiting/Metaverse

xushiting 3 лет назад
Родитель
Сommit
4c3af79dd8
5 измененных файлов с 27 добавлено и 28 удалено
  1. 1 1
      dist/index.html
  2. 11 7
      src/ActionsHandler.js
  3. 11 15
      src/RotationEvent.js
  4. 3 0
      src/XMaterialComponent.js
  5. 1 5
      src/Xverse_Room.js

+ 1 - 1
dist/index.html

@@ -69,7 +69,7 @@
     const VERSION$1 = "1.0.75"
     , ENV = "production";
   
-    let nickname = "8e2515a18f449";
+    let nickname = "f42d6cfbb189e" //"8e2515a18f449";
 
     const COMPONENT_LIST_PREFIX = "/component_list.json";
     const isFunction = i=>typeof i == "function";

+ 11 - 7
src/ActionsHandler.js

@@ -388,10 +388,7 @@ export default class ActionsHandler {
         endRotation += angle/Math.PI*180
 
         let efns = Math.round(endRotation/6)
-
-        // if(sfns == efns) return
-        // console.error(sfns, efns)
-
+        
         if(window.currentFrame == null){
             window.currentFrame = efns
         }
@@ -401,6 +398,13 @@ export default class ActionsHandler {
         else if(window.currentFrame == efns){
             return
         }
+        
+        // 起始帧不需要传入
+        if(efns>sfns) sfns = (sfns + 1 + 60) % 60
+        if(efns<sfns) sfns = (sfns - 1 + 60) % 60
+        efns = (efns + 60) % 60
+        // console.error(sfns, efns)
+
         window.camera_endRotation = endRotation
         window.star_angle = angle
         console.log('取帧:'+sfns+','+efns);
@@ -414,7 +418,7 @@ export default class ActionsHandler {
             return
         }
         this.room.sceneManager.materialComponent.initreceveFrames()
-        this.room.doRotate()
+        // this.room.doRotate()
         //window.room.sceneManager.cameraComponent.mainCamera.rotation.y += angle
         //window.room.sceneManager.cameraComponent.setCameraPose(cameraState)
     }
@@ -469,10 +473,10 @@ export default class ActionsHandler {
     }
     */
 
-    fetchData({sFrame: sfns, eFrame: efns}){
+    fetchData({type:type, sFrame: sfns, eFrame: efns}){
         if(window.workerReady){
             this.vDecoder.fetch({
-                path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/1011",
+                path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/2",
                 range: [sfns, efns],
               });
         }

+ 11 - 15
src/RotationEvent.js

@@ -50,33 +50,29 @@ export default class RotationEvent {
 
             if(window.initFinished){
                  // 旋转中
-            if(this.rotating) return
+                // if(window.rotating) return
 
+                // offset累计
+                if(!this.offset) this.offset = 0
+                this.offset += offsetX
 
-            // offset累计
-            if(!this.offset) this.offset = 0
-            this.offset += offsetX
+                // 累计超过6度
+                let angle = this.offset / canvasWidth * (2*Math.PI)
+                angle = Math.round(angle / (Math.PI/30)) * (Math.PI/30)
+                if(Math.abs(angle) < Math.PI/30) return
 
-            // 累计超过6度
-            let angle = this.offset / (canvasWidth*10) * (2*Math.PI)
-            angle = Math.round(angle / (Math.PI/30)) * (Math.PI/30)
-            if(Math.abs(angle) < Math.PI/30) return
+                // window.rotating = true
 
-            this.rotating = true
-
-            setTimeout(() => {
                 // 开始旋转
                 this._room.actionsHandler.rotate({
                     type: 'rotate',
-                    angle: Math.PI/30 * Math.sign(angle)    // angle
+                    angle: Math.PI/30 * Math.sign(angle)    // 目前固定1次mousemove只转1帧
                 });
 
                 // 重置累计
                 this.offset = 0
-                this.rotating = false
-            }, 1000/32)
+                // this.rotating = false
             }
-           
 
             this.touchStartX = pageX;
             this.touchStartY = pageY;

+ 3 - 0
src/XMaterialComponent.js

@@ -273,6 +273,9 @@ export default class XMaterialComponent {
     }
     //xst
     receveFrames(data){
+        // console.error("decodeData")
+        window.room.doRotate(window.star_angle)
+
         const { width, height, data: buffer } = data;
         let stream = new Uint8Array(buffer)
         var o, a;

+ 1 - 5
src/Xverse_Room.js

@@ -145,11 +145,7 @@ export default class Xverse_Room extends EventEmitter {
         })
     }
 
-    doRotate(){
-        if(typeof(window.star_angle) == 'undefined'){
-            return
-        }
-        let angle = window.star_angle
+    doRotate(angle){
         //this.sceneManager.materialComponent.initreceveFrames()
 
         let cameraPostion0 = util.xversePosition2Ue4(this.sceneManager.cameraComponent.mainCamera.position.clone())