@realsee/dnalogel 2.1.0-alpha.26 → 2.1.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/index.cjs.js +556 -0
  2. package/dist/index.es.js +21392 -0
  3. package/dist/index.js +5104 -4997
  4. package/dist/index.umd.js +556 -0
  5. package/docs/classes/CruisePluginController.html +14 -14
  6. package/docs/classes/Magnifier.html +4 -4
  7. package/docs/classes/ModelRoomLabelController.html +4 -4
  8. package/docs/classes/Object3DHelperController.html +9 -9
  9. package/docs/classes/PaintBrush.html +3 -3
  10. package/docs/classes/PanoTagPluginController.html +23 -23
  11. package/docs/enums/CameraMovementEffect.html +2 -2
  12. package/docs/enums/ContentType.html +7 -7
  13. package/docs/enums/DIRECTION.html +1 -1
  14. package/docs/enums/DISPLAY_STRATEGY_TYPE.html +1 -1
  15. package/docs/enums/DimensionType.html +1 -1
  16. package/docs/enums/FLOOR_PLAN_ATTACHED_TO.html +1 -1
  17. package/docs/enums/ITEM_LABEL_PLUGIN_DISPLAY_STRATEGY_TYPE.html +1 -1
  18. package/docs/enums/LinkType.html +1 -1
  19. package/docs/enums/PaintBrushTypeEnum.html +1 -1
  20. package/docs/enums/PointType.html +1 -1
  21. package/docs/enums/Rotation.html +2 -2
  22. package/docs/index.html +1 -1
  23. package/docs/interfaces/CSS3DRenderPluginEventMap.html +2 -2
  24. package/docs/interfaces/CSS3DRenderPluginState.html +2 -2
  25. package/docs/interfaces/CameraMovementPluginExportType.html +2 -2
  26. package/docs/interfaces/ContentTypeMap.html +3 -3
  27. package/docs/interfaces/FloorplanBounding.html +4 -4
  28. package/docs/interfaces/FloorplanData.html +2 -2
  29. package/docs/interfaces/FloorplanEntrance.html +7 -7
  30. package/docs/interfaces/FloorplanExtraObject.html +3 -3
  31. package/docs/interfaces/FloorplanExtraObject3D.html +2 -2
  32. package/docs/interfaces/FloorplanFloorData.html +2 -2
  33. package/docs/interfaces/FloorplanImagePosition.html +2 -2
  34. package/docs/interfaces/FloorplanObserver.html +2 -2
  35. package/docs/interfaces/FloorplanOutlineItem.html +2 -2
  36. package/docs/interfaces/FloorplanPosition.html +2 -2
  37. package/docs/interfaces/FloorplanRoomItem.html +6 -6
  38. package/docs/interfaces/FloorplanRoomLabelItem.html +3 -3
  39. package/docs/interfaces/FloorplanServerBounding.html +4 -4
  40. package/docs/interfaces/FloorplanServerComputedData.html +1 -1
  41. package/docs/interfaces/FloorplanServerData.html +2 -2
  42. package/docs/interfaces/FloorplanServerDoorItem.html +1 -1
  43. package/docs/interfaces/FloorplanServerDoorPosition.html +1 -1
  44. package/docs/interfaces/FloorplanServerEntrance.html +7 -7
  45. package/docs/interfaces/FloorplanServerFloorData.html +2 -2
  46. package/docs/interfaces/FloorplanServerImagePosition.html +2 -2
  47. package/docs/interfaces/FloorplanServerObserver.html +2 -2
  48. package/docs/interfaces/FloorplanServerOutlineItem.html +2 -2
  49. package/docs/interfaces/FloorplanServerPosition.html +2 -2
  50. package/docs/interfaces/FloorplanServerRoomItem.html +7 -7
  51. package/docs/interfaces/FloorplanServerRoomLabelItem.html +3 -3
  52. package/docs/interfaces/ItemLabelPluginData.html +1 -1
  53. package/docs/interfaces/ItemLabelPluginExportReturnsType.html +1 -1
  54. package/docs/interfaces/ItemLabelPluginParametersType.html +1 -1
  55. package/docs/interfaces/LineJson.html +1 -1
  56. package/docs/interfaces/ModelChassisCompassPluginData.html +1 -1
  57. package/docs/interfaces/ModelChassisCompassPluginExportType.html +1 -1
  58. package/docs/interfaces/ModelChassisCompassPluginParameterType.html +1 -1
  59. package/docs/interfaces/ModelEntryDoorGuidePluginData.html +1 -1
  60. package/docs/interfaces/ModelEntryDoorGuidePluginExportType.html +1 -1
  61. package/docs/interfaces/ModelItemLabelPluginData.html +1 -1
  62. package/docs/interfaces/ModelItemLabelPluginExportReturnsType.html +1 -1
  63. package/docs/interfaces/ModelItemLabelPluginParametersType.html +1 -1
  64. package/docs/interfaces/ModelRoomLabelPluginData.html +1 -1
  65. package/docs/interfaces/ModelTVVideoPluginData.html +1 -1
  66. package/docs/interfaces/ModelTVVideoPluginExportType.html +1 -1
  67. package/docs/interfaces/ModelTVVideoPluginParameterType.html +1 -1
  68. package/docs/interfaces/ModelViewPluginExportType.html +1 -1
  69. package/docs/interfaces/Object3DHelperState.html +1 -1
  70. package/docs/interfaces/OpenParameter.html +2 -2
  71. package/docs/interfaces/PaintBrushAction.html +7 -7
  72. package/docs/interfaces/PaintBrushConfigs.html +1 -1
  73. package/docs/interfaces/PaintBrushState.html +1 -1
  74. package/docs/interfaces/PanoCursorRaycasterPluginExportType.html +6 -6
  75. package/docs/interfaces/PanoCursorRaycasterPluginParameterType.html +1 -1
  76. package/docs/interfaces/PanoMeasureParameterType.html +2 -2
  77. package/docs/interfaces/PanoRulerPluginExportType.html +1 -1
  78. package/docs/interfaces/PanoRulerPluginOptions.html +1 -1
  79. package/docs/interfaces/PanoRulerPluginParameterType.html +1 -1
  80. package/docs/interfaces/PanoRulerProPluginExportType.html +1 -1
  81. package/docs/interfaces/PanoRulerProPluginOptions.html +1 -1
  82. package/docs/interfaces/PanoRulerProPluginParameterType.html +1 -1
  83. package/docs/interfaces/PanoRulerProPluginState.html +1 -1
  84. package/docs/interfaces/PanoSpatialTagPluginContentEvent.html +1 -1
  85. package/docs/interfaces/PanoSpatialTagPluginContentReplacement.html +1 -1
  86. package/docs/interfaces/PanoSpatialTagPluginData.html +1 -1
  87. package/docs/interfaces/PanoSpatialTagPluginDataElement.html +1 -1
  88. package/docs/interfaces/PanoSpatialTagPluginExportType.html +1 -1
  89. package/docs/interfaces/PanoSpatialTagPluginOriginElement.html +1 -1
  90. package/docs/interfaces/PanoSpatialTagPluginParameterType.html +1 -1
  91. package/docs/interfaces/PanoSpatialTagPluginPointElement.html +1 -1
  92. package/docs/interfaces/PanoSpatialTagPluginTagElement.html +1 -1
  93. package/docs/interfaces/Point.html +1 -1
  94. package/docs/interfaces/PointJson.html +1 -1
  95. package/docs/interfaces/Room.html +1 -1
  96. package/docs/interfaces/RoomInfo.html +1 -1
  97. package/docs/interfaces/RoomLabel.html +7 -7
  98. package/docs/interfaces/RoomRules.html +1 -1
  99. package/docs/interfaces/Rooms.html +1 -1
  100. package/docs/interfaces/Scissor.html +5 -5
  101. package/docs/interfaces/TagConfig.html +3 -3
  102. package/docs/interfaces/Tags.html +3 -3
  103. package/docs/modules.html +21 -21
  104. package/libs/CSS3DRenderPlugin/CSS3DRender.d.ts +15 -4
  105. package/libs/CSS3DRenderPlugin/CSS3DRender.js +197 -143
  106. package/libs/CSS3DRenderPlugin/Controller.d.ts +2 -0
  107. package/libs/CSS3DRenderPlugin/Controller.js +47 -26
  108. package/libs/CSS3DRenderPlugin/utils/CSS3DObjectPlus.d.ts +22 -4
  109. package/libs/CSS3DRenderPlugin/utils/CSS3DObjectPlus.js +56 -37
  110. package/libs/Object3DHelperPlugin/Controller.js +24 -23
  111. package/libs/PanoTagPlugin/Components/Common/MediaItem.js +81 -81
  112. package/libs/PanoTagPlugin/Components/Tag/ImageTextTag.js +69 -68
  113. package/libs/PanoTagPlugin/controller/index.js +1 -1
  114. package/libs/shared-utils/Object3DHelper/Base/BaseController.js +63 -53
  115. package/libs/shared-utils/Object3DHelper/Controller/MoveController.js +12 -13
  116. package/libs/shared-utils/Object3DHelper/Controller/RectangleScaleController.js +43 -45
  117. package/libs/shared-utils/Object3DHelper/Helper/Objects/ArrowGroup.js +16 -10
  118. package/libs/shared-utils/Object3DHelper/Helper/RectangleScaleHelper.d.ts +1 -1
  119. package/libs/shared-utils/Object3DHelper/Helper/RectangleScaleHelper.js +43 -43
  120. package/libs/shared-utils/Object3DHelper/Helper/RotateHelper.js +2 -2
  121. package/libs/shared-utils/Object3DHelper/index.js +12 -12
  122. package/package.json +2 -2
