@realsee/dnalogel 2.0.0-alpha.26 → 2.0.0-alpha.28
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/CHANGELOG.md +6 -0
- package/dist/CSS3DRenderPlugin/Plugin.d.ts +49 -0
- package/dist/CSS3DRenderPlugin/index.d.ts +3 -48
- package/dist/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
- package/dist/CameraMovementPlugin/index.d.ts +4 -6
- package/dist/CameraMovementPlugin/index.js +12 -12
- package/dist/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
- package/dist/ModelChassisCompassPlugin/index.d.ts +3 -18
- package/dist/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
- package/dist/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
- package/dist/ModelEntryDoorGuidePlugin/index.js +0 -5
- package/dist/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
- package/dist/ModelItemLabelPlugin/index.d.ts +8 -3
- package/dist/ModelItemLabelPlugin/index.js +13 -7
- package/dist/ModelTVVideoPlugin/Plugin.d.ts +4 -0
- package/dist/ModelTVVideoPlugin/index.d.ts +4 -3
- package/dist/ModelTVVideoPlugin/index.js +3 -3
- package/dist/ModelViewPlugin/Plugin.d.ts +17 -0
- package/dist/ModelViewPlugin/index.d.ts +3 -16
- package/dist/PanoCompassPlugin/Plugin.d.ts +47 -0
- package/dist/PanoCompassPlugin/index.d.ts +4 -47
- package/dist/PanoCompassPlugin/index.js +5 -4
- package/dist/PanoMeasurePlugin/index.d.ts +1 -1
- package/dist/PanoMeasurePlugin/index.js +4 -1
- package/dist/PanoRulerPlugin/Plugin.d.ts +31 -0
- package/dist/PanoRulerPlugin/index.d.ts +4 -30
- package/dist/PanoRulerPlugin/index.js +0 -5
- package/dist/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
- package/dist/PanoSpatialTagPlugin/index.d.ts +4 -32
- package/dist/PanoSpatialTagPlugin/index.js +23 -21
- package/dist/_index.d.ts +30 -0
- package/dist/floorplan/index.d.ts +6 -0
- package/dist/index.d.ts +15 -30
- package/dist/index.es.js +149 -22
- package/dist/index.js +177 -43
- package/dist/index.umd.js +180 -47
- package/docs/assets/search.js +1 -1
- package/docs/classes/ModelRoomLabelController.html +5 -8
- package/docs/classes/PanoFloorplanRadarPluginController.html +3 -0
- package/docs/enums/CameraMovementEffect.html +3 -0
- package/docs/enums/DIRECTION.html +1 -0
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -0
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ModelFloorplanErrorType.html +1 -1
- package/docs/enums/Rotation.html +3 -0
- package/docs/index.html +2 -2
- package/docs/interfaces/CSS3DRenderPluginExportType.html +4 -0
- package/docs/interfaces/CameraMovementPluginExportType.html +17 -0
- package/docs/interfaces/FloorplanBounding.html +10 -0
- package/docs/interfaces/FloorplanData.html +3 -0
- package/docs/interfaces/FloorplanEntrance.html +15 -0
- package/docs/interfaces/FloorplanExtraObject.html +7 -0
- package/docs/interfaces/FloorplanExtraObject3D.html +3 -0
- package/docs/interfaces/FloorplanFloorData.html +3 -0
- package/docs/interfaces/FloorplanImagePosition.html +3 -0
- package/docs/interfaces/FloorplanObserver.html +5 -0
- package/docs/interfaces/FloorplanOutlineItem.html +3 -0
- package/docs/interfaces/FloorplanPosition.html +3 -0
- package/docs/interfaces/FloorplanRoomItem.html +17 -0
- package/docs/interfaces/FloorplanRoomLabelItem.html +7 -0
- package/docs/interfaces/FloorplanServerBounding.html +10 -0
- package/docs/interfaces/FloorplanServerComputedData.html +1 -0
- package/docs/interfaces/FloorplanServerData.html +3 -0
- package/docs/interfaces/FloorplanServerEntrance.html +15 -0
- package/docs/interfaces/FloorplanServerFloorData.html +3 -0
- package/docs/interfaces/FloorplanServerImagePosition.html +3 -0
- package/docs/interfaces/FloorplanServerObserver.html +5 -0
- package/docs/interfaces/FloorplanServerOutlineItem.html +3 -0
- package/docs/interfaces/FloorplanServerPosition.html +3 -0
- package/docs/interfaces/FloorplanServerRoomItem.html +20 -0
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +7 -0
- package/docs/interfaces/LineJson.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
- package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
- package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
- package/docs/interfaces/ModelFloorplanParameterType.html +1 -1
- package/docs/interfaces/ModelFloorplanViewEvent.html +3 -3
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -0
- package/docs/interfaces/PanoCompassPluginData.html +1 -1
- package/docs/interfaces/PanoCompassPluginParameterType.html +1 -1
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -0
- package/docs/interfaces/PanoFloorplanRadarPluginControllerParameter.html +1 -0
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -0
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -0
- package/docs/interfaces/Point.html +1 -0
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -0
- package/docs/interfaces/RoomInfo.html +1 -0
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/RoomRules.html +1 -0
- package/docs/interfaces/Rooms.html +1 -0
- package/docs/interfaces/TopviewFloorplanPluginParameterType.html +10 -10
- package/docs/modules.html +28 -12
- package/libs/CSS3DRenderPlugin/Plugin.d.ts +49 -0
- package/libs/CSS3DRenderPlugin/Plugin.js +182 -0
- package/libs/CSS3DRenderPlugin/index.d.ts +3 -48
- package/libs/CSS3DRenderPlugin/index.js +2 -181
- package/libs/CameraMovementPlugin/CameraMovementPlugin.d.ts +7 -0
- package/libs/CameraMovementPlugin/CameraMovementPlugin.js +159 -0
- package/libs/CameraMovementPlugin/index.d.ts +4 -6
- package/libs/CameraMovementPlugin/index.js +3 -158
- package/libs/ModelChassisCompassPlugin/Plugin.d.ts +19 -0
- package/libs/ModelChassisCompassPlugin/Plugin.js +75 -0
- package/libs/ModelChassisCompassPlugin/index.d.ts +3 -18
- package/libs/ModelChassisCompassPlugin/index.js +2 -74
- package/libs/ModelEntryDoorGuidePlugin/Plugin.d.ts +26 -0
- package/libs/ModelEntryDoorGuidePlugin/Plugin.js +140 -0
- package/libs/ModelEntryDoorGuidePlugin/index.d.ts +3 -25
- package/libs/ModelEntryDoorGuidePlugin/index.js +2 -139
- package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.d.ts +4 -0
- package/libs/ModelItemLabelPlugin/ModelItemLabelPlugin.js +120 -0
- package/libs/ModelItemLabelPlugin/index.d.ts +8 -3
- package/libs/ModelItemLabelPlugin/index.js +7 -119
- package/libs/ModelTVVideoPlugin/Plugin.d.ts +4 -0
- package/libs/ModelTVVideoPlugin/Plugin.js +254 -0
- package/libs/ModelTVVideoPlugin/index.d.ts +4 -3
- package/libs/ModelTVVideoPlugin/index.js +3 -253
- package/libs/ModelViewPlugin/Plugin.d.ts +17 -0
- package/libs/ModelViewPlugin/Plugin.js +160 -0
- package/libs/ModelViewPlugin/index.d.ts +3 -16
- package/libs/ModelViewPlugin/index.js +2 -159
- package/libs/PanoCompassPlugin/Plugin.d.ts +47 -0
- package/libs/PanoCompassPlugin/Plugin.js +249 -0
- package/libs/PanoCompassPlugin/index.d.ts +4 -47
- package/libs/PanoCompassPlugin/index.js +3 -249
- package/libs/PanoMeasurePlugin/index.d.ts +1 -1
- package/libs/PanoMeasurePlugin/index.js +1 -1
- package/libs/PanoRulerPlugin/Plugin.d.ts +31 -0
- package/libs/PanoRulerPlugin/Plugin.js +402 -0
- package/libs/PanoRulerPlugin/index.d.ts +4 -30
- package/libs/PanoRulerPlugin/index.js +2 -401
- package/libs/PanoSpatialTagPlugin/Plugin.d.ts +33 -0
- package/libs/PanoSpatialTagPlugin/Plugin.js +415 -0
- package/libs/PanoSpatialTagPlugin/index.d.ts +4 -32
- package/libs/PanoSpatialTagPlugin/index.js +4 -412
- package/libs/_index.d.ts +30 -0
- package/libs/_index.js +18 -0
- package/libs/floorplan/index.d.ts +6 -0
- package/libs/floorplan/index.js +7 -0
- package/libs/index.d.ts +15 -30
- package/libs/index.js +25 -17
- package/package.json +5 -4
|
@@ -1,402 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { intersectionOfLine } from '../shared-utils/math/planimetry';
|
|
4
|
-
import { nextFrame } from '../shared-utils/nextFrame';
|
|
5
|
-
import throttle from '../shared-utils/throttle';
|
|
6
|
-
import PanoRulerStyle from './style';
|
|
7
|
-
const getDistance = (p1, p2) => {
|
|
8
|
-
return Math.sqrt(Math.pow(p1.z - p2.z, 2) + Math.pow(p1.x - p2.x, 2));
|
|
9
|
-
};
|
|
10
|
-
const getRoomHeightInfo = (roomInfo, five) => {
|
|
11
|
-
const roomHeightInfo = {};
|
|
12
|
-
const raycaster = new Raycaster();
|
|
13
|
-
const work = five.work;
|
|
14
|
-
if (!work)
|
|
15
|
-
return roomHeightInfo;
|
|
16
|
-
const observers = roomInfo.observers;
|
|
17
|
-
work.observers.forEach((observer, index) => {
|
|
18
|
-
const { standingPosition: position } = observer;
|
|
19
|
-
const point = new Vector3(position.x, position.y, position.z);
|
|
20
|
-
raycaster.set(point, new Vector3(0, 1, 0));
|
|
21
|
-
const [intersection] = five.model.intersectRaycaster(raycaster);
|
|
22
|
-
// 虚景 VR 没有天花板碰撞射线无相交,默认固定层高2.7m
|
|
23
|
-
const verticalY = intersection ? intersection.point.y : 2.7;
|
|
24
|
-
const id = observers[index];
|
|
25
|
-
if (!id)
|
|
26
|
-
return roomHeightInfo;
|
|
27
|
-
const observerRoomName = roomInfo.rooms[id].name;
|
|
28
|
-
if (roomHeightInfo[observerRoomName] === undefined) {
|
|
29
|
-
roomHeightInfo[observerRoomName] = {
|
|
30
|
-
__roof: [verticalY],
|
|
31
|
-
__floor: [point.y],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
roomHeightInfo[observerRoomName].__roof.push(verticalY);
|
|
36
|
-
roomHeightInfo[observerRoomName].__floor.push(point.y);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
// 地板高度求中位数,屋顶高度取最高
|
|
40
|
-
for (const roomName in roomHeightInfo) {
|
|
41
|
-
const room = roomHeightInfo[roomName];
|
|
42
|
-
room.__roof.sort();
|
|
43
|
-
room.__floor.sort();
|
|
44
|
-
room.floor = room.__floor[~~(room.__floor.length / 2)];
|
|
45
|
-
room.roof = room.__roof[room.__roof.length - 1];
|
|
46
|
-
}
|
|
47
|
-
return roomHeightInfo;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* 全景标尺插件
|
|
51
|
-
*/
|
|
52
|
-
export const PanoRulerPlugin = (five, params) => {
|
|
53
|
-
const state = {
|
|
54
|
-
enable: false,
|
|
55
|
-
loaded: false,
|
|
56
|
-
options: params.options || {
|
|
57
|
-
distanceText: (distance) => `${distance.toFixed(1)}m`,
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
const tpl = (name, distance) => {
|
|
61
|
-
const domStr = `
|
|
62
|
-
<div class="PanoRulerPlugin-rule-line">
|
|
63
|
-
<em></em>
|
|
64
|
-
<div class="PanoRulerPlugin-rule-label">
|
|
65
|
-
<div class="PanoRulerPlugin-rule-label-name">${state.options.distanceText(distance)}</div>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
`;
|
|
69
|
-
const res = document.createElement('div');
|
|
70
|
-
res.setAttribute('class', 'PanoRulerPlugin-rule');
|
|
71
|
-
res.setAttribute('data-name', name);
|
|
72
|
-
res.setAttribute('style', 'display: none');
|
|
73
|
-
res.innerHTML = domStr;
|
|
74
|
-
return res;
|
|
75
|
-
};
|
|
76
|
-
const $rule = document.createElement('div');
|
|
77
|
-
$rule.setAttribute('style', `position: absolute;pointer-events: none;width: 100%;height: 100%;left: 0;top: 0;overflow: hidden;`);
|
|
78
|
-
// 添加标尺样式
|
|
79
|
-
const style = document.createElement('div');
|
|
80
|
-
style.innerHTML = PanoRulerStyle;
|
|
81
|
-
$rule.appendChild(style);
|
|
82
|
-
const __rule = {};
|
|
83
|
-
const _load = (roomInfo, roomRules) => {
|
|
84
|
-
// if (state.loaded) {
|
|
85
|
-
// throw new Error('标尺被重复初始化!')
|
|
86
|
-
// }
|
|
87
|
-
const roomHeightInfo = getRoomHeightInfo(roomInfo, five);
|
|
88
|
-
const work = five.work;
|
|
89
|
-
if (!work)
|
|
90
|
-
return false;
|
|
91
|
-
for (const obKey in roomRules) {
|
|
92
|
-
const points = roomRules[obKey];
|
|
93
|
-
const { standingPosition: defaultPosition } = work.observers[0];
|
|
94
|
-
const roomPoints = points.map(({ x, z, observers }) => {
|
|
95
|
-
const pointRoomName = observers.length > 0 ? roomInfo.rooms[roomInfo.observers[observers[0]]].name : '';
|
|
96
|
-
const medianFloorHeight = roomHeightInfo[pointRoomName] ? roomHeightInfo[pointRoomName].floor : null;
|
|
97
|
-
let minDistance = Infinity;
|
|
98
|
-
let nearestPoint = {
|
|
99
|
-
index: 0,
|
|
100
|
-
x: defaultPosition.x,
|
|
101
|
-
y: defaultPosition.y,
|
|
102
|
-
z: defaultPosition.z,
|
|
103
|
-
};
|
|
104
|
-
observers.forEach((index) => {
|
|
105
|
-
if (!work.observers[index])
|
|
106
|
-
return;
|
|
107
|
-
const { standingPosition: position } = work.observers[index];
|
|
108
|
-
const observerPoint = {
|
|
109
|
-
index,
|
|
110
|
-
x: position.x,
|
|
111
|
-
y: position.y,
|
|
112
|
-
z: position.z,
|
|
113
|
-
};
|
|
114
|
-
const distance = getDistance({ x, z }, observerPoint);
|
|
115
|
-
if (medianFloorHeight) {
|
|
116
|
-
// 取最近点时排除高度与房间平均高度差大于0.3米的点
|
|
117
|
-
if (distance < minDistance && Math.abs(observerPoint.y - medianFloorHeight) < 0.3) {
|
|
118
|
-
minDistance = distance;
|
|
119
|
-
nearestPoint = observerPoint;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
if (distance < minDistance) {
|
|
124
|
-
minDistance = distance;
|
|
125
|
-
nearestPoint = observerPoint;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
const _origin = new Vector3(x, nearestPoint.y, z);
|
|
130
|
-
Object.assign(_origin, { observers });
|
|
131
|
-
const verticalY = roomHeightInfo[pointRoomName] ? roomHeightInfo[pointRoomName].roof : null;
|
|
132
|
-
const _vertical = !verticalY ? null : new Vector3(x, verticalY, z);
|
|
133
|
-
if (_vertical)
|
|
134
|
-
Object.assign(_vertical, { observers });
|
|
135
|
-
const origin = _origin;
|
|
136
|
-
const vertical = _vertical;
|
|
137
|
-
return { origin, vertical };
|
|
138
|
-
});
|
|
139
|
-
__rule[obKey] = {
|
|
140
|
-
origins: roomPoints.map((roomPoint) => roomPoint.origin),
|
|
141
|
-
rules: [],
|
|
142
|
-
};
|
|
143
|
-
for (const { origin, vertical } of roomPoints) {
|
|
144
|
-
if (!vertical)
|
|
145
|
-
continue;
|
|
146
|
-
const $element = tpl(obKey, origin.distanceTo(vertical));
|
|
147
|
-
$rule.append($element);
|
|
148
|
-
__rule[obKey].rules.push({ vertical: true, rule: [origin, vertical], $element });
|
|
149
|
-
}
|
|
150
|
-
for (let index = 0; index < roomPoints.length; index++) {
|
|
151
|
-
let nextIndex = index + 1;
|
|
152
|
-
if (nextIndex >= roomPoints.length)
|
|
153
|
-
nextIndex = 0;
|
|
154
|
-
const { origin } = roomPoints[index];
|
|
155
|
-
const { origin: next } = roomPoints[nextIndex];
|
|
156
|
-
const $element = tpl(obKey, origin.distanceTo(next));
|
|
157
|
-
$rule.append($element);
|
|
158
|
-
__rule[obKey].rules.push({ vertical: false, rule: [origin, next], $element });
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
state.loaded = true;
|
|
162
|
-
freshRule();
|
|
163
|
-
return true;
|
|
164
|
-
};
|
|
165
|
-
const load = async (_roomInfo, _roomRules, options) => {
|
|
166
|
-
const roomInfo = _roomInfo || params.roomInfo;
|
|
167
|
-
const roomRules = _roomRules || params.roomRules;
|
|
168
|
-
if (!roomInfo || !roomRules) {
|
|
169
|
-
throw new Error('标尺数据依赖不齐全!');
|
|
170
|
-
}
|
|
171
|
-
state.loaded = false;
|
|
172
|
-
state.options = Object.assign({}, state.options, options || {});
|
|
173
|
-
if (five.model.loaded) {
|
|
174
|
-
return _load(roomInfo, roomRules);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
return await new Promise((resolve) => five.once('modelLoaded', () => resolve(_load(roomInfo, roomRules))));
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
if (params.roomInfo && params.roomRules) {
|
|
181
|
-
load(params.roomInfo, params.roomRules);
|
|
182
|
-
}
|
|
183
|
-
const getRuleScreenIntr = (startPoint, endPoint, canvasWidth, canvasHeight) => {
|
|
184
|
-
const screenLines = [
|
|
185
|
-
[
|
|
186
|
-
{ x: 0, y: 0 },
|
|
187
|
-
{ x: canvasWidth, y: 0 },
|
|
188
|
-
],
|
|
189
|
-
[
|
|
190
|
-
{ x: 0, y: 0 },
|
|
191
|
-
{ x: 0, y: canvasHeight },
|
|
192
|
-
],
|
|
193
|
-
[
|
|
194
|
-
{ x: canvasWidth, y: 0 },
|
|
195
|
-
{ x: canvasWidth, y: canvasHeight },
|
|
196
|
-
],
|
|
197
|
-
[
|
|
198
|
-
{ x: 0, y: canvasHeight },
|
|
199
|
-
{ x: canvasWidth, y: canvasHeight },
|
|
200
|
-
],
|
|
201
|
-
];
|
|
202
|
-
const intr = [];
|
|
203
|
-
for (let i = 0; i < screenLines.length; i++) {
|
|
204
|
-
const result = intersectionOfLine([startPoint, endPoint], [screenLines[i][0], screenLines[i][1]], true);
|
|
205
|
-
if (result)
|
|
206
|
-
intr.push(result);
|
|
207
|
-
}
|
|
208
|
-
if (intr.length === 0)
|
|
209
|
-
return false;
|
|
210
|
-
else {
|
|
211
|
-
return intr;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const freshRule = () => {
|
|
215
|
-
var _a;
|
|
216
|
-
const element = (_a = five.getElement()) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
217
|
-
if (!element)
|
|
218
|
-
return;
|
|
219
|
-
if (!state.loaded)
|
|
220
|
-
return;
|
|
221
|
-
if (Object.keys(__rule).length <= 0)
|
|
222
|
-
return;
|
|
223
|
-
const { panoIndex, camera, currentMode } = five;
|
|
224
|
-
if (panoIndex === undefined)
|
|
225
|
-
return;
|
|
226
|
-
let name;
|
|
227
|
-
for (const _name in __rule) {
|
|
228
|
-
if (_name.split(',').indexOf(panoIndex.toString()) >= 0)
|
|
229
|
-
name = _name;
|
|
230
|
-
}
|
|
231
|
-
if (!name)
|
|
232
|
-
return;
|
|
233
|
-
const cameraPosition = camera.position;
|
|
234
|
-
const cameraDirection = camera.getWorldDirection(new Vector3());
|
|
235
|
-
const width = element.clientWidth;
|
|
236
|
-
const height = element.clientHeight;
|
|
237
|
-
// 非全景模式下隐藏所有标尺
|
|
238
|
-
if (currentMode !== Five.Mode.Panorama) {
|
|
239
|
-
for (const _name in __rule) {
|
|
240
|
-
for (const { $element } of __rule[_name].rules) {
|
|
241
|
-
$element.style.display = 'none';
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
// 隐藏非当前点位的标尺
|
|
247
|
-
for (const _name in __rule) {
|
|
248
|
-
for (const { $element } of __rule[_name].rules) {
|
|
249
|
-
$element.style.display = _name === name ? 'block' : 'none';
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
const verticalLines = [];
|
|
253
|
-
// 可以看到的角度最小的拐点
|
|
254
|
-
const [visibleOrigin] = __rule[name].origins
|
|
255
|
-
.slice()
|
|
256
|
-
.filter((point) => point.observers.indexOf(panoIndex) >= 0)
|
|
257
|
-
.sort((pointA, pointB) => {
|
|
258
|
-
const angleA = pointA.clone().setY(0).sub(cameraPosition).normalize().angleTo(cameraDirection.clone().setY(0));
|
|
259
|
-
const angleB = pointB.clone().setY(0).sub(cameraPosition).normalize().angleTo(cameraDirection.clone().setY(0));
|
|
260
|
-
return angleA - angleB;
|
|
261
|
-
});
|
|
262
|
-
const shownNotVerticalRules = [];
|
|
263
|
-
for (const { rule, vertical, $element } of __rule[name].rules) {
|
|
264
|
-
const [start, end] = rule;
|
|
265
|
-
const $line = $element.querySelector('.PanoRulerPlugin-rule-line');
|
|
266
|
-
if (!$line)
|
|
267
|
-
return;
|
|
268
|
-
if (!visibleOrigin) {
|
|
269
|
-
$element.style.display = 'none';
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
272
|
-
if (start !== visibleOrigin && end !== visibleOrigin) {
|
|
273
|
-
$element.style.display = 'none';
|
|
274
|
-
continue;
|
|
275
|
-
}
|
|
276
|
-
if (start.distanceTo(end) < 0.5) {
|
|
277
|
-
$element.style.display = 'none';
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
if (start.observers.indexOf(panoIndex) === -1 || end.observers.indexOf(panoIndex) === -1) {
|
|
281
|
-
$element.style.display = 'none';
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
const startAngle = start.clone().sub(cameraPosition).normalize().angleTo(cameraDirection);
|
|
285
|
-
if (startAngle > Math.PI / 2) {
|
|
286
|
-
$element.style.display = 'none';
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
const endAngle = end.clone().sub(cameraPosition).normalize().angleTo(cameraDirection);
|
|
290
|
-
if (endAngle > Math.PI / 2) {
|
|
291
|
-
$element.style.display = 'none';
|
|
292
|
-
continue;
|
|
293
|
-
}
|
|
294
|
-
const ruleLength = start.distanceTo(end);
|
|
295
|
-
const midPoint = end.clone().sub(end.clone().sub(start).divide(new Vector3(2, 2, 2)));
|
|
296
|
-
const disFromCameraToMid = midPoint.distanceTo(cameraPosition);
|
|
297
|
-
if (disFromCameraToMid / ruleLength > 8) {
|
|
298
|
-
$element.style.display = 'none';
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
if (!vertical)
|
|
302
|
-
shownNotVerticalRules.push(rule);
|
|
303
|
-
if (vertical)
|
|
304
|
-
verticalLines.push({ $element, startAngle });
|
|
305
|
-
const mouseStart = start.clone().project(camera);
|
|
306
|
-
const startLeft = ((mouseStart.x + 1) / 2) * width;
|
|
307
|
-
const startTop = ((-mouseStart.y + 1) / 2) * height;
|
|
308
|
-
const mouseEnd = end.clone().project(camera);
|
|
309
|
-
const endLeft = ((mouseEnd.x + 1) / 2) * width;
|
|
310
|
-
const endTop = ((-mouseEnd.y + 1) / 2) * height;
|
|
311
|
-
const distance = Math.sqrt(Math.pow(endLeft - startLeft, 2) + Math.pow(endTop - startTop, 2));
|
|
312
|
-
let visibleLength = distance;
|
|
313
|
-
let labelOffset = 50;
|
|
314
|
-
const intr = getRuleScreenIntr({ x: ~~startLeft, y: ~~startTop }, {
|
|
315
|
-
x: ~~endLeft,
|
|
316
|
-
y: ~~endTop
|
|
317
|
-
}, width, height);
|
|
318
|
-
if (intr && intr.length === 1) {
|
|
319
|
-
if (visibleOrigin === start) {
|
|
320
|
-
visibleLength = Math.sqrt(Math.pow(intr[0].x - startLeft, 2) + Math.pow(intr[0].y - startTop, 2));
|
|
321
|
-
labelOffset = (visibleLength / distance) * 50;
|
|
322
|
-
}
|
|
323
|
-
else if (visibleOrigin === end) {
|
|
324
|
-
visibleLength = Math.sqrt(Math.pow(intr[0].x - endLeft, 2) + Math.pow(intr[0].y - endTop, 2));
|
|
325
|
-
labelOffset = 100 - (visibleLength / distance) * 50;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (intr && intr.length === 2) {
|
|
329
|
-
const middlePoint = {
|
|
330
|
-
x: (intr[0].x + intr[1].x) / 2,
|
|
331
|
-
y: (intr[0].y + intr[1].y) / 2,
|
|
332
|
-
};
|
|
333
|
-
const distanceFromStart = Math.sqrt(Math.pow(middlePoint.x - startLeft, 2) + Math.pow(middlePoint.y - startTop, 2));
|
|
334
|
-
labelOffset = (distanceFromStart / distance) * 100;
|
|
335
|
-
}
|
|
336
|
-
const rad = Math.PI / 2 - Math.atan2(endLeft - startLeft, startTop - endTop);
|
|
337
|
-
const deg = (rad / Math.PI) * 180;
|
|
338
|
-
const $label = $line.querySelector('.PanoRulerPlugin-rule-label');
|
|
339
|
-
// 线的长度小于标签时或者标签与线两端点重合时隐藏,
|
|
340
|
-
const labelWidth = $label.children[0].clientWidth;
|
|
341
|
-
if (labelWidth >= distance ||
|
|
342
|
-
labelWidth / 2 >= (labelOffset / 100) * distance ||
|
|
343
|
-
labelWidth / 2 >= (1 - labelOffset / 100) * distance) {
|
|
344
|
-
$line.style.display = 'none';
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
$line.style.display = 'block';
|
|
348
|
-
$line.style.width = distance + 'px';
|
|
349
|
-
$line.style.left = startLeft + 'px';
|
|
350
|
-
$line.style.top = startTop + 'px';
|
|
351
|
-
$line.style.transform = `rotate(${-deg}deg)`;
|
|
352
|
-
$label.style.left = `${labelOffset}%`;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
const nextFrameFreshRule = () => nextFrame(freshRule);
|
|
357
|
-
const throttleFreshRule = throttle(freshRule, 80);
|
|
358
|
-
const enable = () => {
|
|
359
|
-
var _a, _b;
|
|
360
|
-
if (!state.loaded)
|
|
361
|
-
return false;
|
|
362
|
-
if (state.enable)
|
|
363
|
-
return true;
|
|
364
|
-
$rule.setAttribute('class', 'PanoRulerPlugin' + (state.options.className ? ' ' + state.options.className : ''));
|
|
365
|
-
(_b = (_a = five.getElement()) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.append($rule);
|
|
366
|
-
freshRule();
|
|
367
|
-
five.on('panoArrived', freshRule);
|
|
368
|
-
five.on('modeChange', freshRule);
|
|
369
|
-
five.on('cameraDirectionUpdate', nextFrameFreshRule);
|
|
370
|
-
five.on('movingToPano', nextFrameFreshRule);
|
|
371
|
-
five.on('mouseWheel', throttleFreshRule);
|
|
372
|
-
five.on('pinchGesture', throttleFreshRule);
|
|
373
|
-
state.enable = true;
|
|
374
|
-
return true;
|
|
375
|
-
};
|
|
376
|
-
const disable = () => {
|
|
377
|
-
if (!state.enable)
|
|
378
|
-
return true;
|
|
379
|
-
five.off('panoArrived', freshRule);
|
|
380
|
-
five.off('modeChange', freshRule);
|
|
381
|
-
five.off('cameraDirectionUpdate', nextFrameFreshRule);
|
|
382
|
-
five.off('movingToPano', nextFrameFreshRule);
|
|
383
|
-
five.off('mouseWheel', throttleFreshRule);
|
|
384
|
-
five.off('pinchGesture', throttleFreshRule);
|
|
385
|
-
if ($rule) {
|
|
386
|
-
$rule.remove();
|
|
387
|
-
}
|
|
388
|
-
state.enable = false;
|
|
389
|
-
return true;
|
|
390
|
-
};
|
|
391
|
-
return {
|
|
392
|
-
enable,
|
|
393
|
-
disable,
|
|
394
|
-
load,
|
|
395
|
-
state,
|
|
396
|
-
};
|
|
397
|
-
};
|
|
398
|
-
export const panoRulerPluginServerParams = {
|
|
399
|
-
name: 'PanoRulerPlugin',
|
|
400
|
-
version: 0,
|
|
401
|
-
};
|
|
1
|
+
import PanoRulerPlugin from './Plugin';
|
|
2
|
+
export { PanoRulerPlugin };
|
|
402
3
|
export default PanoRulerPlugin;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { FivePlugin } from '@realsee/five';
|
|
2
|
+
import type { PanoSpatialTagPluginId, PanoSpatialTagPluginDataElement, PanoSpatialTagPluginContentReplacement, PanoSpatialTagPluginContentEvent } from './typings';
|
|
3
|
+
export interface PanoSpatialTagPluginData {
|
|
4
|
+
folded?: boolean;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
points: Array<PanoSpatialTagPluginDataElement>;
|
|
7
|
+
template: string;
|
|
8
|
+
events?: PanoSpatialTagPluginContentEvent;
|
|
9
|
+
render?: (template: string, replacement: PanoSpatialTagPluginContentReplacement) => string;
|
|
10
|
+
}
|
|
11
|
+
export interface PanoSpatialTagPluginParameterType {
|
|
12
|
+
container?: Element;
|
|
13
|
+
wait?: number;
|
|
14
|
+
maxNumberOnScreen?: number;
|
|
15
|
+
minRad?: number;
|
|
16
|
+
nearTolerance?: number;
|
|
17
|
+
upsideHeight?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface PanoSpatialTagPluginExportType {
|
|
20
|
+
load: (data: PanoSpatialTagPluginData) => void;
|
|
21
|
+
unfoldAll: () => void;
|
|
22
|
+
foldAll: () => void;
|
|
23
|
+
unfold: (id: PanoSpatialTagPluginId) => void;
|
|
24
|
+
fold: (id: PanoSpatialTagPluginId) => void;
|
|
25
|
+
enable: () => void;
|
|
26
|
+
disable: () => void;
|
|
27
|
+
dispose: () => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 空间游走标签插件
|
|
31
|
+
*/
|
|
32
|
+
export declare const PanoSpatialTagPlugin: FivePlugin<PanoSpatialTagPluginParameterType, PanoSpatialTagPluginExportType>;
|
|
33
|
+
export default PanoSpatialTagPlugin;
|