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.
2109 lines
83 KiB
2109 lines
83 KiB
|
1 year ago
|
var Glodon$1 = window.Glodon || {};
|
||
|
|
window.Glodon = Glodon$1;
|
||
|
|
|
||
|
|
/******************************************************************************
|
||
|
|
Copyright (c) Microsoft Corporation.
|
||
|
|
|
||
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
||
|
|
purpose with or without fee is hereby granted.
|
||
|
|
|
||
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||
|
|
PERFORMANCE OF THIS SOFTWARE.
|
||
|
|
***************************************************************************** */
|
||
|
|
/* global Reflect, Promise */
|
||
|
|
|
||
|
|
var extendStatics = function(d, b) {
|
||
|
|
extendStatics = Object.setPrototypeOf ||
|
||
|
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||
|
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||
|
|
return extendStatics(d, b);
|
||
|
|
};
|
||
|
|
|
||
|
|
function __extends(d, b) {
|
||
|
|
if (typeof b !== "function" && b !== null)
|
||
|
|
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||
|
|
extendStatics(d, b);
|
||
|
|
function __() { this.constructor = d; }
|
||
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||
|
|
}
|
||
|
|
|
||
|
|
var __assign = function() {
|
||
|
|
__assign = Object.assign || function __assign(t) {
|
||
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||
|
|
s = arguments[i];
|
||
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||
|
|
}
|
||
|
|
return t;
|
||
|
|
};
|
||
|
|
return __assign.apply(this, arguments);
|
||
|
|
};
|
||
|
|
|
||
|
|
/** @deprecated */
|
||
|
|
function __spreadArrays() {
|
||
|
|
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
||
|
|
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
||
|
|
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
||
|
|
r[k] = a[j];
|
||
|
|
return r;
|
||
|
|
}
|
||
|
|
|
||
|
|
// 事件处理基类
|
||
|
|
var EventManager = /** @class */ (function () {
|
||
|
|
function EventManager() {
|
||
|
|
this._eventContainer = {};
|
||
|
|
}
|
||
|
|
// 添加监听事件
|
||
|
|
EventManager.prototype.addEvent = function (type, fn) {
|
||
|
|
this._eventContainer[type] = this._eventContainer[type] || [];
|
||
|
|
this._eventContainer[type].push(fn);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 删除监听事件
|
||
|
|
EventManager.prototype.removeEvent = function (type, fn) {
|
||
|
|
if (this._eventContainer[type]) {
|
||
|
|
var index = this._eventContainer[type].indexOf(fn);
|
||
|
|
index >= 0 && this._eventContainer[type].splice(index, 1);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 触发监听事件
|
||
|
|
EventManager.prototype.fireEvent = function (type) {
|
||
|
|
var args = [];
|
||
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
||
|
|
args[_i - 1] = arguments[_i];
|
||
|
|
}
|
||
|
|
if (type && this._eventContainer[type]) {
|
||
|
|
__spreadArrays(this._eventContainer[type]).forEach(function (fn) {
|
||
|
|
fn.apply(null, args);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// reset
|
||
|
|
EventManager.prototype.reset = function () {
|
||
|
|
this._eventContainer = {};
|
||
|
|
};
|
||
|
|
return EventManager;
|
||
|
|
}());
|
||
|
|
|
||
|
|
// 事件处理类
|
||
|
|
var EventEmmiter = /** @class */ (function (_super) {
|
||
|
|
__extends(EventEmmiter, _super);
|
||
|
|
function EventEmmiter() {
|
||
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||
|
|
_this._onceEvents = {};
|
||
|
|
_this._pausedEvents = {};
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
// 增加监听事件
|
||
|
|
EventEmmiter.prototype.on = function (type, fn) {
|
||
|
|
return this.addEvent(type, fn);
|
||
|
|
};
|
||
|
|
// 删除监听事件
|
||
|
|
EventEmmiter.prototype.off = function (type, fn) {
|
||
|
|
var index;
|
||
|
|
if (this._onceEvents[type]) { // once列表中查找并删除此事件
|
||
|
|
(index = this._onceEvents[type].indexOf(fn)) >= 0 && this._onceEvents[type].splice(index, 1);
|
||
|
|
this._onceEvents[type].length === 0 && delete this._onceEvents[type];
|
||
|
|
}
|
||
|
|
if (this._pausedEvents[type]) { // pause列表中查找并删除此事件
|
||
|
|
(index = this._pausedEvents[type].indexOf(fn)) >= 0 && this._pausedEvents[type].splice(index, 1);
|
||
|
|
this._pausedEvents[type].length === 0 && delete this._pausedEvents[type];
|
||
|
|
}
|
||
|
|
return this.removeEvent(type, fn);
|
||
|
|
};
|
||
|
|
// 触发一类监听事件
|
||
|
|
EventEmmiter.prototype.trigger = function (type) {
|
||
|
|
var _this = this;
|
||
|
|
var args = [];
|
||
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
||
|
|
args[_i - 1] = arguments[_i];
|
||
|
|
}
|
||
|
|
if (!this._eventContainer[type])
|
||
|
|
return this;
|
||
|
|
var originEvents = __spreadArrays(this._eventContainer[type]);
|
||
|
|
if (this._pausedEvents[type]) { // 此类监听事件中存在pause项时,另外记录完整的事件数组,并在现有的数组中删除pause项
|
||
|
|
this._pausedEvents[type].forEach(function (fn) {
|
||
|
|
_this.removeEvent(type, fn);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
this.fireEvent.apply(this, __spreadArrays([type], args));
|
||
|
|
this._eventContainer[type] = originEvents; // 恢复完整的事件数组
|
||
|
|
if (this._onceEvents[type]) { // 单次执行的事件,执行后从数组中删除
|
||
|
|
this._onceEvents[type].forEach(function (fn) {
|
||
|
|
(!_this._pausedEvents[type] || _this._pausedEvents[type].indexOf(fn) < 0) && _this.off(type, fn); // 排除once事件pause状态
|
||
|
|
});
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 增加单次执行的事件
|
||
|
|
EventEmmiter.prototype.once = function (type, fn) {
|
||
|
|
this.on(type, fn);
|
||
|
|
this._onceEvents[type] = this._onceEvents[type] || [];
|
||
|
|
this._onceEvents[type].indexOf(fn) < 0 && this._onceEvents[type].push(fn);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 暂停事件
|
||
|
|
EventEmmiter.prototype.pause = function (type, fn) {
|
||
|
|
this._pausedEvents[type] = this._pausedEvents[type] || [];
|
||
|
|
this._pausedEvents[type].indexOf(fn) < 0 && this._pausedEvents[type].push(fn);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 恢复事件
|
||
|
|
EventEmmiter.prototype.resume = function (type, fn) {
|
||
|
|
if (!this._pausedEvents[type])
|
||
|
|
return this;
|
||
|
|
var index = this._pausedEvents[type].indexOf(fn);
|
||
|
|
index >= 0 && this._pausedEvents[type].splice(index, 1);
|
||
|
|
this._pausedEvents[type].length === 0 && delete this._pausedEvents[type];
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
EventEmmiter.prototype.reset = function () {
|
||
|
|
this._onceEvents = {};
|
||
|
|
this._pausedEvents = {};
|
||
|
|
_super.prototype.reset.call(this);
|
||
|
|
};
|
||
|
|
return EventEmmiter;
|
||
|
|
}(EventManager));
|
||
|
|
|
||
|
|
var InteractionEvent;
|
||
|
|
(function (InteractionEvent) {
|
||
|
|
InteractionEvent["TransformStarted"] = "TransformStarted";
|
||
|
|
InteractionEvent["TransformChanged"] = "TransformChanged";
|
||
|
|
InteractionEvent["TransformFinished"] = "TransformFinished";
|
||
|
|
InteractionEvent["TransformModeChanged"] = "TransformModeChanged";
|
||
|
|
InteractionEvent["DrawFinished"] = "DrawFinished";
|
||
|
|
InteractionEvent["Exit"] = "Exit";
|
||
|
|
InteractionEvent["ExitEdit"] = "ExitEdit";
|
||
|
|
InteractionEvent["EditCompleted"] = "EditCompleted";
|
||
|
|
InteractionEvent["WarningHint"] = "WarningHint";
|
||
|
|
})(InteractionEvent || (InteractionEvent = {}));
|
||
|
|
var InteractionEvent$1 = InteractionEvent;
|
||
|
|
|
||
|
|
// 此对象用于简化处理各类数据,包括判断数据类型、判断属性、及数据的各类其他操作等,待丰富
|
||
|
|
var DataUtil = {
|
||
|
|
// 用于判断数据类型
|
||
|
|
assertType: function (param, typeName) {
|
||
|
|
var assert = function (fullTypeName) { return Object.prototype.toString.call(param) === "[object " + fullTypeName + "]"; };
|
||
|
|
switch (typeName) {
|
||
|
|
case 'obj':
|
||
|
|
case 'Obj':
|
||
|
|
case 'object':
|
||
|
|
case 'Object':
|
||
|
|
return assert('Object');
|
||
|
|
case 'arr':
|
||
|
|
case 'Arr':
|
||
|
|
case 'array':
|
||
|
|
case 'Array':
|
||
|
|
return assert('Array');
|
||
|
|
case 'num':
|
||
|
|
case 'Num':
|
||
|
|
case 'number':
|
||
|
|
case 'Number':
|
||
|
|
return assert('Number');
|
||
|
|
case 'func':
|
||
|
|
case 'Func':
|
||
|
|
case 'function':
|
||
|
|
case 'Function':
|
||
|
|
return assert('Function');
|
||
|
|
case 'str':
|
||
|
|
case 'Str':
|
||
|
|
case 'string':
|
||
|
|
case 'String':
|
||
|
|
return assert('String');
|
||
|
|
default:
|
||
|
|
return assert(typeName);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 判断多个参数是否都是某个数据类型(参数平铺传入,最后一个参数是类型名)
|
||
|
|
assertParamsType: function () {
|
||
|
|
var _this = this;
|
||
|
|
var params = [];
|
||
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||
|
|
params[_i] = arguments[_i];
|
||
|
|
}
|
||
|
|
if (params.length > 1) {
|
||
|
|
var typeName_1 = params.splice(params.length - 1, 1)[0];
|
||
|
|
var result_1 = true;
|
||
|
|
params.every(function (param) {
|
||
|
|
result_1 = _this.assertType(param, typeName_1);
|
||
|
|
return result_1;
|
||
|
|
});
|
||
|
|
return result_1;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 判断对象是否包含某属性
|
||
|
|
hasProperty: function (param, propertyName) {
|
||
|
|
if (this.assertType(param, 'obj')) {
|
||
|
|
return param[propertyName] !== undefined;
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 颜色转换 hex to rgb
|
||
|
|
hexToRgb: function (hex) {
|
||
|
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||
|
|
return result ? {
|
||
|
|
red: parseInt(result[1], 16),
|
||
|
|
green: parseInt(result[2], 16),
|
||
|
|
blue: parseInt(result[3], 16)
|
||
|
|
} : null;
|
||
|
|
},
|
||
|
|
componentToHex: function (c) {
|
||
|
|
var hex = c.toString(16);
|
||
|
|
return hex.length == 1 ? "0" + hex : hex;
|
||
|
|
},
|
||
|
|
// 颜色转换 rgb to hex
|
||
|
|
rgbToHex: function (r, g, b) {
|
||
|
|
return "#" + this.componentToHex(r) + this.componentToHex(g) + this.componentToHex(b);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
var _a, _b, _c, _d;
|
||
|
|
var SDM = (_d = (_c = (_b = (_a = window.Glodon) === null || _a === void 0 ? void 0 : _a.Bimface) === null || _b === void 0 ? void 0 : _b.Data) === null || _c === void 0 ? void 0 : _c.StatisticsDataManager) === null || _d === void 0 ? void 0 : _d.getInstance();
|
||
|
|
|
||
|
|
/*
|
||
|
|
* @namespace Glodon.Bimface.Module.Scene.EditorEvent
|
||
|
|
* @classdesc 常量:Editor的事件
|
||
|
|
*/
|
||
|
|
var EditorEvent;
|
||
|
|
(function (EditorEvent) {
|
||
|
|
EditorEvent["Loaded"] = "Loaded";
|
||
|
|
EditorEvent["ViewChanged"] = "ViewChanged";
|
||
|
|
EditorEvent["ModelAdded"] = "ModelAdded";
|
||
|
|
EditorEvent["ModelRemoved"] = "ModelRemoved";
|
||
|
|
EditorEvent["LayerTreeNodeClicked"] = "LayerTreeNodeClicked";
|
||
|
|
EditorEvent["SceneAdded"] = "SceneAdded";
|
||
|
|
EditorEvent["PropertiesShow"] = "PropertiesShow";
|
||
|
|
EditorEvent["PropertiesHide"] = "PropertiesHide";
|
||
|
|
EditorEvent["HideEffectsPanels"] = "HideEffectsPanels";
|
||
|
|
EditorEvent["EffectsShow"] = "EffectsShow";
|
||
|
|
EditorEvent["EffectsHide"] = "EffectsHide";
|
||
|
|
EditorEvent["EffectFolderShow"] = "EffectFolderShow";
|
||
|
|
EditorEvent["EffectFolderHide"] = "EffectFolderHide";
|
||
|
|
EditorEvent["EffectCrossHairShow"] = "EffectCrossHairShow";
|
||
|
|
EditorEvent["EffectCrossHairHide"] = "EffectCrossHairHide";
|
||
|
|
EditorEvent["EffectPanelShow"] = "EffectPanelShow";
|
||
|
|
EditorEvent["EffectPanelHide"] = "EffectPanelHide";
|
||
|
|
EditorEvent["EffectShow"] = "EffectShow";
|
||
|
|
EditorEvent["EffectHide"] = "EffectHide";
|
||
|
|
EditorEvent["SaveEffect"] = "SaveEffect";
|
||
|
|
EditorEvent["AnchorPointUpdate"] = "AnchorPointUpdate";
|
||
|
|
EditorEvent["AnchorPointDestroy"] = "AnchorPointDestroy";
|
||
|
|
EditorEvent["TempAnchorDestroy"] = "TempAnchorDestroy";
|
||
|
|
EditorEvent["AnchorEffectShow"] = "AnchorEffectShow";
|
||
|
|
EditorEvent["AnchorEffectHide"] = "AnchorEffectHide";
|
||
|
|
EditorEvent["AnchorSizeUpdate"] = "AnchorSizeUpdate";
|
||
|
|
EditorEvent["SaveAnchorEffect"] = "SaveAnchorEffect";
|
||
|
|
EditorEvent["FireEffectShow"] = "FireEffectShow";
|
||
|
|
EditorEvent["FireEffectHide"] = "FireEffectHide";
|
||
|
|
EditorEvent["FireEffectDrawExit"] = "FireEffectDrawExit";
|
||
|
|
EditorEvent["FireEffectDestroy"] = "FireEffectDestroy";
|
||
|
|
EditorEvent["SaveFireEffect"] = "SaveFireEffect";
|
||
|
|
EditorEvent["CurveHide"] = "CurveHide";
|
||
|
|
EditorEvent["CurveInit"] = "CurveInit";
|
||
|
|
EditorEvent["CurveAnimationDestroy"] = "CurveAnimationDestroy";
|
||
|
|
EditorEvent["TempCurveDestroy"] = "TempCurveDestroy";
|
||
|
|
EditorEvent["CurveEffectShow"] = "CurveEffectShow";
|
||
|
|
EditorEvent["CurveEffectHide"] = "CurveEffectHide";
|
||
|
|
EditorEvent["SaveCurveEffect"] = "SaveCurveEffect";
|
||
|
|
EditorEvent["FanScanDrawExit"] = "FanScanDrawExit";
|
||
|
|
EditorEvent["FanScanDestroy"] = "FanScanDestroy";
|
||
|
|
EditorEvent["FanScanShow"] = "FanScanShow";
|
||
|
|
EditorEvent["FanScanHide"] = "FanScanHide";
|
||
|
|
EditorEvent["SaveFanScan"] = "SaveFanScan";
|
||
|
|
EditorEvent["RingScanDrawExit"] = "RingScanDrawExit";
|
||
|
|
EditorEvent["RingScanDestroy"] = "RingScanDestroy";
|
||
|
|
EditorEvent["RingScanShow"] = "RingScanShow";
|
||
|
|
EditorEvent["RingScanHide"] = "RingScanHide";
|
||
|
|
EditorEvent["SaveRingScan"] = "SaveRingScan";
|
||
|
|
EditorEvent["WaterEffectDrawExit"] = "WaterEffectDrawExit";
|
||
|
|
EditorEvent["WaterEffectDestroy"] = "WaterEffectDestroy";
|
||
|
|
EditorEvent["WaterEffectShow"] = "WaterEffectShow";
|
||
|
|
EditorEvent["WaterEffectHide"] = "WaterEffectHide";
|
||
|
|
EditorEvent["SaveWaterEffect"] = "SaveWaterEffect";
|
||
|
|
EditorEvent["MapEffectDestroy"] = "MapEffectDestroy";
|
||
|
|
EditorEvent["MapEffectShow"] = "MapEffectShow";
|
||
|
|
EditorEvent["MapEffectHide"] = "MapEffectHide";
|
||
|
|
EditorEvent["SaveMapEffect"] = "SaveMapEffect";
|
||
|
|
EditorEvent["SkyBoxShow"] = "SkyBoxShow";
|
||
|
|
EditorEvent["SkyBoxHide"] = "SkyBoxHide";
|
||
|
|
EditorEvent["SaveSkyBox"] = "SaveSkyBox";
|
||
|
|
EditorEvent["RainEffectShow"] = "RainEffectShow";
|
||
|
|
EditorEvent["RainEffectHide"] = "RainEffectHide";
|
||
|
|
EditorEvent["SaveRainEffect"] = "SaveRainEffect";
|
||
|
|
EditorEvent["RainEffectDestroy"] = "RainEffectDestroy";
|
||
|
|
EditorEvent["handleStartDrawOrEditEvent"] = "handleStartDrawOrEditEvent";
|
||
|
|
EditorEvent["handleExitDrawOrEditEvent"] = "handleExitDrawOrEditEvent";
|
||
|
|
EditorEvent["LayerTreeNodeSelectionChanged"] = "LayerTreeNodeSelectionChanged";
|
||
|
|
EditorEvent["EffectTreeNodeSelectionChanged"] = "EffectTreeNodeSelectionChanged";
|
||
|
|
EditorEvent["AddResourceByViewToken"] = "AddResourceByViewToken";
|
||
|
|
EditorEvent["AddResourcePanelShow"] = "AddResourcePanelShow";
|
||
|
|
EditorEvent["UpdateResourcePanelShow"] = "UpdateResourcePanelShow";
|
||
|
|
EditorEvent["LayerNameChanged"] = "LayerNameChanged";
|
||
|
|
EditorEvent["EffectNameChanged"] = "EffectNameChanged";
|
||
|
|
EditorEvent["EffectNamePanelChanged"] = "EffectNamePanelChanged";
|
||
|
|
EditorEvent["LayerAdjustmentShow"] = "LayerAdjustmentShow";
|
||
|
|
EditorEvent["LayerAdjustmentHide"] = "LayerAdjustmentHide";
|
||
|
|
EditorEvent["TileLayerSourceChanged"] = "TileLayerSourceChanged";
|
||
|
|
EditorEvent["ModelLayerTransformed"] = "ModelLayerTransformed";
|
||
|
|
EditorEvent["ClearInvalidLayers"] = "ClearInvalidLayers";
|
||
|
|
EditorEvent["PropertiesShowPanel"] = "PropertiesShowPanel";
|
||
|
|
EditorEvent["LayerTreeNodeVisibleChanged"] = "LayerTreeNodeVisibleChanged";
|
||
|
|
EditorEvent["layerEditNotificationShow"] = "layerEditNotificationShow";
|
||
|
|
EditorEvent["layerEditNotificationHide"] = "layerEditNotificationHide";
|
||
|
|
EditorEvent["LayerEditInit"] = "LayerEditInit";
|
||
|
|
EditorEvent["ExitLayerEffectDrawOrEdit"] = "ExitLayerEffectDrawOrEdit";
|
||
|
|
EditorEvent["LayerEditTreeUnselect"] = "LayerEditTreeUnselect";
|
||
|
|
EditorEvent["DrawFlatEffect"] = "DrawFlatEffect";
|
||
|
|
EditorEvent["DrawFlatEffectExit"] = "DrawFlatEffectExit";
|
||
|
|
EditorEvent["EditFlatEffectExit"] = "EditFlatEffectExit";
|
||
|
|
EditorEvent["initFlatEffect"] = "initFlatEffect";
|
||
|
|
EditorEvent["DrawClippingEffect"] = "DrawClippingEffect";
|
||
|
|
EditorEvent["DrawClippingEffectExit"] = "DrawClippingEffectExit";
|
||
|
|
EditorEvent["EditClippingEffectExit"] = "EditClippingEffectExit";
|
||
|
|
EditorEvent["initClippingEffect"] = "initClippingEffect";
|
||
|
|
EditorEvent["LayerEditHideLayer"] = "LayerEditHideLayer";
|
||
|
|
EditorEvent["RestoreLayerVisible"] = "RestoreLayerVisible";
|
||
|
|
EditorEvent["SetDirectoryTreeState"] = "SetDirectoryTreeState";
|
||
|
|
EditorEvent["ExitEditTool"] = "ExitEditTool";
|
||
|
|
EditorEvent["ReinitEditFan"] = "ReinitEditFan";
|
||
|
|
EditorEvent["ReinitEditLine"] = "ReinitEditLine";
|
||
|
|
EditorEvent["ReinitEditRing"] = "ReinitEditRing";
|
||
|
|
EditorEvent["ReinitEditWater"] = "ReinitEditWater";
|
||
|
|
EditorEvent["ReinitEditFlapSurface"] = "ReinitEditFlapSurface";
|
||
|
|
EditorEvent["ReinitEditFlapSurfaceForWall"] = "ReinitEditFlapSurfaceForWall";
|
||
|
|
EditorEvent["ExitEditFlatEffect"] = "ExitEditFlatEffect";
|
||
|
|
EditorEvent["ExitEditWallEffect"] = "ExitEditWallEffect";
|
||
|
|
EditorEvent["ReinitEditClippingSurface"] = "ReinitEditClippingSurface";
|
||
|
|
EditorEvent["ExitEditClippingEffect"] = "ExitEditClippingEffect";
|
||
|
|
})(EditorEvent || (EditorEvent = {}));
|
||
|
|
|
||
|
|
var eventBus = new EventEmmiter();
|
||
|
|
|
||
|
|
// DomElement操作工具类
|
||
|
|
var Dom = /** @class */ (function () {
|
||
|
|
function Dom(element) {
|
||
|
|
this.eventMap = {};
|
||
|
|
this.element = element;
|
||
|
|
}
|
||
|
|
// 创建DomElement对象(使用空的Dom对象初始化时调用)
|
||
|
|
Dom.prototype.createElement = function (param) {
|
||
|
|
var element = document.createElement(param.elementType);
|
||
|
|
var className = param.className;
|
||
|
|
if (className) {
|
||
|
|
DataUtil.assertType(className, 'arr') && (className = className.join(' '));
|
||
|
|
element.className = className;
|
||
|
|
}
|
||
|
|
param.id && (element.id = param.id);
|
||
|
|
var domObject = new Dom(element);
|
||
|
|
if (param.parent) {
|
||
|
|
var parent_1 = param.parent instanceof Dom ? param.parent : new Dom(param.parent);
|
||
|
|
parent_1.append(domObject);
|
||
|
|
}
|
||
|
|
domObject.visible = true;
|
||
|
|
return domObject; // 返回一个新的以DomElement为参数创建的Dom对象以进行后续的链式操作
|
||
|
|
};
|
||
|
|
// 获取HTTPElement对象
|
||
|
|
Dom.prototype.getElement = function () {
|
||
|
|
return this.element;
|
||
|
|
};
|
||
|
|
// 获取父元素HTTPElement对象
|
||
|
|
Dom.prototype.getParent = function () {
|
||
|
|
return this.element.parentElement;
|
||
|
|
};
|
||
|
|
// 末尾附加一个子元素
|
||
|
|
Dom.prototype.append = function (childElement) {
|
||
|
|
this.element.appendChild(childElement.element);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 附加一个子元素到指定位置
|
||
|
|
Dom.prototype.insert = function (childElement, index) {
|
||
|
|
if (index !== undefined && this.element.childNodes.length > index) {
|
||
|
|
this.element.insertBefore(childElement.element, this.element.childNodes[index]);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.append(childElement);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 删除一个子元素
|
||
|
|
Dom.prototype.remove = function (childElement) {
|
||
|
|
this.element.removeChild(childElement.element);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 删除所有子元素
|
||
|
|
Dom.prototype.clear = function () {
|
||
|
|
while (this.element.childNodes.length > 0) {
|
||
|
|
this.element.removeChild(this.element.childNodes[0]);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 替换元素
|
||
|
|
Dom.prototype.replace = function (newElement, oldElement) {
|
||
|
|
this.element.replaceChild(newElement.getElement(), oldElement.getElement());
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 显示对象
|
||
|
|
Dom.prototype.show = function () {
|
||
|
|
if (this.visible)
|
||
|
|
return this;
|
||
|
|
this.element.style.display = this.displayType;
|
||
|
|
this.visible = true;
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 隐藏对象
|
||
|
|
Dom.prototype.hide = function () {
|
||
|
|
if (!this.visible)
|
||
|
|
return this;
|
||
|
|
if (this.element) {
|
||
|
|
this.displayType = this.element.style.display;
|
||
|
|
this.displayType === 'none' && (this.displayType = undefined);
|
||
|
|
this.element.style.display = 'none';
|
||
|
|
this.visible = false;
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 获取可见性
|
||
|
|
Dom.prototype.isVisible = function () {
|
||
|
|
return this.visible;
|
||
|
|
};
|
||
|
|
// 添加dom事件监听
|
||
|
|
Dom.prototype.on = function (eventType, fn, option) {
|
||
|
|
if (option === void 0) { option = null; }
|
||
|
|
this.element.addEventListener(eventType, fn, option);
|
||
|
|
this.eventMap[eventType] = this.eventMap[eventType] || [];
|
||
|
|
this.eventMap[eventType].push(fn);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 删除dom事件监听
|
||
|
|
Dom.prototype.off = function (eventType, fn) {
|
||
|
|
this.element.removeEventListener(eventType, fn);
|
||
|
|
if (this.eventMap[eventType]) {
|
||
|
|
var index = this.eventMap[eventType].indexOf(fn);
|
||
|
|
index >= 0 && this.eventMap[eventType].splice(index, 1);
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 销毁对象
|
||
|
|
Dom.prototype.destroy = function () {
|
||
|
|
var _this = this;
|
||
|
|
var _loop_1 = function (eventType) {
|
||
|
|
this_1.eventMap[eventType].forEach(function (fn) {
|
||
|
|
_this.off(eventType, fn);
|
||
|
|
});
|
||
|
|
};
|
||
|
|
var this_1 = this;
|
||
|
|
for (var eventType in this.eventMap) {
|
||
|
|
_loop_1(eventType);
|
||
|
|
}
|
||
|
|
this.element.parentElement && this.element.parentElement.removeChild(this.element);
|
||
|
|
this.eventMap = undefined;
|
||
|
|
this.displayType = undefined;
|
||
|
|
this.themeType = undefined;
|
||
|
|
this.element = undefined;
|
||
|
|
};
|
||
|
|
Dom.prototype.getClass = function () {
|
||
|
|
return this.getElement().getAttribute('class');
|
||
|
|
};
|
||
|
|
Dom.prototype.hasClass = function (className) {
|
||
|
|
var currentClassName = this.getClass();
|
||
|
|
if (!currentClassName)
|
||
|
|
return false;
|
||
|
|
var arr = currentClassName && currentClassName.split(' ');
|
||
|
|
if (arr.indexOf(className) > -1) {
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// 添加一个或多个css class
|
||
|
|
Dom.prototype.addClass = function () {
|
||
|
|
var _a;
|
||
|
|
var classes = [];
|
||
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||
|
|
classes[_i] = arguments[_i];
|
||
|
|
}
|
||
|
|
(_a = this.element.classList).add.apply(_a, classes);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 删除一个或多个css class
|
||
|
|
Dom.prototype.removeClass = function () {
|
||
|
|
var _a;
|
||
|
|
var classes = [];
|
||
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||
|
|
classes[_i] = arguments[_i];
|
||
|
|
}
|
||
|
|
(_a = this.element.classList).remove.apply(_a, classes);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
Dom.prototype.toggleClass = function (className, enable) {
|
||
|
|
this.getClass(); var hasClassName = this.hasClass(className);
|
||
|
|
if (enable != undefined) {
|
||
|
|
if (enable && !hasClassName) {
|
||
|
|
this.addClass(className);
|
||
|
|
}
|
||
|
|
if (!enable) {
|
||
|
|
this.removeClass(className);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
if (hasClassName) {
|
||
|
|
this.removeClass(className);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.addClass(className);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return !hasClassName;
|
||
|
|
};
|
||
|
|
// toggle一个css class
|
||
|
|
Dom.prototype.toggle = function (classname) {
|
||
|
|
this.element.classList.toggle(classname);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 获取元素当前在页面中的位置
|
||
|
|
Dom.prototype.getPosition = function () {
|
||
|
|
var _a = this.element.getBoundingClientRect(), top = _a.top, left = _a.left, right = _a.right, bottom = _a.bottom;
|
||
|
|
return { top: top, left: left, right: right, bottom: bottom };
|
||
|
|
};
|
||
|
|
// 获取元素的尺寸信息
|
||
|
|
Dom.prototype.getDimensions = function () {
|
||
|
|
var _a = this.element.getBoundingClientRect(), width = _a.width, height = _a.height;
|
||
|
|
return { width: width, height: height };
|
||
|
|
};
|
||
|
|
// 获取元素宽度
|
||
|
|
Dom.prototype.getWidth = function () {
|
||
|
|
var width = this.element.getBoundingClientRect().width;
|
||
|
|
return width;
|
||
|
|
};
|
||
|
|
// 获取元素高度
|
||
|
|
Dom.prototype.getHeight = function () {
|
||
|
|
var height = this.element.getBoundingClientRect().height;
|
||
|
|
return height;
|
||
|
|
};
|
||
|
|
// 获取或设置元素的内容
|
||
|
|
Dom.prototype.html = function (htmlContent) {
|
||
|
|
if (htmlContent != undefined) {
|
||
|
|
this.element.innerHTML = htmlContent;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return this.element.innerHTML;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// 获取单个css属性或设置单个/多个css属性
|
||
|
|
Dom.prototype.css = function (key, value) {
|
||
|
|
if (DataUtil.assertType(key, 'str')) {
|
||
|
|
if (value) {
|
||
|
|
this.element.style[key] = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return this.element.style[key];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (DataUtil.assertType(key, 'obj')) {
|
||
|
|
var cssOptions = key;
|
||
|
|
for (var cssKey in cssOptions) {
|
||
|
|
this.element.style[cssKey] = cssOptions[cssKey];
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// 获取单个attribute属性或设置单个/多个attribute属性
|
||
|
|
Dom.prototype.attribute = function (key, value) {
|
||
|
|
if (DataUtil.assertType(key, 'str')) {
|
||
|
|
if (value != undefined) {
|
||
|
|
this.element[key] = value;
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return this.element[key];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (DataUtil.assertType(key, 'obj')) {
|
||
|
|
var attrOptions = key;
|
||
|
|
for (var attrKey in attrOptions) {
|
||
|
|
this.element[attrKey] = attrOptions[attrKey];
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// 获取或设置元素的主题
|
||
|
|
Dom.prototype.theme = function (themeType) {
|
||
|
|
if (themeType) {
|
||
|
|
this.themeType && this.removeClass(this.themeType);
|
||
|
|
this.themeType = themeType;
|
||
|
|
this.addClass(themeType);
|
||
|
|
return this;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
return this.themeType;
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// 点击组件
|
||
|
|
Dom.prototype.click = function () {
|
||
|
|
this.element.click();
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
return Dom;
|
||
|
|
}());
|
||
|
|
|
||
|
|
var UIEvents;
|
||
|
|
(function (UIEvents) {
|
||
|
|
UIEvents["ValueChanged"] = "ValueChanged";
|
||
|
|
UIEvents["Clicked"] = "Clicked";
|
||
|
|
UIEvents["RightClicked"] = "RightClicked";
|
||
|
|
UIEvents["MouseOver"] = "MouseOver";
|
||
|
|
UIEvents["MouseOut"] = "MouseOut";
|
||
|
|
UIEvents["CheckedChanged"] = "CheckedChanged";
|
||
|
|
UIEvents["SelectionChanged"] = "SelectionChanged";
|
||
|
|
UIEvents["ExpendChanged"] = "ExpendChanged";
|
||
|
|
UIEvents["IsolateChanged"] = "IsolateChanged"; // 是否隔离
|
||
|
|
})(UIEvents || (UIEvents = {}));
|
||
|
|
var UIEvents$1 = UIEvents;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @namespace Glodon.Bimface.Tiles.UI.ControlAnchor
|
||
|
|
* @classdesc 常量:UI锚点(用以进行控件定位)
|
||
|
|
* @description Glodon.Bimface.Tiles.UI.ControlAnchor
|
||
|
|
* @property {String} TopLeft 视图左上角
|
||
|
|
* @property {String} TopCenter 视图中上侧
|
||
|
|
* @property {String} TopRight 视图右上角
|
||
|
|
* @property {String} MiddleLeft 视图左中侧
|
||
|
|
* @property {String} MiddleRight 视图右中侧
|
||
|
|
* @property {String} BottomLeft 视图左下角
|
||
|
|
* @property {String} BottomCenter 视图中下侧
|
||
|
|
* @property {String} BottomRight 视图右下角
|
||
|
|
* @property {String} MiddleCenter 视图中心
|
||
|
|
*/
|
||
|
|
var ControlAnchor;
|
||
|
|
(function (ControlAnchor) {
|
||
|
|
ControlAnchor["TopLeft"] = "TopLeft";
|
||
|
|
ControlAnchor["TopCenter"] = "TopCenter";
|
||
|
|
ControlAnchor["TopRight"] = "TopRight";
|
||
|
|
ControlAnchor["MiddleLeft"] = "MiddleLeft";
|
||
|
|
ControlAnchor["MiddleRight"] = "MiddleRight";
|
||
|
|
ControlAnchor["BottomLeft"] = "BottomLeft";
|
||
|
|
ControlAnchor["BottomCenter"] = "BottomCenter";
|
||
|
|
ControlAnchor["BottomRight"] = "BottomRight";
|
||
|
|
ControlAnchor["MiddleCenter"] = "MiddleCenter";
|
||
|
|
})(ControlAnchor || (ControlAnchor = {}));
|
||
|
|
var ControlAnchor$1 = ControlAnchor;
|
||
|
|
|
||
|
|
// UI组件基类
|
||
|
|
var Control = /** @class */ (function (_super) {
|
||
|
|
__extends(Control, _super);
|
||
|
|
function Control(param) {
|
||
|
|
var _this = _super.call(this) || this;
|
||
|
|
_this._domElement = param.element || new Dom().createElement(param.elementParam);
|
||
|
|
if (param.parent) {
|
||
|
|
var parentElement = param.parent instanceof Control ? param.parent._domElement
|
||
|
|
: param.parent instanceof Dom ? param.parent : new Dom(param.parent);
|
||
|
|
parentElement.append(_this._domElement);
|
||
|
|
param.parent instanceof Control && (_this._parent = param.parent);
|
||
|
|
}
|
||
|
|
_this.id = param.id; // || uuid
|
||
|
|
_this.type = param.type;
|
||
|
|
_this.position = { anchor: 'TopLeft', offset: { x: 0, y: 0 } };
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
//
|
||
|
|
Control.prototype.getParent = function () {
|
||
|
|
return this._parent;
|
||
|
|
};
|
||
|
|
// 设置本对象的父级Control对象
|
||
|
|
Control.prototype.setParent = function (control) {
|
||
|
|
this._parent = control;
|
||
|
|
};
|
||
|
|
// 获取DomElement对象
|
||
|
|
Control.prototype.getDomElement = function () {
|
||
|
|
return this._domElement;
|
||
|
|
};
|
||
|
|
// 设置点击事件
|
||
|
|
Control.prototype.onClick = function (fn) {
|
||
|
|
var _this = this;
|
||
|
|
this._domElement.on('click', function (eventData) {
|
||
|
|
fn(eventData);
|
||
|
|
_this.trigger(UIEvents$1.Clicked, _this);
|
||
|
|
});
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 设置鼠标移入事件
|
||
|
|
Control.prototype.onMouseOver = function (fn) {
|
||
|
|
var _this = this;
|
||
|
|
this._domElement.on('mouseover', function (eventData) {
|
||
|
|
fn(eventData);
|
||
|
|
_this.trigger(UIEvents$1.MouseOver, _this);
|
||
|
|
});
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 设置鼠标移出事件
|
||
|
|
Control.prototype.onMouseOut = function (fn) {
|
||
|
|
var _this = this;
|
||
|
|
this._domElement.on('mouseout', function (eventData) {
|
||
|
|
fn(eventData);
|
||
|
|
_this.trigger(UIEvents$1.MouseOut, _this);
|
||
|
|
});
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 显示
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.show
|
||
|
|
*/
|
||
|
|
Control.prototype.show = function () {
|
||
|
|
this._domElement.show();
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 隐藏
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.hide
|
||
|
|
*/
|
||
|
|
Control.prototype.hide = function () {
|
||
|
|
this._domElement.hide();
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 获取可见性状态
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.isVisible
|
||
|
|
* @returns {Boolean} 可见性状态
|
||
|
|
*/
|
||
|
|
Control.prototype.isVisible = function () {
|
||
|
|
return this._domElement.isVisible();
|
||
|
|
};
|
||
|
|
// 销毁
|
||
|
|
Control.prototype.destroy = function () {
|
||
|
|
this._domElement.destroy();
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 对组件增加CSS样式
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.addClass
|
||
|
|
* @param {String} class CSS类名
|
||
|
|
*/
|
||
|
|
Control.prototype.addClass = function () {
|
||
|
|
var _a;
|
||
|
|
var classes = [];
|
||
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||
|
|
classes[_i] = arguments[_i];
|
||
|
|
}
|
||
|
|
(_a = this._domElement).addClass.apply(_a, classes);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 对组件移除CSS样式
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.removeClass
|
||
|
|
* @param {String} class CSS类名
|
||
|
|
*/
|
||
|
|
Control.prototype.removeClass = function () {
|
||
|
|
var _a;
|
||
|
|
var classes = [];
|
||
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||
|
|
classes[_i] = arguments[_i];
|
||
|
|
}
|
||
|
|
(_a = this._domElement).removeClass.apply(_a, classes);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
// 删除一个或多个css class
|
||
|
|
Control.prototype.toggleClass = function (className) {
|
||
|
|
this._domElement.toggleClass(className);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 设置组件的位置信息
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.setPosition
|
||
|
|
* @param {Object} position 组件的位置信息
|
||
|
|
* @param {Glodon.Bimface.Tiles.UI.ControlAnchor} position.anchor 定位组件位置的锚点
|
||
|
|
* @param {Object} position.offset 基于锚点的偏移值
|
||
|
|
* @param {Number} position.offset.x X方向偏移值,单位为px
|
||
|
|
* @param {Number} position.offset.y Y方向偏移值,单位为px
|
||
|
|
*/
|
||
|
|
Control.prototype.setPosition = function (position) {
|
||
|
|
if (position.anchor && ControlAnchor$1.hasOwnProperty(position.anchor)) {
|
||
|
|
for (var key in ControlAnchor$1) {
|
||
|
|
this.removeClass("bfui-anchor-" + key.toLowerCase());
|
||
|
|
}
|
||
|
|
var anchor = position.anchor.toLowerCase();
|
||
|
|
this.addClass("bfui-anchor-" + anchor);
|
||
|
|
this.position.anchor = position.anchor;
|
||
|
|
}
|
||
|
|
this.setOffset(position.offset);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
Control.prototype.setOffset = function (offset) {
|
||
|
|
if (offset) {
|
||
|
|
var offsetX = offset.x || 0;
|
||
|
|
var offsetY = offset.y || 0;
|
||
|
|
var anchor = this.position.anchor.toLowerCase();
|
||
|
|
this.setStyle(anchor.indexOf('right') >= 0 ? { marginRight: -offsetX + "px" } : { marginLeft: offsetX + "px" })
|
||
|
|
.setStyle(anchor.indexOf('bottom') >= 0 ? { marginBottom: -offsetY + "px" } : { marginTop: offsetY + "px" });
|
||
|
|
this.position.offset.x = offsetX;
|
||
|
|
this.position.offset.y = offsetY;
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
Control.prototype.getPositionParam = function () {
|
||
|
|
return this.position;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 获取ID
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getId
|
||
|
|
* @returns {String} ID
|
||
|
|
*/
|
||
|
|
Control.prototype.getId = function () {
|
||
|
|
return this.id;
|
||
|
|
};
|
||
|
|
// 获取Control类型
|
||
|
|
Control.prototype.getType = function () {
|
||
|
|
return this.type;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 获取组件的位置信息
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getPosition
|
||
|
|
* @returns {Object} 组件的位置信息
|
||
|
|
*/
|
||
|
|
Control.prototype.getPosition = function () {
|
||
|
|
return this._domElement.getPosition();
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 获取组件的尺寸信息
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Control.prototype.getDimensions
|
||
|
|
* @returns {Object} 组件的尺寸信息
|
||
|
|
*/
|
||
|
|
Control.prototype.getDimensions = function () {
|
||
|
|
return this._domElement.getDimensions();
|
||
|
|
};
|
||
|
|
// 获取元素宽度
|
||
|
|
Control.prototype.getWidth = function () {
|
||
|
|
return this._domElement.getWidth();
|
||
|
|
};
|
||
|
|
// 获取元素高度
|
||
|
|
Control.prototype.getHeight = function () {
|
||
|
|
return this._domElement.getHeight();
|
||
|
|
};
|
||
|
|
// 设置css style(传入多个键值对组成的对象参数)
|
||
|
|
Control.prototype.setStyle = function (style) {
|
||
|
|
this._domElement.css(style);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
Control.prototype.getTooltip = function () {
|
||
|
|
return this.tooltip;
|
||
|
|
};
|
||
|
|
Control.prototype.setTooltip = function (tooltip) {
|
||
|
|
this.tooltip = tooltip;
|
||
|
|
this.getDomElement().attribute('title', tooltip);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 通过HTML字符串初始化Control内容,支持在字符串中插入Control对象标记,配合controlMap实现html与Control混合结构的整体初始化
|
||
|
|
* @param {string} html Control的内容html字符串。如需插入Control对象,则在插入的位置写入<Control id="abc"></Control>作为标记,id与controlMap中的key对应
|
||
|
|
* @param {IControlMap} controlMap 通过key、value方式提供需插入html中的各个Control对象,key与html字符串中标记处的id对应
|
||
|
|
*/
|
||
|
|
Control.prototype.setHTML = function (html, controlMap) {
|
||
|
|
var controlReg = /<[C,c]ontrol id="(.*?)".*?>.*?<\/[C,c]ontrol>/g;
|
||
|
|
var computedHtml = html.replace(controlReg, function (value) {
|
||
|
|
var execResult = controlReg.exec(value);
|
||
|
|
controlReg.lastIndex = 0;
|
||
|
|
var id = execResult[1];
|
||
|
|
var replaceHtml = "<div class=\"BFUI_Control_" + id + "\"></div>";
|
||
|
|
return replaceHtml;
|
||
|
|
});
|
||
|
|
var dom = this.getDomElement();
|
||
|
|
dom.html(computedHtml);
|
||
|
|
for (var id in controlMap) {
|
||
|
|
var elements = dom.getElement().getElementsByClassName("BFUI_Control_" + id);
|
||
|
|
if (elements.length === 1) {
|
||
|
|
var element = elements[0];
|
||
|
|
var parent_1 = new Dom(element.parentElement);
|
||
|
|
parent_1.replace(controlMap[id].getDomElement && controlMap[id].getDomElement() || controlMap[id], new Dom(element));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 点击组件
|
||
|
|
*/
|
||
|
|
Control.prototype.click = function () {
|
||
|
|
this.getDomElement().click();
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
return Control;
|
||
|
|
}(EventEmmiter));
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @classdesc 类:Message组件类
|
||
|
|
* @class Glodon.Bimface.Tiles.UI.Message
|
||
|
|
* @constructs Glodon.Bimface.Tiles.UI.Message
|
||
|
|
* @description 构造消息组件
|
||
|
|
* @extends Glodon.Bimface.Tiles.UI.Control
|
||
|
|
* @param {Object} option 构造消息的配置项
|
||
|
|
* @param {String} option.id 消息组件ID
|
||
|
|
* @param {String} option.text 消息的文字内容
|
||
|
|
*/
|
||
|
|
var Message = /** @class */ (function (_super) {
|
||
|
|
__extends(Message, _super);
|
||
|
|
function Message(param) {
|
||
|
|
var _this = this;
|
||
|
|
param = param || {};
|
||
|
|
var elementParam = {
|
||
|
|
elementType: 'div',
|
||
|
|
className: 'bfui-message'
|
||
|
|
};
|
||
|
|
var controlParam = {
|
||
|
|
elementParam: elementParam,
|
||
|
|
type: 'Message',
|
||
|
|
id: param.id,
|
||
|
|
parent: param.parent
|
||
|
|
};
|
||
|
|
_this = _super.call(this, controlParam) || this;
|
||
|
|
param.text && _this.setText(param.text);
|
||
|
|
param.className && _this.addClass(param.className);
|
||
|
|
setTimeout(function () {
|
||
|
|
_this.getDomElement().addClass('hide');
|
||
|
|
_this.getDomElement().on('transitionend', function () { return _this.destroy(); });
|
||
|
|
}, param.duration || 3000);
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 获取文字内容
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Message.prototype.getText
|
||
|
|
* @returns {String} 文字内容
|
||
|
|
*/
|
||
|
|
Message.prototype.getText = function () {
|
||
|
|
return this._domElement.html();
|
||
|
|
};
|
||
|
|
/**
|
||
|
|
* 设置文字内容
|
||
|
|
* @function Glodon.Bimface.Tiles.UI.Message.prototype.setText
|
||
|
|
* @param {String} text 文字内容
|
||
|
|
*/
|
||
|
|
Message.prototype.setText = function (text) {
|
||
|
|
this._domElement.html(text);
|
||
|
|
return this;
|
||
|
|
};
|
||
|
|
return Message;
|
||
|
|
}(Control));
|
||
|
|
|
||
|
|
var SNS = 'bf_interaction.sceneEditor';
|
||
|
|
var CLOUD = window.CLOUD;
|
||
|
|
var Glodon = window.Glodon;
|
||
|
|
// 工具基类
|
||
|
|
var BaseTool = /** @class */ (function (_super) {
|
||
|
|
__extends(BaseTool, _super);
|
||
|
|
function BaseTool(config) {
|
||
|
|
var _this = _super.call(this) || this;
|
||
|
|
_this._destroyed = false;
|
||
|
|
_this.helperEvents = {};
|
||
|
|
var viewer = config.viewer, hasToolbar = config.hasToolbar, controlId = config.controlId, controlType = config.controlType, controlParams = config.controlParams, reinitTriggerName = config.reinitTriggerName, hasCustomIntEvt = config.hasCustomIntEvt;
|
||
|
|
_this.viewer = viewer;
|
||
|
|
_this.controlId = controlId;
|
||
|
|
_this.controlType = controlType;
|
||
|
|
_this.controlParams = controlParams;
|
||
|
|
_this.reinitTriggerName = reinitTriggerName;
|
||
|
|
_this.hasCustomIntEvt = hasCustomIntEvt;
|
||
|
|
_this.initControl();
|
||
|
|
_this.initEvents();
|
||
|
|
hasToolbar !== false && _this.initToolbar();
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
// 初始化三维交互组件
|
||
|
|
BaseTool.prototype.initControl = function () {
|
||
|
|
this.helper = CLOUD.Interaction.InteractionHelper.getInstance(this.viewer.getViewer());
|
||
|
|
this.helper.addControl(this.controlId, this.controlType, this.controlParams);
|
||
|
|
};
|
||
|
|
// 添加交互组件监听
|
||
|
|
BaseTool.prototype.initEvents = function () {
|
||
|
|
var _this = this;
|
||
|
|
this.helperEvents.WarningHint = function (_a) {
|
||
|
|
var id = _a.id, text = _a.text;
|
||
|
|
if ([_this.getControl().translateControlId, _this.getControl().pointTranslateControlId, _this.getControl().controlId].indexOf(id) >= 0) {
|
||
|
|
new Message({
|
||
|
|
parent: _this.viewer.getDomElement(),
|
||
|
|
className: "bfui-effect-warning",
|
||
|
|
text: text,
|
||
|
|
duration: 2000,
|
||
|
|
});
|
||
|
|
}
|
||
|
|
_this.fireEvent(InteractionEvent$1.WarningHint, { id: id, text: text });
|
||
|
|
};
|
||
|
|
for (var key in this.helperEvents) {
|
||
|
|
var listener = this.helperEvents[key];
|
||
|
|
this.helper.addEventListener(key, listener);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
// 初始化工具栏(默认只包含退出按钮)
|
||
|
|
BaseTool.prototype.initToolbar = function () {
|
||
|
|
var _this = this;
|
||
|
|
var modelEditorContainer = document.createElement('div');
|
||
|
|
modelEditorContainer.classList.add('bf-effectToolbar');
|
||
|
|
this.domElement = modelEditorContainer;
|
||
|
|
modelEditorContainer.addEventListener('mousedown', function (event) {
|
||
|
|
event.stopPropagation();
|
||
|
|
return false;
|
||
|
|
});
|
||
|
|
// 退出的toolbar
|
||
|
|
var modelEditorConfig = new Glodon.Bimface.UI.Toolbar.ToolbarConfig();
|
||
|
|
modelEditorConfig.element = modelEditorContainer;
|
||
|
|
modelEditorConfig.className = "bf-toolbar bf-toolbar-effectToolbar switch-btn";
|
||
|
|
var operationToolbar = new Glodon.Bimface.UI.Toolbar.Toolbar(modelEditorConfig);
|
||
|
|
//退出按钮
|
||
|
|
var exitButtonConfig = new Glodon.Bimface.UI.Button.ButtonConfig();
|
||
|
|
exitButtonConfig.className = "bf-button bimface-icon gld-bf-edit-24";
|
||
|
|
exitButtonConfig.title = '点击隐藏编辑控件'; // 后期做国际化处理
|
||
|
|
exitButtonConfig.checkedState = true;
|
||
|
|
var exitButton = new Glodon.Bimface.UI.Button.ToggleButton(exitButtonConfig);
|
||
|
|
exitButton.addEventListener("StateChange", function (isChecked) {
|
||
|
|
if (isChecked) {
|
||
|
|
exitButton.element.title = '点击隐藏编辑控件';
|
||
|
|
SDM.send(SNS, "editorStatusOn");
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
exitButton.element.title = '点击显示编辑控件';
|
||
|
|
SDM.send(SNS, "editorStatusOff");
|
||
|
|
}
|
||
|
|
if (isChecked) {
|
||
|
|
_this.initControl();
|
||
|
|
_this.initEvents();
|
||
|
|
eventBus.trigger(_this.reinitTriggerName);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
// 退出按钮点击时触发Exit事件
|
||
|
|
_this.hasCustomIntEvt ? _this.fireEvent(InteractionEvent$1.ExitEdit) : _this.fireEvent(InteractionEvent$1.Exit);
|
||
|
|
_this.helper.removeControl(_this.controlId);
|
||
|
|
for (var key in _this.helperEvents) {
|
||
|
|
var listener = _this.helperEvents[key];
|
||
|
|
_this.helper.removeEventListener(key, listener);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
_this.toggleOtherButtons(isChecked);
|
||
|
|
});
|
||
|
|
operationToolbar.addControl(exitButton);
|
||
|
|
var toolbarConfig = Glodon.Bimface.UI.Toolbar.ToolbarConfig();
|
||
|
|
toolbarConfig.className = "bf-toolbar bf-toolbar-effectToolbar";
|
||
|
|
toolbarConfig.element = modelEditorContainer;
|
||
|
|
toolbarConfig.buttons = ['ModelEditingTranslate'];
|
||
|
|
this.toolbar = new Glodon.Bimface.Application.UI.Toolbar.Toolbar(toolbarConfig);
|
||
|
|
// 初始化按钮状态
|
||
|
|
var toggleButtons = this.toolbar.getControls();
|
||
|
|
var controlEvent = Glodon.Bimface.UI.Control.ControlEvent;
|
||
|
|
var _loop_1 = function (i) {
|
||
|
|
var toggleButton = toggleButtons[i];
|
||
|
|
toggleButton.setCheckedState(true);
|
||
|
|
toggleButton.addEventListener(controlEvent.Click, function () {
|
||
|
|
toggleButton.setCheckedState(true);
|
||
|
|
});
|
||
|
|
};
|
||
|
|
for (var i = 0; i < toggleButtons.length; i++) {
|
||
|
|
_loop_1(i);
|
||
|
|
}
|
||
|
|
var domElement = this.viewer.getDomElement();
|
||
|
|
domElement.appendChild(modelEditorContainer);
|
||
|
|
};
|
||
|
|
// 获取三维交互组件对象
|
||
|
|
BaseTool.prototype.getControl = function () {
|
||
|
|
return this.helper.getControl(this.controlId);
|
||
|
|
};
|
||
|
|
// 添加本工具的监听
|
||
|
|
BaseTool.prototype.addEventListener = function (type, event) {
|
||
|
|
this.addEvent(type, event);
|
||
|
|
};
|
||
|
|
// 移除本工具的监听
|
||
|
|
BaseTool.prototype.removeEventListener = function (type, event) {
|
||
|
|
this.removeEvent(type, event);
|
||
|
|
};
|
||
|
|
// 退出工具
|
||
|
|
BaseTool.prototype.exit = function () {
|
||
|
|
this.destroy();
|
||
|
|
};
|
||
|
|
// 销毁工具
|
||
|
|
BaseTool.prototype.destroy = function () {
|
||
|
|
if (this._destroyed) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this._destroyed = true;
|
||
|
|
for (var key in this.helperEvents) {
|
||
|
|
var listener = this.helperEvents[key];
|
||
|
|
this.helper.removeEventListener(key, listener);
|
||
|
|
}
|
||
|
|
if (this.domElement) {
|
||
|
|
this.domElement.remove();
|
||
|
|
this.domElement = null;
|
||
|
|
}
|
||
|
|
this.viewer = null;
|
||
|
|
this.helper.removeControl(this.controlId);
|
||
|
|
};
|
||
|
|
// 显示/隐藏其它按钮
|
||
|
|
BaseTool.prototype.toggleOtherButtons = function (isChecked) {
|
||
|
|
var btns = this.toolbar.getControls();
|
||
|
|
var btn;
|
||
|
|
if (btns.length) {
|
||
|
|
btn = btns[0];
|
||
|
|
if (isChecked) {
|
||
|
|
btn.element.parentElement.style.display = 'flex';
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
btn.element.parentElement.style.display = 'none';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for (var i = 0; i < btns.length; i++) {
|
||
|
|
btn = btns[i];
|
||
|
|
if (isChecked) {
|
||
|
|
if (i === 0) {
|
||
|
|
btn.setCheckedState(true);
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
btn.setCheckedState(false);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
return BaseTool;
|
||
|
|
}(EventEmmiter));
|
||
|
|
|
||
|
|
var DrawRectangleTool = /** @class */ (function (_super) {
|
||
|
|
__extends(DrawRectangleTool, _super);
|
||
|
|
function DrawRectangleTool(config) {
|
||
|
|
var _this = this;
|
||
|
|
config.controlId = "DrawRectangleTool_" + Glodon$1.Web.Lang.Utility.UUID.createUUID();
|
||
|
|
config.controlType = "DrawRectangleControl";
|
||
|
|
config.hasToolbar = false;
|
||
|
|
config.elevation = config.elevation;
|
||
|
|
config.controlParams = {
|
||
|
|
elevation: config.elevation,
|
||
|
|
viewer: config.viewer,
|
||
|
|
enableAxisGrids: config.enableAxisGrids,
|
||
|
|
};
|
||
|
|
_this = _super.call(this, config) || this;
|
||
|
|
_this._config = config;
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
DrawRectangleTool.prototype.initEvents = function () {
|
||
|
|
var _this = this;
|
||
|
|
this.helperEvents = {
|
||
|
|
DrawFinished: function (_a) {
|
||
|
|
var id = _a.id;
|
||
|
|
if (id === _this.controlId) {
|
||
|
|
var points = _this.getData();
|
||
|
|
_this.fireEvent(InteractionEvent$1.DrawFinished, { ringData: points });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
_super.prototype.initEvents.call(this);
|
||
|
|
};
|
||
|
|
DrawRectangleTool.prototype.getData = function () {
|
||
|
|
var data = this.getControl().getPoints();
|
||
|
|
if (!data)
|
||
|
|
return null;
|
||
|
|
return [data[1], data[3], data[4], data[5]];
|
||
|
|
};
|
||
|
|
return DrawRectangleTool;
|
||
|
|
}(BaseTool));
|
||
|
|
|
||
|
|
var DrawPolyLineTool = /** @class */ (function (_super) {
|
||
|
|
__extends(DrawPolyLineTool, _super);
|
||
|
|
function DrawPolyLineTool(config) {
|
||
|
|
var _this = this;
|
||
|
|
config.controlId = "DrawPolyLineTool_" + Glodon$1.Web.Lang.Utility.UUID.createUUID();
|
||
|
|
config.controlType = "DrawPolyLineControl";
|
||
|
|
config.hasToolbar = false;
|
||
|
|
config.elevation = config.elevation;
|
||
|
|
config.controlParams = {
|
||
|
|
elevation: config.elevation,
|
||
|
|
viewer: config.viewer,
|
||
|
|
enableAxisGrids: config.enableAxisGrids,
|
||
|
|
};
|
||
|
|
_this = _super.call(this, config) || this;
|
||
|
|
_this._config = config;
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
DrawPolyLineTool.prototype.initEvents = function () {
|
||
|
|
var _this = this;
|
||
|
|
this.helperEvents = {
|
||
|
|
DrawFinished: function (_a) {
|
||
|
|
var id = _a.id;
|
||
|
|
if (id === _this.controlId) {
|
||
|
|
_this.fireEvent(InteractionEvent$1.DrawFinished, { ringData: _this.getData() });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
};
|
||
|
|
_super.prototype.initEvents.call(this);
|
||
|
|
};
|
||
|
|
DrawPolyLineTool.prototype.getData = function () {
|
||
|
|
var res = [];
|
||
|
|
var data;
|
||
|
|
if (!this.editPolygon) {
|
||
|
|
data = this.getControl().getPoints();
|
||
|
|
if (!data)
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
data = this.editPolygon.getPointsData();
|
||
|
|
}
|
||
|
|
// remove duplicate object data from data
|
||
|
|
for (var i = 0; i < data.length; i++) {
|
||
|
|
var item = data[i];
|
||
|
|
var isExist = false;
|
||
|
|
for (var j = 0; j < res.length; j++) {
|
||
|
|
var resItem = res[j];
|
||
|
|
if (item.x === resItem.x && item.y === resItem.y && item.z === resItem.z) {
|
||
|
|
isExist = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!isExist) {
|
||
|
|
res.push(item);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return res;
|
||
|
|
};
|
||
|
|
return DrawPolyLineTool;
|
||
|
|
}(BaseTool));
|
||
|
|
|
||
|
|
// 编辑贴地裁切面的工具
|
||
|
|
var EditClipSurfaceTool = /** @class */ (function (_super) {
|
||
|
|
__extends(EditClipSurfaceTool, _super);
|
||
|
|
function EditClipSurfaceTool(config) {
|
||
|
|
var _this = this;
|
||
|
|
config.controlId = 'EditClipSurfaceTool_' + Glodon$1.Web.Lang.Utility.UUID.createUUID();
|
||
|
|
config.controlType = 'SurfaceControl';
|
||
|
|
config.reinitTriggerName = 'ReinitEditClippingSurface';
|
||
|
|
config.hasCustomIntEvt = true;
|
||
|
|
config.controlParams = {
|
||
|
|
points: config.points,
|
||
|
|
layerInfo: config.layerInfo,
|
||
|
|
hidePlane: config.hidePlane,
|
||
|
|
color: config.color,
|
||
|
|
showEdge: config.showEdge,
|
||
|
|
};
|
||
|
|
_this = _super.call(this, config) || this;
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
// 编辑工具包含TransformFinished事件
|
||
|
|
EditClipSurfaceTool.prototype.initEvents = function () {
|
||
|
|
var _this = this;
|
||
|
|
this.helperEvents = {
|
||
|
|
TransformFinished: function (_a) {
|
||
|
|
var id = _a.id;
|
||
|
|
if ([_this.getControl().pointTranslateControlId].indexOf(id) >= 0) {
|
||
|
|
_this.fireEvent(InteractionEvent$1.TransformFinished);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
TransformChanged: function (_a) {
|
||
|
|
var id = _a.id;
|
||
|
|
if ([_this.getControl().pointTranslateControlId].indexOf(id) >= 0) {
|
||
|
|
_this.fireEvent(InteractionEvent$1.TransformChanged);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
EditCompleted: function (_a) {
|
||
|
|
var id = _a.id;
|
||
|
|
if ([_this.getControl().controlId].indexOf(id) >= 0) {
|
||
|
|
_this.fireEvent(InteractionEvent$1.EditCompleted);
|
||
|
|
}
|
||
|
|
},
|
||
|
|
};
|
||
|
|
_super.prototype.initEvents.call(this);
|
||
|
|
};
|
||
|
|
// 获取面的控制点信息
|
||
|
|
EditClipSurfaceTool.prototype.getPointsData = function () {
|
||
|
|
return this.getControl().getPointsData();
|
||
|
|
};
|
||
|
|
// 根据传入的Points更新组件
|
||
|
|
EditClipSurfaceTool.prototype.setPoints = function (points) {
|
||
|
|
this.getControl().setPoints(points);
|
||
|
|
};
|
||
|
|
return EditClipSurfaceTool;
|
||
|
|
}(BaseTool));
|
||
|
|
|
||
|
|
var DrawableItem = /** @class */ (function () {
|
||
|
|
function DrawableItem() {
|
||
|
|
this.xmlns = "http://www.w3.org/2000/svg";
|
||
|
|
this.material = null;
|
||
|
|
this.svgNode = null;
|
||
|
|
this.children = [];
|
||
|
|
this.glodonColor = '#11DAB7';
|
||
|
|
this.position = new THREE.Vector2();
|
||
|
|
}
|
||
|
|
DrawableItem.prototype.add = function (item) {
|
||
|
|
this.children.push(item);
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.getSvgNode = function () {
|
||
|
|
return this.svgNode;
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.abtainRenderables = function (container) {
|
||
|
|
container.appendChild(this.svgNode);
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.isMatch = function (name) {
|
||
|
|
return this.name == name;
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.highlight = function () {
|
||
|
|
this.svgNode.setAttribute('style', 'stroke:' + this.glodonColor);
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.cancelHighlight = function () {
|
||
|
|
this.svgNode.setAttribute('style', 'stroke:' + this.material.color.getStyle());
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.locate = function (posX, posY) {
|
||
|
|
this.position.set(posX, posY);
|
||
|
|
this.move(0, 0);
|
||
|
|
};
|
||
|
|
DrawableItem.prototype.move = function (deltaX, deltaY) {
|
||
|
|
var offsetX = this.position.x + deltaX;
|
||
|
|
var offsetY = this.position.y + deltaY;
|
||
|
|
this.svgNode.setAttribute("transform", "translate(" + offsetX + "," + offsetY + ")");
|
||
|
|
};
|
||
|
|
return DrawableItem;
|
||
|
|
}());
|
||
|
|
|
||
|
|
var EditorName;
|
||
|
|
(function (EditorName) {
|
||
|
|
EditorName["Default"] = "Editor";
|
||
|
|
EditorName["PICK_Editor"] = "Pick";
|
||
|
|
EditorName["RECTPICK_Editor"] = "RectPick";
|
||
|
|
EditorName["PAN_Editor"] = "Pan";
|
||
|
|
EditorName["Zoom_Editor"] = "Zoom";
|
||
|
|
})(EditorName || (EditorName = {}));
|
||
|
|
var Editor = /** @class */ (function () {
|
||
|
|
function Editor() {
|
||
|
|
this.bIsMouseDown = false;
|
||
|
|
this.name = EditorName.Default;
|
||
|
|
}
|
||
|
|
Editor.prototype.onMouseDown = function (event) {
|
||
|
|
};
|
||
|
|
Editor.prototype.onMouseMove = function (event) {
|
||
|
|
};
|
||
|
|
Editor.prototype.onMouseUp = function (event) {
|
||
|
|
};
|
||
|
|
Editor.prototype.onMouseWheel = function (event) {
|
||
|
|
};
|
||
|
|
Editor.prototype.getName = function () {
|
||
|
|
return this.name;
|
||
|
|
};
|
||
|
|
return Editor;
|
||
|
|
}());
|
||
|
|
|
||
|
|
var EventType;
|
||
|
|
(function (EventType) {
|
||
|
|
EventType[EventType["RECTPICK_MOUSE_DOWN"] = 1000] = "RECTPICK_MOUSE_DOWN";
|
||
|
|
EventType[EventType["RECTPICK_MOUSE_MOVE"] = 1001] = "RECTPICK_MOUSE_MOVE";
|
||
|
|
EventType[EventType["RECTPICK_MOUSE_UP"] = 1002] = "RECTPICK_MOUSE_UP";
|
||
|
|
EventType[EventType["PICK_MOUSE_DOWN"] = 2000] = "PICK_MOUSE_DOWN";
|
||
|
|
EventType[EventType["PICK_MOUSE_MOVE"] = 2001] = "PICK_MOUSE_MOVE";
|
||
|
|
EventType[EventType["PICK_MOUSE_UP"] = 2002] = "PICK_MOUSE_UP";
|
||
|
|
EventType[EventType["Floor_Plane_Changed"] = 3000] = "Floor_Plane_Changed";
|
||
|
|
EventType[EventType["Floor_Plane_Changed_For_Panel"] = 3001] = "Floor_Plane_Changed_For_Panel";
|
||
|
|
EventType[EventType["Resize"] = 4000] = "Resize";
|
||
|
|
EventType[EventType["Camera_Height_Changed"] = 5000] = "Camera_Height_Changed";
|
||
|
|
EventType[EventType["ZOOM_MOUSE_WHEEL"] = 6000] = "ZOOM_MOUSE_WHEEL";
|
||
|
|
EventType[EventType["PAN_MOUSE_MOVE"] = 7000] = "PAN_MOUSE_MOVE";
|
||
|
|
// 小地图框选
|
||
|
|
EventType[EventType["Minimap_Rect_Changed"] = 8000] = "Minimap_Rect_Changed";
|
||
|
|
EventType[EventType["Minimap_Rect_Destroyed"] = 8001] = "Minimap_Rect_Destroyed";
|
||
|
|
})(EventType || (EventType = {}));
|
||
|
|
var MouseEventType;
|
||
|
|
(function (MouseEventType) {
|
||
|
|
MouseEventType[MouseEventType["Left"] = 0] = "Left";
|
||
|
|
MouseEventType[MouseEventType["Middle"] = 1] = "Middle";
|
||
|
|
MouseEventType[MouseEventType["Right"] = 2] = "Right";
|
||
|
|
})(MouseEventType || (MouseEventType = {}));
|
||
|
|
|
||
|
|
var VFSizeMode;
|
||
|
|
(function (VFSizeMode) {
|
||
|
|
VFSizeMode["Min"] = "Min";
|
||
|
|
VFSizeMode["Max"] = "Max";
|
||
|
|
})(VFSizeMode || (VFSizeMode = {}));
|
||
|
|
//按鼠标进行缩放
|
||
|
|
var ZoomEditor = /** @class */ (function (_super) {
|
||
|
|
__extends(ZoomEditor, _super);
|
||
|
|
function ZoomEditor(vfViewer, eventManager) {
|
||
|
|
var _this = _super.call(this) || this;
|
||
|
|
_this.totalZoomFactors = [];
|
||
|
|
_this.zoomFactors = [];
|
||
|
|
_this.lastZoomFactor = 1;
|
||
|
|
_this.currentIdx = 0;
|
||
|
|
_this.name = EditorName.Zoom_Editor;
|
||
|
|
_this.eventManager = eventManager;
|
||
|
|
_this.vfData = vfViewer.getData();
|
||
|
|
_this.vfViewer = vfViewer;
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
ZoomEditor.prototype.onMouseWheel = function (event) {
|
||
|
|
var deltaY = event.deltaY || -event.wheelDelta || event.detail;
|
||
|
|
var bIsZoomIn = (deltaY < 0) ? true : false;
|
||
|
|
var multiplyZoomFactor = -1;
|
||
|
|
if (bIsZoomIn) {
|
||
|
|
if (this.currentIdx < this.zoomFactors.length - 1) {
|
||
|
|
this.currentIdx++;
|
||
|
|
multiplyZoomFactor = this.zoomFactors[this.currentIdx];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
if (this.currentIdx > 0) {
|
||
|
|
this.currentIdx--;
|
||
|
|
multiplyZoomFactor = this.zoomFactors[this.currentIdx];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (multiplyZoomFactor < 0 || this.lastZoomFactor == multiplyZoomFactor) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.lastZoomFactor = multiplyZoomFactor;
|
||
|
|
if (multiplyZoomFactor == 1) {
|
||
|
|
PanEditor.clear();
|
||
|
|
}
|
||
|
|
var originPanelSize = this.vfData.getOriginSize();
|
||
|
|
var mouseWheelOffset = new THREE.Vector2(event.offsetX - originPanelSize[0] / 2, event.offsetY - originPanelSize[1] / 2);
|
||
|
|
var curZoomFactor = this.zoomFactors[this.currentIdx];
|
||
|
|
var panDeltaX = 0, panDeltaY = 0;
|
||
|
|
// zoom in
|
||
|
|
if (bIsZoomIn) {
|
||
|
|
var lastZoomFactor = this.zoomFactors[this.currentIdx - 1];
|
||
|
|
var multiplier = curZoomFactor / lastZoomFactor;
|
||
|
|
var currentZoomOffset = [];
|
||
|
|
var restoreZoomOffset = this.vfData.getCorner('Virtual', 'LB');
|
||
|
|
restoreZoomOffset[0] -= mouseWheelOffset.x;
|
||
|
|
restoreZoomOffset[1] -= mouseWheelOffset.y;
|
||
|
|
currentZoomOffset.push(restoreZoomOffset[0] * multiplier + mouseWheelOffset.x);
|
||
|
|
currentZoomOffset.push(restoreZoomOffset[1] * multiplier + mouseWheelOffset.y);
|
||
|
|
this.vfData.setZoomFactor(curZoomFactor);
|
||
|
|
var panelCornerLB = this.vfData.getCorner('Virtual', 'LB');
|
||
|
|
this.vfData.setZoomFactor(lastZoomFactor);
|
||
|
|
panDeltaX = currentZoomOffset[0] - panelCornerLB[0];
|
||
|
|
panDeltaY = currentZoomOffset[1] - panelCornerLB[1];
|
||
|
|
}
|
||
|
|
// zoom out , need bounds checking
|
||
|
|
else {
|
||
|
|
var lastZoomFactor = this.zoomFactors[this.currentIdx + 1];
|
||
|
|
var additionOffset = this.boundsChecking(curZoomFactor, lastZoomFactor, mouseWheelOffset);
|
||
|
|
panDeltaX = additionOffset[0];
|
||
|
|
panDeltaY += additionOffset[1];
|
||
|
|
}
|
||
|
|
PanEditor.panOffsetX += panDeltaX;
|
||
|
|
PanEditor.panOffsetY += panDeltaY;
|
||
|
|
PanEditor.panOffsetXForCamera += panDeltaX;
|
||
|
|
PanEditor.panOffsetYForCamera += panDeltaY;
|
||
|
|
this.vfData.setZoomFactor(multiplyZoomFactor);
|
||
|
|
this.vfViewer.destroy();
|
||
|
|
this.vfData.destroy();
|
||
|
|
this.vfData.build();
|
||
|
|
this.vfViewer.update();
|
||
|
|
this.vfData.updateMovement();
|
||
|
|
this.updateZoomAndPan();
|
||
|
|
this.eventManager.dispatchEvent({
|
||
|
|
type: EventType.ZOOM_MOUSE_WHEEL,
|
||
|
|
data: {
|
||
|
|
offsetX: PanEditor.panOffsetX,
|
||
|
|
offsetY: PanEditor.panOffsetY,
|
||
|
|
zoomFactor: multiplyZoomFactor,
|
||
|
|
}
|
||
|
|
});
|
||
|
|
};
|
||
|
|
//checking when zoom out
|
||
|
|
ZoomEditor.prototype.boundsChecking = function (curZoomFactor, lastZoomFactor, mouseWheelOffset) {
|
||
|
|
var multiplier = curZoomFactor / lastZoomFactor;
|
||
|
|
var cornerLB = this.vfData.getCorner('Virtual', 'LB');
|
||
|
|
var cornerLT = this.vfData.getCorner('Virtual', 'LT');
|
||
|
|
var cornerRT = this.vfData.getCorner('Virtual', 'RT');
|
||
|
|
var cornerRB = this.vfData.getCorner('Virtual', 'RB');
|
||
|
|
var additionOffset = [0, 0];
|
||
|
|
var offsetX = (cornerLB[0] - mouseWheelOffset.x) * multiplier + mouseWheelOffset.x, offsetY = (cornerLB[1] - mouseWheelOffset.y) * multiplier + mouseWheelOffset.y;
|
||
|
|
this.vfData.setZoomFactor(curZoomFactor);
|
||
|
|
var panelCornerLB = this.vfData.getCorner('Virtual', 'LB');
|
||
|
|
this.vfData.setZoomFactor(lastZoomFactor);
|
||
|
|
additionOffset[0] = (offsetX - panelCornerLB[0]);
|
||
|
|
additionOffset[1] = (offsetY - panelCornerLB[1]);
|
||
|
|
var xCounts = 0, yCounts = 0;
|
||
|
|
//corner left bottom
|
||
|
|
var originCornerLB = this.vfData.getCorner('Origin', 'LB');
|
||
|
|
if (offsetX > originCornerLB[0]) {
|
||
|
|
additionOffset[0] += (originCornerLB[0] - offsetX);
|
||
|
|
xCounts++;
|
||
|
|
}
|
||
|
|
if (offsetY < originCornerLB[1]) {
|
||
|
|
additionOffset[1] += (originCornerLB[1] - offsetY);
|
||
|
|
yCounts++;
|
||
|
|
}
|
||
|
|
//corner left top
|
||
|
|
offsetX = (cornerLT[0] - mouseWheelOffset.x) * multiplier + mouseWheelOffset.x;
|
||
|
|
offsetY = (cornerLT[1] - mouseWheelOffset.y) * multiplier + mouseWheelOffset.y;
|
||
|
|
var originCornerLT = this.vfData.getCorner('Origin', 'LT');
|
||
|
|
if (offsetX > originCornerLT[0]) {
|
||
|
|
if (xCounts == 0) {
|
||
|
|
additionOffset[0] += (originCornerLT[0] - offsetX);
|
||
|
|
xCounts++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (offsetY > originCornerLT[1]) {
|
||
|
|
if (yCounts == 0) {
|
||
|
|
additionOffset[1] += (originCornerLT[1] - offsetY);
|
||
|
|
yCounts++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//corner right top
|
||
|
|
offsetX = (cornerRT[0] - mouseWheelOffset.x) * multiplier + mouseWheelOffset.x;
|
||
|
|
offsetY = (cornerRT[1] - mouseWheelOffset.y) * multiplier + mouseWheelOffset.y;
|
||
|
|
var originCornerRT = this.vfData.getCorner('Origin', 'RT');
|
||
|
|
if (offsetX < originCornerRT[0]) {
|
||
|
|
if (xCounts == 0) {
|
||
|
|
additionOffset[0] += (originCornerRT[0] - offsetX);
|
||
|
|
xCounts++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (offsetY > originCornerRT[1]) {
|
||
|
|
if (yCounts == 0) {
|
||
|
|
additionOffset[1] += (originCornerRT[1] - offsetY);
|
||
|
|
yCounts++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//corner right bottom
|
||
|
|
offsetX = (cornerRB[0] - mouseWheelOffset.x) * multiplier + mouseWheelOffset.x;
|
||
|
|
offsetY = (cornerRB[1] - mouseWheelOffset.y) * multiplier + mouseWheelOffset.y;
|
||
|
|
var origincornerRB = this.vfData.getCorner('Origin', 'RB');
|
||
|
|
if (offsetX < origincornerRB[0]) {
|
||
|
|
if (xCounts == 0) {
|
||
|
|
additionOffset[0] += (origincornerRB[0] - offsetX);
|
||
|
|
xCounts++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (offsetY < origincornerRB[1]) {
|
||
|
|
if (yCounts == 0) {
|
||
|
|
additionOffset[1] += (origincornerRB[1] - offsetY);
|
||
|
|
yCounts++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return additionOffset;
|
||
|
|
};
|
||
|
|
ZoomEditor.prototype.enableMode = function (mode) {
|
||
|
|
if (mode == VFSizeMode.Min) {
|
||
|
|
this.zoomFactors = this.totalZoomFactors;
|
||
|
|
}
|
||
|
|
else if (mode == VFSizeMode.Max) {
|
||
|
|
this.zoomFactors = this.totalZoomFactors.slice(1, this.totalZoomFactors.length);
|
||
|
|
for (var i = 1; i < this.zoomFactors.length; i++) {
|
||
|
|
this.zoomFactors[i] /= this.zoomFactors[0];
|
||
|
|
}
|
||
|
|
this.zoomFactors[0] = 1;
|
||
|
|
}
|
||
|
|
this.currentIdx = 0;
|
||
|
|
};
|
||
|
|
ZoomEditor.prototype.setZoomFactors = function (zoomFactors) {
|
||
|
|
this.totalZoomFactors = zoomFactors;
|
||
|
|
this.zoomFactors = zoomFactors;
|
||
|
|
};
|
||
|
|
ZoomEditor.prototype.setZoonIndex = function (index) {
|
||
|
|
this.currentIdx = index;
|
||
|
|
};
|
||
|
|
ZoomEditor.prototype.getZoonIndex = function () {
|
||
|
|
return this.currentIdx;
|
||
|
|
};
|
||
|
|
ZoomEditor.prototype.updateZoomAndPan = function () {
|
||
|
|
var originCornerLT = this.vfData.getCorner('Origin', 'LT');
|
||
|
|
var virtualCornerLT = this.vfData.getCorner('Virtual', 'LT');
|
||
|
|
ZoomEditor.offsetXForZoomAndPan = originCornerLT[0] - virtualCornerLT[0];
|
||
|
|
ZoomEditor.offsetYForZoomAndPan = originCornerLT[1] - virtualCornerLT[1];
|
||
|
|
};
|
||
|
|
ZoomEditor.clear = function () {
|
||
|
|
ZoomEditor.offsetXForZoomAndPan = 0;
|
||
|
|
ZoomEditor.offsetYForZoomAndPan = 0;
|
||
|
|
};
|
||
|
|
ZoomEditor.offsetXForZoomAndPan = 0;
|
||
|
|
ZoomEditor.offsetYForZoomAndPan = 0;
|
||
|
|
return ZoomEditor;
|
||
|
|
}(Editor));
|
||
|
|
|
||
|
|
var PanEditor = /** @class */ (function (_super) {
|
||
|
|
__extends(PanEditor, _super);
|
||
|
|
function PanEditor(vfViewer, eventManager) {
|
||
|
|
var _this = _super.call(this) || this;
|
||
|
|
_this.name = EditorName.PAN_Editor;
|
||
|
|
_this.eventManager = eventManager;
|
||
|
|
_this.vfData = vfViewer.getData();
|
||
|
|
_this.bIsMouseDown = false;
|
||
|
|
_this.mouseDownPos = new THREE.Vector2();
|
||
|
|
PanEditor.panOffsetX = 0;
|
||
|
|
PanEditor.panOffsetY = 0;
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
PanEditor.prototype.onMouseDown = function (event) {
|
||
|
|
this.bIsMouseDown = true;
|
||
|
|
this.mouseDownPos.setX(event.clientX);
|
||
|
|
this.mouseDownPos.setY(event.clientY);
|
||
|
|
};
|
||
|
|
PanEditor.prototype.onMouseMove = function (event) {
|
||
|
|
if (this.bIsMouseDown == false) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (this.vfData.getZoomFactor() == 1) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
// 当右键或中键在进行拖动时,根据鼠标位置进行实时更新定位
|
||
|
|
var deltaX = (event.clientX - this.mouseDownPos.x);
|
||
|
|
var deltaY = (event.clientY - this.mouseDownPos.y);
|
||
|
|
var boundsOffset = this.boundsChecking(deltaX, deltaY);
|
||
|
|
deltaX = boundsOffset[0];
|
||
|
|
deltaY = boundsOffset[1];
|
||
|
|
PanEditor.panOffsetX += deltaX;
|
||
|
|
PanEditor.panOffsetY += deltaY;
|
||
|
|
PanEditor.panOffsetXForCamera += deltaX;
|
||
|
|
PanEditor.panOffsetYForCamera += deltaY;
|
||
|
|
this.vfData.updateMovement();
|
||
|
|
this.updateZoomAndPan();
|
||
|
|
this.mouseDownPos.setX(event.clientX);
|
||
|
|
this.mouseDownPos.setY(event.clientY);
|
||
|
|
};
|
||
|
|
PanEditor.prototype.onMouseUp = function (event) {
|
||
|
|
if (this.bIsMouseDown == false) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (this.vfData.getZoomFactor() == 1) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
var deltaX = (event.clientX - this.mouseDownPos.x);
|
||
|
|
var deltaY = (event.clientY - this.mouseDownPos.y);
|
||
|
|
//对新的offset做bounds check
|
||
|
|
var boundsOffset = this.boundsChecking(deltaX, deltaY);
|
||
|
|
deltaX = boundsOffset[0];
|
||
|
|
deltaY = boundsOffset[1];
|
||
|
|
PanEditor.panOffsetX += deltaX;
|
||
|
|
PanEditor.panOffsetY += deltaY;
|
||
|
|
PanEditor.panOffsetXForCamera += deltaX;
|
||
|
|
PanEditor.panOffsetYForCamera += deltaY;
|
||
|
|
this.vfData.updateMovement();
|
||
|
|
this.updateZoomAndPan();
|
||
|
|
this.eventManager.dispatchEvent({
|
||
|
|
type: EventType.PAN_MOUSE_MOVE,
|
||
|
|
data: {
|
||
|
|
offsetX: PanEditor.panOffsetX,
|
||
|
|
offsetY: PanEditor.panOffsetY,
|
||
|
|
zoomFactor: this.vfData.getZoomFactor()
|
||
|
|
}
|
||
|
|
});
|
||
|
|
this.bIsMouseDown = false;
|
||
|
|
};
|
||
|
|
//deltaX 大于0 ---> 检查LB.x
|
||
|
|
// 小于0 ---> 检查RT.x
|
||
|
|
//deltaY 大于0 ---> 检查LB.y
|
||
|
|
// 小于0 ---> 检查RT.y
|
||
|
|
PanEditor.prototype.boundsChecking = function (deltaX, deltaY) {
|
||
|
|
var originCornerLB = this.vfData.getCorner('Origin', 'LB');
|
||
|
|
var virtualCornerLB = this.vfData.getCorner('Virtual', 'LB');
|
||
|
|
var originCornerRT = this.vfData.getCorner('Origin', 'RT');
|
||
|
|
var virtualCornerRT = this.vfData.getCorner('Virtual', 'RT');
|
||
|
|
//横向检查
|
||
|
|
if (deltaX > 0) {
|
||
|
|
var maxOffsetX = originCornerLB[0] - virtualCornerLB[0];
|
||
|
|
if (maxOffsetX <= deltaX) {
|
||
|
|
deltaX = maxOffsetX;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (deltaX < 0) {
|
||
|
|
var maxOffsetX = originCornerRT[0] - virtualCornerRT[0];
|
||
|
|
if (maxOffsetX >= deltaX) {
|
||
|
|
deltaX = maxOffsetX;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//纵向检查
|
||
|
|
if (deltaY < 0) {
|
||
|
|
var maxOffsetY = originCornerLB[1] - virtualCornerLB[1];
|
||
|
|
if (maxOffsetY >= deltaY) {
|
||
|
|
deltaY = maxOffsetY;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (deltaY > 0) {
|
||
|
|
var maxOffsetY = originCornerRT[1] - virtualCornerRT[1];
|
||
|
|
if (maxOffsetY <= deltaY) {
|
||
|
|
deltaY = maxOffsetY;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return [deltaX, deltaY];
|
||
|
|
};
|
||
|
|
PanEditor.prototype.updateZoomAndPan = function () {
|
||
|
|
var originCornerLT = this.vfData.getCorner('Origin', 'LT');
|
||
|
|
var virtualCornerLT = this.vfData.getCorner('Virtual', 'LT');
|
||
|
|
ZoomEditor.offsetXForZoomAndPan = originCornerLT[0] - virtualCornerLT[0];
|
||
|
|
ZoomEditor.offsetYForZoomAndPan = originCornerLT[1] - virtualCornerLT[1];
|
||
|
|
};
|
||
|
|
PanEditor.clear = function () {
|
||
|
|
PanEditor.panOffsetX = 0;
|
||
|
|
PanEditor.panOffsetY = 0;
|
||
|
|
PanEditor.panOffsetXForCamera = 0;
|
||
|
|
PanEditor.panOffsetYForCamera = 0;
|
||
|
|
};
|
||
|
|
return PanEditor;
|
||
|
|
}(Editor));
|
||
|
|
|
||
|
|
/** @class */ ((function (_super) {
|
||
|
|
__extends(CameraNode, _super);
|
||
|
|
function CameraNode() {
|
||
|
|
var _this = _super.call(this) || this;
|
||
|
|
_this.cameraCircleNode = null;
|
||
|
|
_this.cameraArrowNode = null;
|
||
|
|
_this.rotateAngle = 0;
|
||
|
|
_this.panelSize = [298, 198];
|
||
|
|
_this.build();
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
CameraNode.prototype.build = function () {
|
||
|
|
var svgNode = document.createElementNS(this.xmlns, 'g');
|
||
|
|
svgNode.setAttribute('fill', 'none');
|
||
|
|
svgNode.setAttribute('fill-rule', 'evenodd');
|
||
|
|
svgNode.setAttribute('stroke-width', '1');
|
||
|
|
var circle = document.createElementNS(this.xmlns, 'circle');
|
||
|
|
circle.setAttribute('r', '4.5');
|
||
|
|
circle.setAttribute('stroke', '#FFFFFF');
|
||
|
|
circle.setAttribute('fill', '#32D3A6');
|
||
|
|
this.cameraCircleNode = circle;
|
||
|
|
var path = document.createElementNS(this.xmlns, 'path');
|
||
|
|
//path.setAttribute('d', 'M 7 6 Q 10 0, 7 -6 L 19 0 Z');
|
||
|
|
path.setAttribute('d', 'M5.94925387,0 C18.4132389,0 28.6581001,9.50119823 29.8362478,21.6560048 L5.94925387,25 Z');
|
||
|
|
path.setAttribute('fill', 'url(#radialGradient-1)');
|
||
|
|
path.setAttribute('transform', 'translate(13,-21)rotate(50)');
|
||
|
|
this.cameraArrowNode = path;
|
||
|
|
// 渐变
|
||
|
|
var defs = document.createElementNS(this.xmlns, 'defs');
|
||
|
|
var radialGradient = document.createElementNS(this.xmlns, 'radialGradient');
|
||
|
|
var stop1 = document.createElementNS(this.xmlns, 'stop');
|
||
|
|
var stop2 = document.createElementNS(this.xmlns, 'stop');
|
||
|
|
radialGradient.setAttribute('cx', '0%');
|
||
|
|
radialGradient.setAttribute('cy', '100%');
|
||
|
|
radialGradient.setAttribute('fx', '0%');
|
||
|
|
radialGradient.setAttribute('fy', '100%');
|
||
|
|
radialGradient.setAttribute('r', '104.321936%');
|
||
|
|
radialGradient.setAttribute('id', 'radialGradient-1');
|
||
|
|
stop1.setAttribute('stop-color', '#36D4A8');
|
||
|
|
stop1.setAttribute('offset', '0%');
|
||
|
|
stop2.setAttribute('stop-color', '#36D4A8');
|
||
|
|
stop2.setAttribute('offset', '100%');
|
||
|
|
stop2.setAttribute('stop-opacity', '0');
|
||
|
|
defs.append(radialGradient);
|
||
|
|
radialGradient.append(stop1);
|
||
|
|
radialGradient.append(stop2);
|
||
|
|
svgNode.appendChild(defs);
|
||
|
|
svgNode.appendChild(circle);
|
||
|
|
svgNode.appendChild(path);
|
||
|
|
this.svgNode = svgNode;
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setCircleAttribute = function (key, value) {
|
||
|
|
this.cameraCircleNode.setAttribute(key, value);
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setArrowAttribute = function (key, value) {
|
||
|
|
this.cameraArrowNode.setAttribute(key, value);
|
||
|
|
};
|
||
|
|
CameraNode.prototype.rotate = function (angle) {
|
||
|
|
if (angle) {
|
||
|
|
this.rotateAngle = angle;
|
||
|
|
}
|
||
|
|
var transform = this.svgNode.getAttribute('transform');
|
||
|
|
transform += "rotate" + "(" + this.rotateAngle + ")";
|
||
|
|
this.svgNode.setAttribute("transform", transform);
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setOffsetAndRotate = function (offsetX, offsetY, angle) {
|
||
|
|
var offset = this.setOffsetBoundary(offsetX, offsetY);
|
||
|
|
this.locate(offset.X, offset.Y);
|
||
|
|
this.rotate(angle);
|
||
|
|
PanEditor.panOffsetXForCamera = 0;
|
||
|
|
PanEditor.panOffsetYForCamera = 0;
|
||
|
|
};
|
||
|
|
CameraNode.prototype.move = function (deltaX, deltaY) {
|
||
|
|
var offsetX = this.position.x + deltaX;
|
||
|
|
var offsetY = this.position.y + deltaY;
|
||
|
|
var offset = this.setOffsetBoundary(offsetX, offsetY);
|
||
|
|
this.svgNode.setAttribute("transform", "translate(" + offset.X + "," + offset.Y + ")");
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setOpacity = function (opacity) {
|
||
|
|
this.svgNode.setAttribute('opacity', opacity);
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setCameraArrowOpacity = function (opacity) {
|
||
|
|
this.cameraArrowNode.setAttribute('opacity', opacity);
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setCameraCircleOpacity = function (opacity) {
|
||
|
|
this.cameraCircleNode.setAttribute('opacity', opacity);
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setBigCamera = function () {
|
||
|
|
this.cameraCircleNode.setAttribute('r', '4.5');
|
||
|
|
this.cameraArrowNode.setAttribute('transform', 'translate(13,-21)rotate(50)');
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setSmallCamera = function () {
|
||
|
|
this.cameraCircleNode.setAttribute('r', '2');
|
||
|
|
this.cameraArrowNode.setAttribute('transform', 'translate(20,-21)rotate(50)');
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setPanelSize = function (panelSize) {
|
||
|
|
this.panelSize = panelSize;
|
||
|
|
};
|
||
|
|
CameraNode.prototype.setOffsetBoundary = function (offsetX, offsetY) {
|
||
|
|
var offsetXmax = this.panelSize[0] / 2 - 6;
|
||
|
|
var offsetXmin = -this.panelSize[0] / 2 + 6;
|
||
|
|
var offsetYmax = this.panelSize[1] / 2 - 6;
|
||
|
|
var offsetYmin = -this.panelSize[1] / 2 + 6;
|
||
|
|
if (offsetX >= offsetXmax || offsetX <= offsetXmin || offsetY >= offsetYmax || offsetY <= offsetYmin) {
|
||
|
|
this.setSmallCamera();
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.setBigCamera();
|
||
|
|
}
|
||
|
|
offsetX > offsetXmax ? offsetX = offsetXmax : '';
|
||
|
|
offsetX < offsetXmin ? offsetX = offsetXmin : '';
|
||
|
|
offsetY > offsetYmax ? offsetY = offsetYmax : '';
|
||
|
|
offsetY < offsetYmin ? offsetY = offsetYmin : '';
|
||
|
|
return { X: offsetX, Y: offsetY };
|
||
|
|
};
|
||
|
|
return CameraNode;
|
||
|
|
})(DrawableItem));
|
||
|
|
|
||
|
|
// 初始化剖切
|
||
|
|
var initSectionPlane = function (viewer3D) {
|
||
|
|
delete viewer3D._sectionPlane;
|
||
|
|
var config = new window.Glodon.Bimface.Plugins.Section.SectionPlaneConfig();
|
||
|
|
config.plane = window.Glodon.Bimface.Plugins.Section.SectionPlanePlane.Z;
|
||
|
|
config.viewer = viewer3D;
|
||
|
|
config.id = "SectionPlane";
|
||
|
|
config.exitSectionBox = false;
|
||
|
|
config.enableSnap = true;
|
||
|
|
var sectionPlane = new window.Glodon.Bimface.Plugins.Section.SectionPlane(config);
|
||
|
|
sectionPlane.hidePlane();
|
||
|
|
viewer3D._sectionPlane = sectionPlane;
|
||
|
|
};
|
||
|
|
|
||
|
|
var TYPE;
|
||
|
|
(function (TYPE) {
|
||
|
|
TYPE[TYPE["RECTANGLE"] = 1] = "RECTANGLE";
|
||
|
|
TYPE[TYPE["POLYLINE"] = 2] = "POLYLINE";
|
||
|
|
})(TYPE || (TYPE = {}));
|
||
|
|
var Separation = /** @class */ (function (_super) {
|
||
|
|
__extends(Separation, _super);
|
||
|
|
function Separation(config) {
|
||
|
|
var _this = _super.call(this) || this;
|
||
|
|
_this._config = config;
|
||
|
|
_this.type = config.type || null;
|
||
|
|
config.elevation != null && _this.setSectionPlane(config);
|
||
|
|
_this.showAxisGrid();
|
||
|
|
_this.available = true;
|
||
|
|
_this.visible = true;
|
||
|
|
return _this;
|
||
|
|
}
|
||
|
|
// construct new section based on elevation
|
||
|
|
Separation.prototype.setSectionPlane = function (config) {
|
||
|
|
var viewer = config.viewer, modelId = config.modelId; config.roomId; config.elevation; config.unit; var fileId = config.fileId;
|
||
|
|
var model = viewer.getModel(modelId);
|
||
|
|
model.getBoundingBox(fileId ? fileId : model.modelId, function (data) {
|
||
|
|
var unit = config.unit || config.viewer.getGlobalUnit();
|
||
|
|
if (!viewer._sectionPlane)
|
||
|
|
initSectionPlane(viewer);
|
||
|
|
var fullHeight = data.originalBoundingBox.max.z - data.originalBoundingBox.min.z;
|
||
|
|
var sectionHeight = data.originalBoundingBox.max.z - (unit == 'Meter' ? config.elevation : config.elevation * 1000) - (unit == 'Meter' ? config.height - 0.12 : config.height - 12) - config.viewer.getModel(config.modelId).getModelTransformationAdaptedUnit()[14];
|
||
|
|
var progress = sectionHeight / fullHeight * 100;
|
||
|
|
viewer._sectionPlane.setProgress(progress);
|
||
|
|
viewer._sectionPlane.enableHatch(false);
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Separation.prototype.showAxisGrid = function () {
|
||
|
|
this._config.viewer.getModel(this._config.modelId).showAxisGridsByFloor(this._config.fileId, this._config.floor);
|
||
|
|
};
|
||
|
|
Separation.prototype.removeAllAxisGrids = function () {
|
||
|
|
this._config.viewer.getModel(this._config.modelId).removeAllAxisGrids();
|
||
|
|
};
|
||
|
|
Separation.prototype.drawRectangle = function () {
|
||
|
|
var _this = this;
|
||
|
|
if (this.type)
|
||
|
|
return;
|
||
|
|
this.drawRectangleTool = new DrawRectangleTool(this._config);
|
||
|
|
this.type = TYPE.RECTANGLE;
|
||
|
|
this.drawRectangleTool.addEventListener('DrawFinished', function () {
|
||
|
|
_this.addNewSolid();
|
||
|
|
_this.fireEvent('DrawFinished');
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Separation.prototype.drawPolyLine = function () {
|
||
|
|
var _this = this;
|
||
|
|
if (this.type)
|
||
|
|
return;
|
||
|
|
this.drawPolyLineTool = new DrawPolyLineTool(this._config);
|
||
|
|
this.type = TYPE.POLYLINE;
|
||
|
|
this.drawPolyLineTool.addEventListener('DrawFinished', function () {
|
||
|
|
_this.addNewSolid();
|
||
|
|
_this.fireEvent('DrawFinished');
|
||
|
|
});
|
||
|
|
};
|
||
|
|
Separation.prototype.edit = function (points) {
|
||
|
|
var _this = this;
|
||
|
|
if (!this.visible || !this.available) {
|
||
|
|
this._config.viewer.unlockAxis(Glodon$1.Bimface.Viewer.AxisOption.Z);
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
!points && (points = this.room ? this.exchangeBimtileMmToM(this.translateRoom(this.room.getBoundary().outer, false)) : this.getSolid());
|
||
|
|
this.drawRectangleTool && this.drawRectangleTool.exit();
|
||
|
|
this.drawPolyLineTool && this.drawPolyLineTool.exit();
|
||
|
|
this.editPolygon && this.editPolygon.exit();
|
||
|
|
this.roomManager && this.roomManager.hideRoomsById([this.room.roomId]);
|
||
|
|
this._config.controlType = "EditPolygonControl";
|
||
|
|
this._config.points = points;
|
||
|
|
this._config.color = '#32D3A6';
|
||
|
|
this._config.hidePlane = true;
|
||
|
|
this._config.showEdge = true;
|
||
|
|
var newTool = new EditClipSurfaceTool(this._config);
|
||
|
|
this.editPolygon = newTool;
|
||
|
|
newTool.setPoints(points);
|
||
|
|
var self = this;
|
||
|
|
this.editPolygon.addEventListener('EditCompleted', function () {
|
||
|
|
self.room && self.room.setBoundary({ outer: self.translateRoom(self.getSolid()) }, self._config.unit);
|
||
|
|
self.roomManager && self.roomManager.loadAndCalculateOverLap(self._config.roomId, self._config.overlapType || 'plus');
|
||
|
|
self.roomManager && self.roomManager.showRoomsById([_this.room.roomId]);
|
||
|
|
self._config.viewer.unlockAxis(Glodon$1.Bimface.Viewer.AxisOption.Z);
|
||
|
|
self.fireEvent('EditCompleted');
|
||
|
|
});
|
||
|
|
this.editPolygon.addEventListener('WarningHint', function () {
|
||
|
|
self.fireEvent('WarningHint');
|
||
|
|
});
|
||
|
|
};
|
||
|
|
// match room position changed, an inverted matrix is applied
|
||
|
|
Separation.prototype.translateRoom = function (res, reverse) {
|
||
|
|
if (reverse === void 0) { reverse = true; }
|
||
|
|
var matrix = new window.THREE.Matrix4();
|
||
|
|
matrix.elements = this._config.viewer.getModel(this._config.modelId).getModelTransformationAdaptedUnit();
|
||
|
|
var positions = [];
|
||
|
|
res.map(function (position) {
|
||
|
|
var newPoint = new window.THREE.Vector3(position.x, position.y, position.z).applyMatrix4(reverse ? matrix.clone().invert() : matrix.clone());
|
||
|
|
positions.push(newPoint);
|
||
|
|
});
|
||
|
|
return positions;
|
||
|
|
};
|
||
|
|
// bimtile special exchange
|
||
|
|
Separation.prototype.exchangeBimtileMmToM = function (points) {
|
||
|
|
if (this._config.viewer.getModel(this._config.modelId)._manifest.Metadata.Content.Type == 'bimtiles'
|
||
|
|
&& this._config.viewer.getGlobalUnit() == 'Millimeter') {
|
||
|
|
points = points.map(function (point) {
|
||
|
|
point.x = point.x / 1000;
|
||
|
|
point.y = point.y / 1000;
|
||
|
|
point.z = point.z / 1000;
|
||
|
|
return point;
|
||
|
|
});
|
||
|
|
}
|
||
|
|
return points;
|
||
|
|
};
|
||
|
|
Separation.prototype.getSolid = function () {
|
||
|
|
var res = [];
|
||
|
|
var data;
|
||
|
|
if (!this.editPolygon) {
|
||
|
|
if (this.type == TYPE.RECTANGLE) {
|
||
|
|
data = this.drawRectangleTool.getControl().getPoints();
|
||
|
|
if (!data)
|
||
|
|
return null;
|
||
|
|
data = [data[1], data[3], data[4], data[5]];
|
||
|
|
}
|
||
|
|
if (this.type == TYPE.POLYLINE) {
|
||
|
|
data = this.drawPolyLineTool.getControl().getPoints();
|
||
|
|
if (!data)
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
data = this.editPolygon.getPointsData();
|
||
|
|
}
|
||
|
|
// remove duplicate object data from data
|
||
|
|
for (var i = 0; i < data.length; i++) {
|
||
|
|
var item = data[i];
|
||
|
|
var isExist = false;
|
||
|
|
for (var j = 0; j < res.length; j++) {
|
||
|
|
var resItem = res[j];
|
||
|
|
if (item.x === resItem.x && item.y === resItem.y && item.z === resItem.z) {
|
||
|
|
isExist = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (!isExist) {
|
||
|
|
var newItem = __assign({}, item);
|
||
|
|
if (this._config.viewer.getGlobalUnit() == 'Millimeter' && this._config.viewer.getModel(this._config.modelId)._manifest.Metadata.Content.Type == 'bimtiles') {
|
||
|
|
newItem.x = newItem.x * 1000;
|
||
|
|
newItem.y = newItem.y * 1000;
|
||
|
|
newItem.z = newItem.z * 1000;
|
||
|
|
}
|
||
|
|
res.push(newItem);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return res;
|
||
|
|
};
|
||
|
|
Separation.prototype.hide = function () {
|
||
|
|
if (!this.available)
|
||
|
|
return;
|
||
|
|
this.visible = false;
|
||
|
|
if (!this.editPolygon) {
|
||
|
|
this.drawRectangleTool && this.drawRectangleTool.getControl().hide();
|
||
|
|
this.drawPolyLineTool && this.drawPolyLineTool.getControl().hide();
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.editPolygon.getControl().hide();
|
||
|
|
}
|
||
|
|
this._config.viewer && this._config.viewer.render();
|
||
|
|
};
|
||
|
|
Separation.prototype.show = function () {
|
||
|
|
if (!this.available)
|
||
|
|
return;
|
||
|
|
this.visible = true;
|
||
|
|
if (!this.editPolygon) {
|
||
|
|
this.drawRectangleTool && this.drawRectangleTool.getControl().show();
|
||
|
|
this.drawPolyLineTool && this.drawPolyLineTool.getControl().show();
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
this.editPolygon.getControl().show();
|
||
|
|
}
|
||
|
|
this._config.viewer && this._config.viewer.render();
|
||
|
|
};
|
||
|
|
Separation.prototype.exit = function () {
|
||
|
|
this.hide();
|
||
|
|
this.visible = false;
|
||
|
|
this.available = false;
|
||
|
|
this.drawRectangleTool && this.drawRectangleTool.exit();
|
||
|
|
this.drawPolyLineTool && this.drawPolyLineTool.exit();
|
||
|
|
this.editPolygon && this.editPolygon.exit();
|
||
|
|
};
|
||
|
|
Separation.prototype.addNewSolid = function () {
|
||
|
|
var positions = this.translateRoom(this.getSolid());
|
||
|
|
var roomConfig = new Glodon$1.Bimface.Plugins.Rooms.RoomConfig();
|
||
|
|
roomConfig.viewer = this._config.viewer;
|
||
|
|
roomConfig.roomId = this._config.roomId;
|
||
|
|
roomConfig.modelId = this._config.modelId;
|
||
|
|
roomConfig.geometry = {
|
||
|
|
type: 'extrusion',
|
||
|
|
boundary: {
|
||
|
|
outer: positions,
|
||
|
|
},
|
||
|
|
height: this._config.height,
|
||
|
|
unit: this._config.unit
|
||
|
|
};
|
||
|
|
roomConfig.roomColor = this._config.fillColor;
|
||
|
|
roomConfig.frameColor = this._config.frameColor;
|
||
|
|
this.room = new Glodon$1.Bimface.Plugins.Rooms.Room(roomConfig);
|
||
|
|
this.room.name = this._config.name;
|
||
|
|
this.room.conditions = this._config.conditions;
|
||
|
|
this.room.floor = this._config.floor;
|
||
|
|
this.room.drawTool = this;
|
||
|
|
this.roomManager = this._config.viewer.getModel(this._config.modelId).getRoomManager();
|
||
|
|
this.roomManager.addRoom(this.room);
|
||
|
|
// bind manager to room in order to allow room to update itself
|
||
|
|
this.room.roomModelManager = this.roomManager;
|
||
|
|
this.roomManager.loadAndCalculateOverLap(this._config.roomId, this._config.overlapType || 'plus');
|
||
|
|
this._config.viewer.render();
|
||
|
|
};
|
||
|
|
Separation.prototype.getRoom = function () {
|
||
|
|
if (!this.available)
|
||
|
|
return;
|
||
|
|
return this.room;
|
||
|
|
};
|
||
|
|
// 添加本工具的监听
|
||
|
|
Separation.prototype.addEventListener = function (type, event) {
|
||
|
|
this.addEvent(type, event);
|
||
|
|
};
|
||
|
|
// 移除本工具的监听
|
||
|
|
Separation.prototype.removeEventListener = function (type, event) {
|
||
|
|
this.removeEvent(type, event);
|
||
|
|
};
|
||
|
|
return Separation;
|
||
|
|
}(EventEmmiter));
|
||
|
|
|
||
|
|
Glodon$1.Bimface = Glodon$1.Bimface || {};
|
||
|
|
Glodon$1.Bimface.Interactions = Glodon$1.Bimface.Interactions || {};
|
||
|
|
Glodon$1.Bimface.Interactions.DrawRectangleTool = DrawRectangleTool;
|
||
|
|
Glodon$1.Bimface.Interactions.DrawPolyLineTool = DrawPolyLineTool;
|
||
|
|
Glodon$1.Bimface.Interactions.Separation = Separation;
|