@realsee/dnalogel 2.0.0-alpha.12 → 2.0.0-alpha.15
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 +11 -0
- package/README.md +78 -28
- package/dist/CSS3DRenderPlugin/index.js +17 -14
- package/dist/CameraMovementPlugin/index.js +40 -15
- package/dist/ModelChassisCompassPlugin/index.js +32 -6
- package/dist/ModelEntryDoorGuidePlugin/index.js +48 -18
- package/dist/ModelItemLabelPlugin/index.js +81 -95
- package/dist/ModelRoomLabelPlugin/index.js +67 -26
- package/dist/ModelTVVideoPlugin/index.d.ts +4 -0
- package/dist/ModelTVVideoPlugin/index.js +326 -0
- package/dist/ModelTVVideoPlugin/typings.d.ts +25 -0
- package/dist/ModelTVVideoPlugin/utils/parseData.d.ts +2 -0
- package/dist/PanoCompassPlugin/index.js +311 -164
- package/dist/PanoCursorRaycasterPlugin/index.js +5 -3
- package/dist/PanoMeasurePlugin/index.js +1335 -581
- package/dist/PanoRulerPlugin/index.js +32 -5
- package/dist/PanoSpatialTagPlugin/index.js +64 -29
- package/dist/floorplan/ModelFloorplanPlugin/index.js +586 -362
- package/dist/floorplan/PanoFloorplanRadarPlugin/index.js +164 -72
- package/dist/floorplan/TopviewFloorplanPlugin/index.js +311 -153
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +2999 -1419
- package/dist/index.js +3003 -1422
- package/dist/index.umd.js +3003 -1422
- package/docs/assets/search.js +1 -1
- package/docs/classes/ModelRoomLabelController.html +6 -6
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ModelFloorplanErrorType.html +1 -1
- package/docs/index.html +78 -33
- 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 +2 -2
- package/docs/interfaces/ModelItemLabelPluginData.html +1 -0
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -0
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -0
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -0
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -0
- package/docs/interfaces/ModelTVVideoPluginParameterType.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/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/TopviewFloorplanPluginParameterType.html +1 -1
- package/docs/modules.html +12 -12
- package/libs/CSS3DRenderPlugin/index.js +16 -13
- package/libs/CameraMovementPlugin/index.js +24 -15
- package/libs/ModelChassisCompassPlugin/index.js +14 -5
- package/libs/ModelEntryDoorGuidePlugin/index.js +24 -12
- package/libs/ModelItemLabelPlugin/ItemLabelComponent.js +54 -67
- package/libs/ModelItemLabelPlugin/index.js +8 -59
- package/libs/ModelItemLabelPlugin/utils/parseData.js +1 -4
- package/libs/ModelRoomLabelPlugin/Controller.js +64 -23
- package/libs/ModelRoomLabelPlugin/RoomLabelItems.js +3 -3
- package/libs/ModelTVVideoPlugin/index.d.ts +4 -0
- package/libs/ModelTVVideoPlugin/index.js +263 -0
- package/libs/ModelTVVideoPlugin/typings.d.ts +25 -0
- package/libs/ModelTVVideoPlugin/typings.js +7 -0
- package/libs/ModelTVVideoPlugin/utils/parseData.d.ts +2 -0
- package/libs/ModelTVVideoPlugin/utils/parseData.js +13 -0
- package/libs/PanoCompassPlugin/index.js +225 -128
- package/libs/PanoCursorRaycasterPlugin/index.js +5 -3
- package/libs/PanoMeasurePlugin/Controller/BaseController.js +68 -13
- package/libs/PanoMeasurePlugin/Controller/EditController.js +267 -154
- package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.js +40 -20
- package/libs/PanoMeasurePlugin/Controller/WatchController.js +234 -152
- package/libs/PanoMeasurePlugin/Controller/index.js +131 -47
- package/libs/PanoMeasurePlugin/Model/index.js +30 -5
- package/libs/PanoMeasurePlugin/Model/line.js +60 -10
- package/libs/PanoMeasurePlugin/Model/point.js +24 -4
- package/libs/PanoMeasurePlugin/Model/polyline.js +20 -3
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.js +59 -14
- package/libs/PanoMeasurePlugin/Modules/FiveHelper.js +23 -8
- package/libs/PanoMeasurePlugin/Modules/GuideController.js +61 -26
- package/libs/PanoMeasurePlugin/Modules/Magnifier.js +60 -10
- package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +83 -37
- package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +52 -17
- package/libs/PanoMeasurePlugin/Modules/UIController/index.js +61 -30
- package/libs/PanoMeasurePlugin/utils/distanceDom.js +3 -2
- package/libs/PanoMeasurePlugin/utils/line.js +8 -7
- package/libs/PanoRulerPlugin/index.js +16 -5
- package/libs/PanoSpatialTagPlugin/index.js +11 -9
- package/libs/floorplan/Components/BaseImage.js +10 -5
- package/libs/floorplan/Components/RoomHighlight/RoomHighlight.js +3 -1
- package/libs/floorplan/Components/RoomMaterials/RoomMaterial.js +5 -6
- package/libs/floorplan/ModelFloorplanPlugin/Components/Compass.js +7 -2
- package/libs/floorplan/ModelFloorplanPlugin/Components/RoomLabels/RoomLabel.js +3 -1
- package/libs/floorplan/ModelFloorplanPlugin/Controller.js +456 -273
- package/libs/floorplan/ModelFloorplanPlugin/utils/correctFiveState.js +33 -22
- package/libs/floorplan/PanoFloorplanRadarPlugin/Components/CurrentFloor/CurrentFloor.js +3 -1
- package/libs/floorplan/PanoFloorplanRadarPlugin/Controller.js +97 -36
- package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +231 -108
- package/libs/floorplan/utils/formatData.js +43 -28
- package/libs/floorplan/utils/formatPosition.js +1 -1
- package/libs/index.d.ts +3 -0
- package/libs/index.js +1 -1
- package/libs/shared-utils/Subscribe.js +8 -1
- package/libs/shared-utils/animationFrame/BetterTween.js +47 -18
- package/libs/shared-utils/createCanvasTextTexture.js +6 -5
- package/libs/shared-utils/five/changeMode.js +23 -12
- package/libs/shared-utils/getPxmm.js +1 -1
- package/libs/shared-utils/math/evenNumber.js +1 -1
- package/libs/shared-utils/three/loadFbxObj.js +20 -9
- package/libs/shared-utils/three/loadTexture.js +17 -6
- package/libs/shared-utils/three/transfromToMeshBasicMaterial.js +2 -1
- package/libs/shared-utils/tinyEJSrender.js +36 -6
- package/libs/shared-utils/to.js +21 -10
- package/libs/shared-utils/useDebounce.js +1 -1
- package/libs/shared-utils/useThrottle.js +2 -1
- package/package.json +2 -1
|
@@ -14,24 +14,25 @@ import createResizeObserver from './utils/createResizeObserver';
|
|
|
14
14
|
export const CSS3DRenderPlugin = (five) => {
|
|
15
15
|
const state = { disposeCallbacks: [] };
|
|
16
16
|
const create3DDomContainer = (...params) => {
|
|
17
|
+
var _a, _b, _c;
|
|
17
18
|
const points = params[0].map((point) => (point instanceof Vector3 ? point : transformPositionToVector3(point)));
|
|
18
19
|
const config = params[1];
|
|
19
|
-
if (points
|
|
20
|
+
if ((points === null || points === void 0 ? void 0 : points.length) < 4)
|
|
20
21
|
return console.error('points must be equal or greater than than 4');
|
|
21
|
-
if (!five
|
|
22
|
-
return console.error('five.model.loaded is: ', five
|
|
22
|
+
if (!((_a = five === null || five === void 0 ? void 0 : five.model) === null || _a === void 0 ? void 0 : _a.loaded))
|
|
23
|
+
return console.error('five.model.loaded is: ', (_b = five === null || five === void 0 ? void 0 : five.model) === null || _b === void 0 ? void 0 : _b.loaded);
|
|
23
24
|
const fiveElement = five.getElement();
|
|
24
25
|
if (!fiveElement)
|
|
25
26
|
return console.error('five.getElement() is ' + fiveElement);
|
|
26
27
|
const disposers = [];
|
|
27
|
-
const ratio = config
|
|
28
|
+
const ratio = (config === null || config === void 0 ? void 0 : config.ratio) || 0.00216;
|
|
28
29
|
if (ratio <= 0.00215)
|
|
29
30
|
console.warn('if you need click css3DElement on safari, ratio must be greater than 0.00215');
|
|
30
|
-
const dpr = config
|
|
31
|
-
const mode = config
|
|
32
|
-
const autoRender = config
|
|
33
|
-
const behindFiveContainer = config
|
|
34
|
-
const container = config
|
|
31
|
+
const dpr = (config === null || config === void 0 ? void 0 : config.dpr) || 1;
|
|
32
|
+
const mode = (config === null || config === void 0 ? void 0 : config.mode) || 'front';
|
|
33
|
+
const autoRender = (_c = config === null || config === void 0 ? void 0 : config.autoRender) !== null && _c !== void 0 ? _c : true;
|
|
34
|
+
const behindFiveContainer = (config === null || config === void 0 ? void 0 : config.behindFiveContainer) || fiveElement.parentElement || document.body;
|
|
35
|
+
const container = (config === null || config === void 0 ? void 0 : config.container) || document.createElement('div');
|
|
35
36
|
container.classList.add('__Dnalogel-plugin--CSS3DRenderPlugin');
|
|
36
37
|
// 获取css3DObject, 如果mode为behind的话,一起获取mesh
|
|
37
38
|
const { css3DObject, mesh } = createObject(points, { ratio, dpr, container, mode });
|
|
@@ -69,8 +70,9 @@ export const CSS3DRenderPlugin = (five) => {
|
|
|
69
70
|
css3DRenderer.render(scene, five.camera);
|
|
70
71
|
};
|
|
71
72
|
return () => {
|
|
73
|
+
var _a;
|
|
72
74
|
scene.add(css3DObject);
|
|
73
|
-
resizeObserver
|
|
75
|
+
(_a = resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.observe) === null || _a === void 0 ? void 0 : _a.call(resizeObserver);
|
|
74
76
|
renderEveryFrame();
|
|
75
77
|
if (mode === 'behind' && mesh) {
|
|
76
78
|
five.scene.add(mesh);
|
|
@@ -94,7 +96,8 @@ export const CSS3DRenderPlugin = (five) => {
|
|
|
94
96
|
}
|
|
95
97
|
// ======= INIT END =======
|
|
96
98
|
const dispose = () => {
|
|
97
|
-
|
|
99
|
+
var _a;
|
|
100
|
+
disposers.forEach((d) => d === null || d === void 0 ? void 0 : d());
|
|
98
101
|
scene.remove(css3DObject);
|
|
99
102
|
if (scene.children.length === 0) {
|
|
100
103
|
if (typeof stateMode.requestAnimationFrameId === 'number') {
|
|
@@ -106,7 +109,7 @@ export const CSS3DRenderPlugin = (five) => {
|
|
|
106
109
|
if (mode === 'behind')
|
|
107
110
|
state.behindMode = undefined;
|
|
108
111
|
if (!state.behindMode && !state.frontMode) {
|
|
109
|
-
resizeObserver
|
|
112
|
+
(_a = resizeObserver === null || resizeObserver === void 0 ? void 0 : resizeObserver.unobserve) === null || _a === void 0 ? void 0 : _a.call(resizeObserver);
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
return true;
|
|
@@ -171,7 +174,7 @@ export const CSS3DRenderPlugin = (five) => {
|
|
|
171
174
|
return {
|
|
172
175
|
create3DDomContainer,
|
|
173
176
|
disposeAll: () => {
|
|
174
|
-
state.disposeCallbacks.forEach((d) => d
|
|
177
|
+
state.disposeCallbacks.forEach((d) => d === null || d === void 0 ? void 0 : d());
|
|
175
178
|
state.disposeCallbacks = [];
|
|
176
179
|
},
|
|
177
180
|
};
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { Five } from '@realsee/five';
|
|
2
11
|
import * as TWEEN from '@tweenjs/tween.js';
|
|
3
12
|
import { tweenProgress } from '../shared-utils/animationFrame/tween';
|
|
@@ -29,21 +38,21 @@ const getLongitudeParams = (from, to, rotation) => {
|
|
|
29
38
|
*/
|
|
30
39
|
export const CameraMovementPlugin = (five) => {
|
|
31
40
|
const state = {};
|
|
32
|
-
const move =
|
|
41
|
+
const move = (args, duration, opts = { preload: true }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
42
|
if (state.interruptCallback) {
|
|
34
43
|
state.interruptCallback(false);
|
|
35
44
|
}
|
|
36
45
|
if (opts.asyncStartCallback) {
|
|
37
|
-
|
|
46
|
+
yield opts.asyncStartCallback();
|
|
38
47
|
}
|
|
39
48
|
if (args.mode && args.mode !== five.currentMode) {
|
|
40
|
-
|
|
49
|
+
yield five.changeMode(args.mode);
|
|
41
50
|
}
|
|
42
51
|
if (opts.preload && args.panoIndex !== undefined && args.panoIndex !== five.panoIndex) {
|
|
43
|
-
|
|
52
|
+
yield five.preloadPano(args.panoIndex);
|
|
44
53
|
}
|
|
45
54
|
if (opts.asyncEndCallback) {
|
|
46
|
-
|
|
55
|
+
yield opts.asyncEndCallback();
|
|
47
56
|
}
|
|
48
57
|
if (args.panoIndex === undefined &&
|
|
49
58
|
args.fov === undefined &&
|
|
@@ -51,7 +60,7 @@ export const CameraMovementPlugin = (five) => {
|
|
|
51
60
|
args.longitude === undefined) {
|
|
52
61
|
return true;
|
|
53
62
|
}
|
|
54
|
-
return
|
|
63
|
+
return yield new Promise((resolve, reject) => {
|
|
55
64
|
const panoIndex = args.panoIndex !== undefined ? args.panoIndex : five.panoIndex;
|
|
56
65
|
if (panoIndex !== undefined) {
|
|
57
66
|
five.moveToPano(panoIndex, Object.assign({
|
|
@@ -64,7 +73,7 @@ export const CameraMovementPlugin = (five) => {
|
|
|
64
73
|
reject(false);
|
|
65
74
|
}
|
|
66
75
|
});
|
|
67
|
-
};
|
|
76
|
+
});
|
|
68
77
|
const getAnimeParams = (args) => {
|
|
69
78
|
const currentFiveState = five.state;
|
|
70
79
|
// latitude
|
|
@@ -80,20 +89,20 @@ export const CameraMovementPlugin = (five) => {
|
|
|
80
89
|
to: { latitude: toLatitude, longitude: toLongitude, fov: toFov },
|
|
81
90
|
};
|
|
82
91
|
};
|
|
83
|
-
const rotate =
|
|
92
|
+
const rotate = (args, duration, opts = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
93
|
if (state.interruptCallback) {
|
|
85
94
|
state.interruptCallback(false);
|
|
86
95
|
}
|
|
87
96
|
if (opts.asyncStartCallback) {
|
|
88
|
-
|
|
97
|
+
yield opts.asyncStartCallback();
|
|
89
98
|
}
|
|
90
99
|
if (five.currentMode !== Five.Mode.Panorama) {
|
|
91
|
-
|
|
100
|
+
yield five.changeMode(Five.Mode.Panorama);
|
|
92
101
|
}
|
|
93
102
|
if (args.panoIndex !== undefined && args.panoIndex !== five.panoIndex) {
|
|
94
103
|
if (opts.preload)
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
yield five.preloadPano(args.panoIndex);
|
|
105
|
+
yield new Promise((resolve, reject) => {
|
|
97
106
|
if (!args.panoIndex) {
|
|
98
107
|
resolve(true);
|
|
99
108
|
return;
|
|
@@ -105,10 +114,10 @@ export const CameraMovementPlugin = (five) => {
|
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
if (opts.asyncEndCallback) {
|
|
108
|
-
|
|
117
|
+
yield opts.asyncEndCallback();
|
|
109
118
|
}
|
|
110
119
|
const { from, to } = getAnimeParams(args);
|
|
111
|
-
return
|
|
120
|
+
return yield new Promise((resolve) => {
|
|
112
121
|
const onUpdate = ({ progress }) => {
|
|
113
122
|
const state = {};
|
|
114
123
|
state.longitude = progressNumber(from.longitude, to.longitude, progress);
|
|
@@ -150,7 +159,7 @@ export const CameraMovementPlugin = (five) => {
|
|
|
150
159
|
state.interruptCallback(true);
|
|
151
160
|
}, duration);
|
|
152
161
|
});
|
|
153
|
-
};
|
|
162
|
+
});
|
|
154
163
|
return {
|
|
155
164
|
move,
|
|
156
165
|
rotate,
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import * as THREE from 'three';
|
|
2
11
|
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
|
|
3
12
|
import object3d2LocalMatrix from '../shared-utils/object3d2LocalMatrix';
|
|
@@ -10,9 +19,9 @@ export const ModelChassisCompassPlugin = (five, params) => {
|
|
|
10
19
|
const defaultNorthRad = params.north_rad || undefined;
|
|
11
20
|
// 局部状态
|
|
12
21
|
const state = {};
|
|
13
|
-
const load =
|
|
14
|
-
const fbxUrl = data
|
|
15
|
-
const northRad = data
|
|
22
|
+
const load = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const fbxUrl = (data === null || data === void 0 ? void 0 : data.fbx_url) || defaultFbxUrl;
|
|
24
|
+
const northRad = (data === null || data === void 0 ? void 0 : data.north_rad) || defaultNorthRad;
|
|
16
25
|
if (!northRad) {
|
|
17
26
|
throw new Error('"northRad"配置参数缺失:未配置指南针指向!');
|
|
18
27
|
}
|
|
@@ -21,7 +30,7 @@ export const ModelChassisCompassPlugin = (five, params) => {
|
|
|
21
30
|
const zOffset = bounding.max.z - bounding.min.z;
|
|
22
31
|
const maxOffset = Math.max(xOffset, zOffset);
|
|
23
32
|
const fbxLoader = new FBXLoader();
|
|
24
|
-
const object =
|
|
33
|
+
const object = yield fbxLoader.loadAsync(fbxUrl);
|
|
25
34
|
transfromToMeshBasicMaterial(object, {
|
|
26
35
|
transparent: true,
|
|
27
36
|
side: THREE.DoubleSide,
|
|
@@ -35,7 +44,7 @@ export const ModelChassisCompassPlugin = (five, params) => {
|
|
|
35
44
|
object3d2LocalMatrix(object, { position, rotation, scale });
|
|
36
45
|
state.object = object;
|
|
37
46
|
return true;
|
|
38
|
-
};
|
|
47
|
+
});
|
|
39
48
|
const onCameraUpdate = ({ latitude }) => {
|
|
40
49
|
if (!state.object)
|
|
41
50
|
return;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { AnimationMixer, MeshBasicMaterial } from 'three';
|
|
2
11
|
import * as THREE from 'three';
|
|
3
12
|
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
|
|
@@ -8,31 +17,33 @@ import transfromToMeshBasicMaterial from '../shared-utils/three/transfromToMeshB
|
|
|
8
17
|
* 模型入户门引导插件
|
|
9
18
|
*/
|
|
10
19
|
export const ModelEntryDoorGuidePlugin = (five, params) => {
|
|
20
|
+
var _a, _b, _c;
|
|
11
21
|
// 局部状态
|
|
12
22
|
const state = {};
|
|
13
|
-
const defaultAnimationEnable = params.animationEnabled
|
|
14
|
-
const defaultModelPosition = params.position
|
|
15
|
-
const defaultRad = params.rad
|
|
23
|
+
const defaultAnimationEnable = (_a = params.animationEnabled) !== null && _a !== void 0 ? _a : true;
|
|
24
|
+
const defaultModelPosition = (_b = params.position) !== null && _b !== void 0 ? _b : undefined;
|
|
25
|
+
const defaultRad = (_c = params.rad) !== null && _c !== void 0 ? _c : undefined;
|
|
16
26
|
const defaultFbxUrl = params.fbx_url || '//vrlab-image4.ljcdn.com/release/web/entryDoorMini/Anim_Door1.fbx';
|
|
17
27
|
const mixers = [];
|
|
18
|
-
const load =
|
|
19
|
-
|
|
28
|
+
const load = (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
var _d, _e, _f, _g, _h, _j, _k;
|
|
30
|
+
const position = (_d = data === null || data === void 0 ? void 0 : data.position) !== null && _d !== void 0 ? _d : defaultModelPosition;
|
|
20
31
|
if (!position)
|
|
21
32
|
return Promise.reject(`ModelEntryDoorGuidePlugin.load(): position is undefined`);
|
|
22
33
|
const modelPosition = transformPositionToVector3(position);
|
|
23
|
-
const rad = data
|
|
24
|
-
const fbxUrl = data
|
|
34
|
+
const rad = (_e = data === null || data === void 0 ? void 0 : data.rad) !== null && _e !== void 0 ? _e : defaultRad;
|
|
35
|
+
const fbxUrl = (_f = data === null || data === void 0 ? void 0 : data.fbx_url) !== null && _f !== void 0 ? _f : defaultFbxUrl;
|
|
25
36
|
state.rad = rad;
|
|
26
37
|
if (rad === undefined)
|
|
27
38
|
return Promise.reject(`ModelEntryDoorGuidePlugin.load(): rad is ${rad}`);
|
|
28
39
|
// 加载模型
|
|
29
|
-
const object =
|
|
40
|
+
const object = yield new FBXLoader().loadAsync(fbxUrl);
|
|
30
41
|
// 设置位置
|
|
31
42
|
object.position.copy(modelPosition);
|
|
32
43
|
object.rotation.z = rad;
|
|
33
44
|
object.scale.set(0.8, 0.8, 0.8);
|
|
34
45
|
transfromToMeshBasicMaterial(object, { transparent: true, side: THREE.DoubleSide });
|
|
35
|
-
const textMesh = object.children
|
|
46
|
+
const textMesh = (_k = (_j = (_h = (_g = object.children) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.children) === null || _j === void 0 ? void 0 : _j[3]) === null || _k === void 0 ? void 0 : _k.clone();
|
|
36
47
|
if (!textMesh)
|
|
37
48
|
return Promise.reject(`ModelEntryDoorGuidePlugin.load(): textMesh is ${textMesh}`);
|
|
38
49
|
textMesh.material = new MeshBasicMaterial({ transparent: true, map: createCanvasTextTexture('入户门') });
|
|
@@ -40,7 +51,7 @@ export const ModelEntryDoorGuidePlugin = (five, params) => {
|
|
|
40
51
|
object.children[0].add(textMesh);
|
|
41
52
|
state.object = object;
|
|
42
53
|
return true;
|
|
43
|
-
};
|
|
54
|
+
});
|
|
44
55
|
const initAnimation = () => {
|
|
45
56
|
if (state.animation)
|
|
46
57
|
return;
|
|
@@ -84,16 +95,17 @@ export const ModelEntryDoorGuidePlugin = (five, params) => {
|
|
|
84
95
|
};
|
|
85
96
|
const stop = () => {
|
|
86
97
|
action.stop();
|
|
87
|
-
stopAnimation
|
|
98
|
+
stopAnimation === null || stopAnimation === void 0 ? void 0 : stopAnimation();
|
|
88
99
|
stopAnimation = undefined;
|
|
89
100
|
};
|
|
90
101
|
const animation = { play, stop };
|
|
91
102
|
state.animation = animation;
|
|
92
103
|
};
|
|
93
104
|
const show = (config) => {
|
|
105
|
+
var _a;
|
|
94
106
|
if (!state.object)
|
|
95
107
|
return console.error('ModelEntryDoorGuidePlugin.enable(): object is ', state.object);
|
|
96
|
-
const animationEnable = config
|
|
108
|
+
const animationEnable = (_a = config === null || config === void 0 ? void 0 : config.animationEnable) !== null && _a !== void 0 ? _a : defaultAnimationEnable;
|
|
97
109
|
if (animationEnable) {
|
|
98
110
|
if (!state.animation)
|
|
99
111
|
initAnimation();
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
mount_component,
|
|
18
18
|
outro_and_destroy_block,
|
|
19
19
|
safe_not_equal,
|
|
20
|
+
set_style,
|
|
20
21
|
transition_in,
|
|
21
22
|
transition_out,
|
|
22
23
|
update_keyed_each
|
|
@@ -27,6 +28,7 @@ import { beforeUpdate, onDestroy, onMount } from "svelte";
|
|
|
27
28
|
import * as THREE from 'three';
|
|
28
29
|
import ItemLabelItem from './ItemLabelItem';
|
|
29
30
|
import "./events.type";
|
|
31
|
+
import debounce from '../shared-utils/debounce';
|
|
30
32
|
|
|
31
33
|
function add_css(target) {
|
|
32
34
|
append_styles(target, "svelte-rmdeb", ".item-labels-container.svelte-rmdeb{width:100%;height:100%;position:relative}");
|
|
@@ -34,11 +36,11 @@ function add_css(target) {
|
|
|
34
36
|
|
|
35
37
|
function get_each_context(ctx, list, i) {
|
|
36
38
|
const child_ctx = ctx.slice();
|
|
37
|
-
child_ctx[
|
|
39
|
+
child_ctx[27] = list[i];
|
|
38
40
|
return child_ctx;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
// (
|
|
43
|
+
// (159:1) {#each renderItemLabels as itemLabelItem (itemLabelItem.id)}
|
|
42
44
|
function create_each_block(key_1, ctx) {
|
|
43
45
|
let first;
|
|
44
46
|
let itemlabelitem;
|
|
@@ -46,7 +48,7 @@ function create_each_block(key_1, ctx) {
|
|
|
46
48
|
|
|
47
49
|
itemlabelitem = new ItemLabelItem({
|
|
48
50
|
props: {
|
|
49
|
-
itemLabel: /*itemLabelItem*/ ctx[
|
|
51
|
+
itemLabel: /*itemLabelItem*/ ctx[27],
|
|
50
52
|
hooks: /*hooks*/ ctx[0]
|
|
51
53
|
}
|
|
52
54
|
});
|
|
@@ -67,7 +69,7 @@ function create_each_block(key_1, ctx) {
|
|
|
67
69
|
p(new_ctx, dirty) {
|
|
68
70
|
ctx = new_ctx;
|
|
69
71
|
const itemlabelitem_changes = {};
|
|
70
|
-
if (dirty & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[
|
|
72
|
+
if (dirty & /*renderItemLabels*/ 2) itemlabelitem_changes.itemLabel = /*itemLabelItem*/ ctx[27];
|
|
71
73
|
if (dirty & /*hooks*/ 1) itemlabelitem_changes.hooks = /*hooks*/ ctx[0];
|
|
72
74
|
itemlabelitem.$set(itemlabelitem_changes);
|
|
73
75
|
},
|
|
@@ -94,7 +96,7 @@ function create_fragment(ctx) {
|
|
|
94
96
|
let div_resize_listener;
|
|
95
97
|
let current;
|
|
96
98
|
let each_value = /*renderItemLabels*/ ctx[1];
|
|
97
|
-
const get_key = ctx => /*itemLabelItem*/ ctx[
|
|
99
|
+
const get_key = ctx => /*itemLabelItem*/ ctx[27].id;
|
|
98
100
|
|
|
99
101
|
for (let i = 0; i < each_value.length; i += 1) {
|
|
100
102
|
let child_ctx = get_each_context(ctx, each_value, i);
|
|
@@ -111,7 +113,8 @@ function create_fragment(ctx) {
|
|
|
111
113
|
}
|
|
112
114
|
|
|
113
115
|
attr(div, "class", "item-labels-container svelte-rmdeb");
|
|
114
|
-
add_render_callback(() => /*div_elementresize_handler*/ ctx[
|
|
116
|
+
add_render_callback(() => /*div_elementresize_handler*/ ctx[10].call(div));
|
|
117
|
+
set_style(div, "opacity", /*itemsVisible*/ ctx[4] ? 1 : 0, false);
|
|
115
118
|
},
|
|
116
119
|
m(target, anchor) {
|
|
117
120
|
insert(target, div, anchor);
|
|
@@ -120,7 +123,7 @@ function create_fragment(ctx) {
|
|
|
120
123
|
each_blocks[i].m(div, null);
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[
|
|
126
|
+
div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[10].bind(div));
|
|
124
127
|
current = true;
|
|
125
128
|
},
|
|
126
129
|
p(ctx, [dirty]) {
|
|
@@ -130,6 +133,10 @@ function create_fragment(ctx) {
|
|
|
130
133
|
each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div, outro_and_destroy_block, create_each_block, null, get_each_context);
|
|
131
134
|
check_outros();
|
|
132
135
|
}
|
|
136
|
+
|
|
137
|
+
if (dirty & /*itemsVisible*/ 16) {
|
|
138
|
+
set_style(div, "opacity", /*itemsVisible*/ ctx[4] ? 1 : 0, false);
|
|
139
|
+
}
|
|
133
140
|
},
|
|
134
141
|
i(local) {
|
|
135
142
|
if (current) return;
|
|
@@ -179,46 +186,14 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
179
186
|
// 计算重叠
|
|
180
187
|
let cssOffsetLists = [];
|
|
181
188
|
|
|
189
|
+
// 动画过程中 itemsVisible 为 false
|
|
190
|
+
let itemsVisible = true;
|
|
191
|
+
|
|
182
192
|
/**
|
|
183
193
|
* 可见性策略:
|
|
184
194
|
* 1、当前楼层(假设先不考虑多楼层)
|
|
185
195
|
* 2、模型未被遮挡(一个 box 有没有被遮挡的计算? TODO)
|
|
186
196
|
* */
|
|
187
|
-
// 画辅助线
|
|
188
|
-
function addHelper(x, y, z, type, helper) {
|
|
189
|
-
let geometry, materials, mesh;
|
|
190
|
-
|
|
191
|
-
if (type === 'box') {
|
|
192
|
-
geometry = new THREE.BoxGeometry(0.6, 2.5, 1.010696);
|
|
193
|
-
let mats = [];
|
|
194
|
-
|
|
195
|
-
for (let i = 0; i < geometry.faces.length; i++) {
|
|
196
|
-
const material = new THREE.MeshBasicMaterial({
|
|
197
|
-
color: new THREE.Color(Math.random() * 0xffffff)
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
mats.push(material);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
materials = mats;
|
|
204
|
-
} else if (type === 'ball') {
|
|
205
|
-
geometry = new THREE.SphereGeometry(0.02, 0.02, 64);
|
|
206
|
-
materials = new THREE.MeshBasicMaterial({ color: new THREE.Color(0xffffff) });
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
mesh = new THREE.Mesh(geometry, materials);
|
|
210
|
-
|
|
211
|
-
// y 轴需要加一半的高度,因为position是从地面开始的,或者我应该算偏移更合理
|
|
212
|
-
mesh.position.set(x, y, z);
|
|
213
|
-
|
|
214
|
-
if (helper) {
|
|
215
|
-
const helper = new THREE.AxesHelper(5);
|
|
216
|
-
mesh.add(helper);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
five.scene.add(mesh);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
197
|
const getLabelVisible = (five, itemLabel) => {
|
|
223
198
|
// 虚拟 VR 仅有一层,不考虑楼层信息
|
|
224
199
|
const raycaster = new Raycaster();
|
|
@@ -238,8 +213,15 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
238
213
|
const getLabelCssOffset = (five, itemLabel) => {
|
|
239
214
|
const modelPosition = new Vector3(itemLabel.modelPosition[0], itemLabel.modelPosition[1], itemLabel.modelPosition[2]);
|
|
240
215
|
const cssPosition = five.project2d(modelPosition);
|
|
241
|
-
|
|
242
|
-
const
|
|
216
|
+
|
|
217
|
+
const xOffset = cssPosition === null || cssPosition === void 0
|
|
218
|
+
? void 0
|
|
219
|
+
: cssPosition.x;
|
|
220
|
+
|
|
221
|
+
const yOffset = cssPosition === null || cssPosition === void 0
|
|
222
|
+
? void 0
|
|
223
|
+
: cssPosition.y;
|
|
224
|
+
|
|
243
225
|
return [xOffset, yOffset];
|
|
244
226
|
};
|
|
245
227
|
|
|
@@ -281,18 +263,13 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
281
263
|
: true;
|
|
282
264
|
|
|
283
265
|
const visible = naturalVisible && !isOverlap([cssOffset[0], cssOffset[1] + strokeLength], curLabelWidth);
|
|
284
|
-
if (!visible) return {
|
|
266
|
+
if (!visible) return Object.assign(Object.assign({}, label), { visible });
|
|
285
267
|
cssOffsetLists.push(cssOffset);
|
|
286
268
|
|
|
287
269
|
// position
|
|
288
270
|
const transform = getLabelTransform(cssOffset);
|
|
289
271
|
|
|
290
|
-
return {
|
|
291
|
-
...label,
|
|
292
|
-
visible,
|
|
293
|
-
transform,
|
|
294
|
-
strokeLength
|
|
295
|
-
};
|
|
272
|
+
return Object.assign(Object.assign({}, label), { visible, transform, strokeLength });
|
|
296
273
|
});
|
|
297
274
|
|
|
298
275
|
const sortedItemLabelItems = newLabels.filter(({ visible }) => visible).map(label => ({
|
|
@@ -302,7 +279,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
302
279
|
|
|
303
280
|
return newLabels.map(label => {
|
|
304
281
|
const sortIndex = sortedItemLabelItems.findIndex(item => item.itemLabelItem.id === label.id);
|
|
305
|
-
if (sortIndex !== undefined) return {
|
|
282
|
+
if (sortIndex !== undefined) return Object.assign(Object.assign({}, label), { zIndex: sortIndex * 10 });
|
|
306
283
|
return label;
|
|
307
284
|
});
|
|
308
285
|
};
|
|
@@ -320,11 +297,22 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
320
297
|
$$invalidate(1, renderItemLabels = itemLabels);
|
|
321
298
|
curItemLabels = itemLabels;
|
|
322
299
|
onItemLabelUpdate();
|
|
323
|
-
|
|
324
|
-
// five.on('cameraUpdate', onItemLabelUpdate)
|
|
325
300
|
addResizeListener();
|
|
301
|
+
|
|
302
|
+
five.on('cameraUpdate', () => {
|
|
303
|
+
$$invalidate(4, itemsVisible = false);
|
|
304
|
+
handleCameraUpdate();
|
|
305
|
+
});
|
|
326
306
|
});
|
|
327
307
|
|
|
308
|
+
const handleCameraUpdate = debounce(
|
|
309
|
+
() => {
|
|
310
|
+
$$invalidate(4, itemsVisible = true);
|
|
311
|
+
onItemLabelUpdate();
|
|
312
|
+
},
|
|
313
|
+
300
|
|
314
|
+
);
|
|
315
|
+
|
|
328
316
|
const addResizeListener = () => {
|
|
329
317
|
wrapperSize = {
|
|
330
318
|
width: wrapper.clientWidth,
|
|
@@ -338,7 +326,6 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
338
326
|
if (curItemLabels !== itemLabels) {
|
|
339
327
|
$$invalidate(1, renderItemLabels = itemLabels);
|
|
340
328
|
curItemLabels = itemLabels;
|
|
341
|
-
console.log('--debug--update--');
|
|
342
329
|
onItemLabelUpdate();
|
|
343
330
|
}
|
|
344
331
|
};
|
|
@@ -356,9 +343,8 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
356
343
|
});
|
|
357
344
|
|
|
358
345
|
onDestroy(() => {
|
|
359
|
-
|
|
346
|
+
five.off('cameraUpdate');
|
|
360
347
|
resizeObserver.unobserve(wrapper);
|
|
361
|
-
|
|
362
348
|
curItemLabels = null;
|
|
363
349
|
$$invalidate(1, renderItemLabels = null);
|
|
364
350
|
wrapperSize = { width: 0, height: 0 };
|
|
@@ -372,12 +358,12 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
372
358
|
}
|
|
373
359
|
|
|
374
360
|
$$self.$$set = $$props => {
|
|
375
|
-
if ('five' in $$props) $$invalidate(
|
|
376
|
-
if ('modelOcclusionEnable' in $$props) $$invalidate(
|
|
377
|
-
if ('itemLabels' in $$props) $$invalidate(
|
|
378
|
-
if ('wrapper' in $$props) $$invalidate(
|
|
361
|
+
if ('five' in $$props) $$invalidate(5, five = $$props.five);
|
|
362
|
+
if ('modelOcclusionEnable' in $$props) $$invalidate(6, modelOcclusionEnable = $$props.modelOcclusionEnable);
|
|
363
|
+
if ('itemLabels' in $$props) $$invalidate(7, itemLabels = $$props.itemLabels);
|
|
364
|
+
if ('wrapper' in $$props) $$invalidate(8, wrapper = $$props.wrapper);
|
|
379
365
|
if ('hooks' in $$props) $$invalidate(0, hooks = $$props.hooks);
|
|
380
|
-
if ('displayStrategyType' in $$props) $$invalidate(
|
|
366
|
+
if ('displayStrategyType' in $$props) $$invalidate(9, displayStrategyType = $$props.displayStrategyType);
|
|
381
367
|
};
|
|
382
368
|
|
|
383
369
|
return [
|
|
@@ -385,6 +371,7 @@ function instance($$self, $$props, $$invalidate) {
|
|
|
385
371
|
renderItemLabels,
|
|
386
372
|
containerWidth,
|
|
387
373
|
containerHeight,
|
|
374
|
+
itemsVisible,
|
|
388
375
|
five,
|
|
389
376
|
modelOcclusionEnable,
|
|
390
377
|
itemLabels,
|
|
@@ -405,12 +392,12 @@ class Component extends SvelteComponent {
|
|
|
405
392
|
create_fragment,
|
|
406
393
|
safe_not_equal,
|
|
407
394
|
{
|
|
408
|
-
five:
|
|
409
|
-
modelOcclusionEnable:
|
|
410
|
-
itemLabels:
|
|
411
|
-
wrapper:
|
|
395
|
+
five: 5,
|
|
396
|
+
modelOcclusionEnable: 6,
|
|
397
|
+
itemLabels: 7,
|
|
398
|
+
wrapper: 8,
|
|
412
399
|
hooks: 0,
|
|
413
|
-
displayStrategyType:
|
|
400
|
+
displayStrategyType: 9
|
|
414
401
|
},
|
|
415
402
|
add_css
|
|
416
403
|
);
|