You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1444 lines
62 KiB
1444 lines
62 KiB
import { Angle, AnimationGroup, Axis, Mesh, MeshBuilder, Quaternion, Scene, SceneLoader, Space, TransformNode, Vector3 } from "@babylonjs/core"; |
|
import { Event_MarkInfoChange, MarkInfoChangeType } from "./event-manager/events/event-mark-info-change"; |
|
import { EventManager } from "./event-manager/event-manager"; |
|
import { ChildNodeData, MarkData, MarkType } from "../model/data/mark/mark-data"; |
|
import { ModelInfo_mark } from "../model/info/mark/model-info-mark"; |
|
export enum ArmActionState { |
|
Bi, |
|
Bi1, |
|
Bi2, |
|
Bi3, |
|
Bi4, |
|
Bi5, |
|
Bi6, |
|
Pentou, |
|
} |
|
export enum LTState { |
|
None, |
|
LU, |
|
LU1, |
|
LU2 |
|
} |
|
|
|
export class InputController { |
|
private targetPoint: Vector3 = null; |
|
|
|
public rotateSpeed: number = 1; // 旋转速度 |
|
public moveBiSpeed: number = 5;// 展臂速度 |
|
public animation: AnimationGroup; |
|
// 选中的对象 |
|
public selectedObject: Mesh = null; // Y轴旋转 |
|
// 选中的类型 |
|
private markType: MarkType = null; |
|
public Bi: Mesh = null; // Y轴旋转 |
|
public Bi1: Mesh = null;// X轴旋转 |
|
public Bi2: Mesh = null;// 伸臂 |
|
public Bi3: Mesh = null;// 伸臂 |
|
public Bi4: Mesh = null;// 伸臂 |
|
public Bi5: Mesh = null;// 伸臂 |
|
public Bi6: Mesh = null;// X轴旋转 |
|
public PingTai: Mesh = null;// 保持水平 |
|
public PT: Mesh = null;// X轴旋转 |
|
public BaShou: Mesh = null;// X轴旋转 |
|
public Arm: Mesh = null; |
|
public Light: Mesh = null; |
|
public Bi1Postion: Vector3 = null; |
|
public Bi1MaxAngle: number = -84; |
|
public Bi1MinAngle: number = -6; |
|
public LadderUp: TransformNode = null; |
|
public LadderUp1: TransformNode = null; |
|
public LadderUp2: TransformNode = null; |
|
// 最大臂长 |
|
public maxArmlength = 15; |
|
// 最小臂长 |
|
public minArmlength = 0; |
|
public L6Length = 3; |
|
public L15Length = 5; |
|
// Bi2 |
|
public Bi2Length = 0; |
|
// Bi3 |
|
public Bi3Length = 0; |
|
// Bi4 |
|
public Bi4Length = 0; |
|
// Bi5 |
|
public Bi5Length = 0; |
|
|
|
deltaTime: number = 0.005; |
|
private scene: Scene; |
|
// 自动举臂状态 |
|
private armActionState: ArmActionState = ArmActionState.Bi; |
|
private LTActionState: LTState = LTState.None; |
|
// data |
|
dataBi: ChildNodeData = null; |
|
dataBi1: ChildNodeData = null; |
|
dataBi2: ChildNodeData = null; |
|
dataBi3: ChildNodeData = null; |
|
dataBi4: ChildNodeData = null; |
|
dataBi5: ChildNodeData = null; |
|
dataBi6: ChildNodeData = null; |
|
dataPingTai: ChildNodeData = null; |
|
dataBaShou: ChildNodeData = null; |
|
dataPT: ChildNodeData = null; |
|
dataLadderUp: ChildNodeData = null; |
|
dataLadderUp1: ChildNodeData = null; |
|
dataLadderUp2: ChildNodeData = null; |
|
dataArm: ChildNodeData = null; |
|
dataLight: ChildNodeData = null; |
|
markData: MarkData = null; |
|
markInfo: ModelInfo_mark = null; |
|
waterPowerSpeed: number = 50; |
|
/** |
|
* |
|
*/ |
|
constructor(scene: Scene) { |
|
this.scene = scene; |
|
|
|
//添加监听事件 |
|
EventManager.addListener<Event_MarkInfoChange>(Event_MarkInfoChange, (eventData, eventState) => { |
|
this.markInfo = eventData.markInfo; |
|
if (eventData.markInfo == null) { |
|
console.trace("Event_MarkInfoChange===="); |
|
return; |
|
} |
|
this.markData = eventData.markInfo.markData; |
|
this.markType = eventData.markInfo.markData.type; |
|
switch (eventData.eventType) { |
|
case MarkInfoChangeType.Create: |
|
// 数据 |
|
this.dataBi = eventData.markInfo.getChildrenDataByName("Bi"); |
|
this.dataBi1 = eventData.markInfo.getChildrenDataByName("Bi1"); |
|
this.dataBi2 = eventData.markInfo.getChildrenDataByName("Bi2"); |
|
this.dataBi3 = eventData.markInfo.getChildrenDataByName("Bi3"); |
|
this.dataBi4 = eventData.markInfo.getChildrenDataByName("Bi4"); |
|
this.dataBi5 = eventData.markInfo.getChildrenDataByName("Bi5"); |
|
this.dataBi6 = eventData.markInfo.getChildrenDataByName("Bi6"); |
|
this.dataPingTai = eventData.markInfo.getChildrenDataByName("PingTai"); |
|
this.dataBaShou = eventData.markInfo.getChildrenDataByName("BaShou"); |
|
this.dataPT = eventData.markInfo.getChildrenDataByName("PT"); |
|
this.dataLadderUp = eventData.markInfo.getChildrenDataByName("LadderUp"); |
|
this.dataLadderUp1 = eventData.markInfo.getChildrenDataByName("LadderUp1"); |
|
this.dataLadderUp2 = eventData.markInfo.getChildrenDataByName("LadderUp2"); |
|
this.dataArm = eventData.markInfo.getChildrenDataByName("Arm"); |
|
this.dataLight = eventData.markInfo.getChildrenDataByName("Light"); |
|
|
|
let playAnimation = true; |
|
|
|
if (this.dataBi) { |
|
this.Bi = eventData.markInfo.getChildrenByName("Bi") as Mesh; |
|
this.Bi.rotationQuaternion = this.dataBi.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataBi1) { |
|
this.Bi1 = eventData.markInfo.getChildrenByName("Bi1") as Mesh; |
|
this.Bi1.rotationQuaternion = this.dataBi1.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataBi2) { |
|
this.Bi2 = eventData.markInfo.getChildrenByName("Bi2") as Mesh; |
|
this.Bi2.position = this.dataBi2.transformData.position; |
|
playAnimation = false; |
|
} |
|
if (this.dataBi3) { |
|
this.Bi3 = eventData.markInfo.getChildrenByName("Bi3") as Mesh; |
|
this.Bi3.position = this.dataBi3.transformData.position; |
|
playAnimation = false; |
|
} |
|
if (this.dataBi4) { |
|
this.Bi4 = eventData.markInfo.getChildrenByName("Bi4") as Mesh; |
|
this.Bi4.position = this.dataBi4.transformData.position; |
|
playAnimation = false; |
|
} |
|
if (this.dataBi5) { |
|
this.Bi5 = eventData.markInfo.getChildrenByName("Bi5") as Mesh; |
|
// if (this.markType == MarkType.DGPTC) { |
|
// this.Bi5.rotationQuaternion = this.dataBi5.transformData.rotationQuaternion; |
|
// } else { |
|
this.Bi5.position = this.dataBi5.transformData.position; |
|
// } |
|
playAnimation = false; |
|
} |
|
if (this.dataBi6) { |
|
this.Bi6 = eventData.markInfo.getChildrenByName("Bi6") as Mesh; |
|
this.Bi6.rotationQuaternion = this.dataBi6.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataPingTai) { |
|
// if (this.markType == MarkType.YTC) { |
|
// this.PingTai = eventData.markInfo.getChildrenByName("pingtai") as Mesh; |
|
// } else { |
|
this.PingTai = eventData.markInfo.getChildrenByName("PingTai") as Mesh; |
|
// } |
|
this.PingTai.rotationQuaternion = this.dataPingTai.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataBaShou) { |
|
this.BaShou = eventData.markInfo.getChildrenByName("BaShou") as Mesh; |
|
this.BaShou.rotationQuaternion = this.dataBaShou.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataPT) { |
|
this.PT = eventData.markInfo.getChildrenByName("PT") as Mesh; |
|
this.PT.rotationQuaternion = this.dataPT.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataLadderUp) { |
|
this.LadderUp = eventData.markInfo.getChildrenByName("LadderUp_primitive0").parent as TransformNode; |
|
this.LadderUp.position = this.dataLadderUp.transformData.position; |
|
playAnimation = false; |
|
} |
|
if (this.dataLadderUp1) { |
|
this.LadderUp1 = eventData.markInfo.getChildrenByName("LadderUp1_primitive0").parent as TransformNode; |
|
this.LadderUp1.position = this.dataLadderUp1.transformData.position; |
|
playAnimation = false; |
|
} |
|
if (this.dataLadderUp2) { |
|
this.LadderUp2 = eventData.markInfo.getChildrenByName("LadderUp2_primitive0").parent as TransformNode; |
|
this.LadderUp2.position = this.dataLadderUp2.transformData.position; |
|
playAnimation = false; |
|
} |
|
if (this.dataArm) { |
|
this.Arm = eventData.markInfo.getChildrenByName("Arm") as Mesh; |
|
this.Arm.rotationQuaternion = this.dataArm.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.dataLight) { |
|
this.Light = eventData.markInfo.getChildrenByName("Light") as Mesh; |
|
this.Light.rotationQuaternion = this.dataLight.transformData.rotationQuaternion; |
|
playAnimation = false; |
|
} |
|
if (this.CanPlayAnimation() && playAnimation) {// 创建高喷车、登高平台车、云梯车播放默认动画 |
|
this.animation = eventData.markInfo.animationGroups[0]; |
|
this.animation.start(); |
|
} |
|
break; |
|
case MarkInfoChangeType.Select: |
|
// 数据 |
|
this.dataBi = eventData.markInfo.getChildrenDataByName("Bi"); |
|
this.dataBi1 = eventData.markInfo.getChildrenDataByName("Bi1"); |
|
this.dataBi2 = eventData.markInfo.getChildrenDataByName("Bi2"); |
|
this.dataBi3 = eventData.markInfo.getChildrenDataByName("Bi3"); |
|
this.dataBi4 = eventData.markInfo.getChildrenDataByName("Bi4"); |
|
this.dataBi5 = eventData.markInfo.getChildrenDataByName("Bi5"); |
|
this.dataBi6 = eventData.markInfo.getChildrenDataByName("Bi6"); |
|
this.dataPingTai = eventData.markInfo.getChildrenDataByName("PingTai"); |
|
this.dataBaShou = eventData.markInfo.getChildrenDataByName("BaShou"); |
|
this.dataPT = eventData.markInfo.getChildrenDataByName("PT"); |
|
this.dataArm = eventData.markInfo.getChildrenDataByName("PT"); |
|
this.dataLight = eventData.markInfo.getChildrenDataByName("Light"); |
|
// 如果可以忽略返回,否则设置 |
|
this.selectedObject = eventData.markInfo.modelBox as Mesh; |
|
this.Bi = eventData.markInfo.getChildrenByName("Bi") as Mesh; |
|
this.Bi1 = eventData.markInfo.getChildrenByName("Bi1") as Mesh; |
|
this.Bi2 = eventData.markInfo.getChildrenByName("Bi2") as Mesh; |
|
this.Bi2Length = this.Bi2?.position.z; |
|
this.Bi3 = eventData.markInfo.getChildrenByName("Bi3") as Mesh; |
|
this.Bi3Length = this.Bi3?.position.z; |
|
this.Bi4 = eventData.markInfo.getChildrenByName("Bi4") as Mesh; |
|
this.Bi4Length = this.Bi4?.position.z; |
|
this.Bi5 = eventData.markInfo.getChildrenByName("Bi5") as Mesh; |
|
this.Bi5Length = this.Bi5?.position.z; |
|
this.Bi6 = eventData.markInfo.getChildrenByName("Bi6") as Mesh; |
|
this.PingTai = eventData.markInfo.getChildrenByName("PingTai") as Mesh; |
|
this.PT = eventData.markInfo.getChildrenByName("PT") as Mesh; |
|
this.BaShou = eventData.markInfo.getChildrenByName("BaShou") as Mesh; |
|
this.Arm = eventData.markInfo.getChildrenByName("Arm") as Mesh; |
|
this.Light = eventData.markInfo.getChildrenByName("Light") as Mesh; |
|
|
|
|
|
// if (this.markType === MarkType.LT6) { |
|
// this.LTActionState = LTState.LU; |
|
// this.LadderUp = (eventData.markInfo.getChildrenByName("LadderUp_primitive0")).parent as TransformNode;; |
|
// console.log(this.LadderUp); |
|
// } |
|
// if (this.markType == MarkType.LT15) { |
|
// this.LTActionState = LTState.LU1; |
|
// this.LadderUp1 = (eventData.markInfo.getChildrenByName("LadderUp1_primitive0")).parent as TransformNode; |
|
// this.LadderUp2 = (eventData.markInfo.getChildrenByName("LadderUp2_primitive0")).parent as TransformNode;; |
|
// console.log(this.LadderUp1, this.LadderUp2); |
|
// } |
|
// if (this.markType == MarkType.YTC) { |
|
// this.PingTai = eventData.markInfo.getChildrenByName("pingtai") as Mesh; |
|
// } |
|
break; |
|
case MarkInfoChangeType.UnSelect: |
|
this.markInfo = null; |
|
this.markData = null; |
|
this.markType = null; |
|
this.animation = null; |
|
this.selectedObject = null; |
|
this.Bi = null; |
|
this.Bi1 = null; |
|
this.Bi2 = null; |
|
this.Bi3 = null; |
|
this.Bi4 = null; |
|
this.Bi5 = null; |
|
this.Bi6 = null; |
|
this.Arm = null; |
|
this.Light = null; |
|
this.LadderUp = null; |
|
this.LadderUp1 = null; |
|
this.LadderUp2 = null; |
|
this.PT = null; |
|
this.PingTai = null; |
|
this.BaShou = null; |
|
break; |
|
} |
|
}) |
|
|
|
this.scene.registerBeforeRender(() => { |
|
this.update(); |
|
}) |
|
|
|
} |
|
// 可以旋转 |
|
public CanRotateSelf(): boolean { |
|
return this.markType != MarkType.H |
|
&& this.markType != MarkType.SNH |
|
&& this.markType != MarkType.YWA |
|
&& this.markType != MarkType.YWB |
|
&& this.markType != MarkType.JJX |
|
// && this.markType != MarkType.SD |
|
&& this.markType != MarkType.JGLX |
|
&& this.markType != MarkType.CT |
|
// && this.markType != MarkType.JJQ |
|
&& this.markType != MarkType.QYSDA |
|
&& this.markType != MarkType.QYSDB; |
|
} |
|
// 可以播放动画 |
|
public CanPlayAnimation(): boolean { |
|
// return this.markType === MarkType.GPC |
|
// || this.markType === MarkType.DGPTC |
|
// || this.markType === MarkType.YTC |
|
return false; |
|
} |
|
// 是消防员 |
|
public IsFiremen(): boolean { |
|
return this.markType == MarkType.XFY |
|
// || this.markType == MarkType.JYF |
|
// || this.markType == MarkType.GRF |
|
// || this.markType == MarkType.FHF |
|
// || this.markType == MarkType.BHF |
|
// || this.markType == MarkType.YWXFY |
|
; |
|
} |
|
// 是消防车 |
|
public IsFireTruck(): boolean { |
|
return this.markType == MarkType.XFC |
|
// || this.markType == MarkType.SGC |
|
// || this.markType == MarkType.GCGSC |
|
; |
|
} |
|
// |
|
// todo 按选择的类型处理,也方便后续拆分 |
|
// if(高喷车) |
|
// 按键处理 |
|
// if(喷水车) |
|
// 按键处理 |
|
|
|
// 更新 |
|
update() { |
|
if (this.selectedObject) { |
|
this.RotateSelfControl(); |
|
this.HighSprayCarControl(); |
|
this.LadderCarControl(); |
|
this.FiremenControl(); |
|
this.FireTruckControl(); |
|
this.AscendingPlatformCarControl(); |
|
this.WaterCannonControl(); |
|
this.LadderControl(); |
|
this.LightTruckControl(); |
|
} |
|
} |
|
// 控制自身旋转 |
|
public RotateSelfControl() { |
|
if (this.CanRotateSelf()) { |
|
if (Keyboard.Instance.ArrowLeft) { |
|
this.rotateSpeed = -1; |
|
this.RotateAroundAxisY(this.selectedObject); |
|
} |
|
if (Keyboard.Instance.ArrowRight) { |
|
this.rotateSpeed = 1; |
|
this.RotateAroundAxisY(this.selectedObject); |
|
} |
|
} |
|
} |
|
// 控制消防员 |
|
public FiremenControl() { |
|
if (this.IsFiremen()) { |
|
if (Keyboard.Instance.u) { |
|
this.rotateSpeed = -1; |
|
this.RotateAroundAxisX(this.PT); |
|
if (this.dataPT == null) { |
|
this.dataPT = new ChildNodeData(); |
|
this.dataPT.name = "PT"; |
|
this.markData.childrenNodeData.push(this.dataPT); |
|
} |
|
this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
} |
|
if (Keyboard.Instance.j) { |
|
this.rotateSpeed = 1; |
|
this.RotateAroundAxisX(this.PT); |
|
if (this.dataPT == null) { |
|
this.dataPT = new ChildNodeData(); |
|
this.dataPT.name = "PT"; |
|
this.markData.childrenNodeData.push(this.dataPT); |
|
} |
|
this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
} |
|
if (Keyboard.Instance.AddKey) { |
|
this.markInfo?.changeWaterPower(this.markData.waterPower + this.deltaTime * this.waterPowerSpeed); |
|
} |
|
if (Keyboard.Instance.SubKey) { |
|
this.markInfo?.changeWaterPower(this.markData.waterPower - this.deltaTime * this.waterPowerSpeed); |
|
} |
|
} |
|
} |
|
// 控制喷水车 |
|
public FireTruckControl() { |
|
if (this.IsFireTruck()) { |
|
if (Keyboard.Instance.u) { |
|
this.rotateSpeed = -1; |
|
this.RotateAroundAxisX(this.PT); |
|
if (this.dataPT == null) { |
|
this.dataPT = new ChildNodeData(); |
|
this.dataPT.name = "PT"; |
|
this.markData.childrenNodeData.push(this.dataPT); |
|
} |
|
this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
} |
|
if (Keyboard.Instance.j) { |
|
this.rotateSpeed = 1; |
|
this.RotateAroundAxisX(this.PT); |
|
if (this.dataPT == null) { |
|
this.dataPT = new ChildNodeData(); |
|
this.dataPT.name = "PT"; |
|
this.markData.childrenNodeData.push(this.dataPT); |
|
} |
|
this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
} |
|
if (Keyboard.Instance.h) { |
|
this.rotateSpeed = -1; |
|
this.RotateAroundAxisY(this.PT); |
|
if (this.dataPT == null) { |
|
this.dataPT = new ChildNodeData(); |
|
this.dataPT.name = "PT"; |
|
this.markData.childrenNodeData.push(this.dataPT); |
|
} |
|
this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
} |
|
if (Keyboard.Instance.k) { |
|
this.rotateSpeed = 1; |
|
this.RotateAroundAxisY(this.PT); |
|
if (this.dataPT == null) { |
|
this.dataPT = new ChildNodeData(); |
|
this.dataPT.name = "PT"; |
|
this.markData.childrenNodeData.push(this.dataPT); |
|
} |
|
this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
} |
|
if (Keyboard.Instance.AddKey) { |
|
this.markInfo?.changeWaterPower(this.markData.waterPower + this.deltaTime * this.waterPowerSpeed); |
|
} |
|
if (Keyboard.Instance.SubKey) { |
|
this.markInfo?.changeWaterPower(this.markData.waterPower - this.deltaTime * this.waterPowerSpeed); |
|
} |
|
} |
|
} |
|
// 控制照明车 |
|
public LightTruckControl() { |
|
// if (this.markType == MarkType.ZMC) { |
|
// if (Keyboard.Instance.a) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisZ(this.Light); |
|
// if (this.dataLight == null) { |
|
// this.dataLight = new ChildNodeData(); |
|
// this.dataLight.name = "Light"; |
|
// this.markData.childrenNodeData.push(this.dataLight); |
|
// } |
|
// this.dataLight.transformData.rotationQuaternion = this.Light.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.d) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisZ(this.Light); |
|
// if (this.dataLight == null) { |
|
// this.dataLight = new ChildNodeData(); |
|
// this.dataLight.name = "Light"; |
|
// this.markData.childrenNodeData.push(this.dataLight); |
|
// } |
|
// this.dataLight.transformData.rotationQuaternion = this.Light.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.w) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.Arm); |
|
// if (this.dataArm == null) { |
|
// this.dataArm = new ChildNodeData(); |
|
// this.dataArm.name = "Arm"; |
|
// this.markData.childrenNodeData.push(this.dataArm); |
|
// } |
|
// this.dataArm.transformData.rotationQuaternion = this.Arm.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.s) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.Arm); |
|
// if (this.dataArm == null) { |
|
// this.dataArm = new ChildNodeData(); |
|
// this.dataArm.name = "Arm"; |
|
// this.markData.childrenNodeData.push(this.dataArm); |
|
// } |
|
// this.dataArm.transformData.rotationQuaternion = this.Arm.rotationQuaternion; |
|
// } |
|
// } |
|
} |
|
// 控制高喷车 |
|
public HighSprayCarControl() { |
|
// if (this.markType == MarkType.GPC) { |
|
// if (Keyboard.Instance.ArrowLeft) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.ArrowRight) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.a) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.Bi); |
|
// if (this.dataBi == null) { |
|
// this.dataBi = new ChildNodeData(); |
|
// this.dataBi.name = "Bi"; |
|
// this.markData.childrenNodeData.push(this.dataBi); |
|
// } |
|
// this.dataBi.transformData.rotationQuaternion = this.Bi.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.d) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.Bi); |
|
// if (this.dataBi == null) { |
|
// this.dataBi = new ChildNodeData(); |
|
// this.dataBi.name = "Bi"; |
|
// this.markData.childrenNodeData.push(this.dataBi); |
|
// } |
|
// this.dataBi.transformData.rotationQuaternion = this.Bi.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.w) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.Bi1); |
|
// if (this.dataBi1 == null) { |
|
// this.dataBi1 = new ChildNodeData(); |
|
// this.dataBi1.name = "Bi1"; |
|
// this.markData.childrenNodeData.push(this.dataBi1); |
|
// } |
|
// this.dataBi1.transformData.rotationQuaternion = this.Bi1.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.s) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.Bi1); |
|
// if (this.dataBi1 == null) { |
|
// this.dataBi1 = new ChildNodeData(); |
|
// this.dataBi1.name = "Bi1"; |
|
// this.markData.childrenNodeData.push(this.dataBi1); |
|
// } |
|
// this.dataBi1.transformData.rotationQuaternion = this.Bi1.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.u) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.j) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.h) { |
|
// // this.rotateSpeed = -1; |
|
// // this.RotateAroundAxisY(this.PT); |
|
// } |
|
// if (Keyboard.Instance.k) { |
|
// // this.rotateSpeed = 1; |
|
// // this.RotateAroundAxisY(this.PT); |
|
// } |
|
// if (Keyboard.Instance.W) { |
|
// this.moveBiSpeed = 5; |
|
// this.TranlateBiGPC(); |
|
// } |
|
// if (Keyboard.Instance.S) { |
|
// this.moveBiSpeed = -5; |
|
// this.TranlateBiGPC(); |
|
// } |
|
// if (Keyboard.Instance.U) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.Bi6); |
|
// if (this.dataBi6 == null) { |
|
// this.dataBi6 = new ChildNodeData(); |
|
// this.dataBi6.name = "Bi6"; |
|
// this.markData.childrenNodeData.push(this.dataBi6); |
|
// } |
|
// this.dataBi6.transformData.rotationQuaternion = this.Bi6.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.J) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.Bi6); |
|
// if (this.dataBi6 == null) { |
|
// this.dataBi6 = new ChildNodeData(); |
|
// this.dataBi6.name = "Bi6"; |
|
// this.markData.childrenNodeData.push(this.dataBi6); |
|
// } |
|
// this.dataBi6.transformData.rotationQuaternion = this.Bi6.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.AddKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower + this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// if (Keyboard.Instance.SubKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower - this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// } |
|
} |
|
// 控制云梯车 |
|
public LadderCarControl() { |
|
// if (this.markType == MarkType.YTC) { |
|
// var theta = Vector3.Dot(this.PingTai.forward, Vector3.Up()); |
|
// this.PingTai.rotate(Axis.X, theta, Space.WORLD); |
|
// if (Keyboard.Instance.ArrowLeft) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.ArrowRight) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.a) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.Bi); |
|
// if (this.dataBi == null) { |
|
// this.dataBi = new ChildNodeData(); |
|
// this.dataBi.name = "Bi"; |
|
// this.markData.childrenNodeData.push(this.dataBi); |
|
// } |
|
// this.dataBi.transformData.rotationQuaternion = this.Bi.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.d) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.Bi); |
|
// if (this.dataBi == null) { |
|
// this.dataBi = new ChildNodeData(); |
|
// this.dataBi.name = "Bi"; |
|
// this.markData.childrenNodeData.push(this.dataBi); |
|
// } |
|
// this.dataBi.transformData.rotationQuaternion = this.Bi.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.w) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.Bi1); |
|
// if (this.dataBi1 == null) { |
|
// this.dataBi1 = new ChildNodeData(); |
|
// this.dataBi1.name = "Bi1"; |
|
// this.markData.childrenNodeData.push(this.dataBi1); |
|
// } |
|
// this.dataBi1.transformData.rotationQuaternion = this.Bi1.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.s) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.Bi1); |
|
// if (this.dataBi1 == null) { |
|
// this.dataBi1 = new ChildNodeData(); |
|
// this.dataBi1.name = "Bi1"; |
|
// this.markData.childrenNodeData.push(this.dataBi1); |
|
// } |
|
// this.dataBi1.transformData.rotationQuaternion = this.Bi1.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.u) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.j) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.h) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.k) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.W) { |
|
// this.moveBiSpeed = 5; |
|
// this.TranlateBiGPC(); |
|
// } |
|
// if (Keyboard.Instance.S) { |
|
// this.moveBiSpeed = -5; |
|
// this.TranlateBiGPC(); |
|
// } |
|
// if (Keyboard.Instance.AddKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower + this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// if (Keyboard.Instance.SubKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower - this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// } |
|
} |
|
// 控制登高平台车 |
|
public AscendingPlatformCarControl() { |
|
// if (this.markType == MarkType.DGPTC) { |
|
// var theta = Vector3.Dot(this.PingTai.forward, Vector3.Up()); |
|
// this.PingTai.rotate(Axis.X, theta, Space.WORLD); |
|
// if (Keyboard.Instance.ArrowLeft) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.ArrowRight) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.a) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.Bi); |
|
// if (this.dataBi == null) { |
|
// this.dataBi = new ChildNodeData(); |
|
// this.dataBi.name = "Bi"; |
|
// this.markData.childrenNodeData.push(this.dataBi); |
|
// } |
|
// this.dataBi.transformData.rotationQuaternion = this.Bi.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.d) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.Bi); |
|
// if (this.dataBi == null) { |
|
// this.dataBi = new ChildNodeData(); |
|
// this.dataBi.name = "Bi"; |
|
// this.markData.childrenNodeData.push(this.dataBi); |
|
// } |
|
// this.dataBi.transformData.rotationQuaternion = this.Bi.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.w) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.Bi1); |
|
// if (this.dataBi1 == null) { |
|
// this.dataBi1 = new ChildNodeData(); |
|
// this.dataBi1.name = "Bi1"; |
|
// this.markData.childrenNodeData.push(this.dataBi1); |
|
// } |
|
// this.dataBi1.transformData.rotationQuaternion = this.Bi1.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.s) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.Bi1); |
|
// if (this.dataBi1 == null) { |
|
// this.dataBi1 = new ChildNodeData(); |
|
// this.dataBi1.name = "Bi1"; |
|
// this.markData.childrenNodeData.push(this.dataBi1); |
|
// } |
|
// this.dataBi1.transformData.rotationQuaternion = this.Bi1.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.u) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.j) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.h) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.k) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.W) { |
|
// this.moveBiSpeed = 5; |
|
// this.TranlateBiDGPTC(); |
|
// } |
|
// if (Keyboard.Instance.S) { |
|
// this.moveBiSpeed = -5; |
|
// this.TranlateBiDGPTC(); |
|
// } |
|
// if (Keyboard.Instance.U) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.Bi5); |
|
// if (this.dataBi5 == null) { |
|
// this.dataBi5 = new ChildNodeData(); |
|
// this.dataBi5.name = "Bi5"; |
|
// this.markData.childrenNodeData.push(this.dataBi5); |
|
// } |
|
// this.dataBi5.transformData.rotationQuaternion = this.Bi5.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.J) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.Bi5); |
|
// if (this.dataBi5 == null) { |
|
// this.dataBi5 = new ChildNodeData(); |
|
// this.dataBi5.name = "Bi5"; |
|
// this.markData.childrenNodeData.push(this.dataBi5); |
|
// } |
|
// this.dataBi5.transformData.rotationQuaternion = this.Bi5.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.AddKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower + this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// if (Keyboard.Instance.SubKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower - this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// } |
|
} |
|
// 水炮控制 |
|
public WaterCannonControl() { |
|
// if (this.markType == MarkType.SP) { |
|
// if (Keyboard.Instance.h) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.k) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisY(this.selectedObject); |
|
// } |
|
// if (Keyboard.Instance.u) { |
|
// this.rotateSpeed = -1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.j) { |
|
// this.rotateSpeed = 1; |
|
// this.RotateAroundAxisX(this.PT); |
|
// if (this.dataPT == null) { |
|
// this.dataPT = new ChildNodeData(); |
|
// this.dataPT.name = "PT"; |
|
// this.markData.childrenNodeData.push(this.dataPT); |
|
// } |
|
// this.dataPT.transformData.rotationQuaternion = this.PT.rotationQuaternion; |
|
// } |
|
// if (Keyboard.Instance.AddKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower + this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// if (Keyboard.Instance.SubKey) { |
|
// this.markInfo?.changeWaterPower(this.markData.waterPower - this.deltaTime * this.waterPowerSpeed); |
|
// } |
|
// } |
|
} |
|
// 梯子 |
|
public LadderControl() { |
|
// if (this.markType == MarkType.LT6) { |
|
// if (Keyboard.Instance.W) { |
|
// this.moveBiSpeed = 5; |
|
// this.TranslateLadder6M(); |
|
// } |
|
// if (Keyboard.Instance.S) { |
|
// this.moveBiSpeed = -5; |
|
// this.TranslateLadder6M(); |
|
// } |
|
// } else if (this.markType == MarkType.LT15) { |
|
// if (Keyboard.Instance.W) { |
|
// this.moveBiSpeed = 5; |
|
// this.TranslateLadder15M(); |
|
// } |
|
// if (Keyboard.Instance.S) { |
|
// this.moveBiSpeed = -5; |
|
// this.TranslateLadder15M(); |
|
// } |
|
// } |
|
} |
|
// 围绕Y轴旋转 |
|
public RotateAroundAxisY(mesh: Mesh) { |
|
mesh?.rotate(Axis.Y, this.scene.deltaTime * 0.001 * this.rotateSpeed, Space.LOCAL); |
|
} |
|
// 围绕X轴旋转 |
|
public RotateAroundAxisX(mesh: Mesh) { |
|
mesh?.rotate(Axis.X, this.scene.deltaTime * 0.001 * this.rotateSpeed, Space.LOCAL); |
|
} |
|
// 围绕Z轴旋转 |
|
public RotateAroundAxisZ(mesh: Mesh) { |
|
mesh?.rotate(Axis.Z, this.scene.deltaTime * 0.001 * this.rotateSpeed, Space.LOCAL); |
|
} |
|
// 高喷车展臂 |
|
public TranlateBiGPC() { |
|
|
|
switch (this.armActionState) { |
|
case ArmActionState.Bi3: |
|
this.TranlateBi(this.Bi3, ArmActionState.Bi4); |
|
if (this.dataBi3 == null) { |
|
this.dataBi3 = new ChildNodeData(); |
|
this.dataBi3.name = "Bi3"; |
|
this.markData.childrenNodeData.push(this.dataBi3); |
|
} |
|
this.dataBi3.transformData.position = this.Bi3.position; |
|
break; |
|
case ArmActionState.Bi4: |
|
this.TranlateBi(this.Bi4, ArmActionState.Bi5); |
|
if (this.dataBi4 == null) { |
|
this.dataBi4 = new ChildNodeData(); |
|
this.dataBi4.name = "Bi4"; |
|
this.markData.childrenNodeData.push(this.dataBi4); |
|
} |
|
this.dataBi4.transformData.position = this.Bi4.position; |
|
break; |
|
case ArmActionState.Bi5: |
|
this.TranlateBi(this.Bi5, ArmActionState.Bi1); |
|
if (this.dataBi5 == null) { |
|
this.dataBi5 = new ChildNodeData(); |
|
this.dataBi5.name = "Bi5"; |
|
this.markData.childrenNodeData.push(this.dataBi5); |
|
} |
|
this.dataBi5.transformData.position = this.Bi5.position; |
|
break; |
|
default: |
|
this.TranlateBi(this.Bi2, ArmActionState.Bi3); |
|
if (this.dataBi2 == null) { |
|
this.dataBi2 = new ChildNodeData(); |
|
this.dataBi2.name = "Bi2"; |
|
this.markData.childrenNodeData.push(this.dataBi2); |
|
} |
|
this.dataBi2.transformData.position = this.Bi2.position; |
|
break; |
|
} |
|
} |
|
// 高喷车展臂 |
|
public TranlateBiYTC() { |
|
|
|
switch (this.armActionState) { |
|
case ArmActionState.Bi3: |
|
this.TranlateBi(this.Bi3, ArmActionState.Bi4); |
|
if (this.dataBi3 == null) { |
|
this.dataBi3 = new ChildNodeData(); |
|
this.dataBi3.name = "Bi3"; |
|
this.markData.childrenNodeData.push(this.dataBi3); |
|
} |
|
this.dataBi3.transformData.position = this.Bi3.position; |
|
break; |
|
case ArmActionState.Bi4: |
|
this.TranlateBi(this.Bi4, ArmActionState.Bi5); |
|
if (this.dataBi4 == null) { |
|
this.dataBi4 = new ChildNodeData(); |
|
this.dataBi4.name = "Bi4"; |
|
this.markData.childrenNodeData.push(this.dataBi4); |
|
} |
|
this.dataBi4.transformData.position = this.Bi4.position; |
|
break; |
|
case ArmActionState.Bi5: |
|
this.TranlateBi(this.Bi5, ArmActionState.Bi6); |
|
if (this.dataBi5 == null) { |
|
this.dataBi5 = new ChildNodeData(); |
|
this.dataBi5.name = "Bi5"; |
|
this.markData.childrenNodeData.push(this.dataBi5); |
|
} |
|
this.dataBi5.transformData.position = this.Bi5.position; |
|
break; |
|
case ArmActionState.Bi6: |
|
this.TranlateBi(this.Bi6, ArmActionState.Bi1); |
|
if (this.dataBi6 == null) { |
|
this.dataBi6 = new ChildNodeData(); |
|
this.dataBi6.name = "Bi6"; |
|
this.markData.childrenNodeData.push(this.dataBi6); |
|
} |
|
this.dataBi6.transformData.position = this.Bi6.position; |
|
break; |
|
default: |
|
this.TranlateBi(this.Bi2, ArmActionState.Bi3); |
|
if (this.dataBi2 == null) { |
|
this.dataBi2 = new ChildNodeData(); |
|
this.dataBi2.name = "Bi2"; |
|
this.markData.childrenNodeData.push(this.dataBi2); |
|
} |
|
this.dataBi2.transformData.position = this.Bi2.position; |
|
break; |
|
} |
|
} |
|
// 登高平台车展臂 |
|
public TranlateBiDGPTC() { |
|
|
|
switch (this.armActionState) { |
|
case ArmActionState.Bi3: |
|
this.TranlateBi(this.Bi3, ArmActionState.Bi4); |
|
break; |
|
default: |
|
this.TranlateBi(this.Bi2, ArmActionState.Bi3); |
|
break; |
|
} |
|
} |
|
// 移动6米梯子 |
|
public TranslateLadder6M() { |
|
switch (this.LTActionState) { |
|
default: |
|
this.TranlateLadder(this.LadderUp, 3, 0, LTState.None); |
|
if (this.dataLadderUp == null) { |
|
this.dataLadderUp = new ChildNodeData(); |
|
this.dataLadderUp.name = "LadderUp"; |
|
this.markData.childrenNodeData.push(this.dataLadderUp); |
|
} |
|
this.dataLadderUp.transformData.position = this.LadderUp.position; |
|
break; |
|
} |
|
} |
|
// 移动15米梯子 |
|
public TranslateLadder15M() { |
|
switch (this.LTActionState) { |
|
default: |
|
this.TranlateLadder(this.LadderUp1, 5, 0, LTState.LU2); |
|
if (this.dataLadderUp1 == null) { |
|
this.dataLadderUp1 = new ChildNodeData(); |
|
this.dataLadderUp1.name = "LadderUp1"; |
|
this.markData.childrenNodeData.push(this.dataLadderUp1); |
|
} |
|
this.dataLadderUp1.transformData.position = this.LadderUp1.position; |
|
break; |
|
case LTState.LU2: |
|
this.TranlateLadder(this.LadderUp2, 5, 0, LTState.None); |
|
if (this.dataLadderUp2 == null) { |
|
this.dataLadderUp2 = new ChildNodeData(); |
|
this.dataLadderUp2.name = "LadderUp2"; |
|
this.markData.childrenNodeData.push(this.dataLadderUp2); |
|
} |
|
this.dataLadderUp2.transformData.position = this.LadderUp2.position; |
|
break; |
|
} |
|
} |
|
// 消防车展臂 |
|
public TranlateBi(tranlateMesh: Mesh, nextState: ArmActionState) { |
|
tranlateMesh?.translate(Axis.Z, this.scene.deltaTime * 0.001 * this.moveBiSpeed, Space.LOCAL); |
|
if (tranlateMesh?.position.z > this.maxArmlength) { |
|
tranlateMesh.position.z = this.maxArmlength; |
|
this.armActionState = nextState; |
|
} else if (tranlateMesh?.position.z < this.minArmlength) { |
|
tranlateMesh.position.z = this.minArmlength; |
|
this.armActionState = nextState; |
|
} |
|
} |
|
|
|
// 移动梯子 |
|
public TranlateLadder(tranlateMesh: TransformNode, maxLength: number, minLength: number, nextState: LTState) { |
|
tranlateMesh?.translate(Axis.Y, this.scene.deltaTime * 0.001 * this.moveBiSpeed, Space.LOCAL); |
|
if (tranlateMesh?.position.y > maxLength) { |
|
tranlateMesh.position.y = maxLength; |
|
this.LTActionState = nextState; |
|
} else if (tranlateMesh?.position.y < minLength) { |
|
tranlateMesh.position.y = minLength; |
|
this.LTActionState = nextState; |
|
} |
|
} |
|
|
|
|
|
// 旋转消防车 |
|
// public RotateRoot(angle: number) { |
|
// if (this.selectedObject) { |
|
// this.selectedObject.rotate(Axis.Y, angle, Space.LOCAL); |
|
// } |
|
// } |
|
// 旋转消防车举臂底盘 |
|
// public RotateBi(angle: number) { |
|
// if (this.Bi) { |
|
// this.Bi.rotate(Axis.Y, angle, Space.LOCAL); |
|
// } |
|
// } |
|
// 旋转消防车举臂角度 |
|
// public RotateAroundAxisX(angle: number) { |
|
// if (this.Bi1) { |
|
// this.Bi1.rotate(Axis.X, angle, Space.LOCAL); |
|
// } |
|
// } |
|
// 高喷车喷头前一节举臂 |
|
// public RotateBi6(angle: number) { |
|
// if (this.Bi6) { |
|
// this.Bi6.rotate(Axis.X, angle, Space.LOCAL); |
|
// } |
|
// } |
|
// 自动旋转Bi |
|
// public AutoRotateBi() { |
|
// // this.center.position.set(10, 0, 10); |
|
|
|
// // const lookPosBox = this.targetPoint.subtract(this.box.absolutePosition).normalize(); |
|
// // lookPosBox.y = 0; |
|
// // const q0 = Quaternion.FromLookDirectionLH(lookPosBox, Vector3.Up()); |
|
// // if (!this.box.absoluteRotationQuaternion.equalsWithEpsilon(q0, 0.01)) { |
|
// // this.box.rotate(Axis.Y, 0.005, Space.LOCAL) |
|
// // } |
|
|
|
// // const lookPos = this.targetPoint.subtract(this.Bi.absolutePosition).normalize(); |
|
// // lookPos.y = 0; |
|
// // const q1 = Quaternion.FromLookDirectionLH(lookPos, Vector3.Up()); |
|
|
|
|
|
// // if (!this.Bi.absoluteRotationQuaternion.equalsWithEpsilon(q1, 0.01)) { |
|
// // this.Bi.rotate(Axis.Y, 0.005, Space.LOCAL) |
|
// // } |
|
|
|
// // const absoluteRotationQuaternion = Quaternion.FromLookDirectionLH(lookPos, Vector3.Up()); |
|
// // const absoluteRotationQuaternionOffset = absoluteRotationQuaternion.subtract(this.root.absoluteRotationQuaternion); |
|
// // this.Bi.addRotation(0, absoluteRotationQuaternionOffset.toEulerAngles().y, 0); |
|
// // this.armActionState = ArmActionState.Bi2; |
|
// // this.Bi.rotationQuaternion = Quaternion.Slerp(this.Bi.rotationQuaternion, absoluteRotationQuaternionOffset.normalize(), this.deltaTime * 10);// TODO需要设置世界旋转 |
|
// // if (this.Bi.rotationQuaternion.equalsWithEpsilon(rotation, 0.1)) { |
|
// // this.Bi.rotationQuaternion = rotation; |
|
// // // this.armActionState = ArmActionState.Bi2; |
|
// // console.log("旋转地盘结束"); |
|
// // const line = MeshBuilder.CreateLines('line', { points: [this.targetPoint, this.Bi.absolutePosition] }); |
|
// // line.color = Color3.Red(); |
|
// // } |
|
// // const v1 = (new Vector3(this.targetPoint.x, this.Bi.position.y, this.targetPoint.z).subtract(this.Bi.position)).normalize(); |
|
// // const v2 = this.root.forward; |
|
// // const targetDir = Vector3.Cross(v1, v2).y > 0 ? 1 : -1; |
|
|
|
// // const targetAngle = Math.acos(Vector3.Dot(v1, v2)) * 180 / Math.PI * targetDir; |
|
// // const currentAngle = this.Bi.rotationQuaternion.toEulerAngles().y * 180 / Math.PI; |
|
|
|
|
|
// // // console.log(this.Bi.rotationQuaternion.equalsWithEpsilon(new Quaternion(-rotation.x, -rotation.y, -rotation.z, rotation.w), 0.001)); |
|
|
|
// // if (Math.abs(targetAngle - currentAngle) > 0.5) { |
|
// // const speedDir = (targetAngle - currentAngle) >= 0 ? 1 : -1; |
|
// // this.RotateBi(speedDir * 0.01); |
|
// // } else { |
|
// // this.armActionState = ArmActionState.Bi2; |
|
// // } |
|
// } |
|
|
|
|
|
|
|
// public AutoRotateBi1() { |
|
// // const d2E = Math.floor(Vector3.Distance(this.Bi6.absolutePosition, this.Bi.absolutePosition)) + 15;//臂长 |
|
// // const d2T = Math.floor(Vector3.Distance(this.Bi.absolutePosition, this.targetPoint));//臂底端到目标的距离 |
|
// // const distance = Math.round(Vector3.Distance(this.Bi6.absolutePosition, this.targetPoint)); //Bi6到目标距离 |
|
|
|
// // const v1 = (new Vector3(this.targetPoint.x, this.targetPoint.y, this.targetPoint.z).subtract(this.Bi1.position)).normalize(); |
|
// // const v2 = this.Bi.forward.normalize(); |
|
// // const targetDir = Vector3.Cross(v1, v2).x > 0 ? -1 : 1; |
|
|
|
|
|
// // const lookPos = this.targetPoint.subtract(this.Bi1.position).normalize(); |
|
// // const rotation = Quaternion.FromLookDirectionRH(lookPos, this.Bi1.up); |
|
// // this.Bi1.rotationQuaternion = Quaternion.Slerp(this.Bi1.rotationQuaternion, new Quaternion(rotation.x, rotation.y, rotation.z, rotation.w), this.deltaTime * 10); |
|
|
|
|
|
// // const targetAngle = Math.acos(Vector3.Dot(v1, v2)) * 180 / Math.PI * targetDir; |
|
// // const currentAngle = this.Bi1.rotationQuaternion.toEulerAngles().x * 180 / Math.PI; |
|
|
|
|
|
// // console.log(currentAngle,); |
|
// // console.log(targetAngle, "================="); |
|
// // if (Math.abs(targetAngle - currentAngle) > 0.5) { |
|
// // const speedDir = (targetAngle - currentAngle) >= 0 ? 1 : -1; |
|
// // this.RotateBi1(speedDir * 0.01); |
|
// // } else { |
|
// // this.armActionState = ArmActionState.Bi6; |
|
// // } |
|
|
|
// // console.log(distance, '') |
|
// // if (d2E < d2T) { |
|
// // // todo 直接指向目标点 |
|
// // this.armActionState = ArmActionState.Bi6; |
|
// // } else { |
|
// // // 根据距离上调或下调 |
|
// // if (distance < 15) { |
|
// // this.RotateBi1(-this.deltaTime); |
|
// // } else if (distance > 15) { |
|
// // this.RotateBi1(this.deltaTime); |
|
// // } else { |
|
// // this.armActionState = ArmActionState.Bi6; |
|
// // } |
|
// // } |
|
// } |
|
|
|
// public AutoRotateBi6() { |
|
// // const v1 = (new Vector3(this.targetPoint.x, this.targetPoint.y, this.targetPoint.z).subtract(this.Bi6.position)).normalize(); |
|
// // const v2 = this.Bi.forward.normalize(); |
|
// // const targetDir = Vector3.Cross(v1, v2).x > 0 ? -1 : 1; |
|
|
|
// // const targetAngle = Math.acos(Vector3.Dot(v1, v2)) * 180 / Math.PI * targetDir; |
|
// // const currentAngle = this.Bi6.rotationQuaternion.toEulerAngles().x * 180 / Math.PI; |
|
|
|
|
|
// // const test = Vector3.GetAngleBetweenVectors(v1, this.Bi1.forward.normalize(), this.Bi1.up.normalize()) * 180 / Math.PI; |
|
|
|
|
|
// // const isUp = Math.abs(this.Bi6.rotationQuaternion.toEulerAngles().y) < 0.1 && Math.abs(this.Bi6.rotationQuaternion.toEulerAngles().z) < 0.1; |
|
// // const isZero = test - currentAngle > 0; |
|
|
|
// // if (test - currentAngle < 0.5 && isZero && isUp) { |
|
// // // this.armActionState = ArmActionState.Pentou; |
|
// // } else { |
|
// // if (isUp) { |
|
// // if (isZero) { |
|
// // this.RotateBi6(0.01); |
|
// // console.log("0"); |
|
// // } else { |
|
// // this.RotateBi6(-0.01); |
|
// // console.log("1"); |
|
// // } |
|
|
|
// // } else { |
|
// // this.RotateBi6(-0.01); |
|
// // console.log("2"); |
|
// // } |
|
// // } |
|
|
|
// // console.log(test, 'Angle', isUp); |
|
|
|
// // console.log(currentAngle, this.Bi6.rotationQuaternion.toEulerAngles().y, this.Bi6.rotationQuaternion.toEulerAngles().z); |
|
// } |
|
|
|
// // 移动举臂 |
|
// public AutoTranlateBi(tranlateMesh: Mesh, nextState: ArmActionState) { |
|
// //#region 自动伸臂 |
|
// const d2E = Math.floor(Vector3.Distance(this.Bi6.absolutePosition, this.Bi.absolutePosition)) + 15;//臂长 |
|
// const d2T = Math.floor(Vector3.Distance(this.Bi.absolutePosition, this.targetPoint));//臂底端到目标的距离 |
|
|
|
// // console.log("当前臂长:", d2E, d2T); |
|
// // 臂长小于目标距离,伸臂 |
|
// if (d2E < d2T) { |
|
// tranlateMesh.translate(Axis.Z, this.deltaTime * this.speed, Space.LOCAL); |
|
// if (tranlateMesh.position.z > this.maxArmlength) { |
|
// tranlateMesh.position.z = this.maxArmlength; |
|
// this.armActionState = nextState; |
|
// } else if (tranlateMesh.position.z < this.minArmlength) { |
|
// tranlateMesh.position.z = this.minArmlength; |
|
// this.armActionState = nextState; |
|
// } |
|
// } |
|
// else if (d2E > d2T) { |
|
// tranlateMesh.translate(Axis.Z, -this.deltaTime * this.speed, Space.LOCAL); |
|
// if (tranlateMesh.position.z > this.maxArmlength) { |
|
// tranlateMesh.position.z = this.maxArmlength; |
|
// this.armActionState = nextState; |
|
// } else if (tranlateMesh.position.z < this.minArmlength) { |
|
// tranlateMesh.position.z = this.minArmlength; |
|
// this.armActionState = nextState; |
|
// } |
|
// } |
|
// else { |
|
// this.armActionState = nextState; |
|
// } |
|
// //#endregion |
|
// } |
|
} |
|
|
|
|
|
export class Keyboard { |
|
public ArrowLeft = false; |
|
public ArrowRight = false; |
|
public ShiftKey = false; |
|
public w = false; |
|
public a = false; |
|
public s = false; |
|
public d = false; |
|
public u = false; |
|
public j = false; |
|
public h = false; |
|
public k = false; |
|
public W = false; |
|
public S = false; |
|
public U = false; |
|
public J = false; |
|
public AddKey = false; |
|
public SubKey = false; |
|
|
|
private static instance: Keyboard = new Keyboard(); |
|
|
|
public static get Instance(): Keyboard { |
|
return this.instance; |
|
} |
|
/** |
|
* |
|
*/ |
|
private constructor() { |
|
// 添加快捷键 |
|
document.addEventListener('keydown', (e: KeyboardEvent) => { |
|
if (e.key == null) { |
|
return; |
|
} |
|
let key = e.key.toLocaleLowerCase(); |
|
// console.log(key); |
|
if (key == "w" && e.shiftKey) { |
|
this.W = true; |
|
} else if (key == "w") { |
|
this.w = true; |
|
} |
|
if (key == "s" && e.shiftKey) { |
|
this.S = true; |
|
} else if (key == "s") { |
|
this.s = true; |
|
} |
|
if (key == "u" && e.shiftKey) { |
|
this.U = true; |
|
} else if (key == "u") { |
|
this.u = true; |
|
} |
|
if (key == "j" && e.shiftKey) { |
|
this.J = true; |
|
} else if (key == "j") { |
|
this.j = true; |
|
} |
|
if (key == "arrowleft") { |
|
this.ArrowLeft = true; |
|
} |
|
if (key == "arrowright") { |
|
this.ArrowRight = true; |
|
} |
|
|
|
if (key == "a") { |
|
this.a = true; |
|
} |
|
|
|
if (key == "d") { |
|
this.d = true; |
|
} |
|
|
|
|
|
if (key == "h") { |
|
this.h = true; |
|
} |
|
if (key == "k") { |
|
this.k = true; |
|
} |
|
if (key == "=") { |
|
this.AddKey = true; |
|
} |
|
if (key == "-") { |
|
this.SubKey = true; |
|
} |
|
if (key == "shift") { |
|
if (this.w == true) { |
|
this.W = true; |
|
this.w = false; |
|
} else if (this.s == true) { |
|
this.S = true; |
|
this.s = false; |
|
} |
|
else if (this.u == true) { |
|
this.U = true; |
|
this.u = false; |
|
} |
|
else if (this.j == true) { |
|
this.J = true; |
|
this.j = false; |
|
} |
|
} |
|
}); |
|
document.addEventListener('keyup', (e: KeyboardEvent) => { |
|
if (e.key == null) { |
|
return; |
|
} |
|
let key = e.key.toLocaleLowerCase(); |
|
if (key == "arrowleft") { |
|
this.ArrowLeft = false; |
|
} |
|
if (key == "arrowright") { |
|
this.ArrowRight = false; |
|
} |
|
if (key == "w") { |
|
this.w = false; |
|
this.W = false; |
|
} |
|
if (key == "a") { |
|
this.a = false; |
|
} |
|
if (key == "s") { |
|
this.s = false; |
|
this.S = false; |
|
} |
|
if (key == "d") { |
|
this.d = false; |
|
} |
|
if (key == "u") { |
|
this.u = false; |
|
this.U = false; |
|
} |
|
if (key == "j") { |
|
this.j = false; |
|
this.J = false; |
|
} |
|
if (key == "h") { |
|
this.h = false; |
|
} |
|
if (key == "k") { |
|
this.k = false; |
|
} |
|
if (key == "=") { |
|
this.AddKey = false; |
|
} |
|
if (key == "-") { |
|
this.SubKey = false; |
|
} |
|
if (key == "shift") { |
|
if (this.W == true) { |
|
this.W = false; |
|
this.w = true; |
|
} else if (this.S == true) { |
|
this.S = false; |
|
this.s = true; |
|
} |
|
else if (this.U == true) { |
|
this.U = false; |
|
this.u = true; |
|
} |
|
else if (this.J == true) { |
|
this.J = false; |
|
this.j = true; |
|
} |
|
} |
|
}); |
|
} |
|
} |