@realsee/dnalogel 0.1.0 → 0.1.4
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/data/8054djM0oR6ky3Ey8e.d.ts +55 -0
- package/data/8054djM0oR6ky3Ey8e.js +348 -0
- package/data/PrXel3aqGbp34JQn.js +10 -2
- package/data/XJ6NMLWnkAY3Rdx8.d.ts +843 -0
- package/data/XJ6NMLWnkAY3Rdx8.js +7987 -0
- package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.d.ts +85 -0
- package/data/jd6oMOzPxnQ3BvxY_B7yw51J9rXlhYhjhGTOgRVqu6WeEqjNX.js +509 -0
- package/data/vLykj3NWrllMrG06.d.ts +2 -0
- package/data/vLykj3NWrllMrG06.js +197 -2
- package/data/zxMawr9raSg8LYjG.d.ts +53 -0
- package/data/zxMawr9raSg8LYjG.js +588 -0
- package/package.json +3 -3
- package/plugins/AutoPreloadPlugin/index.d.ts +23 -0
- package/plugins/AutoPreloadPlugin/index.js +85 -0
- package/plugins/CSS3DRenderPlugin/index.d.ts +11 -11
- package/plugins/CSS3DRenderPlugin/index.js +170 -120
- package/plugins/ModelChassisCompassPlugin/index.d.ts +7 -3
- package/plugins/ModelChassisCompassPlugin/index.js +13 -26
- package/plugins/ModelEntryDoorGuidePlugin/index.d.ts +13 -1
- package/plugins/ModelEntryDoorGuidePlugin/index.js +212 -2
- package/plugins/ModelRoomLabelPlugin/Controller.d.ts +35 -0
- package/plugins/ModelRoomLabelPlugin/Controller.js +147 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItem.d.ts +8 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItem.js +48 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItems.d.ts +7 -0
- package/plugins/ModelRoomLabelPlugin/RoomLabelItems.js +149 -0
- package/plugins/ModelRoomLabelPlugin/index.d.ts +8 -0
- package/plugins/ModelRoomLabelPlugin/index.js +16 -0
- package/plugins/ModelRoomLabelPlugin/typings.d.ts +35 -0
- package/plugins/ModelRoomLabelPlugin/typings.js +5 -0
- package/plugins/ModelRoomLabelPlugin/utils/parseData.d.ts +3 -0
- package/plugins/ModelRoomLabelPlugin/utils/parseData.js +29 -0
- package/plugins/PanoMaskSelectorPlugin/compare.d.ts +1 -0
- package/plugins/PanoMaskSelectorPlugin/compare.js +15 -0
- package/plugins/PanoMaskSelectorPlugin/createBox.d.ts +7 -0
- package/plugins/PanoMaskSelectorPlugin/createBox.js +61 -0
- package/plugins/PanoMaskSelectorPlugin/createTextures.d.ts +3 -0
- package/plugins/PanoMaskSelectorPlugin/createTextures.js +29 -0
- package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -0
- package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +8 -0
- package/plugins/PanoMaskSelectorPlugin/index.d.ts +49 -0
- package/plugins/PanoMaskSelectorPlugin/index.js +272 -0
- package/plugins/PanoMaskSelectorPlugin/vertexShader.d.ts +1 -0
- package/plugins/PanoMaskSelectorPlugin/vertexShader.js +8 -0
- package/plugins/TreasurePlugin/Controller.d.ts +53 -12
- package/plugins/TreasurePlugin/Controller.js +129 -60
- package/plugins/TreasurePlugin/TreasureFaceAnime.d.ts +8 -6
- package/plugins/TreasurePlugin/TreasureFaceAnime.js +4 -4
- package/plugins/TreasurePlugin/TreasureObject.d.ts +30 -12
- package/plugins/TreasurePlugin/TreasureObject.js +269 -53
- package/plugins/TreasurePlugin/TreasureOpenAnime.d.ts +4 -2
- package/plugins/TreasurePlugin/TreasureOpenAnime.js +10 -5
- package/plugins/TreasurePlugin/constants.d.ts +32 -11
- package/plugins/TreasurePlugin/constants.js +52 -17
- package/plugins/TreasurePlugin/index.d.ts +5 -5
- package/plugins/TreasurePlugin/index.js +8 -0
- package/plugins/floorplan/ModelFloorplanPlugin/components/Camera.js +4 -2
- package/plugins/floorplan/ModelFloorplanPlugin/components/Compass.js +2 -1
- package/plugins/floorplan/ModelFloorplanPlugin/components/NowFloor/RoomLabels.js +5 -2
- package/plugins/floorplan/ModelFloorplanPlugin/components/index.js +1 -1
- package/plugins/floorplan/typings/floorplanData.d.ts +5 -1
- package/plugins/floorplan/utils/formatData.js +1 -22
- package/plugins/floorplan/utils/formatPosition.d.ts +4 -4
- package/shared-utils/createCanvasTextTexture.d.ts +8 -0
- package/shared-utils/createCanvasTextTexture.js +29 -0
- package/shared-utils/isNil.d.ts +10 -0
- package/shared-utils/isNil.js +24 -0
- package/shared-utils/three/getExtraModelLoader.d.ts +6 -0
- package/shared-utils/three/getExtraModelLoader.js +31 -0
- package/shared-utils/three/getTextureLoader.d.ts +6 -0
- package/shared-utils/three/getTextureLoader.js +34 -0
- package/shared-utils/three/loadFbxObj.d.ts +1 -2
- package/shared-utils/three/loadFbxObj.js +6 -2
- package/shared-utils/three/transformPositionToVector3.d.ts +7 -0
- package/shared-utils/three/{vecror3.js → transformPositionToVector3.js} +2 -2
- package/shared-utils/three/transfromToMeshBasicMaterial.d.ts +2 -0
- package/shared-utils/three/transfromToMeshBasicMaterial.js +27 -0
- package/shared-utils/to.d.ts +0 -1
- package/shared-utils/to.js +45 -7
- package/typedoc/plugins.d.ts +3 -1
- package/typedoc/plugins.js +63 -13
- package/typedoc/typings.d.ts +1 -1
- package/typings/math.type.d.ts +2 -2
- package/data/wYnRjQ4KZoV1yPoG.d.ts +0 -114
- package/data/wYnRjQ4KZoV1yPoG.js +0 -512
- package/plugins/PanoCursorRaycasterPlugin/utils/vecror3.d.ts +0 -7
- package/plugins/PanoCursorRaycasterPlugin/utils/vecror3.js +0 -18
- package/plugins/TreasurePlugin/treasureDataMap.d.ts +0 -7
- package/plugins/TreasurePlugin/treasureDataMap.js +0 -20
- package/plugins/TreasurePlugin/utils/loadTreasureTextures.d.ts +0 -7
- package/plugins/TreasurePlugin/utils/loadTreasureTextures.js +0 -115
- package/shared-utils/three/vecror3.d.ts +0 -7
|
@@ -1,15 +1,225 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = void 0;
|
|
7
9
|
|
|
10
|
+
var THREE = _interopRequireWildcard(require("three"));
|
|
11
|
+
|
|
12
|
+
var _FBXLoader = require("three/examples/jsm/loaders/FBXLoader");
|
|
13
|
+
|
|
14
|
+
var _createCanvasTextTexture = _interopRequireDefault(require("../../shared-utils/createCanvasTextTexture"));
|
|
15
|
+
|
|
16
|
+
var _transformPositionToVector = _interopRequireDefault(require("../../shared-utils/three/transformPositionToVector3"));
|
|
17
|
+
|
|
18
|
+
var _transfromToMeshBasicMaterial = _interopRequireDefault(require("../../shared-utils/three/transfromToMeshBasicMaterial"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
27
|
+
|
|
28
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
29
|
+
|
|
8
30
|
/**
|
|
9
31
|
* 模型入户门引导插件
|
|
10
32
|
*/
|
|
11
|
-
var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin() {
|
|
12
|
-
|
|
33
|
+
var ModelEntryDoorGuidePlugin = function ModelEntryDoorGuidePlugin(five, params) {
|
|
34
|
+
var _params$animationEnab, _params$position, _params$rad;
|
|
35
|
+
|
|
36
|
+
// 局部状态
|
|
37
|
+
var state = {};
|
|
38
|
+
var defaultAnimationEnable = (_params$animationEnab = params.animationEnabled) !== null && _params$animationEnab !== void 0 ? _params$animationEnab : true;
|
|
39
|
+
var defaultModelPosition = (_params$position = params.position) !== null && _params$position !== void 0 ? _params$position : undefined;
|
|
40
|
+
var defaultRad = (_params$rad = params.rad) !== null && _params$rad !== void 0 ? _params$rad : undefined;
|
|
41
|
+
var defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
|
|
42
|
+
var mixers = [];
|
|
43
|
+
|
|
44
|
+
var load = /*#__PURE__*/function () {
|
|
45
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(data) {
|
|
46
|
+
var _data$position, _data$position2, _data$rad, _data$fbx_url, _object$children, _object$children$, _object$children$$chi, _object$children$$chi2;
|
|
47
|
+
|
|
48
|
+
var modelPosition, rad, fbxUrl, object, textMesh;
|
|
49
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
50
|
+
while (1) {
|
|
51
|
+
switch (_context.prev = _context.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
if (!(((_data$position = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position !== void 0 ? _data$position : defaultModelPosition) === undefined)) {
|
|
54
|
+
_context.next = 2;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): position is undefined"));
|
|
59
|
+
|
|
60
|
+
case 2:
|
|
61
|
+
modelPosition = (0, _transformPositionToVector["default"])((_data$position2 = data === null || data === void 0 ? void 0 : data.position) !== null && _data$position2 !== void 0 ? _data$position2 : defaultModelPosition);
|
|
62
|
+
rad = (_data$rad = data === null || data === void 0 ? void 0 : data.rad) !== null && _data$rad !== void 0 ? _data$rad : defaultRad;
|
|
63
|
+
fbxUrl = (_data$fbx_url = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _data$fbx_url !== void 0 ? _data$fbx_url : defaultFbxUrl;
|
|
64
|
+
state.rad = rad;
|
|
65
|
+
|
|
66
|
+
if (!(rad === undefined)) {
|
|
67
|
+
_context.next = 8;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): rad is ".concat(rad)));
|
|
72
|
+
|
|
73
|
+
case 8:
|
|
74
|
+
_context.next = 10;
|
|
75
|
+
return new _FBXLoader.FBXLoader().loadAsync(fbxUrl);
|
|
76
|
+
|
|
77
|
+
case 10:
|
|
78
|
+
object = _context.sent;
|
|
79
|
+
// 设置位置
|
|
80
|
+
object.position.copy(modelPosition);
|
|
81
|
+
object.rotation.z = rad;
|
|
82
|
+
object.scale.set(0.8, 0.8, 0.8);
|
|
83
|
+
(0, _transfromToMeshBasicMaterial["default"])(object, {
|
|
84
|
+
transparent: true,
|
|
85
|
+
side: THREE.DoubleSide
|
|
86
|
+
});
|
|
87
|
+
textMesh = (_object$children = object.children) === null || _object$children === void 0 ? void 0 : (_object$children$ = _object$children[0]) === null || _object$children$ === void 0 ? void 0 : (_object$children$$chi = _object$children$.children) === null || _object$children$$chi === void 0 ? void 0 : (_object$children$$chi2 = _object$children$$chi[3]) === null || _object$children$$chi2 === void 0 ? void 0 : _object$children$$chi2.clone();
|
|
88
|
+
|
|
89
|
+
if (textMesh) {
|
|
90
|
+
_context.next = 18;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return _context.abrupt("return", Promise.reject("ModelEntryDoorGuidePlugin.load(): textMesh is ".concat(textMesh)));
|
|
95
|
+
|
|
96
|
+
case 18:
|
|
97
|
+
textMesh.material = new THREE.MeshBasicMaterial({
|
|
98
|
+
transparent: true,
|
|
99
|
+
map: (0, _createCanvasTextTexture["default"])('入户门')
|
|
100
|
+
});
|
|
101
|
+
textMesh.renderOrder = 3;
|
|
102
|
+
object.children[0].add(textMesh);
|
|
103
|
+
state.object = object;
|
|
104
|
+
return _context.abrupt("return", true);
|
|
105
|
+
|
|
106
|
+
case 23:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context.stop();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, _callee);
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
return function load(_x) {
|
|
115
|
+
return _ref.apply(this, arguments);
|
|
116
|
+
};
|
|
117
|
+
}();
|
|
118
|
+
|
|
119
|
+
var initAnimation = function initAnimation() {
|
|
120
|
+
if (state.animation) return;
|
|
121
|
+
if (!state.object) return console.error('ModelEntryDoorGuidePlugin.initAnimation(): state.object is ', state.object); // action
|
|
122
|
+
|
|
123
|
+
var animationSpeed = 1;
|
|
124
|
+
var mixer = new THREE.AnimationMixer(state.object);
|
|
125
|
+
mixers.push(mixer);
|
|
126
|
+
var action = mixer.clipAction(state.object.animations[0]);
|
|
127
|
+
action.timeScale = animationSpeed;
|
|
128
|
+
var stopAnimation;
|
|
129
|
+
|
|
130
|
+
var requestAnimationFrameLoop = function requestAnimationFrameLoop() {
|
|
131
|
+
var index = 0;
|
|
132
|
+
var oldTime = 0;
|
|
133
|
+
var minDeltaTime = 1000 / 30;
|
|
134
|
+
|
|
135
|
+
var animation = function animation(time) {
|
|
136
|
+
index = requestAnimationFrame(animation);
|
|
137
|
+
var deltaTime = time - oldTime;
|
|
138
|
+
if (deltaTime < minDeltaTime) return;
|
|
139
|
+
oldTime = time;
|
|
140
|
+
mixers.forEach(function (mixer) {
|
|
141
|
+
return mixer.update(deltaTime / 1000);
|
|
142
|
+
});
|
|
143
|
+
five.needsRender = true;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
index = requestAnimationFrame(animation);
|
|
147
|
+
return function () {
|
|
148
|
+
cancelAnimationFrame(index);
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
var play = function play() {
|
|
153
|
+
if (stopAnimation) return;
|
|
154
|
+
action.play();
|
|
155
|
+
stopAnimation = requestAnimationFrameLoop(); // 开始播动画时,rotation可能会还原
|
|
156
|
+
|
|
157
|
+
requestAnimationFrame(function () {
|
|
158
|
+
if (state.object && state.object.rotation.z !== state.rad) state.object.rotation.z = state.rad;
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var stop = function stop() {
|
|
163
|
+
var _stopAnimation;
|
|
164
|
+
|
|
165
|
+
action.stop();
|
|
166
|
+
(_stopAnimation = stopAnimation) === null || _stopAnimation === void 0 ? void 0 : _stopAnimation();
|
|
167
|
+
stopAnimation = undefined;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
var animation = {
|
|
171
|
+
play: play,
|
|
172
|
+
stop: stop
|
|
173
|
+
};
|
|
174
|
+
state.animation = animation;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
var show = function show(config) {
|
|
178
|
+
var _config$animationEnab;
|
|
179
|
+
|
|
180
|
+
if (!state.object) return console.error('ModelEntryDoorGuidePlugin.enable(): object is ', state.object);
|
|
181
|
+
var animationEnable = (_config$animationEnab = config === null || config === void 0 ? void 0 : config.animationEnable) !== null && _config$animationEnab !== void 0 ? _config$animationEnab : defaultAnimationEnable;
|
|
182
|
+
|
|
183
|
+
if (animationEnable) {
|
|
184
|
+
if (!state.animation) initAnimation();
|
|
185
|
+
state.animation.play();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
five.scene.add(state.object);
|
|
189
|
+
five.needsRender = true;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
var hide = function hide() {
|
|
193
|
+
if (!state.object) return;
|
|
194
|
+
if (state.animation) state.animation.stop();
|
|
195
|
+
five.scene.remove(state.object);
|
|
196
|
+
five.needsRender = true;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
var modeChangeHandler = function modeChangeHandler(mode) {
|
|
200
|
+
return mode === 'Floorplan' ? show() : hide();
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
var enable = function enable(config) {
|
|
204
|
+
if (state.enabled) return true;
|
|
205
|
+
state.enabled = true;
|
|
206
|
+
five.on('modeChange', modeChangeHandler);
|
|
207
|
+
show(config);
|
|
208
|
+
return true;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
var disable = function disable() {
|
|
212
|
+
if (!state.enabled) return true;
|
|
213
|
+
state.enabled = false;
|
|
214
|
+
five.off('modeChange', modeChangeHandler);
|
|
215
|
+
return true;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return {
|
|
219
|
+
load: load,
|
|
220
|
+
enable: enable,
|
|
221
|
+
disable: disable
|
|
222
|
+
};
|
|
13
223
|
};
|
|
14
224
|
|
|
15
225
|
var _default = ModelEntryDoorGuidePlugin;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Five } from '@realsee/five';
|
|
2
|
+
import { ModelRoomLabelPluginData } from './typings';
|
|
3
|
+
export declare type ModelRoomLabelPluginParameters = undefined;
|
|
4
|
+
export declare class ModelRoomLabelController {
|
|
5
|
+
private five;
|
|
6
|
+
private enabled;
|
|
7
|
+
private fiveModeEnabled;
|
|
8
|
+
private wrapper?;
|
|
9
|
+
private roomLabels;
|
|
10
|
+
private container;
|
|
11
|
+
constructor(five: Five);
|
|
12
|
+
dispose(): void;
|
|
13
|
+
/** 加载数据 */
|
|
14
|
+
load(data: ModelRoomLabelPluginData): void;
|
|
15
|
+
/** 设置插件容器 */
|
|
16
|
+
appendTo(wrapper: Element): this;
|
|
17
|
+
/** 禁用插件功能
|
|
18
|
+
* @description
|
|
19
|
+
* - 如果当前正在展示中,会清除所有展示的 DOM
|
|
20
|
+
* - 如果当前未展示,即使后续 Five 状态满足展示要求,也不会展示
|
|
21
|
+
* */
|
|
22
|
+
disable(): this;
|
|
23
|
+
/** 启用插件功能
|
|
24
|
+
* @description
|
|
25
|
+
* - 如果当前符合展示条件,会立刻展示
|
|
26
|
+
* - 如果不符合展示条件,会等待 Five 状态满足条件后再展示
|
|
27
|
+
*/
|
|
28
|
+
enable(): this;
|
|
29
|
+
/** 监听 Five Mode 变化
|
|
30
|
+
* @description
|
|
31
|
+
* Mode 不符合要求时,立刻消失,满足要求时,需要等待动画结束再展示
|
|
32
|
+
*/
|
|
33
|
+
private onFiveModeChange;
|
|
34
|
+
private render;
|
|
35
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ModelRoomLabelController = void 0;
|
|
9
|
+
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var ReactDOM = _interopRequireWildcard(require("react-dom"));
|
|
13
|
+
|
|
14
|
+
var _RoomLabelItems = _interopRequireDefault(require("./RoomLabelItems"));
|
|
15
|
+
|
|
16
|
+
var _parseData = require("./utils/parseData");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
|
|
24
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
25
|
+
|
|
26
|
+
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, descriptor.key, descriptor); } }
|
|
27
|
+
|
|
28
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
29
|
+
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
|
|
32
|
+
var ModelRoomLabelController = /*#__PURE__*/function () {
|
|
33
|
+
function ModelRoomLabelController(five) {
|
|
34
|
+
var _this = this;
|
|
35
|
+
|
|
36
|
+
_classCallCheck(this, ModelRoomLabelController);
|
|
37
|
+
|
|
38
|
+
_defineProperty(this, "enabled", true);
|
|
39
|
+
|
|
40
|
+
_defineProperty(this, "roomLabels", []);
|
|
41
|
+
|
|
42
|
+
_defineProperty(this, "container", document.createElement('div'));
|
|
43
|
+
|
|
44
|
+
_defineProperty(this, "onFiveModeChange", function (mode) {
|
|
45
|
+
if (mode !== 'Floorplan') {
|
|
46
|
+
_this.fiveModeEnabled = false;
|
|
47
|
+
|
|
48
|
+
_this.render();
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
_this.five.once('initAnimationEnded', function () {
|
|
54
|
+
_this.fiveModeEnabled = _this.five.currentMode === 'Floorplan';
|
|
55
|
+
|
|
56
|
+
_this.render();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.five = five;
|
|
61
|
+
this.fiveModeEnabled = this.five.currentMode === 'Floorplan'; // init container style
|
|
62
|
+
|
|
63
|
+
this.container.classList.add('model-room-label-plugin-container');
|
|
64
|
+
this.container.style.width = '100%';
|
|
65
|
+
this.container.style.height = '100%';
|
|
66
|
+
this.container.style.position = 'absolute';
|
|
67
|
+
this.container.style.left = '0';
|
|
68
|
+
this.container.style.top = '0'; // five lisenter
|
|
69
|
+
|
|
70
|
+
this.five.once('dispose', function () {
|
|
71
|
+
return _this.dispose();
|
|
72
|
+
});
|
|
73
|
+
this.five.on('modeChange', this.onFiveModeChange);
|
|
74
|
+
this.render();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
_createClass(ModelRoomLabelController, [{
|
|
78
|
+
key: "dispose",
|
|
79
|
+
value: function dispose() {
|
|
80
|
+
this.five.off('modeChange', this.onFiveModeChange);
|
|
81
|
+
ReactDOM.unmountComponentAtNode(this.container);
|
|
82
|
+
this.container.remove();
|
|
83
|
+
}
|
|
84
|
+
/** 加载数据 */
|
|
85
|
+
|
|
86
|
+
}, {
|
|
87
|
+
key: "load",
|
|
88
|
+
value: function load(data) {
|
|
89
|
+
this.roomLabels = (0, _parseData.parseModelRoomLabelPluginData)(data);
|
|
90
|
+
this.render();
|
|
91
|
+
}
|
|
92
|
+
/** 设置插件容器 */
|
|
93
|
+
|
|
94
|
+
}, {
|
|
95
|
+
key: "appendTo",
|
|
96
|
+
value: function appendTo(wrapper) {
|
|
97
|
+
this.wrapper = wrapper;
|
|
98
|
+
wrapper.appendChild(this.container);
|
|
99
|
+
this.render();
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/** 禁用插件功能
|
|
103
|
+
* @description
|
|
104
|
+
* - 如果当前正在展示中,会清除所有展示的 DOM
|
|
105
|
+
* - 如果当前未展示,即使后续 Five 状态满足展示要求,也不会展示
|
|
106
|
+
* */
|
|
107
|
+
|
|
108
|
+
}, {
|
|
109
|
+
key: "disable",
|
|
110
|
+
value: function disable() {
|
|
111
|
+
this.enabled = false;
|
|
112
|
+
this.render();
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/** 启用插件功能
|
|
116
|
+
* @description
|
|
117
|
+
* - 如果当前符合展示条件,会立刻展示
|
|
118
|
+
* - 如果不符合展示条件,会等待 Five 状态满足条件后再展示
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
}, {
|
|
122
|
+
key: "enable",
|
|
123
|
+
value: function enable() {
|
|
124
|
+
this.enabled = true;
|
|
125
|
+
this.render();
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
/** 监听 Five Mode 变化
|
|
129
|
+
* @description
|
|
130
|
+
* Mode 不符合要求时,立刻消失,满足要求时,需要等待动画结束再展示
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
}, {
|
|
134
|
+
key: "render",
|
|
135
|
+
value: function render() {
|
|
136
|
+
if (!this.wrapper) return;
|
|
137
|
+
ReactDOM.render(this.enabled && this.fiveModeEnabled ? /*#__PURE__*/React.createElement(_RoomLabelItems["default"], {
|
|
138
|
+
five: this.five,
|
|
139
|
+
roomLabels: this.roomLabels
|
|
140
|
+
}) : /*#__PURE__*/React.createElement(React.Fragment, null), this.container);
|
|
141
|
+
}
|
|
142
|
+
}]);
|
|
143
|
+
|
|
144
|
+
return ModelRoomLabelController;
|
|
145
|
+
}();
|
|
146
|
+
|
|
147
|
+
exports.ModelRoomLabelController = ModelRoomLabelController;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Five } from '@realsee/five';
|
|
3
|
+
import { RoomLabel } from './typings';
|
|
4
|
+
declare const RefRoomLabelItem: React.ForwardRefExoticComponent<{
|
|
5
|
+
five: Five;
|
|
6
|
+
item: RoomLabel;
|
|
7
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export default RefRoomLabelItem;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
11
|
+
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _px2rem = _interopRequireDefault(require("../../shared-utils/px2rem"));
|
|
15
|
+
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
function RoomLabelItem(props, ref) {
|
|
23
|
+
var five = props.five;
|
|
24
|
+
var roomName = props.item.name;
|
|
25
|
+
var handleClick = React.useCallback(function () {
|
|
26
|
+
five.setState({
|
|
27
|
+
panoIndex: props.item.panoIndex,
|
|
28
|
+
mode: 'Panorama',
|
|
29
|
+
longitude: props.item.longitude
|
|
30
|
+
});
|
|
31
|
+
}, [props.five]);
|
|
32
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
onClick: handleClick,
|
|
34
|
+
ref: ref,
|
|
35
|
+
className: _style["default"].dynamic([["3619298579", [(0, _px2rem["default"])(roomName.length > 3 ? 8 : 10), (0, _px2rem["default"])(-64), (0, _px2rem["default"])(20), (0, _px2rem["default"])(32), (0, _px2rem["default"])(6), (0, _px2rem["default"])(-44), (0, _px2rem["default"])(48), (0, _px2rem["default"])(1)]]]) + " " + "room-guid-label-plugin__item"
|
|
36
|
+
}, /*#__PURE__*/React.createElement(_style["default"], {
|
|
37
|
+
id: "3619298579",
|
|
38
|
+
dynamic: [(0, _px2rem["default"])(roomName.length > 3 ? 8 : 10), (0, _px2rem["default"])(-64), (0, _px2rem["default"])(20), (0, _px2rem["default"])(32), (0, _px2rem["default"])(6), (0, _px2rem["default"])(-44), (0, _px2rem["default"])(48), (0, _px2rem["default"])(1)]
|
|
39
|
+
}, [".room-guid-label-plugin__item.__jsx-style-dynamic-selector{position:absolute;z-index:0;font-size:".concat((0, _px2rem["default"])(roomName.length > 3 ? 8 : 10), ";-webkit-transform:'';-ms-transform:'';transform:'';cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;}"), ".room-guid-label-plugin__item-text.__jsx-style-dynamic-selector{position:absolute;left:0;top:".concat((0, _px2rem["default"])(-64), ";-webkit-transform:translate(-50%,0);-ms-transform:translate(-50%,0);transform:translate(-50%,0);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;height:").concat((0, _px2rem["default"])(20), ";min-width:").concat((0, _px2rem["default"])(32), ";padding:0 ").concat((0, _px2rem["default"])(6), ";pointer-events:all;background:url('//vrlab-static.ljcdn.com/release/web/room-label-bg.23e9d038.png') no-repeat;background-size:100% 100%;white-space:nowrap;}"), ".room-guid-label-plugin__item-bar.__jsx-style-dynamic-selector{position:absolute;top:".concat((0, _px2rem["default"])(-44), ";height:").concat((0, _px2rem["default"])(48), ";width:").concat((0, _px2rem["default"])(1), ";background-image:linear-gradient(to bottom,rgba(255,255,255,1),rgba(255,255,255,0));}")]), /*#__PURE__*/React.createElement("span", {
|
|
40
|
+
className: _style["default"].dynamic([["3619298579", [(0, _px2rem["default"])(roomName.length > 3 ? 8 : 10), (0, _px2rem["default"])(-64), (0, _px2rem["default"])(20), (0, _px2rem["default"])(32), (0, _px2rem["default"])(6), (0, _px2rem["default"])(-44), (0, _px2rem["default"])(48), (0, _px2rem["default"])(1)]]]) + " " + "room-guid-label-plugin__item-text"
|
|
41
|
+
}, roomName), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: _style["default"].dynamic([["3619298579", [(0, _px2rem["default"])(roomName.length > 3 ? 8 : 10), (0, _px2rem["default"])(-64), (0, _px2rem["default"])(20), (0, _px2rem["default"])(32), (0, _px2rem["default"])(6), (0, _px2rem["default"])(-44), (0, _px2rem["default"])(48), (0, _px2rem["default"])(1)]]]) + " " + "room-guid-label-plugin__item-bar"
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var RefRoomLabelItem = /*#__PURE__*/React.forwardRef(RoomLabelItem);
|
|
47
|
+
var _default = RefRoomLabelItem;
|
|
48
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = RoomLabelItems;
|
|
9
|
+
|
|
10
|
+
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
11
|
+
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _three = require("three");
|
|
15
|
+
|
|
16
|
+
var _RoomLabelItem = _interopRequireDefault(require("./RoomLabelItem"));
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
24
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
25
|
+
|
|
26
|
+
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; } }
|
|
27
|
+
|
|
28
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
+
|
|
30
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
31
|
+
|
|
32
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
33
|
+
|
|
34
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
35
|
+
|
|
36
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
37
|
+
|
|
38
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
|
+
|
|
40
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
41
|
+
|
|
42
|
+
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); }
|
|
43
|
+
|
|
44
|
+
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; }
|
|
45
|
+
|
|
46
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
47
|
+
|
|
48
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
+
|
|
50
|
+
function getLabelVisible(five, roomLabelItem) {
|
|
51
|
+
// 先看是不是在当前展示的楼层上
|
|
52
|
+
var isLabelInFloor = five.model.shownFloor === null || roomLabelItem.floorIndex === five.model.shownFloor;
|
|
53
|
+
if (!isLabelInFloor) return false; // 再看是不是被模型遮挡
|
|
54
|
+
|
|
55
|
+
var raycaster = new _three.Raycaster();
|
|
56
|
+
var cameraPosition = five.camera.position.clone();
|
|
57
|
+
var position = new _three.Vector3(roomLabelItem.position.x, roomLabelItem.position.y, roomLabelItem.position.z);
|
|
58
|
+
var vectorDistance = position.distanceTo(cameraPosition);
|
|
59
|
+
raycaster.set(cameraPosition.clone(), position.clone().sub(cameraPosition).normalize());
|
|
60
|
+
|
|
61
|
+
var _five$model$intersect = five.model.intersectRaycaster(raycaster),
|
|
62
|
+
_five$model$intersect2 = _slicedToArray(_five$model$intersect, 1),
|
|
63
|
+
intersection = _five$model$intersect2[0];
|
|
64
|
+
|
|
65
|
+
if (intersection && intersection.distance + 1 < vectorDistance) return false;
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getLabelTransform(five, roomLabelItem, containerWidth, containerHeight) {
|
|
70
|
+
var position = new _three.Vector3(roomLabelItem.position.x, roomLabelItem.position.y, roomLabelItem.position.z);
|
|
71
|
+
var mouse = position.clone().project(five.camera);
|
|
72
|
+
var xOffset = Math.ceil((mouse.x + 1) / 2 * containerWidth);
|
|
73
|
+
var yOffset = Math.ceil((-mouse.y + 1) / 2 * containerHeight);
|
|
74
|
+
return "translate(".concat(xOffset, "px, ").concat(yOffset, "px)");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function updateFormatData(five, labels, containerWidth, containerHeight) {
|
|
78
|
+
labels.forEach(function (roomLabelItem) {
|
|
79
|
+
// 计算是否可见,入股不可见,不会更新位置
|
|
80
|
+
roomLabelItem.visible = getLabelVisible(five, roomLabelItem);
|
|
81
|
+
if (!roomLabelItem.visible) return roomLabelItem; // 更新位置
|
|
82
|
+
|
|
83
|
+
roomLabelItem.transform = getLabelTransform(five, roomLabelItem, containerWidth, containerHeight);
|
|
84
|
+
return true;
|
|
85
|
+
});
|
|
86
|
+
labels.filter(function (_ref) {
|
|
87
|
+
var visible = _ref.visible;
|
|
88
|
+
return visible;
|
|
89
|
+
}).map(function (roomLabelItem) {
|
|
90
|
+
return {
|
|
91
|
+
roomLabelItem: roomLabelItem,
|
|
92
|
+
distance: _construct(_three.Vector3, _toConsumableArray(Object.values(roomLabelItem.position))).clone().distanceTo(five.camera.position)
|
|
93
|
+
};
|
|
94
|
+
}).sort(function (a, b) {
|
|
95
|
+
return a.distance - b.distance;
|
|
96
|
+
}).forEach(function (_ref2, index) {
|
|
97
|
+
var roomLabelItem = _ref2.roomLabelItem;
|
|
98
|
+
roomLabelItem.zIndex = index * 10;
|
|
99
|
+
});
|
|
100
|
+
return labels;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function RoomLabelItems(props) {
|
|
104
|
+
var five = props.five;
|
|
105
|
+
var itemRefs = React.useRef([]);
|
|
106
|
+
var contentRef = React.useRef(null);
|
|
107
|
+
var roomLabels = props.roomLabels;
|
|
108
|
+
|
|
109
|
+
function onFiveCameraDirectionUpdate() {
|
|
110
|
+
if (!contentRef.current) return;
|
|
111
|
+
updateFormatData(five, roomLabels, contentRef.current.clientWidth, contentRef.current.clientHeight).forEach(function (item, index) {
|
|
112
|
+
var ref = itemRefs.current[index];
|
|
113
|
+
if (!ref) return;
|
|
114
|
+
|
|
115
|
+
if (!item.visible) {
|
|
116
|
+
ref.style.opacity = '0';
|
|
117
|
+
ref.style.pointerEvents = 'none';
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
ref.style.opacity = '1';
|
|
122
|
+
ref.style.pointerEvents = 'all';
|
|
123
|
+
ref.style.transform = item.transform;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
React.useEffect(function () {
|
|
128
|
+
five.on('cameraDirectionUpdate', onFiveCameraDirectionUpdate);
|
|
129
|
+
onFiveCameraDirectionUpdate();
|
|
130
|
+
return function () {
|
|
131
|
+
five.off('cameraDirectionUpdate', onFiveCameraDirectionUpdate);
|
|
132
|
+
};
|
|
133
|
+
}, []);
|
|
134
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
ref: contentRef,
|
|
136
|
+
className: "jsx-2859587460" + " " + "room-guid-label-plugin__content"
|
|
137
|
+
}, /*#__PURE__*/React.createElement(_style["default"], {
|
|
138
|
+
id: "2859587460"
|
|
139
|
+
}, [".room-guid-label-plugin__content.jsx-2859587460{width:100%;height:100%;position:relative;color:#fff;}"]), roomLabels.map(function (item) {
|
|
140
|
+
return /*#__PURE__*/React.createElement(_RoomLabelItem["default"], {
|
|
141
|
+
key: item.id,
|
|
142
|
+
item: item,
|
|
143
|
+
five: props.five,
|
|
144
|
+
ref: function ref(_ref3) {
|
|
145
|
+
return itemRefs.current.push(_ref3);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FivePlugin } from '@realsee/five';
|
|
2
|
+
import { ModelRoomLabelController, ModelRoomLabelPluginParameters } from './Controller';
|
|
3
|
+
export declare const ModelRoomLabelPlugin: FivePlugin<ModelRoomLabelPluginParameters, ModelRoomLabelPluginReturnType>;
|
|
4
|
+
export default ModelRoomLabelPlugin;
|
|
5
|
+
export type { ModelRoomLabelController } from './Controller';
|
|
6
|
+
export type { ModelRoomLabelPluginData, RoomLabel } from './typings';
|
|
7
|
+
export declare type ModelRoomLabelPluginReturnType = ModelRoomLabelController;
|
|
8
|
+
export type { ModelRoomLabelPluginParameters } from './Controller';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.ModelRoomLabelPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
var _Controller = require("./Controller");
|
|
9
|
+
|
|
10
|
+
var ModelRoomLabelPlugin = function ModelRoomLabelPlugin(five) {
|
|
11
|
+
return new _Controller.ModelRoomLabelController(five);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.ModelRoomLabelPlugin = ModelRoomLabelPlugin;
|
|
15
|
+
var _default = ModelRoomLabelPlugin;
|
|
16
|
+
exports["default"] = _default;
|