mx3d 0.0.34 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/mx3d.dazzle.min.js +1 -1
- package/lib/Camera.d.ts +1 -0
- package/lib/VisualAngle.d.ts +0 -4
- package/lib/components/AirFlowObject.d.ts +1 -0
- package/lib/components/ConduitObject.d.ts +1 -0
- package/lib/components/DefaultObject.d.ts +1 -0
- package/lib/components/IObject.d.ts +1 -0
- package/lib/components/LeakWaterObject.d.ts +1 -0
- package/lib/components/Project.d.ts +1 -0
- package/lib/components/Region.d.ts +2 -0
- package/mx3d.js +749 -669
- package/mx3d.min.js +3 -3
- package/package.json +1 -1
package/mx3d.js
CHANGED
|
@@ -6990,6 +6990,9 @@ class Camera_Camera {
|
|
|
6990
6990
|
this.camera.lowerBetaLimit = _visualAngle.minBeta;
|
|
6991
6991
|
this.camera.upperBetaLimit = _visualAngle.maxBeta;
|
|
6992
6992
|
}
|
|
6993
|
+
translation(_visualAngle, _sheep = 300) {
|
|
6994
|
+
this.tw_target.to({ x: _visualAngle.focus.x, y: _visualAngle.focus.y, z: _visualAngle.focus.z }, _sheep).start().onComplete(() => { this.tw_camera.to({ radius: _visualAngle.radius }, _sheep).start(); });
|
|
6995
|
+
}
|
|
6993
6996
|
computeCameraView() {
|
|
6994
6997
|
const ratio = this.app.canvas.clientWidth / this.app.canvas.clientHeight;
|
|
6995
6998
|
this.camera.orthoLeft = -ratio * this.frustrum;
|
|
@@ -7776,204 +7779,567 @@ var ObjectType;
|
|
|
7776
7779
|
ObjectType["optimizedWall"] = "optimizedWall";
|
|
7777
7780
|
})(ObjectType || (ObjectType = {}));
|
|
7778
7781
|
|
|
7779
|
-
// CONCATENATED MODULE: ./src/lib/
|
|
7780
|
-
var EffectType;
|
|
7781
|
-
(function (EffectType) {
|
|
7782
|
-
EffectType[EffectType["Opaque"] = 0] = "Opaque";
|
|
7783
|
-
EffectType[EffectType["Flash"] = 1] = "Flash";
|
|
7784
|
-
EffectType[EffectType["Transparent"] = 2] = "Transparent";
|
|
7785
|
-
})(EffectType || (EffectType = {}));
|
|
7786
|
-
|
|
7787
|
-
// CONCATENATED MODULE: ./src/lib/EventType.ts
|
|
7788
|
-
var EventType;
|
|
7789
|
-
(function (EventType) {
|
|
7790
|
-
/// <summary>
|
|
7791
|
-
/// 左键单击
|
|
7792
|
-
/// </summary>
|
|
7793
|
-
EventType["leftClick"] = "leftClick";
|
|
7794
|
-
/// <summary>
|
|
7795
|
-
/// 右键单击
|
|
7796
|
-
/// </summary>
|
|
7797
|
-
EventType["rightClick"] = "rightClick";
|
|
7798
|
-
/// <summary>
|
|
7799
|
-
/// 双击
|
|
7800
|
-
/// </summary>
|
|
7801
|
-
EventType["doubleClick"] = "doubleClick";
|
|
7802
|
-
/// <summary>
|
|
7803
|
-
/// 移入
|
|
7804
|
-
/// </summary>
|
|
7805
|
-
EventType["eover"] = "eover";
|
|
7806
|
-
/// <summary>
|
|
7807
|
-
/// 长按
|
|
7808
|
-
/// </summary>
|
|
7809
|
-
EventType["longPress"] = "longPress";
|
|
7810
|
-
/// <summary>
|
|
7811
|
-
/// 移出
|
|
7812
|
-
/// </summary>
|
|
7813
|
-
EventType["out"] = "out";
|
|
7814
|
-
})(EventType || (EventType = {}));
|
|
7815
|
-
|
|
7816
|
-
// CONCATENATED MODULE: ./src/lib/components/DefaultObject.ts
|
|
7782
|
+
// CONCATENATED MODULE: ./src/lib/VisualAngle.ts
|
|
7817
7783
|
|
|
7784
|
+
class VisualAngle_VisualAngle {
|
|
7785
|
+
// constructor(_object: IObject | Project) {
|
|
7786
|
+
// this.object = _object;
|
|
7787
|
+
// //重新计算包围盒
|
|
7788
|
+
// if (this.object instanceof Region || this.object instanceof Project) {
|
|
7789
|
+
// let bound = this.object.getBounding();
|
|
7790
|
+
// let _vis = MX3D.Tools.getVisualAngle(bound, this.object.app);
|
|
7791
|
+
// this.alpha = _vis.alpha;
|
|
7792
|
+
// this.beta = _vis.beta;
|
|
7793
|
+
// this.focus = _vis.focus;
|
|
7794
|
+
// this.radius = _vis.radius;
|
|
7795
|
+
// if (this.object instanceof Region) {
|
|
7796
|
+
// // this.radius = bound.boundingSphere.radiusWorld + 3;
|
|
7797
|
+
// this.focus.y = this.object.height;
|
|
7798
|
+
// }
|
|
7799
|
+
// }
|
|
7800
|
+
// else {
|
|
7801
|
+
// let bound = this.object.instance.getBoundingInfo();
|
|
7802
|
+
// let _vis = MX3D.Tools.getVisualAngle(bound, this.object.app);
|
|
7803
|
+
// this.alpha = _vis.alpha;
|
|
7804
|
+
// this.beta = _vis.beta;
|
|
7805
|
+
// this.focus = _vis.focus;
|
|
7806
|
+
// this.radius = _vis.radius;
|
|
7807
|
+
// if (!(this.object instanceof ConduitObject)) {
|
|
7808
|
+
// this.focus = this.object.instance.getAbsolutePosition();
|
|
7809
|
+
// this.radius = bound.boundingSphere.radiusWorld + 3;
|
|
7810
|
+
// }
|
|
7811
|
+
// }
|
|
7812
|
+
// this.minimumLimit = 0.3;
|
|
7813
|
+
// this.maximumLimit = this.radius * 2;
|
|
7814
|
+
// this.minBeta = 0.01;
|
|
7815
|
+
// this.maxBeta = (Math.PI / 2) * 0.98;
|
|
7816
|
+
// }
|
|
7817
|
+
//设置视角参数
|
|
7818
|
+
setVisual(_visual) {
|
|
7819
|
+
let config = JSON.parse(_visual);
|
|
7820
|
+
this.alpha = config.alpha;
|
|
7821
|
+
this.beta = config.beta;
|
|
7822
|
+
this.radius = config.radius;
|
|
7823
|
+
this.focus = src.Tools.ToVector3(config.focus);
|
|
7824
|
+
}
|
|
7825
|
+
//设置缩放范围
|
|
7826
|
+
setLimit(_miniLimit, _maxiLimit) {
|
|
7827
|
+
this.minimumLimit = _miniLimit + 0.3;
|
|
7828
|
+
this.maximumLimit = _maxiLimit;
|
|
7829
|
+
}
|
|
7830
|
+
//设置上下视角限制
|
|
7831
|
+
setBeta(_minBeta, _maxBeta) {
|
|
7832
|
+
this.minBeta = _minBeta;
|
|
7833
|
+
this.maxBeta = _maxBeta;
|
|
7834
|
+
}
|
|
7835
|
+
}
|
|
7836
|
+
|
|
7837
|
+
// CONCATENATED MODULE: ./src/lib/components/Project.ts
|
|
7818
7838
|
|
|
7819
7839
|
|
|
7820
7840
|
|
|
7821
7841
|
|
|
7822
|
-
class
|
|
7842
|
+
class Project_Project {
|
|
7823
7843
|
constructor(_app) {
|
|
7824
|
-
|
|
7825
|
-
this.
|
|
7826
|
-
this.clickEvents = new Dictionary();
|
|
7827
|
-
this.touchtime = new Date().getTime();
|
|
7828
|
-
this.effectType = EffectType.Opaque;
|
|
7829
|
-
this._isMonitor = true;
|
|
7844
|
+
//场景集合
|
|
7845
|
+
this.objectDatas = new Dictionary();
|
|
7830
7846
|
this.app = _app;
|
|
7831
7847
|
}
|
|
7832
|
-
|
|
7833
|
-
this._isMonitor = _value;
|
|
7834
|
-
}
|
|
7835
|
-
get isMonitor() {
|
|
7836
|
-
return this._isMonitor;
|
|
7837
|
-
}
|
|
7838
|
-
setEnabled(_value) {
|
|
7848
|
+
delete() {
|
|
7839
7849
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
7840
|
-
this.
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
this.instance.isPickable = this.executes.count() > 0;
|
|
7844
|
-
if (this.executes.find(EventType.eover) || this.executes.find(EventType.out))
|
|
7845
|
-
this.instance.enablePointerMoveEvents = true;
|
|
7846
|
-
else
|
|
7847
|
-
this.instance.enablePointerMoveEvents = false;
|
|
7848
|
-
}
|
|
7849
|
-
else {
|
|
7850
|
-
this.instance.isPickable = false;
|
|
7851
|
-
this.instance.enablePointerMoveEvents = false;
|
|
7850
|
+
for (const _o in this.objectDatas.map) {
|
|
7851
|
+
if (this.objectDatas.find(_o).instance)
|
|
7852
|
+
this.objectDatas.find(_o).instance.dispose();
|
|
7852
7853
|
}
|
|
7854
|
+
this.objectDatas.clear();
|
|
7855
|
+
this.current = null;
|
|
7853
7856
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
7854
7857
|
}
|
|
7855
|
-
|
|
7856
|
-
this.
|
|
7857
|
-
|
|
7858
|
-
this.app.scene.
|
|
7858
|
+
optimization() {
|
|
7859
|
+
this.computeView();
|
|
7860
|
+
//冻结活动网格,与自发光合用回导致内存泄露
|
|
7861
|
+
this.app.scene.freezeActiveMeshes();
|
|
7859
7862
|
}
|
|
7860
|
-
|
|
7861
|
-
|
|
7863
|
+
computeView() {
|
|
7864
|
+
this.visualAngle = new VisualAngle_VisualAngle();
|
|
7865
|
+
let bound = this.getBounding();
|
|
7866
|
+
let _vis = src.Tools.getVisualAngle(bound, this.app);
|
|
7867
|
+
this.visualAngle.alpha = _vis.alpha;
|
|
7868
|
+
this.visualAngle.beta = _vis.beta;
|
|
7869
|
+
this.visualAngle.focus = _vis.focus;
|
|
7870
|
+
this.visualAngle.radius = _vis.radius;
|
|
7862
7871
|
}
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
this.
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
this.isMonitor = _m.isMonitor;
|
|
7872
|
-
if (_m.isVisible != null)
|
|
7873
|
-
this.isVisible = _m.isVisible;
|
|
7874
|
-
this.objectType = _m.objectType;
|
|
7875
|
-
let _o = new BABYLON.Mesh(this.id, this.app.scene);
|
|
7876
|
-
let res = this.app.Resources.resources.find(this.modelId);
|
|
7877
|
-
res.meshes[0].getChildMeshes().forEach(x => {
|
|
7878
|
-
var m = x.createInstance(this.id);
|
|
7879
|
-
m.isPickable = false;
|
|
7880
|
-
m.enablePointerMoveEvents = false;
|
|
7881
|
-
m.parent = _o;
|
|
7882
|
-
});
|
|
7883
|
-
_o.rotation = src.Tools.ToVector3(_m.rotation);
|
|
7884
|
-
_o.position = src.Tools.ToVector3(_m.position);
|
|
7885
|
-
_o.scaling = src.Tools.ToVector3(_m.scaling);
|
|
7886
|
-
let bound = src.Tools.computeBounds(_o);
|
|
7887
|
-
_o.setBoundingInfo(bound);
|
|
7888
|
-
this.instance = this.app.Resources.BOX.clone(this.id);
|
|
7889
|
-
this.instance.id = this.id;
|
|
7890
|
-
this.instance.enablePointerMoveEvents = false;
|
|
7891
|
-
this.instance.isPickable = false;
|
|
7892
|
-
this.instance.scaling = new BABYLON.Vector3((bound.maximum.x - bound.minimum.x) * _o.scaling.x, (bound.maximum.y - bound.minimum.y) * _o.scaling.y, (bound.maximum.z - bound.minimum.z) * _o.scaling.z);
|
|
7893
|
-
if (this.instance.scaling.y == 0)
|
|
7894
|
-
this.instance.scaling.y = 0.01;
|
|
7895
|
-
this.instance.position = _o.position.clone();
|
|
7896
|
-
this.instance.position.y = (bound.maximum.y - bound.minimum.y) / 2 + _o.position.y;
|
|
7897
|
-
this.instance.rotation = _o.rotation.clone();
|
|
7898
|
-
_o.setParent(this.instance);
|
|
7899
|
-
this.alwaysActive();
|
|
7900
|
-
this.optimization(true);
|
|
7901
|
-
this.instance.setEnabled(false);
|
|
7902
|
-
this.visualAngle = new VisualAngle_VisualAngle(this);
|
|
7903
|
-
if (this.isAutoPlay)
|
|
7904
|
-
this.play();
|
|
7905
|
-
// this.addEventListener(EventType.doubleClick, (x) => {
|
|
7906
|
-
// console.log(x)
|
|
7907
|
-
// x.play(true);
|
|
7908
|
-
// });
|
|
7909
|
-
// this.play(true);
|
|
7910
|
-
// this.alwaysSelect();
|
|
7872
|
+
getChildNodes(_id) {
|
|
7873
|
+
let _objects = new Array();
|
|
7874
|
+
for (const id in this.objectDatas.map) {
|
|
7875
|
+
let _object = this.app.project.objectDatas.find(id);
|
|
7876
|
+
if (_object.parentId == _id && _object.objectType != ObjectType.Wall && _object.objectType != ObjectType.Corner)
|
|
7877
|
+
_objects.push(_object);
|
|
7878
|
+
}
|
|
7879
|
+
return _objects;
|
|
7911
7880
|
}
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7881
|
+
getTrees() {
|
|
7882
|
+
const infinite = (id, target) => {
|
|
7883
|
+
for (const _id in this.objectDatas.map) {
|
|
7884
|
+
let _object = this.app.project.objectDatas.find(_id);
|
|
7885
|
+
if (!_object.isMonitor || _object.parentId != id)
|
|
7886
|
+
continue;
|
|
7887
|
+
target.push({ label: _object.name, id: _object.id, type: _object.objectType, children: [] });
|
|
7888
|
+
infinite(_object.id, target[target.length - 1].children);
|
|
7889
|
+
}
|
|
7890
|
+
};
|
|
7891
|
+
let node = { label: this.root.name, id: this.root.id, type: this.root.objectType, children: [] };
|
|
7892
|
+
infinite(this.root.id, node.children);
|
|
7893
|
+
return node;
|
|
7921
7894
|
}
|
|
7922
|
-
|
|
7923
|
-
this.
|
|
7924
|
-
x.alwaysSelectAsActiveMesh = true;
|
|
7925
|
-
x.doNotSyncBoundingInfo = false;
|
|
7926
|
-
x.ignoreNonUniformScaling = true;
|
|
7927
|
-
});
|
|
7928
|
-
this.instance.alwaysSelectAsActiveMesh = true;
|
|
7929
|
-
this.instance.doNotSyncBoundingInfo = false;
|
|
7895
|
+
find(_id) {
|
|
7896
|
+
return this.objectDatas.find(_id);
|
|
7930
7897
|
}
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
this.
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
this.instance.isPickable = true;
|
|
7939
|
-
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, (e) => {
|
|
7940
|
-
let leftCall = this.clickEvents.find(EventType.leftClick);
|
|
7941
|
-
if (leftCall && e.sourceEvent.button == 0)
|
|
7942
|
-
leftCall(this, e);
|
|
7943
|
-
let rightCall = this.clickEvents.find(EventType.rightClick);
|
|
7944
|
-
if (rightCall && e.sourceEvent.button == 2)
|
|
7945
|
-
rightCall(this, e);
|
|
7946
|
-
// let doubleCall = this.clickEvents.find(EventType.doubleClick);
|
|
7947
|
-
// if (doubleCall && e.sourceEvent.button == 0 && (new Date().getTime() - this.touchtime) < 500)
|
|
7948
|
-
// doubleCall(this, e);
|
|
7949
|
-
this.touchtime = new Date().getTime();
|
|
7950
|
-
});
|
|
7951
|
-
type = "click";
|
|
7952
|
-
}
|
|
7953
|
-
else if (type == EventType.doubleClick)
|
|
7954
|
-
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger, (e) => callback(this, e));
|
|
7955
|
-
else if (type == EventType.eover) {
|
|
7956
|
-
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger, (e) => callback(this, e));
|
|
7957
|
-
this.instance.enablePointerMoveEvents = true;
|
|
7958
|
-
}
|
|
7959
|
-
else if (type == EventType.longPress)
|
|
7960
|
-
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger, (e) => callback(this, e));
|
|
7961
|
-
else if (type == EventType.out) {
|
|
7962
|
-
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger, (e) => callback(this, e));
|
|
7963
|
-
this.instance.enablePointerMoveEvents = true;
|
|
7898
|
+
findFormObjectType(_type, isCurent = true) {
|
|
7899
|
+
let _objects = new Array();
|
|
7900
|
+
for (const id in this.objectDatas.map) {
|
|
7901
|
+
let _object = this.app.project.objectDatas.find(id);
|
|
7902
|
+
if ((isCurent && _object.parentId != this.current.id) || _object.objectType != _type)
|
|
7903
|
+
continue;
|
|
7904
|
+
_objects.push(_object);
|
|
7964
7905
|
}
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7906
|
+
return _objects;
|
|
7907
|
+
}
|
|
7908
|
+
show() {
|
|
7909
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
7910
|
+
for (const id in this.app.project.objectDatas.map) {
|
|
7911
|
+
let _object = this.app.project.objectDatas.find(id);
|
|
7912
|
+
_object.setEnabled(true);
|
|
7913
|
+
}
|
|
7914
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
7915
|
+
}
|
|
7916
|
+
getBounding() {
|
|
7917
|
+
var min, max;
|
|
7918
|
+
for (const _id in this.app.project.objectDatas.map) {
|
|
7919
|
+
let _model = this.app.project.objectDatas.find(_id);
|
|
7920
|
+
if (_model.objectType == ObjectType.ParkModel || _model.objectType == ObjectType.Storey)
|
|
7921
|
+
continue;
|
|
7922
|
+
let boundingInfo = _model.instance.getBoundingInfo();
|
|
7923
|
+
if (!min || !max)
|
|
7924
|
+
min = max = boundingInfo.boundingBox.center.clone();
|
|
7925
|
+
min = BABYLON.Vector3.Minimize(min, boundingInfo.minimum.add(_model.instance.position));
|
|
7926
|
+
max = BABYLON.Vector3.Maximize(max, boundingInfo.maximum.add(_model.instance.position));
|
|
7927
|
+
}
|
|
7928
|
+
if (!min || !max) {
|
|
7929
|
+
min = BABYLON.Vector3.Zero();
|
|
7930
|
+
max = new BABYLON.Vector3(12, 0, 8);
|
|
7931
|
+
}
|
|
7932
|
+
return new BABYLON.BoundingInfo(min, max);
|
|
7933
|
+
}
|
|
7934
|
+
flyTo() {
|
|
7935
|
+
this.app.camera.flyTo(this.visualAngle, 500);
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7939
|
+
// CONCATENATED MODULE: ./src/lib/Resources.ts
|
|
7940
|
+
|
|
7941
|
+
|
|
7942
|
+
|
|
7943
|
+
class Resources_Resources {
|
|
7944
|
+
constructor(_app) {
|
|
7945
|
+
this.resourcePath = "http://models.wodashijie.com/";
|
|
7946
|
+
this.walls = new Dictionary();
|
|
7947
|
+
//模型资源集合
|
|
7948
|
+
this.resources = new Dictionary();
|
|
7949
|
+
this.ndoeMats = new Dictionary();
|
|
7950
|
+
//资源集合
|
|
7951
|
+
this.Materials = new Dictionary();
|
|
7952
|
+
//贴图集合
|
|
7953
|
+
this.Textures = new Dictionary();
|
|
7954
|
+
this.MergeMaterials = new Dictionary();
|
|
7955
|
+
this.app = _app;
|
|
7956
|
+
let tranId = GUID.getGUID(12);
|
|
7957
|
+
this.transparentBox = BABYLON.MeshBuilder.CreateBox(tranId, { size: 1 }, this.app.scene);
|
|
7958
|
+
this.transparentBox.alwaysSelectAsActiveMesh = true;
|
|
7959
|
+
let boxmat = new BABYLON.StandardMaterial(tranId, this.app.scene);
|
|
7960
|
+
boxmat.diffuseTexture = new BABYLON.Texture(this.app.rootUrl + "resources/white.jpg", this.app.scene, true, false);
|
|
7961
|
+
boxmat.alphaMode = BABYLON.Engine.ALPHA_COMBINE;
|
|
7962
|
+
boxmat.emissiveColor = BABYLON.Color3.Green();
|
|
7963
|
+
this.transparentBox.material = boxmat;
|
|
7964
|
+
this.transparentBox.setEnabled(false);
|
|
7965
|
+
this.transparentBox.visibility = 0.3;
|
|
7966
|
+
let boxId = GUID.getGUID(12);
|
|
7967
|
+
this.BOX = BABYLON.MeshBuilder.CreateBox(boxId, { size: 1 }, this.app.scene);
|
|
7968
|
+
this.BOX.edgesColor = BABYLON.Color4.FromHexString("#4ba3fff2");
|
|
7969
|
+
// this.BOX.registerInstancedBuffer("color", 4);
|
|
7970
|
+
// this.BOX.instancedBuffers.color = new BABYLON.Color4(1, 0, 0, 1);
|
|
7971
|
+
this.BOX.setEnabled(false);
|
|
7972
|
+
this.BOX.visibility = 0;
|
|
7973
|
+
// 加上材质会影响加载时间
|
|
7974
|
+
// let box_mat = new BABYLON.StandardMaterial(boxId, this.app.scene);
|
|
7975
|
+
// box_mat.diffuseColor=BABYLON.Color3.White()
|
|
7976
|
+
// box_mat.alpha = 0;
|
|
7977
|
+
// this.BOX.setEnabled(false);
|
|
7978
|
+
// this.BOX.material = box_mat;
|
|
7979
|
+
// this.BOX.material.freeze();
|
|
7980
|
+
// 粒子雾贴图
|
|
7981
|
+
this.FogTex = new BABYLON.Texture(this.app.rootUrl + "resources/fogtex.png", this.app.scene, true, false);
|
|
7982
|
+
}
|
|
7983
|
+
async loadModelMesh(baseModel) {
|
|
7984
|
+
let _mesh = this.resources.find(baseModel.modelId);
|
|
7985
|
+
if (!_mesh) {
|
|
7986
|
+
try {
|
|
7987
|
+
_mesh = await BABYLON.SceneLoader.LoadAssetContainerAsync(this.resourcePath + "bundle/" + baseModel.modelId + "/", baseModel.modelId + baseModel.extension, this.app.scene);
|
|
7988
|
+
if (_mesh.animationGroups.length > 0)
|
|
7989
|
+
_mesh.animationGroups[0].stop();
|
|
7990
|
+
_mesh.addAllToScene();
|
|
7991
|
+
_mesh.meshes[0].setEnabled(false);
|
|
7992
|
+
_mesh.meshes[0].getChildMeshes().forEach(m => {
|
|
7993
|
+
if (m.metadata && m.metadata.gltf && m.metadata.gltf.extras) {
|
|
7994
|
+
_mesh.isExtras = true;
|
|
7995
|
+
if (m.metadata.gltf.extras.U)
|
|
7996
|
+
BABYLON.Animation.CreateAndStartAnimation("u", m.material.albedoTexture, "uOffset", m.metadata.gltf.extras.Uspeed * 30, 30, 0, 1, 1);
|
|
7997
|
+
if (m.metadata.gltf.extras.V)
|
|
7998
|
+
BABYLON.Animation.CreateAndStartAnimation("v", m.material.albedoTexture, "vOffset", m.metadata.gltf.extras.Vspeed * 30, 30, 0, 1, 1);
|
|
7999
|
+
}
|
|
8000
|
+
});
|
|
8001
|
+
if (baseModel.objectType != ObjectType.OutDoorScene && !_mesh.isExtras) {
|
|
8002
|
+
_mesh.meshes[0].getChildMeshes().forEach(e => {
|
|
8003
|
+
e.registerInstancedBuffer("color", 4);
|
|
8004
|
+
e.instancedBuffers.color = new BABYLON.Color4(1, 1, 1, 1);
|
|
8005
|
+
});
|
|
8006
|
+
}
|
|
8007
|
+
this.resources.add(baseModel.modelId, _mesh);
|
|
8008
|
+
}
|
|
8009
|
+
catch (ex) {
|
|
8010
|
+
console.error("模型下载失败!模型编号:" + baseModel.modelId + ";错误信息:" + ex);
|
|
8011
|
+
}
|
|
8012
|
+
}
|
|
8013
|
+
return _mesh;
|
|
8014
|
+
}
|
|
8015
|
+
loadModelMeshAsync(baseModel, callback) {
|
|
8016
|
+
let _mesh = this.resources.find(baseModel.modelId);
|
|
8017
|
+
if (!_mesh) {
|
|
8018
|
+
BABYLON.SceneLoader.LoadAssetContainerAsync(this.resourcePath + "bundle/" + baseModel.modelId + "/", baseModel.modelId + baseModel.extension, this.app.scene).then((container) => {
|
|
8019
|
+
if (container.animationGroups.length > 0)
|
|
8020
|
+
container.animationGroups[0].stop();
|
|
8021
|
+
// container.meshes[0].getChildMeshes().forEach(e => {
|
|
8022
|
+
// (e as BABYLON.Mesh).registerInstancedBuffer("color", 4);
|
|
8023
|
+
// e.instancedBuffers.color = new BABYLON.Color4(1, 1, 1, 1);
|
|
8024
|
+
// });
|
|
8025
|
+
this.resources.add(baseModel.modelId, container);
|
|
8026
|
+
callback(container);
|
|
8027
|
+
}).catch(() => {
|
|
8028
|
+
console.error("模型下载失败!模型编号:" + baseModel.modelId);
|
|
8029
|
+
});
|
|
8030
|
+
}
|
|
8031
|
+
else
|
|
8032
|
+
callback(_mesh);
|
|
8033
|
+
}
|
|
8034
|
+
GetMaterial(textureData, scene) {
|
|
8035
|
+
let _mat = this.Materials.find(textureData.modelId);
|
|
8036
|
+
if (typeof _mat == "undefined") {
|
|
8037
|
+
let _m = this.GetTexture(textureData, scene);
|
|
8038
|
+
_mat = new BABYLON.StandardMaterial(textureData.modelId, scene);
|
|
8039
|
+
_mat.alphaMode = BABYLON.Engine.ALPHA_COMBINE;
|
|
8040
|
+
_mat.diffuseTexture = _m;
|
|
8041
|
+
this.Materials.add(textureData.modelId, _mat);
|
|
8042
|
+
// if (_m.hasAlpha) {
|
|
8043
|
+
// // _mat.needDepthPrePass = true;
|
|
8044
|
+
// _mat.useAlphaFromDiffuseTexture = true;
|
|
8045
|
+
// }
|
|
8046
|
+
}
|
|
8047
|
+
return _mat;
|
|
8048
|
+
}
|
|
8049
|
+
GetTexture(textureData, scene) {
|
|
8050
|
+
let _Texture = this.Textures.find(textureData.modelId);
|
|
8051
|
+
if (typeof _Texture == "undefined") {
|
|
8052
|
+
_Texture = new BABYLON.Texture(this.resourcePath + "texture/" + textureData.modelId + textureData.extension, scene, false);
|
|
8053
|
+
if (textureData.extension == ".png") {
|
|
8054
|
+
_Texture.hasAlpha = true;
|
|
8055
|
+
}
|
|
8056
|
+
this.Textures.add(textureData.modelId, _Texture);
|
|
8057
|
+
}
|
|
8058
|
+
return _Texture;
|
|
8059
|
+
}
|
|
8060
|
+
GetMergeMaterial(textureData, scene) {
|
|
8061
|
+
let _mat = this.MergeMaterials.find(textureData.modelId);
|
|
8062
|
+
if (typeof _mat == "undefined") {
|
|
8063
|
+
_mat = new BABYLON.CustomMaterial(textureData.modelId, scene);
|
|
8064
|
+
_mat.alphaMode = 2;
|
|
8065
|
+
this.MergeMaterials.add(textureData.modelId, _mat);
|
|
8066
|
+
// _mat.specularPower=64;
|
|
8067
|
+
// _mat.specularColor=BABYLON.Color3.Black();
|
|
8068
|
+
_mat.AddUniform('textureData', 'sampler2D', null);
|
|
8069
|
+
_mat.Vertex_Definitions(`
|
|
8070
|
+
varying vec3 localPos ;
|
|
8071
|
+
varying vec3 localNrm ;
|
|
8072
|
+
`);
|
|
8073
|
+
_mat.Fragment_Definitions(`
|
|
8074
|
+
varying vec3 localPos ;
|
|
8075
|
+
varying vec3 localNrm ;`);
|
|
8076
|
+
_mat.Vertex_Before_PositionUpdated(`
|
|
8077
|
+
localPos = position.xyz;
|
|
8078
|
+
localNrm = normal;
|
|
8079
|
+
`);
|
|
8080
|
+
let tex = this.GetTexture(textureData, scene);
|
|
8081
|
+
if (textureData.extension == ".png") {
|
|
8082
|
+
tex.hasAlpha = true;
|
|
8083
|
+
_mat.alpha = 0.9;
|
|
8084
|
+
// _mat.needDepthPrePass = true;
|
|
8085
|
+
// _mat.useAlphaFromDiffuseTexture = true;
|
|
8086
|
+
}
|
|
8087
|
+
textureData.length = 3.1;
|
|
8088
|
+
console.log(textureData.width);
|
|
8089
|
+
_mat.onBindObservable.add(() => _mat.getEffect().setTexture('textureData', tex));
|
|
8090
|
+
_mat.Fragment_Custom_Diffuse(`
|
|
8091
|
+
vec3 newUV = vec3(abs(localPos.x)/` + textureData.width + `,abs(localPos.y)/` + textureData.length + `,abs(localPos.z)/` + textureData.width + `);
|
|
8092
|
+
if(abs(localNrm.z)>abs(localNrm.x)){
|
|
8093
|
+
vec4 res = texture2D(textureData,newUV.xy);
|
|
8094
|
+
diffuseColor = res.rgb;
|
|
8095
|
+
alpha = res.a;
|
|
8096
|
+
}
|
|
8097
|
+
else {
|
|
8098
|
+
vec4 res = texture2D(textureData,newUV.zy);
|
|
8099
|
+
diffuseColor = res.rgb;
|
|
8100
|
+
alpha = res.a;
|
|
8101
|
+
}
|
|
8102
|
+
`);
|
|
8103
|
+
_mat.freeze();
|
|
8104
|
+
}
|
|
8105
|
+
return _mat;
|
|
8106
|
+
}
|
|
8107
|
+
delete(isAll = false) {
|
|
8108
|
+
this.BOX && this.BOX.dispose();
|
|
8109
|
+
this.transparentBox && this.transparentBox.dispose(true, true);
|
|
8110
|
+
this.BOX = null;
|
|
8111
|
+
this.transparentBox = null;
|
|
8112
|
+
if (isAll) {
|
|
8113
|
+
for (const _id in this.resources.map) {
|
|
8114
|
+
this.resources.find(_id).removeAllFromScene();
|
|
8115
|
+
this.resources.remove(_id);
|
|
8116
|
+
}
|
|
8117
|
+
this.resources.clear();
|
|
8118
|
+
}
|
|
8119
|
+
}
|
|
8120
|
+
async GetWalls(url, projectId) {
|
|
8121
|
+
let walls = await BABYLON.SceneLoader.LoadAssetContainerAsync(url, projectId + ".gltf", this.app.scene);
|
|
8122
|
+
if (walls.meshes) {
|
|
8123
|
+
let _walls = walls.meshes[0].getChildMeshes();
|
|
8124
|
+
for (let i = 0; i < _walls.length; i++) {
|
|
8125
|
+
this.walls.add(_walls[i].id, _walls[i]);
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
}
|
|
8129
|
+
}
|
|
8130
|
+
|
|
8131
|
+
// CONCATENATED MODULE: ./src/lib/EventType.ts
|
|
8132
|
+
var EventType;
|
|
8133
|
+
(function (EventType) {
|
|
8134
|
+
/// <summary>
|
|
8135
|
+
/// 左键单击
|
|
8136
|
+
/// </summary>
|
|
8137
|
+
EventType["leftClick"] = "leftClick";
|
|
8138
|
+
/// <summary>
|
|
8139
|
+
/// 右键单击
|
|
8140
|
+
/// </summary>
|
|
8141
|
+
EventType["rightClick"] = "rightClick";
|
|
8142
|
+
/// <summary>
|
|
8143
|
+
/// 双击
|
|
8144
|
+
/// </summary>
|
|
8145
|
+
EventType["doubleClick"] = "doubleClick";
|
|
8146
|
+
/// <summary>
|
|
8147
|
+
/// 移入
|
|
8148
|
+
/// </summary>
|
|
8149
|
+
EventType["eover"] = "eover";
|
|
8150
|
+
/// <summary>
|
|
8151
|
+
/// 长按
|
|
8152
|
+
/// </summary>
|
|
8153
|
+
EventType["longPress"] = "longPress";
|
|
8154
|
+
/// <summary>
|
|
8155
|
+
/// 移出
|
|
8156
|
+
/// </summary>
|
|
8157
|
+
EventType["out"] = "out";
|
|
8158
|
+
})(EventType || (EventType = {}));
|
|
8159
|
+
|
|
8160
|
+
// CONCATENATED MODULE: ./src/lib/EffectType.ts
|
|
8161
|
+
var EffectType;
|
|
8162
|
+
(function (EffectType) {
|
|
8163
|
+
EffectType[EffectType["Opaque"] = 0] = "Opaque";
|
|
8164
|
+
EffectType[EffectType["Flash"] = 1] = "Flash";
|
|
8165
|
+
EffectType[EffectType["Transparent"] = 2] = "Transparent";
|
|
8166
|
+
})(EffectType || (EffectType = {}));
|
|
8167
|
+
|
|
8168
|
+
// CONCATENATED MODULE: ./src/lib/components/DefaultObject.ts
|
|
8169
|
+
|
|
8170
|
+
|
|
8171
|
+
|
|
8172
|
+
|
|
8173
|
+
|
|
8174
|
+
class DefaultObject_DefaultObject {
|
|
8175
|
+
constructor(_app) {
|
|
8176
|
+
this.isVisible = true;
|
|
8177
|
+
this.executes = new Dictionary();
|
|
8178
|
+
this.clickEvents = new Dictionary();
|
|
8179
|
+
this.touchtime = new Date().getTime();
|
|
8180
|
+
this.effectType = EffectType.Opaque;
|
|
8181
|
+
this._isMonitor = true;
|
|
8182
|
+
this.app = _app;
|
|
8183
|
+
}
|
|
8184
|
+
set isMonitor(_value) {
|
|
8185
|
+
this._isMonitor = _value;
|
|
8186
|
+
}
|
|
8187
|
+
get isMonitor() {
|
|
8188
|
+
return this._isMonitor;
|
|
8189
|
+
}
|
|
8190
|
+
setEnabled(_value) {
|
|
8191
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8192
|
+
this.instance.setEnabled(_value);
|
|
8193
|
+
this.isEnabled = _value;
|
|
8194
|
+
if (this.isEnabled) {
|
|
8195
|
+
this.instance.isPickable = this.executes.count() > 0;
|
|
8196
|
+
if (this.executes.find(EventType.eover) || this.executes.find(EventType.out))
|
|
8197
|
+
this.instance.enablePointerMoveEvents = true;
|
|
8198
|
+
else
|
|
8199
|
+
this.instance.enablePointerMoveEvents = false;
|
|
8200
|
+
}
|
|
8201
|
+
else {
|
|
8202
|
+
this.instance.isPickable = false;
|
|
8203
|
+
this.instance.enablePointerMoveEvents = false;
|
|
8204
|
+
}
|
|
8205
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8206
|
+
}
|
|
8207
|
+
set showBoundingBox(_value) {
|
|
8208
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8209
|
+
this.instance.showBoundingBox = _value;
|
|
8210
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8211
|
+
}
|
|
8212
|
+
get showBoundingBox() {
|
|
8213
|
+
return this.instance.showBoundingBox;
|
|
8214
|
+
}
|
|
8215
|
+
bind(_m) {
|
|
8216
|
+
this.id = _m.id;
|
|
8217
|
+
this.name = _m.name;
|
|
8218
|
+
this.parentId = _m.parentId;
|
|
8219
|
+
this.modelId = _m.baseModel.modelId;
|
|
8220
|
+
this.animation = _m.animation;
|
|
8221
|
+
this.isAutoPlay = _m.isAutoPlay;
|
|
8222
|
+
this.isloop = _m.isloop;
|
|
8223
|
+
this.isMonitor = _m.isMonitor;
|
|
8224
|
+
if (_m.isVisible != null)
|
|
8225
|
+
this.isVisible = _m.isVisible;
|
|
8226
|
+
this.objectType = _m.objectType;
|
|
8227
|
+
let _o = new BABYLON.Mesh(this.id, this.app.scene);
|
|
8228
|
+
let res = this.app.Resources.resources.find(this.modelId);
|
|
8229
|
+
res.meshes[0].getChildMeshes().forEach(x => {
|
|
8230
|
+
var m = x.createInstance(this.id);
|
|
8231
|
+
m.isPickable = false;
|
|
8232
|
+
m.enablePointerMoveEvents = false;
|
|
8233
|
+
m.parent = _o;
|
|
8234
|
+
});
|
|
8235
|
+
_o.rotation = src.Tools.ToVector3(_m.rotation);
|
|
8236
|
+
_o.position = src.Tools.ToVector3(_m.position);
|
|
8237
|
+
_o.scaling = src.Tools.ToVector3(_m.scaling);
|
|
8238
|
+
let bound = src.Tools.computeBounds(_o);
|
|
8239
|
+
_o.setBoundingInfo(bound);
|
|
8240
|
+
this.instance = this.app.Resources.BOX.clone(this.id);
|
|
8241
|
+
this.instance.id = this.id;
|
|
8242
|
+
this.instance.enablePointerMoveEvents = false;
|
|
8243
|
+
this.instance.isPickable = false;
|
|
8244
|
+
this.instance.scaling = new BABYLON.Vector3((bound.maximum.x - bound.minimum.x) * _o.scaling.x, (bound.maximum.y - bound.minimum.y) * _o.scaling.y, (bound.maximum.z - bound.minimum.z) * _o.scaling.z);
|
|
8245
|
+
if (this.instance.scaling.y == 0)
|
|
8246
|
+
this.instance.scaling.y = 0.01;
|
|
8247
|
+
this.instance.position = _o.position.clone();
|
|
8248
|
+
this.instance.position.y = (bound.maximum.y - bound.minimum.y) / 2 + _o.position.y;
|
|
8249
|
+
this.instance.rotation = _o.rotation.clone();
|
|
8250
|
+
_o.setParent(this.instance);
|
|
8251
|
+
this.alwaysActive();
|
|
8252
|
+
this.optimization(true);
|
|
8253
|
+
this.instance.setEnabled(false);
|
|
8254
|
+
this.computeView();
|
|
8255
|
+
if (this.isAutoPlay)
|
|
8256
|
+
this.play();
|
|
8257
|
+
// this.instance.showBoundingBox=true;
|
|
8258
|
+
// this.addEventListener(EventType.doubleClick, (x) => {
|
|
8259
|
+
// console.log(x)
|
|
8260
|
+
// x.play(true);
|
|
8261
|
+
// });
|
|
8262
|
+
// this.play(true);
|
|
8263
|
+
// this.alwaysSelect();
|
|
8264
|
+
}
|
|
8265
|
+
computeView() {
|
|
8266
|
+
this.visualAngle = new VisualAngle_VisualAngle();
|
|
8267
|
+
let bound = this.instance.getBoundingInfo();
|
|
8268
|
+
let _vis = src.Tools.getVisualAngle(bound, this.app);
|
|
8269
|
+
this.visualAngle.alpha = _vis.alpha;
|
|
8270
|
+
this.visualAngle.beta = _vis.beta;
|
|
8271
|
+
this.visualAngle.focus = this.instance.getAbsolutePosition();
|
|
8272
|
+
this.visualAngle.radius = bound.boundingSphere.radiusWorld + 3;
|
|
8273
|
+
this.visualAngle.minimumLimit = 0.3;
|
|
8274
|
+
this.visualAngle.maximumLimit = this.visualAngle.radius * 2;
|
|
8275
|
+
this.visualAngle.minBeta = 0.01;
|
|
8276
|
+
this.visualAngle.maxBeta = (Math.PI / 2) * 0.98;
|
|
8277
|
+
}
|
|
8278
|
+
//true:优化,false:取消优化
|
|
8279
|
+
optimization(_isOptimization) {
|
|
8280
|
+
this.instance.getChildMeshes().forEach(x => {
|
|
8281
|
+
_isOptimization ? x.freezeWorldMatrix() : x.unfreezeWorldMatrix();
|
|
8282
|
+
// if (x.material) _isOptimization ? x.material.freeze() : x.material.unfreeze();
|
|
8283
|
+
});
|
|
8284
|
+
_isOptimization ? this.instance.freezeWorldMatrix() : this.instance.unfreezeWorldMatrix();
|
|
8285
|
+
if (this.instance.material)
|
|
8286
|
+
_isOptimization ? this.instance.material.freeze() : this.instance.material.unfreeze();
|
|
8287
|
+
}
|
|
8288
|
+
alwaysActive() {
|
|
8289
|
+
this.instance.getChildMeshes().forEach(x => {
|
|
8290
|
+
x.alwaysSelectAsActiveMesh = true;
|
|
8291
|
+
x.doNotSyncBoundingInfo = false;
|
|
8292
|
+
x.ignoreNonUniformScaling = true;
|
|
8293
|
+
});
|
|
8294
|
+
this.instance.alwaysSelectAsActiveMesh = true;
|
|
8295
|
+
this.instance.doNotSyncBoundingInfo = false;
|
|
8296
|
+
}
|
|
8297
|
+
//添加模型事件
|
|
8298
|
+
addEventListener(type, callback) {
|
|
8299
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8300
|
+
let execut = null;
|
|
8301
|
+
if (type == EventType.leftClick || type == EventType.rightClick) {
|
|
8302
|
+
this.clickEvents.remove(type);
|
|
8303
|
+
this.clickEvents.add(type, callback);
|
|
8304
|
+
this.instance.isPickable = true;
|
|
8305
|
+
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, (e) => {
|
|
8306
|
+
let leftCall = this.clickEvents.find(EventType.leftClick);
|
|
8307
|
+
if (leftCall && e.sourceEvent.button == 0)
|
|
8308
|
+
leftCall(this, e);
|
|
8309
|
+
let rightCall = this.clickEvents.find(EventType.rightClick);
|
|
8310
|
+
if (rightCall && e.sourceEvent.button == 2)
|
|
8311
|
+
rightCall(this, e);
|
|
8312
|
+
// let doubleCall = this.clickEvents.find(EventType.doubleClick);
|
|
8313
|
+
// if (doubleCall && e.sourceEvent.button == 0 && (new Date().getTime() - this.touchtime) < 500)
|
|
8314
|
+
// doubleCall(this, e);
|
|
8315
|
+
this.touchtime = new Date().getTime();
|
|
8316
|
+
});
|
|
8317
|
+
type = "click";
|
|
8318
|
+
}
|
|
8319
|
+
else if (type == EventType.doubleClick)
|
|
8320
|
+
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnDoublePickTrigger, (e) => callback(this, e));
|
|
8321
|
+
else if (type == EventType.eover) {
|
|
8322
|
+
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger, (e) => callback(this, e));
|
|
8323
|
+
this.instance.enablePointerMoveEvents = true;
|
|
8324
|
+
}
|
|
8325
|
+
else if (type == EventType.longPress)
|
|
8326
|
+
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger, (e) => callback(this, e));
|
|
8327
|
+
else if (type == EventType.out) {
|
|
8328
|
+
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger, (e) => callback(this, e));
|
|
8329
|
+
this.instance.enablePointerMoveEvents = true;
|
|
8330
|
+
}
|
|
8331
|
+
if (execut) {
|
|
8332
|
+
if (!this.action) {
|
|
8333
|
+
this.action = new BABYLON.ActionManager(this.app.scene);
|
|
8334
|
+
this.instance.actionManager = this.action;
|
|
8335
|
+
// this.instance.getChildMeshes().forEach(e => e.actionManager = this.action);
|
|
8336
|
+
}
|
|
8337
|
+
let oldExecut = this.executes.find(type);
|
|
8338
|
+
if (oldExecut)
|
|
8339
|
+
this.action.unregisterAction(oldExecut);
|
|
8340
|
+
this.executes.remove(type);
|
|
8341
|
+
this.executes.add(type, execut);
|
|
8342
|
+
this.action.registerAction(execut);
|
|
7977
8343
|
}
|
|
7978
8344
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
7979
8345
|
}
|
|
@@ -8044,101 +8410,30 @@ class DefaultObject_DefaultObject {
|
|
|
8044
8410
|
m.animations.forEach((e) => { if (e.name.indexOf("open") != -1)
|
|
8045
8411
|
open = e; });
|
|
8046
8412
|
if (open)
|
|
8047
|
-
this.app.scene.beginDirectAnimation(m, [open], 0, open.getKeys().length * 10, this.isloop);
|
|
8048
|
-
else
|
|
8049
|
-
m.animations.forEach((e) => this.app.scene.beginDirectAnimation(m, [e], 0, e.getKeys().length * 10, this.isloop));
|
|
8050
|
-
});
|
|
8051
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8052
|
-
}
|
|
8053
|
-
stop() {
|
|
8054
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8055
|
-
this.instance.getChildMeshes().forEach(m => {
|
|
8056
|
-
let close;
|
|
8057
|
-
m.animations.forEach((e) => { if (e.name.indexOf("close") != -1)
|
|
8058
|
-
close = e; });
|
|
8059
|
-
if (close)
|
|
8060
|
-
this.app.scene.beginDirectAnimation(m, [close], 0, close.getKeys().length * 10, false);
|
|
8061
|
-
else
|
|
8062
|
-
m.animations.forEach((e) => this.app.scene.beginDirectAnimation(m, [e], e.getKeys().length * 10, 0, false));
|
|
8063
|
-
});
|
|
8064
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8065
|
-
}
|
|
8066
|
-
flyTo() {
|
|
8067
|
-
this.app.camera.flyTo(this.visualAngle, 500);
|
|
8068
|
-
}
|
|
8069
|
-
focus() {
|
|
8070
|
-
// this.app.Camera.focusingFromProperty(this.visualAngle);
|
|
8071
|
-
}
|
|
8072
|
-
}
|
|
8073
|
-
|
|
8074
|
-
// CONCATENATED MODULE: ./src/lib/components/ConduitObject.ts
|
|
8075
|
-
|
|
8076
|
-
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
//墙角
|
|
8081
|
-
class ConduitObject_ConduitObject extends DefaultObject_DefaultObject {
|
|
8082
|
-
bind(_m) {
|
|
8083
|
-
this.id = _m.id;
|
|
8084
|
-
this.name = _m.name;
|
|
8085
|
-
this.parentId = _m.parentId;
|
|
8086
|
-
this.isMonitor = _m.isMonitor;
|
|
8087
|
-
this.objectType = _m.objectType;
|
|
8088
|
-
this.isVisible = true;
|
|
8089
|
-
this.color = _m.color;
|
|
8090
|
-
let pists = Tools.ToARRVector3(_m.pints);
|
|
8091
|
-
this.instance = Tools.createTube(_m.id, pists, _m.radius, this.app);
|
|
8092
|
-
let mat = new BABYLON.StandardMaterial(_m.id, this.app.scene);
|
|
8093
|
-
mat.diffuseColor = BABYLON.Color3.FromHexString(_m.color);
|
|
8094
|
-
mat.alpha = _m.alpha;
|
|
8095
|
-
this.alpha = _m.alpha;
|
|
8096
|
-
this.instance.material = mat;
|
|
8097
|
-
this.instance.enablePointerMoveEvents = this.isMonitor;
|
|
8098
|
-
this.instance.isPickable = this.isMonitor;
|
|
8099
|
-
this.instance.setEnabled(false);
|
|
8100
|
-
this.alwaysActive();
|
|
8101
|
-
this.optimization(true);
|
|
8102
|
-
this.visualAngle = new VisualAngle_VisualAngle(this);
|
|
8103
|
-
//重新计算包围盒
|
|
8104
|
-
// this.bound = this.instance.getBoundingInfo();
|
|
8105
|
-
// this.visualAngle = this.app.Tools.getVisualAngle(this.bound);
|
|
8106
|
-
// this.visualAngle.radius = this.bound.boundingSphere.radiusWorld + 3;
|
|
8107
|
-
// this.alwaysSelect();
|
|
8108
|
-
}
|
|
8109
|
-
//设置告警闪烁
|
|
8110
|
-
setFlash(_level = 1) {
|
|
8111
|
-
if (this.effectType != EffectType.Opaque)
|
|
8112
|
-
return;
|
|
8113
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8114
|
-
this.optimization(false);
|
|
8115
|
-
this.instance.material.emissiveColor = src.EffectMgr.colors[_level];
|
|
8116
|
-
this.app.Glow.addIncludedOnlyMesh(this.instance);
|
|
8117
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8118
|
-
this.effectType = EffectType.Flash;
|
|
8119
|
-
}
|
|
8120
|
-
//设置正常
|
|
8121
|
-
setOpaque() {
|
|
8122
|
-
if (this.effectType == EffectType.Opaque)
|
|
8123
|
-
return;
|
|
8124
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8125
|
-
this.app.Glow.removeIncludedOnlyMesh(this.instance);
|
|
8126
|
-
this.optimization(true);
|
|
8127
|
-
this.instance.material.alpha = this.alpha;
|
|
8128
|
-
this.instance.material.emissiveColor = null;
|
|
8413
|
+
this.app.scene.beginDirectAnimation(m, [open], 0, open.getKeys().length * 10, this.isloop);
|
|
8414
|
+
else
|
|
8415
|
+
m.animations.forEach((e) => this.app.scene.beginDirectAnimation(m, [e], 0, e.getKeys().length * 10, this.isloop));
|
|
8416
|
+
});
|
|
8129
8417
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8130
|
-
this.effectType = EffectType.Opaque;
|
|
8131
8418
|
}
|
|
8132
|
-
|
|
8133
|
-
setTransparent(alpha = 0.3) {
|
|
8134
|
-
if (this.effectType != EffectType.Opaque)
|
|
8135
|
-
return;
|
|
8419
|
+
stop() {
|
|
8136
8420
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8137
|
-
this.
|
|
8138
|
-
|
|
8139
|
-
|
|
8421
|
+
this.instance.getChildMeshes().forEach(m => {
|
|
8422
|
+
let close;
|
|
8423
|
+
m.animations.forEach((e) => { if (e.name.indexOf("close") != -1)
|
|
8424
|
+
close = e; });
|
|
8425
|
+
if (close)
|
|
8426
|
+
this.app.scene.beginDirectAnimation(m, [close], 0, close.getKeys().length * 10, false);
|
|
8427
|
+
else
|
|
8428
|
+
m.animations.forEach((e) => this.app.scene.beginDirectAnimation(m, [e], e.getKeys().length * 10, 0, false));
|
|
8429
|
+
});
|
|
8140
8430
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8141
|
-
|
|
8431
|
+
}
|
|
8432
|
+
flyTo() {
|
|
8433
|
+
this.app.camera.translation(this.visualAngle, 500);
|
|
8434
|
+
}
|
|
8435
|
+
focus() {
|
|
8436
|
+
// this.app.Camera.focusingFromProperty(this.visualAngle);
|
|
8142
8437
|
}
|
|
8143
8438
|
}
|
|
8144
8439
|
|
|
@@ -8183,7 +8478,6 @@ class WallObject_WallObject extends DefaultObject_DefaultObject {
|
|
|
8183
8478
|
// CONCATENATED MODULE: ./src/lib/components/WindowObject.ts
|
|
8184
8479
|
|
|
8185
8480
|
|
|
8186
|
-
|
|
8187
8481
|
//窗户
|
|
8188
8482
|
class WindowObject_WindowObject extends DefaultObject_DefaultObject {
|
|
8189
8483
|
// virtualBox: BABYLON.InstancedMesh;
|
|
@@ -8245,7 +8539,7 @@ class WindowObject_WindowObject extends DefaultObject_DefaultObject {
|
|
|
8245
8539
|
this.alwaysActive();
|
|
8246
8540
|
this.optimization(true);
|
|
8247
8541
|
this.instance.setEnabled(false);
|
|
8248
|
-
this.
|
|
8542
|
+
this.computeView();
|
|
8249
8543
|
//重新计算包围盒
|
|
8250
8544
|
// this.bound = this.instance.getBoundingInfo();
|
|
8251
8545
|
// this.visualAngle = this.app.Tools.getVisualAngle(this.bound);
|
|
@@ -8258,7 +8552,6 @@ class WindowObject_WindowObject extends DefaultObject_DefaultObject {
|
|
|
8258
8552
|
// CONCATENATED MODULE: ./src/lib/components/DoorObject.ts
|
|
8259
8553
|
|
|
8260
8554
|
|
|
8261
|
-
|
|
8262
8555
|
//门
|
|
8263
8556
|
class DoorObject_DoorObject extends DefaultObject_DefaultObject {
|
|
8264
8557
|
bind(_m) {
|
|
@@ -8293,7 +8586,7 @@ class DoorObject_DoorObject extends DefaultObject_DefaultObject {
|
|
|
8293
8586
|
this.alwaysActive();
|
|
8294
8587
|
this.optimization(true);
|
|
8295
8588
|
this.instance.setEnabled(false);
|
|
8296
|
-
this.
|
|
8589
|
+
this.computeView();
|
|
8297
8590
|
}
|
|
8298
8591
|
}
|
|
8299
8592
|
|
|
@@ -8311,7 +8604,9 @@ class CabinetObject_CabinetObject extends DefaultObject_DefaultObject {
|
|
|
8311
8604
|
//漏水线
|
|
8312
8605
|
class LeakWaterObject_LeakWaterObject extends DefaultObject_DefaultObject {
|
|
8313
8606
|
bind(_l) {
|
|
8607
|
+
this.visualAngle = new VisualAngle_VisualAngle();
|
|
8314
8608
|
let lines = src.Tools.ToARRVector3(_l.lines);
|
|
8609
|
+
this.visualAngle.focus = lines[0].clone();
|
|
8315
8610
|
this.instance = src.Tools.createTube(_l.id, lines, 0.02, this.app);
|
|
8316
8611
|
this.instance.setEnabled(false);
|
|
8317
8612
|
this.id = _l.id;
|
|
@@ -8326,7 +8621,7 @@ class LeakWaterObject_LeakWaterObject extends DefaultObject_DefaultObject {
|
|
|
8326
8621
|
this.instance.material = material0;
|
|
8327
8622
|
this.alwaysActive();
|
|
8328
8623
|
this.optimization(true);
|
|
8329
|
-
this.
|
|
8624
|
+
this.computeView();
|
|
8330
8625
|
// let bound = this.instance.getBoundingInfo();
|
|
8331
8626
|
// this.instance.position = this.bound.boundingBox.center.clone();
|
|
8332
8627
|
// this.visualAngle = MX3D.Tools.getVisualAngle(bound);
|
|
@@ -8335,6 +8630,17 @@ class LeakWaterObject_LeakWaterObject extends DefaultObject_DefaultObject {
|
|
|
8335
8630
|
// this.visualAngle.radius = this.bound.boundingSphere.radiusWorld + 3;
|
|
8336
8631
|
// this.alwaysSelect();
|
|
8337
8632
|
}
|
|
8633
|
+
computeView() {
|
|
8634
|
+
let bound = this.instance.getBoundingInfo();
|
|
8635
|
+
let _vis = src.Tools.getVisualAngle(bound, this.app);
|
|
8636
|
+
this.visualAngle.alpha = _vis.alpha;
|
|
8637
|
+
this.visualAngle.beta = _vis.beta;
|
|
8638
|
+
this.visualAngle.radius = bound.boundingSphere.radiusWorld + 3;
|
|
8639
|
+
this.visualAngle.minimumLimit = 0.3;
|
|
8640
|
+
this.visualAngle.maximumLimit = this.visualAngle.radius * 2;
|
|
8641
|
+
this.visualAngle.minBeta = 0.01;
|
|
8642
|
+
this.visualAngle.maxBeta = (Math.PI / 2) * 0.98;
|
|
8643
|
+
}
|
|
8338
8644
|
//添加模型事件
|
|
8339
8645
|
addEventListener(type, callback) {
|
|
8340
8646
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
@@ -8342,6 +8648,8 @@ class LeakWaterObject_LeakWaterObject extends DefaultObject_DefaultObject {
|
|
|
8342
8648
|
if (type == EventType.leftClick || type == EventType.rightClick || type == EventType.doubleClick) {
|
|
8343
8649
|
this.clickEvents.remove(type);
|
|
8344
8650
|
this.clickEvents.add(type, callback);
|
|
8651
|
+
this.instance.isPickable = true;
|
|
8652
|
+
// this.instance.enablePointerMoveEvents = true;
|
|
8345
8653
|
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, (e) => {
|
|
8346
8654
|
let leftCall = this.clickEvents.find(EventType.leftClick);
|
|
8347
8655
|
if (leftCall && e.sourceEvent.button == 0)
|
|
@@ -8356,16 +8664,20 @@ class LeakWaterObject_LeakWaterObject extends DefaultObject_DefaultObject {
|
|
|
8356
8664
|
});
|
|
8357
8665
|
type = "click";
|
|
8358
8666
|
}
|
|
8359
|
-
else if (type == EventType.eover)
|
|
8667
|
+
else if (type == EventType.eover) {
|
|
8360
8668
|
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOverTrigger, (e) => callback(this, e));
|
|
8669
|
+
this.instance.enablePointerMoveEvents = true;
|
|
8670
|
+
}
|
|
8361
8671
|
else if (type == EventType.longPress)
|
|
8362
8672
|
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnLongPressTrigger, (e) => callback(this, e));
|
|
8363
|
-
else if (type == EventType.out)
|
|
8673
|
+
else if (type == EventType.out) {
|
|
8364
8674
|
execut = new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPointerOutTrigger, (e) => callback(this, e));
|
|
8675
|
+
this.instance.enablePointerMoveEvents = true;
|
|
8676
|
+
}
|
|
8365
8677
|
if (execut) {
|
|
8366
8678
|
if (!this.action) {
|
|
8367
8679
|
this.action = new BABYLON.ActionManager(this.app.scene);
|
|
8368
|
-
this.instance.
|
|
8680
|
+
this.instance.actionManager = this.action;
|
|
8369
8681
|
}
|
|
8370
8682
|
let oldExecut = this.executes.find(type);
|
|
8371
8683
|
if (oldExecut)
|
|
@@ -8402,7 +8714,6 @@ class LeakWaterObject_LeakWaterObject extends DefaultObject_DefaultObject {
|
|
|
8402
8714
|
// CONCATENATED MODULE: ./src/lib/components/VirtualBoxObject.ts
|
|
8403
8715
|
|
|
8404
8716
|
|
|
8405
|
-
|
|
8406
8717
|
//虚拟盒子
|
|
8407
8718
|
class VirtualBoxObject_VirtualBoxObject extends DefaultObject_DefaultObject {
|
|
8408
8719
|
async bind(_m) {
|
|
@@ -8452,7 +8763,7 @@ class VirtualBoxObject_VirtualBoxObject extends DefaultObject_DefaultObject {
|
|
|
8452
8763
|
this.instance.scaling = src.Tools.ToVector3(_m.scaling);
|
|
8453
8764
|
this.alwaysActive();
|
|
8454
8765
|
this.optimization(true);
|
|
8455
|
-
this.
|
|
8766
|
+
this.computeView();
|
|
8456
8767
|
//重新计算包围盒
|
|
8457
8768
|
// this.bound = this.instance.getBoundingInfo();
|
|
8458
8769
|
// this.visualAngle = this.app.Tools.getVisualAngle(this.bound);
|
|
@@ -8465,7 +8776,6 @@ class VirtualBoxObject_VirtualBoxObject extends DefaultObject_DefaultObject {
|
|
|
8465
8776
|
// CONCATENATED MODULE: ./src/lib/components/UI3DTextObject.ts
|
|
8466
8777
|
|
|
8467
8778
|
|
|
8468
|
-
|
|
8469
8779
|
//3d文本
|
|
8470
8780
|
class UI3DTextObject_UI3DTextObject extends DefaultObject_DefaultObject {
|
|
8471
8781
|
// set transparent(_value: boolean) {
|
|
@@ -8523,7 +8833,7 @@ class UI3DTextObject_UI3DTextObject extends DefaultObject_DefaultObject {
|
|
|
8523
8833
|
this.instance.material = mat;
|
|
8524
8834
|
this.alwaysActive();
|
|
8525
8835
|
this.optimization(true);
|
|
8526
|
-
this.
|
|
8836
|
+
this.computeView();
|
|
8527
8837
|
//重新计算包围盒
|
|
8528
8838
|
// this.bound = this.instance.getBoundingInfo();
|
|
8529
8839
|
// this.visualAngle = this.app.Tools.getVisualAngle(this.bound);
|
|
@@ -8533,8 +8843,91 @@ class UI3DTextObject_UI3DTextObject extends DefaultObject_DefaultObject {
|
|
|
8533
8843
|
}
|
|
8534
8844
|
}
|
|
8535
8845
|
|
|
8536
|
-
// CONCATENATED MODULE: ./src/lib/components/
|
|
8846
|
+
// CONCATENATED MODULE: ./src/lib/components/ConduitObject.ts
|
|
8847
|
+
|
|
8848
|
+
|
|
8849
|
+
|
|
8850
|
+
|
|
8537
8851
|
|
|
8852
|
+
//墙角
|
|
8853
|
+
class ConduitObject_ConduitObject extends DefaultObject_DefaultObject {
|
|
8854
|
+
bind(_m) {
|
|
8855
|
+
this.id = _m.id;
|
|
8856
|
+
this.name = _m.name;
|
|
8857
|
+
this.parentId = _m.parentId;
|
|
8858
|
+
this.isMonitor = _m.isMonitor;
|
|
8859
|
+
this.objectType = _m.objectType;
|
|
8860
|
+
this.isVisible = true;
|
|
8861
|
+
this.color = _m.color;
|
|
8862
|
+
let pists = Tools.ToARRVector3(_m.pints);
|
|
8863
|
+
this.instance = Tools.createTube(_m.id, pists, _m.radius, this.app);
|
|
8864
|
+
let mat = new BABYLON.StandardMaterial(_m.id, this.app.scene);
|
|
8865
|
+
mat.diffuseColor = BABYLON.Color3.FromHexString(_m.color);
|
|
8866
|
+
mat.alpha = _m.alpha;
|
|
8867
|
+
this.alpha = _m.alpha;
|
|
8868
|
+
this.instance.material = mat;
|
|
8869
|
+
this.instance.enablePointerMoveEvents = this.isMonitor;
|
|
8870
|
+
this.instance.isPickable = this.isMonitor;
|
|
8871
|
+
this.instance.setEnabled(false);
|
|
8872
|
+
this.alwaysActive();
|
|
8873
|
+
this.optimization(true);
|
|
8874
|
+
this.computeView();
|
|
8875
|
+
//重新计算包围盒
|
|
8876
|
+
// this.bound = this.instance.getBoundingInfo();
|
|
8877
|
+
// this.visualAngle = this.app.Tools.getVisualAngle(this.bound);
|
|
8878
|
+
// this.visualAngle.radius = this.bound.boundingSphere.radiusWorld + 3;
|
|
8879
|
+
// this.alwaysSelect();
|
|
8880
|
+
}
|
|
8881
|
+
computeView() {
|
|
8882
|
+
this.visualAngle = new VisualAngle_VisualAngle();
|
|
8883
|
+
let bound = this.instance.getBoundingInfo();
|
|
8884
|
+
let _vis = src.Tools.getVisualAngle(bound, this.app);
|
|
8885
|
+
this.alpha = _vis.alpha;
|
|
8886
|
+
this.visualAngle.beta = _vis.beta;
|
|
8887
|
+
this.visualAngle.focus = _vis.focus;
|
|
8888
|
+
this.visualAngle.radius = _vis.radius;
|
|
8889
|
+
this.visualAngle.minimumLimit = 0.3;
|
|
8890
|
+
this.visualAngle.maximumLimit = this.visualAngle.radius * 2;
|
|
8891
|
+
this.visualAngle.minBeta = 0.01;
|
|
8892
|
+
this.visualAngle.maxBeta = (Math.PI / 2) * 0.98;
|
|
8893
|
+
}
|
|
8894
|
+
//设置告警闪烁
|
|
8895
|
+
setFlash(_level = 1) {
|
|
8896
|
+
if (this.effectType != EffectType.Opaque)
|
|
8897
|
+
return;
|
|
8898
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8899
|
+
this.optimization(false);
|
|
8900
|
+
this.instance.material.emissiveColor = src.EffectMgr.colors[_level];
|
|
8901
|
+
this.app.Glow.addIncludedOnlyMesh(this.instance);
|
|
8902
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8903
|
+
this.effectType = EffectType.Flash;
|
|
8904
|
+
}
|
|
8905
|
+
//设置正常
|
|
8906
|
+
setOpaque() {
|
|
8907
|
+
if (this.effectType == EffectType.Opaque)
|
|
8908
|
+
return;
|
|
8909
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8910
|
+
this.app.Glow.removeIncludedOnlyMesh(this.instance);
|
|
8911
|
+
this.optimization(true);
|
|
8912
|
+
this.instance.material.alpha = this.alpha;
|
|
8913
|
+
this.instance.material.emissiveColor = null;
|
|
8914
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8915
|
+
this.effectType = EffectType.Opaque;
|
|
8916
|
+
}
|
|
8917
|
+
//设置半透明
|
|
8918
|
+
setTransparent(alpha = 0.3) {
|
|
8919
|
+
if (this.effectType != EffectType.Opaque)
|
|
8920
|
+
return;
|
|
8921
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
8922
|
+
this.app.Glow.removeIncludedOnlyMesh(this.instance);
|
|
8923
|
+
this.optimization(false);
|
|
8924
|
+
this.instance.material.alpha = alpha;
|
|
8925
|
+
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
8926
|
+
this.effectType = EffectType.Transparent;
|
|
8927
|
+
}
|
|
8928
|
+
}
|
|
8929
|
+
|
|
8930
|
+
// CONCATENATED MODULE: ./src/lib/components/FloorObject.ts
|
|
8538
8931
|
|
|
8539
8932
|
|
|
8540
8933
|
//房间
|
|
@@ -8566,7 +8959,7 @@ class FloorObject_FloorObject extends DefaultObject_DefaultObject {
|
|
|
8566
8959
|
}
|
|
8567
8960
|
this.instance.material = material0;
|
|
8568
8961
|
this.optimization(true);
|
|
8569
|
-
this.
|
|
8962
|
+
this.computeView();
|
|
8570
8963
|
// this.nativeMaterial = material0;
|
|
8571
8964
|
// this.material = this.nativeMaterial;
|
|
8572
8965
|
// this.alwaysSelect();
|
|
@@ -8579,7 +8972,6 @@ class FloorObject_FloorObject extends DefaultObject_DefaultObject {
|
|
|
8579
8972
|
|
|
8580
8973
|
// CONCATENATED MODULE: ./src/lib/components/OptimizedWallObject.ts
|
|
8581
8974
|
|
|
8582
|
-
|
|
8583
8975
|
//墙体
|
|
8584
8976
|
class OptimizedWallObject_OptimizedWallObject extends DefaultObject_DefaultObject {
|
|
8585
8977
|
// set transparent(_value: boolean) {
|
|
@@ -8637,7 +9029,7 @@ class OptimizedWallObject_OptimizedWallObject extends DefaultObject_DefaultObjec
|
|
|
8637
9029
|
this.alwaysActive();
|
|
8638
9030
|
this.optimization(true);
|
|
8639
9031
|
this.instance.setEnabled(false);
|
|
8640
|
-
this.
|
|
9032
|
+
this.computeView();
|
|
8641
9033
|
}
|
|
8642
9034
|
}
|
|
8643
9035
|
}
|
|
@@ -8757,10 +9149,23 @@ class AirFlowObject_AirFlowObject extends DefaultObject_DefaultObject {
|
|
|
8757
9149
|
this.alwaysActive();
|
|
8758
9150
|
this.optimization(true);
|
|
8759
9151
|
this.instance.setEnabled(false);
|
|
8760
|
-
this.
|
|
9152
|
+
this.computeView();
|
|
8761
9153
|
if (this.isAutoPlay)
|
|
8762
9154
|
this.play();
|
|
8763
9155
|
}
|
|
9156
|
+
computeView() {
|
|
9157
|
+
this.visualAngle = new VisualAngle_VisualAngle();
|
|
9158
|
+
let bound = this.instance.getBoundingInfo();
|
|
9159
|
+
let _vis = src.Tools.getVisualAngle(bound, this.app);
|
|
9160
|
+
this.visualAngle.alpha = _vis.alpha;
|
|
9161
|
+
this.visualAngle.beta = _vis.beta;
|
|
9162
|
+
this.visualAngle.focus = this.instance.getAbsolutePosition();
|
|
9163
|
+
this.visualAngle.radius = bound.boundingSphere.radiusWorld + 3;
|
|
9164
|
+
this.visualAngle.minimumLimit = 0.3;
|
|
9165
|
+
this.visualAngle.maximumLimit = this.visualAngle.radius * 2;
|
|
9166
|
+
this.visualAngle.minBeta = 0.01;
|
|
9167
|
+
this.visualAngle.maxBeta = (Math.PI / 2) * 0.98;
|
|
9168
|
+
}
|
|
8764
9169
|
setFlash(_level) {
|
|
8765
9170
|
}
|
|
8766
9171
|
setTransparent(_alpha) {
|
|
@@ -8991,203 +9396,68 @@ class Region_Region extends DefaultObject_DefaultObject {
|
|
|
8991
9396
|
}
|
|
8992
9397
|
//右面墙
|
|
8993
9398
|
let rightMetopes = beforeWalls.find(walls[i].rightMap.modelId);
|
|
8994
|
-
if (!rightMetopes) {
|
|
8995
|
-
rightMetopes = { t: walls[i].rightMap, walls: new Array() };
|
|
8996
|
-
beforeWalls.add(walls[i].rightMap.modelId, rightMetopes);
|
|
8997
|
-
}
|
|
8998
|
-
let subMeshs = src.Tools.DeconsTructMesh(_obejct, parseFloat(walls[i].height), this.app);
|
|
8999
|
-
for (let i = 0; i < subMeshs.length; i++) {
|
|
9000
|
-
// if (i == 3 || i == 7) walfenli[i].dispose();
|
|
9001
|
-
// else
|
|
9002
|
-
if (i == 2 || i == 3)
|
|
9003
|
-
leftMetopes.walls.push(subMeshs[i]);
|
|
9004
|
-
else if (i == 4 || i == 5)
|
|
9005
|
-
rightMetopes.walls.push(subMeshs[i]);
|
|
9006
|
-
else
|
|
9007
|
-
beforeWalls.find("body").walls.push(subMeshs[i]);
|
|
9008
|
-
}
|
|
9009
|
-
}
|
|
9010
|
-
for (const key in beforeWalls.map) {
|
|
9011
|
-
if (beforeWalls.find(key).walls.length > 0) {
|
|
9012
|
-
let _wall = new WallObject_WallObject(this.app);
|
|
9013
|
-
_wall.parentId = this.id;
|
|
9014
|
-
_wall.height = this.height;
|
|
9015
|
-
_wall.bind(beforeWalls.find(key));
|
|
9016
|
-
this.app.project.objectDatas.add(_wall.id, _wall);
|
|
9017
|
-
}
|
|
9018
|
-
}
|
|
9019
|
-
}
|
|
9020
|
-
//清除临时变量
|
|
9021
|
-
walls = null;
|
|
9022
|
-
this.visualAngle = new VisualAngle_VisualAngle(this);
|
|
9023
|
-
}
|
|
9024
|
-
focus() {
|
|
9025
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
9026
|
-
for (const id in this.app.project.objectDatas.map) {
|
|
9027
|
-
let _object = this.app.project.objectDatas.find(id);
|
|
9028
|
-
if (_object.parentId == this.id)
|
|
9029
|
-
_object.setEnabled(_object.isVisible);
|
|
9030
|
-
else
|
|
9031
|
-
_object.setEnabled(false);
|
|
9032
|
-
}
|
|
9033
|
-
this.isEnabled = true;
|
|
9034
|
-
this.app.project.current = this;
|
|
9035
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
9036
|
-
}
|
|
9037
|
-
setEnabled(_value) { }
|
|
9038
|
-
getBounding() {
|
|
9039
|
-
var min, max;
|
|
9040
|
-
for (const _id in this.app.project.objectDatas.map) {
|
|
9041
|
-
let _model = this.app.project.objectDatas.find(_id);
|
|
9042
|
-
if (_model.objectType == ObjectType.ParkModel || _model.objectType == ObjectType.Storey || _model.parentId != this.id)
|
|
9043
|
-
continue;
|
|
9044
|
-
let boundingInfo = _model.instance.getBoundingInfo();
|
|
9045
|
-
if (!min || !max)
|
|
9046
|
-
min = max = boundingInfo.boundingBox.center.clone();
|
|
9047
|
-
min = BABYLON.Vector3.Minimize(min, boundingInfo.minimum.add(_model.instance.position));
|
|
9048
|
-
max = BABYLON.Vector3.Maximize(max, boundingInfo.maximum.add(_model.instance.position));
|
|
9049
|
-
}
|
|
9050
|
-
if (!min || !max) {
|
|
9051
|
-
min = BABYLON.Vector3.Zero();
|
|
9052
|
-
max = new BABYLON.Vector3(12, this.height, 8);
|
|
9053
|
-
}
|
|
9054
|
-
return new BABYLON.BoundingInfo(min, max);
|
|
9055
|
-
}
|
|
9056
|
-
dispose() { }
|
|
9057
|
-
}
|
|
9058
|
-
|
|
9059
|
-
// CONCATENATED MODULE: ./src/lib/VisualAngle.ts
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
class VisualAngle_VisualAngle {
|
|
9065
|
-
constructor(_object) {
|
|
9066
|
-
this.object = _object;
|
|
9067
|
-
//重新计算包围盒
|
|
9068
|
-
if (this.object instanceof Region_Region || this.object instanceof Project_Project) {
|
|
9069
|
-
let bound = this.object.getBounding();
|
|
9070
|
-
let _vis = src.Tools.getVisualAngle(bound, this.object.app);
|
|
9071
|
-
this.alpha = _vis.alpha;
|
|
9072
|
-
this.beta = _vis.beta;
|
|
9073
|
-
this.focus = _vis.focus;
|
|
9074
|
-
this.radius = _vis.radius;
|
|
9075
|
-
if (this.object instanceof Region_Region) {
|
|
9076
|
-
// this.radius = bound.boundingSphere.radiusWorld + 3;
|
|
9077
|
-
this.focus.y = this.object.height;
|
|
9078
|
-
}
|
|
9079
|
-
}
|
|
9080
|
-
else {
|
|
9081
|
-
let bound = this.object.instance.getBoundingInfo();
|
|
9082
|
-
let _vis = src.Tools.getVisualAngle(bound, this.object.app);
|
|
9083
|
-
this.alpha = _vis.alpha;
|
|
9084
|
-
this.beta = _vis.beta;
|
|
9085
|
-
this.focus = _vis.focus;
|
|
9086
|
-
this.radius = _vis.radius;
|
|
9087
|
-
if (!(this.object instanceof ConduitObject_ConduitObject)) {
|
|
9088
|
-
this.focus = this.object.instance.getAbsolutePosition();
|
|
9089
|
-
this.radius = bound.boundingSphere.radiusWorld + 3;
|
|
9090
|
-
}
|
|
9091
|
-
}
|
|
9092
|
-
this.minimumLimit = 0.3;
|
|
9093
|
-
this.maximumLimit = this.radius * 2;
|
|
9094
|
-
this.minBeta = 0.01;
|
|
9095
|
-
this.maxBeta = (Math.PI / 2) * 0.98;
|
|
9096
|
-
}
|
|
9097
|
-
//设置视角参数
|
|
9098
|
-
setVisual(_visual) {
|
|
9099
|
-
let config = JSON.parse(_visual);
|
|
9100
|
-
this.alpha = config.alpha;
|
|
9101
|
-
this.beta = config.beta;
|
|
9102
|
-
this.radius = config.radius;
|
|
9103
|
-
this.focus = src.Tools.ToVector3(config.focus);
|
|
9104
|
-
}
|
|
9105
|
-
//设置缩放范围
|
|
9106
|
-
setLimit(_miniLimit, _maxiLimit) {
|
|
9107
|
-
this.minimumLimit = _miniLimit + 0.3;
|
|
9108
|
-
this.maximumLimit = _maxiLimit;
|
|
9109
|
-
}
|
|
9110
|
-
//设置上下视角限制
|
|
9111
|
-
setBeta(_minBeta, _maxBeta) {
|
|
9112
|
-
this.minBeta = _minBeta;
|
|
9113
|
-
this.maxBeta = _maxBeta;
|
|
9114
|
-
}
|
|
9115
|
-
}
|
|
9116
|
-
|
|
9117
|
-
// CONCATENATED MODULE: ./src/lib/components/Project.ts
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
class Project_Project {
|
|
9122
|
-
constructor(_app) {
|
|
9123
|
-
//场景集合
|
|
9124
|
-
this.objectDatas = new Dictionary();
|
|
9125
|
-
this.app = _app;
|
|
9126
|
-
}
|
|
9127
|
-
delete() {
|
|
9128
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
9129
|
-
for (const _o in this.objectDatas.map) {
|
|
9130
|
-
if (this.objectDatas.find(_o).instance)
|
|
9131
|
-
this.objectDatas.find(_o).instance.dispose();
|
|
9132
|
-
}
|
|
9133
|
-
this.objectDatas.clear();
|
|
9134
|
-
this.current = null;
|
|
9135
|
-
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
9136
|
-
}
|
|
9137
|
-
optimization() {
|
|
9138
|
-
this.visualAngle = new VisualAngle_VisualAngle(this);
|
|
9139
|
-
//冻结活动网格,与自发光合用回导致内存泄露
|
|
9140
|
-
this.app.scene.freezeActiveMeshes();
|
|
9141
|
-
}
|
|
9142
|
-
getChildNodes(_id) {
|
|
9143
|
-
let _objects = new Array();
|
|
9144
|
-
for (const id in this.objectDatas.map) {
|
|
9145
|
-
let _object = this.app.project.objectDatas.find(id);
|
|
9146
|
-
if (_object.parentId == _id && _object.objectType != ObjectType.Wall && _object.objectType != ObjectType.Corner)
|
|
9147
|
-
_objects.push(_object);
|
|
9148
|
-
}
|
|
9149
|
-
return _objects;
|
|
9150
|
-
}
|
|
9151
|
-
getTrees() {
|
|
9152
|
-
const infinite = (id, target) => {
|
|
9153
|
-
for (const _id in this.objectDatas.map) {
|
|
9154
|
-
let _object = this.app.project.objectDatas.find(_id);
|
|
9155
|
-
if (!_object.isMonitor || _object.parentId != id)
|
|
9156
|
-
continue;
|
|
9157
|
-
target.push({ label: _object.name, id: _object.id, type: _object.objectType, children: [] });
|
|
9158
|
-
infinite(_object.id, target[target.length - 1].children);
|
|
9399
|
+
if (!rightMetopes) {
|
|
9400
|
+
rightMetopes = { t: walls[i].rightMap, walls: new Array() };
|
|
9401
|
+
beforeWalls.add(walls[i].rightMap.modelId, rightMetopes);
|
|
9402
|
+
}
|
|
9403
|
+
let subMeshs = src.Tools.DeconsTructMesh(_obejct, parseFloat(walls[i].height), this.app);
|
|
9404
|
+
for (let i = 0; i < subMeshs.length; i++) {
|
|
9405
|
+
// if (i == 3 || i == 7) walfenli[i].dispose();
|
|
9406
|
+
// else
|
|
9407
|
+
if (i == 2 || i == 3)
|
|
9408
|
+
leftMetopes.walls.push(subMeshs[i]);
|
|
9409
|
+
else if (i == 4 || i == 5)
|
|
9410
|
+
rightMetopes.walls.push(subMeshs[i]);
|
|
9411
|
+
else
|
|
9412
|
+
beforeWalls.find("body").walls.push(subMeshs[i]);
|
|
9413
|
+
}
|
|
9414
|
+
}
|
|
9415
|
+
for (const key in beforeWalls.map) {
|
|
9416
|
+
if (beforeWalls.find(key).walls.length > 0) {
|
|
9417
|
+
let _wall = new WallObject_WallObject(this.app);
|
|
9418
|
+
_wall.parentId = this.id;
|
|
9419
|
+
_wall.height = this.height;
|
|
9420
|
+
_wall.bind(beforeWalls.find(key));
|
|
9421
|
+
this.app.project.objectDatas.add(_wall.id, _wall);
|
|
9422
|
+
}
|
|
9159
9423
|
}
|
|
9160
|
-
};
|
|
9161
|
-
let node = { label: this.root.name, id: this.root.id, type: this.root.objectType, children: [] };
|
|
9162
|
-
infinite(this.root.id, node.children);
|
|
9163
|
-
return node;
|
|
9164
|
-
}
|
|
9165
|
-
find(_id) {
|
|
9166
|
-
return this.objectDatas.find(_id);
|
|
9167
|
-
}
|
|
9168
|
-
findFormObjectType(_type, isCurent = true) {
|
|
9169
|
-
let _objects = new Array();
|
|
9170
|
-
for (const id in this.objectDatas.map) {
|
|
9171
|
-
let _object = this.app.project.objectDatas.find(id);
|
|
9172
|
-
if ((isCurent && _object.parentId != this.current.id) || _object.objectType != _type)
|
|
9173
|
-
continue;
|
|
9174
|
-
_objects.push(_object);
|
|
9175
9424
|
}
|
|
9176
|
-
|
|
9425
|
+
//清除临时变量
|
|
9426
|
+
walls = null;
|
|
9427
|
+
this.computeView();
|
|
9428
|
+
}
|
|
9429
|
+
computeView() {
|
|
9430
|
+
this.visualAngle = new VisualAngle_VisualAngle();
|
|
9431
|
+
let bound = this.getBounding();
|
|
9432
|
+
let _vis = src.Tools.getVisualAngle(bound, this.app);
|
|
9433
|
+
this.visualAngle.alpha = _vis.alpha;
|
|
9434
|
+
this.visualAngle.beta = _vis.beta;
|
|
9435
|
+
this.visualAngle.focus = _vis.focus;
|
|
9436
|
+
this.visualAngle.radius = _vis.radius;
|
|
9437
|
+
this.visualAngle.focus.y = this.height;
|
|
9177
9438
|
}
|
|
9178
|
-
|
|
9439
|
+
flyTo() {
|
|
9440
|
+
this.app.camera.flyTo(this.visualAngle, 500);
|
|
9441
|
+
}
|
|
9442
|
+
focus() {
|
|
9179
9443
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = true;
|
|
9180
9444
|
for (const id in this.app.project.objectDatas.map) {
|
|
9181
9445
|
let _object = this.app.project.objectDatas.find(id);
|
|
9182
|
-
_object.
|
|
9446
|
+
if (_object.parentId == this.id)
|
|
9447
|
+
_object.setEnabled(_object.isVisible);
|
|
9448
|
+
else
|
|
9449
|
+
_object.setEnabled(false);
|
|
9183
9450
|
}
|
|
9451
|
+
this.isEnabled = true;
|
|
9452
|
+
this.app.project.current = this;
|
|
9184
9453
|
this.app.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
9185
9454
|
}
|
|
9455
|
+
setEnabled(_value) { }
|
|
9186
9456
|
getBounding() {
|
|
9187
9457
|
var min, max;
|
|
9188
9458
|
for (const _id in this.app.project.objectDatas.map) {
|
|
9189
9459
|
let _model = this.app.project.objectDatas.find(_id);
|
|
9190
|
-
if (_model.objectType == ObjectType.ParkModel || _model.objectType == ObjectType.Storey)
|
|
9460
|
+
if (_model.objectType == ObjectType.ParkModel || _model.objectType == ObjectType.Storey || _model.parentId != this.id)
|
|
9191
9461
|
continue;
|
|
9192
9462
|
let boundingInfo = _model.instance.getBoundingInfo();
|
|
9193
9463
|
if (!min || !max)
|
|
@@ -9197,205 +9467,11 @@ class Project_Project {
|
|
|
9197
9467
|
}
|
|
9198
9468
|
if (!min || !max) {
|
|
9199
9469
|
min = BABYLON.Vector3.Zero();
|
|
9200
|
-
max = new BABYLON.Vector3(12,
|
|
9470
|
+
max = new BABYLON.Vector3(12, this.height, 8);
|
|
9201
9471
|
}
|
|
9202
9472
|
return new BABYLON.BoundingInfo(min, max);
|
|
9203
9473
|
}
|
|
9204
|
-
|
|
9205
|
-
this.app.camera.flyTo(this.visualAngle, 500);
|
|
9206
|
-
}
|
|
9207
|
-
}
|
|
9208
|
-
|
|
9209
|
-
// CONCATENATED MODULE: ./src/lib/Resources.ts
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
class Resources_Resources {
|
|
9214
|
-
constructor(_app) {
|
|
9215
|
-
this.resourcePath = "http://models.wodashijie.com/";
|
|
9216
|
-
this.walls = new Dictionary();
|
|
9217
|
-
//模型资源集合
|
|
9218
|
-
this.resources = new Dictionary();
|
|
9219
|
-
this.ndoeMats = new Dictionary();
|
|
9220
|
-
//资源集合
|
|
9221
|
-
this.Materials = new Dictionary();
|
|
9222
|
-
//贴图集合
|
|
9223
|
-
this.Textures = new Dictionary();
|
|
9224
|
-
this.MergeMaterials = new Dictionary();
|
|
9225
|
-
this.app = _app;
|
|
9226
|
-
let tranId = GUID.getGUID(12);
|
|
9227
|
-
this.transparentBox = BABYLON.MeshBuilder.CreateBox(tranId, { size: 1 }, this.app.scene);
|
|
9228
|
-
this.transparentBox.alwaysSelectAsActiveMesh = true;
|
|
9229
|
-
let boxmat = new BABYLON.StandardMaterial(tranId, this.app.scene);
|
|
9230
|
-
boxmat.diffuseTexture = new BABYLON.Texture(this.app.rootUrl + "resources/white.jpg", this.app.scene, true, false);
|
|
9231
|
-
boxmat.alphaMode = BABYLON.Engine.ALPHA_COMBINE;
|
|
9232
|
-
boxmat.emissiveColor = BABYLON.Color3.Green();
|
|
9233
|
-
this.transparentBox.material = boxmat;
|
|
9234
|
-
this.transparentBox.setEnabled(false);
|
|
9235
|
-
this.transparentBox.visibility = 0.3;
|
|
9236
|
-
let boxId = GUID.getGUID(12);
|
|
9237
|
-
this.BOX = BABYLON.MeshBuilder.CreateBox(boxId, { size: 1 }, this.app.scene);
|
|
9238
|
-
this.BOX.edgesColor = BABYLON.Color4.FromHexString("#4ba3fff2");
|
|
9239
|
-
// this.BOX.registerInstancedBuffer("color", 4);
|
|
9240
|
-
// this.BOX.instancedBuffers.color = new BABYLON.Color4(1, 0, 0, 1);
|
|
9241
|
-
this.BOX.setEnabled(false);
|
|
9242
|
-
this.BOX.visibility = 0;
|
|
9243
|
-
// 加上材质会影响加载时间
|
|
9244
|
-
// let box_mat = new BABYLON.StandardMaterial(boxId, this.app.scene);
|
|
9245
|
-
// box_mat.diffuseColor=BABYLON.Color3.White()
|
|
9246
|
-
// box_mat.alpha = 0;
|
|
9247
|
-
// this.BOX.setEnabled(false);
|
|
9248
|
-
// this.BOX.material = box_mat;
|
|
9249
|
-
// this.BOX.material.freeze();
|
|
9250
|
-
// 粒子雾贴图
|
|
9251
|
-
this.FogTex = new BABYLON.Texture(this.app.rootUrl + "resources/fogtex.png", this.app.scene, true, false);
|
|
9252
|
-
}
|
|
9253
|
-
async loadModelMesh(baseModel) {
|
|
9254
|
-
let _mesh = this.resources.find(baseModel.modelId);
|
|
9255
|
-
if (!_mesh) {
|
|
9256
|
-
try {
|
|
9257
|
-
_mesh = await BABYLON.SceneLoader.LoadAssetContainerAsync(this.resourcePath + "bundle/" + baseModel.modelId + "/", baseModel.modelId + baseModel.extension, this.app.scene);
|
|
9258
|
-
if (_mesh.animationGroups.length > 0)
|
|
9259
|
-
_mesh.animationGroups[0].stop();
|
|
9260
|
-
_mesh.addAllToScene();
|
|
9261
|
-
_mesh.meshes[0].setEnabled(false);
|
|
9262
|
-
_mesh.meshes[0].getChildMeshes().forEach(m => {
|
|
9263
|
-
if (m.metadata && m.metadata.gltf && m.metadata.gltf.extras) {
|
|
9264
|
-
_mesh.isExtras = true;
|
|
9265
|
-
if (m.metadata.gltf.extras.U)
|
|
9266
|
-
BABYLON.Animation.CreateAndStartAnimation("u", m.material.albedoTexture, "uOffset", m.metadata.gltf.extras.Uspeed * 30, 30, 0, 1, 1);
|
|
9267
|
-
if (m.metadata.gltf.extras.V)
|
|
9268
|
-
BABYLON.Animation.CreateAndStartAnimation("v", m.material.albedoTexture, "vOffset", m.metadata.gltf.extras.Vspeed * 30, 30, 0, 1, 1);
|
|
9269
|
-
}
|
|
9270
|
-
});
|
|
9271
|
-
if (baseModel.objectType != ObjectType.OutDoorScene && !_mesh.isExtras) {
|
|
9272
|
-
_mesh.meshes[0].getChildMeshes().forEach(e => {
|
|
9273
|
-
e.registerInstancedBuffer("color", 4);
|
|
9274
|
-
e.instancedBuffers.color = new BABYLON.Color4(1, 1, 1, 1);
|
|
9275
|
-
});
|
|
9276
|
-
}
|
|
9277
|
-
this.resources.add(baseModel.modelId, _mesh);
|
|
9278
|
-
}
|
|
9279
|
-
catch (ex) {
|
|
9280
|
-
console.error("模型下载失败!模型编号:" + baseModel.modelId + ";错误信息:" + ex);
|
|
9281
|
-
}
|
|
9282
|
-
}
|
|
9283
|
-
return _mesh;
|
|
9284
|
-
}
|
|
9285
|
-
loadModelMeshAsync(baseModel, callback) {
|
|
9286
|
-
let _mesh = this.resources.find(baseModel.modelId);
|
|
9287
|
-
if (!_mesh) {
|
|
9288
|
-
BABYLON.SceneLoader.LoadAssetContainerAsync(this.resourcePath + "bundle/" + baseModel.modelId + "/", baseModel.modelId + baseModel.extension, this.app.scene).then((container) => {
|
|
9289
|
-
if (container.animationGroups.length > 0)
|
|
9290
|
-
container.animationGroups[0].stop();
|
|
9291
|
-
// container.meshes[0].getChildMeshes().forEach(e => {
|
|
9292
|
-
// (e as BABYLON.Mesh).registerInstancedBuffer("color", 4);
|
|
9293
|
-
// e.instancedBuffers.color = new BABYLON.Color4(1, 1, 1, 1);
|
|
9294
|
-
// });
|
|
9295
|
-
this.resources.add(baseModel.modelId, container);
|
|
9296
|
-
callback(container);
|
|
9297
|
-
}).catch(() => {
|
|
9298
|
-
console.error("模型下载失败!模型编号:" + baseModel.modelId);
|
|
9299
|
-
});
|
|
9300
|
-
}
|
|
9301
|
-
else
|
|
9302
|
-
callback(_mesh);
|
|
9303
|
-
}
|
|
9304
|
-
GetMaterial(textureData, scene) {
|
|
9305
|
-
let _mat = this.Materials.find(textureData.modelId);
|
|
9306
|
-
if (typeof _mat == "undefined") {
|
|
9307
|
-
let _m = this.GetTexture(textureData, scene);
|
|
9308
|
-
_mat = new BABYLON.StandardMaterial(textureData.modelId, scene);
|
|
9309
|
-
_mat.alphaMode = BABYLON.Engine.ALPHA_COMBINE;
|
|
9310
|
-
_mat.diffuseTexture = _m;
|
|
9311
|
-
this.Materials.add(textureData.modelId, _mat);
|
|
9312
|
-
// if (_m.hasAlpha) {
|
|
9313
|
-
// // _mat.needDepthPrePass = true;
|
|
9314
|
-
// _mat.useAlphaFromDiffuseTexture = true;
|
|
9315
|
-
// }
|
|
9316
|
-
}
|
|
9317
|
-
return _mat;
|
|
9318
|
-
}
|
|
9319
|
-
GetTexture(textureData, scene) {
|
|
9320
|
-
let _Texture = this.Textures.find(textureData.modelId);
|
|
9321
|
-
if (typeof _Texture == "undefined") {
|
|
9322
|
-
_Texture = new BABYLON.Texture(this.resourcePath + "texture/" + textureData.modelId + textureData.extension, scene, false);
|
|
9323
|
-
if (textureData.extension == ".png") {
|
|
9324
|
-
_Texture.hasAlpha = true;
|
|
9325
|
-
}
|
|
9326
|
-
this.Textures.add(textureData.modelId, _Texture);
|
|
9327
|
-
}
|
|
9328
|
-
return _Texture;
|
|
9329
|
-
}
|
|
9330
|
-
GetMergeMaterial(textureData, scene) {
|
|
9331
|
-
let _mat = this.MergeMaterials.find(textureData.modelId);
|
|
9332
|
-
if (typeof _mat == "undefined") {
|
|
9333
|
-
_mat = new BABYLON.CustomMaterial(textureData.modelId, scene);
|
|
9334
|
-
_mat.alphaMode = 2;
|
|
9335
|
-
this.MergeMaterials.add(textureData.modelId, _mat);
|
|
9336
|
-
// _mat.specularPower=64;
|
|
9337
|
-
// _mat.specularColor=BABYLON.Color3.Black();
|
|
9338
|
-
_mat.AddUniform('textureData', 'sampler2D', null);
|
|
9339
|
-
_mat.Vertex_Definitions(`
|
|
9340
|
-
varying vec3 localPos ;
|
|
9341
|
-
varying vec3 localNrm ;
|
|
9342
|
-
`);
|
|
9343
|
-
_mat.Fragment_Definitions(`
|
|
9344
|
-
varying vec3 localPos ;
|
|
9345
|
-
varying vec3 localNrm ;`);
|
|
9346
|
-
_mat.Vertex_Before_PositionUpdated(`
|
|
9347
|
-
localPos = position.xyz;
|
|
9348
|
-
localNrm = normal;
|
|
9349
|
-
`);
|
|
9350
|
-
let tex = this.GetTexture(textureData, scene);
|
|
9351
|
-
if (textureData.extension == ".png") {
|
|
9352
|
-
tex.hasAlpha = true;
|
|
9353
|
-
_mat.alpha = 0.9;
|
|
9354
|
-
// _mat.needDepthPrePass = true;
|
|
9355
|
-
// _mat.useAlphaFromDiffuseTexture = true;
|
|
9356
|
-
}
|
|
9357
|
-
textureData.length = 3.1;
|
|
9358
|
-
console.log(textureData.width);
|
|
9359
|
-
_mat.onBindObservable.add(() => _mat.getEffect().setTexture('textureData', tex));
|
|
9360
|
-
_mat.Fragment_Custom_Diffuse(`
|
|
9361
|
-
vec3 newUV = vec3(abs(localPos.x)/` + textureData.width + `,abs(localPos.y)/` + textureData.length + `,abs(localPos.z)/` + textureData.width + `);
|
|
9362
|
-
if(abs(localNrm.z)>abs(localNrm.x)){
|
|
9363
|
-
vec4 res = texture2D(textureData,newUV.xy);
|
|
9364
|
-
diffuseColor = res.rgb;
|
|
9365
|
-
alpha = res.a;
|
|
9366
|
-
}
|
|
9367
|
-
else {
|
|
9368
|
-
vec4 res = texture2D(textureData,newUV.zy);
|
|
9369
|
-
diffuseColor = res.rgb;
|
|
9370
|
-
alpha = res.a;
|
|
9371
|
-
}
|
|
9372
|
-
`);
|
|
9373
|
-
_mat.freeze();
|
|
9374
|
-
}
|
|
9375
|
-
return _mat;
|
|
9376
|
-
}
|
|
9377
|
-
delete(isAll = false) {
|
|
9378
|
-
this.BOX && this.BOX.dispose();
|
|
9379
|
-
this.transparentBox && this.transparentBox.dispose(true, true);
|
|
9380
|
-
this.BOX = null;
|
|
9381
|
-
this.transparentBox = null;
|
|
9382
|
-
if (isAll) {
|
|
9383
|
-
for (const _id in this.resources.map) {
|
|
9384
|
-
this.resources.find(_id).removeAllFromScene();
|
|
9385
|
-
this.resources.remove(_id);
|
|
9386
|
-
}
|
|
9387
|
-
this.resources.clear();
|
|
9388
|
-
}
|
|
9389
|
-
}
|
|
9390
|
-
async GetWalls(url, projectId) {
|
|
9391
|
-
let walls = await BABYLON.SceneLoader.LoadAssetContainerAsync(url, projectId + ".gltf", this.app.scene);
|
|
9392
|
-
if (walls.meshes) {
|
|
9393
|
-
let _walls = walls.meshes[0].getChildMeshes();
|
|
9394
|
-
for (let i = 0; i < _walls.length; i++) {
|
|
9395
|
-
this.walls.add(_walls[i].id, _walls[i]);
|
|
9396
|
-
}
|
|
9397
|
-
}
|
|
9398
|
-
}
|
|
9474
|
+
dispose() { }
|
|
9399
9475
|
}
|
|
9400
9476
|
|
|
9401
9477
|
// CONCATENATED MODULE: ./src/lib/Optimized/OptimizedRegion.ts
|
|
@@ -9885,6 +9961,7 @@ class App_App {
|
|
|
9885
9961
|
// this.scene.debugLayer.show();
|
|
9886
9962
|
this.scene.blockfreeActiveMeshesAndRenderingGroups = false;
|
|
9887
9963
|
resolve(null);
|
|
9964
|
+
this.engine.resize();
|
|
9888
9965
|
_config.complete && _config.complete();
|
|
9889
9966
|
}
|
|
9890
9967
|
catch (e) {
|
|
@@ -10100,7 +10177,10 @@ class UI_UI {
|
|
|
10100
10177
|
/// <param name="_height">相对于物体高度</param>
|
|
10101
10178
|
/// <param name="_app">场景实例</param>
|
|
10102
10179
|
static createIconFromMesh(_id, _anchor, url, _scaling, _height) {
|
|
10103
|
-
let
|
|
10180
|
+
let view = _anchor.visualAngle.focus.clone();
|
|
10181
|
+
let bound = _anchor.instance.getBoundingInfo();
|
|
10182
|
+
view.y += (bound.boundingBox.maximum.y - bound.boundingBox.minimum.y) / 2;
|
|
10183
|
+
let icon = new external_Dazzle_["IconFromMesh"](_id, view, url, _scaling, _height, _anchor.app.scene);
|
|
10104
10184
|
return icon;
|
|
10105
10185
|
}
|
|
10106
10186
|
/// <summary>
|