@vertexvis/viewer 0.18.1 → 0.18.2-testing.0

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 (226) hide show
  1. package/dist/components/_commonjsHelpers.js +41 -0
  2. package/dist/components/_commonjsHelpers.js.map +1 -0
  3. package/dist/components/browser.esm.js +3173 -0
  4. package/dist/components/browser.esm.js.map +1 -0
  5. package/dist/components/bundle.esm.js +2250 -0
  6. package/dist/components/bundle.esm.js.map +1 -0
  7. package/dist/components/bundle.esm2.js +39740 -0
  8. package/dist/components/bundle.esm2.js.map +1 -0
  9. package/dist/components/config.js +81 -0
  10. package/dist/components/config.js.map +1 -0
  11. package/dist/components/controller.js +7627 -0
  12. package/dist/components/controller.js.map +1 -0
  13. package/dist/components/controller2.js +124 -0
  14. package/dist/components/controller2.js.map +1 -0
  15. package/dist/components/controller3.js +111 -0
  16. package/dist/components/controller3.js.map +1 -0
  17. package/dist/components/cursors.js +110 -0
  18. package/dist/components/cursors.js.map +1 -0
  19. package/dist/components/dom.js +43 -0
  20. package/dist/components/dom.js.map +1 -0
  21. package/dist/components/dom2.js +10 -0
  22. package/dist/components/dom2.js.map +1 -0
  23. package/dist/components/elementRectObserver.js +25 -0
  24. package/dist/components/elementRectObserver.js.map +1 -0
  25. package/dist/components/entities.js +179 -0
  26. package/dist/components/entities.js.map +1 -0
  27. package/dist/components/errors.js +80 -0
  28. package/dist/components/errors.js.map +1 -0
  29. package/dist/components/events.js +11 -0
  30. package/dist/components/events.js.map +1 -0
  31. package/dist/components/index.d.ts +26 -0
  32. package/dist/components/index.js +365 -0
  33. package/dist/components/index.js.map +1 -0
  34. package/dist/components/index2.js +63 -0
  35. package/dist/components/index2.js.map +1 -0
  36. package/dist/components/interactions.js +236 -0
  37. package/dist/components/interactions.js.map +1 -0
  38. package/dist/components/mapper.js +9811 -0
  39. package/dist/components/mapper.js.map +1 -0
  40. package/dist/components/markup.js +33 -0
  41. package/dist/components/markup.js.map +1 -0
  42. package/dist/components/model.js +134 -0
  43. package/dist/components/model.js.map +1 -0
  44. package/dist/components/model2.js +157 -0
  45. package/dist/components/model2.js.map +1 -0
  46. package/dist/components/overlays.js +76 -0
  47. package/dist/components/overlays.js.map +1 -0
  48. package/dist/components/png-decoder.js +2405 -0
  49. package/dist/components/png-decoder.js.map +1 -0
  50. package/dist/components/regl-component.js +12582 -0
  51. package/dist/components/regl-component.js.map +1 -0
  52. package/dist/components/results.js +24 -0
  53. package/dist/components/results.js.map +1 -0
  54. package/dist/components/row.js +32 -0
  55. package/dist/components/row.js.map +1 -0
  56. package/dist/components/scene-tree-search.js +146 -0
  57. package/dist/components/scene-tree-search.js.map +1 -0
  58. package/dist/components/scene-tree-table-layout.js +928 -0
  59. package/dist/components/scene-tree-table-layout.js.map +1 -0
  60. package/dist/components/scene-tree-toolbar.js +35 -0
  61. package/dist/components/scene-tree-toolbar.js.map +1 -0
  62. package/dist/components/scene.js +1508 -0
  63. package/dist/components/scene.js.map +1 -0
  64. package/dist/components/stencil.js +25 -0
  65. package/dist/components/stencil.js.map +1 -0
  66. package/dist/components/streamAttributes.js +40833 -0
  67. package/dist/components/streamAttributes.js.map +1 -0
  68. package/dist/components/templates.js +36 -0
  69. package/dist/components/templates.js.map +1 -0
  70. package/dist/components/tslib.es6.js +125 -0
  71. package/dist/components/tslib.es6.js.map +1 -0
  72. package/dist/components/vertex-scene-tree-search.d.ts +11 -0
  73. package/dist/components/vertex-scene-tree-search.js +11 -0
  74. package/dist/components/vertex-scene-tree-search.js.map +1 -0
  75. package/dist/components/vertex-scene-tree-table-cell.d.ts +11 -0
  76. package/dist/components/vertex-scene-tree-table-cell.js +209 -0
  77. package/dist/components/vertex-scene-tree-table-cell.js.map +1 -0
  78. package/dist/components/vertex-scene-tree-table-column.d.ts +11 -0
  79. package/dist/components/vertex-scene-tree-table-column.js +42 -0
  80. package/dist/components/vertex-scene-tree-table-column.js.map +1 -0
  81. package/dist/components/vertex-scene-tree-table-header.d.ts +11 -0
  82. package/dist/components/vertex-scene-tree-table-header.js +38 -0
  83. package/dist/components/vertex-scene-tree-table-header.js.map +1 -0
  84. package/dist/components/vertex-scene-tree-table-layout.d.ts +11 -0
  85. package/dist/components/vertex-scene-tree-table-layout.js +11 -0
  86. package/dist/components/vertex-scene-tree-table-layout.js.map +1 -0
  87. package/dist/components/vertex-scene-tree-table-resize-divider.d.ts +11 -0
  88. package/dist/components/vertex-scene-tree-table-resize-divider.js +57 -0
  89. package/dist/components/vertex-scene-tree-table-resize-divider.js.map +1 -0
  90. package/dist/components/vertex-scene-tree-toolbar-group.d.ts +11 -0
  91. package/dist/components/vertex-scene-tree-toolbar-group.js +38 -0
  92. package/dist/components/vertex-scene-tree-toolbar-group.js.map +1 -0
  93. package/dist/components/vertex-scene-tree-toolbar.d.ts +11 -0
  94. package/dist/components/vertex-scene-tree-toolbar.js +11 -0
  95. package/dist/components/vertex-scene-tree-toolbar.js.map +1 -0
  96. package/dist/components/vertex-scene-tree.d.ts +11 -0
  97. package/dist/components/vertex-scene-tree.js +803 -0
  98. package/dist/components/vertex-scene-tree.js.map +1 -0
  99. package/dist/components/vertex-viewer-box-query-tool.d.ts +11 -0
  100. package/dist/components/vertex-viewer-box-query-tool.js +352 -0
  101. package/dist/components/vertex-viewer-box-query-tool.js.map +1 -0
  102. package/dist/components/vertex-viewer-button.d.ts +11 -0
  103. package/dist/components/vertex-viewer-button.js +11 -0
  104. package/dist/components/vertex-viewer-button.js.map +1 -0
  105. package/dist/components/vertex-viewer-default-toolbar.d.ts +11 -0
  106. package/dist/components/vertex-viewer-default-toolbar.js +99 -0
  107. package/dist/components/vertex-viewer-default-toolbar.js.map +1 -0
  108. package/dist/components/vertex-viewer-dom-element.d.ts +11 -0
  109. package/dist/components/vertex-viewer-dom-element.js +11 -0
  110. package/dist/components/vertex-viewer-dom-element.js.map +1 -0
  111. package/dist/components/vertex-viewer-dom-group.d.ts +11 -0
  112. package/dist/components/vertex-viewer-dom-group.js +11 -0
  113. package/dist/components/vertex-viewer-dom-group.js.map +1 -0
  114. package/dist/components/vertex-viewer-dom-renderer.d.ts +11 -0
  115. package/dist/components/vertex-viewer-dom-renderer.js +11 -0
  116. package/dist/components/vertex-viewer-dom-renderer.js.map +1 -0
  117. package/dist/components/vertex-viewer-hit-result-indicator.d.ts +11 -0
  118. package/dist/components/vertex-viewer-hit-result-indicator.js +335 -0
  119. package/dist/components/vertex-viewer-hit-result-indicator.js.map +1 -0
  120. package/dist/components/vertex-viewer-icon.d.ts +11 -0
  121. package/dist/components/vertex-viewer-icon.js +11 -0
  122. package/dist/components/vertex-viewer-icon.js.map +1 -0
  123. package/dist/components/vertex-viewer-layer.d.ts +11 -0
  124. package/dist/components/vertex-viewer-layer.js +11 -0
  125. package/dist/components/vertex-viewer-layer.js.map +1 -0
  126. package/dist/components/vertex-viewer-markup-arrow.d.ts +11 -0
  127. package/dist/components/vertex-viewer-markup-arrow.js +11 -0
  128. package/dist/components/vertex-viewer-markup-arrow.js.map +1 -0
  129. package/dist/components/vertex-viewer-markup-circle.d.ts +11 -0
  130. package/dist/components/vertex-viewer-markup-circle.js +11 -0
  131. package/dist/components/vertex-viewer-markup-circle.js.map +1 -0
  132. package/dist/components/vertex-viewer-markup-freeform.d.ts +11 -0
  133. package/dist/components/vertex-viewer-markup-freeform.js +11 -0
  134. package/dist/components/vertex-viewer-markup-freeform.js.map +1 -0
  135. package/dist/components/vertex-viewer-markup-tool.d.ts +11 -0
  136. package/dist/components/vertex-viewer-markup-tool.js +257 -0
  137. package/dist/components/vertex-viewer-markup-tool.js.map +1 -0
  138. package/dist/components/vertex-viewer-markup.d.ts +11 -0
  139. package/dist/components/vertex-viewer-markup.js +362 -0
  140. package/dist/components/vertex-viewer-markup.js.map +1 -0
  141. package/dist/components/vertex-viewer-measurement-details.d.ts +11 -0
  142. package/dist/components/vertex-viewer-measurement-details.js +307 -0
  143. package/dist/components/vertex-viewer-measurement-details.js.map +1 -0
  144. package/dist/components/vertex-viewer-measurement-distance.d.ts +11 -0
  145. package/dist/components/vertex-viewer-measurement-distance.js +1067 -0
  146. package/dist/components/vertex-viewer-measurement-distance.js.map +1 -0
  147. package/dist/components/vertex-viewer-measurement-line.d.ts +11 -0
  148. package/dist/components/vertex-viewer-measurement-line.js +11 -0
  149. package/dist/components/vertex-viewer-measurement-line.js.map +1 -0
  150. package/dist/components/vertex-viewer-measurement-overlays.d.ts +11 -0
  151. package/dist/components/vertex-viewer-measurement-overlays.js +11 -0
  152. package/dist/components/vertex-viewer-measurement-overlays.js.map +1 -0
  153. package/dist/components/vertex-viewer-measurement-precise.d.ts +11 -0
  154. package/dist/components/vertex-viewer-measurement-precise.js +362 -0
  155. package/dist/components/vertex-viewer-measurement-precise.js.map +1 -0
  156. package/dist/components/vertex-viewer-pin-group.d.ts +11 -0
  157. package/dist/components/vertex-viewer-pin-group.js +11 -0
  158. package/dist/components/vertex-viewer-pin-group.js.map +1 -0
  159. package/dist/components/vertex-viewer-pin-label-line.d.ts +11 -0
  160. package/dist/components/vertex-viewer-pin-label-line.js +11 -0
  161. package/dist/components/vertex-viewer-pin-label-line.js.map +1 -0
  162. package/dist/components/vertex-viewer-pin-label.d.ts +11 -0
  163. package/dist/components/vertex-viewer-pin-label.js +11 -0
  164. package/dist/components/vertex-viewer-pin-label.js.map +1 -0
  165. package/dist/components/vertex-viewer-pin-tool.d.ts +11 -0
  166. package/dist/components/vertex-viewer-pin-tool.js +430 -0
  167. package/dist/components/vertex-viewer-pin-tool.js.map +1 -0
  168. package/dist/components/vertex-viewer-spinner.d.ts +11 -0
  169. package/dist/components/vertex-viewer-spinner.js +11 -0
  170. package/dist/components/vertex-viewer-spinner.js.map +1 -0
  171. package/dist/components/vertex-viewer-toolbar-group.d.ts +11 -0
  172. package/dist/components/vertex-viewer-toolbar-group.js +11 -0
  173. package/dist/components/vertex-viewer-toolbar-group.js.map +1 -0
  174. package/dist/components/vertex-viewer-toolbar.d.ts +11 -0
  175. package/dist/components/vertex-viewer-toolbar.js +11 -0
  176. package/dist/components/vertex-viewer-toolbar.js.map +1 -0
  177. package/dist/components/vertex-viewer-transform-widget.d.ts +11 -0
  178. package/dist/components/vertex-viewer-transform-widget.js +838 -0
  179. package/dist/components/vertex-viewer-transform-widget.js.map +1 -0
  180. package/dist/components/vertex-viewer-view-cube.d.ts +11 -0
  181. package/dist/components/vertex-viewer-view-cube.js +270 -0
  182. package/dist/components/vertex-viewer-view-cube.js.map +1 -0
  183. package/dist/components/vertex-viewer.d.ts +11 -0
  184. package/dist/components/vertex-viewer.js +3543 -0
  185. package/dist/components/vertex-viewer.js.map +1 -0
  186. package/dist/components/viewer-button.js +35 -0
  187. package/dist/components/viewer-button.js.map +1 -0
  188. package/dist/components/viewer-dom-element.js +250 -0
  189. package/dist/components/viewer-dom-element.js.map +1 -0
  190. package/dist/components/viewer-dom-group.js +214 -0
  191. package/dist/components/viewer-dom-group.js.map +1 -0
  192. package/dist/components/viewer-dom-renderer.js +295 -0
  193. package/dist/components/viewer-dom-renderer.js.map +1 -0
  194. package/dist/components/viewer-icon.js +87 -0
  195. package/dist/components/viewer-icon.js.map +1 -0
  196. package/dist/components/viewer-layer.js +46 -0
  197. package/dist/components/viewer-layer.js.map +1 -0
  198. package/dist/components/viewer-markup-arrow.js +235 -0
  199. package/dist/components/viewer-markup-arrow.js.map +1 -0
  200. package/dist/components/viewer-markup-circle-components.js +42 -0
  201. package/dist/components/viewer-markup-circle-components.js.map +1 -0
  202. package/dist/components/viewer-markup-circle.js +201 -0
  203. package/dist/components/viewer-markup-circle.js.map +1 -0
  204. package/dist/components/viewer-markup-freeform.js +251 -0
  205. package/dist/components/viewer-markup-freeform.js.map +1 -0
  206. package/dist/components/viewer-measurement-line.js +77 -0
  207. package/dist/components/viewer-measurement-line.js.map +1 -0
  208. package/dist/components/viewer-measurement-overlays.js +184 -0
  209. package/dist/components/viewer-measurement-overlays.js.map +1 -0
  210. package/dist/components/viewer-pin-group.js +207 -0
  211. package/dist/components/viewer-pin-group.js.map +1 -0
  212. package/dist/components/viewer-pin-label-line.js +43 -0
  213. package/dist/components/viewer-pin-label-line.js.map +1 -0
  214. package/dist/components/viewer-pin-label.js +427 -0
  215. package/dist/components/viewer-pin-label.js.map +1 -0
  216. package/dist/components/viewer-spinner.js +53 -0
  217. package/dist/components/viewer-spinner.js.map +1 -0
  218. package/dist/components/viewer-toolbar-group.js +42 -0
  219. package/dist/components/viewer-toolbar-group.js.map +1 -0
  220. package/dist/components/viewer-toolbar.js +61 -0
  221. package/dist/components/viewer-toolbar.js.map +1 -0
  222. package/dist/components/viewport.js +188 -0
  223. package/dist/components/viewport.js.map +1 -0
  224. package/dist/components/wrappers_pb.js +1926 -0
  225. package/dist/components/wrappers_pb.js.map +1 -0
  226. package/package.json +7 -7
