abstract-3d 2.12.2 → 3.0.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.
Files changed (57) hide show
  1. package/lib/abstract-3d.d.ts +33 -6
  2. package/lib/abstract-3d.d.ts.map +1 -1
  3. package/lib/abstract-3d.js +1 -1
  4. package/lib/abstract-3d.js.map +1 -1
  5. package/lib/renderers/ifc/ifc-encoding.d.ts +5 -2
  6. package/lib/renderers/ifc/ifc-encoding.d.ts.map +1 -1
  7. package/lib/renderers/ifc/ifc-encoding.js +30 -7
  8. package/lib/renderers/ifc/ifc-encoding.js.map +1 -1
  9. package/lib/renderers/ifc/ifc.d.ts +35 -22
  10. package/lib/renderers/ifc/ifc.d.ts.map +1 -1
  11. package/lib/renderers/ifc/ifc.js +124 -49
  12. package/lib/renderers/ifc/ifc.js.map +1 -1
  13. package/lib/renderers/react/index.d.ts +0 -1
  14. package/lib/renderers/react/index.d.ts.map +1 -1
  15. package/lib/renderers/react/index.js.map +1 -1
  16. package/lib/renderers/react/react-dimension.d.ts +2 -2
  17. package/lib/renderers/react/react-dimension.d.ts.map +1 -1
  18. package/lib/renderers/react/react-dimension.js +2 -2
  19. package/lib/renderers/react/react-dimension.js.map +1 -1
  20. package/lib/renderers/react/react-group.d.ts +3 -2
  21. package/lib/renderers/react/react-group.d.ts.map +1 -1
  22. package/lib/renderers/react/react-group.js +3 -3
  23. package/lib/renderers/react/react-group.js.map +1 -1
  24. package/lib/renderers/react/react-material.d.ts +2 -2
  25. package/lib/renderers/react/react-material.d.ts.map +1 -1
  26. package/lib/renderers/react/react-material.js +3 -3
  27. package/lib/renderers/react/react-material.js.map +1 -1
  28. package/lib/renderers/react/react-relation.d.ts +10 -0
  29. package/lib/renderers/react/react-relation.d.ts.map +1 -0
  30. package/lib/renderers/react/react-relation.js +31 -0
  31. package/lib/renderers/react/react-relation.js.map +1 -0
  32. package/lib/renderers/react/react-scene.d.ts +4 -7
  33. package/lib/renderers/react/react-scene.d.ts.map +1 -1
  34. package/lib/renderers/react/react-scene.js +4 -4
  35. package/lib/renderers/react/react-scene.js.map +1 -1
  36. package/lib/renderers/react/react.d.ts +8 -7
  37. package/lib/renderers/react/react.d.ts.map +1 -1
  38. package/lib/renderers/react/react.js +2 -2
  39. package/lib/renderers/react/react.js.map +1 -1
  40. package/package.json +2 -2
  41. package/src/abstract-3d.ts +39 -8
  42. package/src/renderers/ifc/ifc-encoding.ts +31 -7
  43. package/src/renderers/ifc/ifc.test.ts +233 -102
  44. package/src/renderers/ifc/ifc.ts +263 -80
  45. package/src/renderers/react/index.ts +0 -1
  46. package/src/renderers/react/react-dimension.tsx +3 -3
  47. package/src/renderers/react/react-group.test.ts +2 -2
  48. package/src/renderers/react/react-group.tsx +5 -4
  49. package/src/renderers/react/react-material.tsx +4 -4
  50. package/src/renderers/react/react-relation.tsx +86 -0
  51. package/src/renderers/react/react-scene.tsx +9 -21
  52. package/src/renderers/react/react.tsx +11 -14
  53. package/lib/renderers/react/react-hotspot.d.ts +0 -27
  54. package/lib/renderers/react/react-hotspot.d.ts.map +0 -1
  55. package/lib/renderers/react/react-hotspot.js +0 -37
  56. package/lib/renderers/react/react-hotspot.js.map +0 -1
  57. package/src/renderers/react/react-hotspot.tsx +0 -112
