@luma.gl/engine 9.0.0-alpha.16 → 9.0.0-alpha.19

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 (188) hide show
  1. package/dist/animation/key-frames.d.ts +1 -1
  2. package/dist/animation/key-frames.d.ts.map +1 -1
  3. package/dist/animation/key-frames.js +55 -54
  4. package/dist/animation/key-frames.js.map +1 -0
  5. package/dist/animation/timeline.d.ts +4 -4
  6. package/dist/animation/timeline.d.ts.map +1 -1
  7. package/dist/animation/timeline.js +101 -94
  8. package/dist/animation/timeline.js.map +1 -0
  9. package/dist/animation-loop/animation-loop.d.ts +4 -2
  10. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  11. package/dist/animation-loop/animation-loop.js +358 -414
  12. package/dist/animation-loop/animation-loop.js.map +1 -0
  13. package/dist/animation-loop/animation-props.d.ts +3 -1
  14. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  15. package/dist/animation-loop/animation-props.js +1 -0
  16. package/dist/animation-loop/animation-props.js.map +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +1 -1
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  19. package/dist/animation-loop/make-animation-loop.js +25 -26
  20. package/dist/animation-loop/make-animation-loop.js.map +1 -0
  21. package/dist/animation-loop/render-loop.js +5 -17
  22. package/dist/animation-loop/render-loop.js.map +1 -0
  23. package/dist/dist.dev.js +12517 -0
  24. package/dist/geometries/cone-geometry.d.ts +1 -1
  25. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  26. package/dist/geometries/cone-geometry.js +18 -12
  27. package/dist/geometries/cone-geometry.js.map +1 -0
  28. package/dist/geometries/cube-geometry.d.ts +1 -1
  29. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  30. package/dist/geometries/cube-geometry.js +60 -187
  31. package/dist/geometries/cube-geometry.js.map +1 -0
  32. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  33. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  34. package/dist/geometries/cylinder-geometry.js +15 -10
  35. package/dist/geometries/cylinder-geometry.js.map +1 -0
  36. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  37. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  38. package/dist/geometries/ico-sphere-geometry.js +160 -141
  39. package/dist/geometries/ico-sphere-geometry.js.map +1 -0
  40. package/dist/geometries/plane-geometry.d.ts +1 -1
  41. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  42. package/dist/geometries/plane-geometry.js +111 -93
  43. package/dist/geometries/plane-geometry.js.map +1 -0
  44. package/dist/geometries/sphere-geometry.d.ts +1 -1
  45. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  46. package/dist/geometries/sphere-geometry.js +95 -76
  47. package/dist/geometries/sphere-geometry.js.map +1 -0
  48. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  49. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  50. package/dist/geometries/truncated-cone-geometry.js +126 -105
  51. package/dist/geometries/truncated-cone-geometry.js.map +1 -0
  52. package/dist/geometry/geometry-table.d.ts +1 -1
  53. package/dist/geometry/geometry-table.d.ts.map +1 -1
  54. package/dist/geometry/geometry-table.js +1 -0
  55. package/dist/geometry/geometry-table.js.map +1 -0
  56. package/dist/geometry/geometry-utils.js +32 -22
  57. package/dist/geometry/geometry-utils.js.map +1 -0
  58. package/dist/geometry/geometry.d.ts +4 -4
  59. package/dist/geometry/geometry.d.ts.map +1 -1
  60. package/dist/geometry/geometry.js +109 -96
  61. package/dist/geometry/geometry.js.map +1 -0
  62. package/dist/geometry/primitive-utils.js +1 -30
  63. package/dist/geometry/primitive-utils.js.map +1 -0
  64. package/dist/index.cjs +2268 -0
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +17 -20
  68. package/dist/index.js.map +1 -0
  69. package/dist/lib/clip-space.d.ts +8 -0
  70. package/dist/lib/clip-space.d.ts.map +1 -1
  71. package/dist/lib/clip-space.js +32 -45
  72. package/dist/lib/clip-space.js.map +1 -0
  73. package/dist/lib/model-utils.js +28 -101
  74. package/dist/lib/model-utils.js.map +1 -0
  75. package/dist/lib/model.d.ts +1 -1
  76. package/dist/lib/model.d.ts.map +1 -1
  77. package/dist/lib/model.js +129 -121
  78. package/dist/lib/model.js.map +1 -0
  79. package/dist/lib/pipeline-factory.d.ts +3 -3
  80. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  81. package/dist/lib/pipeline-factory.js +165 -136
  82. package/dist/lib/pipeline-factory.js.map +1 -0
  83. package/dist.min.js +295 -0
  84. package/package.json +22 -13
  85. package/src/animation/timeline.ts +1 -1
  86. package/src/animation-loop/animation-loop.ts +5 -5
  87. package/src/animation-loop/make-animation-loop.ts +2 -1
  88. package/src/geometry/geometry.ts +2 -2
  89. package/src/index.ts +1 -1
  90. package/src/lib/clip-space.ts +14 -11
  91. package/src/lib/pipeline-factory.ts +1 -1
  92. package/dist/bundle.d.ts +0 -2
  93. package/dist/bundle.d.ts.map +0 -1
  94. package/dist/bundle.js +0 -5
  95. package/dist/dist.min.js +0 -31
  96. package/dist/es5/animation/key-frames.js +0 -84
  97. package/dist/es5/animation/key-frames.js.map +0 -1
  98. package/dist/es5/animation/timeline.js +0 -183
  99. package/dist/es5/animation/timeline.js.map +0 -1
  100. package/dist/es5/animation-loop/animation-loop.js +0 -534
  101. package/dist/es5/animation-loop/animation-loop.js.map +0 -1
  102. package/dist/es5/animation-loop/animation-props.js +0 -2
  103. package/dist/es5/animation-loop/animation-props.js.map +0 -1
  104. package/dist/es5/animation-loop/make-animation-loop.js +0 -53
  105. package/dist/es5/animation-loop/make-animation-loop.js.map +0 -1
  106. package/dist/es5/animation-loop/render-loop.js +0 -39
  107. package/dist/es5/animation-loop/render-loop.js.map +0 -1
  108. package/dist/es5/bundle.js +0 -6
  109. package/dist/es5/bundle.js.map +0 -1
  110. package/dist/es5/geometries/cone-geometry.js +0 -43
  111. package/dist/es5/geometries/cone-geometry.js.map +0 -1
  112. package/dist/es5/geometries/cube-geometry.js +0 -84
  113. package/dist/es5/geometries/cube-geometry.js.map +0 -1
  114. package/dist/es5/geometries/cylinder-geometry.js +0 -39
  115. package/dist/es5/geometries/cylinder-geometry.js.map +0 -1
  116. package/dist/es5/geometries/ico-sphere-geometry.js +0 -185
  117. package/dist/es5/geometries/ico-sphere-geometry.js.map +0 -1
  118. package/dist/es5/geometries/plane-geometry.js +0 -137
  119. package/dist/es5/geometries/plane-geometry.js.map +0 -1
  120. package/dist/es5/geometries/sphere-geometry.js +0 -120
  121. package/dist/es5/geometries/sphere-geometry.js.map +0 -1
  122. package/dist/es5/geometries/truncated-cone-geometry.js +0 -160
  123. package/dist/es5/geometries/truncated-cone-geometry.js.map +0 -1
  124. package/dist/es5/geometry/geometry-table.js +0 -2
  125. package/dist/es5/geometry/geometry-table.js.map +0 -1
  126. package/dist/es5/geometry/geometry-utils.js +0 -39
  127. package/dist/es5/geometry/geometry-utils.js.map +0 -1
  128. package/dist/es5/geometry/geometry.js +0 -150
  129. package/dist/es5/geometry/geometry.js.map +0 -1
  130. package/dist/es5/geometry/primitive-utils.js +0 -2
  131. package/dist/es5/geometry/primitive-utils.js.map +0 -1
  132. package/dist/es5/index.js +0 -112
  133. package/dist/es5/index.js.map +0 -1
  134. package/dist/es5/lib/clip-space.js +0 -2
  135. package/dist/es5/lib/clip-space.js.map +0 -1
  136. package/dist/es5/lib/model-utils.js +0 -52
  137. package/dist/es5/lib/model-utils.js.map +0 -1
  138. package/dist/es5/lib/model.js +0 -173
  139. package/dist/es5/lib/model.js.map +0 -1
  140. package/dist/es5/lib/pipeline-factory.js +0 -244
  141. package/dist/es5/lib/pipeline-factory.js.map +0 -1
  142. package/dist/esm/animation/key-frames.js +0 -57
  143. package/dist/esm/animation/key-frames.js.map +0 -1
  144. package/dist/esm/animation/timeline.js +0 -113
  145. package/dist/esm/animation/timeline.js.map +0 -1
  146. package/dist/esm/animation-loop/animation-loop.js +0 -367
  147. package/dist/esm/animation-loop/animation-loop.js.map +0 -1
  148. package/dist/esm/animation-loop/animation-props.js +0 -2
  149. package/dist/esm/animation-loop/animation-props.js.map +0 -1
  150. package/dist/esm/animation-loop/make-animation-loop.js +0 -28
  151. package/dist/esm/animation-loop/make-animation-loop.js.map +0 -1
  152. package/dist/esm/animation-loop/render-loop.js +0 -7
  153. package/dist/esm/animation-loop/render-loop.js.map +0 -1
  154. package/dist/esm/bundle.js +0 -4
  155. package/dist/esm/bundle.js.map +0 -1
  156. package/dist/esm/geometries/cone-geometry.js +0 -21
  157. package/dist/esm/geometries/cone-geometry.js.map +0 -1
  158. package/dist/esm/geometries/cube-geometry.js +0 -67
  159. package/dist/esm/geometries/cube-geometry.js.map +0 -1
  160. package/dist/esm/geometries/cylinder-geometry.js +0 -18
  161. package/dist/esm/geometries/cylinder-geometry.js.map +0 -1
  162. package/dist/esm/geometries/ico-sphere-geometry.js +0 -170
  163. package/dist/esm/geometries/ico-sphere-geometry.js.map +0 -1
  164. package/dist/esm/geometries/plane-geometry.js +0 -119
  165. package/dist/esm/geometries/plane-geometry.js.map +0 -1
  166. package/dist/esm/geometries/sphere-geometry.js +0 -102
  167. package/dist/esm/geometries/sphere-geometry.js.map +0 -1
  168. package/dist/esm/geometries/truncated-cone-geometry.js +0 -136
  169. package/dist/esm/geometries/truncated-cone-geometry.js.map +0 -1
  170. package/dist/esm/geometry/geometry-table.js +0 -2
  171. package/dist/esm/geometry/geometry-table.js.map +0 -1
  172. package/dist/esm/geometry/geometry-utils.js +0 -37
  173. package/dist/esm/geometry/geometry-utils.js.map +0 -1
  174. package/dist/esm/geometry/geometry.js +0 -119
  175. package/dist/esm/geometry/geometry.js.map +0 -1
  176. package/dist/esm/geometry/primitive-utils.js +0 -2
  177. package/dist/esm/geometry/primitive-utils.js.map +0 -1
  178. package/dist/esm/index.js +0 -16
  179. package/dist/esm/index.js.map +0 -1
  180. package/dist/esm/lib/clip-space.js +0 -2
  181. package/dist/esm/lib/clip-space.js.map +0 -1
  182. package/dist/esm/lib/model-utils.js +0 -40
  183. package/dist/esm/lib/model-utils.js.map +0 -1
  184. package/dist/esm/lib/model.js +0 -146
  185. package/dist/esm/lib/model.js.map +0 -1
  186. package/dist/esm/lib/pipeline-factory.js +0 -180
  187. package/dist/esm/lib/pipeline-factory.js.map +0 -1
  188. package/src/bundle.ts +0 -4
