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

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 (183) 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 +5240 -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 +2222 -0
  65. package/dist/index.js +16 -20
  66. package/dist/index.js.map +1 -0
  67. package/dist/lib/clip-space.js +1 -50
  68. package/dist/lib/clip-space.js.map +1 -0
  69. package/dist/lib/model-utils.js +28 -101
  70. package/dist/lib/model-utils.js.map +1 -0
  71. package/dist/lib/model.d.ts +1 -1
  72. package/dist/lib/model.d.ts.map +1 -1
  73. package/dist/lib/model.js +129 -121
  74. package/dist/lib/model.js.map +1 -0
  75. package/dist/lib/pipeline-factory.d.ts +3 -3
  76. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  77. package/dist/lib/pipeline-factory.js +165 -136
  78. package/dist/lib/pipeline-factory.js.map +1 -0
  79. package/dist.min.js +245 -0
  80. package/package.json +22 -13
  81. package/src/.DS_Store +0 -0
  82. package/src/animation/timeline.ts +1 -1
  83. package/src/animation-loop/animation-loop.ts +5 -5
  84. package/src/animation-loop/make-animation-loop.ts +2 -1
  85. package/src/geometry/geometry.ts +2 -2
  86. package/src/lib/pipeline-factory.ts +1 -1
  87. package/dist/bundle.d.ts +0 -2
  88. package/dist/bundle.d.ts.map +0 -1
  89. package/dist/bundle.js +0 -5
  90. package/dist/dist.min.js +0 -31
  91. package/dist/es5/animation/key-frames.js +0 -84
  92. package/dist/es5/animation/key-frames.js.map +0 -1
  93. package/dist/es5/animation/timeline.js +0 -183
  94. package/dist/es5/animation/timeline.js.map +0 -1
  95. package/dist/es5/animation-loop/animation-loop.js +0 -534
  96. package/dist/es5/animation-loop/animation-loop.js.map +0 -1
  97. package/dist/es5/animation-loop/animation-props.js +0 -2
  98. package/dist/es5/animation-loop/animation-props.js.map +0 -1
  99. package/dist/es5/animation-loop/make-animation-loop.js +0 -53
  100. package/dist/es5/animation-loop/make-animation-loop.js.map +0 -1
  101. package/dist/es5/animation-loop/render-loop.js +0 -39
  102. package/dist/es5/animation-loop/render-loop.js.map +0 -1
  103. package/dist/es5/bundle.js +0 -6
  104. package/dist/es5/bundle.js.map +0 -1
  105. package/dist/es5/geometries/cone-geometry.js +0 -43
  106. package/dist/es5/geometries/cone-geometry.js.map +0 -1
  107. package/dist/es5/geometries/cube-geometry.js +0 -84
  108. package/dist/es5/geometries/cube-geometry.js.map +0 -1
  109. package/dist/es5/geometries/cylinder-geometry.js +0 -39
  110. package/dist/es5/geometries/cylinder-geometry.js.map +0 -1
  111. package/dist/es5/geometries/ico-sphere-geometry.js +0 -185
  112. package/dist/es5/geometries/ico-sphere-geometry.js.map +0 -1
  113. package/dist/es5/geometries/plane-geometry.js +0 -137
  114. package/dist/es5/geometries/plane-geometry.js.map +0 -1
  115. package/dist/es5/geometries/sphere-geometry.js +0 -120
  116. package/dist/es5/geometries/sphere-geometry.js.map +0 -1
  117. package/dist/es5/geometries/truncated-cone-geometry.js +0 -160
  118. package/dist/es5/geometries/truncated-cone-geometry.js.map +0 -1
  119. package/dist/es5/geometry/geometry-table.js +0 -2
  120. package/dist/es5/geometry/geometry-table.js.map +0 -1
  121. package/dist/es5/geometry/geometry-utils.js +0 -39
  122. package/dist/es5/geometry/geometry-utils.js.map +0 -1
  123. package/dist/es5/geometry/geometry.js +0 -150
  124. package/dist/es5/geometry/geometry.js.map +0 -1
  125. package/dist/es5/geometry/primitive-utils.js +0 -2
  126. package/dist/es5/geometry/primitive-utils.js.map +0 -1
  127. package/dist/es5/index.js +0 -112
  128. package/dist/es5/index.js.map +0 -1
  129. package/dist/es5/lib/clip-space.js +0 -2
  130. package/dist/es5/lib/clip-space.js.map +0 -1
  131. package/dist/es5/lib/model-utils.js +0 -52
  132. package/dist/es5/lib/model-utils.js.map +0 -1
  133. package/dist/es5/lib/model.js +0 -173
  134. package/dist/es5/lib/model.js.map +0 -1
  135. package/dist/es5/lib/pipeline-factory.js +0 -244
  136. package/dist/es5/lib/pipeline-factory.js.map +0 -1
  137. package/dist/esm/animation/key-frames.js +0 -57
  138. package/dist/esm/animation/key-frames.js.map +0 -1
  139. package/dist/esm/animation/timeline.js +0 -113
  140. package/dist/esm/animation/timeline.js.map +0 -1
  141. package/dist/esm/animation-loop/animation-loop.js +0 -367
  142. package/dist/esm/animation-loop/animation-loop.js.map +0 -1
  143. package/dist/esm/animation-loop/animation-props.js +0 -2
  144. package/dist/esm/animation-loop/animation-props.js.map +0 -1
  145. package/dist/esm/animation-loop/make-animation-loop.js +0 -28
  146. package/dist/esm/animation-loop/make-animation-loop.js.map +0 -1
  147. package/dist/esm/animation-loop/render-loop.js +0 -7
  148. package/dist/esm/animation-loop/render-loop.js.map +0 -1
  149. package/dist/esm/bundle.js +0 -4
  150. package/dist/esm/bundle.js.map +0 -1
  151. package/dist/esm/geometries/cone-geometry.js +0 -21
  152. package/dist/esm/geometries/cone-geometry.js.map +0 -1
  153. package/dist/esm/geometries/cube-geometry.js +0 -67
  154. package/dist/esm/geometries/cube-geometry.js.map +0 -1
  155. package/dist/esm/geometries/cylinder-geometry.js +0 -18
  156. package/dist/esm/geometries/cylinder-geometry.js.map +0 -1
  157. package/dist/esm/geometries/ico-sphere-geometry.js +0 -170
  158. package/dist/esm/geometries/ico-sphere-geometry.js.map +0 -1
  159. package/dist/esm/geometries/plane-geometry.js +0 -119
  160. package/dist/esm/geometries/plane-geometry.js.map +0 -1
  161. package/dist/esm/geometries/sphere-geometry.js +0 -102
  162. package/dist/esm/geometries/sphere-geometry.js.map +0 -1
  163. package/dist/esm/geometries/truncated-cone-geometry.js +0 -136
  164. package/dist/esm/geometries/truncated-cone-geometry.js.map +0 -1
  165. package/dist/esm/geometry/geometry-table.js +0 -2
  166. package/dist/esm/geometry/geometry-table.js.map +0 -1
  167. package/dist/esm/geometry/geometry-utils.js +0 -37
  168. package/dist/esm/geometry/geometry-utils.js.map +0 -1
  169. package/dist/esm/geometry/geometry.js +0 -119
  170. package/dist/esm/geometry/geometry.js.map +0 -1
  171. package/dist/esm/geometry/primitive-utils.js +0 -2
  172. package/dist/esm/geometry/primitive-utils.js.map +0 -1
  173. package/dist/esm/index.js +0 -16
  174. package/dist/esm/index.js.map +0 -1
  175. package/dist/esm/lib/clip-space.js +0 -2
  176. package/dist/esm/lib/clip-space.js.map +0 -1
  177. package/dist/esm/lib/model-utils.js +0 -40
  178. package/dist/esm/lib/model-utils.js.map +0 -1
  179. package/dist/esm/lib/model.js +0 -146
  180. package/dist/esm/lib/model.js.map +0 -1
  181. package/dist/esm/lib/pipeline-factory.js +0 -180
  182. package/dist/esm/lib/pipeline-factory.js.map +0 -1
  183. package/src/bundle.ts +0 -4