@@ -1,12 +1,11 @@
1
1
  import { Html } from "@react-three/drei";
2
2
  import type { ThreeEvent } from "@react-three/fiber";
3
3
  import React from "react";
4
- import type { Scene, Group } from "../../abstract-3d.js";
4
+ import type { Scene, Group, Relation } from "../../abstract-3d.js";
5
5
  import { ReactDimensions } from "./react-dimension.js";
6
6
  import { ReactGroup } from "./react-group.js";
7
- import type { HotSpotInfo } from "./react-hotspot.js";
8
- import { ReactHotSpots } from "./react-hotspot.js";
9
7
  import type { MaterialState } from "./react-material.js";
8
+ import { ReactRelations } from "./react-relation.js";
10
9
  import type { ReactPopover } from "./react-types.js";
11
10
 
12
11
  export type SceneMouseEvent = ThreeEvent<MouseEvent>;
@@ -15,10 +14,8 @@ export function ReactScene({
15
14
  scene,
16
15
  selectedIds,
17
16
  hoveredIdsExternal,
18
- activeHotSpots,
17
+ activeRelations,
19
18
  activeComponents,
20
- hotSpotTexts,
21
- showHotSpotTexts,
22
19
  showDimensions,
23
20
  useAlphaTest,
24
21
  materialStateImages,
@@ -27,19 +24,17 @@ export function ReactScene({
27
24
  onHoverGroup,
28
25
  onContextMenuGroup,
29
26
  getTooltips,
30
- onClickHotSpot,
27
+ onClickRelation,
31
28
  createGroupKey,
32
29
  createGroupId,
33
30
  }: {
34
31
  readonly scene: Scene;
35
32
  readonly selectedIds: Record<string, boolean> | undefined;
36
33
  readonly hoveredIdsExternal: ReadonlyArray<string> | undefined;
37
- readonly activeHotSpots: Record<string, HotSpotInfo> | undefined;
34
+ readonly activeRelations: ReadonlyArray<string> | undefined;
38
35
  readonly activeComponents: Record<string, MaterialState> | undefined;
39
- readonly showHotSpotTexts: boolean;
40
36
  readonly showDimensions: boolean;
41
37
  readonly useAlphaTest?: boolean;
42
- readonly hotSpotTexts?: Record<string, string>;
43
38
  readonly materialStateImages?: Record<string, string>;
44
39
  readonly reactPopovers?: ReadonlyArray<ReactPopover>;
45
40
  readonly onClickGroup?: (
@@ -63,7 +58,7 @@ export function ReactScene({
63
58
  e: SceneMouseEvent
64
59
  ) => void;
65
60
  readonly getTooltips?: (id: string) => ReadonlyArray<ReactPopover>;
66
- readonly onClickHotSpot?: (hotSpot: HotSpotInfo, e: SceneMouseEvent) => void;
61
+ readonly onClickRelation?: (relation: Relation, e: SceneMouseEvent) => void;
67
62
  readonly createGroupKey?: (g: Group, idx: number, rootData: Record<string, string> | undefined, id: string) => string;
68
63
  readonly createGroupId?: (g: Group) => string;
69
64
  }): React.JSX.Element {
@@ -79,7 +74,7 @@ export function ReactScene({
79
74
  key={createGroupKey ? createGroupKey(g, 0, g.data, id) : i}
80
75
  g={g}
81
76
  selectedIds={selectedIds}
82
- hotSpotsActive={activeHotSpots !== undefined}
77
+ relationsActive={activeRelations !== undefined}
83
78
  activeComponents={activeComponents}
84
79
  materialStateImages={materialStateImages}
85
80
  hoveredIdsExternal={hoveredIdsExternal}
@@ -100,19 +95,12 @@ export function ReactScene({
100
95
  sceneRotation={scene.rotation_deprecated}
101
96
  sceneCenter={scene.center_deprecated}
102
97
  selectedIds={selectedIds}
103
- hotSpotsActive={activeHotSpots !== undefined}
98
+ relationsActive={activeRelations !== undefined}
104
99
  onClickGroup={onClickGroup}
105
100
  onHoverGroup={onHoverGroup}
106
101
  onContextMenuGroup={onContextMenuGroup}
107
102
  />
108
- <ReactHotSpots
109
- hotSpots={scene.hotSpots_deprecated}
110
- hotSpotZAdjPos={scene.size_deprecated.z / 2}
111
- activeHotSpots={activeHotSpots}
112
- hotSpotTexts={hotSpotTexts}
113
- onClickHotSpot={onClickHotSpot}
114
- showHotSpotTexts={showHotSpotTexts}
115
- />
103
+ <ReactRelations relations={scene.relations} activeRelations={activeRelations} onClickRelation={onClickRelation} />
116
104
  {reactPopovers?.map((p) => (
117
105
  <Html key={p.id} position={[p.pos.x, p.pos.y, p.pos.z]} center pointerEvents="none" style={{ pointerEvents: "none" }}>
118
106
  {p.content}
@@ -2,10 +2,9 @@ import { Html, type OrbitControlsProps } from "@react-three/drei";
2
2
  import { Canvas, type CanvasProps, type ThreeEvent } from "@react-three/fiber";
3
3
  import { EffectComposer, N8AO } from "@react-three/postprocessing";
4
4
  import React, { memo, useMemo } from "react";
5
- import type { Scene, View, Group } from "../../abstract-3d.js";
5
+ import type { Scene, View, Group, Relation } from "../../abstract-3d.js";
6
6
  import type { ControlsHelper, Camera, BufferZones } from "./react-camera.js";
7
7
  import { ReactCamera } from "./react-camera.js";
8
- import type { HotSpotInfo } from "./react-hotspot.js";
9
8
  import type { MaterialState } from "./react-material.js";
10
9
  import { ReactScene } from "./react-scene.js";
11
10
  import type { ReactPopover } from "./react-types.js";
@@ -13,12 +12,14 @@ import type { ReactPopover } from "./react-types.js";
13
12
  type ReactProps = {
14
13
  readonly scene: Scene | undefined; // undefined to allow for simple early loadign the js when lazy loading the React3Js renderer
15
14
  readonly selectedIds: Record<string, boolean> | undefined;
16
- readonly activeHotSpots?: Record<string, HotSpotInfo> | undefined;
15
+ /**
16
+ * The ids of the relations whose shape is drawn to be clicked, e.g. where a component can be inserted. While defined, even when empty, only the
17
+ * groups whose material state is Accept can be clicked
18
+ */
19
+ readonly activeRelations?: ReadonlyArray<string> | undefined;
17
20
  readonly activeComponents?: Record<string, MaterialState> | undefined;
18
21
  readonly hoveredIdsExternal?: ReadonlyArray<string> | undefined;
19
- readonly showHotSpotTexts?: boolean;
20
22
  readonly showDimensions?: boolean;
21
- readonly hotSpotTexts?: Record<string, string>;
22
23
  readonly popovers?: ReadonlyArray<ReactPopover>;
23
24
  readonly useAnimations?: boolean;
24
25
  readonly camera?: Camera;
@@ -53,7 +54,7 @@ type ReactProps = {
53
54
  e: ThreeEvent<MouseEvent>
54
55
  ) => void;
55
56
  readonly getTooltips?: (id: string) => ReadonlyArray<ReactPopover>;
56
- readonly onClickHotSpot?: (hotSpot: HotSpotInfo, e: ThreeEvent<MouseEvent>) => void;
57
+ readonly onClickRelation?: (relation: Relation, e: ThreeEvent<MouseEvent>) => void;
57
58
  readonly createGroupKey?: (g: Group, idx: number, rootData: Record<string, string> | undefined, id: string) => string;
58
59
  readonly createGroupId?: (g: Group) => string;
59
60
  };
@@ -63,12 +64,10 @@ export const render = memo(
63
64
  scene,
64
65
  selectedIds,
65
66
  useOldMode,
66
- activeHotSpots,
67
+ activeRelations,
67
68
  activeComponents,
68
69
  hoveredIdsExternal,
69
- hotSpotTexts,
70
70
  popovers: reactPopovers,
71
- showHotSpotTexts = false,
72
71
  showDimensions = true,
73
72
  useAnimations = false,
74
73
  camera = { type: "Perspective" },
@@ -83,7 +82,7 @@ export const render = memo(
83
82
  onHoverGroup,
84
83
  onContextMenuGroup,
85
84
  getTooltips,
86
- onClickHotSpot,
85
+ onClickRelation,
87
86
  createGroupKey,
88
87
  createGroupId,
89
88
  bufferZones,
@@ -149,19 +148,17 @@ export const render = memo(
149
148
  <ReactScene
150
149
  scene={scene}
151
150
  selectedIds={selectedIds}
152
- activeHotSpots={activeHotSpots}
151
+ activeRelations={activeRelations}
153
152
  activeComponents={activeComponents}
154
153
  showDimensions={showDimensions}
155
- showHotSpotTexts={showHotSpotTexts}
156
154
  hoveredIdsExternal={hoveredIdsExternal}
157
- hotSpotTexts={hotSpotTexts}
158
155
  reactPopovers={reactPopovers}
159
156
  materialStateImages={materialStateImages}
160
157
  onClickGroup={onClickGroup}
161
158
  onHoverGroup={onHoverGroup}
162
159
  onContextMenuGroup={onContextMenuGroup}
163
160
  getTooltips={getTooltips}
164
- onClickHotSpot={onClickHotSpot}
161
+ onClickRelation={onClickRelation}
165
162
  createGroupKey={createGroupKey}
166
163
  createGroupId={createGroupId}
167
164
  useAlphaTest={useAlphaTest}
@@ -1,27 +0,0 @@
1
- import type { ThreeEvent } from "@react-three/fiber";
2
- import React from "react";
3
- import type { HotSpot } from "../../abstract-3d.js";
4
- export interface HotSpotInfo {
5
- readonly replaceId: string;
6
- readonly replaceFromId: string;
7
- readonly replaceOutlet: string;
8
- readonly replaceToId: string;
9
- readonly replaceInlet: string;
10
- }
11
- export declare const ReactHotSpots: React.MemoExoticComponent<({ hotSpots, showHotSpotTexts, hotSpotTexts, hotSpotZAdjPos, activeHotSpots, onClickHotSpot, }: {
12
- readonly hotSpots?: ReadonlyArray<HotSpot>;
13
- readonly showHotSpotTexts: boolean;
14
- readonly hotSpotZAdjPos: number;
15
- readonly hotSpotTexts?: Record<string, string>;
16
- readonly activeHotSpots: Record<string, HotSpotInfo> | undefined;
17
- readonly onClickHotSpot?: (hotSpot: HotSpotInfo, e: ThreeEvent<MouseEvent>) => void;
18
- }) => React.JSX.Element>;
19
- export declare function ReactHotSpot({ h, hotSpotZAdjPos, showHotSpotTexts, hotSpotTexts, activeHotSpots, onClickHotSpot, }: {
20
- readonly h: HotSpot;
21
- readonly hotSpotZAdjPos: number;
22
- readonly showHotSpotTexts: boolean;
23
- readonly hotSpotTexts?: Record<string, string>;
24
- readonly activeHotSpots: Record<string, HotSpotInfo> | undefined;
25
- readonly onClickHotSpot?: (hotSpot: HotSpotInfo, e: ThreeEvent<MouseEvent>) => void;
26
- }): React.JSX.Element;
27
- //# sourceMappingURL=react-hotspot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hotspot.d.ts","sourceRoot":"","sources":["../../../src/renderers/react/react-hotspot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAO,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAKzD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,aAAa,4HAQrB;IACD,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACrF,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiBtB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAC3B,CAAC,EACD,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,GACf,EAAE;IACD,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;CACrF,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA+CpB"}
@@ -1,37 +0,0 @@
1
- import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Html } from "@react-three/drei";
3
- import React from "react";
4
- import { vec3Scale, vec3Zero } from "../../abstract-3d.js";
5
- import { ReactMaterial } from "./react-material.js";
6
- import { ReactMesh } from "./react-mesh.js";
7
- export const ReactHotSpots = React.memo(({ hotSpots, showHotSpotTexts, hotSpotTexts, hotSpotZAdjPos, activeHotSpots, onClickHotSpot, }) => {
8
- return (_jsx(_Fragment, { children: hotSpots?.map((h) => (_jsx(ReactHotSpot, { h: h, hotSpotZAdjPos: hotSpotZAdjPos, activeHotSpots: activeHotSpots, hotSpotTexts: hotSpotTexts, onClickHotSpot: onClickHotSpot, showHotSpotTexts: showHotSpotTexts }, h.id))) }));
9
- });
10
- export function ReactHotSpot({ h, hotSpotZAdjPos, showHotSpotTexts, hotSpotTexts, activeHotSpots, onClickHotSpot, }) {
11
- const [hovered, setHovered] = React.useState(false);
12
- const hotSpot = activeHotSpots ? activeHotSpots[h.id] : undefined;
13
- const hsPos = h.mesh.geometry.type === "Box" ? h.mesh.geometry.pos : vec3Zero;
14
- const text = hotSpotTexts?.[h.id];
15
- const geo = h.mesh.geometry;
16
- return (_jsxs(_Fragment, { children: [_jsxs("group", { visible: hotSpot !== undefined, ...(hotSpot && {
17
- onClick: (e) => {
18
- if (onClickHotSpot) {
19
- e.stopPropagation();
20
- onClickHotSpot(hotSpot, e);
21
- }
22
- },
23
- onPointerOver: (e) => {
24
- e.stopPropagation();
25
- document.body.style.cursor = "pointer";
26
- setHovered(true);
27
- },
28
- onPointerOut: (_e) => {
29
- document.body.style.cursor = "auto";
30
- setHovered(false);
31
- },
32
- onContextMenu: (e) => {
33
- e.stopPropagation();
34
- },
35
- }), children: [_jsx(ReactMesh, { mesh: h.mesh, children: _jsx(ReactMaterial, { isText: false, isHotSpot: true, material: h.mesh.material, hovered: hovered }) }), _jsx(ReactMesh, { mesh: { ...h.mesh, geometry: { ...geo, size: vec3Scale(geo.size, 1.0125) } }, children: _jsx(ReactMaterial, { isText: false, isHotSpot: true, drawBackOnly: true, material: { normal: "rgb(0, 0, 0)", opacity: 1.0 }, hovered: hovered }) })] }), hotSpotTexts && text && (_jsx(Html, { position: [hsPos.x, hsPos.y, hotSpotZAdjPos], center: true, children: _jsx("div", { className: `air-states-container ${showHotSpotTexts ? "" : "air-states-container-hidden"}`, children: _jsx("span", { className: "air-states-text", children: text }) }) }))] }));
36
- }
37
- //# sourceMappingURL=react-hotspot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hotspot.js","sourceRoot":"","sources":["../../../src/renderers/react/react-hotspot.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD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,GAAI,GACjI,IACN,EACP,YAAY,IAAI,IAAI,IAAI,CACvB,KAAC,IAAI,IAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,kBACxD,cAAK,SAAS,EAAE,wBAAwB,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,6BAA6B,EAAE,YAC7F,eAAM,SAAS,EAAC,iBAAiB,YAAE,IAAI,GAAQ,GAC3C,GACD,CACR,IACA,CACJ,CAAC;AACJ,CAAC"}
@@ -1,112 +0,0 @@
1
- import { Html } from "@react-three/drei";
2
- import type { ThreeEvent } from "@react-three/fiber";
3
- import React from "react";
4
- import type { Box, HotSpot } from "../../abstract-3d.js";
5
- import { vec3Scale, vec3Zero } from "../../abstract-3d.js";
6
- import { ReactMaterial } from "./react-material.js";
7
- import { ReactMesh } from "./react-mesh.js";
8
-
9
- export interface HotSpotInfo {
10
- readonly replaceId: string;
11
- readonly replaceFromId: string;
12
- readonly replaceOutlet: string;
13
- readonly replaceToId: string;
14
- readonly replaceInlet: string;
15
- }
16
-
17
- export const ReactHotSpots = React.memo(
18
- ({
19
- hotSpots,
20
- showHotSpotTexts,
21
- hotSpotTexts,
22
- hotSpotZAdjPos,
23
- activeHotSpots,
24
- onClickHotSpot,
25
- }: {
26
- readonly hotSpots?: ReadonlyArray<HotSpot>;
27
- readonly showHotSpotTexts: boolean;
28
- readonly hotSpotZAdjPos: number;
29
- readonly hotSpotTexts?: Record<string, string>;
30
- readonly activeHotSpots: Record<string, HotSpotInfo> | undefined;
31
- readonly onClickHotSpot?: (hotSpot: HotSpotInfo, e: ThreeEvent<MouseEvent>) => void;
32
- }): React.JSX.Element => {
33
- return (
34
- <>
35
- {hotSpots?.map((h) => (
36
- <ReactHotSpot
37
- key={h.id}
38
- h={h}
39
- hotSpotZAdjPos={hotSpotZAdjPos}
40
- activeHotSpots={activeHotSpots}
41
- hotSpotTexts={hotSpotTexts}
42
- onClickHotSpot={onClickHotSpot}
43
- showHotSpotTexts={showHotSpotTexts}
44
- />
45
- ))}
46
- </>
47
- );
48
- }
49
- );
50
-
51
- export function ReactHotSpot({
52
- h,
53
- hotSpotZAdjPos,
54
- showHotSpotTexts,
55
- hotSpotTexts,
56
- activeHotSpots,
57
- onClickHotSpot,
58
- }: {
59
- readonly h: HotSpot;
60
- readonly hotSpotZAdjPos: number;
61
- readonly showHotSpotTexts: boolean;
62
- readonly hotSpotTexts?: Record<string, string>;
63
- readonly activeHotSpots: Record<string, HotSpotInfo> | undefined;
64
- readonly onClickHotSpot?: (hotSpot: HotSpotInfo, e: ThreeEvent<MouseEvent>) => void;
65
- }): React.JSX.Element {
66
- const [hovered, setHovered] = React.useState<boolean>(false);
67
- const hotSpot = activeHotSpots ? activeHotSpots[h.id] : undefined;
68
- const hsPos = h.mesh.geometry.type === "Box" ? h.mesh.geometry.pos : vec3Zero;
69
- const text = hotSpotTexts?.[h.id];
70
- const geo = h.mesh.geometry as Box;
71
- return (
72
- <>
73
- <group
74
- visible={hotSpot !== undefined}
75
- {...(hotSpot && {
76
- onClick: (e) => {
77
- if (onClickHotSpot) {
78
- e.stopPropagation();
79
- onClickHotSpot(hotSpot, e);
80
- }
81
- },
82
- onPointerOver: (e) => {
83
- e.stopPropagation();
84
- document.body.style.cursor = "pointer";
85
- setHovered(true);
86
- },
87
- onPointerOut: (_e) => {
88
- document.body.style.cursor = "auto";
89
- setHovered(false);
90
- },
91
- onContextMenu: (e) => {
92
- e.stopPropagation();
93
- },
94
- })}
95
- >
96
- <ReactMesh mesh={h.mesh}>
97
- <ReactMaterial isText={false} isHotSpot={true} material={h.mesh.material} hovered={hovered} />
98
- </ReactMesh>
99
- <ReactMesh mesh={{ ...h.mesh, geometry: { ...geo, size: vec3Scale(geo.size, 1.0125) } }}>
100
- <ReactMaterial isText={false} isHotSpot={true} drawBackOnly={true} material={{ normal: "rgb(0, 0, 0)", opacity: 1.0 }} hovered={hovered} />
101
- </ReactMesh>
102
- </group>
103
- {hotSpotTexts && text && (
104
- <Html position={[hsPos.x, hsPos.y, hotSpotZAdjPos]} center>
105
- <div className={`air-states-container ${showHotSpotTexts ? "" : "air-states-container-hidden"}`}>
106
- <span className="air-states-text">{text}</span>
107
- </div>
108
- </Html>
109
- )}
110
- </>
111
- );
112
- }