From 1a104b2d94a415b0172436a64742ce559dc43737 Mon Sep 17 00:00:00 2001 From: dgflash Date: Sat, 10 Sep 2022 21:33:48 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=962D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E8=B7=9F=E9=9A=8F3D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=97=B6=E7=9A=84=E6=8A=96=E5=8A=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/core/common/storage/StorageManager.ts | 4 ++-- .../libs/animator-effect/Effect2DFollow3D.ts | 21 ++++++++++++++----- assets/libs/camera/OrbitCamera.ts | 6 +++--- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/assets/core/common/storage/StorageManager.ts b/assets/core/common/storage/StorageManager.ts index bc76970..3cc130f 100644 --- a/assets/core/common/storage/StorageManager.ts +++ b/assets/core/common/storage/StorageManager.ts @@ -7,7 +7,7 @@ import { EncryptUtil } from "../../utils/EncryptUtil"; export class StorageManager { private _key: string | null = null; private _iv: string | null = null; - private _id: number = -1; + private _id: string = ""; /** * 初始化密钥 @@ -23,7 +23,7 @@ export class StorageManager { * 设置用户唯一标识 * @param id */ - setUser(id: number) { + setUser(id: string) { this._id = id; } diff --git a/assets/libs/animator-effect/Effect2DFollow3D.ts b/assets/libs/animator-effect/Effect2DFollow3D.ts index f4bc545..0e077fa 100644 --- a/assets/libs/animator-effect/Effect2DFollow3D.ts +++ b/assets/libs/animator-effect/Effect2DFollow3D.ts @@ -7,6 +7,7 @@ import { Camera, Component, Node, Vec3, _decorator } from "cc"; import { oops } from "../../core/Oops"; +import { MathUtil } from "../../core/utils/MathUtil"; const { ccclass, property } = _decorator; @@ -35,18 +36,28 @@ export class Effect2DFollow3D extends Component { */ setTarget(node: Node) { this.node3d = node; - this.lateUpdate(0); + } + + start() { + var scale = this.zoom(); + this.node.setScale(scale, scale, 1); } protected lateUpdate(dt: number) { + var scale = this.zoom(); + scale = MathUtil.lerp(this.node.scale.x, scale, 0.1); + this.node.setScale(scale, scale, 1); + } + + private zoom(): number { this.camera.convertToUINode(this.node3d.worldPosition, oops.gui.game, this.pos); this.nodeUi.setPosition(this.pos); - // @ts-ignore 注:优化为事件触发式,避免重复计算 + // @ts-ignore Vec3.transformMat4(this.pos, this.node3d.worldPosition, this.camera._camera!.matView); - const ratio = this.distance / Math.abs(this.pos.z); - const value = Math.floor(ratio * 100) / 100; - this.node.setScale(value, value, 1); + var ratio = this.distance / Math.abs(this.pos.z); + var value = Math.floor(ratio * 100) / 100; + return value; } } diff --git a/assets/libs/camera/OrbitCamera.ts b/assets/libs/camera/OrbitCamera.ts index c89e1a4..a8fb8da 100644 --- a/assets/libs/camera/OrbitCamera.ts +++ b/assets/libs/camera/OrbitCamera.ts @@ -141,7 +141,7 @@ export class OrbitCamera extends Component { } if (this.enableScaleRadius) { - input.on(Input.EventType.MOUSE_WHEEL, this.onMouseWhee, this); + input.on(Input.EventType.MOUSE_WHEEL, this.onMouseWheel, this); } this.resetTargetRotation(); @@ -204,13 +204,13 @@ export class OrbitCamera extends Component { private onTouchEnd() { this._touched = false; } + //#endregion - private onMouseWhee(event: EventMouse) { + private onMouseWheel(event: EventMouse) { let scrollY = event.getScrollY(); this._targetRadius += this.radiusScaleSpeed * -Math.sign(scrollY); // 滚轮向前为负,滚轮向后为正 this._targetRadius = Math.min(this.maxRadius, Math.max(this.minRadius, this._targetRadius)); } - //#endregion update(dt: number) { let targetRotation = this._targetRotation; From 07a57b79d5dc3a8c6bf39ce560286a7b28a019ab Mon Sep 17 00:00:00 2001 From: dgflash Date: Tue, 13 Sep 2022 17:49:00 +0800 Subject: [PATCH 2/2] . --- assets/core/gui/layer/Defines.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/core/gui/layer/Defines.ts b/assets/core/gui/layer/Defines.ts index b6d583d..ed9cb74 100644 --- a/assets/core/gui/layer/Defines.ts +++ b/assets/core/gui/layer/Defines.ts @@ -2,7 +2,7 @@ * @Author: dgflash * @Date: 2021-11-18 11:21:32 * @LastEditors: dgflash - * @LastEditTime: 2022-09-02 13:37:03 + * @LastEditTime: 2022-09-13 17:48:48 */ import { Node } from "cc"; @@ -56,5 +56,5 @@ export class ViewParams { /** 是否在使用状态 */ valid: boolean = true; /** 界面根节点 */ - node: Node | null = null;; + node: Node | null = null; } \ No newline at end of file