@@ -1,244 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.PipelineFactory = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _shadertools = require("@luma.gl/shadertools");
12
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
- var DEFAULT_RENDER_PIPELINE_OPTIONS = {
18
- vs: '',
19
- fs: '',
20
- modules: [],
21
- defines: {},
22
- inject: {},
23
- transpileToGLSL100: false,
24
- layout: null,
25
- varyings: [],
26
- bufferMode: 0x8c8d,
27
- topology: 'triangle-list',
28
- parameters: {}
29
- };
30
- var PipelineFactory = function () {
31
- function PipelineFactory(device) {
32
- (0, _classCallCheck2.default)(this, PipelineFactory);
33
- (0, _defineProperty2.default)(this, "device", void 0);
34
- (0, _defineProperty2.default)(this, "stateHash", 0);
35
- (0, _defineProperty2.default)(this, "_hashCounter", 0);
36
- (0, _defineProperty2.default)(this, "_hashes", {});
37
- (0, _defineProperty2.default)(this, "_useCounts", {});
38
- (0, _defineProperty2.default)(this, "_pipelineCache", {});
39
- (0, _defineProperty2.default)(this, "_getUniforms", {});
40
- (0, _defineProperty2.default)(this, "_hookFunctions", []);
41
- (0, _defineProperty2.default)(this, "_defaultModules", []);
42
- this.device = device;
43
- }
44
- (0, _createClass2.default)(PipelineFactory, [{
45
- key: "addDefaultModule",
46
- value: function addDefaultModule(module) {
47
- if (!this._defaultModules.find(function (m) {
48
- return m.name === (typeof module === 'string' ? module : module.name);
49
- })) {
50
- this._defaultModules.push(module);
51
- }
52
- this.stateHash++;
53
- }
54
- }, {
55
- key: "removeDefaultModule",
56
- value: function removeDefaultModule(module) {
57
- var moduleName = typeof module === 'string' ? module : module.name;
58
- this._defaultModules = this._defaultModules.filter(function (m) {
59
- return m.name !== moduleName;
60
- });
61
- this.stateHash++;
62
- }
63
- }, {
64
- key: "addShaderHook",
65
- value: function addShaderHook(hook, opts) {
66
- if (opts) {
67
- hook = Object.assign(opts, {
68
- hook: hook
69
- });
70
- }
71
- this._hookFunctions.push(hook);
72
- this.stateHash++;
73
- }
74
- }, {
75
- key: "createRenderPipeline",
76
- value: function createRenderPipeline(options) {
77
- var props = _objectSpread(_objectSpread({}, DEFAULT_RENDER_PIPELINE_OPTIONS), options);
78
- var modules = this._getModuleList(props.modules);
79
- var hash = this._hashRenderPipeline(_objectSpread(_objectSpread({}, props), {}, {
80
- modules: modules
81
- }));
82
- if (!this._pipelineCache[hash]) {
83
- var _this$_createRenderPi = this._createRenderPipeline(_objectSpread(_objectSpread({}, props), {}, {
84
- modules: modules
85
- })),
86
- pipeline = _this$_createRenderPi.pipeline,
87
- getUniforms = _this$_createRenderPi.getUniforms;
88
- pipeline.hash = hash;
89
- this._pipelineCache[hash] = pipeline;
90
- this._getUniforms[hash] = getUniforms || function (x) {
91
- return {};
92
- };
93
- this._useCounts[hash] = 0;
94
- }
95
- this._useCounts[hash]++;
96
- return {
97
- pipeline: this._pipelineCache[hash],
98
- getUniforms: this._getUniforms[hash]
99
- };
100
- }
101
- }, {
102
- key: "release",
103
- value: function release(pipeline) {
104
- var hash = pipeline.hash;
105
- this._useCounts[hash]--;
106
- if (this._useCounts[hash] === 0) {
107
- this._pipelineCache[hash].destroy();
108
- delete this._pipelineCache[hash];
109
- delete this._getUniforms[hash];
110
- delete this._useCounts[hash];
111
- }
112
- }
113
- }, {
114
- key: "getUniforms",
115
- value: function getUniforms(pipeline) {
116
- return this._getUniforms[pipeline.hash] || null;
117
- }
118
- }, {
119
- key: "_createRenderPipeline",
120
- value: function _createRenderPipeline(props) {
121
- var platformInfo = {
122
- gpu: this.device.info.gpu,
123
- features: this.device.features
124
- };
125
- if (!props.fs) {
126
- throw new Error('fs');
127
- }
128
- var assembled = (0, _shadertools.assembleShaders)(platformInfo, _objectSpread(_objectSpread({}, props), {}, {
129
- fs: props.fs,
130
- hookFunctions: this._hookFunctions
131
- }));
132
- var pipeline = this.device.createRenderPipeline(_objectSpread(_objectSpread({}, props), {}, {
133
- vs: this.device.createShader({
134
- stage: 'vertex',
135
- source: assembled.vs
136
- }),
137
- fs: assembled.fs ? this.device.createShader({
138
- stage: 'fragment',
139
- source: assembled.fs
140
- }) : null
141
- }));
142
- return {
143
- pipeline: pipeline,
144
- getUniforms: assembled.getUniforms
145
- };
146
- }
147
- }, {
148
- key: "_hashRenderPipeline",
149
- value: function _hashRenderPipeline(props) {
150
- var _this = this;
151
- var _props$modules = props.modules,
152
- modules = _props$modules === void 0 ? [] : _props$modules,
153
- _props$varyings = props.varyings,
154
- varyings = _props$varyings === void 0 ? [] : _props$varyings,
155
- _props$defines = props.defines,
156
- defines = _props$defines === void 0 ? {} : _props$defines,
157
- _props$inject = props.inject,
158
- inject = _props$inject === void 0 ? {} : _props$inject,
159
- _props$parameters = props.parameters,
160
- parameters = _props$parameters === void 0 ? {} : _props$parameters;
161
- var vsHash = this._getHash(props.vs);
162
- var fsHash = props.fs ? this._getHash(props.fs) : 0;
163
- var moduleHashes = modules.map(function (m) {
164
- return _this._getHash(typeof m === 'string' ? m : m.name);
165
- }).sort();
166
- var varyingHashes = varyings.map(function (v) {
167
- return _this._getHash(v);
168
- });
169
- var defineKeys = Object.keys(defines).sort();
170
- var injectKeys = Object.keys(inject).sort();
171
- var defineHashes = [];
172
- var injectHashes = [];
173
- var _iterator = _createForOfIteratorHelper(defineKeys),
174
- _step;
175
- try {
176
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
177
- var key = _step.value;
178
- defineHashes.push(this._getHash(key));
179
- defineHashes.push(this._getHash(String(defines[key])));
180
- }
181
- } catch (err) {
182
- _iterator.e(err);
183
- } finally {
184
- _iterator.f();
185
- }
186
- var _iterator2 = _createForOfIteratorHelper(injectKeys),
187
- _step2;
188
- try {
189
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
190
- var _key = _step2.value;
191
- injectHashes.push(this._getHash(_key));
192
- injectHashes.push(this._getHash(inject[_key]));
193
- }
194
- } catch (err) {
195
- _iterator2.e(err);
196
- } finally {
197
- _iterator2.f();
198
- }
199
- var parameterHash = JSON.stringify(parameters);
200
- return "".concat(vsHash, "/").concat(fsHash, "D").concat(defineHashes.join('/'), "M").concat(moduleHashes.join('/'), "I").concat(injectHashes.join('/'), "V").concat(varyingHashes.join('/'), "H").concat(this.stateHash, "B").concat(props.bufferMode).concat(props.transpileToGLSL100 ? 'T' : '', "P").concat(parameterHash);
201
- }
202
- }, {
203
- key: "_getHash",
204
- value: function _getHash(key) {
205
- if (this._hashes[key] === undefined) {
206
- this._hashes[key] = this._hashCounter++;
207
- }
208
- return this._hashes[key];
209
- }
210
- }, {
211
- key: "_getModuleList",
212
- value: function _getModuleList() {
213
- var appModules = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
214
- var modules = new Array(this._defaultModules.length + appModules.length);
215
- var seen = {};
216
- var count = 0;
217
- for (var i = 0, len = this._defaultModules.length; i < len; ++i) {
218
- var module = this._defaultModules[i];
219
- var name = module.name;
220
- modules[count++] = module;
221
- seen[name] = true;
222
- }
223
- for (var _i = 0, _len = appModules.length; _i < _len; ++_i) {
224
- var _module = appModules[_i];
225
- var _name = _module.name;
226
- if (!seen[_name]) {
227
- modules[count++] = _module;
228
- seen[_name] = true;
229
- }
230
- }
231
- modules.length = count;
232
- return modules;
233
- }
234
- }], [{
235
- key: "getDefaultPipelineFactory",
236
- value: function getDefaultPipelineFactory(device) {
237
- device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);
238
- return device.defaultPipelineFactory;
239
- }
240
- }]);
241
- return PipelineFactory;
242
- }();
243
- exports.PipelineFactory = PipelineFactory;
244
- //# sourceMappingURL=pipeline-factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipeline-factory.js","names":["_shadertools","require","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","i","F","s","n","done","value","e","_e","f","TypeError","normalCompletion","didErr","err","call","step","next","_e2","return","minLen","_arrayLikeToArray","Object","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","ownKeys","object","enumerableOnly","keys","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","arguments","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","DEFAULT_RENDER_PIPELINE_OPTIONS","vs","fs","modules","defines","inject","transpileToGLSL100","layout","varyings","bufferMode","topology","parameters","PipelineFactory","device","_classCallCheck2","_createClass2","addDefaultModule","module","_defaultModules","find","m","stateHash","removeDefaultModule","moduleName","addShaderHook","hook","opts","assign","_hookFunctions","createRenderPipeline","options","props","_getModuleList","hash","_hashRenderPipeline","_pipelineCache","_this$_createRenderPi","_createRenderPipeline","pipeline","getUniforms","_getUniforms","x","_useCounts","release","destroy","platformInfo","gpu","info","features","Error","assembled","assembleShaders","hookFunctions","createShader","stage","_this","_props$modules","_props$varyings","_props$defines","_props$inject","_props$parameters","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","injectKeys","defineHashes","injectHashes","_iterator","_step","String","_iterator2","_step2","parameterHash","JSON","stringify","concat","join","_hashes","undefined","_hashCounter","appModules","seen","count","getDefaultPipelineFactory","defaultPipelineFactory","exports"],"sources":["../../../src/lib/pipeline-factory.ts"],"sourcesContent":["import type {RenderPipelineParameters, PrimitiveTopology, ShaderLayout} from '@luma.gl/api';\nimport {Device, RenderPipeline} from '@luma.gl/api/';\nimport type { ShaderModule } from '@luma.gl/shadertools';\nimport {assembleShaders} from '@luma.gl/shadertools';\n\nexport type GetRenderPipelineOptions = {\n vs: string;\n fs: string | null;\n topology: PrimitiveTopology;\n layout?: ShaderLayout | null;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string | number | boolean>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number, \n};\n\nexport type GetComputePipelineOptions = {\n cs: string;\n parameters?: RenderPipelineParameters;\n\n modules?: ShaderModule[];\n defines?: Record<string, string>;\n inject?: Record<string, string>;\n transpileToGLSL100?: boolean;\n\n varyings?: string[];\n bufferMode?: number;\n};\n\nconst DEFAULT_RENDER_PIPELINE_OPTIONS: Required<GetRenderPipelineOptions> = {\n vs: '',\n fs: '',\n modules: [],\n defines: {},\n inject: {},\n transpileToGLSL100: false,\n layout: null,\n\n varyings: [],\n bufferMode: 0x8c8d, // // varyings/bufferMode for xform feedback, 0x8c8d: SEPARATE_ATTRIBS\n topology: 'triangle-list',\n parameters: {} \n};\n\ntype GetUniformsFunc = (props?: Record<string, any>) => Record<string, any>;\n\n/** Efficiently create shared pipelines with varying parameters */\nexport class PipelineFactory {\n readonly device: Device;\n\n stateHash: number = 0; // Used to change hashing if hooks are modified\n private _hashCounter: number = 0;\n private readonly _hashes: Record<string, number> = {};\n private readonly _useCounts: Record<string, number> = {};\n\n private readonly _pipelineCache: Record<string, RenderPipeline> = {};\n\n private readonly _getUniforms: Record<string, GetUniformsFunc> = {};\n private readonly _hookFunctions: any[] = [];\n private _defaultModules: any[] = [];\n // private readonly _registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n\n static getDefaultPipelineFactory(device: Device): PipelineFactory {\n // @ts-expect-error Add to device\n device.defaultPipelineFactory = device.defaultPipelineFactory || new PipelineFactory(device);\n // @ts-expect-error Add to device\n return device.defaultPipelineFactory;\n }\n\n constructor(device: Device) {\n this.device = device;\n }\n\n addDefaultModule(module: ShaderModule): void {\n if (!this._defaultModules.find((m) => m.name === (typeof module === 'string' ? module : module.name))) {\n this._defaultModules.push(module);\n }\n this.stateHash++;\n }\n\n removeDefaultModule(module: ShaderModule): void {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter((m) => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook: string, opts?: any): void {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n this._hookFunctions.push(hook);\n this.stateHash++;\n }\n\n createRenderPipeline(options: GetRenderPipelineOptions): {\n pipeline: RenderPipeline;\n getUniforms: GetUniformsFunc;\n } {\n const props: Required<GetRenderPipelineOptions> = {...DEFAULT_RENDER_PIPELINE_OPTIONS, ...options};\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const hash = this._hashRenderPipeline({...props, modules});\n\n if (!this._pipelineCache[hash]) {\n const {pipeline, getUniforms} = this._createRenderPipeline({...props, modules});\n pipeline.hash = hash;\n this._pipelineCache[hash] = pipeline;\n this._getUniforms[hash] = getUniforms || ((x?: unknown) => ({}));\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return {\n pipeline: this._pipelineCache[hash],\n getUniforms: this._getUniforms[hash]\n };\n }\n\n release(pipeline: RenderPipeline): void {\n const hash = pipeline.hash;\n this._useCounts[hash]--;\n if (this._useCounts[hash] === 0) {\n this._pipelineCache[hash].destroy();\n delete this._pipelineCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n getUniforms(pipeline: RenderPipeline) {\n return this._getUniforms[pipeline.hash] || null;\n }\n\n // PRIVATE\n\n _createRenderPipeline(props: GetRenderPipelineOptions): {\n pipeline: RenderPipeline,\n getUniforms: GetUniformsFunc\n } {\n const platformInfo = {\n gpu: this.device.info.gpu,\n features: this.device.features\n };\n\n if (!props.fs) {\n throw new Error('fs');\n }\n\n const assembled = assembleShaders(platformInfo, {...props, fs: props.fs, hookFunctions: this._hookFunctions});\n\n const pipeline = this.device.createRenderPipeline({\n ...props,\n vs: this.device.createShader({stage: 'vertex', source: assembled.vs}),\n fs: assembled.fs ? this.device.createShader({stage: 'fragment', source: assembled.fs}) : null,\n });\n\n return {pipeline, getUniforms: assembled.getUniforms};\n }\n\n /** Calculate a hash based on all the inputs for a render pipeline */\n _hashRenderPipeline(props: GetRenderPipelineOptions): string {\n const {modules = [], varyings = [], defines = {}, inject = {}, parameters = {}} = props;\n const vsHash = this._getHash(props.vs);\n const fsHash = props.fs ? this._getHash(props.fs) : 0;\n\n const moduleHashes = modules.map((m) => this._getHash(typeof m === 'string' ? m : m.name)).sort();\n const varyingHashes = varyings.map((v) => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes: number[] = [];\n const injectHashes: number[] = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(String(defines[key])));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n // TODO - hash parameters!\n const parameterHash = JSON.stringify(parameters);\n\n return `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${props.bufferMode}${\n props.transpileToGLSL100 ? 'T' : ''\n }P${parameterHash}`;\n }\n\n _getHash(key: string): number {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n return this._hashes[key];\n }\n\n // Dedupe and combine with default modules\n _getModuleList(appModules: ShaderModule[] = []): ShaderModule[] {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen: Record<string, boolean> = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules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;AAAA;AAAA+E,OAAA,CAAA/E,eAAA,GAAAA,eAAA"}
@@ -1,57 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- export class KeyFrames {
3
- constructor(keyFrames) {
4
- _defineProperty(this, "startIndex", -1);
5
- _defineProperty(this, "endIndex", -1);
6
- _defineProperty(this, "factor", 0);
7
- _defineProperty(this, "times", []);
8
- _defineProperty(this, "values", []);
9
- _defineProperty(this, "_lastTime", -1);
10
- this.setKeyFrames(keyFrames);
11
- this.setTime(0);
12
- }
13
- setKeyFrames(keyFrames) {
14
- const numKeys = keyFrames.length;
15
- this.times.length = numKeys;
16
- this.values.length = numKeys;
17
- for (let i = 0; i < numKeys; ++i) {
18
- this.times[i] = keyFrames[i][0];
19
- this.values[i] = keyFrames[i][1];
20
- }
21
- this._calculateKeys(this._lastTime);
22
- }
23
- setTime(time) {
24
- time = Math.max(0, time);
25
- if (time !== this._lastTime) {
26
- this._calculateKeys(time);
27
- this._lastTime = time;
28
- }
29
- }
30
- getStartTime() {
31
- return this.times[this.startIndex];
32
- }
33
- getEndTime() {
34
- return this.times[this.endIndex];
35
- }
36
- getStartData() {
37
- return this.values[this.startIndex];
38
- }
39
- getEndData() {
40
- return this.values[this.endIndex];
41
- }
42
- _calculateKeys(time) {
43
- let index = 0;
44
- const numKeys = this.times.length;
45
- for (index = 0; index < numKeys - 2; ++index) {
46
- if (this.times[index + 1] > time) {
47
- break;
48
- }
49
- }
50
- this.startIndex = index;
51
- this.endIndex = index + 1;
52
- const startTime = this.times[this.startIndex];
53
- const endTime = this.times[this.endIndex];
54
- this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);
55
- }
56
- }
57
- //# sourceMappingURL=key-frames.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-frames.js","names":["KeyFrames","constructor","keyFrames","_defineProperty","setKeyFrames","setTime","numKeys","length","times","values","i","_calculateKeys","_lastTime","time","Math","max","getStartTime","startIndex","getEndTime","endIndex","getStartData","getEndData","index","startTime","endTime","factor","min"],"sources":["../../../src/animation/key-frames.ts"],"sourcesContent":["// keyframes\nexport type KeyFrame<T> = [number, T];\n\n/** Holds a list of key frames (timestamped values) */\nexport class KeyFrames<T = number> {\n startIndex: number = -1;\n endIndex: number = -1;\n factor: number = 0;\n times: number[] = [];\n values: T[] = [];\n private _lastTime = -1;\n\n constructor(keyFrames: KeyFrame<T>[]) {\n this.setKeyFrames(keyFrames);\n this.setTime(0);\n }\n\n setKeyFrames(keyFrames: KeyFrame<T>[]): void {\n const numKeys = keyFrames.length;\n this.times.length = numKeys;\n this.values.length = numKeys;\n\n for (let i = 0; i < numKeys; ++i) {\n this.times[i] = keyFrames[i][0];\n this.values[i] = keyFrames[i][1];\n }\n\n this._calculateKeys(this._lastTime);\n }\n\n setTime(time: number): void {\n time = Math.max(0, time);\n\n if (time !== this._lastTime) {\n this._calculateKeys(time);\n this._lastTime = time;\n }\n }\n\n getStartTime(): number {\n return this.times[this.startIndex];\n }\n\n getEndTime(): number {\n return this.times[this.endIndex];\n }\n\n getStartData(): T {\n return this.values[this.startIndex];\n }\n\n getEndData(): T {\n return this.values[this.endIndex];\n }\n\n _calculateKeys(time: number): void {\n let index = 0;\n const numKeys = this.times.length;\n\n for (index = 0; index < numKeys - 2; ++index) {\n if (this.times[index + 1] > time) {\n break;\n }\n }\n\n this.startIndex = index;\n this.endIndex = index + 1;\n\n const startTime = this.times[this.startIndex];\n const endTime = this.times[this.endIndex];\n this.factor = Math.min(Math.max(0, (time - startTime) / (endTime - startTime)), 1);\n }\n}\n"],"mappings":";AAIA,OAAO,MAAMA,SAAS,CAAa;EAQjCC,WAAWA,CAACC,SAAwB,EAAE;IAAAC,eAAA,qBAPjB,CAAC,CAAC;IAAAA,eAAA,mBACJ,CAAC,CAAC;IAAAA,eAAA,iBACJ,CAAC;IAAAA,eAAA,gBACA,EAAE;IAAAA,eAAA,iBACN,EAAE;IAAAA,eAAA,oBACI,CAAC,CAAC;IAGpB,IA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AR,cAAcA,CAACE,IAAY,EAAQ;IACjC,IAAIS,KAAK,GAAG,CAAC;IACb,MAAMhB,OAAO,GAAG,IAAI,CAACE,KAAK,CAACD,MAAM;IAEjC,KAAKe,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAGhB,OAAO,GAAG,CAAC,EAAE,EAAEgB,KAAK,EAAE;MAC5C,IAAI,IAAI,CAACd,KAAK,CAACc,KAAK,GAAG,CAAC,CAAC,GAAGT,IAAI,EAAE;QAChC;MACF;IACF;IAEA,IAAI,CAACI,UAAU,GAAGK,KAAK;IACvB,IAAI,CAACH,QAAQ,GAAGG,KAAK,GAAG,CAAC;IAEzB,MAAMC,SAAS,GAAG,IAAI,CAACf,KAAK,CAAC,IAAI,CAACS,UAAU,CAAC;IAC7C,MAAMO,OAAO,GAAG,IAAI,CAAChB,KAAK,CAAC,IAAI,CAACW,QAAQ,CAAC;IACzC,IAAI,CAACM,MAAM,GAAGX,IAAI,CAACY,GAAG,CAACZ,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE,CAACF,IAAI,GAAGU,SAAS,KAAKC,OAAO,GAAGD,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;EACpF;AACF"}
@@ -1,113 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- let channelHandles = 1;
3
- let animationHandles = 1;
4
- export class Timeline {
5
- constructor() {
6
- _defineProperty(this, "time", 0);
7
- _defineProperty(this, "channels", new Map());
8
- _defineProperty(this, "animations", new Map());
9
- _defineProperty(this, "playing", false);
10
- _defineProperty(this, "lastEngineTime", -1);
11
- }
12
- addChannel(props) {
13
- const {
14
- delay = 0,
15
- duration = Number.POSITIVE_INFINITY,
16
- rate = 1,
17
- repeat = 1
18
- } = props;
19
- const handle = channelHandles++;
20
- const channel = {
21
- time: 0,
22
- delay,
23
- duration,
24
- rate,
25
- repeat
26
- };
27
- this._setChannelTime(channel, this.time);
28
- this.channels.set(handle, channel);
29
- return handle;
30
- }
31
- removeChannel(handle) {
32
- this.channels.delete(handle);
33
- for (const [animationHandle, animation] of this.animations) {
34
- if (animation.channel === handle) {
35
- this.detachAnimation(animationHandle);
36
- }
37
- }
38
- }
39
- isFinished(handle) {
40
- const channel = this.channels.get(handle);
41
- if (channel === undefined) {
42
- return false;
43
- }
44
- return this.time >= channel.delay + channel.duration * channel.repeat;
45
- }
46
- getTime(handle) {
47
- if (handle === undefined) {
48
- return this.time;
49
- }
50
- const channel = this.channels.get(handle);
51
- if (channel === undefined) {
52
- return -1;
53
- }
54
- return channel.time;
55
- }
56
- setTime(time) {
57
- this.time = Math.max(0, time);
58
- const channels = this.channels.values();
59
- for (const channel of channels) {
60
- this._setChannelTime(channel, this.time);
61
- }
62
- const animations = this.animations.values();
63
- for (const animationData of animations) {
64
- const {
65
- animation,
66
- channel
67
- } = animationData;
68
- animation.setTime(this.getTime(channel));
69
- }
70
- }
71
- play() {
72
- this.playing = true;
73
- }
74
- pause() {
75
- this.playing = false;
76
- this.lastEngineTime = -1;
77
- }
78
- reset() {
79
- this.setTime(0);
80
- }
81
- attachAnimation(animation, channelHandle) {
82
- const animationHandle = animationHandles++;
83
- this.animations.set(animationHandle, {
84
- animation,
85
- channel: channelHandle
86
- });
87
- animation.setTime(this.getTime(channelHandle));
88
- return animationHandle;
89
- }
90
- detachAnimation(handle) {
91
- this.animations.delete(handle);
92
- }
93
- update(engineTime) {
94
- if (this.playing) {
95
- if (this.lastEngineTime === -1) {
96
- this.lastEngineTime = engineTime;
97
- }
98
- this.setTime(this.time + (engineTime - this.lastEngineTime));
99
- this.lastEngineTime = engineTime;
100
- }
101
- }
102
- _setChannelTime(channel, time) {
103
- const offsetTime = time - channel.delay;
104
- const totalDuration = channel.duration * channel.repeat;
105
- if (offsetTime >= totalDuration) {
106
- channel.time = channel.duration * channel.rate;
107
- } else {
108
- channel.time = Math.max(0, offsetTime) % channel.duration;
109
- channel.time *= channel.rate;
110
- }
111
- }
112
- }
113
- //# sourceMappingURL=timeline.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"timeline.js","names":["channelHandles","animationHandles","Timeline","constructor","_defineProperty","Map","addChannel","props","delay","duration","Number","POSITIVE_INFINITY","rate","repeat","handle","channel","time","_setChannelTime","channels","set","removeChannel","delete","animationHandle","animation","animations","detachAnimation","isFinished","get","undefined","getTime","setTime","Math","max","values","animationData","play","playing","pause","lastEngineTime","reset","attachAnimation","channelHandle","update","engineTime","offsetTime","totalDuration"],"sources":["../../../src/animation/timeline.ts"],"sourcesContent":["// luma.gl, MIT license\n\n/**\n * Timeline channel properties\n * @param delay = 0;\n * @param duration = Number.POSITIVE_INFINITY;\n * @param rate = 1\n * @param repeat = 1\n */\n export type ChannelOptions = {\n delay?: number\n duration?: number\n rate?: number\n repeat?: number\n}\n\nexport type AnimationOptions = {\n setTime: (time: number) => void\n}\n\n type Channel = {\n time: number\n delay: number\n duration: number\n rate: number\n repeat: number\n}\n\ntype Animation = {\n channel?: number;\n animation: {\n setTime: (time: number) => void\n }\n}\n\nlet channelHandles = 1;\nlet animationHandles = 1;\n\nexport class Timeline {\n time: number = 0;\n channels = new Map<number, Channel>();\n animations = new Map<number, Animation>();\n playing: boolean = false;\n lastEngineTime: number = -1;\n\n constructor() {\n }\n\n addChannel(props: ChannelOptions): number {\n const {delay = 0, duration = Number.POSITIVE_INFINITY, rate = 1, repeat = 1} = props;\n\n const handle = channelHandles++;\n const channel: Channel = {\n time: 0,\n delay,\n duration,\n rate,\n repeat\n };\n this._setChannelTime(channel, this.time);\n this.channels.set(handle, channel);\n\n return handle;\n }\n\n removeChannel(handle: number): void {\n this.channels.delete(handle);\n\n for (const [animationHandle, animation] of this.animations) {\n if (animation.channel === handle) {\n this.detachAnimation(animationHandle);\n }\n }\n }\n\n isFinished(handle: number): boolean {\n const channel = this.channels.get(handle);\n if (channel === undefined) {\n return false;\n }\n\n return this.time >= channel.delay + channel.duration * channel.repeat;\n }\n\n getTime(handle?: number): number {\n if (handle === undefined) {\n return this.time;\n }\n\n const channel = this.channels.get(handle);\n\n if (channel === undefined) {\n return -1;\n }\n\n return channel.time;\n }\n\n setTime(time: number): void {\n this.time = Math.max(0, time);\n\n const channels = this.channels.values();\n for (const channel of channels) {\n this._setChannelTime(channel, this.time);\n }\n\n const animations = this.animations.values();\n for (const animationData of animations) {\n const {animation, channel} = animationData;\n animation.setTime(this.getTime(channel));\n }\n }\n\n play(): void {\n this.playing = true;\n }\n\n pause(): void {\n this.playing = false;\n this.lastEngineTime = -1;\n }\n\n reset(): void {\n this.setTime(0);\n }\n\n attachAnimation(animation: AnimationOptions, channelHandle?: number): number {\n const animationHandle = animationHandles++;\n\n this.animations.set(animationHandle, {\n animation,\n channel: channelHandle\n });\n\n animation.setTime(this.getTime(channelHandle));\n\n return animationHandle;\n }\n\n detachAnimation(handle: number): void {\n this.animations.delete(handle);\n }\n\n update(engineTime: number): void {\n if (this.playing) {\n if (this.lastEngineTime === -1) {\n this.lastEngineTime = engineTime;\n }\n this.setTime(this.time + (engineTime - this.lastEngineTime));\n this.lastEngineTime = engineTime;\n }\n }\n\n _setChannelTime(channel: Channel, time: number): void {\n const offsetTime = time - channel.delay;\n const totalDuration = channel.duration * channel.repeat;\n // Note(Tarek): Don't loop on final repeat.\n if (offsetTime >= totalDuration) {\n channel.time = channel.duration * channel.rate;\n } else {\n channel.time = Math.max(0, offsetTime) % channel.duration;\n channel.time *= channel.rate;\n }\n }\n}\n"],"mappings":";AAmCA,IAAIA,cAAc,GAAG,CAAC;AACtB,IAAIC,gBAAgB,GAAG,CAAC;AAExB,OAAO,MAAMC,QAAQ,CAAC;EAOpBC,WAAWA,CAAA,EAAG;IAAAC,eAAA,eANC,CAAC;IAAAA,eAAA,mBACL,IAAIC,GAAG,EAAmB;IAAAD,eAAA,qBACxB,IAAIC,GAAG,EAAqB;IAAAD,eAAA,kBACtB,KAAK;IAAAA,eAAA,yBACC,CAAC,CAAC;EAG3B;EAEAE,UAAUA,CAACC,KAAqB,EAAU;IACxC,MAAM;MAACC,KAAK,GAA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