@realsee/dnalogel 2.0.4 → 2.0.5--alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +46 -46
- package/dist/index.es.js +4100 -3838
- package/dist/index.js +4100 -3838
- package/dist/index.umd.js +34 -34
- package/docs/assets/search.js +1 -1
- package/docs/classes/CruisePluginController.html +14 -14
- package/docs/classes/Magnifier.html +4 -4
- package/docs/classes/ModelRoomLabelController.html +4 -4
- package/docs/classes/PaintBrush.html +8 -0
- package/docs/enums/CameraMovementEffect.html +2 -2
- package/docs/enums/DIRECTION.html +1 -1
- package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
- package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
- package/docs/enums/PaintBrushTypeEnum.html +1 -0
- package/docs/enums/Rotation.html +2 -2
- package/docs/index.html +2 -2
- package/docs/interfaces/CSS3DRenderPluginEventMap.html +11 -0
- package/docs/interfaces/CSS3DRenderPluginState.html +3 -0
- package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
- package/docs/interfaces/FloorplanBounding.html +4 -4
- package/docs/interfaces/FloorplanData.html +2 -2
- package/docs/interfaces/FloorplanEntrance.html +7 -7
- package/docs/interfaces/FloorplanExtraObject.html +3 -3
- package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
- package/docs/interfaces/FloorplanFloorData.html +2 -2
- package/docs/interfaces/FloorplanImagePosition.html +2 -2
- package/docs/interfaces/FloorplanObserver.html +2 -2
- package/docs/interfaces/FloorplanOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanPosition.html +2 -2
- package/docs/interfaces/FloorplanRoomItem.html +6 -6
- package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
- package/docs/interfaces/FloorplanServerBounding.html +4 -4
- package/docs/interfaces/FloorplanServerComputedData.html +1 -1
- package/docs/interfaces/FloorplanServerData.html +2 -2
- package/docs/interfaces/FloorplanServerDoorItem.html +1 -1
- package/docs/interfaces/FloorplanServerDoorPosition.html +1 -1
- package/docs/interfaces/FloorplanServerEntrance.html +7 -7
- package/docs/interfaces/FloorplanServerFloorData.html +2 -2
- package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
- package/docs/interfaces/FloorplanServerObserver.html +2 -2
- package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
- package/docs/interfaces/FloorplanServerPosition.html +2 -2
- package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
- package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
- package/docs/interfaces/ItemLabelPluginData.html +1 -1
- package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
- 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/ModelItemLabelPluginData.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
- package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
- package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
- package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
- package/docs/interfaces/ModelViewPluginExportType.html +1 -1
- package/docs/interfaces/OpenParameter.html +2 -2
- package/docs/interfaces/PaintBrushAction.html +13 -0
- package/docs/interfaces/PaintBrushConfigs.html +1 -0
- package/docs/interfaces/PaintBrushState.html +1 -0
- package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
- package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
- package/docs/interfaces/PanoMeasureParameterType.html +2 -2
- package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
- package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
- package/docs/interfaces/PanoRulerProPluginState.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
- package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
- package/docs/interfaces/Point.html +1 -1
- package/docs/interfaces/PointJson.html +1 -1
- package/docs/interfaces/Room.html +1 -1
- package/docs/interfaces/RoomInfo.html +1 -1
- package/docs/interfaces/RoomLabel.html +7 -7
- package/docs/interfaces/RoomRules.html +1 -1
- package/docs/interfaces/Rooms.html +1 -1
- package/docs/modules.html +17 -20
- package/libs/CSS3DRenderPlugin/CSS3DRender.d.ts +156 -0
- package/libs/CSS3DRenderPlugin/CSS3DRender.js +246 -0
- package/libs/CSS3DRenderPlugin/Controller.d.ts +78 -0
- package/libs/CSS3DRenderPlugin/Controller.js +59 -0
- package/libs/CSS3DRenderPlugin/index.d.ts +4 -3
- package/libs/CSS3DRenderPlugin/index.js +10 -8
- package/libs/CSS3DRenderPlugin/typing.d.ts +26 -0
- package/libs/CSS3DRenderPlugin/typing.js +1 -0
- package/libs/CSS3DRenderPlugin/utils/CSS3DObjectPlus.d.ts +16 -0
- package/libs/CSS3DRenderPlugin/utils/CSS3DObjectPlus.js +48 -0
- package/libs/CSS3DRenderPlugin/utils/centerPoint.d.ts +2 -0
- package/libs/CSS3DRenderPlugin/utils/centerPoint.js +10 -0
- package/libs/CSS3DRenderPlugin/utils/evenNumber.d.ts +3 -0
- package/libs/CSS3DRenderPlugin/utils/evenNumber.js +7 -0
- package/libs/CSS3DRenderPlugin/utils/index.d.ts +4 -0
- package/libs/CSS3DRenderPlugin/utils/index.js +13 -0
- package/libs/CSS3DRenderPlugin/utils/positionToVector3.d.ts +13 -0
- package/libs/CSS3DRenderPlugin/utils/positionToVector3.js +7 -0
- package/libs/CSS3DRenderPlugin/utils/random.d.ts +1 -0
- package/libs/CSS3DRenderPlugin/utils/random.js +6 -0
- package/libs/ModelTVVideoPlugin/Plugin.d.ts +1 -1
- package/libs/ModelTVVideoPlugin/Plugin.js +129 -139
- package/libs/ModelTVVideoPlugin/index.js +14 -5
- package/libs/ModelTVVideoPlugin/typings.js +0 -1
- package/libs/ModelTVVideoPlugin/utils/parseData.d.ts +1 -1
- package/libs/ModelTVVideoPlugin/utils/parseData.js +12 -8
- package/libs/PanoCompassPlugin/Controller.js +19 -16
- package/libs/PanoCompassPlugin/index.js +11 -8
- package/libs/PanoDoorLabelPlugin/BaseController.js +7 -7
- package/libs/PanoSpatialTagPlugin/Plugin.js +11 -8
- package/libs/PanoSpatialTagPlugin/index.js +11 -8
- package/libs/index.js +80 -76
- package/libs/shared-utils/Subscribe.d.ts +41 -25
- package/libs/shared-utils/Subscribe.js +37 -45
- package/package.json +1 -1
- package/docs/interfaces/CSS3DRenderPluginExportType.html +0 -4
- package/libs/CSS3DRenderPlugin/Plugin.d.ts +0 -49
- package/libs/CSS3DRenderPlugin/Plugin.js +0 -80
- package/libs/CSS3DRenderPlugin/utils/createResizeObserver.d.ts +0 -7
- package/libs/CSS3DRenderPlugin/utils/createResizeObserver.js +0 -17
- package/libs/shared-utils/three/centerPoint.d.ts +0 -2
- package/libs/shared-utils/three/centerPoint.js +0 -7
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { CSS3DRenderer } from 'three/examples/jsm/renderers/CSS3DRenderer';
|
|
3
|
+
import { Subscribe } from '../shared-utils/Subscribe';
|
|
4
|
+
import { AnyPosition } from './utils';
|
|
5
|
+
import { CSS3DObjectPlus } from './utils/CSS3DObjectPlus';
|
|
6
|
+
export declare const __ELEMENT__ = "__CSS3DOBJECT_CSS3DRENDER_CONTAINER__";
|
|
7
|
+
export declare const PLUGIN: string;
|
|
8
|
+
export declare const MinRatio = 0.00216;
|
|
9
|
+
export interface CSS3DRenderState {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
disposed: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare type CSS3DRenderEventMap = {
|
|
15
|
+
show: (options?: {
|
|
16
|
+
userAction?: boolean;
|
|
17
|
+
}) => void;
|
|
18
|
+
hide: (options?: {
|
|
19
|
+
userAction?: boolean;
|
|
20
|
+
}) => void;
|
|
21
|
+
enable: (options?: {
|
|
22
|
+
userAction?: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
disable: (options?: {
|
|
25
|
+
userAction?: boolean;
|
|
26
|
+
}) => void;
|
|
27
|
+
dispose: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* 插件状态变化
|
|
30
|
+
* @param params.state 最新的State
|
|
31
|
+
* @param params.prevState 上一个State
|
|
32
|
+
* @param params.userAction 是否是用户触发
|
|
33
|
+
*/
|
|
34
|
+
stateChange: (params: {
|
|
35
|
+
state: CSS3DRenderState;
|
|
36
|
+
prevState?: CSS3DRenderState;
|
|
37
|
+
userAction: boolean;
|
|
38
|
+
}) => void;
|
|
39
|
+
};
|
|
40
|
+
export interface Create3DDElementParamsType {
|
|
41
|
+
points: AnyPosition[];
|
|
42
|
+
config?: {
|
|
43
|
+
ratio?: number;
|
|
44
|
+
devicePixelRatio?: number;
|
|
45
|
+
autoRender?: boolean;
|
|
46
|
+
container?: HTMLElement;
|
|
47
|
+
pointerEvents?: 'none' | 'auto';
|
|
48
|
+
scene?: THREE.Scene;
|
|
49
|
+
} & ({
|
|
50
|
+
mode?: 'front';
|
|
51
|
+
} | {
|
|
52
|
+
mode: 'behind';
|
|
53
|
+
scene: THREE.Scene;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export declare const globalStore: {
|
|
57
|
+
resizeObserver?: {
|
|
58
|
+
observe: () => void;
|
|
59
|
+
unobserve: () => void;
|
|
60
|
+
};
|
|
61
|
+
frontModeContainer?: Element;
|
|
62
|
+
behindModeContainer?: Element;
|
|
63
|
+
frontModeStore?: {
|
|
64
|
+
css3DScene: THREE.Scene;
|
|
65
|
+
css3DRenderer: CSS3DRenderer;
|
|
66
|
+
requestAnimationFrameId?: number;
|
|
67
|
+
appendedToPage?: boolean;
|
|
68
|
+
};
|
|
69
|
+
behindModeStore?: {
|
|
70
|
+
scene: THREE.Scene;
|
|
71
|
+
css3DScene: THREE.Scene;
|
|
72
|
+
css3DRenderer: CSS3DRenderer;
|
|
73
|
+
requestAnimationFrameId?: number;
|
|
74
|
+
appendedToPage?: boolean;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export declare class CSS3DRender {
|
|
78
|
+
hooks: Subscribe<CSS3DRenderEventMap>;
|
|
79
|
+
state: CSS3DRenderState;
|
|
80
|
+
private store;
|
|
81
|
+
getCurrentState(): CSS3DRenderState;
|
|
82
|
+
setState(state: Partial<CSS3DRenderState>, options?: {
|
|
83
|
+
userAction: boolean;
|
|
84
|
+
}): void;
|
|
85
|
+
dispose(): void;
|
|
86
|
+
show({ userAction }?: {
|
|
87
|
+
userAction: boolean;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
hide({ userAction }?: {
|
|
90
|
+
userAction: boolean;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
enable({ userAction }?: {
|
|
93
|
+
userAction: boolean;
|
|
94
|
+
}): void;
|
|
95
|
+
disable({ userAction }?: {
|
|
96
|
+
userAction: boolean;
|
|
97
|
+
}): void;
|
|
98
|
+
/**
|
|
99
|
+
* @description 根据传入的四个点位创建一个 3d dom容器,可以通过ReactDom.render()的方式将react组件放到容器中
|
|
100
|
+
* @param { Vector3Position[] } points 矩形四个点坐标
|
|
101
|
+
* @param config 均为可选值
|
|
102
|
+
* @config_document `config` 均为可选值
|
|
103
|
+
* | key | type | defaultValue | comment |
|
|
104
|
+
* | - | - | - | - |
|
|
105
|
+
* | `ratio` | *`number`* | `0.00216` | 1px对应多少米,默认为 0.00216,即1px对应2.16mm |
|
|
106
|
+
* | `devicePixelRatio` | *`number`* | `1` | 设备的物理像素分辨率与CSS像素分辨率的比值 |
|
|
107
|
+
* | `container` | *`HTMLElement`* | `undefined` | 自定义 return 中的 `container`
|
|
108
|
+
* | `pointerEvents` | *`'none'\|'auto'`* | `'none'` | container 的 css属性:`pointer-events` 的值 |
|
|
109
|
+
* | `autoRender` | *`boolean`* | `true` | 是否自动渲染,通常为true |
|
|
110
|
+
* | `mode` | *`'front'\|'behind'`* | `front` | 两种模式:|
|
|
111
|
+
* | | | | `front` 模式:DOM 处于 five Canvas 上方,所以无法模拟遮挡效果,需要手动检测是否可见去设置显隐 |
|
|
112
|
+
* | | | | `behind` 模式:DOM 处于 five Canvas 下方,可以模拟真实的遮挡效果,但是 DOM 必须是非透明的 |
|
|
113
|
+
* | `scene` | *`THREE.Scene`* | `undefined` | 如果 mode 为 `behind`,需要传入 |
|
|
114
|
+
*
|
|
115
|
+
* @return
|
|
116
|
+
* ```typescript
|
|
117
|
+
* {
|
|
118
|
+
* id: string, // id
|
|
119
|
+
* container: HTMLDIVElement // dom容器
|
|
120
|
+
* dispose: () => void // 销毁
|
|
121
|
+
* css3DObject: CSS3DObject // THREE.CSS3DObject 实例
|
|
122
|
+
* render?: () => void // 渲染函数,当 config.autoRender = true || undefined 时为 undefined
|
|
123
|
+
* setVisible: (visible: boolean) => void // 设置显隐, 同 setVisibleById(id, visible)
|
|
124
|
+
* show: () => void // 同 setVisible(true)
|
|
125
|
+
* hide: () => void // 同 setVisible(false)
|
|
126
|
+
* setEnabled: (enabled: boolean) => void // 添加/移除 container, 同 setEnabledById(id, enabled)
|
|
127
|
+
* enable: () => void // 同 setEnabled(true)
|
|
128
|
+
* disable: () => void // 同 setEnabled(false)
|
|
129
|
+
* } | void
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
create3DElement: (camera: THREE.Camera, points: Create3DDElementParamsType['points'], config?: Create3DDElementParamsType['config']) => void | {
|
|
133
|
+
id: string;
|
|
134
|
+
container: HTMLElement;
|
|
135
|
+
dispose: () => boolean;
|
|
136
|
+
css3DObject: CSS3DObjectPlus<HTMLElement>;
|
|
137
|
+
render: () => void;
|
|
138
|
+
show: () => void;
|
|
139
|
+
hide: () => void;
|
|
140
|
+
setVisible: (visible: boolean) => void;
|
|
141
|
+
disable: () => void;
|
|
142
|
+
enable: () => void;
|
|
143
|
+
setEnabled: (enabled: boolean) => void;
|
|
144
|
+
appendToElement: (container: Element) => void;
|
|
145
|
+
};
|
|
146
|
+
appendToElement(container: Element | undefined, mode: 'front' | 'behind'): void;
|
|
147
|
+
setVisibleById: (id: string, visible: boolean) => void;
|
|
148
|
+
setEnabledById: (id: string, enabled: boolean) => void;
|
|
149
|
+
private createObject;
|
|
150
|
+
private handleShow;
|
|
151
|
+
private handleHide;
|
|
152
|
+
private handleEnable;
|
|
153
|
+
private handleDisable;
|
|
154
|
+
private createResizeObserver;
|
|
155
|
+
private disposedErrorLog;
|
|
156
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
var B = Object.defineProperty;
|
|
2
|
+
var q = (f, e, s) => e in f ? B(f, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : f[e] = s;
|
|
3
|
+
var l = (f, e, s) => (q(f, typeof e != "symbol" ? e + "" : e, s), s);
|
|
4
|
+
import * as m from "three";
|
|
5
|
+
import { CSS3DRenderer as A } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
6
|
+
import H from "../shared-utils/Subscribe.js";
|
|
7
|
+
import { evenNumber as _ } from "./utils/evenNumber.js";
|
|
8
|
+
import { anyPositionToVector3 as x } from "./utils/positionToVector3.js";
|
|
9
|
+
import { CSS3DObjectPlus as V } from "./utils/CSS3DObjectPlus.js";
|
|
10
|
+
import "./utils/centerPoint.js";
|
|
11
|
+
const U = "v2.0.1", T = "CSS3DRenderer", Z = "__CSS3DOBJECT_CSS3DRENDER_CONTAINER__", D = `${T}@${U}`, L = (f) => `${D}--${f}`, ee = 216e-5, o = {};
|
|
12
|
+
class te {
|
|
13
|
+
constructor() {
|
|
14
|
+
l(this, "hooks", new H());
|
|
15
|
+
l(this, "state", {
|
|
16
|
+
enabled: !0,
|
|
17
|
+
visible: !0,
|
|
18
|
+
disposed: !1
|
|
19
|
+
});
|
|
20
|
+
l(this, "store", {
|
|
21
|
+
disposers: [],
|
|
22
|
+
frontModeCSS3DObjects: {},
|
|
23
|
+
behindModeCSS3DObjects: {}
|
|
24
|
+
});
|
|
25
|
+
l(this, "create3DElement", (e, s, t) => {
|
|
26
|
+
if (this.state.disposed)
|
|
27
|
+
return this.disposedErrorLog();
|
|
28
|
+
const i = (() => {
|
|
29
|
+
const d = {
|
|
30
|
+
ratio: 216e-5,
|
|
31
|
+
devicePixelRatio: 1,
|
|
32
|
+
mode: "front",
|
|
33
|
+
autoRender: !0,
|
|
34
|
+
container: document.createElement("div"),
|
|
35
|
+
pointerEvents: "none"
|
|
36
|
+
};
|
|
37
|
+
return Object.assign(d, t);
|
|
38
|
+
})(), n = s.map(x);
|
|
39
|
+
if ((n == null ? void 0 : n.length) < 4)
|
|
40
|
+
return console.error(`${D}: requires 4 point but params may have fewer`);
|
|
41
|
+
const { ratio: a, devicePixelRatio: h, mode: r, autoRender: u, container: S, pointerEvents: E } = i, v = [], { css3DObject: c, opacityMesh: b } = this.createObject(n, {
|
|
42
|
+
ratio: a,
|
|
43
|
+
dpr: h,
|
|
44
|
+
container: S,
|
|
45
|
+
mode: r,
|
|
46
|
+
pointerEvents: E
|
|
47
|
+
});
|
|
48
|
+
S.id = `container--${c.uuid}`;
|
|
49
|
+
const y = r === "front" && !o.frontModeStore, R = r === "behind" && !o.behindModeStore;
|
|
50
|
+
R && (o.behindModeStore = {
|
|
51
|
+
scene: i.scene,
|
|
52
|
+
css3DScene: new m.Scene(),
|
|
53
|
+
css3DRenderer: new A()
|
|
54
|
+
}), y && (o.frontModeStore = { css3DScene: new m.Scene(), css3DRenderer: new A() });
|
|
55
|
+
const M = r === "front" ? o.frontModeStore : o.behindModeStore, { css3DScene: O, css3DRenderer: p } = M, g = (() => {
|
|
56
|
+
const d = () => {
|
|
57
|
+
r === "front" ? this.store.frontModeCSS3DObjects[c.uuid] = {
|
|
58
|
+
visible: !0,
|
|
59
|
+
enabled: !0,
|
|
60
|
+
css3DObject: c,
|
|
61
|
+
mode: "front"
|
|
62
|
+
} : this.store.behindModeCSS3DObjects[c.uuid] = {
|
|
63
|
+
visible: !0,
|
|
64
|
+
enabled: !0,
|
|
65
|
+
css3DObject: c,
|
|
66
|
+
opacityMesh: b,
|
|
67
|
+
mode: "behind",
|
|
68
|
+
scene: i.scene
|
|
69
|
+
}, O.add(c), r === "behind" && b && (i.scene.add(b), v.push(() => b && i.scene.remove(b)));
|
|
70
|
+
};
|
|
71
|
+
if (y || R) {
|
|
72
|
+
p.domElement.style.position = "absolute", p.domElement.style.top = "0", p.domElement.style.userSelect = "none", p.domElement.style.pointerEvents = "none", p.domElement.classList.add(L(r));
|
|
73
|
+
const I = () => {
|
|
74
|
+
const k = requestAnimationFrame(I);
|
|
75
|
+
M.requestAnimationFrameId = k, p.render(O, e);
|
|
76
|
+
};
|
|
77
|
+
return () => {
|
|
78
|
+
d(), I();
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return () => d();
|
|
82
|
+
})(), w = r === "front" ? o.frontModeContainer : o.behindModeContainer;
|
|
83
|
+
if (w) {
|
|
84
|
+
this.appendToElement(w, r);
|
|
85
|
+
const d = r === "front" ? o.frontModeStore : o.behindModeStore;
|
|
86
|
+
d && (d.appendedToPage = !0);
|
|
87
|
+
}
|
|
88
|
+
const j = (d) => this.setVisibleById(c.uuid, d), C = (d) => this.setEnabledById(c.uuid, d), P = () => j(!0), $ = () => j(!1), F = () => C(!0), N = () => C(!1), z = () => (delete this.store.frontModeCSS3DObjects[c.uuid], delete this.store.behindModeCSS3DObjects[c.uuid], v.forEach((d) => d == null ? void 0 : d()), O.remove(c), O.children.length === 0 && (typeof M.requestAnimationFrameId == "number" && cancelAnimationFrame(M.requestAnimationFrameId), p.domElement.remove(), r === "front" && (o.frontModeStore = void 0), r === "behind" && (o.behindModeStore = void 0), o.resizeObserver = void 0), !0);
|
|
89
|
+
return this.store.disposers.push(z), u && g(), {
|
|
90
|
+
id: c.uuid,
|
|
91
|
+
container: S,
|
|
92
|
+
dispose: z,
|
|
93
|
+
css3DObject: c,
|
|
94
|
+
render: u ? void 0 : g,
|
|
95
|
+
show: P,
|
|
96
|
+
hide: $,
|
|
97
|
+
setVisible: j,
|
|
98
|
+
disable: N,
|
|
99
|
+
enable: F,
|
|
100
|
+
setEnabled: C,
|
|
101
|
+
appendToElement: (d) => this.appendToElement(d, r)
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
l(this, "setVisibleById", (e, s) => {
|
|
105
|
+
var i;
|
|
106
|
+
const t = (i = this.store.frontModeCSS3DObjects[e]) != null ? i : this.store.behindModeCSS3DObjects[e];
|
|
107
|
+
if (!t)
|
|
108
|
+
return console.error("id not found", e);
|
|
109
|
+
t.visible = s, this.state.visible && (t.css3DObject.visible = s, t.mode === "behind" && (t.opacityMesh.visible = s));
|
|
110
|
+
});
|
|
111
|
+
l(this, "setEnabledById", (e, s) => {
|
|
112
|
+
var n, a, h;
|
|
113
|
+
const t = (n = this.store.frontModeCSS3DObjects[e]) != null ? n : this.store.behindModeCSS3DObjects[e];
|
|
114
|
+
if (!t)
|
|
115
|
+
return;
|
|
116
|
+
const i = t.mode === "front" ? (a = o.frontModeStore) == null ? void 0 : a.css3DScene : (h = o.behindModeStore) == null ? void 0 : h.css3DScene;
|
|
117
|
+
!i || (s ? (i.add(t.css3DObject), t.mode === "behind" && t.scene.add(t.opacityMesh)) : (i.remove(t.css3DObject), t.mode === "behind" && t.scene.remove(t.opacityMesh)), t.enabled = s);
|
|
118
|
+
});
|
|
119
|
+
l(this, "createObject", (e, s) => {
|
|
120
|
+
const { ratio: t, dpr: i, container: n, mode: a, pointerEvents: h } = s, r = new V(n, e, t, i);
|
|
121
|
+
n.style.pointerEvents = h, n.classList.add(`${T}__container`);
|
|
122
|
+
const { domWidthPx: u, domHeightPx: S } = r, E = (() => {
|
|
123
|
+
if (a === "behind") {
|
|
124
|
+
const v = new m.MeshBasicMaterial({
|
|
125
|
+
opacity: 0,
|
|
126
|
+
transparent: !1,
|
|
127
|
+
side: m.DoubleSide
|
|
128
|
+
}), c = new m.PlaneGeometry(u, S), b = new m.Mesh(c, v);
|
|
129
|
+
return b.name = L("mesh"), b.position.copy(r.position), b.rotation.copy(r.rotation), b.scale.copy(r.scale), b;
|
|
130
|
+
}
|
|
131
|
+
})();
|
|
132
|
+
return { css3DObject: r, opacityMesh: E };
|
|
133
|
+
});
|
|
134
|
+
l(this, "createResizeObserver", (e, s, t = !0) => {
|
|
135
|
+
if (!e)
|
|
136
|
+
return console.error("createResizeObserver: element is undefined"), { observe: () => {
|
|
137
|
+
}, unobserve: () => {
|
|
138
|
+
} };
|
|
139
|
+
const i = () => {
|
|
140
|
+
const a = _(e.clientWidth, { smaller: !0 }), h = _(e.clientHeight, { smaller: !0 });
|
|
141
|
+
s(a, h);
|
|
142
|
+
};
|
|
143
|
+
if (typeof ResizeObserver > "u" || !ResizeObserver)
|
|
144
|
+
return console.warn("createResizeObserver: ResizeObserver is undefined"), { observe: () => i(), unobserve: () => {
|
|
145
|
+
} };
|
|
146
|
+
const n = new ResizeObserver(i);
|
|
147
|
+
return t && i(), {
|
|
148
|
+
observe: () => n.observe(e),
|
|
149
|
+
unobserve: () => n.unobserve(e)
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
l(this, "disposedErrorLog", () => {
|
|
153
|
+
console.error(`${D} is disposed`);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
getCurrentState() {
|
|
157
|
+
return this.state;
|
|
158
|
+
}
|
|
159
|
+
setState(e, s = { userAction: !0 }) {
|
|
160
|
+
if (this.state.disposed)
|
|
161
|
+
return this.disposedErrorLog();
|
|
162
|
+
const t = { ...this.state };
|
|
163
|
+
this.state = Object.assign(this.state, e), t.visible !== this.state.visible && (e.visible ? this.handleShow() : this.handleHide()), t.enabled !== this.state.enabled && (e.enabled ? this.handleEnable() : this.handleDisable()), this.hooks.emit("stateChange", { state: this.state, prevState: t, userAction: s.userAction });
|
|
164
|
+
}
|
|
165
|
+
dispose() {
|
|
166
|
+
this.store.disposers.forEach((e) => e == null ? void 0 : e()), this.store.disposers = [], this.hooks.emit("dispose"), this.state.disposed = !0;
|
|
167
|
+
}
|
|
168
|
+
async show({ userAction: e } = { userAction: !0 }) {
|
|
169
|
+
if (this.state.disposed)
|
|
170
|
+
return this.disposedErrorLog();
|
|
171
|
+
this.setState({ visible: !0 }, { userAction: e }), this.hooks.emit("show", { userAction: e });
|
|
172
|
+
}
|
|
173
|
+
async hide({ userAction: e } = { userAction: !0 }) {
|
|
174
|
+
if (this.state.disposed)
|
|
175
|
+
return this.disposedErrorLog();
|
|
176
|
+
this.setState({ visible: !1 }, { userAction: e }), this.hooks.emit("hide", { userAction: e });
|
|
177
|
+
}
|
|
178
|
+
enable({ userAction: e } = { userAction: !0 }) {
|
|
179
|
+
if (this.state.disposed)
|
|
180
|
+
return this.disposedErrorLog();
|
|
181
|
+
this.setState({ enabled: !0 }, { userAction: e }), this.hooks.emit("enable", { userAction: e });
|
|
182
|
+
}
|
|
183
|
+
disable({ userAction: e } = { userAction: !0 }) {
|
|
184
|
+
if (this.state.disposed)
|
|
185
|
+
return this.disposedErrorLog();
|
|
186
|
+
this.setState({ enabled: !1 }, { userAction: e }), this.hooks.emit("disable", { userAction: e });
|
|
187
|
+
}
|
|
188
|
+
appendToElement(e, s) {
|
|
189
|
+
if (!e)
|
|
190
|
+
throw new Error(`${D} Cannot append to container: container is ${e}`);
|
|
191
|
+
const t = s === "front" ? o.frontModeStore : o.behindModeStore;
|
|
192
|
+
if (!t) {
|
|
193
|
+
s === "front" && (o.frontModeContainer = e), s === "behind" && (o.behindModeContainer = e);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (!t.appendedToPage) {
|
|
197
|
+
if (e.appendChild(t.css3DRenderer.domElement), !o.resizeObserver) {
|
|
198
|
+
const i = (h, r) => {
|
|
199
|
+
var u, S;
|
|
200
|
+
(u = o.frontModeStore) == null || u.css3DRenderer.setSize(h, r), (S = o.behindModeStore) == null || S.css3DRenderer.setSize(h, r);
|
|
201
|
+
}, { observe: n, unobserve: a } = this.createResizeObserver(e, i, !0);
|
|
202
|
+
o.resizeObserver = { observe: n, unobserve: a }, n(), this.store.disposers.push(a);
|
|
203
|
+
}
|
|
204
|
+
t.appendedToPage = !0;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
async handleShow() {
|
|
208
|
+
Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
|
|
209
|
+
e.css3DObject.visible = e.visible;
|
|
210
|
+
}), Object.values(this.store.behindModeCSS3DObjects).forEach((e) => {
|
|
211
|
+
e.css3DObject.visible = e.visible, e.opacityMesh.visible = e.visible;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
async handleHide() {
|
|
215
|
+
Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
|
|
216
|
+
e.css3DObject.visible = !1;
|
|
217
|
+
}), Object.values(this.store.behindModeCSS3DObjects).forEach((e) => {
|
|
218
|
+
e.css3DObject.visible = !1, e.opacityMesh.visible = !1;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
handleEnable() {
|
|
222
|
+
Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
|
|
223
|
+
var s;
|
|
224
|
+
!e.enabled || (s = o.frontModeStore) == null || s.css3DScene.add(e.css3DObject);
|
|
225
|
+
}), Object.values(this.store.behindModeCSS3DObjects).forEach((e) => {
|
|
226
|
+
var s, t;
|
|
227
|
+
!e.enabled || ((s = o.behindModeStore) == null || s.css3DScene.add(e.css3DObject), (t = o.behindModeStore) == null || t.scene.add(e.opacityMesh));
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
handleDisable() {
|
|
231
|
+
Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
|
|
232
|
+
var s;
|
|
233
|
+
(s = o.frontModeStore) == null || s.css3DScene.remove(e.css3DObject);
|
|
234
|
+
}), Object.values(this.store.behindModeCSS3DObjects).forEach((e) => {
|
|
235
|
+
var s, t;
|
|
236
|
+
(s = o.behindModeStore) == null || s.css3DScene.remove(e.css3DObject), (t = o.behindModeStore) == null || t.scene.remove(e.opacityMesh);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
te as CSS3DRender,
|
|
242
|
+
ee as MinRatio,
|
|
243
|
+
D as PLUGIN,
|
|
244
|
+
Z as __ELEMENT__,
|
|
245
|
+
o as globalStore
|
|
246
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type * as BasePlugin from '../base/BasePlugin';
|
|
2
|
+
import type { Five } from '@realsee/five';
|
|
3
|
+
import { CSS3DRender, CSS3DRenderEventMap, CSS3DRenderState } from './CSS3DRender';
|
|
4
|
+
import type { AnyPosition } from './utils';
|
|
5
|
+
export declare const PLUGIN_NAME: string;
|
|
6
|
+
export interface Create3DDomContainerParamsType {
|
|
7
|
+
points: AnyPosition[];
|
|
8
|
+
config?: {
|
|
9
|
+
ratio?: number;
|
|
10
|
+
/** @deprecated dpr renamed as devicePixelRatio */
|
|
11
|
+
dpr?: number;
|
|
12
|
+
devicePixelRatio?: number;
|
|
13
|
+
autoRender?: boolean;
|
|
14
|
+
container?: HTMLElement;
|
|
15
|
+
pointerEvents?: 'none' | 'auto';
|
|
16
|
+
} & ({
|
|
17
|
+
mode?: 'front';
|
|
18
|
+
} | {
|
|
19
|
+
mode: 'behind';
|
|
20
|
+
behindFiveContainer: HTMLElement;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export default class Controller extends CSS3DRender implements BasePlugin.Controller<CSS3DRenderState, CSS3DRenderEventMap> {
|
|
24
|
+
five: Five;
|
|
25
|
+
constructor(five: Five);
|
|
26
|
+
/** @deprecated disposeAll() renamed as dispose() */
|
|
27
|
+
disposeAll(): void;
|
|
28
|
+
setState(...params: Parameters<InstanceType<typeof CSS3DRender>['setState']>): void;
|
|
29
|
+
/**
|
|
30
|
+
* @description 根据传入的四个点位创建一个 3d dom容器,可以通过ReactDom.render()的方式将react组件放到容器中
|
|
31
|
+
* @param { Vector3Position[] } points 矩形四个点坐标
|
|
32
|
+
* @param config 均为可选值
|
|
33
|
+
* @config_document `config` 均为可选值
|
|
34
|
+
* | key | type | defaultValue | comment |
|
|
35
|
+
* | - | - | - | - |
|
|
36
|
+
* | `ratio` | *`number`* | `0.00216` | 1px对应多少米,默认为 0.00216,即1px对应2.16mm |
|
|
37
|
+
* | ~~`dpr`~~ | ~~*`number`*~~ | ~~`undefined`~~ | ~~**已改名**,请使用~~ `devicePixelRatio` |
|
|
38
|
+
* | `devicePixelRatio` | *`number`* | `1` | 设备的物理像素分辨率与CSS像素分辨率的比值 |
|
|
39
|
+
* | `container` | *`HTMLElement`* | `undefined` | 自定义 return 中的 `container`
|
|
40
|
+
* | `pointerEvents` | *`'none'\|'auto'`* | `'none'` | container 的 css属性:`pointer-events` 的值 |
|
|
41
|
+
* | `autoRender` | *`boolean`* | `true` | 是否自动渲染,通常为true |
|
|
42
|
+
* | `mode` | *`'front'\|'behind'`* | `front` | 两种模式:|
|
|
43
|
+
* | | | | `front` 模式:DOM 处于 five Canvas 上方,所以无法模拟遮挡效果,需要手动检测是否可见去设置显隐 |
|
|
44
|
+
* | | | | `behind` 模式:DOM 处于 five Canvas 下方,可以模拟真实的遮挡效果,但是 DOM 必须是非透明的 |
|
|
45
|
+
* | `behindFiveContainer` | *`HTMLElement`* | `undefined` | 如果 mode 为 `behind`,需要传入容器,并确保此容器位five下方,且中间无其他不透明的dom元素遮挡 |
|
|
46
|
+
*
|
|
47
|
+
* @return
|
|
48
|
+
* ```typescript
|
|
49
|
+
* {
|
|
50
|
+
* id: string, // id
|
|
51
|
+
* container: HTMLDIVElement // dom容器
|
|
52
|
+
* dispose: () => void // 销毁
|
|
53
|
+
* css3DObject: CSS3DObject // THREE.CSS3DObject 实例
|
|
54
|
+
* render?: () => void // 渲染函数,当 config.autoRender = true || undefined 时为 undefined
|
|
55
|
+
* setVisible: (visible: boolean) => void // 设置显隐, 同 setVisibleById(id, visible)
|
|
56
|
+
* show: () => void // 同 setVisible(true)
|
|
57
|
+
* hide: () => void // 同 setVisible(false)
|
|
58
|
+
* setEnabled: (enabled: boolean) => void // 添加/移除 container, 同 setEnabledById(id, enabled)
|
|
59
|
+
* enable: () => void // 同 setEnabled(true)
|
|
60
|
+
* disable: () => void // 同 setEnabled(false)
|
|
61
|
+
* } | void
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
create3DDomContainer: (points: Create3DDomContainerParamsType['points'], config?: Create3DDomContainerParamsType['config']) => {
|
|
65
|
+
render: () => void;
|
|
66
|
+
id: string;
|
|
67
|
+
container: HTMLElement;
|
|
68
|
+
dispose: () => boolean;
|
|
69
|
+
css3DObject: import("./utils/CSS3DObjectPlus").CSS3DObjectPlus<HTMLElement>;
|
|
70
|
+
show: () => void;
|
|
71
|
+
hide: () => void;
|
|
72
|
+
setVisible: (visible: boolean) => void;
|
|
73
|
+
disable: () => void;
|
|
74
|
+
enable: () => void;
|
|
75
|
+
setEnabled: (enabled: boolean) => void;
|
|
76
|
+
appendToElement: (container: Element) => void;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var R = (o, r, t) => r in o ? h(o, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[r] = t;
|
|
3
|
+
var m = (o, r, t) => (R(o, typeof r != "symbol" ? r + "" : r, t), t);
|
|
4
|
+
import { CSS3DRender as E } from "./CSS3DRender.js";
|
|
5
|
+
import "three";
|
|
6
|
+
import "three/examples/jsm/renderers/CSS3DRenderer";
|
|
7
|
+
import "../shared-utils/Subscribe.js";
|
|
8
|
+
import "./utils/evenNumber.js";
|
|
9
|
+
import "./utils/positionToVector3.js";
|
|
10
|
+
import "./utils/CSS3DObjectPlus.js";
|
|
11
|
+
import "./utils/centerPoint.js";
|
|
12
|
+
const S = "v2.0.1", c = `CSS3DRenderPlugin@${S}`;
|
|
13
|
+
class I extends E {
|
|
14
|
+
constructor(t) {
|
|
15
|
+
super();
|
|
16
|
+
m(this, "five");
|
|
17
|
+
m(this, "create3DDomContainer", (t, e) => {
|
|
18
|
+
if (this.state.disposed)
|
|
19
|
+
return;
|
|
20
|
+
const n = (() => {
|
|
21
|
+
var v;
|
|
22
|
+
(e == null ? void 0 : e.dpr) !== void 0 && console.warn(`${c}: please use "config.devicePixelRatio" replace "config.dpr"`);
|
|
23
|
+
const i = {
|
|
24
|
+
ratio: 216e-5,
|
|
25
|
+
devicePixelRatio: (v = e == null ? void 0 : e.dpr) != null ? v : 1,
|
|
26
|
+
mode: "front",
|
|
27
|
+
autoRender: !0
|
|
28
|
+
};
|
|
29
|
+
return Object.assign(i, e, (e == null ? void 0 : e.mode) === "behind" ? { scene: this.five.scene } : void 0);
|
|
30
|
+
})(), d = this.five.getElement();
|
|
31
|
+
if (!d) {
|
|
32
|
+
console.error(`${c}: five.getElement() is ${d}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const { autoRender: p, mode: s } = n, f = s === "front" ? d.parentElement : n.behindFiveContainer;
|
|
36
|
+
this.appendToElement(f || document.body, s);
|
|
37
|
+
const a = this.create3DElement(this.five.camera, t, { ...n, autoRender: !1 });
|
|
38
|
+
if (!a)
|
|
39
|
+
return;
|
|
40
|
+
const l = a.render, u = () => {
|
|
41
|
+
var i;
|
|
42
|
+
s === "front" && l(), s === "behind" && ((i = this.five.model) != null && i.loaded ? l() : this.five.once("modelLoaded", () => l()));
|
|
43
|
+
};
|
|
44
|
+
return p && u(), { ...a, render: p ? void 0 : u };
|
|
45
|
+
});
|
|
46
|
+
this.five = t;
|
|
47
|
+
}
|
|
48
|
+
disposeAll() {
|
|
49
|
+
return this.dispose();
|
|
50
|
+
}
|
|
51
|
+
setState(...t) {
|
|
52
|
+
const e = super.setState(...t);
|
|
53
|
+
return this.five.needsRender = !0, e;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
c as PLUGIN_NAME,
|
|
58
|
+
I as default
|
|
59
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import type { FivePlugin } from '@realsee/five';
|
|
2
|
+
import Controller from './Controller';
|
|
3
|
+
export * from './typing';
|
|
4
|
+
export declare const CSS3DRenderPlugin: FivePlugin<void, InstanceType<typeof Controller>>;
|
|
3
5
|
export default CSS3DRenderPlugin;
|
|
4
|
-
export type { CSS3DRenderPluginExportType } from './Plugin';
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import
|
|
1
|
+
import r from "./Controller.js";
|
|
2
|
+
import "./CSS3DRender.js";
|
|
3
3
|
import "three";
|
|
4
4
|
import "three/examples/jsm/renderers/CSS3DRenderer";
|
|
5
|
-
import "../shared-utils/
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
8
|
-
import "./utils/
|
|
5
|
+
import "../shared-utils/Subscribe.js";
|
|
6
|
+
import "./utils/evenNumber.js";
|
|
7
|
+
import "./utils/positionToVector3.js";
|
|
8
|
+
import "./utils/CSS3DObjectPlus.js";
|
|
9
|
+
import "./utils/centerPoint.js";
|
|
10
|
+
const f = (o) => new r(o);
|
|
9
11
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
f as CSS3DRenderPlugin,
|
|
13
|
+
f as default
|
|
12
14
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type CSS3DRenderPlugin from '.';
|
|
2
|
+
import type * as BasePlugin from '../base/BasePlugin';
|
|
3
|
+
import type { CSS3DRender } from './CSS3DRender';
|
|
4
|
+
export declare type CSS3DRenderPluginParameterType = undefined;
|
|
5
|
+
export declare type CSS3DRenderPluginExportType = ReturnType<typeof CSS3DRenderPlugin>;
|
|
6
|
+
export declare type CSS3DRenderExportType = InstanceType<typeof CSS3DRender>;
|
|
7
|
+
export declare type Create3DDomContainerReturnType = ReturnType<CSS3DRenderPluginExportType['create3DDomContainer']>;
|
|
8
|
+
export declare type Create3DElementReturnType = ReturnType<InstanceType<typeof CSS3DRender>['create3DElement']>;
|
|
9
|
+
export interface CSS3DRenderPluginState extends BasePlugin.State {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
visible: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface CSS3DRenderPluginEventMap extends BasePlugin.EventMap<CSS3DRenderPluginState> {
|
|
14
|
+
show: (options?: {
|
|
15
|
+
userAction?: boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
hide: (options?: {
|
|
18
|
+
userAction?: boolean;
|
|
19
|
+
}) => void;
|
|
20
|
+
enable: (options?: {
|
|
21
|
+
userAction?: boolean;
|
|
22
|
+
}) => void;
|
|
23
|
+
disable: (options?: {
|
|
24
|
+
userAction?: boolean;
|
|
25
|
+
}) => void;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer';
|
|
2
|
+
import { Vector3 } from 'three';
|
|
3
|
+
export declare const MinRatio = 0.00216;
|
|
4
|
+
export declare const DefaultRatio = 0.003;
|
|
5
|
+
export declare class CSS3DObjectPlus<T extends HTMLElement> extends CSS3DObject {
|
|
6
|
+
version: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
domWidthPx: number;
|
|
10
|
+
domHeightPx: number;
|
|
11
|
+
cornerPoints: [Vector3, Vector3, Vector3, Vector3];
|
|
12
|
+
ratio: number;
|
|
13
|
+
container: T;
|
|
14
|
+
centerPosition: Vector3;
|
|
15
|
+
constructor(container: T, cornerPoints: [Vector3, Vector3, Vector3, Vector3], ratio?: number, dpr?: number);
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var P = Object.defineProperty;
|
|
2
|
+
var W = (c, i, t) => i in c ? P(c, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[i] = t;
|
|
3
|
+
var o = (c, i, t) => (W(c, typeof i != "symbol" ? i + "" : i, t), t);
|
|
4
|
+
import { CSS3DObject as D } from "three/examples/jsm/renderers/CSS3DRenderer";
|
|
5
|
+
import { Vector3 as m } from "three";
|
|
6
|
+
import { evenNumber as V } from "./evenNumber.js";
|
|
7
|
+
import { centerPoint as E } from "./centerPoint.js";
|
|
8
|
+
const f = "1.0.1", H = `CSS3DObjectPlus@${f}`, j = 216e-5, v = 3e-3;
|
|
9
|
+
class T extends D {
|
|
10
|
+
constructor(t, e, h = v, u = 1) {
|
|
11
|
+
const l = Math.max(j, h), p = e[0].distanceTo(e[1]), a = e[1].distanceTo(e[2]), n = V(p / h * u), d = V(a / h * u), x = E(...e);
|
|
12
|
+
let g;
|
|
13
|
+
if (l === h)
|
|
14
|
+
t.style.width = `${n}px`, t.style.height = `${d}px`, g = t;
|
|
15
|
+
else {
|
|
16
|
+
const s = document.createElement("div");
|
|
17
|
+
s.style.width = `${n}px`, s.style.height = `${d}px`, s.style.pointerEvents = "none";
|
|
18
|
+
const b = h / l;
|
|
19
|
+
t.style.position = "absolute", t.style.left = "0", t.style.top = "0", t.style.width = `${b * n}px`, t.style.height = `${b * d}px`, s.appendChild(t), g = s;
|
|
20
|
+
}
|
|
21
|
+
super(g);
|
|
22
|
+
o(this, "version", f);
|
|
23
|
+
o(this, "width");
|
|
24
|
+
o(this, "height");
|
|
25
|
+
o(this, "domWidthPx");
|
|
26
|
+
o(this, "domHeightPx");
|
|
27
|
+
o(this, "cornerPoints");
|
|
28
|
+
o(this, "ratio");
|
|
29
|
+
o(this, "container");
|
|
30
|
+
o(this, "centerPosition");
|
|
31
|
+
if (this.scale.set(l, l, l), this.cornerPoints = e, this.ratio = h, this.container = t, l === h)
|
|
32
|
+
this.width = p, this.height = a, this.domWidthPx = n, this.domHeightPx = d, this.centerPosition = x;
|
|
33
|
+
else {
|
|
34
|
+
const s = h / l;
|
|
35
|
+
this.width = s * p, this.height = s * a, this.domWidthPx = s * n, this.domHeightPx = s * d, this.centerPosition = new m().subVectors(x.clone(), e[0].clone()).multiplyScalar(s).add(e[0]);
|
|
36
|
+
}
|
|
37
|
+
t.classList.add(`${H}__container`);
|
|
38
|
+
const S = new m().subVectors(e[1], e[0]), r = new m().subVectors(e[3], e[0]), $ = new m().crossVectors(S, r).normalize();
|
|
39
|
+
this.lookAt($);
|
|
40
|
+
const y = this.up.clone().applyQuaternion(this.quaternion), w = r.clone(), O = new m().crossVectors(y, w).normalize();
|
|
41
|
+
this.rotateOnWorldAxis(O, y.angleTo(w)), this.position.copy(x);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
T as CSS3DObjectPlus,
|
|
46
|
+
v as DefaultRatio,
|
|
47
|
+
j as MinRatio
|
|
48
|
+
};
|