package/dist/index.cjs ADDED
@@ -0,0 +1,2268 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var __async = (__this, __arguments, generator) => {
47
+ return new Promise((resolve, reject) => {
48
+ var fulfilled = (value) => {
49
+ try {
50
+ step(generator.next(value));
51
+ } catch (e) {
52
+ reject(e);
53
+ }
54
+ };
55
+ var rejected = (value) => {
56
+ try {
57
+ step(generator.throw(value));
58
+ } catch (e) {
59
+ reject(e);
60
+ }
61
+ };
62
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
63
+ step((generator = generator.apply(__this, __arguments)).next());
64
+ });
65
+ };
66
+
67
+ // src/index.ts
68
+ var src_exports = {};
69
+ __export(src_exports, {
70
+ AnimationLoop: () => AnimationLoop,
71
+ AnimationLoopTemplate: () => AnimationLoopTemplate,
72
+ ClipSpace: () => ClipSpace,
73
+ ConeGeometry: () => ConeGeometry,
74
+ CubeGeometry: () => CubeGeometry,
75
+ CylinderGeometry: () => CylinderGeometry,
76
+ Geometry: () => Geometry,
77
+ IcoSphereGeometry: () => IcoSphereGeometry,
78
+ KeyFrames: () => KeyFrames,
79
+ Model: () => Model,
80
+ PipelineFactory: () => PipelineFactory,
81
+ PlaneGeometry: () => PlaneGeometry,
82
+ SphereGeometry: () => SphereGeometry,
83
+ Timeline: () => Timeline,
84
+ TruncatedConeGeometry: () => TruncatedConeGeometry,
85
+ makeAnimationLoop: () => makeAnimationLoop
86
+ });
87
+ module.exports = __toCommonJS(src_exports);
88
+
89
+ // src/animation/timeline.ts
90
+ var channelHandles = 1;
91
+ var animationHandles = 1;
92
+ var Timeline = class {
93
+ constructor() {
94
+ this.time = 0;
95
+ this.channels = /* @__PURE__ */ new Map();
96
+ this.animations = /* @__PURE__ */ new Map();
97
+ this.playing = false;
98
+ this.lastEngineTime = -1;
99
+ }
100
+ addChannel(props) {
101
+ const { delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1 } = props;
102
+ const handle = channelHandles++;
103
+ const channel = {
104
+ time: 0,
105
+ delay,
106
+ duration,
107
+ rate,
108
+ repeat
109
+ };
110
+ this._setChannelTime(channel, this.time);
111
+ this.channels.set(handle, channel);
112
+ return handle;
113
+ }
114
+ removeChannel(handle) {
115
+ this.channels.delete(handle);
116
+ for (const [animationHandle, animation] of this.animations) {
117
+ if (animation.channel === handle) {
118
+ this.detachAnimation(animationHandle);
119
+ }
120
+ }
121
+ }
122
+ isFinished(handle) {
123
+ const channel = this.channels.get(handle);
124
+ if (channel === void 0) {
125
+ return false;
126
+ }
127
+ return this.time >= channel.delay + channel.duration * channel.repeat;
128
+ }
129
+ getTime(handle) {
130
+ if (handle === void 0) {
131
+ return this.time;
132
+ }
133
+ const channel = this.channels.get(handle);
134
+ if (channel === void 0) {
135
+ return -1;
136
+ }
137
+ return channel.time;
138
+ }
139
+ setTime(time) {
140
+ this.time = Math.max(0, time);
141
+ const channels = this.channels.values();
142
+ for (const channel of channels) {
143
+ this._setChannelTime(channel, this.time);
144
+ }
145
+ const animations = this.animations.values();
146
+ for (const animationData of animations) {
147
+ const { animation, channel } = animationData;
148
+ animation.setTime(this.getTime(channel));
149
+ }
150
+ }
151
+ play() {
152
+ this.playing = true;
153
+ }
154
+ pause() {
155
+ this.playing = false;
156
+ this.lastEngineTime = -1;
157
+ }
158
+ reset() {
159
+ this.setTime(0);
160
+ }
161
+ attachAnimation(animation, channelHandle) {
162
+ const animationHandle = animationHandles++;
163
+ this.animations.set(animationHandle, {
164
+ animation,
165
+ channel: channelHandle
166
+ });
167
+ animation.setTime(this.getTime(channelHandle));
168
+ return animationHandle;
169
+ }
170
+ detachAnimation(handle) {
171
+ this.animations.delete(handle);
172
+ }
173
+ update(engineTime) {
174
+ if (this.playing) {
175
+ if (this.lastEngineTime === -1) {
176
+ this.lastEngineTime = engineTime;
177
+ }
178
+ this.setTime(this.time + (engineTime - this.lastEngineTime));
179
+ this.lastEngineTime = engineTime;
180
+ }
181
+ }
182
+ _setChannelTime(channel, time) {
183
+ const offsetTime = time - channel.delay;
184
+ const totalDuration = channel.duration * channel.repeat;
185
+ if (offsetTime >= totalDuration) {
186
+ channel.time = channel.duration * channel.rate;
187
+ } else {
188
+ channel.time = Math.max(0, offsetTime) % channel.duration;
189
+ channel.time *= channel.rate;
190
+ }
191
+ }
192
+ };
193
+
194
+ // src/animation/key-frames.ts
195
+ var KeyFrames = class {
196
+ constructor(keyFrames) {
197
+ this.startIndex = -1;
198
+ this.endIndex = -1;
199
+ this.factor = 0;
200
+ this.times = [];
201
+ this.values = [];
202
+ this._lastTime = -1;
203
+ this.setKeyFrames(keyFrames);
204
+ this.setTime(0);
205
+ }
206
+ setKeyFrames(keyFrames) {
207
+ const numKeys = keyFrames.length;
208
+ this.times.length = numKeys;
209
+ this.values.length = numKeys;
210
+ for (let i = 0; i < numKeys; ++i) {
211
+ this.times[i] = keyFrames[i][0];
212
+ this.values[i] = keyFrames[i][1];
213
+ }
214
+ this._calculateKeys(this._lastTime);
215
+ }
216
+ setTime(time) {
217
+ time = Math.max(0, time);
218
+ if (time !== this._lastTime) {
219
+ this._calculateKeys(time);
220
+ this._lastTime = time;
221
+ }
222
+ }
223
+ getStartTime() {
224
+ return this.times[this.startIndex];
225
+ }
226
+ getEndTime() {
227
+ return this.times[this.endIndex];
228
+ }
229
+ getStartData() {
230
+ return this.values[this.startIndex];
231
+ }
232
+ getEndData() {
233
+ return this.values[this.endIndex];
234
+ }
235
+ _calculateKeys(time) {
236
+ let index = 0;
237
+ const numKeys = this.times.length;
238
+ for (index = 0; index < numKeys - 2; ++index) {
239
+ if (this.times[index + 1] > time) {
240
+ break;
241
+ }
242
+ }
243
+ this.startIndex = index;
244
+ this.endIndex = index + 1;
245
+ const startTime = this.times[this.startIndex];
246
+ const endTime = this.times[this.endIndex];
247
+ this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
248
+ }
249
+ };
250
+
251
+ // src/animation-loop/render-loop.ts
252
+ var AnimationLoopTemplate = class {
253
+ constructor(animationProps) {
254
+ }
255
+ onInitialize(animationProps) {
256
+ return __async(this, null, function* () {
257
+ return null;
258
+ });
259
+ }
260
+ };
261
+
262
+ // src/animation-loop/animation-loop.ts
263
+ var import_api = require("@luma.gl/api");
264
+ var import_api2 = require("@luma.gl/api");
265
+ var import_stats = require("@probe.gl/stats");
266
+ var statIdCounter = 0;
267
+ var DEFAULT_ANIMATION_LOOP_PROPS = {
268
+ device: null,
269
+ onAddHTML: () => "",
270
+ onInitialize: () => __async(void 0, null, function* () {
271
+ return null;
272
+ }),
273
+ onRender: () => {
274
+ },
275
+ onFinalize: () => {
276
+ },
277
+ onError: (error) => console.error(error),
278
+ // eslint-disable-line no-console
279
+ stats: import_api.luma.stats.get(`animation-loop-${statIdCounter++}`),
280
+ // view parameters
281
+ useDevicePixels: true,
282
+ autoResizeViewport: false,
283
+ autoResizeDrawingBuffer: false
284
+ };
285
+ var AnimationLoop = class {
286
+ // _gpuTimeQuery: Query | null = null;
287
+ /*
288
+ * @param {HTMLCanvasElement} canvas - if provided, width and height will be passed to context
289
+ */
290
+ constructor(props) {
291
+ this.device = null;
292
+ this.canvas = null;
293
+ this.animationProps = null;
294
+ this.timeline = null;
295
+ this.needsRedraw = "initialized";
296
+ this._initialized = false;
297
+ this._running = false;
298
+ this._animationFrameId = null;
299
+ this._nextFramePromise = null;
300
+ this._resolveNextFrame = null;
301
+ this._cpuStartTime = 0;
302
+ this.props = __spreadValues(__spreadValues({}, DEFAULT_ANIMATION_LOOP_PROPS), props);
303
+ props = this.props;
304
+ if (!props.device) {
305
+ throw new Error("No device provided");
306
+ }
307
+ const { useDevicePixels = true } = this.props;
308
+ this.stats = props.stats || new import_stats.Stats({ id: "animation-loop-stats" });
309
+ this.cpuTime = this.stats.get("CPU Time");
310
+ this.gpuTime = this.stats.get("GPU Time");
311
+ this.frameRate = this.stats.get("Frame Rate");
312
+ this.setProps({
313
+ autoResizeViewport: props.autoResizeViewport,
314
+ autoResizeDrawingBuffer: props.autoResizeDrawingBuffer,
315
+ useDevicePixels
316
+ });
317
+ this.start = this.start.bind(this);
318
+ this.stop = this.stop.bind(this);
319
+ this._onMousemove = this._onMousemove.bind(this);
320
+ this._onMouseleave = this._onMouseleave.bind(this);
321
+ }
322
+ destroy() {
323
+ this.stop();
324
+ this._setDisplay(null);
325
+ }
326
+ /** @deprecated Use .destroy() */
327
+ delete() {
328
+ this.destroy();
329
+ }
330
+ setNeedsRedraw(reason) {
331
+ this.needsRedraw = this.needsRedraw || reason;
332
+ return this;
333
+ }
334
+ // TODO - move to CanvasContext
335
+ setProps(props) {
336
+ if ("autoResizeViewport" in props) {
337
+ this.props.autoResizeViewport = props.autoResizeViewport || false;
338
+ }
339
+ if ("autoResizeDrawingBuffer" in props) {
340
+ this.props.autoResizeDrawingBuffer = props.autoResizeDrawingBuffer || false;
341
+ }
342
+ if ("useDevicePixels" in props) {
343
+ this.props.useDevicePixels = props.useDevicePixels || false;
344
+ }
345
+ return this;
346
+ }
347
+ /** Starts a render loop if not already running */
348
+ start() {
349
+ return __async(this, null, function* () {
350
+ if (this._running) {
351
+ return this;
352
+ }
353
+ this._running = true;
354
+ try {
355
+ if (!this._running) {
356
+ return null;
357
+ }
358
+ let appContext;
359
+ if (!this._initialized) {
360
+ this._initialized = true;
361
+ yield this._initDevice();
362
+ this._initialize();
363
+ yield this.props.onInitialize(this._getAnimationProps());
364
+ }
365
+ if (!this._running) {
366
+ return null;
367
+ }
368
+ if (appContext !== false) {
369
+ this._cancelAnimationFrame();
370
+ this._requestAnimationFrame();
371
+ }
372
+ return this;
373
+ } catch (err) {
374
+ const error = err instanceof Error ? err : new Error("Unknown error");
375
+ this.props.onError(error);
376
+ throw error;
377
+ }
378
+ });
379
+ }
380
+ /** Explicitly draw a frame */
381
+ redraw() {
382
+ var _a;
383
+ if ((_a = this.device) == null ? void 0 : _a.isLost) {
384
+ return this;
385
+ }
386
+ this._beginTimers();
387
+ this._setupFrame();
388
+ this._updateAnimationProps();
389
+ this._renderFrame(this._getAnimationProps());
390
+ this._clearNeedsRedraw();
391
+ if (this._resolveNextFrame) {
392
+ this._resolveNextFrame(this);
393
+ this._nextFramePromise = null;
394
+ this._resolveNextFrame = null;
395
+ }
396
+ this._endTimers();
397
+ return this;
398
+ }
399
+ // Stops a render loop if already running, finalizing
400
+ stop() {
401
+ if (this._running) {
402
+ if (this.animationProps) {
403
+ this.props.onFinalize(this.animationProps);
404
+ }
405
+ this._cancelAnimationFrame();
406
+ this._nextFramePromise = null;
407
+ this._resolveNextFrame = null;
408
+ this._running = false;
409
+ }
410
+ return this;
411
+ }
412
+ attachTimeline(timeline) {
413
+ this.timeline = timeline;
414
+ return this.timeline;
415
+ }
416
+ detachTimeline() {
417
+ this.timeline = null;
418
+ }
419
+ waitForRender() {
420
+ this.setNeedsRedraw("waitForRender");
421
+ if (!this._nextFramePromise) {
422
+ this._nextFramePromise = new Promise((resolve) => {
423
+ this._resolveNextFrame = resolve;
424
+ });
425
+ }
426
+ return this._nextFramePromise;
427
+ }
428
+ toDataURL() {
429
+ return __async(this, null, function* () {
430
+ this.setNeedsRedraw("toDataURL");
431
+ yield this.waitForRender();
432
+ if (this.canvas instanceof HTMLCanvasElement) {
433
+ return this.canvas.toDataURL();
434
+ }
435
+ throw new Error("OffscreenCanvas");
436
+ });
437
+ }
438
+ // PRIVATE METHODS
439
+ _initialize() {
440
+ this._startEventHandling();
441
+ this._initializeAnimationProps();
442
+ this._updateAnimationProps();
443
+ this._resizeCanvasDrawingBuffer();
444
+ this._resizeViewport();
445
+ }
446
+ _setDisplay(display) {
447
+ if (this.display) {
448
+ this.display.delete();
449
+ this.display.animationLoop = null;
450
+ }
451
+ if (display) {
452
+ display.animationLoop = this;
453
+ }
454
+ this.display = display;
455
+ }
456
+ _requestAnimationFrame() {
457
+ if (!this._running) {
458
+ return;
459
+ }
460
+ this._animationFrameId = (0, import_api2.requestAnimationFrame)(this._animationFrame.bind(this));
461
+ }
462
+ _cancelAnimationFrame() {
463
+ if (this._animationFrameId !== null) {
464
+ return;
465
+ }
466
+ (0, import_api2.cancelAnimationFrame)(this._animationFrameId);
467
+ this._animationFrameId = null;
468
+ }
469
+ _animationFrame() {
470
+ if (!this._running) {
471
+ return;
472
+ }
473
+ this.redraw();
474
+ this._requestAnimationFrame();
475
+ }
476
+ // Called on each frame, can be overridden to call onRender multiple times
477
+ // to support e.g. stereoscopic rendering
478
+ _renderFrame(animationProps) {
479
+ if (this.display) {
480
+ this.display._renderFrame(animationProps);
481
+ return;
482
+ }
483
+ this.props.onRender(this._getAnimationProps());
484
+ }
485
+ _clearNeedsRedraw() {
486
+ this.needsRedraw = false;
487
+ }
488
+ _setupFrame() {
489
+ this._resizeCanvasDrawingBuffer();
490
+ this._resizeViewport();
491
+ }
492
+ // Initialize the object that will be passed to app callbacks
493
+ _initializeAnimationProps() {
494
+ var _a, _b;
495
+ if (!this.device) {
496
+ throw new Error("loop");
497
+ }
498
+ this.animationProps = {
499
+ animationLoop: this,
500
+ device: this.device,
501
+ canvas: (_b = (_a = this.device) == null ? void 0 : _a.canvasContext) == null ? void 0 : _b.canvas,
502
+ timeline: this.timeline,
503
+ // Initial values
504
+ useDevicePixels: this.props.useDevicePixels,
505
+ needsRedraw: false,
506
+ // Placeholders
507
+ width: 1,
508
+ height: 1,
509
+ aspect: 1,
510
+ // Animation props
511
+ time: 0,
512
+ startTime: Date.now(),
513
+ engineTime: 0,
514
+ tick: 0,
515
+ tock: 0,
516
+ // Experimental
517
+ _mousePosition: null
518
+ // Event props
519
+ };
520
+ }
521
+ _getAnimationProps() {
522
+ if (!this.animationProps) {
523
+ throw new Error("animationProps");
524
+ }
525
+ return this.animationProps;
526
+ }
527
+ // Update the context object that will be passed to app callbacks
528
+ _updateAnimationProps() {
529
+ if (!this.animationProps) {
530
+ return;
531
+ }
532
+ const { width, height, aspect } = this._getSizeAndAspect();
533
+ if (width !== this.animationProps.width || height !== this.animationProps.height) {
534
+ this.setNeedsRedraw("drawing buffer resized");
535
+ }
536
+ if (aspect !== this.animationProps.aspect) {
537
+ this.setNeedsRedraw("drawing buffer aspect changed");
538
+ }
539
+ this.animationProps.width = width;
540
+ this.animationProps.height = height;
541
+ this.animationProps.aspect = aspect;
542
+ this.animationProps.needsRedraw = this.needsRedraw;
543
+ this.animationProps.engineTime = Date.now() - this.animationProps.startTime;
544
+ if (this.timeline) {
545
+ this.timeline.update(this.animationProps.engineTime);
546
+ }
547
+ this.animationProps.tick = Math.floor(this.animationProps.time / 1e3 * 60);
548
+ this.animationProps.tock++;
549
+ this.animationProps.time = this.timeline ? this.timeline.getTime() : this.animationProps.engineTime;
550
+ }
551
+ /** Wait for supplied device */
552
+ _initDevice() {
553
+ return __async(this, null, function* () {
554
+ var _a;
555
+ this.device = yield this.props.device;
556
+ if (!this.device) {
557
+ throw new Error("No device provided");
558
+ }
559
+ this.canvas = ((_a = this.device.canvasContext) == null ? void 0 : _a.canvas) || null;
560
+ });
561
+ }
562
+ _createInfoDiv() {
563
+ if (this.canvas && this.props.onAddHTML) {
564
+ const wrapperDiv = document.createElement("div");
565
+ document.body.appendChild(wrapperDiv);
566
+ wrapperDiv.style.position = "relative";
567
+ const div = document.createElement("div");
568
+ div.style.position = "absolute";
569
+ div.style.left = "10px";
570
+ div.style.bottom = "10px";
571
+ div.style.width = "300px";
572
+ div.style.background = "white";
573
+ if (this.canvas instanceof HTMLCanvasElement) {
574
+ wrapperDiv.appendChild(this.canvas);
575
+ }
576
+ wrapperDiv.appendChild(div);
577
+ const html = this.props.onAddHTML(div);
578
+ if (html) {
579
+ div.innerHTML = html;
580
+ }
581
+ }
582
+ }
583
+ _getSizeAndAspect() {
584
+ var _a, _b, _c, _d;
585
+ if (!this.device) {
586
+ return { width: 1, height: 1, aspect: 1 };
587
+ }
588
+ const [width, height] = ((_b = (_a = this.device) == null ? void 0 : _a.canvasContext) == null ? void 0 : _b.getPixelSize()) || [1, 1];
589
+ let aspect = 1;
590
+ const canvas = (_d = (_c = this.device) == null ? void 0 : _c.canvasContext) == null ? void 0 : _d.canvas;
591
+ if (canvas && canvas.clientHeight) {
592
+ aspect = canvas.clientWidth / canvas.clientHeight;
593
+ } else if (width > 0 && height > 0) {
594
+ aspect = width / height;
595
+ }
596
+ return { width, height, aspect };
597
+ }
598
+ /** Default viewport setup */
599
+ _resizeViewport() {
600
+ if (this.props.autoResizeViewport && this.device.gl) {
601
+ this.device.gl.viewport(0, 0, this.device.gl.drawingBufferWidth, this.device.gl.drawingBufferHeight);
602
+ }
603
+ }
604
+ /**
605
+ * Resize the render buffer of the canvas to match canvas client size
606
+ * Optionally multiplying with devicePixel ratio
607
+ */
608
+ _resizeCanvasDrawingBuffer() {
609
+ var _a, _b;
610
+ if (this.props.autoResizeDrawingBuffer) {
611
+ (_b = (_a = this.device) == null ? void 0 : _a.canvasContext) == null ? void 0 : _b.resize({ useDevicePixels: this.props.useDevicePixels });
612
+ }
613
+ }
614
+ _beginTimers() {
615
+ this.frameRate.timeEnd();
616
+ this.frameRate.timeStart();
617
+ }
618
+ _endTimers() {
619
+ this.cpuTime.timeEnd();
620
+ }
621
+ // Event handling
622
+ _startEventHandling() {
623
+ if (this.canvas) {
624
+ this.canvas.addEventListener("mousemove", this._onMousemove.bind(this));
625
+ this.canvas.addEventListener("mouseleave", this._onMouseleave.bind(this));
626
+ }
627
+ }
628
+ _onMousemove(event) {
629
+ if (event instanceof MouseEvent) {
630
+ this._getAnimationProps()._mousePosition = [event.offsetX, event.offsetY];
631
+ }
632
+ }
633
+ _onMouseleave(event) {
634
+ this._getAnimationProps()._mousePosition = null;
635
+ }
636
+ };
637
+
638
+ // src/animation-loop/make-animation-loop.ts
639
+ var import_api3 = require("@luma.gl/api");
640
+ function makeAnimationLoop(AnimationLoopTemplateCtor, props) {
641
+ let renderLoop = null;
642
+ const device = (props == null ? void 0 : props.device) || import_api3.luma.createDevice();
643
+ const animationLoop = new AnimationLoop(__spreadProps(__spreadValues({}, props), {
644
+ device,
645
+ onInitialize(animationProps) {
646
+ return __async(this, null, function* () {
647
+ renderLoop = new AnimationLoopTemplateCtor(animationProps);
648
+ return yield renderLoop == null ? void 0 : renderLoop.onInitialize(animationProps);
649
+ });
650
+ },
651
+ onRender: (animationProps) => renderLoop == null ? void 0 : renderLoop.onRender(animationProps),
652
+ onFinalize: (animationProps) => renderLoop == null ? void 0 : renderLoop.onFinalize(animationProps)
653
+ }));
654
+ animationLoop.getInfo = () => {
655
+ return this.AnimationLoopTemplateCtor.info;
656
+ };
657
+ return animationLoop;
658
+ }
659
+
660
+ // src/lib/model.ts
661
+ var import_api5 = require("@luma.gl/api");
662
+
663
+ // src/lib/model-utils.ts
664
+ var import_api4 = require("@luma.gl/api");
665
+ var GLTF_TO_LUMA_ATTRIBUTE_MAP = {
666
+ POSITION: "positions",
667
+ NORMAL: "normals",
668
+ COLOR_0: "colors",
669
+ TEXCOORD_0: "texCoords",
670
+ TEXCOORD_1: "texCoords1",
671
+ TEXCOORD_2: "texCoords2"
672
+ };
673
+ function getIndexBufferFromGeometry(device, geometry) {
674
+ if (!geometry.indices) {
675
+ return void 0;
676
+ }
677
+ const data = geometry.indices.value || geometry.indices;
678
+ (0, import_api4.assert)(
679
+ data instanceof Uint16Array || data instanceof Uint32Array,
680
+ 'attribute array for "indices" must be of integer type'
681
+ );
682
+ return device.createBuffer({ usage: import_api4.Buffer.INDEX, data });
683
+ }
684
+ function getAttributeBuffersFromGeometry(device, geometry) {
685
+ const buffers = {};
686
+ for (const [name, attribute] of Object.entries(geometry.attributes)) {
687
+ const remappedName = mapAttributeName(name);
688
+ if (attribute == null ? void 0 : attribute.constant) {
689
+ throw new Error("constant attributes not supported");
690
+ } else {
691
+ const typedArray = attribute == null ? void 0 : attribute.value;
692
+ buffers[remappedName] = device.createBuffer({ data: typedArray, id: `${remappedName}-buffer` });
693
+ }
694
+ }
695
+ return buffers;
696
+ }
697
+ function mapAttributeName(name) {
698
+ return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
699
+ }
700
+
701
+ // src/lib/pipeline-factory.ts
702
+ var import_shadertools = require("@luma.gl/shadertools");
703
+ var DEFAULT_RENDER_PIPELINE_OPTIONS = {
704
+ vs: "",
705
+ fs: "",
706
+ modules: [],
707
+ defines: {},
708
+ inject: {},
709
+ transpileToGLSL100: false,
710
+ layout: null,
711
+ varyings: [],
712
+ bufferMode: 35981,
713
+ // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS
714
+ topology: "triangle-list",
715
+ parameters: {}
716
+ };
717
+ var PipelineFactory = class {
718
+ constructor(device) {
719
+ this.stateHash = 0;
720
+ // Used to change hashing if hooks are modified
721
+ this._hashCounter = 0;
722
+ this._hashes = {};
723
+ this._useCounts = {};
724
+ this._pipelineCache = {};
725
+ this._getUniforms = {};
726
+ this._hookFunctions = [];
727
+ this._defaultModules = [];
728
+ this.device = device;
729
+ }
730
+ // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl
731
+ static getDefaultPipelineFactory(device) {
732
+ device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
733
+ return device.defaultPipelineFactory;
734
+ }
735
+ addDefaultModule(module2) {
736
+ if (!this._defaultModules.find((m) => m.name === (typeof module2 === "string" ? module2 : module2.name))) {
737
+ this._defaultModules.push(module2);
738
+ }
739
+ this.stateHash++;
740
+ }
741
+ removeDefaultModule(module2) {
742
+ const moduleName = typeof module2 === "string" ? module2 : module2.name;
743
+ this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);
744
+ this.stateHash++;
745
+ }
746
+ addShaderHook(hook, opts) {
747
+ if (opts) {
748
+ hook = Object.assign(opts, { hook });
749
+ }
750
+ this._hookFunctions.push(hook);
751
+ this.stateHash++;
752
+ }
753
+ createRenderPipeline(options) {
754
+ const props = __spreadValues(__spreadValues({}, DEFAULT_RENDER_PIPELINE_OPTIONS), options);
755
+ const modules = this._getModuleList(props.modules);
756
+ const hash = this._hashRenderPipeline(__spreadProps(__spreadValues({}, props), { modules }));
757
+ if (!this._pipelineCache[hash]) {
758
+ const { pipeline, getUniforms } = this._createRenderPipeline(__spreadProps(__spreadValues({}, props), { modules }));
759
+ pipeline.hash = hash;
760
+ this._pipelineCache[hash] = pipeline;
761
+ this._getUniforms[hash] = getUniforms || ((x) => ({}));
762
+ this._useCounts[hash] = 0;
763
+ }
764
+ this._useCounts[hash]++;
765
+ return {
766
+ pipeline: this._pipelineCache[hash],
767
+ getUniforms: this._getUniforms[hash]
768
+ };
769
+ }
770
+ release(pipeline) {
771
+ const hash = pipeline.hash;
772
+ this._useCounts[hash]--;
773
+ if (this._useCounts[hash] === 0) {
774
+ this._pipelineCache[hash].destroy();
775
+ delete this._pipelineCache[hash];
776
+ delete this._getUniforms[hash];
777
+ delete this._useCounts[hash];
778
+ }
779
+ }
780
+ getUniforms(pipeline) {
781
+ return this._getUniforms[pipeline.hash] || null;
782
+ }
783
+ // PRIVATE
784
+ _createRenderPipeline(props) {
785
+ const platformInfo = {
786
+ gpu: this.device.info.gpu,
787
+ features: this.device.features
788
+ };
789
+ if (!props.fs) {
790
+ throw new Error("fs");
791
+ }
792
+ const assembled = (0, import_shadertools.assembleShaders)(platformInfo, __spreadProps(__spreadValues({}, props), { fs: props.fs, hookFunctions: this._hookFunctions }));
793
+ const pipeline = this.device.createRenderPipeline(__spreadProps(__spreadValues({}, props), {
794
+ vs: this.device.createShader({ stage: "vertex", source: assembled.vs }),
795
+ fs: assembled.fs ? this.device.createShader({ stage: "fragment", source: assembled.fs }) : null
796
+ }));
797
+ return { pipeline, getUniforms: assembled.getUniforms };
798
+ }
799
+ /** Calculate a hash based on all the inputs for a render pipeline */
800
+ _hashRenderPipeline(props) {
801
+ const { modules = [], varyings = [], defines = {}, inject = {}, parameters = {} } = props;
802
+ const vsHash = this._getHash(props.vs);
803
+ const fsHash = props.fs ? this._getHash(props.fs) : 0;
804
+ const moduleHashes = modules.map((m) => this._getHash(typeof m === "string" ? m : m.name)).sort();
805
+ const varyingHashes = varyings.map((v) => this._getHash(v));
806
+ const defineKeys = Object.keys(defines).sort();
807
+ const injectKeys = Object.keys(inject).sort();
808
+ const defineHashes = [];
809
+ const injectHashes = [];
810
+ for (const key of defineKeys) {
811
+ defineHashes.push(this._getHash(key));
812
+ defineHashes.push(this._getHash(String(defines[key])));
813
+ }
814
+ for (const key of injectKeys) {
815
+ injectHashes.push(this._getHash(key));
816
+ injectHashes.push(this._getHash(inject[key]));
817
+ }
818
+ const parameterHash = JSON.stringify(parameters);
819
+ return `${vsHash}/${fsHash}D${defineHashes.join("/")}M${moduleHashes.join(
820
+ "/"
821
+ )}I${injectHashes.join("/")}V${varyingHashes.join("/")}H${this.stateHash}B${props.bufferMode}${props.transpileToGLSL100 ? "T" : ""}P${parameterHash}`;
822
+ }
823
+ _getHash(key) {
824
+ if (this._hashes[key] === void 0) {
825
+ this._hashes[key] = this._hashCounter++;
826
+ }
827
+ return this._hashes[key];
828
+ }
829
+ // Dedupe and combine with default modules
830
+ _getModuleList(appModules = []) {
831
+ const modules = new Array(this._defaultModules.length + appModules.length);
832
+ const seen = {};
833
+ let count = 0;
834
+ for (let i = 0, len = this._defaultModules.length; i < len; ++i) {
835
+ const module2 = this._defaultModules[i];
836
+ const name = module2.name;
837
+ modules[count++] = module2;
838
+ seen[name] = true;
839
+ }
840
+ for (let i = 0, len = appModules.length; i < len; ++i) {
841
+ const module2 = appModules[i];
842
+ const name = module2.name;
843
+ if (!seen[name]) {
844
+ modules[count++] = module2;
845
+ seen[name] = true;
846
+ }
847
+ }
848
+ modules.length = count;
849
+ return modules;
850
+ }
851
+ };
852
+
853
+ // src/lib/model.ts
854
+ var DEFAULT_MODEL_PROPS = __spreadProps(__spreadValues({}, import_api5.RenderPipeline._DEFAULT_PROPS), {
855
+ vs: null,
856
+ fs: null,
857
+ id: "unnamed",
858
+ handle: void 0,
859
+ userData: {},
860
+ modules: [],
861
+ moduleSettings: {},
862
+ geometry: null
863
+ });
864
+ var Model = class {
865
+ constructor(device, props) {
866
+ this.fs = null;
867
+ this.props = __spreadValues(__spreadValues({}, DEFAULT_MODEL_PROPS), props);
868
+ props = this.props;
869
+ this.id = this.props.id;
870
+ this.device = device;
871
+ if (!props.vs) {
872
+ throw new Error("no vertex shader");
873
+ }
874
+ this.vs = getShaderSource(this.device, props.vs);
875
+ if (props.fs) {
876
+ this.fs = getShaderSource(this.device, props.fs);
877
+ }
878
+ this.vertexCount = this.props.vertexCount;
879
+ this.topology = this.props.topology;
880
+ if (this.props.geometry) {
881
+ this.vertexCount = this.props.geometry.vertexCount;
882
+ this.topology = this.props.geometry.topology || "triangle-list";
883
+ }
884
+ const pipelineFactory = PipelineFactory.getDefaultPipelineFactory(this.device);
885
+ const { pipeline, getUniforms } = pipelineFactory.createRenderPipeline(__spreadProps(__spreadValues({}, this.props), {
886
+ vs: this.vs,
887
+ fs: this.fs,
888
+ topology: this.topology,
889
+ parameters: props.parameters,
890
+ layout: props.layout
891
+ }));
892
+ this.pipeline = pipeline;
893
+ this._getModuleUniforms = getUniforms;
894
+ if (this.props.geometry) {
895
+ this._setGeometry(this.props.geometry);
896
+ }
897
+ this.setUniforms(this._getModuleUniforms());
898
+ this.setProps(this.props);
899
+ }
900
+ destroy() {
901
+ this.pipeline.destroy();
902
+ }
903
+ draw(renderPass) {
904
+ this.pipeline.draw({
905
+ renderPass,
906
+ vertexCount: this.vertexCount,
907
+ instanceCount: this.props.instanceCount
908
+ });
909
+ return this;
910
+ }
911
+ setProps(props) {
912
+ if (props.indices) {
913
+ this.setIndexBuffer(props.indices);
914
+ }
915
+ if (props.attributes) {
916
+ this.setAttributes(props.attributes);
917
+ }
918
+ if (props.bindings) {
919
+ this.setBindings(props.bindings);
920
+ }
921
+ if (props.uniforms) {
922
+ this.setUniforms(props.uniforms);
923
+ }
924
+ if (props.moduleSettings) {
925
+ this.updateModuleSettings(props.moduleSettings);
926
+ }
927
+ return this;
928
+ }
929
+ updateModuleSettings(props) {
930
+ const uniforms = this._getModuleUniforms(props);
931
+ this.setUniforms(uniforms);
932
+ return this;
933
+ }
934
+ setIndexBuffer(indices) {
935
+ this.pipeline.setIndexBuffer(indices);
936
+ return this;
937
+ }
938
+ setAttributes(attributes) {
939
+ this.pipeline.setAttributes(attributes);
940
+ Object.assign(this.props.attributes, attributes);
941
+ return this;
942
+ }
943
+ /** Set the bindings */
944
+ setBindings(bindings) {
945
+ this.pipeline.setBindings(bindings);
946
+ Object.assign(this.props.bindings, bindings);
947
+ return this;
948
+ }
949
+ setUniforms(uniforms) {
950
+ this.pipeline.setUniforms(uniforms);
951
+ Object.assign(this.props.uniforms, uniforms);
952
+ return this;
953
+ }
954
+ _setGeometry(geometry) {
955
+ const geometryBuffers = getAttributeBuffersFromGeometry(this.device, geometry);
956
+ this.setAttributes(geometryBuffers);
957
+ const indexBuffer = getIndexBufferFromGeometry(this.device, geometry);
958
+ if (indexBuffer) {
959
+ this.setIndexBuffer(indexBuffer);
960
+ }
961
+ }
962
+ };
963
+ function getShaderSource(device, shader) {
964
+ if (typeof shader === "string") {
965
+ return shader;
966
+ }
967
+ switch (device.info.type) {
968
+ case "webgpu":
969
+ if (shader == null ? void 0 : shader.wgsl) {
970
+ return shader.wgsl;
971
+ }
972
+ throw new Error("WebGPU does not support GLSL shaders");
973
+ default:
974
+ if (shader == null ? void 0 : shader.glsl) {
975
+ return shader.glsl;
976
+ }
977
+ throw new Error("WebGL does not support WGSL shaders");
978
+ }
979
+ }
980
+
981
+ // src/lib/clip-space.ts
982
+ var import_constants2 = __toESM(require("@luma.gl/constants"), 1);
983
+ var import_api7 = require("@luma.gl/api");
984
+
985
+ // src/geometry/geometry.ts
986
+ var import_api6 = require("@luma.gl/api");
987
+ var import_constants = __toESM(require("@luma.gl/constants"), 1);
988
+ var Geometry = class {
989
+ constructor(props = {}) {
990
+ this.userData = {};
991
+ /** @deprecated */
992
+ this.drawMode = import_constants.default.TRIANGLES;
993
+ const {
994
+ id = (0, import_api6.uid)("geometry"),
995
+ drawMode = import_constants.default.TRIANGLES,
996
+ attributes = {},
997
+ indices = null,
998
+ vertexCount = null
999
+ } = props;
1000
+ this.id = id;
1001
+ this.drawMode = drawMode;
1002
+ this.topology = props.topology || convertToTopology(drawMode);
1003
+ if (indices) {
1004
+ this.indices = ArrayBuffer.isView(indices) ? { value: indices, size: 1 } : indices;
1005
+ }
1006
+ this.attributes = {};
1007
+ for (const [attributeName, attributeValue] of Object.entries(attributes)) {
1008
+ const attribute = ArrayBuffer.isView(attributeValue) ? { value: attributeValue } : attributeValue;
1009
+ (0, import_api6.assert)(
1010
+ ArrayBuffer.isView(attribute.value),
1011
+ `${this._print(attributeName)}: must be typed array or object with value as typed array`
1012
+ );
1013
+ if ((attributeName === "POSITION" || attributeName === "positions") && !attribute.size) {
1014
+ attribute.size = 3;
1015
+ }
1016
+ if (attributeName === "indices") {
1017
+ (0, import_api6.assert)(!this.indices);
1018
+ this.indices = attribute;
1019
+ } else {
1020
+ this.attributes[attributeName] = attribute;
1021
+ }
1022
+ }
1023
+ if (this.indices && this.indices.isIndexed !== void 0) {
1024
+ this.indices = Object.assign({}, this.indices);
1025
+ delete this.indices.isIndexed;
1026
+ }
1027
+ this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
1028
+ }
1029
+ /** @deprecated Use string topology constants instead */
1030
+ get mode() {
1031
+ return this.drawMode;
1032
+ }
1033
+ getVertexCount() {
1034
+ return this.vertexCount;
1035
+ }
1036
+ // Return an object with all attributes plus indices added as a field.
1037
+ getAttributes() {
1038
+ return this.indices ? __spreadValues({ indices: this.indices }, this.attributes) : this.attributes;
1039
+ }
1040
+ // PRIVATE
1041
+ _print(attributeName) {
1042
+ return `Geometry ${this.id} attribute ${attributeName}`;
1043
+ }
1044
+ // GeometryAttribute
1045
+ // value: typed array
1046
+ // type: indices, vertices, uvs
1047
+ // size: elements per vertex
1048
+ // target: WebGL buffer type (string or constant)
1049
+ _setAttributes(attributes, indices) {
1050
+ return this;
1051
+ }
1052
+ _calculateVertexCount(attributes, indices) {
1053
+ if (indices) {
1054
+ return indices.value.length;
1055
+ }
1056
+ let vertexCount = Infinity;
1057
+ for (const attributeName in attributes) {
1058
+ const attribute = attributes[attributeName];
1059
+ const { value, size, constant } = attribute;
1060
+ if (!constant && value && size >= 1) {
1061
+ vertexCount = Math.min(vertexCount, value.length / size);
1062
+ }
1063
+ }
1064
+ (0, import_api6.assert)(Number.isFinite(vertexCount));
1065
+ return vertexCount;
1066
+ }
1067
+ };
1068
+ /** @deprecated */
1069
+ Geometry.DRAW_MODE = {
1070
+ POINTS: import_constants.default.POINTS,
1071
+ // draw single points.
1072
+ LINES: import_constants.default.LINES,
1073
+ // draw lines. Each vertex connects to the one after it.
1074
+ LINE_LOOP: import_constants.default.LINE_LOOP,
1075
+ // draw lines. Each set of two vertices is treated as a separate line segment.
1076
+ LINE_STRIP: import_constants.default.LINE_STRIP,
1077
+ // draw a connected group of line segments from the first vertex to the last
1078
+ TRIANGLES: import_constants.default.TRIANGLES,
1079
+ // draw triangles. Each set of three vertices creates a separate triangle.
1080
+ TRIANGLE_STRIP: import_constants.default.TRIANGLE_STRIP,
1081
+ // draw a connected group of triangles.
1082
+ TRIANGLE_FAN: import_constants.default.TRIANGLE_FAN
1083
+ // draw a connected group of triangles.
1084
+ };
1085
+ function convertToTopology(drawMode) {
1086
+ switch (drawMode) {
1087
+ case import_constants.default.POINTS:
1088
+ return "point-list";
1089
+ case import_constants.default.LINES:
1090
+ return "line-list";
1091
+ case import_constants.default.LINE_STRIP:
1092
+ return "line-strip";
1093
+ case import_constants.default.TRIANGLES:
1094
+ return "triangle-list";
1095
+ case import_constants.default.TRIANGLE_STRIP:
1096
+ return "triangle-strip";
1097
+ case import_constants.default.TRIANGLE_FAN:
1098
+ return "triangle-fan";
1099
+ case import_constants.default.LINE_LOOP:
1100
+ return "line-loop";
1101
+ default:
1102
+ throw new Error(String(drawMode));
1103
+ }
1104
+ }
1105
+
1106
+ // src/lib/clip-space.ts
1107
+ var import_webgl = require("@luma.gl/webgl/index");
1108
+ var CLIPSPACE_VERTEX_SHADER = import_api7.glsl`\
1109
+ attribute vec2 aClipSpacePosition;
1110
+ attribute vec2 aTexCoord;
1111
+ attribute vec2 aCoordinate;
1112
+
1113
+ varying vec2 position;
1114
+ varying vec2 coordinate;
1115
+ varying vec2 uv;
1116
+
1117
+ void main(void) {
1118
+ gl_Position = vec4(aClipSpacePosition, 0., 1.);
1119
+ position = aClipSpacePosition;
1120
+ coordinate = aCoordinate;
1121
+ uv = aTexCoord;
1122
+ }
1123
+ `;
1124
+ var POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
1125
+ var ClipSpace = class extends Model {
1126
+ constructor(device, opts) {
1127
+ const TEX_COORDS = POSITIONS.map((coord) => coord === -1 ? 0 : coord);
1128
+ super(
1129
+ import_webgl.WebGLDevice.attach(device),
1130
+ __spreadProps(__spreadValues({}, opts), {
1131
+ vs: CLIPSPACE_VERTEX_SHADER,
1132
+ vertexCount: 4,
1133
+ geometry: new Geometry({
1134
+ drawMode: import_constants2.default.TRIANGLE_STRIP,
1135
+ vertexCount: 4,
1136
+ attributes: {
1137
+ aClipSpacePosition: { size: 2, value: new Float32Array(POSITIONS) },
1138
+ aTexCoord: { size: 2, value: new Float32Array(TEX_COORDS) },
1139
+ aCoordinate: { size: 2, value: new Float32Array(TEX_COORDS) }
1140
+ }
1141
+ })
1142
+ })
1143
+ );
1144
+ }
1145
+ };
1146
+
1147
+ // src/geometries/cone-geometry.ts
1148
+ var import_api9 = require("@luma.gl/api");
1149
+
1150
+ // src/geometries/truncated-cone-geometry.ts
1151
+ var import_api8 = require("@luma.gl/api");
1152
+ var INDEX_OFFSETS = {
1153
+ x: [2, 0, 1],
1154
+ y: [0, 1, 2],
1155
+ z: [1, 2, 0]
1156
+ };
1157
+ var TruncatedConeGeometry = class extends Geometry {
1158
+ constructor(props = {}) {
1159
+ const { id = (0, import_api8.uid)("truncated-code-geometry") } = props;
1160
+ const { indices, attributes } = tesselateTruncatedCone(props);
1161
+ super(__spreadProps(__spreadValues({}, props), {
1162
+ id,
1163
+ indices,
1164
+ attributes: __spreadValues({
1165
+ POSITION: { size: 3, value: attributes.POSITION },
1166
+ NORMAL: { size: 3, value: attributes.NORMAL },
1167
+ TEXCOORD_0: { size: 2, value: attributes.TEXCOORD_0 }
1168
+ }, props.attributes)
1169
+ }));
1170
+ }
1171
+ };
1172
+ function tesselateTruncatedCone(props = {}) {
1173
+ const {
1174
+ bottomRadius = 0,
1175
+ topRadius = 0,
1176
+ height = 1,
1177
+ nradial = 10,
1178
+ nvertical = 10,
1179
+ verticalAxis = "y",
1180
+ topCap = false,
1181
+ bottomCap = false
1182
+ } = props;
1183
+ const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
1184
+ const numVertices = (nradial + 1) * (nvertical + 1 + extra);
1185
+ const slant = Math.atan2(bottomRadius - topRadius, height);
1186
+ const msin = Math.sin;
1187
+ const mcos = Math.cos;
1188
+ const mpi = Math.PI;
1189
+ const cosSlant = mcos(slant);
1190
+ const sinSlant = msin(slant);
1191
+ const start = topCap ? -2 : 0;
1192
+ const end = nvertical + (bottomCap ? 2 : 0);
1193
+ const vertsAroundEdge = nradial + 1;
1194
+ const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
1195
+ const indexOffset = INDEX_OFFSETS[verticalAxis];
1196
+ const positions = new Float32Array(numVertices * 3);
1197
+ const normals = new Float32Array(numVertices * 3);
1198
+ const texCoords = new Float32Array(numVertices * 2);
1199
+ let i3 = 0;
1200
+ let i2 = 0;
1201
+ for (let i = start; i <= end; i++) {
1202
+ let v = i / nvertical;
1203
+ let y = height * v;
1204
+ let ringRadius;
1205
+ if (i < 0) {
1206
+ y = 0;
1207
+ v = 1;
1208
+ ringRadius = bottomRadius;
1209
+ } else if (i > nvertical) {
1210
+ y = height;
1211
+ v = 1;
1212
+ ringRadius = topRadius;
1213
+ } else {
1214
+ ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
1215
+ }
1216
+ if (i === -2 || i === nvertical + 2) {
1217
+ ringRadius = 0;
1218
+ v = 0;
1219
+ }
1220
+ y -= height / 2;
1221
+ for (let j = 0; j < vertsAroundEdge; j++) {
1222
+ const sin = msin(j * mpi * 2 / nradial);
1223
+ const cos = mcos(j * mpi * 2 / nradial);
1224
+ positions[i3 + indexOffset[0]] = sin * ringRadius;
1225
+ positions[i3 + indexOffset[1]] = y;
1226
+ positions[i3 + indexOffset[2]] = cos * ringRadius;
1227
+ normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
1228
+ normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
1229
+ normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
1230
+ texCoords[i2 + 0] = j / nradial;
1231
+ texCoords[i2 + 1] = v;
1232
+ i2 += 2;
1233
+ i3 += 3;
1234
+ }
1235
+ }
1236
+ for (let i = 0; i < nvertical + extra; i++) {
1237
+ for (let j = 0; j < nradial; j++) {
1238
+ const index = (i * nradial + j) * 6;
1239
+ indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
1240
+ indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
1241
+ indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
1242
+ indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
1243
+ indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
1244
+ indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
1245
+ }
1246
+ }
1247
+ return {
1248
+ indices,
1249
+ attributes: {
1250
+ POSITION: positions,
1251
+ NORMAL: normals,
1252
+ TEXCOORD_0: texCoords
1253
+ }
1254
+ };
1255
+ }
1256
+
1257
+ // src/geometries/cone-geometry.ts
1258
+ var ConeGeometry = class extends TruncatedConeGeometry {
1259
+ constructor(props = {}) {
1260
+ const { id = (0, import_api9.uid)("cone-geometry"), radius = 1, cap = true } = props;
1261
+ super(__spreadProps(__spreadValues({}, props), {
1262
+ id,
1263
+ topRadius: 0,
1264
+ topCap: Boolean(cap),
1265
+ bottomCap: Boolean(cap),
1266
+ bottomRadius: radius
1267
+ }));
1268
+ }
1269
+ };
1270
+
1271
+ // src/geometries/cube-geometry.ts
1272
+ var import_api10 = require("@luma.gl/api");
1273
+ var CubeGeometry = class extends Geometry {
1274
+ constructor(props = {}) {
1275
+ const { id = (0, import_api10.uid)("cube-geometry"), indices = true } = props;
1276
+ super(indices ? __spreadProps(__spreadValues({}, props), {
1277
+ id,
1278
+ indices: { size: 1, value: CUBE_INDICES },
1279
+ attributes: __spreadValues(__spreadValues({}, ATTRIBUTES), props.attributes)
1280
+ }) : __spreadProps(__spreadValues({}, props), {
1281
+ id,
1282
+ indices: void 0,
1283
+ attributes: __spreadValues(__spreadValues({}, NON_INDEXED_ATTRIBUTES), props.attributes)
1284
+ }));
1285
+ }
1286
+ };
1287
+ var CUBE_INDICES = new Uint16Array([
1288
+ 0,
1289
+ 1,
1290
+ 2,
1291
+ 0,
1292
+ 2,
1293
+ 3,
1294
+ 4,
1295
+ 5,
1296
+ 6,
1297
+ 4,
1298
+ 6,
1299
+ 7,
1300
+ 8,
1301
+ 9,
1302
+ 10,
1303
+ 8,
1304
+ 10,
1305
+ 11,
1306
+ 12,
1307
+ 13,
1308
+ 14,
1309
+ 12,
1310
+ 14,
1311
+ 15,
1312
+ 16,
1313
+ 17,
1314
+ 18,
1315
+ 16,
1316
+ 18,
1317
+ 19,
1318
+ 20,
1319
+ 21,
1320
+ 22,
1321
+ 20,
1322
+ 22,
1323
+ 23
1324
+ ]);
1325
+ var CUBE_POSITIONS = new Float32Array([
1326
+ -1,
1327
+ -1,
1328
+ 1,
1329
+ 1,
1330
+ -1,
1331
+ 1,
1332
+ 1,
1333
+ 1,
1334
+ 1,
1335
+ -1,
1336
+ 1,
1337
+ 1,
1338
+ -1,
1339
+ -1,
1340
+ -1,
1341
+ -1,
1342
+ 1,
1343
+ -1,
1344
+ 1,
1345
+ 1,
1346
+ -1,
1347
+ 1,
1348
+ -1,
1349
+ -1,
1350
+ -1,
1351
+ 1,
1352
+ -1,
1353
+ -1,
1354
+ 1,
1355
+ 1,
1356
+ 1,
1357
+ 1,
1358
+ 1,
1359
+ 1,
1360
+ 1,
1361
+ -1,
1362
+ -1,
1363
+ -1,
1364
+ -1,
1365
+ 1,
1366
+ -1,
1367
+ -1,
1368
+ 1,
1369
+ -1,
1370
+ 1,
1371
+ -1,
1372
+ -1,
1373
+ 1,
1374
+ 1,
1375
+ -1,
1376
+ -1,
1377
+ 1,
1378
+ 1,
1379
+ -1,
1380
+ 1,
1381
+ 1,
1382
+ 1,
1383
+ 1,
1384
+ -1,
1385
+ 1,
1386
+ -1,
1387
+ -1,
1388
+ -1,
1389
+ -1,
1390
+ -1,
1391
+ 1,
1392
+ -1,
1393
+ 1,
1394
+ 1,
1395
+ -1,
1396
+ 1,
1397
+ -1
1398
+ ]);
1399
+ var CUBE_NORMALS = new Float32Array([
1400
+ // Front face
1401
+ 0,
1402
+ 0,
1403
+ 1,
1404
+ 0,
1405
+ 0,
1406
+ 1,
1407
+ 0,
1408
+ 0,
1409
+ 1,
1410
+ 0,
1411
+ 0,
1412
+ 1,
1413
+ // Back face
1414
+ 0,
1415
+ 0,
1416
+ -1,
1417
+ 0,
1418
+ 0,
1419
+ -1,
1420
+ 0,
1421
+ 0,
1422
+ -1,
1423
+ 0,
1424
+ 0,
1425
+ -1,
1426
+ // Top face
1427
+ 0,
1428
+ 1,
1429
+ 0,
1430
+ 0,
1431
+ 1,
1432
+ 0,
1433
+ 0,
1434
+ 1,
1435
+ 0,
1436
+ 0,
1437
+ 1,
1438
+ 0,
1439
+ // Bottom face
1440
+ 0,
1441
+ -1,
1442
+ 0,
1443
+ 0,
1444
+ -1,
1445
+ 0,
1446
+ 0,
1447
+ -1,
1448
+ 0,
1449
+ 0,
1450
+ -1,
1451
+ 0,
1452
+ // Right face
1453
+ 1,
1454
+ 0,
1455
+ 0,
1456
+ 1,
1457
+ 0,
1458
+ 0,
1459
+ 1,
1460
+ 0,
1461
+ 0,
1462
+ 1,
1463
+ 0,
1464
+ 0,
1465
+ // Left face
1466
+ -1,
1467
+ 0,
1468
+ 0,
1469
+ -1,
1470
+ 0,
1471
+ 0,
1472
+ -1,
1473
+ 0,
1474
+ 0,
1475
+ -1,
1476
+ 0,
1477
+ 0
1478
+ ]);
1479
+ var CUBE_TEX_COORDS = new Float32Array([
1480
+ // Front face
1481
+ 0,
1482
+ 0,
1483
+ 1,
1484
+ 0,
1485
+ 1,
1486
+ 1,
1487
+ 0,
1488
+ 1,
1489
+ // Back face
1490
+ 1,
1491
+ 0,
1492
+ 1,
1493
+ 1,
1494
+ 0,
1495
+ 1,
1496
+ 0,
1497
+ 0,
1498
+ // Top face
1499
+ 0,
1500
+ 1,
1501
+ 0,
1502
+ 0,
1503
+ 1,
1504
+ 0,
1505
+ 1,
1506
+ 1,
1507
+ // Bottom face
1508
+ 1,
1509
+ 1,
1510
+ 0,
1511
+ 1,
1512
+ 0,
1513
+ 0,
1514
+ 1,
1515
+ 0,
1516
+ // Right face
1517
+ 1,
1518
+ 0,
1519
+ 1,
1520
+ 1,
1521
+ 0,
1522
+ 1,
1523
+ 0,
1524
+ 0,
1525
+ // Left face
1526
+ 0,
1527
+ 0,
1528
+ 1,
1529
+ 0,
1530
+ 1,
1531
+ 1,
1532
+ 0,
1533
+ 1
1534
+ ]);
1535
+ var CUBE_NON_INDEXED_POSITIONS = new Float32Array([
1536
+ 1,
1537
+ -1,
1538
+ 1,
1539
+ 1,
1540
+ -1,
1541
+ -1,
1542
+ 1,
1543
+ 1,
1544
+ -1,
1545
+ -1,
1546
+ -1,
1547
+ 1,
1548
+ 1,
1549
+ -1,
1550
+ -1,
1551
+ 1,
1552
+ 1,
1553
+ -1,
1554
+ 1,
1555
+ 1,
1556
+ -1,
1557
+ -1,
1558
+ -1,
1559
+ 1,
1560
+ 1,
1561
+ 1,
1562
+ 1,
1563
+ 1,
1564
+ 1,
1565
+ -1,
1566
+ 1,
1567
+ 1,
1568
+ 1,
1569
+ -1,
1570
+ -1,
1571
+ 1,
1572
+ 1,
1573
+ 1,
1574
+ -1,
1575
+ 1,
1576
+ 1,
1577
+ 1,
1578
+ 1,
1579
+ 1,
1580
+ 1,
1581
+ -1,
1582
+ -1,
1583
+ 1,
1584
+ -1,
1585
+ 1,
1586
+ 1,
1587
+ 1,
1588
+ 1,
1589
+ 1,
1590
+ 1,
1591
+ 1,
1592
+ 1,
1593
+ 1,
1594
+ -1,
1595
+ 1,
1596
+ -1,
1597
+ 1,
1598
+ -1,
1599
+ 1,
1600
+ -1,
1601
+ 1,
1602
+ 1,
1603
+ 1,
1604
+ 1,
1605
+ 1,
1606
+ -1,
1607
+ 1,
1608
+ -1,
1609
+ -1,
1610
+ 1,
1611
+ 1,
1612
+ -1,
1613
+ 1,
1614
+ 1,
1615
+ 1,
1616
+ -1,
1617
+ 1,
1618
+ -1,
1619
+ 1,
1620
+ -1,
1621
+ -1,
1622
+ -1,
1623
+ 1,
1624
+ -1,
1625
+ -1,
1626
+ 1,
1627
+ 1,
1628
+ -1,
1629
+ 1,
1630
+ -1,
1631
+ 1,
1632
+ 1,
1633
+ 1,
1634
+ 1,
1635
+ 1,
1636
+ -1,
1637
+ 1,
1638
+ 1,
1639
+ 1,
1640
+ -1,
1641
+ -1,
1642
+ 1,
1643
+ 1,
1644
+ -1,
1645
+ -1,
1646
+ 1,
1647
+ 1,
1648
+ 1,
1649
+ -1,
1650
+ 1,
1651
+ 1,
1652
+ 1,
1653
+ 1,
1654
+ 1,
1655
+ 1,
1656
+ 1,
1657
+ -1,
1658
+ -1,
1659
+ 1,
1660
+ -1,
1661
+ -1,
1662
+ -1,
1663
+ 1,
1664
+ -1,
1665
+ 1,
1666
+ -1,
1667
+ 1,
1668
+ 1,
1669
+ 1,
1670
+ -1,
1671
+ 1,
1672
+ 1,
1673
+ -1,
1674
+ -1,
1675
+ 1,
1676
+ -1,
1677
+ 1,
1678
+ -1,
1679
+ 1
1680
+ ]);
1681
+ var CUBE_NON_INDEXED_TEX_COORDS = new Float32Array([
1682
+ 1,
1683
+ 1,
1684
+ 0,
1685
+ 1,
1686
+ 0,
1687
+ 0,
1688
+ 1,
1689
+ 0,
1690
+ 1,
1691
+ 1,
1692
+ 0,
1693
+ 0,
1694
+ 1,
1695
+ 1,
1696
+ 0,
1697
+ 1,
1698
+ 0,
1699
+ 0,
1700
+ 1,
1701
+ 0,
1702
+ 1,
1703
+ 1,
1704
+ 0,
1705
+ 0,
1706
+ 1,
1707
+ 1,
1708
+ 0,
1709
+ 1,
1710
+ 0,
1711
+ 0,
1712
+ 1,
1713
+ 0,
1714
+ 1,
1715
+ 1,
1716
+ 0,
1717
+ 0,
1718
+ 1,
1719
+ 1,
1720
+ 0,
1721
+ 1,
1722
+ 0,
1723
+ 0,
1724
+ 1,
1725
+ 0,
1726
+ 1,
1727
+ 1,
1728
+ 0,
1729
+ 0,
1730
+ 1,
1731
+ 1,
1732
+ 0,
1733
+ 1,
1734
+ 0,
1735
+ 0,
1736
+ 0,
1737
+ 0,
1738
+ 1,
1739
+ 0,
1740
+ 1,
1741
+ 1,
1742
+ 1,
1743
+ 1,
1744
+ 0,
1745
+ 1,
1746
+ 0,
1747
+ 0,
1748
+ 1,
1749
+ 0,
1750
+ 1,
1751
+ 1,
1752
+ 0,
1753
+ 0
1754
+ ]);
1755
+ var CUBE_NON_INDEXED_COLORS = new Float32Array([
1756
+ 1,
1757
+ 0,
1758
+ 1,
1759
+ 1,
1760
+ 0,
1761
+ 0,
1762
+ 1,
1763
+ 1,
1764
+ 0,
1765
+ 0,
1766
+ 0,
1767
+ 1,
1768
+ 1,
1769
+ 0,
1770
+ 0,
1771
+ 1,
1772
+ 1,
1773
+ 0,
1774
+ 1,
1775
+ 1,
1776
+ 0,
1777
+ 0,
1778
+ 0,
1779
+ 1,
1780
+ 1,
1781
+ 1,
1782
+ 1,
1783
+ 1,
1784
+ 1,
1785
+ 0,
1786
+ 1,
1787
+ 1,
1788
+ 1,
1789
+ 0,
1790
+ 0,
1791
+ 1,
1792
+ 1,
1793
+ 1,
1794
+ 0,
1795
+ 1,
1796
+ 1,
1797
+ 1,
1798
+ 1,
1799
+ 1,
1800
+ 1,
1801
+ 0,
1802
+ 0,
1803
+ 1,
1804
+ 0,
1805
+ 1,
1806
+ 1,
1807
+ 1,
1808
+ 1,
1809
+ 1,
1810
+ 1,
1811
+ 1,
1812
+ 1,
1813
+ 1,
1814
+ 0,
1815
+ 1,
1816
+ 0,
1817
+ 1,
1818
+ 0,
1819
+ 1,
1820
+ 0,
1821
+ 1,
1822
+ 1,
1823
+ 1,
1824
+ 1,
1825
+ 1,
1826
+ 0,
1827
+ 1,
1828
+ 0,
1829
+ 0,
1830
+ 1,
1831
+ 1,
1832
+ 0,
1833
+ 1,
1834
+ 1,
1835
+ 1,
1836
+ 0,
1837
+ 1,
1838
+ 0,
1839
+ 1,
1840
+ 0,
1841
+ 0,
1842
+ 0,
1843
+ 1,
1844
+ 0,
1845
+ 0,
1846
+ 1,
1847
+ 1,
1848
+ 0,
1849
+ 1,
1850
+ 0,
1851
+ 1,
1852
+ 1,
1853
+ 1,
1854
+ 1,
1855
+ 1,
1856
+ 0,
1857
+ 1,
1858
+ 1,
1859
+ 1,
1860
+ 0,
1861
+ 0,
1862
+ 1,
1863
+ 1,
1864
+ 0,
1865
+ 0,
1866
+ 1,
1867
+ 1,
1868
+ 1,
1869
+ 0,
1870
+ 1,
1871
+ 1,
1872
+ 1,
1873
+ 1,
1874
+ 1,
1875
+ 1,
1876
+ 1,
1877
+ 0,
1878
+ 0,
1879
+ 1,
1880
+ 0,
1881
+ 0,
1882
+ 0,
1883
+ 1,
1884
+ 0,
1885
+ 1,
1886
+ 0,
1887
+ 1,
1888
+ 1,
1889
+ 1,
1890
+ 0,
1891
+ 1,
1892
+ 1,
1893
+ 0,
1894
+ 0,
1895
+ 1,
1896
+ 0,
1897
+ 1,
1898
+ 0,
1899
+ 1
1900
+ ]);
1901
+ var ATTRIBUTES = {
1902
+ POSITION: { size: 3, value: CUBE_POSITIONS },
1903
+ NORMAL: { size: 3, value: CUBE_NORMALS },
1904
+ TEXCOORD_0: { size: 2, value: CUBE_TEX_COORDS }
1905
+ };
1906
+ var NON_INDEXED_ATTRIBUTES = {
1907
+ POSITION: { size: 4, value: CUBE_NON_INDEXED_POSITIONS },
1908
+ // NORMAL: {size: 3, value: CUBE_NON_INDEXED_NORMALS},
1909
+ TEXCOORD_0: { size: 2, value: CUBE_NON_INDEXED_TEX_COORDS },
1910
+ COLOR_0: { size: 3, value: CUBE_NON_INDEXED_COLORS }
1911
+ };
1912
+
1913
+ // src/geometries/cylinder-geometry.ts
1914
+ var import_api11 = require("@luma.gl/api");
1915
+ var CylinderGeometry = class extends TruncatedConeGeometry {
1916
+ constructor(props = {}) {
1917
+ const { id = (0, import_api11.uid)("cylinder-geometry"), radius = 1 } = props;
1918
+ super(__spreadProps(__spreadValues({}, props), {
1919
+ id,
1920
+ bottomRadius: radius,
1921
+ topRadius: radius
1922
+ }));
1923
+ }
1924
+ };
1925
+
1926
+ // src/geometries/ico-sphere-geometry.ts
1927
+ var import_api12 = require("@luma.gl/api");
1928
+ var import_core = require("@math.gl/core");
1929
+ var ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];
1930
+ var ICO_INDICES = [3, 4, 5, 3, 5, 1, 3, 1, 0, 3, 0, 4, 4, 0, 2, 4, 2, 5, 2, 0, 1, 5, 2, 1];
1931
+ var IcoSphereGeometry = class extends Geometry {
1932
+ constructor(props = {}) {
1933
+ const { id = (0, import_api12.uid)("ico-sphere-geometry") } = props;
1934
+ const { indices, attributes } = tesselateIcosaHedron(props);
1935
+ super(__spreadProps(__spreadValues({}, props), {
1936
+ id,
1937
+ indices,
1938
+ attributes: __spreadValues(__spreadValues({}, attributes), props.attributes)
1939
+ }));
1940
+ }
1941
+ };
1942
+ function tesselateIcosaHedron(props) {
1943
+ const { iterations = 0 } = props;
1944
+ const PI = Math.PI;
1945
+ const PI2 = PI * 2;
1946
+ const positions = [...ICO_POSITIONS];
1947
+ let indices = [...ICO_INDICES];
1948
+ positions.push();
1949
+ indices.push();
1950
+ const getMiddlePoint = (() => {
1951
+ const pointMemo = {};
1952
+ return (i1, i2) => {
1953
+ i1 *= 3;
1954
+ i2 *= 3;
1955
+ const mini = i1 < i2 ? i1 : i2;
1956
+ const maxi = i1 > i2 ? i1 : i2;
1957
+ const key = `${mini}|${maxi}`;
1958
+ if (key in pointMemo) {
1959
+ return pointMemo[key];
1960
+ }
1961
+ const x1 = positions[i1];
1962
+ const y1 = positions[i1 + 1];
1963
+ const z1 = positions[i1 + 2];
1964
+ const x2 = positions[i2];
1965
+ const y2 = positions[i2 + 1];
1966
+ const z2 = positions[i2 + 2];
1967
+ let xm = (x1 + x2) / 2;
1968
+ let ym = (y1 + y2) / 2;
1969
+ let zm = (z1 + z2) / 2;
1970
+ const len = Math.sqrt(xm * xm + ym * ym + zm * zm);
1971
+ xm /= len;
1972
+ ym /= len;
1973
+ zm /= len;
1974
+ positions.push(xm, ym, zm);
1975
+ return pointMemo[key] = positions.length / 3 - 1;
1976
+ };
1977
+ })();
1978
+ for (let i = 0; i < iterations; i++) {
1979
+ const indices2 = [];
1980
+ for (let j = 0; j < indices.length; j += 3) {
1981
+ const a = getMiddlePoint(indices[j + 0], indices[j + 1]);
1982
+ const b = getMiddlePoint(indices[j + 1], indices[j + 2]);
1983
+ const c = getMiddlePoint(indices[j + 2], indices[j + 0]);
1984
+ indices2.push(c, indices[j + 0], a, a, indices[j + 1], b, b, indices[j + 2], c, a, b, c);
1985
+ }
1986
+ indices = indices2;
1987
+ }
1988
+ const normals = new Array(positions.length);
1989
+ const texCoords = new Array(positions.length / 3 * 2);
1990
+ const l = indices.length;
1991
+ for (let i = l - 3; i >= 0; i -= 3) {
1992
+ const i1 = indices[i + 0];
1993
+ const i2 = indices[i + 1];
1994
+ const i3 = indices[i + 2];
1995
+ const in1 = i1 * 3;
1996
+ const in2 = i2 * 3;
1997
+ const in3 = i3 * 3;
1998
+ const iu1 = i1 * 2;
1999
+ const iu2 = i2 * 2;
2000
+ const iu3 = i3 * 2;
2001
+ const x1 = positions[in1 + 0];
2002
+ const y1 = positions[in1 + 1];
2003
+ const z1 = positions[in1 + 2];
2004
+ const theta1 = Math.acos(z1 / Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1));
2005
+ const phi1 = Math.atan2(y1, x1) + PI;
2006
+ const v1 = theta1 / PI;
2007
+ const u1 = 1 - phi1 / PI2;
2008
+ const x2 = positions[in2 + 0];
2009
+ const y2 = positions[in2 + 1];
2010
+ const z2 = positions[in2 + 2];
2011
+ const theta2 = Math.acos(z2 / Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2));
2012
+ const phi2 = Math.atan2(y2, x2) + PI;
2013
+ const v2 = theta2 / PI;
2014
+ const u2 = 1 - phi2 / PI2;
2015
+ const x3 = positions[in3 + 0];
2016
+ const y3 = positions[in3 + 1];
2017
+ const z3 = positions[in3 + 2];
2018
+ const theta3 = Math.acos(z3 / Math.sqrt(x3 * x3 + y3 * y3 + z3 * z3));
2019
+ const phi3 = Math.atan2(y3, x3) + PI;
2020
+ const v3 = theta3 / PI;
2021
+ const u3 = 1 - phi3 / PI2;
2022
+ const vec1 = [x3 - x2, y3 - y2, z3 - z2];
2023
+ const vec2 = [x1 - x2, y1 - y2, z1 - z2];
2024
+ const normal = new import_core.Vector3(vec1).cross(vec2).normalize();
2025
+ let newIndex;
2026
+ if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
2027
+ positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
2028
+ newIndex = positions.length / 3 - 1;
2029
+ indices.push(newIndex);
2030
+ texCoords[newIndex * 2 + 0] = 1;
2031
+ texCoords[newIndex * 2 + 1] = v1;
2032
+ normals[newIndex * 3 + 0] = normal.x;
2033
+ normals[newIndex * 3 + 1] = normal.y;
2034
+ normals[newIndex * 3 + 2] = normal.z;
2035
+ positions.push(positions[in2 + 0], positions[in2 + 1], positions[in2 + 2]);
2036
+ newIndex = positions.length / 3 - 1;
2037
+ indices.push(newIndex);
2038
+ texCoords[newIndex * 2 + 0] = 1;
2039
+ texCoords[newIndex * 2 + 1] = v2;
2040
+ normals[newIndex * 3 + 0] = normal.x;
2041
+ normals[newIndex * 3 + 1] = normal.y;
2042
+ normals[newIndex * 3 + 2] = normal.z;
2043
+ positions.push(positions[in3 + 0], positions[in3 + 1], positions[in3 + 2]);
2044
+ newIndex = positions.length / 3 - 1;
2045
+ indices.push(newIndex);
2046
+ texCoords[newIndex * 2 + 0] = 1;
2047
+ texCoords[newIndex * 2 + 1] = v3;
2048
+ normals[newIndex * 3 + 0] = normal.x;
2049
+ normals[newIndex * 3 + 1] = normal.y;
2050
+ normals[newIndex * 3 + 2] = normal.z;
2051
+ }
2052
+ normals[in1 + 0] = normals[in2 + 0] = normals[in3 + 0] = normal.x;
2053
+ normals[in1 + 1] = normals[in2 + 1] = normals[in3 + 1] = normal.y;
2054
+ normals[in1 + 2] = normals[in2 + 2] = normals[in3 + 2] = normal.z;
2055
+ texCoords[iu1 + 0] = u1;
2056
+ texCoords[iu1 + 1] = v1;
2057
+ texCoords[iu2 + 0] = u2;
2058
+ texCoords[iu2 + 1] = v2;
2059
+ texCoords[iu3 + 0] = u3;
2060
+ texCoords[iu3 + 1] = v3;
2061
+ }
2062
+ return {
2063
+ indices: { size: 1, value: new Uint16Array(indices) },
2064
+ attributes: {
2065
+ POSITION: { size: 3, value: new Float32Array(positions) },
2066
+ NORMAL: { size: 3, value: new Float32Array(normals) },
2067
+ TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) }
2068
+ }
2069
+ };
2070
+ }
2071
+
2072
+ // src/geometries/plane-geometry.ts
2073
+ var import_api13 = require("@luma.gl/api");
2074
+
2075
+ // src/geometry/geometry-utils.ts
2076
+ function unpackIndexedGeometry(geometry) {
2077
+ const { indices, attributes } = geometry;
2078
+ if (!indices) {
2079
+ return geometry;
2080
+ }
2081
+ const vertexCount = indices.value.length;
2082
+ const unpackedAttributes = {};
2083
+ for (const attributeName in attributes) {
2084
+ const attribute = attributes[attributeName];
2085
+ const { constant, value, size } = attribute;
2086
+ if (constant || !size) {
2087
+ continue;
2088
+ }
2089
+ const unpackedValue = new value.constructor(vertexCount * size);
2090
+ for (let x = 0; x < vertexCount; ++x) {
2091
+ const index = indices.value[x];
2092
+ for (let i = 0; i < size; i++) {
2093
+ unpackedValue[x * size + i] = value[index * size + i];
2094
+ }
2095
+ }
2096
+ unpackedAttributes[attributeName] = { size, value: unpackedValue };
2097
+ }
2098
+ return {
2099
+ attributes: Object.assign({}, attributes, unpackedAttributes)
2100
+ };
2101
+ }
2102
+
2103
+ // src/geometries/plane-geometry.ts
2104
+ var PlaneGeometry = class extends Geometry {
2105
+ constructor(props = {}) {
2106
+ const { id = (0, import_api13.uid)("plane-geometry") } = props;
2107
+ const { indices, attributes } = tesselatePlane(props);
2108
+ super(__spreadProps(__spreadValues({}, props), {
2109
+ id,
2110
+ indices,
2111
+ attributes: __spreadValues(__spreadValues({}, attributes), props.attributes)
2112
+ }));
2113
+ }
2114
+ };
2115
+ function tesselatePlane(props) {
2116
+ const { type = "x,y", offset = 0, flipCull = false, unpack = false } = props;
2117
+ const coords = type.split(",");
2118
+ let c1len = props[`${coords[0]}len`] || 1;
2119
+ const c2len = props[`${coords[1]}len`] || 1;
2120
+ const subdivisions1 = props[`n${coords[0]}`] || 1;
2121
+ const subdivisions2 = props[`n${coords[1]}`] || 1;
2122
+ const numVertices = (subdivisions1 + 1) * (subdivisions2 + 1);
2123
+ const positions = new Float32Array(numVertices * 3);
2124
+ const normals = new Float32Array(numVertices * 3);
2125
+ const texCoords = new Float32Array(numVertices * 2);
2126
+ if (flipCull) {
2127
+ c1len = -c1len;
2128
+ }
2129
+ let i2 = 0;
2130
+ let i3 = 0;
2131
+ for (let z = 0; z <= subdivisions2; z++) {
2132
+ for (let x = 0; x <= subdivisions1; x++) {
2133
+ const u = x / subdivisions1;
2134
+ const v = z / subdivisions2;
2135
+ texCoords[i2 + 0] = flipCull ? 1 - u : u;
2136
+ texCoords[i2 + 1] = v;
2137
+ switch (type) {
2138
+ case "x,y":
2139
+ positions[i3 + 0] = c1len * u - c1len * 0.5;
2140
+ positions[i3 + 1] = c2len * v - c2len * 0.5;
2141
+ positions[i3 + 2] = offset;
2142
+ normals[i3 + 0] = 0;
2143
+ normals[i3 + 1] = 0;
2144
+ normals[i3 + 2] = flipCull ? 1 : -1;
2145
+ break;
2146
+ case "x,z":
2147
+ positions[i3 + 0] = c1len * u - c1len * 0.5;
2148
+ positions[i3 + 1] = offset;
2149
+ positions[i3 + 2] = c2len * v - c2len * 0.5;
2150
+ normals[i3 + 0] = 0;
2151
+ normals[i3 + 1] = flipCull ? 1 : -1;
2152
+ normals[i3 + 2] = 0;
2153
+ break;
2154
+ case "y,z":
2155
+ positions[i3 + 0] = offset;
2156
+ positions[i3 + 1] = c1len * u - c1len * 0.5;
2157
+ positions[i3 + 2] = c2len * v - c2len * 0.5;
2158
+ normals[i3 + 0] = flipCull ? 1 : -1;
2159
+ normals[i3 + 1] = 0;
2160
+ normals[i3 + 2] = 0;
2161
+ break;
2162
+ default:
2163
+ throw new Error("PlaneGeometry: unknown type");
2164
+ }
2165
+ i2 += 2;
2166
+ i3 += 3;
2167
+ }
2168
+ }
2169
+ const numVertsAcross = subdivisions1 + 1;
2170
+ const indices = new Uint16Array(subdivisions1 * subdivisions2 * 6);
2171
+ for (let z = 0; z < subdivisions2; z++) {
2172
+ for (let x = 0; x < subdivisions1; x++) {
2173
+ const index = (z * subdivisions1 + x) * 6;
2174
+ indices[index + 0] = (z + 0) * numVertsAcross + x;
2175
+ indices[index + 1] = (z + 1) * numVertsAcross + x;
2176
+ indices[index + 2] = (z + 0) * numVertsAcross + x + 1;
2177
+ indices[index + 3] = (z + 1) * numVertsAcross + x;
2178
+ indices[index + 4] = (z + 1) * numVertsAcross + x + 1;
2179
+ indices[index + 5] = (z + 0) * numVertsAcross + x + 1;
2180
+ }
2181
+ }
2182
+ const geometry = {
2183
+ indices: { size: 1, value: indices },
2184
+ attributes: {
2185
+ POSITION: { size: 3, value: positions },
2186
+ NORMAL: { size: 3, value: normals },
2187
+ TEXCOORD_0: { size: 2, value: texCoords }
2188
+ }
2189
+ };
2190
+ return unpack ? unpackIndexedGeometry(geometry) : geometry;
2191
+ }
2192
+
2193
+ // src/geometries/sphere-geometry.ts
2194
+ var import_api14 = require("@luma.gl/api");
2195
+ var SphereGeometry = class extends Geometry {
2196
+ constructor(props = {}) {
2197
+ const { id = (0, import_api14.uid)("sphere-geometry") } = props;
2198
+ const { indices, attributes } = tesselateSphere(props);
2199
+ super(__spreadProps(__spreadValues({}, props), {
2200
+ id,
2201
+ indices,
2202
+ attributes: __spreadValues(__spreadValues({}, attributes), props.attributes)
2203
+ }));
2204
+ }
2205
+ };
2206
+ function tesselateSphere(props) {
2207
+ const { nlat = 10, nlong = 10 } = props;
2208
+ const startLat = 0;
2209
+ const endLat = Math.PI;
2210
+ const latRange = endLat - startLat;
2211
+ const startLong = 0;
2212
+ const endLong = 2 * Math.PI;
2213
+ const longRange = endLong - startLong;
2214
+ const numVertices = (nlat + 1) * (nlong + 1);
2215
+ const radius = (n1, n2, n3, u, v) => props.radius || 1;
2216
+ const positions = new Float32Array(numVertices * 3);
2217
+ const normals = new Float32Array(numVertices * 3);
2218
+ const texCoords = new Float32Array(numVertices * 2);
2219
+ const IndexType = numVertices > 65535 ? Uint32Array : Uint16Array;
2220
+ const indices = new IndexType(nlat * nlong * 6);
2221
+ for (let y = 0; y <= nlat; y++) {
2222
+ for (let x = 0; x <= nlong; x++) {
2223
+ const u = x / nlong;
2224
+ const v = y / nlat;
2225
+ const index = x + y * (nlong + 1);
2226
+ const i2 = index * 2;
2227
+ const i3 = index * 3;
2228
+ const theta = longRange * u;
2229
+ const phi = latRange * v;
2230
+ const sinTheta = Math.sin(theta);
2231
+ const cosTheta = Math.cos(theta);
2232
+ const sinPhi = Math.sin(phi);
2233
+ const cosPhi = Math.cos(phi);
2234
+ const ux = cosTheta * sinPhi;
2235
+ const uy = cosPhi;
2236
+ const uz = sinTheta * sinPhi;
2237
+ const r = radius(ux, uy, uz, u, v);
2238
+ positions[i3 + 0] = r * ux;
2239
+ positions[i3 + 1] = r * uy;
2240
+ positions[i3 + 2] = r * uz;
2241
+ normals[i3 + 0] = ux;
2242
+ normals[i3 + 1] = uy;
2243
+ normals[i3 + 2] = uz;
2244
+ texCoords[i2 + 0] = u;
2245
+ texCoords[i2 + 1] = 1 - v;
2246
+ }
2247
+ }
2248
+ const numVertsAround = nlong + 1;
2249
+ for (let x = 0; x < nlong; x++) {
2250
+ for (let y = 0; y < nlat; y++) {
2251
+ const index = (x * nlat + y) * 6;
2252
+ indices[index + 0] = y * numVertsAround + x;
2253
+ indices[index + 1] = y * numVertsAround + x + 1;
2254
+ indices[index + 2] = (y + 1) * numVertsAround + x;
2255
+ indices[index + 3] = (y + 1) * numVertsAround + x;
2256
+ indices[index + 4] = y * numVertsAround + x + 1;
2257
+ indices[index + 5] = (y + 1) * numVertsAround + x + 1;
2258
+ }
2259
+ }
2260
+ return {
2261
+ indices: { size: 1, value: indices },
2262
+ attributes: {
2263
+ POSITION: { size: 3, value: positions },
2264
+ NORMAL: { size: 3, value: normals },
2265
+ TEXCOORD_0: { size: 2, value: texCoords }
2266
+ }
2267
+ };
2268
+ }