@realsee/dnalogel 2.0.0-alpha.4 → 2.0.0-alpha.7
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 +14 -0
- package/README.md +44 -5
- package/dist/dnalogel.cjs.js +7 -2
- package/dist/dnalogel.es.js +3668 -184
- package/dist/dnalogel.umd.js +7 -2
- package/dist/style.css +1 -1
- package/libs/CSS3DRenderPlugin/index.js +1 -1
- package/libs/PanoCompassPlugin/Assets/roomInfoIcon.d.ts +1 -0
- package/libs/PanoCompassPlugin/Assets/roomInfoIcon.js +1 -0
- package/libs/PanoCompassPlugin/getRoomInfoInstance.d.ts +8 -0
- package/libs/PanoCompassPlugin/getRoomInfoInstance.js +48 -0
- package/libs/PanoCompassPlugin/index.d.ts +29 -3
- package/libs/PanoCompassPlugin/index.js +126 -44
- package/libs/PanoMeasurePlugin/Controller/BaseController.d.ts +36 -0
- package/libs/PanoMeasurePlugin/Controller/BaseController.js +69 -0
- package/libs/PanoMeasurePlugin/Controller/EditController.d.ts +52 -0
- package/libs/PanoMeasurePlugin/Controller/EditController.js +216 -0
- package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.d.ts +12 -0
- package/libs/PanoMeasurePlugin/Controller/ShortcutKeyController.js +44 -0
- package/libs/PanoMeasurePlugin/Controller/WatchController.d.ts +25 -0
- package/libs/PanoMeasurePlugin/Controller/WatchController.js +223 -0
- package/libs/PanoMeasurePlugin/Controller/index.d.ts +61 -0
- package/libs/PanoMeasurePlugin/Controller/index.js +176 -0
- package/libs/PanoMeasurePlugin/Model/index.d.ts +38 -0
- package/libs/PanoMeasurePlugin/Model/index.js +114 -0
- package/libs/PanoMeasurePlugin/Model/line.d.ts +30 -0
- package/libs/PanoMeasurePlugin/Model/line.js +64 -0
- package/libs/PanoMeasurePlugin/Model/point.d.ts +16 -0
- package/libs/PanoMeasurePlugin/Model/point.js +28 -0
- package/libs/PanoMeasurePlugin/Model/polyline.d.ts +16 -0
- package/libs/PanoMeasurePlugin/Model/polyline.js +48 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.d.ts +2 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete.svg.js +15 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.d.ts +2 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_bg.png.js +2 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.d.ts +2 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/_Assets/delete_hover_bg.png.js +2 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.d.ts +22 -0
- package/libs/PanoMeasurePlugin/Modules/DeleteDom/index.js +108 -0
- package/libs/PanoMeasurePlugin/Modules/FiveHelper.d.ts +11 -0
- package/libs/PanoMeasurePlugin/Modules/FiveHelper.js +33 -0
- package/libs/PanoMeasurePlugin/Modules/GuideController.d.ts +18 -0
- package/libs/PanoMeasurePlugin/Modules/GuideController.js +75 -0
- package/libs/PanoMeasurePlugin/Modules/Magnifier.d.ts +24 -0
- package/libs/PanoMeasurePlugin/Modules/Magnifier.js +103 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/HTML.d.ts +6 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/HTML.js +117 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.d.ts +18 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/MainBtnController.js +102 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.d.ts +12 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/Revoke/index.js +35 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/index.d.ts +16 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/index.js +69 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/style.d.ts +17 -0
- package/libs/PanoMeasurePlugin/Modules/UIController/style.js +78 -0
- package/libs/PanoMeasurePlugin/index.d.ts +7 -0
- package/libs/PanoMeasurePlugin/index.js +5 -0
- package/libs/PanoMeasurePlugin/typings/data.d.ts +28 -0
- package/libs/PanoMeasurePlugin/typings/data.js +1 -0
- package/libs/PanoMeasurePlugin/typings/event.type.d.ts +28 -0
- package/libs/PanoMeasurePlugin/typings/event.type.js +1 -0
- package/libs/PanoMeasurePlugin/typings/utils.type.d.ts +1 -0
- package/libs/PanoMeasurePlugin/typings/utils.type.js +1 -0
- package/libs/PanoMeasurePlugin/utils/clearGroup.d.ts +2 -0
- package/libs/PanoMeasurePlugin/utils/clearGroup.js +3 -0
- package/libs/PanoMeasurePlugin/utils/constants.d.ts +4 -0
- package/libs/PanoMeasurePlugin/utils/constants.js +31 -0
- package/libs/PanoMeasurePlugin/utils/distanceDom.d.ts +28 -0
- package/libs/PanoMeasurePlugin/utils/distanceDom.js +114 -0
- package/libs/PanoMeasurePlugin/utils/findAssociatedLines.d.ts +2 -0
- package/libs/PanoMeasurePlugin/utils/findAssociatedLines.js +21 -0
- package/libs/PanoMeasurePlugin/utils/findClosestPoint.d.ts +10 -0
- package/libs/PanoMeasurePlugin/utils/findClosestPoint.js +27 -0
- package/libs/PanoMeasurePlugin/utils/getIntersectionFromEvent.d.ts +4 -0
- package/libs/PanoMeasurePlugin/utils/getIntersectionFromEvent.js +9 -0
- package/libs/PanoMeasurePlugin/utils/getPointFromHammerEvent.d.ts +10 -0
- package/libs/PanoMeasurePlugin/utils/getPointFromHammerEvent.js +14 -0
- package/libs/PanoMeasurePlugin/utils/ironbox.d.ts +1 -0
- package/libs/PanoMeasurePlugin/utils/ironbox.js +1 -0
- package/libs/PanoMeasurePlugin/utils/isNDCPointInScreen.d.ts +2 -0
- package/libs/PanoMeasurePlugin/utils/isNDCPointInScreen.js +6 -0
- package/libs/PanoMeasurePlugin/utils/line.d.ts +17 -0
- package/libs/PanoMeasurePlugin/utils/line.js +32 -0
- package/libs/PanoMeasurePlugin/utils/math.d.ts +17 -0
- package/libs/PanoMeasurePlugin/utils/math.js +44 -0
- package/libs/PanoMeasurePlugin/utils/mouseGroup.d.ts +2 -0
- package/libs/PanoMeasurePlugin/utils/mouseGroup.js +21 -0
- package/libs/PanoMeasurePlugin/utils/ndc2Screen.d.ts +5 -0
- package/libs/PanoMeasurePlugin/utils/ndc2Screen.js +6 -0
- package/libs/PanoRulerPlugin/index.js +1 -0
- package/libs/PanoRulerPlugin/style.d.ts +1 -1
- package/libs/PanoRulerPlugin/style.js +1 -0
- package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.svelte +3 -3
- package/libs/floorplan/ModelFloorplanPlugin/Components/Camera.svelte.map +1 -1
- package/libs/floorplan/ModelFloorplanPlugin/Controller.d.ts +2 -0
- package/libs/floorplan/ModelFloorplanPlugin/Controller.js +3 -1
- package/libs/floorplan/TopviewFloorplanPlugin/Controller.d.ts +2 -0
- package/libs/floorplan/TopviewFloorplanPlugin/Controller.js +4 -3
- package/libs/floorplan/constant.d.ts +5 -0
- package/libs/floorplan/constant.js +6 -0
- package/libs/floorplan/typings/floorplanServerData.d.ts +4 -0
- package/libs/index.d.ts +4 -1
- package/libs/index.js +4 -1
- package/libs/shared-utils/getPxmm.d.ts +6 -1
- package/libs/shared-utils/getPxmm.js +26 -12
- package/package.json +2 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default class Revoke {
|
|
2
|
+
container;
|
|
3
|
+
revokeIcon;
|
|
4
|
+
revokeItem;
|
|
5
|
+
measureController;
|
|
6
|
+
constructor(measureController, container) {
|
|
7
|
+
this.measureController = measureController;
|
|
8
|
+
this.container = container;
|
|
9
|
+
const revokeIcon = this.container.querySelector('.fpm__revoke-icon');
|
|
10
|
+
const revokeItem = this.container.querySelector('.fpm__revoke');
|
|
11
|
+
if (!revokeIcon || !revokeItem)
|
|
12
|
+
throw new Error('不正确的选择器');
|
|
13
|
+
this.revokeIcon = revokeIcon;
|
|
14
|
+
this.revokeItem = revokeItem;
|
|
15
|
+
this.revokeIcon.addEventListener('click', this.onClick);
|
|
16
|
+
measureController.hook.on('modeChange', this.onModeChange);
|
|
17
|
+
}
|
|
18
|
+
dispose() {
|
|
19
|
+
this.revokeIcon.removeEventListener('click', this.onClick);
|
|
20
|
+
this.measureController.hook.off('modeChange', this.onModeChange);
|
|
21
|
+
}
|
|
22
|
+
onClick = () => {
|
|
23
|
+
this.measureController.revoke();
|
|
24
|
+
};
|
|
25
|
+
onModeChange = (mode) => {
|
|
26
|
+
if (mode !== 'Edit') {
|
|
27
|
+
this.revokeItem.classList.remove('enabled');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.revokeItem.classList.add('enabled');
|
|
31
|
+
};
|
|
32
|
+
handleRevoke = () => {
|
|
33
|
+
return () => { };
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import MeasureController from '../../Controller';
|
|
2
|
+
export interface UIControllerParams {
|
|
3
|
+
container: Element;
|
|
4
|
+
}
|
|
5
|
+
export declare class UIController {
|
|
6
|
+
private revoke?;
|
|
7
|
+
private container;
|
|
8
|
+
private mainController?;
|
|
9
|
+
private disposers;
|
|
10
|
+
private measureController;
|
|
11
|
+
constructor(measureController: MeasureController, params: UIControllerParams);
|
|
12
|
+
dispose(): void;
|
|
13
|
+
show(): this;
|
|
14
|
+
hide(): this;
|
|
15
|
+
private handleExit;
|
|
16
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import htmlString from './HTML';
|
|
2
|
+
import { uiWrapperStyle, operatingSpaceStyle, controllerBackgroundStyle, buttonGroupStyle, exitIconStyle, exitItemStyle, textStyle, } from './style';
|
|
3
|
+
import { MainBtnController } from './MainBtnController';
|
|
4
|
+
import Revoke from './Revoke';
|
|
5
|
+
export class UIController {
|
|
6
|
+
revoke;
|
|
7
|
+
container;
|
|
8
|
+
mainController;
|
|
9
|
+
disposers = [];
|
|
10
|
+
measureController;
|
|
11
|
+
constructor(measureController, params) {
|
|
12
|
+
this.measureController = measureController;
|
|
13
|
+
this.container = document.createElement('div');
|
|
14
|
+
this.container.innerHTML = htmlString;
|
|
15
|
+
this.container.classList.add('fpm__ui-controller');
|
|
16
|
+
params.container.appendChild(this.container);
|
|
17
|
+
const textDoms = this.container.querySelectorAll('.fpm__text');
|
|
18
|
+
const UIItems = this.container.querySelectorAll('.fpm__ui-item');
|
|
19
|
+
const bgDom = this.container.querySelector('.fpm_ui-bg');
|
|
20
|
+
const operatingSpaceDom = this.container.querySelector('.fpm_operating-space');
|
|
21
|
+
Object.assign(bgDom?.style, controllerBackgroundStyle);
|
|
22
|
+
Object.assign(operatingSpaceDom?.style, operatingSpaceStyle);
|
|
23
|
+
Object.assign(this.container.style, uiWrapperStyle);
|
|
24
|
+
UIItems.forEach((item) => Object.assign(item.style, buttonGroupStyle));
|
|
25
|
+
textDoms.forEach((item) => Object.assign(item.style, textStyle));
|
|
26
|
+
}
|
|
27
|
+
dispose() {
|
|
28
|
+
this.hide();
|
|
29
|
+
this.container.remove();
|
|
30
|
+
}
|
|
31
|
+
show() {
|
|
32
|
+
this.container.style.opacity = '1';
|
|
33
|
+
this.container.style.transform = 'translate(0, 0)';
|
|
34
|
+
this.revoke = new Revoke(this.measureController, this.container);
|
|
35
|
+
this.mainController = new MainBtnController(this.measureController, this.container);
|
|
36
|
+
this.disposers.push(this.handleExit());
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
hide() {
|
|
40
|
+
this.container.style.opacity = '0';
|
|
41
|
+
this.container.style.transform = 'translate(0, 10px)';
|
|
42
|
+
this.revoke?.dispose();
|
|
43
|
+
this.mainController?.dispose();
|
|
44
|
+
this.disposers.forEach((disposer) => disposer());
|
|
45
|
+
this.disposers = [];
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
handleExit = () => {
|
|
49
|
+
const exitIcon = this.container.querySelector('.fpm__exit-icon');
|
|
50
|
+
const exitItem = this.container.querySelector('.fpm__exit');
|
|
51
|
+
if (!exitItem || !exitIcon)
|
|
52
|
+
throw new Error('cannot find dom');
|
|
53
|
+
Object.assign(exitItem.style, exitItemStyle);
|
|
54
|
+
Object.assign(exitIcon?.style, exitIconStyle);
|
|
55
|
+
const onMouseEnter = () => (exitItem.style.opacity = '1');
|
|
56
|
+
const onMouseLeave = () => (exitItem.style.opacity = '0.7');
|
|
57
|
+
const handleClick = () => {
|
|
58
|
+
this.measureController.disable();
|
|
59
|
+
};
|
|
60
|
+
exitIcon.addEventListener('click', handleClick);
|
|
61
|
+
exitIcon.addEventListener('mouseenter', onMouseEnter);
|
|
62
|
+
exitIcon.addEventListener('mouseleave', onMouseLeave);
|
|
63
|
+
return () => {
|
|
64
|
+
exitIcon.removeEventListener('click', handleClick);
|
|
65
|
+
exitIcon.removeEventListener('mouseenter', onMouseEnter);
|
|
66
|
+
exitIcon.removeEventListener('mouseleave', onMouseLeave);
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const addHoverImage = "//vrlab-static.ljcdn.com/release/web/measure/add-hover.944fffad.png";
|
|
2
|
+
export declare const addNormalImage = "//vrlab-static.ljcdn.com/release/web/measure/add-normal.39e967e9.png";
|
|
3
|
+
export declare const cancelHoverImage = "//vrlab-static.ljcdn.com/release/web/measure/canale-hover.74b37e24.png";
|
|
4
|
+
export declare const cancelNormalImage = "//vrlab-static.ljcdn.com/release/web/measure/cancle-normal.77bb326c.png";
|
|
5
|
+
export declare const doneHoverImage = "//vrlab-static.ljcdn.com/release/web/measure/done-hover.9e09438b.png";
|
|
6
|
+
export declare const doneNormalImage = "//vrlab-static.ljcdn.com/release/web/measure/done-normal.4fcddd73.png";
|
|
7
|
+
export declare const exitImage = "//vrlab-static.ljcdn.com/release/web/measure/exit.6693ad51.png";
|
|
8
|
+
export declare const revokeImage = "//vrlab-static.ljcdn.com/release/web/measure/revoke.3e424843.png";
|
|
9
|
+
export declare const uiWrapperStyle: Partial<CSSStyleDeclaration>;
|
|
10
|
+
export declare const operatingSpaceStyle: Partial<CSSStyleDeclaration>;
|
|
11
|
+
export declare const buttonGroupStyle: Partial<CSSStyleDeclaration>;
|
|
12
|
+
export declare const controllerBackgroundStyle: Partial<CSSStyleDeclaration>;
|
|
13
|
+
export declare const mainItemStyle: Partial<CSSStyleDeclaration>;
|
|
14
|
+
export declare const exitItemStyle: Partial<CSSStyleDeclaration>;
|
|
15
|
+
export declare const mainIconStyle: Partial<CSSStyleDeclaration>;
|
|
16
|
+
export declare const exitIconStyle: Partial<CSSStyleDeclaration>;
|
|
17
|
+
export declare const textStyle: Partial<CSSStyleDeclaration>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export const addHoverImage = '//vrlab-static.ljcdn.com/release/web/measure/add-hover.944fffad.png';
|
|
2
|
+
export const addNormalImage = '//vrlab-static.ljcdn.com/release/web/measure/add-normal.39e967e9.png';
|
|
3
|
+
export const cancelHoverImage = '//vrlab-static.ljcdn.com/release/web/measure/canale-hover.74b37e24.png';
|
|
4
|
+
export const cancelNormalImage = '//vrlab-static.ljcdn.com/release/web/measure/cancle-normal.77bb326c.png';
|
|
5
|
+
export const doneHoverImage = '//vrlab-static.ljcdn.com/release/web/measure/done-hover.9e09438b.png';
|
|
6
|
+
export const doneNormalImage = '//vrlab-static.ljcdn.com/release/web/measure/done-normal.4fcddd73.png';
|
|
7
|
+
export const exitImage = '//vrlab-static.ljcdn.com/release/web/measure/exit.6693ad51.png';
|
|
8
|
+
export const revokeImage = '//vrlab-static.ljcdn.com/release/web/measure/revoke.3e424843.png';
|
|
9
|
+
export const uiWrapperStyle = {
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
top: '0',
|
|
12
|
+
left: '0',
|
|
13
|
+
width: '100%',
|
|
14
|
+
height: '100%',
|
|
15
|
+
opacity: '0',
|
|
16
|
+
transform: 'translate(0, 10px)',
|
|
17
|
+
transition: 'opacity 500ms ease-in-out, transform 500ms ease-in-out',
|
|
18
|
+
};
|
|
19
|
+
export const operatingSpaceStyle = {
|
|
20
|
+
position: 'absolute',
|
|
21
|
+
left: '50%',
|
|
22
|
+
bottom: '32px',
|
|
23
|
+
transform: 'translateX(-50%)',
|
|
24
|
+
width: '300px',
|
|
25
|
+
height: '89px',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
justifyContent: 'space-between',
|
|
28
|
+
fontSize: '16px',
|
|
29
|
+
pointerEvents: 'all',
|
|
30
|
+
color: '#fff',
|
|
31
|
+
zIndex: '10',
|
|
32
|
+
};
|
|
33
|
+
export const buttonGroupStyle = {
|
|
34
|
+
height: '100%',
|
|
35
|
+
width: 'max-content',
|
|
36
|
+
display: 'flex',
|
|
37
|
+
flexDirection: 'column',
|
|
38
|
+
justifyContent: 'space-between',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
};
|
|
41
|
+
// 操作区下方的背景
|
|
42
|
+
export const controllerBackgroundStyle = {
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
bottom: '0',
|
|
45
|
+
left: '0',
|
|
46
|
+
opacity: '0.5',
|
|
47
|
+
width: '100%',
|
|
48
|
+
height: '184px',
|
|
49
|
+
background: `linear-gradient(180deg, rgba(0,0,0,0.00) 0%, #000000 100%)`,
|
|
50
|
+
zIndex: '0',
|
|
51
|
+
};
|
|
52
|
+
// item
|
|
53
|
+
export const mainItemStyle = {
|
|
54
|
+
margin: '0 80px',
|
|
55
|
+
opacity: '0.7',
|
|
56
|
+
};
|
|
57
|
+
export const exitItemStyle = {
|
|
58
|
+
opacity: '0.7',
|
|
59
|
+
};
|
|
60
|
+
// icon
|
|
61
|
+
export const mainIconStyle = {
|
|
62
|
+
width: '60px',
|
|
63
|
+
height: '60px',
|
|
64
|
+
backgroundSize: '100%',
|
|
65
|
+
cursor: 'pointer',
|
|
66
|
+
};
|
|
67
|
+
export const exitIconStyle = {
|
|
68
|
+
width: '40px',
|
|
69
|
+
height: '40px',
|
|
70
|
+
marginTop: '10px',
|
|
71
|
+
backgroundSize: '100%',
|
|
72
|
+
cursor: 'pointer',
|
|
73
|
+
};
|
|
74
|
+
// text
|
|
75
|
+
export const textStyle = {
|
|
76
|
+
cursor: 'default',
|
|
77
|
+
userSelect: 'none',
|
|
78
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FivePlugin } from '@realsee/five';
|
|
2
|
+
import MeasureController, { MeasurePluginParameter } from './Controller';
|
|
3
|
+
declare const PanoMeasurePlugin: FivePlugin<MeasurePluginParameter, PluginReturns>;
|
|
4
|
+
export default PanoMeasurePlugin;
|
|
5
|
+
export declare type PluginReturns = MeasureController;
|
|
6
|
+
export type { PluginEvent } from './typings/event.type';
|
|
7
|
+
export type { LineJson, PointJson } from './typings/data';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface LineCompletelyJson {
|
|
2
|
+
id: string;
|
|
3
|
+
points: PointJson[];
|
|
4
|
+
}
|
|
5
|
+
export interface PolylineCompletelyJson {
|
|
6
|
+
id: string;
|
|
7
|
+
points: PointJson[];
|
|
8
|
+
lines: LineCompletelyJson[];
|
|
9
|
+
}
|
|
10
|
+
export interface LineJson {
|
|
11
|
+
id: string;
|
|
12
|
+
points: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface PolylineJson {
|
|
15
|
+
id: string;
|
|
16
|
+
points: string[];
|
|
17
|
+
lines: string[];
|
|
18
|
+
}
|
|
19
|
+
export interface PointJson {
|
|
20
|
+
id: string;
|
|
21
|
+
lines: string[];
|
|
22
|
+
position: number[];
|
|
23
|
+
}
|
|
24
|
+
export interface PluginData {
|
|
25
|
+
lines: LineJson[];
|
|
26
|
+
points: PointJson[];
|
|
27
|
+
polylines: PolylineJson[];
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { SubscribeEventMap } from '@realsee/five';
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
|
+
import { Mode } from '../Controller';
|
|
4
|
+
import { LineCompletelyJson } from './data';
|
|
5
|
+
interface ControllerEvent extends SubscribeEventMap {
|
|
6
|
+
/**
|
|
7
|
+
* Mode 变更
|
|
8
|
+
*/
|
|
9
|
+
modeChange: (mode: Mode) => void;
|
|
10
|
+
}
|
|
11
|
+
interface WatchEvent extends SubscribeEventMap {
|
|
12
|
+
selectedChange: (lines: LineCompletelyJson[]) => void;
|
|
13
|
+
}
|
|
14
|
+
interface EditEvent {
|
|
15
|
+
/**
|
|
16
|
+
* 编辑线条变更
|
|
17
|
+
*/
|
|
18
|
+
editedLineChange: (lines: LineCompletelyJson[]) => void;
|
|
19
|
+
anchorChange: (anchor: Vector3 | null) => void;
|
|
20
|
+
}
|
|
21
|
+
interface DragEvent extends SubscribeEventMap {
|
|
22
|
+
wantsDragLine: (event: {
|
|
23
|
+
point: string;
|
|
24
|
+
lines: string[];
|
|
25
|
+
}) => boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare type PluginEvent = ControllerEvent & EditEvent & WatchEvent & DragEvent;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ValueOf<T> = T[keyof T];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TextureLoader, Color } from 'three';
|
|
2
|
+
const lineWidth = 2;
|
|
3
|
+
const lightLineWidth = 4;
|
|
4
|
+
const lineColor = new Color(0xffffff);
|
|
5
|
+
const lightLineColor = new Color(0x2d7cff);
|
|
6
|
+
const pointColor = new Color(0xffffff);
|
|
7
|
+
const lightPointColor = new Color(0x2d7cff);
|
|
8
|
+
const pointSize = 8;
|
|
9
|
+
const lightPointSize = 16;
|
|
10
|
+
const pointImage = 'data:image/png;base64,' +
|
|
11
|
+
'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMAG/Py2baba05un7UgfgAAAHJJREFUKM9joBpgLHVSCRdA4metAoJlCJHmVWBgAeNzroKCCVCBLpjACqgJVjCBxRBT2FbBQQJYQAohsBAsUIUQWA4WiEIILAULeCEEloAFtBACizAEMLRgGIphLabDMJ2O6TlM72MGECIIMQIZIxqoBQCPvpJ/e9FaAAAAAABJRU5ErkJggg==';
|
|
12
|
+
const pointTexture = new TextureLoader().load(pointImage);
|
|
13
|
+
export const normalLineOpts = {
|
|
14
|
+
pointTexture,
|
|
15
|
+
pointSize,
|
|
16
|
+
lineWidth,
|
|
17
|
+
lineColor,
|
|
18
|
+
pointColor,
|
|
19
|
+
lineRenderOrder: 20,
|
|
20
|
+
pointsRenderOrder: 20,
|
|
21
|
+
};
|
|
22
|
+
export const dashLineOpts = Object.assign({}, normalLineOpts, { dashed: true });
|
|
23
|
+
export const lightLineOpts = {
|
|
24
|
+
pointTexture,
|
|
25
|
+
pointSize: lightPointSize,
|
|
26
|
+
lineWidth: lightLineWidth,
|
|
27
|
+
lineColor: lightLineColor,
|
|
28
|
+
pointColor: lightPointColor,
|
|
29
|
+
lineRenderOrder: 10,
|
|
30
|
+
pointsRenderOrder: 10,
|
|
31
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Line from '../Model/line';
|
|
2
|
+
import { Five } from '@realsee/five';
|
|
3
|
+
import { Vector3 } from 'three';
|
|
4
|
+
import { LineCompletelyJson, PolylineCompletelyJson } from '../typings/data';
|
|
5
|
+
export declare type DistanceItem = ReturnType<typeof creatDistanceItem>;
|
|
6
|
+
export interface UserDistanceItem {
|
|
7
|
+
element: Element;
|
|
8
|
+
highlight: () => void;
|
|
9
|
+
unHighlight: () => void;
|
|
10
|
+
update: (params: {
|
|
11
|
+
line: LineCompletelyJson;
|
|
12
|
+
polyline: PolylineCompletelyJson;
|
|
13
|
+
}) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface IDistanceItemProps {
|
|
16
|
+
line: Line;
|
|
17
|
+
userDistanceItem?: UserDistanceItem;
|
|
18
|
+
clickCallback?: (item: DistanceItem) => unknown;
|
|
19
|
+
}
|
|
20
|
+
export declare function creatDistanceItem(props: IDistanceItemProps): {
|
|
21
|
+
lineID: string;
|
|
22
|
+
ndcPosition: Vector3;
|
|
23
|
+
update: (five: Five) => void;
|
|
24
|
+
appendTo: (container: Element) => void;
|
|
25
|
+
remove: () => void;
|
|
26
|
+
highlight: () => void;
|
|
27
|
+
unHighlight: () => void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Vector2, Vector3 } from 'three';
|
|
2
|
+
import isNDCPointInScreen from './isNDCPointInScreen';
|
|
3
|
+
function creatContentDom() {
|
|
4
|
+
const contentDom = document.createElement('div');
|
|
5
|
+
contentDom.style.height = '24px';
|
|
6
|
+
contentDom.style.width = '62px';
|
|
7
|
+
contentDom.style.lineHeight = '24px';
|
|
8
|
+
contentDom.style.textAlign = 'center';
|
|
9
|
+
contentDom.style.transform = 'translate(-50%, -50%)';
|
|
10
|
+
contentDom.style.borderRadius = '12px';
|
|
11
|
+
contentDom.style.fontSize = '14px';
|
|
12
|
+
contentDom.style.color = '#000000';
|
|
13
|
+
contentDom.style.background = '#fff';
|
|
14
|
+
contentDom.style.pointerEvents = 'all';
|
|
15
|
+
contentDom.style.cursor = 'pointer';
|
|
16
|
+
return contentDom;
|
|
17
|
+
}
|
|
18
|
+
function createContainerDom(line) {
|
|
19
|
+
const containerDom = document.createElement('div');
|
|
20
|
+
containerDom.id = 'distance_' + line.id;
|
|
21
|
+
containerDom.classList.add('five-plugin-measure__distance');
|
|
22
|
+
containerDom.style.opacity = '0';
|
|
23
|
+
containerDom.style.position = 'absolute';
|
|
24
|
+
containerDom.style.left = '0';
|
|
25
|
+
containerDom.style.top = '0';
|
|
26
|
+
containerDom.style.transform = 'translate3d(0, 0, 0)';
|
|
27
|
+
return containerDom;
|
|
28
|
+
}
|
|
29
|
+
export function creatDistanceItem(props) {
|
|
30
|
+
function handleClick() {
|
|
31
|
+
highlight();
|
|
32
|
+
props.clickCallback?.(distanceItem);
|
|
33
|
+
}
|
|
34
|
+
function highlight() {
|
|
35
|
+
if (userDistanceItem)
|
|
36
|
+
return userDistanceItem.highlight();
|
|
37
|
+
contentDom.style.border = '1px solid #538FFF';
|
|
38
|
+
contentDom.style.color = '#538FFF';
|
|
39
|
+
}
|
|
40
|
+
function unHighlight() {
|
|
41
|
+
if (userDistanceItem)
|
|
42
|
+
return userDistanceItem.unHighlight();
|
|
43
|
+
contentDom.style.border = 'none';
|
|
44
|
+
contentDom.style.color = '#000';
|
|
45
|
+
}
|
|
46
|
+
function update(five) {
|
|
47
|
+
const fiveElement = five.getElement();
|
|
48
|
+
if (!fiveElement)
|
|
49
|
+
return;
|
|
50
|
+
const screenWidth = fiveElement.clientWidth;
|
|
51
|
+
const screenHeight = fiveElement.clientHeight;
|
|
52
|
+
if (line.points.length < 2)
|
|
53
|
+
return;
|
|
54
|
+
const [startPoint, endPoint] = line.points;
|
|
55
|
+
const ndcStartPosition = startPoint.position.clone().project(five.camera);
|
|
56
|
+
const ndcEndPosition = endPoint.position.clone().project(five.camera);
|
|
57
|
+
const ndcDomPosition = ndcStartPosition.clone().lerp(ndcEndPosition, 0.5);
|
|
58
|
+
const visible = (() => {
|
|
59
|
+
// 对于超过近平面和远平面的点,计算会有问题
|
|
60
|
+
if (Math.abs(ndcStartPosition.z) > 1 || Math.abs(ndcEndPosition.z) > 1)
|
|
61
|
+
return false;
|
|
62
|
+
if (!isNDCPointInScreen(ndcStartPosition) && !isNDCPointInScreen(ndcEndPosition))
|
|
63
|
+
return false;
|
|
64
|
+
if (!isNDCPointInScreen(ndcDomPosition))
|
|
65
|
+
return false;
|
|
66
|
+
const screenStartPosition = new Vector2(ndcStartPosition.x * screenWidth, ndcStartPosition.y * screenHeight);
|
|
67
|
+
const screenEndPosition = new Vector2(ndcEndPosition.x * screenWidth, ndcEndPosition.y * screenHeight);
|
|
68
|
+
if (screenStartPosition.distanceTo(screenEndPosition) < 20)
|
|
69
|
+
return false;
|
|
70
|
+
return true;
|
|
71
|
+
})();
|
|
72
|
+
if (visible === false) {
|
|
73
|
+
containerDom.style.opacity = '0';
|
|
74
|
+
containerDom.style.pointerEvents = 'none';
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
// 更新 UI
|
|
78
|
+
const left = ((ndcDomPosition.x + 1) / 2) * screenWidth;
|
|
79
|
+
const top = (-(ndcDomPosition.y - 1) / 2) * screenHeight;
|
|
80
|
+
containerDom.style.transform = `translate3d(${left}px, ${top}px, 10px)`;
|
|
81
|
+
containerDom.style.opacity = '1';
|
|
82
|
+
containerDom.style.pointerEvents = 'all';
|
|
83
|
+
if (userDistanceItem) {
|
|
84
|
+
userDistanceItem.update({ line: line.toCompletelyJson(), polyline: line.getPolyline().toCompletelyJson() });
|
|
85
|
+
}
|
|
86
|
+
const distanceString = startPoint.position.clone().distanceTo(endPoint.position).toFixed(2) + 'm';
|
|
87
|
+
contentDom.innerText !== distanceString && (contentDom.innerText = distanceString);
|
|
88
|
+
}
|
|
89
|
+
function appendTo(container) {
|
|
90
|
+
container.appendChild(containerDom);
|
|
91
|
+
containerDom.addEventListener('click', handleClick);
|
|
92
|
+
}
|
|
93
|
+
function remove() {
|
|
94
|
+
contentDom.removeEventListener('click', handleClick);
|
|
95
|
+
containerDom.remove();
|
|
96
|
+
}
|
|
97
|
+
const { line } = props;
|
|
98
|
+
const lineID = line.id;
|
|
99
|
+
const contentDom = creatContentDom();
|
|
100
|
+
const containerDom = createContainerDom(line);
|
|
101
|
+
const userDistanceItem = props.userDistanceItem;
|
|
102
|
+
const ndcPosition = new Vector3(0, 0, 0);
|
|
103
|
+
const distanceItem = {
|
|
104
|
+
lineID,
|
|
105
|
+
ndcPosition,
|
|
106
|
+
update,
|
|
107
|
+
appendTo,
|
|
108
|
+
remove,
|
|
109
|
+
highlight: highlight,
|
|
110
|
+
unHighlight: unHighlight,
|
|
111
|
+
};
|
|
112
|
+
userDistanceItem?.element ? containerDom.appendChild(userDistanceItem.element) : containerDom.appendChild(contentDom);
|
|
113
|
+
return distanceItem;
|
|
114
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function findAssociatedLines(line) {
|
|
2
|
+
// 找跟这个线段相邻的线
|
|
3
|
+
const mergeNextLine = (point, nextIndex, target) => {
|
|
4
|
+
const nextLine = point.lines.find((line) => {
|
|
5
|
+
const pointIndex = line.points.findIndex(({ id }) => id === point.id);
|
|
6
|
+
if (pointIndex === nextIndex)
|
|
7
|
+
return false;
|
|
8
|
+
return true;
|
|
9
|
+
});
|
|
10
|
+
if (!nextLine)
|
|
11
|
+
return target;
|
|
12
|
+
const nextPoint = nextLine.points[nextIndex];
|
|
13
|
+
if (!nextPoint)
|
|
14
|
+
return target;
|
|
15
|
+
return mergeNextLine(nextPoint, nextIndex, target.concat(nextLine));
|
|
16
|
+
};
|
|
17
|
+
const rightLines = mergeNextLine(line.points[0], 1, []);
|
|
18
|
+
const leftLines = mergeNextLine(line.points[0], 0, []);
|
|
19
|
+
const lines = rightLines.concat(leftLines);
|
|
20
|
+
return lines;
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Vector2 } from 'three';
|
|
2
|
+
import Point from '../Model/point';
|
|
3
|
+
import { Five } from '@realsee/five';
|
|
4
|
+
/**
|
|
5
|
+
* @param tapPoint 注意这里的坐标是相对于 FiveElement 的
|
|
6
|
+
*/
|
|
7
|
+
export declare function findClosestPoint(five: Five, points: Point[], tapPoint: Vector2, maxDistance?: number): {
|
|
8
|
+
distance: number;
|
|
9
|
+
point: Point;
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ndc2Screen from './ndc2Screen';
|
|
2
|
+
import isNDCPointInScreen from './isNDCPointInScreen';
|
|
3
|
+
/**
|
|
4
|
+
* @param tapPoint 注意这里的坐标是相对于 FiveElement 的
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line max-params
|
|
7
|
+
export function findClosestPoint(five, points, tapPoint, maxDistance) {
|
|
8
|
+
const container = five.getElement();
|
|
9
|
+
if (!container)
|
|
10
|
+
return null;
|
|
11
|
+
if (points.length === 0)
|
|
12
|
+
return null;
|
|
13
|
+
const containerSize = { width: container.clientWidth, height: container.clientHeight };
|
|
14
|
+
const ndcPoints = points
|
|
15
|
+
.map((point) => {
|
|
16
|
+
const ndcPosition = point.position.clone().project(five.camera);
|
|
17
|
+
if (!isNDCPointInScreen(ndcPosition))
|
|
18
|
+
return { distance: Infinity, point };
|
|
19
|
+
const screenPosition = ndc2Screen(ndcPosition, containerSize);
|
|
20
|
+
const distance = screenPosition.distanceTo(tapPoint);
|
|
21
|
+
return { distance, point };
|
|
22
|
+
})
|
|
23
|
+
.sort((a, b) => a.distance - b.distance);
|
|
24
|
+
if (typeof maxDistance === 'number' && ndcPoints[0].distance > maxDistance)
|
|
25
|
+
return null;
|
|
26
|
+
return ndcPoints[0];
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Raycaster } from 'three';
|
|
2
|
+
import { getPointFromHammerEvent } from './getPointFromHammerEvent';
|
|
3
|
+
/** 通过鼠标事件或者触摸事件,获取当前点击屏幕关联的射线与模型的交点 */
|
|
4
|
+
export function getIntersectionFromEvent(five, event) {
|
|
5
|
+
const mouse = getPointFromHammerEvent(event).ndcPoint;
|
|
6
|
+
const raycaster = new Raycaster();
|
|
7
|
+
raycaster.setFromCamera(mouse, five.camera);
|
|
8
|
+
return five.model.intersectRaycaster(raycaster);
|
|
9
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Hammer from 'hammerjs';
|
|
2
|
+
import { Vector2 } from 'three';
|
|
3
|
+
/**
|
|
4
|
+
* 从 Hammer 事件中获取操作的点在交互 DOM 中的位置
|
|
5
|
+
* @ignore TODO: make a suitable name
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPointFromHammerEvent(event: typeof Hammer['Input']): {
|
|
8
|
+
point: Vector2;
|
|
9
|
+
ndcPoint: Vector2;
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Vector2 } from 'three';
|
|
2
|
+
/**
|
|
3
|
+
* 从 Hammer 事件中获取操作的点在交互 DOM 中的位置
|
|
4
|
+
* @ignore TODO: make a suitable name
|
|
5
|
+
*/
|
|
6
|
+
export function getPointFromHammerEvent(event) {
|
|
7
|
+
// clientX 与 clientY 是相对 document 的,需要转换成相对于 target 的坐标
|
|
8
|
+
const { x: clientX, y: clientY } = event.center;
|
|
9
|
+
const { clientWidth, clientHeight } = event.target;
|
|
10
|
+
const clientRect = event.target.getBoundingClientRect();
|
|
11
|
+
const position = new Vector2(clientX, clientY).sub(new Vector2(clientRect.left, clientRect.top));
|
|
12
|
+
const mouse = new Vector2((position.x / clientWidth) * 2 - 1, -(position.y / clientHeight) * 2 + 1);
|
|
13
|
+
return { point: position, ndcPoint: mouse };
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const preventDefault: (e: Event) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const preventDefault = (e) => e.preventDefault();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Line from '../Model/line';
|
|
2
|
+
import { Line as FiveLine } from '@realsee/five/line';
|
|
3
|
+
import { Color, Texture, Vector3 } from 'three';
|
|
4
|
+
declare type ISetMaterialOpts = Parameters<FiveLine['setMaterial']>[0];
|
|
5
|
+
export interface ICreatLineOpts extends ISetMaterialOpts {
|
|
6
|
+
hasPoint?: boolean;
|
|
7
|
+
pointSize?: number;
|
|
8
|
+
lineWidth?: number;
|
|
9
|
+
pointTexture?: Texture;
|
|
10
|
+
lineRenderOrder?: number;
|
|
11
|
+
pointsRenderOrder?: number;
|
|
12
|
+
lineColor?: Color | string | number;
|
|
13
|
+
pointColor?: Color | string | number;
|
|
14
|
+
}
|
|
15
|
+
export declare function creatLine(start: Vector3, end: Vector3, opts?: ICreatLineOpts): FiveLine;
|
|
16
|
+
export declare function creatLineMesh(line: Line, type: 'normal' | 'light'): FiveLine;
|
|
17
|
+
export {};
|