@@ -2,10 +2,10 @@ import * as THREE from 'three';
2
2
  import { CSS3DRenderer } from 'three/examples/jsm/renderers/CSS3DRenderer';
3
3
  import { Subscribe } from '../shared-utils/Subscribe';
4
4
  import { AnyPosition } from './utils';
5
- import { CSS3DObjectPlus } from './utils/CSS3DObjectPlus';
5
+ import { CSS3DObjectPlus, Mode } from './utils/CSS3DObjectPlus';
6
+ export { MinRatio } from './utils/CSS3DObjectPlus';
6
7
  export declare const __ELEMENT__ = "__CSS3DOBJECT_CSS3DRENDER_CONTAINER__";
7
8
  export declare const PLUGIN: string;
8
- export declare const MinRatio = 0.00216;
9
9
  export interface CSS3DRenderState {
10
10
  enabled: boolean;
11
11
  visible: boolean;
@@ -54,7 +54,11 @@ export interface Create3DDElementParamsType {
54
54
  });
55
55
  }
56
56
  export declare const globalStore: {
57
- resizeObserver?: {
57
+ frontModeResizeObserver?: {
58
+ observe: () => void;
59
+ unobserve: () => void;
60
+ };
61
+ behindModeResizeObserver?: {
58
62
  observe: () => void;
59
63
  unobserve: () => void;
60
64
  };
@@ -143,10 +147,17 @@ export declare class CSS3DRender {
143
147
  setEnabled: (enabled: boolean) => void;
144
148
  appendToElement: (container: Element) => void;
145
149
  };
146
- appendToElement(container: Element | undefined, mode: 'front' | 'behind'): void;
150
+ setContainer(container: Element, mode: Mode): void;
151
+ appendToElement(container: Element | undefined, mode: Mode): void;
147
152
  setVisibleById: (id: string, visible: boolean) => void;
148
153
  setEnabledById: (id: string, enabled: boolean) => void;
154
+ private render;
149
155
  private createObject;
156
+ private initGlobalModeStore;
157
+ /**
158
+ * @description: 生成透明Mesh
159
+ */
160
+ private createOpacityMesh;
150
161
  private handleShow;
151
162
  private handleHide;
152
163
  private handleEnable;
@@ -1,32 +1,34 @@
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 { Subscribe as 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";
1
+ var J = Object.defineProperty;
2
+ var K = (S, e, t) => e in S ? J(S, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : S[e] = t;
3
+ var b = (S, e, t) => (K(S, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import * as C from "three";
5
+ import { CSS3DRenderer as B } from "three/examples/jsm/renderers/CSS3DRenderer";
6
+ import { Subscribe as X } from "../shared-utils/Subscribe.js";
7
+ import { evenNumber as L } from "./utils/evenNumber.js";
8
+ import { anyPositionToVector3 as Y } from "./utils/positionToVector3.js";
9
+ import { CSS3DObjectPlus as Z } from "./utils/CSS3DObjectPlus.js";
10
+ import { MinRatio as fe } from "./utils/CSS3DObjectPlus.js";
10
11
  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 {
12
+ const ee = "v2.0.1", x = "CSS3DRenderer", ce = "__CSS3DOBJECT_CSS3DRENDER_CONTAINER__", m = `${x}@${ee}`, P = (S) => `${m}--${S}`, o = {};
13
+ class ae {
13
14
  constructor() {
14
- l(this, "hooks", new H());
15
- l(this, "state", {
15
+ b(this, "hooks", new X());
16
+ b(this, "state", {
16
17
  enabled: !0,
17
18
  visible: !0,
18
19
  disposed: !1
19
20
  });
20
- l(this, "store", {
21
+ b(this, "store", {
22
+ rendered: !1,
21
23
  disposers: [],
22
24
  frontModeCSS3DObjects: {},
23
25
  behindModeCSS3DObjects: {}
24
26
  });
25
- l(this, "create3DElement", (e, s, t) => {
27
+ b(this, "create3DElement", (e, t, s) => {
26
28
  if (this.state.disposed)
27
29
  return this.disposedErrorLog();
28
- const i = (() => {
29
- const d = {
30
+ const n = (() => {
31
+ const r = {
30
32
  ratio: 216e-5,
31
33
  devicePixelRatio: 1,
32
34
  mode: "front",
@@ -34,133 +36,143 @@ class te {
34
36
  container: document.createElement("div"),
35
37
  pointerEvents: "none"
36
38
  };
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
39
+ return Object.assign(r, s);
40
+ })(), i = t.map(Y);
41
+ if ((i == null ? void 0 : i.length) < 4)
42
+ return console.error(`${m}: requires 4 point but params may have fewer`);
43
+ const { ratio: d, devicePixelRatio: a, mode: h, autoRender: p, container: f, pointerEvents: N } = n, w = [], { css3DObject: c, opacityMesh: O } = this.createObject(i, { ratio: d, dpr: a, container: f, mode: h, pointerEvents: N });
44
+ f.id = `container--${c.uuid}`;
45
+ const U = h === "front" && !o.frontModeStore, H = h === "behind" && !o.behindModeStore;
46
+ h === "front" && this.initGlobalModeStore("front"), h === "behind" && this.initGlobalModeStore("behind", n.scene), c.hooks.on("changeMode", (r, D, M) => {
47
+ var k, T, $;
48
+ if (r === D)
49
+ return;
50
+ r === "front" && this.initGlobalModeStore("front"), r === "behind" && this.initGlobalModeStore("behind", M);
51
+ const l = D === "front" ? o.frontModeStore : o.behindModeStore, u = r === "front" ? o.frontModeStore : o.behindModeStore, A = D === "behind" ? this.store.behindModeCSS3DObjects : this.store.frontModeCSS3DObjects, I = r === "behind" ? this.store.behindModeCSS3DObjects : this.store.frontModeCSS3DObjects;
52
+ if (!A || !I)
53
+ return console.error(`${m}: changeMode error: prevObjects or nextObjects is undefined`);
54
+ const j = A[c.uuid];
55
+ if (!j)
56
+ return console.error(`${m}: changeMode error: prevObject is undefined`);
57
+ if (r === "behind") {
58
+ const _ = (k = j.opacityMesh) != null ? k : this.createOpacityMesh(j.css3DObject);
59
+ l == null || l.css3DScene.remove(j.css3DObject), I[c.uuid] = { css3DObject: c, opacityMesh: _, visible: !0, enabled: !0, mode: r, scene: M }, u == null || u.css3DScene.add(c), M == null || M.add(_);
60
+ }
61
+ r === "front" && (l == null || l.css3DScene.remove(j.css3DObject), ($ = (T = A[c.uuid]) == null ? void 0 : T.scene) == null || $.remove(j.opacityMesh), I[c.uuid] = { css3DObject: c, visible: !0, enabled: !0, mode: r }, u == null || u.css3DScene.add(c)), r === "behind" && this.appendToElement(o.behindModeContainer, "behind"), r === "front" && this.appendToElement(o.frontModeContainer, "front"), this.render(e), console.log("change success");
47
62
  });
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)));
63
+ const y = h === "front" ? o.frontModeStore : o.behindModeStore, { css3DScene: E, css3DRenderer: v } = y, F = (() => {
64
+ const r = () => {
65
+ var M, l;
66
+ const D = c.mode;
67
+ if (D === "front")
68
+ this.store.frontModeCSS3DObjects[c.uuid] = {
69
+ visible: !0,
70
+ enabled: !0,
71
+ css3DObject: c,
72
+ mode: "front"
73
+ };
74
+ else {
75
+ if (!n.scene)
76
+ return;
77
+ this.store.behindModeCSS3DObjects[c.uuid] = {
78
+ visible: !0,
79
+ enabled: !0,
80
+ css3DObject: c,
81
+ opacityMesh: O,
82
+ mode: "behind",
83
+ scene: n.scene
84
+ };
85
+ }
86
+ E.getObjectById(c.id) || E.add(c), D === "behind" && O && ((M = n.scene) != null && M.getObjectById(O.id) || (l = n.scene) == null || l.add(O), w.push(() => {
87
+ var u;
88
+ return O && ((u = n.scene) == null ? void 0 : u.remove(O));
89
+ }));
70
90
  };
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);
91
+ return U || H ? (v.domElement.style.position = "absolute", v.domElement.style.top = "0", v.domElement.style.userSelect = "none", v.domElement.style.pointerEvents = "none", v.domElement.classList.add(P(h)), () => {
92
+ r(), this.render(e);
93
+ }) : (this.store.rendered = !0, () => r());
94
+ })(), z = h === "front" ? o.frontModeContainer : o.behindModeContainer;
95
+ if (z) {
96
+ this.appendToElement(z, h);
97
+ const r = h === "front" ? o.frontModeStore : o.behindModeStore;
98
+ r && (r.appendedToPage = !0);
87
99
  }
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(), {
100
+ const g = (r) => this.setVisibleById(c.uuid, r), R = (r) => this.setEnabledById(c.uuid, r), V = () => g(!0), G = () => g(!1), Q = () => R(!0), W = () => R(!1), q = () => (delete this.store.frontModeCSS3DObjects[c.uuid], delete this.store.behindModeCSS3DObjects[c.uuid], w.forEach((r) => r == null ? void 0 : r()), E.remove(c), E.children.length === 0 && (typeof y.requestAnimationFrameId == "number" && cancelAnimationFrame(y.requestAnimationFrameId), v.domElement.remove(), h === "front" && (o.frontModeStore = void 0), h === "behind" && (o.behindModeStore = void 0), o.frontModeResizeObserver = void 0, o.behindModeResizeObserver = void 0), !0);
101
+ return this.store.disposers.push(q), p && F(), {
90
102
  id: c.uuid,
91
- container: S,
92
- dispose: z,
103
+ container: f,
104
+ dispose: q,
93
105
  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)
106
+ render: p ? void 0 : F,
107
+ show: V,
108
+ hide: G,
109
+ setVisible: g,
110
+ disable: W,
111
+ enable: Q,
112
+ setEnabled: R,
113
+ appendToElement: (r) => this.appendToElement(r, h)
102
114
  };
103
115
  });
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)
116
+ b(this, "setVisibleById", (e, t) => {
117
+ var n;
118
+ const s = (n = this.store.frontModeCSS3DObjects[e]) != null ? n : this.store.behindModeCSS3DObjects[e];
119
+ if (!s)
108
120
  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));
121
+ s.visible = t, this.state.visible && (s.css3DObject.visible = t, s.mode === "behind" && (s.opacityMesh.visible = t));
110
122
  });
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)
123
+ b(this, "setEnabledById", (e, t) => {
124
+ var i, d, a;
125
+ const s = (i = this.store.frontModeCSS3DObjects[e]) != null ? i : this.store.behindModeCSS3DObjects[e];
126
+ if (!s)
115
127
  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);
128
+ const n = s.mode === "front" ? (d = o.frontModeStore) == null ? void 0 : d.css3DScene : (a = o.behindModeStore) == null ? void 0 : a.css3DScene;
129
+ !n || (t ? (n.add(s.css3DObject), s.mode === "behind" && s.scene.add(s.opacityMesh)) : (n.remove(s.css3DObject), s.mode === "behind" && s.scene.remove(s.opacityMesh)), s.enabled = t);
118
130
  });
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 };
131
+ b(this, "createObject", (e, t) => {
132
+ const { ratio: s, dpr: n, container: i, mode: d, pointerEvents: a } = t, h = new Z(i, e, s, n, d);
133
+ i.style.pointerEvents = a, i.classList.add(`${x}__container`);
134
+ const p = d === "behind" ? this.createOpacityMesh(h) : void 0;
135
+ return { css3DObject: h, opacityMesh: p };
136
+ });
137
+ b(this, "createOpacityMesh", (e) => {
138
+ const { domWidthPx: t, domHeightPx: s } = e, n = new C.MeshBasicMaterial({
139
+ opacity: 0,
140
+ color: 0,
141
+ transparent: !1,
142
+ side: C.DoubleSide
143
+ }), i = new C.PlaneGeometry(t, s), d = new C.Mesh(i, n);
144
+ return d.name = P("mesh"), d.position.copy(e.position), d.rotation.copy(e.rotation), d.scale.copy(e.scale), e.hooks.on("applyMatrix4", (a) => d.applyMatrix4(a)), e.hooks.on("applyQuaternion", (a) => d.applyQuaternion(a)), e.hooks.on("applyScaleMatrix4", (a) => d.scale.applyMatrix4(a)), d;
133
145
  });
134
- l(this, "createResizeObserver", (e, s, t = !0) => {
146
+ b(this, "createResizeObserver", (e, t, s = !0) => {
135
147
  if (!e)
136
148
  return console.error("createResizeObserver: element is undefined"), { observe: () => {
137
149
  }, unobserve: () => {
138
150
  } };
139
- const i = () => {
140
- const a = _(e.clientWidth, { smaller: !0 }), h = _(e.clientHeight, { smaller: !0 });
141
- s(a, h);
151
+ const n = () => {
152
+ const d = L(e.clientWidth, { smaller: !0 }), a = L(e.clientHeight, { smaller: !0 });
153
+ t(d, a);
142
154
  };
143
155
  if (typeof ResizeObserver > "u" || !ResizeObserver)
144
- return console.warn("createResizeObserver: ResizeObserver is undefined"), { observe: () => i(), unobserve: () => {
156
+ return console.warn("createResizeObserver: ResizeObserver is undefined"), { observe: () => n(), unobserve: () => {
145
157
  } };
146
- const n = new ResizeObserver(i);
147
- return t && i(), {
148
- observe: () => n.observe(e),
149
- unobserve: () => n.unobserve(e)
158
+ const i = new ResizeObserver(n);
159
+ return s && n(), {
160
+ observe: () => i.observe(e),
161
+ unobserve: () => i.unobserve(e)
150
162
  };
151
163
  });
152
- l(this, "disposedErrorLog", () => {
153
- console.error(`${D} is disposed`);
164
+ b(this, "disposedErrorLog", () => {
165
+ console.error(`${m} is disposed`);
154
166
  });
155
167
  }
156
168
  getCurrentState() {
157
169
  return this.state;
158
170
  }
159
- setState(e, s = { userAction: !0 }) {
171
+ setState(e, t = { userAction: !0 }) {
160
172
  if (this.state.disposed)
161
173
  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 });
174
+ const s = { ...this.state };
175
+ this.state = Object.assign(this.state, e), s.visible !== this.state.visible && (e.visible ? this.handleShow() : this.handleHide()), s.enabled !== this.state.enabled && (e.enabled ? this.handleEnable() : this.handleDisable()), this.hooks.emit("stateChange", { state: this.state, prevState: s, userAction: t.userAction });
164
176
  }
165
177
  dispose() {
166
178
  this.store.disposers.forEach((e) => e == null ? void 0 : e()), this.store.disposers = [], this.hooks.emit("dispose"), this.state.disposed = !0;
@@ -185,24 +197,66 @@ class te {
185
197
  return this.disposedErrorLog();
186
198
  this.setState({ enabled: !1 }, { userAction: e }), this.hooks.emit("disable", { userAction: e });
187
199
  }
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);
200
+ setContainer(e, t) {
201
+ t === "front" ? o.frontModeContainer = e : o.behindModeContainer = e;
202
+ }
203
+ appendToElement(e, t) {
204
+ const s = t === "front" ? o.frontModeStore : o.behindModeStore;
205
+ if (!s) {
206
+ if (t === "front" && !o.frontModeContainer) {
207
+ if (!e)
208
+ throw new Error(`${m} Cannot append to container: front mode but container is ${e}`);
209
+ o.frontModeContainer = e;
210
+ }
211
+ if (t === "behind" && !o.behindModeContainer) {
212
+ if (!e)
213
+ throw new Error(`${m} Cannot append to container: behind mode but container is ${e}`);
214
+ o.behindModeContainer = e;
215
+ }
194
216
  return;
195
217
  }
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;
218
+ if (s.appendedToPage)
219
+ return;
220
+ const n = t === "behind" ? o.behindModeContainer : o.frontModeContainer;
221
+ if (!n)
222
+ return console.error("wrapper is undefined");
223
+ if (n.appendChild(s.css3DRenderer.domElement), t === "behind" && !o.behindModeResizeObserver) {
224
+ const i = (h, p) => {
225
+ var f;
226
+ (f = o.behindModeStore) == null || f.css3DRenderer.setSize(h, p);
227
+ }, { observe: d, unobserve: a } = this.createResizeObserver(n, i, !0);
228
+ o.behindModeResizeObserver = { observe: d, unobserve: a }, d(), this.store.disposers.push(a);
229
+ }
230
+ if (t === "front" && !o.frontModeResizeObserver) {
231
+ const i = (h, p) => {
232
+ var f;
233
+ (f = o.frontModeStore) == null || f.css3DRenderer.setSize(h, p);
234
+ }, { observe: d, unobserve: a } = this.createResizeObserver(n, i, !0);
235
+ o.frontModeResizeObserver = { observe: d, unobserve: a }, d(), this.store.disposers.push(a);
236
+ }
237
+ s.appendedToPage = !0;
238
+ }
239
+ render(e) {
240
+ const t = o.behindModeStore, s = o.frontModeStore;
241
+ if (t && Object.keys(this.store.behindModeCSS3DObjects).length > 0 && !t.requestAnimationFrameId) {
242
+ const n = () => {
243
+ const i = requestAnimationFrame(n);
244
+ t.requestAnimationFrameId = i, t.css3DRenderer.render(t.css3DScene, e);
245
+ };
246
+ n();
247
+ }
248
+ if (s && Object.keys(this.store.frontModeCSS3DObjects).length > 0 && !s.requestAnimationFrameId) {
249
+ const n = () => {
250
+ const i = requestAnimationFrame(n);
251
+ s.requestAnimationFrameId = i, s.css3DRenderer.render(s.css3DScene, e);
252
+ };
253
+ n();
205
254
  }
255
+ Object.keys(this.store.frontModeCSS3DObjects).length === 0 && (s == null ? void 0 : s.requestAnimationFrameId) !== void 0 && (cancelAnimationFrame(s.requestAnimationFrameId), s.requestAnimationFrameId = void 0), Object.keys(this.store.behindModeCSS3DObjects).length === 0 && (t == null ? void 0 : t.requestAnimationFrameId) !== void 0 && (cancelAnimationFrame(t.requestAnimationFrameId), t.requestAnimationFrameId = void 0);
256
+ }
257
+ initGlobalModeStore(e, t) {
258
+ const s = e === "front" && !o.frontModeStore;
259
+ e === "behind" && !o.behindModeStore && (o.behindModeStore = { scene: t, css3DScene: new C.Scene(), css3DRenderer: new B() }), s && (o.frontModeStore = { css3DScene: new C.Scene(), css3DRenderer: new B() });
206
260
  }
207
261
  async handleShow() {
208
262
  Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
@@ -220,27 +274,27 @@ class te {
220
274
  }
221
275
  handleEnable() {
222
276
  Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
223
- var s;
224
- !e.enabled || (s = o.frontModeStore) == null || s.css3DScene.add(e.css3DObject);
277
+ var t;
278
+ !e.enabled || (t = o.frontModeStore) == null || t.css3DScene.add(e.css3DObject);
225
279
  }), 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));
280
+ var t, s;
281
+ !e.enabled || ((t = o.behindModeStore) == null || t.css3DScene.add(e.css3DObject), (s = o.behindModeStore) == null || s.scene.add(e.opacityMesh));
228
282
  });
229
283
  }
230
284
  handleDisable() {
231
285
  Object.values(this.store.frontModeCSS3DObjects).forEach((e) => {
232
- var s;
233
- (s = o.frontModeStore) == null || s.css3DScene.remove(e.css3DObject);
286
+ var t;
287
+ (t = o.frontModeStore) == null || t.css3DScene.remove(e.css3DObject);
234
288
  }), 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);
289
+ var t, s;
290
+ (t = o.behindModeStore) == null || t.css3DScene.remove(e.css3DObject), (s = o.behindModeStore) == null || s.scene.remove(e.opacityMesh);
237
291
  });
238
292
  }
239
293
  }
240
294
  export {
241
- te as CSS3DRender,
242
- ee as MinRatio,
243
- D as PLUGIN,
244
- Z as __ELEMENT__,
295
+ ae as CSS3DRender,
296
+ fe as MinRatio,
297
+ m as PLUGIN,
298
+ ce as __ELEMENT__,
245
299
  o as globalStore
246
300
  };
@@ -22,6 +22,7 @@ export interface Create3DDomContainerParamsType {
22
22
  }
23
23
  export default class Controller extends CSS3DRender implements BasePlugin.Controller<CSS3DRenderState, CSS3DRenderEventMap> {
24
24
  five: Five;
25
+ behindFiveContainer?: HTMLElement;
25
26
  readonly staticPrefix: string;
26
27
  constructor(five: Five);
27
28
  /** @deprecated disposeAll() renamed as dispose() */
@@ -76,4 +77,5 @@ export default class Controller extends CSS3DRender implements BasePlugin.Contro
76
77
  setEnabled: (enabled: boolean) => void;
77
78
  appendToElement: (container: Element) => void;
78
79
  };
80
+ private getBehindFiveElement;
79
81
  }
@@ -1,7 +1,7 @@
1
- var h = Object.defineProperty;
2
- var R = (i, r, t) => r in i ? h(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t;
3
- var n = (i, r, t) => (R(i, typeof r != "symbol" ? r + "" : r, t), t);
4
- import { CSS3DRender as E } from "./CSS3DRender.js";
1
+ var b = Object.defineProperty;
2
+ var E = (r, n, t) => n in r ? b(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
3
+ var l = (r, n, t) => (E(r, typeof n != "symbol" ? n + "" : n, t), t);
4
+ import { CSS3DRender as R } from "./CSS3DRender.js";
5
5
  import "three";
6
6
  import "three/examples/jsm/renderers/CSS3DRenderer";
7
7
  import "../shared-utils/Subscribe.js";
@@ -9,40 +9,43 @@ import "./utils/evenNumber.js";
9
9
  import "./utils/positionToVector3.js";
10
10
  import "./utils/CSS3DObjectPlus.js";
11
11
  import "./utils/centerPoint.js";
12
- const S = "v2.0.1", c = `CSS3DRenderPlugin@${S}`;
13
- class A extends E {
12
+ const C = "v2.0.1", f = `CSS3DRenderPlugin@${C}`;
13
+ class N extends R {
14
14
  constructor(t) {
15
15
  super();
16
- n(this, "five");
17
- n(this, "staticPrefix", "//vrlab-static.ljcdn.com");
18
- n(this, "create3DDomContainer", (t, e) => {
16
+ l(this, "five");
17
+ l(this, "behindFiveContainer");
18
+ l(this, "staticPrefix", "//vrlab-static.ljcdn.com");
19
+ l(this, "create3DDomContainer", (t, e) => {
19
20
  if (this.state.disposed)
20
21
  return;
21
- const d = (() => {
22
+ const i = (() => {
22
23
  var v;
23
- (e == null ? void 0 : e.dpr) !== void 0 && console.warn(`${c}: please use "config.devicePixelRatio" replace "config.dpr"`);
24
- const o = {
24
+ (e == null ? void 0 : e.dpr) !== void 0 && console.warn(`${f}: please use "config.devicePixelRatio" replace "config.dpr"`);
25
+ const a = {
25
26
  ratio: 216e-5,
26
27
  devicePixelRatio: (v = e == null ? void 0 : e.dpr) != null ? v : 1,
27
28
  mode: "front",
28
29
  autoRender: !0
29
30
  };
30
- return Object.assign(o, e, (e == null ? void 0 : e.mode) === "behind" ? { scene: this.five.scene } : void 0);
31
- })(), a = this.five.getElement();
32
- if (!a) {
33
- console.error(`${c}: five.getElement() is ${a}`);
31
+ return Object.assign(a, e, (e == null ? void 0 : e.mode) === "behind" ? { scene: this.five.scene } : void 0);
32
+ })(), o = this.five.getElement();
33
+ if (!o) {
34
+ console.error(`${f}: five.getElement() is ${o}`);
34
35
  return;
35
36
  }
36
- const { autoRender: p, mode: s } = d, f = s === "front" ? a.parentElement : d.behindFiveContainer;
37
- this.appendToElement(f || document.body, s);
38
- const l = this.create3DElement(this.five.camera, t, { ...d, autoRender: !1 });
39
- if (!l)
37
+ const { autoRender: d, mode: s } = i, c = s === "front" ? o.parentElement : i.behindFiveContainer;
38
+ this.setContainer(c || document.body, "front");
39
+ const p = this.getBehindFiveElement();
40
+ p && this.setContainer(p, "behind"), this.appendToElement(c || document.body, s);
41
+ const m = this.create3DElement(this.five.camera, t, { ...i, autoRender: !1 });
42
+ if (!m)
40
43
  return;
41
- const m = l.render, u = () => {
42
- var o;
43
- s === "front" && m(), s === "behind" && ((o = this.five.model) != null && o.loaded ? m() : this.five.once("modelLoaded", () => m()));
44
+ const u = m.render, h = () => {
45
+ var a;
46
+ s === "front" && u(), s === "behind" && ((a = this.five.model) != null && a.loaded ? u() : this.five.once("modelLoaded", () => u()));
44
47
  };
45
- return p && u(), { ...l, render: p ? void 0 : u };
48
+ return d && h(), { ...m, render: d ? void 0 : h };
46
49
  });
47
50
  this.five = t;
48
51
  }
@@ -53,8 +56,26 @@ class A extends E {
53
56
  const e = super.setState(...t);
54
57
  return this.five.needsRender = !0, e;
55
58
  }
59
+ getBehindFiveElement() {
60
+ var s;
61
+ const { behindFiveContainer: t } = this;
62
+ if (t)
63
+ return t;
64
+ const e = document.createElement("div");
65
+ e.style.position = "absolute", e.style.pointerEvents = "none", e.style.top = "0", e.style.left = "0", e.style.width = "100%", e.style.height = "100%", this.behindFiveContainer = e;
66
+ const i = this.five.getElement();
67
+ if (!i)
68
+ return;
69
+ const o = (s = i == null ? void 0 : i.style.position) != null ? s : getComputedStyle(i);
70
+ (!o || o === "static") && console.warn(
71
+ "if you want to use css3DRenderPlugin behind mode, five element position is static, please set position to relative or absolute"
72
+ );
73
+ const d = i == null ? void 0 : i.parentElement;
74
+ if (d)
75
+ return d.insertBefore(e, i), e;
76
+ }
56
77
  }
57
78
  export {
58
- c as PLUGIN_NAME,
59
- A as default
79
+ f as PLUGIN_NAME,
80
+ N as default
60
81
  };
@@ -1,16 +1,34 @@
1
1
  import { CSS3DObject } from 'three/examples/jsm/renderers/CSS3DRenderer';
2
- import { Vector3 } from 'three';
2
+ import { Matrix4, Quaternion, Vector3 } from 'three';
3
+ import { Subscribe } from '../../shared-utils/Subscribe';
4
+ import type * as THREE from 'three';
3
5
  export declare const MinRatio = 0.00216;
4
6
  export declare const DefaultRatio = 0.003;
5
- export declare class CSS3DObjectPlus<T extends HTMLElement> extends CSS3DObject {
7
+ export declare type Mode = 'front' | 'behind';
8
+ export declare type CornerPoints = [Vector3, Vector3, Vector3, Vector3];
9
+ export declare type CSS3DRenderEventMap = {
10
+ applyMatrix4: (matrix: Matrix4) => void;
11
+ applyQuaternion: (quaternion: Quaternion) => void;
12
+ applyScaleMatrix4: (matrix: Matrix4) => void;
13
+ changeMode: <T extends Mode = Mode>(mode: T, prevMode: Mode, scene: T extends 'behind' ? THREE.Scene : undefined) => void;
14
+ };
15
+ export declare class CSS3DObjectPlus<T extends HTMLElement = HTMLElement> extends CSS3DObject {
6
16
  version: string;
7
17
  width: number;
8
18
  height: number;
9
19
  domWidthPx: number;
10
20
  domHeightPx: number;
11
- cornerPoints: [Vector3, Vector3, Vector3, Vector3];
21
+ cornerPoints: CornerPoints;
12
22
  ratio: number;
13
23
  container: T;
14
24
  centerPosition: Vector3;
15
- constructor(container: T, cornerPoints: [Vector3, Vector3, Vector3, Vector3], ratio?: number, dpr?: number);
25
+ mode: 'front' | 'behind';
26
+ readonly hooks: Subscribe<CSS3DRenderEventMap>;
27
+ readonly isCSS3DObjectPlus: true;
28
+ constructor(container: T, cornerPoints: CornerPoints, ratio?: number, dpr?: number, mode?: Mode);
29
+ changeMode(mode: 'front'): void;
30
+ changeMode(mode: 'behind', scene: THREE.Scene): void;
31
+ applyScaleMatrix4(matrix: Matrix4): void;
32
+ applyMatrix4(matrix: Matrix4): void;
33
+ applyQuaternion(quaternion: Quaternion): this;
16
34
  }