Browse Source

完成放置输油管功能

beijing
刘向辉 3 years ago
parent
commit
3b673181f1
  1. 1
      src/app/babylon/controller/config-manager.ts
  2. 1
      src/app/babylon/controller/inputController.ts
  3. 6
      src/app/babylon/controller/scene-manager.ts
  4. 6
      src/app/babylon/model/data/mark/all-mark-data.ts
  5. 4
      src/app/babylon/model/data/mark/mark-data.ts
  6. 170
      src/app/babylon/model/info/mark/other/mark-plan-syg-info.ts
  7. 16
      src/app/babylon/view/mark-window/mark-window.ts
  8. BIN
      src/assets/images/mark/inside/syg.png
  9. BIN
      src/assets/mesh/mark/inside/ygc/YGC.bin
  10. 32
      src/assets/mesh/mark/inside/ygc/YGC.gltf

1
src/app/babylon/controller/config-manager.ts

@ -174,6 +174,7 @@ export class ConfigManager {
[MarkType.JYY, "加油员"],
[MarkType.XYY, "卸油员"],
[MarkType.YGC, "油罐车"],
[MarkType.SYG, "输油管"],
[MarkType.YGCSJ, "油罐车司机"],
[MarkType.XFSD, "消防沙(堆)"],
[MarkType.XFSQ, "消防沙(圈)"],

1
src/app/babylon/controller/inputController.ts

@ -296,6 +296,7 @@ export class InputController {
&& this.markType != MarkType.YWA
&& this.markType != MarkType.YWB
&& this.markType != MarkType.JJX
&& this.markType != MarkType.SYG
// && this.markType != MarkType.SD
&& this.markType != MarkType.JGLX
&& this.markType != MarkType.CT

6
src/app/babylon/controller/scene-manager.ts

@ -59,6 +59,8 @@ import { ModelInfo_mark_particle } from '../model/info/mark/other/mark-plan-part
import { FacilityPosType, ModelData_facility } from '../model/data/model-data/model-data-facility';
import { LoadTool } from '../tool/load-tool';
import { flatten } from 'earcut';
import { MarkData_multiLine } from '../model/data/mark/other/mark-data-multi-line';
import { MarkPlanSYGInfo } from '../model/info/mark/other/mark-plan-syg-info';
//场景管理器
@ -557,6 +559,10 @@ export class SceneManager {
modelData = plainToClass(MarkData_multiArrow_CT, modelData);
modelInfo = new ModelInfo_mark_multiArrow(modelData as MarkData, null, defaultMesh, null, isNew);
break;
case MarkType.SYG:
modelData = plainToClass(MarkData_multiLine, modelData);
modelInfo = new MarkPlanSYGInfo(modelData as MarkData, null, defaultMesh, null, isNew);
break;
case MarkType.H:
case MarkType.SNH:
case MarkType.YWA:

6
src/app/babylon/model/data/mark/all-mark-data.ts

@ -70,6 +70,7 @@ export class AllMarkData {
AllMarkData.newMarkData(MarkType.JYY, MarkKindType.Persion, tagPos, result);
AllMarkData.newMarkData(MarkType.XYY, MarkKindType.Persion, tagPos, result);
AllMarkData.newMarkData(MarkType.YGC, MarkKindType.Car, tagPos, result);
AllMarkData.newMarkData(MarkType.SYG, MarkKindType.Virtual, tagPos, result, undefined, false);
AllMarkData.newMarkData(MarkType.YGCSJ, MarkKindType.Persion, tagPos, result);
AllMarkData.newMarkData(MarkType.XFSD, MarkKindType.Goods, tagPos, result);
AllMarkData.newMarkData(MarkType.XFSQ, MarkKindType.Goods, tagPos, result);
@ -163,6 +164,11 @@ export class AllMarkData {
case MarkType.CT:
result = new MarkData_multiArrow_CT(type.toString(), type, tagPos, kindType, icon, modelPath, modelName, taskType, isModel);
break;
case MarkType.SYG:
result = new MarkData_multiLine(type.toString(), type, tagPos, kindType, icon, modelPath, modelName, taskType, isModel)
result.color = "#6B6060"
result.radius = 0.07
break;
default:
result = new MarkData(type.toString(), type, tagPos, kindType, icon, modelPath, modelName, taskType, isModel);
break;

4
src/app/babylon/model/data/mark/mark-data.ts

@ -265,6 +265,10 @@ export enum MarkType {
*/
YGC = "YGC",
/**
*
*/
SYG = "SYG",
/**
*
*/

170
src/app/babylon/model/info/mark/other/mark-plan-syg-info.ts

@ -0,0 +1,170 @@
import { AbstractMesh, Color3, EventState, Mesh, MeshBuilder, Observer, PointerEventTypes, PointerInfo, StandardMaterial, Vector3 } from "@babylonjs/core";
import { classToClass, plainToClass } from "class-transformer";
import { SceneManager } from "src/app/babylon/controller/scene-manager";
import { BabylonTool } from "src/app/babylon/tool/babylon-tool";
import { MarkWindow } from "src/app/babylon/view/mark-window/mark-window";
import { MarkData } from "../../../data/mark/mark-data";
import { MarkData_multiLine } from "../../../data/mark/other/mark-data-multi-line";
import { ModelInfo_mark } from "../model-info-mark";
export class MarkPlanSYGInfo extends ModelInfo_mark {
lineData: MarkData_multiLine;
onPointObserver: Observer<PointerInfo>;
lineMesh: Mesh;
mat: StandardMaterial;
onCreate(isNew: boolean) {
let instance = this;
instance.lineData = this.markData as MarkData_multiLine;
this.mat = new StandardMaterial("mat_multiLine", SceneManager.Instance.scene);
this.mat.emissiveColor = Color3.FromHexString(this.lineData.color);
this.mat.disableLighting = true;
if (isNew) {
instance.lineData.pointData = [];
instance.addPoint(this.modelBox.absolutePosition.clone());
setTimeout(() => {
instance.onPointObserver = SceneManager.Instance.scene.onPointerObservable.add((eventData: PointerInfo, eventState: EventState) => {
instance.onPointerObservable(eventData, eventState);
}
);
}, 300);
}
else {
instance.lineData.pointData = plainToClass(Vector3, instance.lineData.pointData);
}
instance.updateRender();
}
/**
*
*/
updateRender() {
if (this.lineData.pointData != null && this.lineData.pointData.length > 1) {
this.lineMesh = MeshBuilder.CreateTube("tube", { path: this.lineData.pointData, radius: this.lineData.radius, sideOrientation: Mesh.DOUBLESIDE, updatable: true, cap: Mesh.CAP_ALL }, SceneManager.Instance.scene);
this.lineMesh.setParent(this.modelBox);
this.lineMesh.position = Vector3.Zero();
this.lineMesh.material = this.mat;
}
}
/**
*
* @param point
*/
addPoint(point: Vector3) {
point.y = point.y + this.lineData.yPos;
this.lineData.pointData.push(point.subtract(this.modelBox.absolutePosition));
//更新表现
if (this.lineData.pointData.length > 1) {
this.updateRender();
}
}
/**
*
*/
removeEvent() {
if (this.onPointObserver != null) {
SceneManager.Instance.scene.onPointerObservable.remove(this.onPointObserver);
this.onPointObserver = null;
}
}
/**
*
*/
cancelCreate() {
if (this.lineData.pointData.length < 2) {
MarkWindow.instance.deleteMarkInfo(this);
}
// MarkWindow.instance.mulLineIsBreak_SD = -1;
}
onPointerObservable(eventData: PointerInfo, eventState: EventState) {
let instance = this;
// if (MarkWindow.instance.mulLineIsBreak_SD < 0) {
// instance.cancelCreate();
// instance.removeEvent();
// return;
// }
switch (eventData.type) {
case PointerEventTypes.POINTERUP:
if (eventData.event.button == 0) { //左键正常
if (eventData.pickInfo.hit && !SceneManager.s_isPointerDrag) {
instance.addPoint(eventData.pickInfo.pickedPoint);
}
}
else if (eventData.event.button == 2) { //右键取消
instance.cancelCreate();
instance.removeEvent();
}
break;
}
}
onSelect(select: boolean) {
super.onSelect(select);
if (select = false) {
this.cancelCreate();
}
}
/**
*
*/
clone(markData?: MarkData, isNew: boolean = true): ModelInfo_mark {
let l_markData: MarkData = null;
if (markData == null) {
l_markData = classToClass(this.modelData) as MarkData;
}
else {
l_markData = markData;
}
let childMeshes = null;
let modelBox = null;
modelBox = BabylonTool.cloneMesh(this.modelBox as Mesh, null, (childMesh: AbstractMesh[]) => {
childMeshes = childMesh;
});
let info = new MarkPlanSYGInfo(l_markData, childMeshes, modelBox, null, isNew);
this.cloneAnimTo(info);
return info;
}
dispose() {
if (this.mat != null) {
this.mat.dispose();
}
this.removeEvent();
super.dispose();
}
}

16
src/app/babylon/view/mark-window/mark-window.ts

@ -87,6 +87,10 @@ export class MarkWindow extends UIBase {
* 退线 0-1--1
*/
mulArrowIsBreak_CT: number = -1;
/**
* 0-1--1
*/
mulLineIsBreak_SYG: number = -1;
/**
*
@ -517,6 +521,7 @@ export class MarkWindow extends UIBase {
this.markLineIsBreak = -1;
this.mulArrowIsBreak_JG = -1;
this.mulArrowIsBreak_CT = -1;
this.mulLineIsBreak_SYG = -1;
}
}
@ -844,6 +849,15 @@ export class MarkWindow extends UIBase {
instance.mulArrowIsBreak_CT = 1;
}
}
else if (instance.currentMarkDataPrefab.type == MarkType.SYG) {
if (instance.mulLineIsBreak_SYG > 0) {
return;
}
else {
instance.mulLineIsBreak_SYG = 1;
}
}
readyCreateMark = true;
pickPos = worldPos;
@ -893,7 +907,7 @@ export class MarkWindow extends UIBase {
let l_markInfo = instance.getMarkInfoFromMesh(eventData.pickInfo.pickedMesh);
if (l_markInfo != null) {
if (instance.currentMarkDataPrefab != null && instance.currentMarkDataPrefab.markKindType != MarkKindType.Effect
&& instance.currentMarkDataPrefab.type != MarkType.MHTK) //特效可以放在标绘物上
&& instance.currentMarkDataPrefab.type != MarkType.MHTK && instance.currentMarkDataPrefab.type != MarkType.SYG) //特效可以放在标绘物上
{
readyCreateMark = false;
}

BIN
src/assets/images/mark/inside/syg.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
src/assets/mesh/mark/inside/ygc/YGC.bin

Binary file not shown.

32
src/assets/mesh/mark/inside/ygc/YGC.gltf

@ -1,6 +1,6 @@
{
"asset" : {
"generator" : "Khronos glTF Blender I/O v1.6.16",
"generator" : "Khronos glTF Blender I/O v1.8.19",
"version" : "2.0"
},
"extensionsUsed" : [
@ -67,7 +67,7 @@
},
{
"mesh" : 10,
"name" : "YouXiang"
"name" : "YouXiang.002"
},
{
"children" : [
@ -514,7 +514,7 @@
]
},
{
"name" : "Object083",
"name" : "Object083.002",
"primitives" : [
{
"attributes" : {
@ -975,12 +975,12 @@
"componentType" : 5126,
"count" : 3028,
"max" : [
0.930234968662262,
0.9678786993026733,
1.0429768562316895,
0.9093518257141113,
1.6651370525360107
],
"min" : [
-0.9589369893074036,
-1.0429768562316895,
0.4841155409812927,
-0.7362931966781616
],
@ -1003,7 +1003,7 @@
},
{
"componentType" : 5126,
"count" : 12414,
"count" : 12010,
"max" : [
1.1273759603500366,
2.7106683254241943,
@ -1011,24 +1011,24 @@
],
"min" : [
-1.1218620538711548,
0.3482356071472168,
0.46230417490005493,
-4.180373191833496
],
"type" : "VEC3"
},
{
"componentType" : 5126,
"count" : 12414,
"count" : 12010,
"type" : "VEC3"
},
{
"componentType" : 5126,
"count" : 12414,
"count" : 12010,
"type" : "VEC2"
},
{
"componentType" : 5123,
"count" : 52836,
"count" : 51528,
"type" : "SCALAR"
}
],
@ -1040,7 +1040,7 @@
},
{
"buffer" : 0,
"byteLength" : 38625,
"byteLength" : 38628,
"byteOffset" : 6180
},
{
@ -1090,13 +1090,13 @@
},
{
"buffer" : 0,
"byteLength" : 15572,
"byteLength" : 15700,
"byteOffset" : 168464
},
{
"buffer" : 0,
"byteLength" : 49230,
"byteOffset" : 184036
"byteLength" : 46892,
"byteOffset" : 184164
}
],
"samplers" : [
@ -1107,7 +1107,7 @@
],
"buffers" : [
{
"byteLength" : 233268,
"byteLength" : 231056,
"uri" : "YGC.bin"
}
]

Loading…
Cancel
Save