|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { Color3, MeshBuilder, Quaternion, Space, Vector3 } from "@babylonjs/core"; |
|
|
|
|
import { Color3, MeshBuilder, Quaternion, Scene, Space, Vector3 } from "@babylonjs/core"; |
|
|
|
|
import { PointerEventTypes, PointerInfo } from "@babylonjs/core/Events/pointerEvents"; |
|
|
|
|
import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial"; |
|
|
|
|
import { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh"; |
|
|
|
@ -27,6 +27,9 @@ export class ModelInfo_mark_multiArrow extends ModelInfo_mark {
|
|
|
|
|
arrowInfo: ArrowInfo[] = []; |
|
|
|
|
|
|
|
|
|
mat: StandardMaterial; |
|
|
|
|
mat_Light: StandardMaterial; |
|
|
|
|
|
|
|
|
|
updateObserver: Observer<Scene>; //update的观察者
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onCreate(isNew: boolean) { |
|
|
|
@ -57,7 +60,8 @@ export class ModelInfo_mark_multiArrow extends ModelInfo_mark {
|
|
|
|
|
|
|
|
|
|
this.mat.disableLighting = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.mat_Light = this.mat.clone(this.mat.name + "_light"); |
|
|
|
|
this.mat_Light.diffuseColor = Color3.FromHexString("#0000FF"); |
|
|
|
|
|
|
|
|
|
if (isNew) { |
|
|
|
|
instance.arrowData.pointData = []; |
|
|
|
@ -76,6 +80,21 @@ export class ModelInfo_mark_multiArrow extends ModelInfo_mark {
|
|
|
|
|
instance.updateRender(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.updateObserver = SceneManager.Instance.scene.onBeforeRenderObservable.add((eventData: Scene, eventState: EventState) => { |
|
|
|
|
instance.onUpdate(instance, eventData, eventState); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 每帧调用 |
|
|
|
|
* @param eventData
|
|
|
|
|
* @param eventState
|
|
|
|
|
*/ |
|
|
|
|
onUpdate(instance: ModelInfo_mark_multiArrow, eventData: Scene, eventState: EventState) { |
|
|
|
|
instance.updateAnim(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -139,6 +158,8 @@ export class ModelInfo_mark_multiArrow extends ModelInfo_mark {
|
|
|
|
|
SceneManager.Instance.scene.onPointerObservable.remove(this.onPointObserver); |
|
|
|
|
this.onPointObserver = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -233,12 +254,80 @@ export class ModelInfo_mark_multiArrow extends ModelInfo_mark {
|
|
|
|
|
if (this.mat != null) { |
|
|
|
|
this.mat.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.updateObserver != null) { |
|
|
|
|
SceneManager.Instance.scene.onBeforeRenderObservable.remove(this.updateObserver); |
|
|
|
|
this.updateObserver = null; |
|
|
|
|
} |
|
|
|
|
this.removeEvent(); |
|
|
|
|
super.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#region 箭头动画
|
|
|
|
|
|
|
|
|
|
animIndex = -1; |
|
|
|
|
|
|
|
|
|
readonly c_animTimer = 10; |
|
|
|
|
|
|
|
|
|
animTimer = 0; |
|
|
|
|
/** |
|
|
|
|
* 更新动画 |
|
|
|
|
*/ |
|
|
|
|
updateAnim() { |
|
|
|
|
|
|
|
|
|
if (this.animTimer > 0) { |
|
|
|
|
this.animTimer -= SceneManager.Instance.scene.deltaTime; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
this.animTimer = this.c_animTimer; |
|
|
|
|
// if (arrowNum > this.animIndex) {
|
|
|
|
|
// this.animIndex++;
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// else {
|
|
|
|
|
// this.animIndex = -1;
|
|
|
|
|
// }
|
|
|
|
|
this.animIndex = this.showArrow(this.animIndex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 展示哪个小箭头隐藏 |
|
|
|
|
* @param animIndex
|
|
|
|
|
* 返回值:找到了为所在的index +1,没找到为-1 |
|
|
|
|
*/ |
|
|
|
|
showArrow(animIndex: number) { |
|
|
|
|
if (this.arrowInfo == null) { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
let index = -1; |
|
|
|
|
let result = -1; |
|
|
|
|
for (let i = 0; i < this.arrowInfo.length; i++) { |
|
|
|
|
let arrowInfo = this.arrowInfo[i].mesh; |
|
|
|
|
|
|
|
|
|
if (arrowInfo != null) { |
|
|
|
|
for (let j = 0; j < arrowInfo.length; j++) { |
|
|
|
|
index++; |
|
|
|
|
// arrowInfo[j].setEnabled(index != animIndex);
|
|
|
|
|
if (index == animIndex) { |
|
|
|
|
arrowInfo[j].material = this.mat_Light; |
|
|
|
|
result = index; |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
arrowInfo[j].material = this.mat; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return result + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -264,6 +353,8 @@ class ArrowInfo {
|
|
|
|
|
endlocalY: number; //局部的Y做坐标,末尾
|
|
|
|
|
mat: StandardMaterial; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(start: Vector3, end: Vector3, mat: StandardMaterial, parent: Mesh) { |
|
|
|
|
this.start = start; |
|
|
|
|
this.end = end; |
|
|
|
|