zhouenguang 3 năm trước cách đây
mục cha
commit
1ff614bfb3
5 tập tin đã thay đổi với 42 bổ sung40 xóa
  1. 1 1
      dist/index.html
  2. 12 8
      src/ActionsHandler.js
  3. 24 26
      src/RotationEvent.js
  4. 4 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";

+ 12 - 8
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
+        if(efns<sfns) sfns = (sfns - 1 + 60) % 60
+        efns = sfns
+        // 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,11 +473,11 @@ 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",
-                range: [sfns, efns],
+                path: "https://laser-data.oss-cn-shenzhen.aliyuncs.com/test-video/2",
+                range: sfns == efns ? [efns] : [sfns, efns],
               });
         }
         else{

+ 24 - 26
src/RotationEvent.js

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

+ 4 - 0
src/XMaterialComponent.js

@@ -273,6 +273,10 @@ export default class XMaterialComponent {
     }
     //xst
     receveFrames(data){
+        // console.error("decodeData")
+        // if(window.star_angle != 0)
+        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())