@@ -0,0 +1,1508 @@
1
+ /*!
2
+ * Copyright (c) 2023 Vertex Software LLC. All rights reserved.
3
+ */
4
+ import { c as color, u as uri, a as async, b as uuid } from './browser.esm.js';
5
+ import { I as InvalidResourceUrnError, a as InvalidCameraError, b as InvalidArgumentError } from './errors.js';
6
+ import { v as vector3, b as boundingBox, a as boundingSphere, m as matrix4, q as quaternion, r as ray, p as point, d as dimensions } from './bundle.esm.js';
7
+ import { v as vertexvis, t as toProtobuf, e as FramePerspectiveCamera, g as constrainViewVector, d as FrameOrthographicCamera, w as withPositionAndViewVector, h as fromBoundingBoxAndLookAtCamera } from './streamAttributes.js';
8
+ import { t as toProtoDuration } from './bundle.esm2.js';
9
+
10
+ const defaultColor = {
11
+ opacity: 255,
12
+ glossiness: 4,
13
+ diffuse: {
14
+ r: 0,
15
+ g: 0,
16
+ b: 0,
17
+ a: 0,
18
+ },
19
+ ambient: {
20
+ r: 0,
21
+ g: 0,
22
+ b: 0,
23
+ a: 0,
24
+ },
25
+ specular: {
26
+ r: 0,
27
+ g: 0,
28
+ b: 0,
29
+ a: 0,
30
+ },
31
+ emissive: {
32
+ r: 0,
33
+ g: 0,
34
+ b: 0,
35
+ a: 0,
36
+ },
37
+ };
38
+ /**
39
+ * This helper creats an rgb value color
40
+ * @param hex
41
+ * @param opacity
42
+ */
43
+ const create = (r, g, b, opacity) => {
44
+ return Object.assign(Object.assign({}, defaultColor), { opacity: opacity !== null && opacity !== void 0 ? opacity : defaultColor.opacity, diffuse: {
45
+ r,
46
+ g,
47
+ b,
48
+ a: 0,
49
+ } });
50
+ };
51
+ /**
52
+ * This helper converts a hex string to a ColorMaterial object
53
+ * @param hex
54
+ * @param opacity
55
+ */
56
+ const fromHex = (hex, opacity) => {
57
+ const color$1 = color.fromHexString(hex);
58
+ return Object.assign(Object.assign({}, defaultColor), { opacity: opacity !== null && opacity !== void 0 ? opacity : defaultColor.opacity, diffuse: color$1 != null ? Object.assign({}, color$1) : Object.assign({}, defaultColor.diffuse) });
59
+ };
60
+
61
+ const colorMaterial = /*#__PURE__*/Object.freeze({
62
+ __proto__: null,
63
+ defaultColor: defaultColor,
64
+ create: create,
65
+ fromHex: fromHex
66
+ });
67
+
68
+ function fromUrn(urn) {
69
+ var _a;
70
+ const uri$1 = uri.parse(urn);
71
+ if (uri$1.scheme !== 'urn' || uri$1.path == null) {
72
+ throw new Error('Invalid URN. Expected URN scheme.');
73
+ }
74
+ const [nid, resourceType, resourceId, ...subResourcePath] = uri$1.path.split(/[:/]/);
75
+ if (nid !== 'vertexvis' && nid !== 'vertex') {
76
+ throw new Error('Invalid URN. Expected URN to be vertex namespace');
77
+ }
78
+ if (nid === 'vertexvis') {
79
+ console.warn("vertexvis namespace is deprecated. Use 'vertex' for the namespace urn instead");
80
+ }
81
+ switch (resourceType) {
82
+ case 'stream-key':
83
+ const queries = fromQuery(uri$1.query);
84
+ const subResource = (_a = fromSubResourcePath(subResourcePath.join('/'))) !== null && _a !== void 0 ? _a : queries.find((q) => q.type === 'scene-view-state');
85
+ return {
86
+ resource: { type: 'stream-key', id: resourceId },
87
+ subResource,
88
+ queries: queries.filter((q) => q.type !== 'scene-view-state'),
89
+ };
90
+ default:
91
+ throw new InvalidResourceUrnError(`Invalid URN. Unknown resource type ${resourceType}`);
92
+ }
93
+ }
94
+ function fromSubResourcePath(path) {
95
+ if (path != null) {
96
+ const [subResourceType, subResourceId] = path.split('/');
97
+ switch (subResourceType) {
98
+ case 'scene-view-states':
99
+ return {
100
+ type: 'scene-view-state',
101
+ id: subResourceId,
102
+ };
103
+ default:
104
+ return undefined;
105
+ }
106
+ }
107
+ }
108
+ function fromQuery(query) {
109
+ if (query != null) {
110
+ return query.split('&').map((queryFragment) => {
111
+ const [resourceType, resourceId] = queryFragment.split('=');
112
+ switch (resourceType) {
113
+ case 'supplied-id':
114
+ return { type: 'supplied-id', id: resourceId };
115
+ case 'scene-view-state':
116
+ return { type: 'scene-view-state', id: resourceId };
117
+ default:
118
+ throw new Error('Invalid URN. Unknown query value type');
119
+ }
120
+ });
121
+ }
122
+ else {
123
+ return [];
124
+ }
125
+ }
126
+
127
+ const loadableResource = /*#__PURE__*/Object.freeze({
128
+ __proto__: null,
129
+ fromUrn: fromUrn
130
+ });
131
+
132
+ function isSceneViewStateId(identifier) {
133
+ return identifier.id != null;
134
+ }
135
+ function isSceneViewStateSuppliedId(identifier) {
136
+ return identifier.suppliedId != null;
137
+ }
138
+
139
+ /**
140
+ * A `SynchronizedClock` allows for approximating the time on a remote machine.
141
+ *
142
+ * During initialization, a known time of the remote host must be supplied. Once
143
+ * the remote time is known, this class can approximate the time on the remote
144
+ * machine from a date or duration.
145
+ *
146
+ * @example
147
+ * ```
148
+ * const knownRemoteTime = await getRemoteTime();
149
+ * const clock = new SynchronizedClock(knownRemoteTime);
150
+ *
151
+ * const localDate = new Date();
152
+ * const serverTime = clock.remoteTime(localDate);
153
+ *
154
+ * const remoteDate = await getRemoteTime();
155
+ * const localTime = clock.localTime(remoteDate);
156
+ *
157
+ * const currentRemoteTime = clock.remoteNow();
158
+ * ```
159
+ */
160
+ class SynchronizedClock {
161
+ constructor(knownRemoteTime, knownLocalTime = new Date()) {
162
+ this.knownRemoteTime = knownRemoteTime;
163
+ this.knownLocalTime = knownLocalTime;
164
+ }
165
+ /**
166
+ * Computes an offset duration from when this clock was instantiated.
167
+ */
168
+ localOffset() {
169
+ return this.duration(this.knownLocalTime, this.localNow());
170
+ }
171
+ /**
172
+ * Approximates the local time from a remote timestamp or duration.
173
+ *
174
+ * @param remoteTimeOrDurationInMs A remote timestamp or duration.
175
+ */
176
+ localTime(remoteTimeOrDurationInMs) {
177
+ const remoteTime = typeof remoteTimeOrDurationInMs === 'number'
178
+ ? new Date(this.knownLocalTime.getTime() + remoteTimeOrDurationInMs)
179
+ : remoteTimeOrDurationInMs;
180
+ const duration = this.duration(this.knownRemoteTime, remoteTime);
181
+ return this.addDuration(this.knownLocalTime, duration);
182
+ }
183
+ /**
184
+ * Approximates an offset duration on the remote machine.
185
+ *
186
+ * @param localTime A local timestamp. Defaults to the current local time.
187
+ */
188
+ remoteOffset(localTime = new Date()) {
189
+ return this.duration(this.remoteTime(this.knownLocalTime), this.remoteTime(localTime));
190
+ }
191
+ /**
192
+ * Approximates the current time on the remote machine.
193
+ */
194
+ remoteNow() {
195
+ return this.remoteTime(this.localNow());
196
+ }
197
+ /**
198
+ * Approximates the remote time from either a local timestamp or duration.
199
+ *
200
+ * @param localTimeOrDurationInMs A local timestamp or duration.
201
+ */
202
+ remoteTime(localTimeOrDurationInMs) {
203
+ const localTime = typeof localTimeOrDurationInMs === 'number'
204
+ ? new Date(this.knownLocalTime.getTime() + localTimeOrDurationInMs)
205
+ : localTimeOrDurationInMs;
206
+ const duration = this.duration(this.knownLocalTime, localTime);
207
+ return this.addDuration(this.knownRemoteTime, duration);
208
+ }
209
+ addDuration(start, duration) {
210
+ return new Date(start.getTime() + duration);
211
+ }
212
+ duration(start, end) {
213
+ return end.getTime() - start.getTime();
214
+ }
215
+ localNow() {
216
+ return new Date(Date.now());
217
+ }
218
+ }
219
+
220
+ const DEFAULT_TIMEOUT_IN_MS = 1000 * 10;
221
+ class StreamApiEventDispatcher {
222
+ constructor(stream, predicate, transform, timeout = DEFAULT_TIMEOUT_IN_MS) {
223
+ this.stream = stream;
224
+ this.predicate = predicate;
225
+ this.transform = transform;
226
+ this.timeout = timeout;
227
+ this.listeners = [];
228
+ this.handleMessage = this.handleMessage.bind(this);
229
+ }
230
+ on(listener) {
231
+ this.listeners = [...this.listeners, listener];
232
+ if (this.eventDisposable == null || this.requestDisposable == null) {
233
+ this.addListeners();
234
+ }
235
+ }
236
+ off(listener) {
237
+ this.listeners = this.listeners.filter((l) => l !== listener);
238
+ if (this.listeners.length === 0) {
239
+ this.removeListeners();
240
+ }
241
+ }
242
+ once() {
243
+ let handler;
244
+ return async.timeout(this.timeout, new Promise((resolve) => {
245
+ handler = (data) => {
246
+ resolve(data);
247
+ this.off(handler);
248
+ };
249
+ this.on(handler);
250
+ })).finally(() => {
251
+ this.off(handler);
252
+ });
253
+ }
254
+ handleMessage(msg) {
255
+ if (this.predicate(msg)) {
256
+ const transformed = this.transform(msg);
257
+ if (transformed != null) {
258
+ this.listeners.forEach((l) => l(transformed));
259
+ }
260
+ }
261
+ }
262
+ addListeners() {
263
+ this.eventDisposable = this.stream.onEvent(this.handleMessage);
264
+ this.requestDisposable = this.stream.onRequest(this.handleMessage);
265
+ }
266
+ removeListeners() {
267
+ var _a, _b;
268
+ (_a = this.eventDisposable) === null || _a === void 0 ? void 0 : _a.dispose();
269
+ (_b = this.requestDisposable) === null || _b === void 0 ? void 0 : _b.dispose();
270
+ }
271
+ }
272
+
273
+ class CameraRenderResult {
274
+ constructor(stream, decodeFrame, { animationId, correlationId }, timeout) {
275
+ this.data = undefined;
276
+ this.onAnimationCompleted = new StreamApiEventDispatcher(stream, (msg) => { var _a, _b, _c; return ((_c = (_b = (_a = msg.event) === null || _a === void 0 ? void 0 : _a.animationCompleted) === null || _b === void 0 ? void 0 : _b.animationId) === null || _c === void 0 ? void 0 : _c.hex) === animationId; }, (msg) => { var _a, _b, _c; return ((_c = (_b = (_a = msg.event) === null || _a === void 0 ? void 0 : _a.animationCompleted) === null || _b === void 0 ? void 0 : _b.animationId) === null || _c === void 0 ? void 0 : _c.hex) || undefined; }, timeout);
277
+ this.onFrameReceived = new StreamApiEventDispatcher(stream, (msg) => {
278
+ var _a, _b, _c;
279
+ return !!((_c = (_b = (_a = msg.request) === null || _a === void 0 ? void 0 : _a.drawFrame) === null || _b === void 0 ? void 0 : _b.frameCorrelationIds) === null || _c === void 0 ? void 0 : _c.some((id) => id === correlationId));
280
+ }, (msg) => {
281
+ var _a;
282
+ return ((_a = msg.request) === null || _a === void 0 ? void 0 : _a.drawFrame) != null
283
+ ? decodeFrame(msg.request.drawFrame)
284
+ : undefined;
285
+ }, timeout);
286
+ }
287
+ }
288
+
289
+ function buildSceneViewStateIdentifier(identifier) {
290
+ if (typeof identifier === 'string') {
291
+ return { sceneViewStateId: { hex: identifier } };
292
+ }
293
+ else if (isSceneViewStateId(identifier)) {
294
+ return { sceneViewStateId: { hex: identifier.id } };
295
+ }
296
+ else if (isSceneViewStateSuppliedId(identifier)) {
297
+ return { sceneViewStateSuppliedId: { value: identifier.suppliedId } };
298
+ }
299
+ else {
300
+ throw new Error('Unable to build scene view state identifier, input must be a string or `SceneViewStateIdentifier`.');
301
+ }
302
+ }
303
+ function buildQueryExpression(query, context) {
304
+ switch (query.type) {
305
+ case 'and':
306
+ case 'or':
307
+ return {
308
+ operand: {
309
+ itemCollection: {
310
+ queries: query.expressions.map((exp) => ({
311
+ sceneItemQuery: buildSceneItemQuery(exp),
312
+ })),
313
+ },
314
+ },
315
+ };
316
+ case 'not':
317
+ return {
318
+ not: {
319
+ expression: buildQueryExpression(query.query, context),
320
+ },
321
+ };
322
+ case 'item-id':
323
+ case 'supplied-id':
324
+ return {
325
+ operand: {
326
+ item: {
327
+ sceneItemQuery: buildSceneItemQuery(query),
328
+ },
329
+ },
330
+ };
331
+ case 'all':
332
+ return {
333
+ operand: {
334
+ root: {},
335
+ },
336
+ };
337
+ case 'scene-tree-range':
338
+ return {
339
+ operand: {
340
+ sceneTreeRange: {
341
+ start: query.range.start,
342
+ end: query.range.end,
343
+ },
344
+ },
345
+ };
346
+ case 'metadata':
347
+ return {
348
+ operand: {
349
+ metadata: {
350
+ valueFilter: query.filter,
351
+ keys: query.keys,
352
+ exactMatch: query.exactMatch,
353
+ },
354
+ },
355
+ };
356
+ case 'all-selected':
357
+ return {
358
+ operand: {
359
+ override: {
360
+ selection: {},
361
+ },
362
+ },
363
+ };
364
+ case 'point':
365
+ return {
366
+ operand: {
367
+ point: {
368
+ point: query.point,
369
+ viewport: context.dimensions,
370
+ },
371
+ },
372
+ };
373
+ case 'volume-intersection':
374
+ return {
375
+ operand: {
376
+ volume: {
377
+ frustumByRectangle: {
378
+ rectangle: query.rectangle,
379
+ },
380
+ exclusive: query.exclusive,
381
+ viewport: context.dimensions,
382
+ },
383
+ },
384
+ };
385
+ default:
386
+ return {};
387
+ }
388
+ }
389
+ function buildSceneOperation(query, operations, context) {
390
+ const operationTypes = buildOperationTypes(operations);
391
+ const queryExpression = buildQueryExpression(query, context);
392
+ return {
393
+ queryExpression,
394
+ operationTypes,
395
+ };
396
+ }
397
+ function buildSceneItemQuery(item) {
398
+ switch (item.type) {
399
+ case 'item-id':
400
+ return {
401
+ id: new vertexvis.protobuf.core.Uuid({
402
+ hex: item.value,
403
+ }),
404
+ };
405
+ case 'supplied-id':
406
+ return {
407
+ suppliedId: item.value,
408
+ };
409
+ default:
410
+ return {};
411
+ }
412
+ }
413
+ function buildFlyToOperation(frameCorrelationId, options, animation) {
414
+ const payload = {
415
+ frameCorrelationId: {
416
+ value: frameCorrelationId,
417
+ },
418
+ animation: animation
419
+ ? {
420
+ duration: toProtoDuration(animation.milliseconds),
421
+ }
422
+ : undefined,
423
+ };
424
+ switch (options.flyTo.type) {
425
+ case 'supplied': {
426
+ return Object.assign(Object.assign({}, payload), { itemSuppliedId: options.flyTo.data });
427
+ }
428
+ case 'internal': {
429
+ return Object.assign(Object.assign({}, payload), { itemId: new vertexvis.protobuf.core.Uuid({
430
+ hex: options.flyTo.data,
431
+ }) });
432
+ }
433
+ case 'camera': {
434
+ return Object.assign(Object.assign({}, payload), { camera: toProtobuf(options.flyTo.data) });
435
+ }
436
+ case 'bounding-box': {
437
+ return Object.assign(Object.assign({}, payload), { boundingBox: {
438
+ xmin: options.flyTo.data.min.x,
439
+ xmax: options.flyTo.data.max.x,
440
+ ymin: options.flyTo.data.min.y,
441
+ ymax: options.flyTo.data.max.y,
442
+ zmin: options.flyTo.data.min.z,
443
+ zmax: options.flyTo.data.max.z,
444
+ } });
445
+ }
446
+ default:
447
+ return {};
448
+ }
449
+ }
450
+ function buildOperationTypes(operations) {
451
+ return operations.map((op) => {
452
+ var _a, _b;
453
+ switch (op.type) {
454
+ case 'change-material':
455
+ return {
456
+ changeMaterial: {
457
+ material: {
458
+ d: op.material.opacity,
459
+ ns: op.material.glossiness,
460
+ ka: op.material.ambient,
461
+ kd: op.material.diffuse,
462
+ ks: op.material.specular,
463
+ ke: op.material.emissive,
464
+ },
465
+ },
466
+ };
467
+ case 'clear-override':
468
+ return {
469
+ changeMaterial: {},
470
+ };
471
+ case 'change-transform':
472
+ return {
473
+ changeTransform: {
474
+ transform: Object.assign({}, op.transform),
475
+ },
476
+ };
477
+ case 'clear-transform':
478
+ return {
479
+ clearTransform: {
480
+ cascade: op.cascade,
481
+ },
482
+ };
483
+ case 'hide':
484
+ return {
485
+ changeVisibility: {
486
+ visible: false,
487
+ },
488
+ };
489
+ case 'show':
490
+ return {
491
+ changeVisibility: {
492
+ visible: true,
493
+ },
494
+ };
495
+ case 'select':
496
+ return {
497
+ changeSelection: { selected: true },
498
+ };
499
+ case 'deselect':
500
+ return {
501
+ changeSelection: { selected: false },
502
+ };
503
+ case 'change-phantom':
504
+ return {
505
+ changePhantom: { phantom: (_a = op.phantomState) !== null && _a !== void 0 ? _a : true },
506
+ };
507
+ case 'clear-phantom':
508
+ return {
509
+ changePhantom: { phantom: false },
510
+ };
511
+ case 'change-end-item':
512
+ return {
513
+ changeEndItem: { endItem: (_b = op.endItemState) !== null && _b !== void 0 ? _b : true },
514
+ };
515
+ case 'clear-end-item':
516
+ return {
517
+ changeEndItem: { endItem: false },
518
+ };
519
+ default:
520
+ return {};
521
+ }
522
+ });
523
+ }
524
+ function toPbSceneViewStateFeatures(features) {
525
+ return features.map((feature) => {
526
+ switch (feature) {
527
+ case 'camera':
528
+ return vertexvis.protobuf.stream.SceneViewStateFeature
529
+ .SCENE_VIEW_STATE_FEATURE_CAMERA;
530
+ case 'material_overrides':
531
+ return vertexvis.protobuf.stream.SceneViewStateFeature
532
+ .SCENE_VIEW_STATE_FEATURE_MATERIAL_OVERRIDE;
533
+ case 'selection':
534
+ return vertexvis.protobuf.stream.SceneViewStateFeature
535
+ .SCENE_VIEW_STATE_FEATURE_SELECTION;
536
+ case 'visibility':
537
+ return vertexvis.protobuf.stream.SceneViewStateFeature
538
+ .SCENE_VIEW_STATE_FEATURE_VISIBILITY;
539
+ case 'transforms':
540
+ return vertexvis.protobuf.stream.SceneViewStateFeature
541
+ .SCENE_VIEW_STATE_FEATURE_TRANSFORM;
542
+ case 'cross_section':
543
+ return vertexvis.protobuf.stream.SceneViewStateFeature
544
+ .SCENE_VIEW_STATE_FEATURE_CROSS_SECTION;
545
+ default:
546
+ return vertexvis.protobuf.stream.SceneViewStateFeature
547
+ .SCENE_VIEW_STATE_FEATURE_INVALID;
548
+ }
549
+ });
550
+ }
551
+
552
+ const PI_OVER_360 = 0.008726646259972;
553
+ class TerminalFlyToExecutor {
554
+ constructor(flyToOptions) {
555
+ this.flyToOptions = flyToOptions;
556
+ }
557
+ build() {
558
+ return this.flyToOptions;
559
+ }
560
+ }
561
+ class FlyToExecutor {
562
+ withItemId(id) {
563
+ return new TerminalFlyToExecutor({
564
+ flyTo: {
565
+ type: 'internal',
566
+ data: id,
567
+ },
568
+ });
569
+ }
570
+ withSuppliedId(id) {
571
+ return new TerminalFlyToExecutor({
572
+ flyTo: {
573
+ type: 'supplied',
574
+ data: id,
575
+ },
576
+ });
577
+ }
578
+ withCamera(camera) {
579
+ return new TerminalFlyToExecutor({
580
+ flyTo: {
581
+ type: 'camera',
582
+ data: camera,
583
+ },
584
+ });
585
+ }
586
+ withBoundingBox(boundingBox) {
587
+ return new TerminalFlyToExecutor({
588
+ flyTo: {
589
+ type: 'bounding-box',
590
+ data: boundingBox,
591
+ },
592
+ });
593
+ }
594
+ build() {
595
+ return this.flyToOptions;
596
+ }
597
+ }
598
+ /**
599
+ * The `Camera` class contains properties that reflect a world space position, a
600
+ * view direction (lookAt), and normalized vector representing the up direction.
601
+ *
602
+ * It also provides utility methods to update orientation of the camera and
603
+ * rerender the scene.
604
+ *
605
+ * This class in intended to treated as an immutable type. Any mutations return
606
+ * a new instance of the class with the updated properties.
607
+ */
608
+ class Camera {
609
+ constructor(stream, aspect, data, boundingBox, decodeFrame, flyToOptions) {
610
+ this.stream = stream;
611
+ this.aspect = aspect;
612
+ this.data = data;
613
+ this.boundingBox = boundingBox;
614
+ this.decodeFrame = decodeFrame;
615
+ this.flyToOptions = flyToOptions;
616
+ }
617
+ fitCameraToBoundingBox(boundingBox$1, distance, viewVector) {
618
+ const vvec = vector3.scale(distance, vector3.normalize(viewVector));
619
+ const lookAt = boundingBox.center(boundingBox$1);
620
+ const position = vector3.subtract(lookAt, vvec);
621
+ return this.update({ lookAt, position, viewVector: vvec });
622
+ }
623
+ /**
624
+ * Returns the distance from the camera's position to the center
625
+ * of the provided bounding box (or the scene's visible bounding box if not provided).
626
+ *
627
+ * @param boundingBox - The bounding box to determine distance from.
628
+ */
629
+ signedDistanceToBoundingBoxCenter(boundingBox$1) {
630
+ const { position, viewVector } = withPositionAndViewVector(this.data);
631
+ const boundingBoxCenter = boundingBox.center(boundingBox$1 !== null && boundingBox$1 !== void 0 ? boundingBox$1 : this.boundingBox);
632
+ const cameraToCenter = vector3.subtract(boundingBoxCenter, position);
633
+ return (vector3.dot(viewVector, cameraToCenter) / vector3.magnitude(viewVector));
634
+ }
635
+ /**
636
+ * Specifies that the next render of the camera will be repositioned to one of
637
+ * the options specified in `options`.
638
+ *
639
+ * @param paramsOrQuery An object or query describing how the camera should
640
+ * be positioned.
641
+ */
642
+ flyTo(paramsOrQuery) {
643
+ if (typeof paramsOrQuery !== 'function') {
644
+ return this.updateFlyToOptions({
645
+ flyTo: this.buildFlyToType(paramsOrQuery),
646
+ });
647
+ }
648
+ else {
649
+ return this.updateFlyToOptions(paramsOrQuery(new FlyToExecutor()).build());
650
+ }
651
+ }
652
+ viewAll() {
653
+ return this.fitToBoundingBox(this.boundingBox);
654
+ }
655
+ /**
656
+ * Queues the rendering for a new frame using this camera. The returned
657
+ * promise will resolve when a frame is received that contains this camera.
658
+ */
659
+ async render(renderOptions) {
660
+ var _a, _b, _c;
661
+ if (this.flyToOptions == null && renderOptions != null) {
662
+ this.flyToOptions = {
663
+ flyTo: {
664
+ type: 'camera',
665
+ data: this.data,
666
+ },
667
+ };
668
+ }
669
+ try {
670
+ const corrId = uuid.create();
671
+ if (this.flyToOptions != null) {
672
+ const payload = buildFlyToOperation(corrId, this.flyToOptions, renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.animation);
673
+ const flyToResponse = await this.stream.flyTo(payload, true);
674
+ return new CameraRenderResult(this.stream, this.decodeFrame, {
675
+ correlationId: corrId,
676
+ animationId: ((_b = (_a = flyToResponse.flyTo) === null || _a === void 0 ? void 0 : _a.animationId) === null || _b === void 0 ? void 0 : _b.hex) || undefined,
677
+ }, ((_c = renderOptions === null || renderOptions === void 0 ? void 0 : renderOptions.animation) === null || _c === void 0 ? void 0 : _c.milliseconds) != null
678
+ ? renderOptions.animation.milliseconds + DEFAULT_TIMEOUT_IN_MS
679
+ : undefined);
680
+ }
681
+ else {
682
+ this.stream.replaceCamera({
683
+ camera: toProtobuf(this.data),
684
+ frameCorrelationId: { value: corrId },
685
+ });
686
+ return new CameraRenderResult(this.stream, this.decodeFrame, {
687
+ correlationId: corrId,
688
+ });
689
+ }
690
+ }
691
+ catch (e) {
692
+ console.warn('Error when performing render: ', e);
693
+ throw e;
694
+ }
695
+ }
696
+ /**
697
+ * Repositions the camera by rotating its current position around an axis.
698
+ *
699
+ * @param angleInRadians The angle, in radians, to rotate.
700
+ * @param axis A normalized vector to rotate around.
701
+ */
702
+ rotateAroundAxis(angleInRadians, axis) {
703
+ return this.rotateAroundAxisAtPoint(angleInRadians, this.data.lookAt, axis);
704
+ }
705
+ /**
706
+ * Aligns the camera to the plane defined by the provided position and normal.
707
+ * This will place the camera at the provided position, set the up vector to
708
+ * the provided normal, and place the lookAt on the defined plane. The point
709
+ * chosen for the lookAt will be determined using the current view vector.
710
+ *
711
+ * @param position The position to place the camera at.
712
+ * @param normal The normal of the plane to align to.
713
+ */
714
+ alignTo(position, normal) {
715
+ const worldX = vector3.normalize(vector3.cross(this.up, vector3.normalize(this.viewVector)));
716
+ const positiveWorldY = vector3.normalize(vector3.cross(vector3.normalize(this.viewVector), worldX));
717
+ // Invert the world y axis if the provided normal is more than 90 degrees from it
718
+ // to compute a proper angle to rotate the view vector by
719
+ const worldY = vector3.angleTo(normal, positiveWorldY) > Math.PI / 2
720
+ ? vector3.negate(positiveWorldY)
721
+ : positiveWorldY;
722
+ const localX = vector3.isEqual(worldY, normal)
723
+ ? worldX
724
+ : vector3.normalize(vector3.cross(worldY, normal));
725
+ const transformedViewVector = vector3.transformMatrix(this.viewVector, matrix4.makeRotation(quaternion.fromAxisAngle(localX, vector3.angleTo(normal, worldY))));
726
+ const lookAtRay = ray.create({
727
+ origin: position,
728
+ direction: vector3.normalize(transformedViewVector),
729
+ });
730
+ const lookAt = ray.at(lookAtRay, vector3.magnitude(this.viewVector));
731
+ return this.update({
732
+ position,
733
+ lookAt,
734
+ up: normal,
735
+ });
736
+ }
737
+ /**
738
+ * Updates the `position` and `up` vectors of the camera to the given standard
739
+ * view.
740
+ *
741
+ * @param standardView The standard view to apply.
742
+ * @returns A new camera.
743
+ */
744
+ standardView(standardView) {
745
+ return this.update({
746
+ position: standardView.position,
747
+ viewVector: vector3.subtract(vector3.origin(), standardView.position),
748
+ lookAt: vector3.origin(),
749
+ up: standardView.up,
750
+ });
751
+ }
752
+ buildFlyToType(options) {
753
+ if (options.boundingBox != null) {
754
+ return { type: 'bounding-box', data: options.boundingBox };
755
+ }
756
+ else if (options.camera != null) {
757
+ return { type: 'camera', data: options.camera };
758
+ }
759
+ else if (options.itemId != null) {
760
+ return { type: 'internal', data: options.itemId };
761
+ }
762
+ else if (options.itemSuppliedId != null) {
763
+ return { type: 'supplied', data: options.itemSuppliedId };
764
+ }
765
+ else {
766
+ throw new Error('Fly to must specify at least one option.');
767
+ }
768
+ }
769
+ computeClippingPlanes(camera) {
770
+ return fromBoundingBoxAndLookAtCamera(this.boundingBox, camera);
771
+ }
772
+ }
773
+ class PerspectiveCamera extends Camera {
774
+ constructor(stream, aspect, perspectiveData, boundingBox, decodeFrame, flyToOptions) {
775
+ super(stream, aspect, perspectiveData, boundingBox, decodeFrame, flyToOptions);
776
+ this.perspectiveData = perspectiveData;
777
+ }
778
+ /**
779
+ * Shifts the position of the camera by the given delta.
780
+ *
781
+ * @param delta The number of units to shift the camera on the X, Y, and Z
782
+ * axis.
783
+ */
784
+ moveBy(delta) {
785
+ return this.update({
786
+ position: vector3.add(this.position, delta),
787
+ lookAt: vector3.add(this.lookAt, delta),
788
+ });
789
+ }
790
+ rotateAroundAxisAtPoint(angleInRadians, point, axis) {
791
+ return this.update({
792
+ position: vector3.rotateAboutAxis(angleInRadians, this.position, axis, point),
793
+ lookAt: vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point),
794
+ up: vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin()),
795
+ });
796
+ }
797
+ fitToBoundingBox(boundingBox$1) {
798
+ var _a;
799
+ const radius = 1.1 *
800
+ vector3.magnitude(vector3.subtract(boundingBox$1.max, boundingBox.center(boundingBox$1)));
801
+ // ratio of the height of the frustum to the distance along the view vector
802
+ let hOverD = Math.tan(((_a = this.fovY) !== null && _a !== void 0 ? _a : 45) * PI_OVER_360);
803
+ if (this.aspect < 1.0) {
804
+ hOverD *= this.aspect;
805
+ }
806
+ const distance = Math.abs(radius / hOverD);
807
+ return super.fitCameraToBoundingBox(boundingBox$1, distance, this.viewVector);
808
+ }
809
+ update(camera) {
810
+ var _a;
811
+ const fovY = (_a = camera.fovY) !== null && _a !== void 0 ? _a : this.fovY;
812
+ return new PerspectiveCamera(this.stream, this.aspect, Object.assign(Object.assign(Object.assign({}, this.perspectiveData), camera), { fovY }), this.boundingBox, this.decodeFrame, this.flyToOptions);
813
+ }
814
+ toFrameCamera() {
815
+ var _a;
816
+ return new FramePerspectiveCamera(this.position, this.lookAt, this.up, this.near, this.far, this.aspectRatio, (_a = this.fovY) !== null && _a !== void 0 ? _a : 45);
817
+ }
818
+ get viewVector() {
819
+ return vector3.subtract(this.lookAt, this.position);
820
+ }
821
+ /**
822
+ * The position vector for the camera, in world space coordinates.
823
+ */
824
+ get position() {
825
+ return Object.assign({}, this.perspectiveData.position);
826
+ }
827
+ /**
828
+ * A normalized vector representing the up direction.
829
+ */
830
+ get up() {
831
+ return Object.assign({}, this.perspectiveData.up);
832
+ }
833
+ /**
834
+ * A vector, in world space coordinates, of where the camera is pointed at.
835
+ */
836
+ get lookAt() {
837
+ return Object.assign({}, this.perspectiveData.lookAt);
838
+ }
839
+ /**
840
+ * The camera's field of view.
841
+ */
842
+ get fovY() {
843
+ return this.perspectiveData.fovY;
844
+ }
845
+ /**
846
+ * The aspect ratio of the camera.
847
+ */
848
+ get aspectRatio() {
849
+ return this.aspect;
850
+ }
851
+ /**
852
+ * The camera's near clipping plane.
853
+ */
854
+ get near() {
855
+ const { near } = this.computeClippingPlanes(this.perspectiveData);
856
+ return near;
857
+ }
858
+ /**
859
+ * The camera's far clipping plane.
860
+ */
861
+ get far() {
862
+ const { far } = this.computeClippingPlanes(this.perspectiveData);
863
+ return far;
864
+ }
865
+ updateFlyToOptions(flyToOptions) {
866
+ return new PerspectiveCamera(this.stream, this.aspect, this.perspectiveData, this.boundingBox, this.decodeFrame, flyToOptions);
867
+ }
868
+ }
869
+ class OrthographicCamera extends Camera {
870
+ constructor(stream, aspect, orthographicData, boundingBox, decodeFrame, flyToOptions) {
871
+ super(stream, aspect, orthographicData, boundingBox, decodeFrame, flyToOptions);
872
+ this.orthographicData = orthographicData;
873
+ }
874
+ /**
875
+ * Shifts the position of the camera by the given delta.
876
+ *
877
+ * @param delta The number of units to shift the camera on the X, Y, and Z
878
+ * axis.
879
+ */
880
+ moveBy(delta) {
881
+ return this.update({
882
+ lookAt: vector3.add(this.lookAt, delta),
883
+ });
884
+ }
885
+ rotateAroundAxisAtPoint(angleInRadians, point, axis) {
886
+ const updatedLookAt = vector3.rotateAboutAxis(angleInRadians, this.lookAt, axis, point);
887
+ const updatedPosition = vector3.rotateAboutAxis(angleInRadians, this.position, axis, point);
888
+ const viewVector = constrainViewVector(vector3.subtract(updatedLookAt, updatedPosition), boundingSphere.create(this.boundingBox));
889
+ return this.update({
890
+ viewVector: viewVector,
891
+ lookAt: updatedLookAt,
892
+ up: vector3.rotateAboutAxis(angleInRadians, this.up, axis, vector3.origin()),
893
+ });
894
+ }
895
+ fitToBoundingBox(boundingBox) {
896
+ const boundingSphere$1 = boundingSphere.create(boundingBox);
897
+ const fitAll = super.fitCameraToBoundingBox(boundingBox, boundingSphere$1.radius, this.viewVector);
898
+ return this.update({
899
+ lookAt: fitAll.lookAt,
900
+ viewVector: fitAll.viewVector,
901
+ fovHeight: boundingSphere$1.radius * 2,
902
+ });
903
+ }
904
+ update(camera) {
905
+ return new OrthographicCamera(this.stream, this.aspect, Object.assign(Object.assign({}, this.orthographicData), camera), this.boundingBox, this.decodeFrame, this.flyToOptions);
906
+ }
907
+ toFrameCamera() {
908
+ return new FrameOrthographicCamera(constrainViewVector(this.viewVector, boundingSphere.create(this.boundingBox)), this.lookAt, this.up, this.near, this.far, this.aspectRatio, this.fovHeight);
909
+ }
910
+ get viewVector() {
911
+ return Object.assign({}, this.orthographicData.viewVector);
912
+ }
913
+ get position() {
914
+ return vector3.add(this.lookAt, vector3.negate(this.viewVector));
915
+ }
916
+ /**
917
+ * A normalized vector representing the up direction.
918
+ */
919
+ get up() {
920
+ return Object.assign({}, this.orthographicData.up);
921
+ }
922
+ /**
923
+ * A vector, in world space coordinates, of where the camera is pointed at.
924
+ */
925
+ get lookAt() {
926
+ return Object.assign({}, this.orthographicData.lookAt);
927
+ }
928
+ /**
929
+ * The camera's field of view.
930
+ */
931
+ get fovHeight() {
932
+ return this.orthographicData.fovHeight;
933
+ }
934
+ /**
935
+ * The aspect ratio of the camera.
936
+ */
937
+ get aspectRatio() {
938
+ return this.aspect;
939
+ }
940
+ /**
941
+ * The camera's near clipping plane.
942
+ */
943
+ get near() {
944
+ const { near } = this.computeClippingPlanes(this.orthographicData);
945
+ return near;
946
+ }
947
+ /**
948
+ * The camera's far clipping plane.
949
+ */
950
+ get far() {
951
+ const { far } = this.computeClippingPlanes(this.orthographicData);
952
+ return far;
953
+ }
954
+ updateFlyToOptions(flyToOptions) {
955
+ return new OrthographicCamera(this.stream, this.aspect, this.orthographicData, this.boundingBox, this.decodeFrame, flyToOptions);
956
+ }
957
+ }
958
+
959
+ /**
960
+ * The `Raycaster` class is here.
961
+ */
962
+ class Raycaster {
963
+ constructor(stream, imageScaleProvider) {
964
+ this.stream = stream;
965
+ this.imageScaleProvider = imageScaleProvider;
966
+ }
967
+ /**
968
+ * Performs request on the stream to find items that intersect
969
+ * the given point.
970
+ *
971
+ * @param point The point to cast from looking for intersections.
972
+ */
973
+ async hitItems(point$1, options) {
974
+ const scale = this.imageScaleProvider();
975
+ const res = await this.stream.hitItems({
976
+ point: point.scale(point$1, (scale === null || scale === void 0 ? void 0 : scale.x) || 1, (scale === null || scale === void 0 ? void 0 : scale.y) || 1),
977
+ includeMetadata: options === null || options === void 0 ? void 0 : options.includeMetadata,
978
+ }, true);
979
+ return res.hitItems || undefined;
980
+ }
981
+ }
982
+
983
+ /**
984
+ * The `CrossSectioner` class is here.
985
+ */
986
+ class CrossSectioner {
987
+ constructor(stream, data) {
988
+ this.stream = stream;
989
+ this.data = data;
990
+ }
991
+ /**
992
+ * Performs request on the stream to update the cross sectioning config.
993
+ *
994
+ * @param crossSectioning The new cross sectioning.
995
+ */
996
+ async update(crossSectioning) {
997
+ const res = await this.stream.updateCrossSectioning({
998
+ crossSectioning: {
999
+ sectionPlanes: crossSectioning.sectionPlanes,
1000
+ highlightColor: crossSectioning.highlightColor,
1001
+ lineWidth: (crossSectioning === null || crossSectioning === void 0 ? void 0 : crossSectioning.lineWidth) != null
1002
+ ? { value: crossSectioning.lineWidth }
1003
+ : null,
1004
+ },
1005
+ }, true);
1006
+ return res.updateCrossSectioning || undefined;
1007
+ }
1008
+ current() {
1009
+ return this.data;
1010
+ }
1011
+ }
1012
+
1013
+ /**
1014
+ * A class to handle the building of operations for a scene.
1015
+ */
1016
+ class SceneOperationBuilder {
1017
+ constructor(operations = []) {
1018
+ this.operations = operations;
1019
+ }
1020
+ /**
1021
+ * Constructs the scene operations and returns a definition describing each
1022
+ * operation.
1023
+ */
1024
+ build() {
1025
+ return this.operations.concat();
1026
+ }
1027
+ materialOverride(material) {
1028
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'change-material', material }]));
1029
+ }
1030
+ show() {
1031
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'show' }]));
1032
+ }
1033
+ hide() {
1034
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'hide' }]));
1035
+ }
1036
+ select() {
1037
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'select' }]));
1038
+ }
1039
+ deselect() {
1040
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'deselect' }]));
1041
+ }
1042
+ clearMaterialOverrides() {
1043
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'clear-override' }]));
1044
+ }
1045
+ transform(matrix) {
1046
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'change-transform', transform: matrix }]));
1047
+ }
1048
+ clearTransforms(cascade = true) {
1049
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'clear-transform', cascade }]));
1050
+ }
1051
+ setPhantom(phantomState) {
1052
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'change-phantom', phantomState }]));
1053
+ }
1054
+ clearPhantom() {
1055
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'clear-phantom' }]));
1056
+ }
1057
+ setEndItem(endItemState) {
1058
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'change-end-item', endItemState }]));
1059
+ }
1060
+ clearEndItem() {
1061
+ return new SceneOperationBuilder(this.operations.concat([{ type: 'clear-end-item' }]));
1062
+ }
1063
+ }
1064
+
1065
+ /**
1066
+ * An interface that represents a query is "complete" and can be turned into an
1067
+ * expression.
1068
+ */
1069
+ class TerminalQuery {
1070
+ constructor(inverted) {
1071
+ this.inverted = inverted;
1072
+ }
1073
+ build() {
1074
+ if (this.inverted) {
1075
+ return {
1076
+ type: 'not',
1077
+ query: this.queryExpressionBuilder(),
1078
+ };
1079
+ }
1080
+ else {
1081
+ return this.queryExpressionBuilder();
1082
+ }
1083
+ }
1084
+ }
1085
+ class RootQuery {
1086
+ constructor(inverted = false) {
1087
+ this.inverted = inverted;
1088
+ }
1089
+ all() {
1090
+ return new AllQuery();
1091
+ }
1092
+ not() {
1093
+ return new NotQuery(!this.inverted);
1094
+ }
1095
+ withItemIds(ids) {
1096
+ return new BulkQuery(ids, 'item-id', this.inverted);
1097
+ }
1098
+ withSuppliedIds(ids) {
1099
+ return new BulkQuery(ids, 'supplied-id', this.inverted);
1100
+ }
1101
+ withItemId(id) {
1102
+ return new SingleQuery({ type: 'item-id', value: id }, this.inverted);
1103
+ }
1104
+ withSuppliedId(id) {
1105
+ return new SingleQuery({ type: 'supplied-id', value: id }, this.inverted);
1106
+ }
1107
+ withSceneTreeRange(range) {
1108
+ return new SceneTreeRangeQuery(range, this.inverted);
1109
+ }
1110
+ withMetadata(filter, keys, exactMatch) {
1111
+ return new MetadataQuery(filter, keys, exactMatch, this.inverted);
1112
+ }
1113
+ withSelected() {
1114
+ return new AllSelectedQuery(this.inverted);
1115
+ }
1116
+ withPoint(point) {
1117
+ return new PointQuery(point, this.inverted);
1118
+ }
1119
+ withVolumeIntersection(rectangle, exclusive) {
1120
+ return new VolumeIntersectionQuery(rectangle, this.inverted, exclusive);
1121
+ }
1122
+ }
1123
+ class NotQuery extends RootQuery {
1124
+ constructor(inverted) {
1125
+ super(inverted);
1126
+ }
1127
+ }
1128
+ class AllQuery extends TerminalQuery {
1129
+ constructor(inverted = false) {
1130
+ super(inverted);
1131
+ }
1132
+ queryExpressionBuilder() {
1133
+ return { type: 'all' };
1134
+ }
1135
+ }
1136
+ class SceneTreeRangeQuery extends TerminalQuery {
1137
+ constructor(range, inverted) {
1138
+ super(inverted);
1139
+ this.range = range;
1140
+ }
1141
+ queryExpressionBuilder() {
1142
+ return {
1143
+ type: 'scene-tree-range',
1144
+ range: this.range,
1145
+ };
1146
+ }
1147
+ }
1148
+ class MetadataQuery extends TerminalQuery {
1149
+ constructor(filter, keys, exactMatch, inverted) {
1150
+ super(inverted);
1151
+ this.filter = filter;
1152
+ this.keys = keys;
1153
+ this.exactMatch = exactMatch;
1154
+ }
1155
+ queryExpressionBuilder() {
1156
+ return {
1157
+ type: 'metadata',
1158
+ filter: this.filter,
1159
+ keys: this.keys,
1160
+ exactMatch: this.exactMatch,
1161
+ };
1162
+ }
1163
+ }
1164
+ class AllSelectedQuery extends TerminalQuery {
1165
+ constructor(inverted) {
1166
+ super(inverted);
1167
+ }
1168
+ queryExpressionBuilder() {
1169
+ return {
1170
+ type: 'all-selected',
1171
+ };
1172
+ }
1173
+ }
1174
+ class PointQuery extends TerminalQuery {
1175
+ constructor(point, inverted) {
1176
+ super(inverted);
1177
+ this.point = point;
1178
+ }
1179
+ queryExpressionBuilder() {
1180
+ return {
1181
+ type: 'point',
1182
+ point: this.point,
1183
+ };
1184
+ }
1185
+ }
1186
+ class VolumeIntersectionQuery extends TerminalQuery {
1187
+ constructor(rectangle, inverted, exclusive) {
1188
+ super(inverted);
1189
+ this.rectangle = rectangle;
1190
+ this.exclusive = exclusive;
1191
+ }
1192
+ queryExpressionBuilder() {
1193
+ return {
1194
+ type: 'volume-intersection',
1195
+ rectangle: this.rectangle,
1196
+ exclusive: !!this.exclusive,
1197
+ };
1198
+ }
1199
+ }
1200
+ class BulkQuery extends TerminalQuery {
1201
+ constructor(ids, type, inverted) {
1202
+ super(inverted);
1203
+ this.ids = ids;
1204
+ this.type = type;
1205
+ }
1206
+ queryExpressionBuilder() {
1207
+ return {
1208
+ type: 'or',
1209
+ expressions: this.ids.map((id) => {
1210
+ return {
1211
+ type: this.type,
1212
+ value: id,
1213
+ };
1214
+ }),
1215
+ };
1216
+ }
1217
+ }
1218
+ class SingleQuery extends TerminalQuery {
1219
+ constructor(query, inverted) {
1220
+ super(inverted);
1221
+ this.query = query;
1222
+ }
1223
+ queryExpressionBuilder() {
1224
+ return Object.assign({}, this.query);
1225
+ }
1226
+ and() {
1227
+ return new AndQuery([this.query], this.inverted);
1228
+ }
1229
+ or() {
1230
+ return new OrQuery([this.query], this.inverted);
1231
+ }
1232
+ }
1233
+ class OrQuery extends TerminalQuery {
1234
+ constructor(expressions, inverted) {
1235
+ super(inverted);
1236
+ this.expressions = expressions;
1237
+ }
1238
+ queryExpressionBuilder() {
1239
+ return { type: 'or', expressions: [...this.expressions] };
1240
+ }
1241
+ withItemId(id) {
1242
+ return new OrQuery([...this.expressions, { type: 'item-id', value: id }], this.inverted);
1243
+ }
1244
+ withSuppliedId(id) {
1245
+ return new OrQuery([...this.expressions, { type: 'supplied-id', value: id }], this.inverted);
1246
+ }
1247
+ or() {
1248
+ return this;
1249
+ }
1250
+ }
1251
+ class AndQuery extends TerminalQuery {
1252
+ constructor(expressions, inverted) {
1253
+ super(inverted);
1254
+ this.expressions = expressions;
1255
+ }
1256
+ queryExpressionBuilder() {
1257
+ return { type: 'and', expressions: [...this.expressions] };
1258
+ }
1259
+ withItemId(id) {
1260
+ return new AndQuery([...this.expressions, { type: 'item-id', value: id }], this.inverted);
1261
+ }
1262
+ withSuppliedId(id) {
1263
+ return new AndQuery([...this.expressions, { type: 'supplied-id', value: id }], this.inverted);
1264
+ }
1265
+ and() {
1266
+ return this;
1267
+ }
1268
+ }
1269
+ class SceneItemQueryExecutor {
1270
+ where(query) {
1271
+ const expression = query(new RootQuery()).build();
1272
+ return new SceneItemOperationsBuilder(expression);
1273
+ }
1274
+ }
1275
+
1276
+ /**
1277
+ * A class that is responsible for building operations for a specific scene.
1278
+ * This executor requires a query, and expects `execute()` to be invoked in order
1279
+ * for the changes to take effect.
1280
+ */
1281
+ class SceneItemOperationsBuilder {
1282
+ constructor(query, givenBuilder) {
1283
+ this.query = query;
1284
+ this.builder =
1285
+ givenBuilder != null ? givenBuilder : new SceneOperationBuilder();
1286
+ }
1287
+ materialOverride(color) {
1288
+ if (typeof color === 'string') {
1289
+ return new SceneItemOperationsBuilder(this.query, this.builder.materialOverride(fromHex(color)));
1290
+ }
1291
+ else {
1292
+ return new SceneItemOperationsBuilder(this.query, this.builder.materialOverride(color));
1293
+ }
1294
+ }
1295
+ hide() {
1296
+ return new SceneItemOperationsBuilder(this.query, this.builder.hide());
1297
+ }
1298
+ show() {
1299
+ return new SceneItemOperationsBuilder(this.query, this.builder.show());
1300
+ }
1301
+ select() {
1302
+ return new SceneItemOperationsBuilder(this.query, this.builder.select());
1303
+ }
1304
+ deselect() {
1305
+ return new SceneItemOperationsBuilder(this.query, this.builder.deselect());
1306
+ }
1307
+ clearMaterialOverrides() {
1308
+ return new SceneItemOperationsBuilder(this.query, this.builder.clearMaterialOverrides());
1309
+ }
1310
+ transform(matrix) {
1311
+ if (Array.isArray(matrix)) {
1312
+ if (matrix.length !== 16) {
1313
+ throw new InvalidArgumentError('Matrix provided must contain exactly 16 values (4x4).');
1314
+ }
1315
+ return new SceneItemOperationsBuilder(this.query, this.builder.transform({
1316
+ r0: {
1317
+ x: matrix[0],
1318
+ y: matrix[1],
1319
+ z: matrix[2],
1320
+ w: matrix[3],
1321
+ },
1322
+ r1: {
1323
+ x: matrix[4],
1324
+ y: matrix[5],
1325
+ z: matrix[6],
1326
+ w: matrix[7],
1327
+ },
1328
+ r2: {
1329
+ x: matrix[8],
1330
+ y: matrix[9],
1331
+ z: matrix[10],
1332
+ w: matrix[11],
1333
+ },
1334
+ r3: {
1335
+ x: matrix[12],
1336
+ y: matrix[13],
1337
+ z: matrix[14],
1338
+ w: matrix[15],
1339
+ },
1340
+ }));
1341
+ }
1342
+ else {
1343
+ return new SceneItemOperationsBuilder(this.query, this.builder.transform(matrix));
1344
+ }
1345
+ }
1346
+ clearTransforms(cascade = true) {
1347
+ return new SceneItemOperationsBuilder(this.query, this.builder.clearTransforms(cascade));
1348
+ }
1349
+ setPhantom(phantomState) {
1350
+ return new SceneItemOperationsBuilder(this.query, this.builder.setPhantom(phantomState));
1351
+ }
1352
+ clearPhantom() {
1353
+ return new SceneItemOperationsBuilder(this.query, this.builder.clearPhantom());
1354
+ }
1355
+ setEndItem(endItemState) {
1356
+ return new SceneItemOperationsBuilder(this.query, this.builder.setEndItem(endItemState));
1357
+ }
1358
+ clearEndItem() {
1359
+ return new SceneItemOperationsBuilder(this.query, this.builder.clearEndItem());
1360
+ }
1361
+ build() {
1362
+ return {
1363
+ query: this.query,
1364
+ operations: this.builder.build(),
1365
+ };
1366
+ }
1367
+ }
1368
+ class ItemsOperationExecutor {
1369
+ constructor(sceneViewId, stream, dimensions, queryOperations) {
1370
+ this.sceneViewId = sceneViewId;
1371
+ this.stream = stream;
1372
+ this.dimensions = dimensions;
1373
+ this.queryOperations = queryOperations;
1374
+ }
1375
+ async execute(executionOptions) {
1376
+ const pbOperations = this.queryOperations.map((op) => buildSceneOperation(op.query, op.operations, {
1377
+ dimensions: this.dimensions,
1378
+ }));
1379
+ const request = {
1380
+ sceneViewId: {
1381
+ hex: this.sceneViewId,
1382
+ },
1383
+ operations: pbOperations,
1384
+ suppliedCorrelationId: (executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.suppliedCorrelationId) != null
1385
+ ? {
1386
+ value: executionOptions === null || executionOptions === void 0 ? void 0 : executionOptions.suppliedCorrelationId,
1387
+ }
1388
+ : undefined,
1389
+ };
1390
+ await this.stream.createSceneAlteration(request);
1391
+ }
1392
+ }
1393
+ /**
1394
+ * A class that represents the `Scene` that has been loaded into the viewer. On
1395
+ * it, you can retrieve attributes of the scene, such as the camera. It also
1396
+ * contains methods for updating the scene and performing requests to rerender
1397
+ * the scene.
1398
+ */
1399
+ class Scene {
1400
+ constructor(stream, frame, decodeFrame, imageScaleProvider, dimensions, sceneId, sceneViewId) {
1401
+ this.stream = stream;
1402
+ this.frame = frame;
1403
+ this.decodeFrame = decodeFrame;
1404
+ this.imageScaleProvider = imageScaleProvider;
1405
+ this.dimensions = dimensions;
1406
+ this.sceneId = sceneId;
1407
+ this.sceneViewId = sceneViewId;
1408
+ }
1409
+ /**
1410
+ * Applies the provided scene view state to the scene.
1411
+ */
1412
+ async applySceneViewState(sceneViewStateId, opts = {}) {
1413
+ const pbIdField = buildSceneViewStateIdentifier(sceneViewStateId);
1414
+ return await this.stream.loadSceneViewState(Object.assign(Object.assign({}, pbIdField), { frameCorrelationId: opts.suppliedCorrelationId
1415
+ ? { value: opts.suppliedCorrelationId }
1416
+ : undefined }), true);
1417
+ }
1418
+ /**
1419
+ * Applies the specified features of the provided scene view state to the scene.
1420
+ */
1421
+ async applyPartialSceneViewState(sceneViewStateId, featuresToApply, opts = {}) {
1422
+ const pbIdField = buildSceneViewStateIdentifier(sceneViewStateId);
1423
+ const pbFeatures = toPbSceneViewStateFeatures(featuresToApply);
1424
+ return await this.stream.loadSceneViewState(Object.assign(Object.assign({}, pbIdField), { frameCorrelationId: opts.suppliedCorrelationId
1425
+ ? { value: opts.suppliedCorrelationId }
1426
+ : undefined, sceneViewStateFeatureSubset: pbFeatures }), true);
1427
+ }
1428
+ /**
1429
+ * Resets the view to its default state, with the ability to reset the camera to that of the base scene.
1430
+ */
1431
+ async reset(opts = {}) {
1432
+ return await this.stream.resetSceneView({
1433
+ includeCamera: opts.includeCamera,
1434
+ frameCorrelationId: opts.suppliedCorrelationId
1435
+ ? { value: opts.suppliedCorrelationId }
1436
+ : undefined,
1437
+ }, true);
1438
+ }
1439
+ /**
1440
+ * Returns an executor that accepts a function as a parameter that contains one or many operations to apply
1441
+ * to the scene view. The operations will be applied transactionally.
1442
+ * @param operations
1443
+ */
1444
+ items(operations) {
1445
+ const sceneOperations = operations(new SceneItemQueryExecutor());
1446
+ const ops = Array.isArray(sceneOperations)
1447
+ ? sceneOperations
1448
+ : [sceneOperations];
1449
+ const operationList = ops.reduce((acc, builder) => acc.concat(builder.build()), []);
1450
+ return new ItemsOperationExecutor(this.sceneViewId, this.stream, this.dimensions, operationList);
1451
+ }
1452
+ /**
1453
+ * An instance of the current camera of the scene.
1454
+ */
1455
+ camera() {
1456
+ const { scene } = this.frame;
1457
+ if (scene.camera.isOrthographic()) {
1458
+ return new OrthographicCamera(this.stream, dimensions.aspectRatio(this.viewport()), {
1459
+ viewVector: scene.camera.viewVector,
1460
+ lookAt: scene.camera.lookAt,
1461
+ up: scene.camera.up,
1462
+ fovHeight: scene.camera.fovHeight,
1463
+ }, this.frame.scene.boundingBox, this.decodeFrame);
1464
+ }
1465
+ else if (scene.camera.isPerspective()) {
1466
+ return new PerspectiveCamera(this.stream, dimensions.aspectRatio(this.viewport()), {
1467
+ position: scene.camera.position,
1468
+ lookAt: scene.camera.lookAt,
1469
+ up: scene.camera.up,
1470
+ fovY: scene.camera.fovY,
1471
+ }, this.frame.scene.boundingBox, this.decodeFrame);
1472
+ }
1473
+ else {
1474
+ throw new InvalidCameraError('Cannot retrieve camera. Scene has an unknown or invalid camera type.');
1475
+ }
1476
+ }
1477
+ boundingBox() {
1478
+ return this.frame.scene.boundingBox;
1479
+ }
1480
+ /**
1481
+ * CrossSectioner to update cross sectioning planes and get current configuration.
1482
+ */
1483
+ crossSectioning() {
1484
+ return new CrossSectioner(this.stream, this.frame.scene.crossSection);
1485
+ }
1486
+ /**
1487
+ * Raycaster to request items that intersect a point.
1488
+ */
1489
+ raycaster() {
1490
+ return new Raycaster(this.stream, this.imageScaleProvider);
1491
+ }
1492
+ /**
1493
+ * The current viewport of the scene, in pixels.
1494
+ */
1495
+ viewport() {
1496
+ return this.frame.dimensions;
1497
+ }
1498
+ /**
1499
+ * The current x and y scale of the rendered image.
1500
+ */
1501
+ scale() {
1502
+ return this.imageScaleProvider() || point.create(1, 1);
1503
+ }
1504
+ }
1505
+
1506
+ export { Scene as S, SynchronizedClock as a, colorMaterial as c, fromUrn as f, loadableResource as l };
1507
+
1508
+ //# sourceMappingURL=scene.js.map