woso_javan 3 tygodni temu
rodzic
commit
63c56c6c0c

+ 21 - 11
assets/module_aliens/Script/LevelAction.ts

@@ -38,7 +38,8 @@ export class LevelAction extends Component {
     zoomDistance: number = 10; //拉近镜头的距离
 
     @property({ type: CCFloat, displayName: "旋转速度" })
-    rotateSpeed: number = 0.2;
+    rotateSpeed: number = 1; 
+    private _rotationTween: Tween<any> | null = null;
 
     // 添加旋转限制属性
     @property({ type: CCFloat, displayName: "水平旋转限制角度" })
@@ -281,35 +282,44 @@ export class LevelAction extends Component {
         this._onTouchMove(event);
     }
 
+    private _targetRotation = new Vec3();
+    private _smoothFactor = 0.5; // 平滑系数,值越小越平滑
+
     private async _onTouchMove(event: EventTouch) {
         if(this._isZooming || !this.camera) return;
 
         const delta = event.getDelta();
-        // console.log('_onTouchMove delta:', delta);
+        
         // 获取当前相机旋转
         const currentRotation = new Vec3();
         this.camera.node.rotation.getEulerAngles(currentRotation);
 
-        // 计算新角度
-        currentRotation.y -= delta.x * this.rotateSpeed;
-        currentRotation.x += delta.y * this.rotateSpeed;
+        // 计算目标角度
+        this._targetRotation.set(currentRotation);
+        this._targetRotation.y -= delta.x * this.rotateSpeed;
+        this._targetRotation.x += delta.y * this.rotateSpeed;
 
-        // 限制水平旋转角度(基于初始角度)
-        currentRotation.y = Math.max(
+        // 限制水平旋转角度
+        this._targetRotation.y = Math.max(
             this._initialRotation.y - this.horizontalLimit,
-            Math.min(this._initialRotation.y + this.horizontalLimit, currentRotation.y)
+            Math.min(this._initialRotation.y + this.horizontalLimit, this._targetRotation.y)
         );
 
-        // 限制垂直旋转角度(基于初始角度)
-        currentRotation.x = Math.max(
+        // 限制垂直旋转角度
+        this._targetRotation.x = Math.max(
             this._initialRotation.x - this.verticalLimit,
-            Math.min(this._initialRotation.x + this.verticalLimit, currentRotation.x)
+            Math.min(this._initialRotation.x + this.verticalLimit, this._targetRotation.x)
         );
 
+        // 使用线性插值平滑旋转
+        currentRotation.x = math.lerp(currentRotation.x, this._targetRotation.x, this._smoothFactor);
+        currentRotation.y = math.lerp(currentRotation.y, this._targetRotation.y, this._smoothFactor);
+
         // 应用旋转
         const rotation = new Quat();
         Quat.fromEuler(rotation, currentRotation.x, currentRotation.y, 0);
         this.camera.node.setRotation(rotation);
+        
         await this.saveCameraState();
     }
 

+ 0 - 1
temp/programming/packer-driver/targets/editor/chunks/62/629ad862c1c836628b576319ec6d524ef0eb20b0.js.map

@@ -1 +0,0 @@
-{"version":3,"sources":["file:///E:/CocosCreator/_Aliens/assets/module_basic/table/Tablemain_config.ts"],"names":["Tablemain_config","JsonUtil","data","id","init","table","get","TableName","param","content"],"mappings":";;;wCAGaA,gB;;;;;;;;;;;;;;AAFJC,MAAAA,Q,iBAAAA,Q;;;;;;;kCAEID,gB,GAAN,MAAMA,gBAAN,CAAuB;AAAA;AAAA,eAGlBE,IAHkB;;AAW1B;AAX0B,eAY1BC,EAZ0B,GAYb,CAZa;AAAA;;AAK1BC,QAAAA,IAAI,CAACD,EAAD,EAAa;AACb,gBAAME,KAAK,GAAG;AAAA;AAAA,oCAASC,GAAT,CAAaN,gBAAgB,CAACO,SAA9B,CAAd;AACA,eAAKL,IAAL,GAAYG,KAAK,CAACF,EAAD,CAAjB;AACA,eAAKA,EAAL,GAAUA,EAAV;AACH;;AAKD;AACS,YAALK,KAAK,GAAW;AAChB,iBAAO,KAAKN,IAAL,CAAUM,KAAjB;AACH;AACD;;;AACW,YAAPC,OAAO,GAAW;AAClB,iBAAO,KAAKP,IAAL,CAAUO,OAAjB;AACH;;AArByB,O;;AAAjBT,MAAAA,gB,CACFO,S,GAAoB,a","sourcesContent":["\nimport { JsonUtil } from \"db://assets/core_tgx/base/utils/JsonUtil\";\n\nexport class Tablemain_config {\n    static TableName: string = \"main_config\";\n\n    private data: any;\n\n    init(id: number) {\n        const table = JsonUtil.get(Tablemain_config.TableName);\n        this.data = table[id];\n        this.id = id;\n    }\n\n    /** 编号【KEY】 */\n    id: number = 0;\n\n    /** 参数 */\n    get param(): number {\n        return this.data.param;\n    }\n    /** 数据说明 */\n    get content(): string {\n        return this.data.content;\n    }\n}\n    "]}

+ 0 - 1
temp/programming/packer-driver/targets/preview/chunks/62/629ad862c1c836628b576319ec6d524ef0eb20b0.js.map

@@ -1 +0,0 @@
-{"version":3,"sources":["file:///E:/CocosCreator/_Aliens/assets/module_basic/table/Tablemain_config.ts"],"names":["Tablemain_config","JsonUtil","data","id","init","table","get","TableName","param","content"],"mappings":";;;wCAGaA,gB;;;;;;;;;;;;;;AAFJC,MAAAA,Q,iBAAAA,Q;;;;;;;kCAEID,gB,GAAN,MAAMA,gBAAN,CAAuB;AAAA;AAAA,eAGlBE,IAHkB;;AAW1B;AAX0B,eAY1BC,EAZ0B,GAYb,CAZa;AAAA;;AAK1BC,QAAAA,IAAI,CAACD,EAAD,EAAa;AACb,cAAME,KAAK,GAAG;AAAA;AAAA,oCAASC,GAAT,CAAaN,gBAAgB,CAACO,SAA9B,CAAd;AACA,eAAKL,IAAL,GAAYG,KAAK,CAACF,EAAD,CAAjB;AACA,eAAKA,EAAL,GAAUA,EAAV;AACH;;AAKD;AACS,YAALK,KAAK,GAAW;AAChB,iBAAO,KAAKN,IAAL,CAAUM,KAAjB;AACH;AACD;;;AACW,YAAPC,OAAO,GAAW;AAClB,iBAAO,KAAKP,IAAL,CAAUO,OAAjB;AACH;;AArByB,O;;AAAjBT,MAAAA,gB,CACFO,S,GAAoB,a","sourcesContent":["\nimport { JsonUtil } from \"db://assets/core_tgx/base/utils/JsonUtil\";\n\nexport class Tablemain_config {\n    static TableName: string = \"main_config\";\n\n    private data: any;\n\n    init(id: number) {\n        const table = JsonUtil.get(Tablemain_config.TableName);\n        this.data = table[id];\n        this.id = id;\n    }\n\n    /** 编号【KEY】 */\n    id: number = 0;\n\n    /** 参数 */\n    get param(): number {\n        return this.data.param;\n    }\n    /** 数据说明 */\n    get content(): string {\n        return this.data.content;\n    }\n}\n    "]}