@anov/3d-ability 0.0.100 → 0.0.102
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/dist/business/Base/ObjectLayer.d.ts +1 -1
- package/dist/business/Base/ObjectLayer.js +3 -1
- package/dist/business/Base/ObjectLayer.js.map +1 -1
- package/dist/business/Flyline/index.js +2 -3
- package/dist/business/Flyline/index.js.map +1 -1
- package/dist/business/HeatMap/core.d.ts +2 -2
- package/dist/business/HeatMap/core.js +1 -1
- package/dist/business/HeatMap/core.js.map +1 -1
- package/dist/business/Mark/KeyframeAnimation.d.ts +62 -0
- package/dist/business/Mark/KeyframeAnimation.js +219 -0
- package/dist/business/Mark/KeyframeAnimation.js.map +1 -0
- package/dist/business/Mark/index.d.ts +15 -8
- package/dist/business/Mark/index.js +134 -74
- package/dist/business/Mark/index.js.map +1 -1
- package/dist/business/{Poi/shader/circle copy 2.d.ts → Mark/shader/tanhao.d.ts} +2 -5
- package/dist/business/Mark/shader/tanhao.js +12 -0
- package/dist/business/Mark/shader/tanhao.js.map +1 -0
- package/dist/business/Mark/type.d.ts +2 -12
- package/dist/business/Mark/type.js +0 -7
- package/dist/business/Mark/type.js.map +1 -1
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.d.ts +68 -63
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js +278 -160
- package/dist/business/MaterialSwitch/MaterialSwitchSystem.js.map +1 -1
- package/dist/business/MaterialSwitch/inject.d.ts +46 -1
- package/dist/business/MaterialSwitch/inject.js +78 -8
- package/dist/business/MaterialSwitch/inject.js.map +1 -1
- package/dist/business/MaterialSwitch/shader/finalFade.d.ts +2 -0
- package/dist/business/MaterialSwitch/shader/finalFade.js +3 -0
- package/dist/business/MaterialSwitch/shader/finalFade.js.map +1 -0
- package/dist/business/MaterialSwitch/shader/ground.d.ts +81 -0
- package/dist/business/MaterialSwitch/shader/ground.js +68 -0
- package/dist/business/MaterialSwitch/shader/ground.js.map +1 -0
- package/dist/business/MaterialSwitch/{realFade.d.ts → shader/realFade.d.ts} +2 -2
- package/dist/business/MaterialSwitch/{realFade.js → shader/realFade.js} +2 -2
- package/dist/business/MaterialSwitch/shader/realFade.js.map +1 -0
- package/dist/business/Poi/link/Pyramid.js +1 -1
- package/dist/business/Poi/link/Pyramid.js.map +1 -1
- package/dist/business/Poi/particle/DoubleCircle.d.ts +1 -0
- package/dist/business/Poi/particle/DoubleCircle.js +14 -1
- package/dist/business/Poi/particle/DoubleCircle.js.map +1 -1
- package/dist/business/Poi/particle/SingleCircle.js +4 -1
- package/dist/business/Poi/particle/SingleCircle.js.map +1 -1
- package/dist/business/Poi/particle/index.d.ts +3 -3
- package/dist/business/Poi/particle/index.js.map +1 -1
- package/dist/business/Poi/shader/doubleCircle.js +1 -1
- package/dist/business/Poi/shader/doubleCircle.js.map +1 -1
- package/dist/business/Poi/title/index.d.ts +1 -1
- package/dist/business/SplitBuilding/index.d.ts +86 -0
- package/dist/business/SplitBuilding/index.js +593 -0
- package/dist/business/SplitBuilding/index.js.map +1 -0
- package/dist/business/SplitBuilding/type.d.ts +34 -0
- package/dist/business/SplitBuilding/type.js +25 -0
- package/dist/business/SplitBuilding/type.js.map +1 -0
- package/dist/business/Utils/constant.d.ts +1 -1
- package/dist/business/Utils/constant.js +1 -1
- package/dist/business/Utils/constant.js.map +1 -1
- package/dist/business/index.d.ts +1 -0
- package/dist/business/index.js +1 -0
- package/dist/business/index.js.map +1 -1
- package/dist/core/Material/SurfaceMaterial/index.js +7 -7
- package/dist/core/Material/SurfaceMaterial/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/business/MaterialSwitch/finalFade.d.ts +0 -2
- package/dist/business/MaterialSwitch/finalFade.js +0 -3
- package/dist/business/MaterialSwitch/finalFade.js.map +0 -1
- package/dist/business/MaterialSwitch/realFade.js.map +0 -1
- package/dist/business/Poi/shader/circle copy 2.js +0 -15
- package/dist/business/Poi/shader/circle copy 2.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Object3D } from '@anov/3d-core';
|
|
2
|
+
import ObjectLayer from '../Base/ObjectLayer';
|
|
3
|
+
import { EBuildingSplitType } from './type';
|
|
4
|
+
declare class BuildingSplit extends ObjectLayer {
|
|
5
|
+
private floorGroups;
|
|
6
|
+
private sortedFloorLevels;
|
|
7
|
+
private aboveGroundFloorCount;
|
|
8
|
+
private undergroundFloorCount;
|
|
9
|
+
private hasRoof;
|
|
10
|
+
private currentAnimation;
|
|
11
|
+
private _building;
|
|
12
|
+
constructor(building: Object3D);
|
|
13
|
+
get building(): Object3D<import("@anov/3d-core").Event>;
|
|
14
|
+
/**
|
|
15
|
+
* 初始化建筑拆分器
|
|
16
|
+
* @param building 建筑模型
|
|
17
|
+
*/
|
|
18
|
+
init(): void;
|
|
19
|
+
/**
|
|
20
|
+
* 解析建筑模型中的楼层
|
|
21
|
+
*/
|
|
22
|
+
private parseFloors;
|
|
23
|
+
/**
|
|
24
|
+
* 将组件添加到对应楼层分组
|
|
25
|
+
*/
|
|
26
|
+
private addToFloorGroup;
|
|
27
|
+
/**
|
|
28
|
+
* 拆分楼层
|
|
29
|
+
* @param options 拆分选项
|
|
30
|
+
* @returns 成功或错误信息
|
|
31
|
+
*/
|
|
32
|
+
split(options: any): {
|
|
33
|
+
success: boolean;
|
|
34
|
+
message?: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 隐藏指定楼层以上的楼层
|
|
38
|
+
* @param targetFloor 目标楼层
|
|
39
|
+
*/
|
|
40
|
+
private hideAboveFloors;
|
|
41
|
+
/**
|
|
42
|
+
* 将指定楼层以上的楼层整体上移
|
|
43
|
+
* @param targetFloor 目标楼层
|
|
44
|
+
* @param animation 动画选项
|
|
45
|
+
*/
|
|
46
|
+
private moveAboveFloorsUp;
|
|
47
|
+
/**
|
|
48
|
+
* 将指定楼层以上的楼层向指定方向移动
|
|
49
|
+
* @param targetFloor 目标楼层
|
|
50
|
+
* @param animation 动画选项
|
|
51
|
+
*/
|
|
52
|
+
private moveAboveFloorsDirection;
|
|
53
|
+
/**
|
|
54
|
+
* 计算方向向量
|
|
55
|
+
* 规则:往右方(X)、前方(Z)是正、往左方(X)、后方(Z)是负数
|
|
56
|
+
* @param direction 方向枚举
|
|
57
|
+
* @param distance 移动距离
|
|
58
|
+
* @returns Vector3 方向向量
|
|
59
|
+
*/
|
|
60
|
+
private getDirectionVector;
|
|
61
|
+
/**
|
|
62
|
+
* 只显示指定楼层
|
|
63
|
+
* @param targetFloor 目标楼层
|
|
64
|
+
*/
|
|
65
|
+
private showSoloFloor;
|
|
66
|
+
/**
|
|
67
|
+
* 执行位置动画
|
|
68
|
+
* @param startPositions 起始位置
|
|
69
|
+
* @param targetPositions 目标位置
|
|
70
|
+
* @param duration 动画时长
|
|
71
|
+
*/
|
|
72
|
+
private animatePositions;
|
|
73
|
+
/**
|
|
74
|
+
* 重置建筑到初始状态
|
|
75
|
+
*/
|
|
76
|
+
private resetBuilding;
|
|
77
|
+
/**
|
|
78
|
+
* 获取楼层总数信息
|
|
79
|
+
*/
|
|
80
|
+
getFloorCounts(): {
|
|
81
|
+
aboveGround: number;
|
|
82
|
+
underground: number;
|
|
83
|
+
hasRoof: boolean;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export { BuildingSplit, EBuildingSplitType };
|
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
9
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
12
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
13
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
17
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
+
import { Vector3 } from '@anov/3d-core';
|
|
19
|
+
import ObjectLayer from "../Base/ObjectLayer";
|
|
20
|
+
import { EBuildingSplitType, EDirection } from "./type";
|
|
21
|
+
var BuildingSplit = /*#__PURE__*/function (_ObjectLayer) {
|
|
22
|
+
_inherits(BuildingSplit, _ObjectLayer);
|
|
23
|
+
var _super = _createSuper(BuildingSplit);
|
|
24
|
+
function BuildingSplit(building) {
|
|
25
|
+
var _this;
|
|
26
|
+
_classCallCheck(this, BuildingSplit);
|
|
27
|
+
_this = _super.call(this);
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "floorGroups", new Map());
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "sortedFloorLevels", []);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "aboveGroundFloorCount", 0);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "undergroundFloorCount", 0);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "hasRoof", false);
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "currentAnimation", {
|
|
34
|
+
timer: null
|
|
35
|
+
});
|
|
36
|
+
_defineProperty(_assertThisInitialized(_this), "_building", void 0);
|
|
37
|
+
_this._building = building;
|
|
38
|
+
_this.init();
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
_createClass(BuildingSplit, [{
|
|
42
|
+
key: "building",
|
|
43
|
+
get: function get() {
|
|
44
|
+
return this._building;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 初始化建筑拆分器
|
|
49
|
+
* @param building 建筑模型
|
|
50
|
+
*/
|
|
51
|
+
}, {
|
|
52
|
+
key: "init",
|
|
53
|
+
value: function init() {
|
|
54
|
+
this.floorGroups = new Map();
|
|
55
|
+
this.sortedFloorLevels = [];
|
|
56
|
+
this.aboveGroundFloorCount = 0;
|
|
57
|
+
this.undergroundFloorCount = 0;
|
|
58
|
+
this.hasRoof = false;
|
|
59
|
+
|
|
60
|
+
// 解析所有楼层
|
|
61
|
+
this.parseFloors();
|
|
62
|
+
|
|
63
|
+
// 排序楼层编号从低到高
|
|
64
|
+
this.sortedFloorLevels = Array.from(this.floorGroups.values()).map(function (group) {
|
|
65
|
+
return group.level;
|
|
66
|
+
}).sort(function (a, b) {
|
|
67
|
+
return a - b;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 解析建筑模型中的楼层
|
|
73
|
+
*/
|
|
74
|
+
}, {
|
|
75
|
+
key: "parseFloors",
|
|
76
|
+
value: function parseFloors() {
|
|
77
|
+
var _this2 = this;
|
|
78
|
+
this.building.traverse(function (object) {
|
|
79
|
+
if (object.type === 'Mesh' || object.type === 'Group') {
|
|
80
|
+
var name = object.name;
|
|
81
|
+
// 检查是否为屋顶
|
|
82
|
+
if (name.startsWith('Roof')) {
|
|
83
|
+
_this2.addToFloorGroup('Roof', {
|
|
84
|
+
mesh: object,
|
|
85
|
+
originalPosition: object.position.clone(),
|
|
86
|
+
originalVisibility: object.visible
|
|
87
|
+
});
|
|
88
|
+
_this2.hasRoof = true;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 提取楼层前缀
|
|
93
|
+
var prefix = null;
|
|
94
|
+
var level = 0;
|
|
95
|
+
var isUnderground = false;
|
|
96
|
+
if (name.startsWith('F') && name.length >= 3) {
|
|
97
|
+
// 地上楼层
|
|
98
|
+
var floorNum = parseInt(name.substring(1, 3));
|
|
99
|
+
if (!isNaN(floorNum)) {
|
|
100
|
+
prefix = "F".concat(name.substring(1, 3));
|
|
101
|
+
level = floorNum;
|
|
102
|
+
isUnderground = false;
|
|
103
|
+
_this2.aboveGroundFloorCount = Math.max(_this2.aboveGroundFloorCount, floorNum);
|
|
104
|
+
}
|
|
105
|
+
} else if (name.startsWith('B') && name.length >= 3) {
|
|
106
|
+
// 地下楼层
|
|
107
|
+
var _floorNum = parseInt(name.substring(1, 3));
|
|
108
|
+
if (!isNaN(_floorNum)) {
|
|
109
|
+
prefix = "B".concat(name.substring(1, 3));
|
|
110
|
+
level = -_floorNum;
|
|
111
|
+
isUnderground = true;
|
|
112
|
+
_this2.undergroundFloorCount = Math.max(_this2.undergroundFloorCount, _floorNum);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (prefix) {
|
|
116
|
+
_this2.addToFloorGroup(prefix, {
|
|
117
|
+
mesh: object,
|
|
118
|
+
originalPosition: object.position.clone(),
|
|
119
|
+
originalVisibility: object.visible
|
|
120
|
+
}, level, isUnderground);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 将组件添加到对应楼层分组
|
|
128
|
+
*/
|
|
129
|
+
}, {
|
|
130
|
+
key: "addToFloorGroup",
|
|
131
|
+
value: function addToFloorGroup(prefix, component) {
|
|
132
|
+
var _this$floorGroups$get;
|
|
133
|
+
var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.aboveGroundFloorCount + 1;
|
|
134
|
+
var isUnderground = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
135
|
+
if (!this.floorGroups.has(prefix)) {
|
|
136
|
+
this.floorGroups.set(prefix, {
|
|
137
|
+
level: level,
|
|
138
|
+
isUnderground: isUnderground,
|
|
139
|
+
isRoof: prefix === 'Roof',
|
|
140
|
+
components: []
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
(_this$floorGroups$get = this.floorGroups.get(prefix)) === null || _this$floorGroups$get === void 0 || _this$floorGroups$get.components.push(component);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 拆分楼层
|
|
148
|
+
* @param options 拆分选项
|
|
149
|
+
* @returns 成功或错误信息
|
|
150
|
+
*/
|
|
151
|
+
}, {
|
|
152
|
+
key: "split",
|
|
153
|
+
value: function split(options) {
|
|
154
|
+
var floor = options.floor,
|
|
155
|
+
animation = options.animation;
|
|
156
|
+
var animOption = animation || {
|
|
157
|
+
type: EBuildingSplitType.Move,
|
|
158
|
+
duration: 1000
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// 取消当前动画
|
|
162
|
+
if (this.currentAnimation.timer !== null) {
|
|
163
|
+
window.clearTimeout(this.currentAnimation.timer);
|
|
164
|
+
this.currentAnimation.timer = null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// 处理 floor = 0 的情况:恢复完整状态
|
|
168
|
+
if (floor === 0) {
|
|
169
|
+
this.resetBuilding();
|
|
170
|
+
return {
|
|
171
|
+
success: true
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 验证楼层参数
|
|
176
|
+
if (floor > 0 && floor > this.aboveGroundFloorCount) {
|
|
177
|
+
return {
|
|
178
|
+
success: false,
|
|
179
|
+
message: "\u5730\u4E0A\u697C\u5C42\u6570\u8D85\u51FA\u8303\u56F4\uFF0C\u6700\u5927\u697C\u5C42\u4E3A ".concat(this.aboveGroundFloorCount)
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
if (floor < 0 && Math.abs(floor) > this.undergroundFloorCount) {
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
message: "\u5730\u4E0B\u697C\u5C42\u6570\u8D85\u51FA\u8303\u56F4\uFF0C\u6700\u5927\u5730\u4E0B\u697C\u5C42\u4E3A ".concat(this.undergroundFloorCount)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// 执行拆分操作
|
|
190
|
+
switch (animOption.type) {
|
|
191
|
+
case EBuildingSplitType.Hide:
|
|
192
|
+
this.hideAboveFloors(floor);
|
|
193
|
+
break;
|
|
194
|
+
case EBuildingSplitType.Move:
|
|
195
|
+
this.moveAboveFloorsDirection(floor, animOption);
|
|
196
|
+
break;
|
|
197
|
+
case EBuildingSplitType.Solo:
|
|
198
|
+
this.showSoloFloor(floor);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
success: true
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 隐藏指定楼层以上的楼层
|
|
208
|
+
* @param targetFloor 目标楼层
|
|
209
|
+
*/
|
|
210
|
+
}, {
|
|
211
|
+
key: "hideAboveFloors",
|
|
212
|
+
value: function hideAboveFloors(targetFloor) {
|
|
213
|
+
var _iterator = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
214
|
+
_step;
|
|
215
|
+
try {
|
|
216
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
217
|
+
var floorGroup = _step.value;
|
|
218
|
+
var floorLevel = floorGroup.level;
|
|
219
|
+
|
|
220
|
+
// 重置所有楼层组件位置
|
|
221
|
+
var _iterator2 = _createForOfIteratorHelper(floorGroup.components),
|
|
222
|
+
_step2;
|
|
223
|
+
try {
|
|
224
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
225
|
+
var component = _step2.value;
|
|
226
|
+
component.mesh.position.copy(component.originalPosition);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// 设置可见性
|
|
230
|
+
} catch (err) {
|
|
231
|
+
_iterator2.e(err);
|
|
232
|
+
} finally {
|
|
233
|
+
_iterator2.f();
|
|
234
|
+
}
|
|
235
|
+
var shouldBeVisible = floorLevel <= targetFloor;
|
|
236
|
+
var _iterator3 = _createForOfIteratorHelper(floorGroup.components),
|
|
237
|
+
_step3;
|
|
238
|
+
try {
|
|
239
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
240
|
+
var _component = _step3.value;
|
|
241
|
+
_component.mesh.visible = shouldBeVisible;
|
|
242
|
+
}
|
|
243
|
+
} catch (err) {
|
|
244
|
+
_iterator3.e(err);
|
|
245
|
+
} finally {
|
|
246
|
+
_iterator3.f();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} catch (err) {
|
|
250
|
+
_iterator.e(err);
|
|
251
|
+
} finally {
|
|
252
|
+
_iterator.f();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* 将指定楼层以上的楼层整体上移
|
|
258
|
+
* @param targetFloor 目标楼层
|
|
259
|
+
* @param animation 动画选项
|
|
260
|
+
*/
|
|
261
|
+
}, {
|
|
262
|
+
key: "moveAboveFloorsUp",
|
|
263
|
+
value: function moveAboveFloorsUp(targetFloor, animation) {
|
|
264
|
+
var distance = 10;
|
|
265
|
+
var duration = animation.duration;
|
|
266
|
+
|
|
267
|
+
// 重置所有楼层可见性
|
|
268
|
+
var _iterator4 = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
269
|
+
_step4;
|
|
270
|
+
try {
|
|
271
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
272
|
+
var floorGroup = _step4.value;
|
|
273
|
+
var _iterator6 = _createForOfIteratorHelper(floorGroup.components),
|
|
274
|
+
_step6;
|
|
275
|
+
try {
|
|
276
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
277
|
+
var component = _step6.value;
|
|
278
|
+
component.mesh.visible = true;
|
|
279
|
+
}
|
|
280
|
+
} catch (err) {
|
|
281
|
+
_iterator6.e(err);
|
|
282
|
+
} finally {
|
|
283
|
+
_iterator6.f();
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// 计算起始位置和目标位置
|
|
288
|
+
} catch (err) {
|
|
289
|
+
_iterator4.e(err);
|
|
290
|
+
} finally {
|
|
291
|
+
_iterator4.f();
|
|
292
|
+
}
|
|
293
|
+
var startPositions = new Map();
|
|
294
|
+
var targetPositions = new Map();
|
|
295
|
+
var _iterator5 = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
296
|
+
_step5;
|
|
297
|
+
try {
|
|
298
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
299
|
+
var _floorGroup = _step5.value;
|
|
300
|
+
var floorLevel = _floorGroup.level;
|
|
301
|
+
var _iterator7 = _createForOfIteratorHelper(_floorGroup.components),
|
|
302
|
+
_step7;
|
|
303
|
+
try {
|
|
304
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
305
|
+
var _component2 = _step7.value;
|
|
306
|
+
startPositions.set(_component2.mesh, _component2.mesh.position.clone());
|
|
307
|
+
if (floorLevel > targetFloor) {
|
|
308
|
+
// 上方楼层需要上移
|
|
309
|
+
var targetPos = _component2.originalPosition.clone();
|
|
310
|
+
targetPos.y += distance;
|
|
311
|
+
targetPositions.set(_component2.mesh, targetPos);
|
|
312
|
+
} else {
|
|
313
|
+
// 其他楼层保持原位
|
|
314
|
+
targetPositions.set(_component2.mesh, _component2.originalPosition.clone());
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
} catch (err) {
|
|
318
|
+
_iterator7.e(err);
|
|
319
|
+
} finally {
|
|
320
|
+
_iterator7.f();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// 执行动画
|
|
325
|
+
} catch (err) {
|
|
326
|
+
_iterator5.e(err);
|
|
327
|
+
} finally {
|
|
328
|
+
_iterator5.f();
|
|
329
|
+
}
|
|
330
|
+
this.animatePositions(startPositions, targetPositions, duration);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* 将指定楼层以上的楼层向指定方向移动
|
|
335
|
+
* @param targetFloor 目标楼层
|
|
336
|
+
* @param animation 动画选项
|
|
337
|
+
*/
|
|
338
|
+
}, {
|
|
339
|
+
key: "moveAboveFloorsDirection",
|
|
340
|
+
value: function moveAboveFloorsDirection(targetFloor, animation) {
|
|
341
|
+
var _ref = animation.rule || {},
|
|
342
|
+
_ref$direction = _ref.direction,
|
|
343
|
+
direction = _ref$direction === void 0 ? [10, 10, 0] : _ref$direction;
|
|
344
|
+
var duration = animation.duration;
|
|
345
|
+
|
|
346
|
+
// 重置所有楼层可见性
|
|
347
|
+
var _iterator8 = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
348
|
+
_step8;
|
|
349
|
+
try {
|
|
350
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
351
|
+
var floorGroup = _step8.value;
|
|
352
|
+
var _iterator10 = _createForOfIteratorHelper(floorGroup.components),
|
|
353
|
+
_step10;
|
|
354
|
+
try {
|
|
355
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
356
|
+
var component = _step10.value;
|
|
357
|
+
component.mesh.visible = true;
|
|
358
|
+
}
|
|
359
|
+
} catch (err) {
|
|
360
|
+
_iterator10.e(err);
|
|
361
|
+
} finally {
|
|
362
|
+
_iterator10.f();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// 计算起始位置和目标位置
|
|
367
|
+
} catch (err) {
|
|
368
|
+
_iterator8.e(err);
|
|
369
|
+
} finally {
|
|
370
|
+
_iterator8.f();
|
|
371
|
+
}
|
|
372
|
+
var startPositions = new Map();
|
|
373
|
+
var targetPositions = new Map();
|
|
374
|
+
var _iterator9 = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
375
|
+
_step9;
|
|
376
|
+
try {
|
|
377
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
378
|
+
var _floorGroup2 = _step9.value;
|
|
379
|
+
var floorLevel = _floorGroup2.level;
|
|
380
|
+
var _iterator11 = _createForOfIteratorHelper(_floorGroup2.components),
|
|
381
|
+
_step11;
|
|
382
|
+
try {
|
|
383
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
384
|
+
var _component3 = _step11.value;
|
|
385
|
+
startPositions.set(_component3.mesh, _component3.mesh.position.clone());
|
|
386
|
+
if (floorLevel > targetFloor) {
|
|
387
|
+
// 上方楼层需要移动
|
|
388
|
+
var targetPos = _component3.originalPosition.clone().add(new Vector3().fromArray(direction));
|
|
389
|
+
targetPositions.set(_component3.mesh, targetPos);
|
|
390
|
+
} else {
|
|
391
|
+
// 其他楼层保持原位
|
|
392
|
+
targetPositions.set(_component3.mesh, _component3.originalPosition.clone());
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
} catch (err) {
|
|
396
|
+
_iterator11.e(err);
|
|
397
|
+
} finally {
|
|
398
|
+
_iterator11.f();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// 执行动画
|
|
403
|
+
} catch (err) {
|
|
404
|
+
_iterator9.e(err);
|
|
405
|
+
} finally {
|
|
406
|
+
_iterator9.f();
|
|
407
|
+
}
|
|
408
|
+
this.animatePositions(startPositions, targetPositions, duration);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* 计算方向向量
|
|
413
|
+
* 规则:往右方(X)、前方(Z)是正、往左方(X)、后方(Z)是负数
|
|
414
|
+
* @param direction 方向枚举
|
|
415
|
+
* @param distance 移动距离
|
|
416
|
+
* @returns Vector3 方向向量
|
|
417
|
+
*/
|
|
418
|
+
}, {
|
|
419
|
+
key: "getDirectionVector",
|
|
420
|
+
value: function getDirectionVector(direction, distance) {
|
|
421
|
+
var vector = new Vector3(0, 0, 0);
|
|
422
|
+
var coefficient = 0.7071; // cos(45°) ≈ 0.7071
|
|
423
|
+
switch (direction) {
|
|
424
|
+
case EDirection.Right:
|
|
425
|
+
vector.set(distance, 0, 0);
|
|
426
|
+
break;
|
|
427
|
+
case EDirection.Left:
|
|
428
|
+
vector.set(-distance, 0, 0);
|
|
429
|
+
break;
|
|
430
|
+
case EDirection.Front:
|
|
431
|
+
vector.set(0, 0, distance);
|
|
432
|
+
break;
|
|
433
|
+
case EDirection.Back:
|
|
434
|
+
vector.set(0, 0, -distance);
|
|
435
|
+
break;
|
|
436
|
+
case EDirection.Right_Front:
|
|
437
|
+
vector.set(distance * coefficient, distance * coefficient, distance * coefficient);
|
|
438
|
+
break;
|
|
439
|
+
case EDirection.Left_Front:
|
|
440
|
+
vector.set(-distance * coefficient, distance * coefficient, distance * coefficient);
|
|
441
|
+
break;
|
|
442
|
+
case EDirection.Right_Back:
|
|
443
|
+
vector.set(distance * coefficient, distance * coefficient, -distance * coefficient);
|
|
444
|
+
break;
|
|
445
|
+
case EDirection.Left_Back:
|
|
446
|
+
vector.set(-distance * coefficient, distance * coefficient, -distance * coefficient);
|
|
447
|
+
break;
|
|
448
|
+
default:
|
|
449
|
+
// 默认向右移动
|
|
450
|
+
vector.set(distance, 0, 0);
|
|
451
|
+
}
|
|
452
|
+
return vector;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* 只显示指定楼层
|
|
457
|
+
* @param targetFloor 目标楼层
|
|
458
|
+
*/
|
|
459
|
+
}, {
|
|
460
|
+
key: "showSoloFloor",
|
|
461
|
+
value: function showSoloFloor(targetFloor) {
|
|
462
|
+
var _iterator12 = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
463
|
+
_step12;
|
|
464
|
+
try {
|
|
465
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
466
|
+
var floorGroup = _step12.value;
|
|
467
|
+
var floorLevel = floorGroup.level;
|
|
468
|
+
|
|
469
|
+
// 重置所有楼层组件位置
|
|
470
|
+
var _iterator13 = _createForOfIteratorHelper(floorGroup.components),
|
|
471
|
+
_step13;
|
|
472
|
+
try {
|
|
473
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
474
|
+
var component = _step13.value;
|
|
475
|
+
component.mesh.position.copy(component.originalPosition);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
// 设置可见性
|
|
479
|
+
} catch (err) {
|
|
480
|
+
_iterator13.e(err);
|
|
481
|
+
} finally {
|
|
482
|
+
_iterator13.f();
|
|
483
|
+
}
|
|
484
|
+
var shouldBeVisible = floorLevel === targetFloor;
|
|
485
|
+
var _iterator14 = _createForOfIteratorHelper(floorGroup.components),
|
|
486
|
+
_step14;
|
|
487
|
+
try {
|
|
488
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
489
|
+
var _component4 = _step14.value;
|
|
490
|
+
_component4.mesh.visible = shouldBeVisible;
|
|
491
|
+
}
|
|
492
|
+
} catch (err) {
|
|
493
|
+
_iterator14.e(err);
|
|
494
|
+
} finally {
|
|
495
|
+
_iterator14.f();
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
} catch (err) {
|
|
499
|
+
_iterator12.e(err);
|
|
500
|
+
} finally {
|
|
501
|
+
_iterator12.f();
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* 执行位置动画
|
|
507
|
+
* @param startPositions 起始位置
|
|
508
|
+
* @param targetPositions 目标位置
|
|
509
|
+
* @param duration 动画时长
|
|
510
|
+
*/
|
|
511
|
+
}, {
|
|
512
|
+
key: "animatePositions",
|
|
513
|
+
value: function animatePositions(startPositions, targetPositions, duration) {
|
|
514
|
+
var _this3 = this;
|
|
515
|
+
var startTime = performance.now();
|
|
516
|
+
var animate = function animate() {
|
|
517
|
+
var currentTime = performance.now();
|
|
518
|
+
var elapsed = currentTime - startTime;
|
|
519
|
+
var progress = Math.min(elapsed / duration, 1);
|
|
520
|
+
targetPositions.forEach(function (targetPos, mesh) {
|
|
521
|
+
var startPos = startPositions.get(mesh);
|
|
522
|
+
if (startPos) {
|
|
523
|
+
// 线性插值计算当前位置
|
|
524
|
+
mesh.position.lerpVectors(startPos, targetPos, progress);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
if (progress < 1) {
|
|
528
|
+
requestAnimationFrame(animate);
|
|
529
|
+
} else {
|
|
530
|
+
// 动画结束
|
|
531
|
+
_this3.currentAnimation.timer = null;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
animate();
|
|
535
|
+
|
|
536
|
+
// 设置超时以确保动画完成
|
|
537
|
+
this.currentAnimation.timer = window.setTimeout(function () {
|
|
538
|
+
_this3.currentAnimation.timer = null;
|
|
539
|
+
}, duration + 100);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* 重置建筑到初始状态
|
|
544
|
+
*/
|
|
545
|
+
}, {
|
|
546
|
+
key: "resetBuilding",
|
|
547
|
+
value: function resetBuilding() {
|
|
548
|
+
var _iterator15 = _createForOfIteratorHelper(this.floorGroups.values()),
|
|
549
|
+
_step15;
|
|
550
|
+
try {
|
|
551
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
552
|
+
var floorGroup = _step15.value;
|
|
553
|
+
var _iterator16 = _createForOfIteratorHelper(floorGroup.components),
|
|
554
|
+
_step16;
|
|
555
|
+
try {
|
|
556
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
557
|
+
var component = _step16.value;
|
|
558
|
+
// 恢复原始位置
|
|
559
|
+
component.mesh.position.copy(component.originalPosition);
|
|
560
|
+
|
|
561
|
+
// 恢复原始可见性
|
|
562
|
+
component.mesh.visible = component.originalVisibility;
|
|
563
|
+
}
|
|
564
|
+
} catch (err) {
|
|
565
|
+
_iterator16.e(err);
|
|
566
|
+
} finally {
|
|
567
|
+
_iterator16.f();
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
} catch (err) {
|
|
571
|
+
_iterator15.e(err);
|
|
572
|
+
} finally {
|
|
573
|
+
_iterator15.f();
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* 获取楼层总数信息
|
|
579
|
+
*/
|
|
580
|
+
}, {
|
|
581
|
+
key: "getFloorCounts",
|
|
582
|
+
value: function getFloorCounts() {
|
|
583
|
+
return {
|
|
584
|
+
aboveGround: this.aboveGroundFloorCount,
|
|
585
|
+
underground: this.undergroundFloorCount,
|
|
586
|
+
hasRoof: this.hasRoof
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
}]);
|
|
590
|
+
return BuildingSplit;
|
|
591
|
+
}(ObjectLayer);
|
|
592
|
+
export { BuildingSplit, EBuildingSplitType };
|
|
593
|
+
//# sourceMappingURL=index.js.map
|