createGeometry.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Cesium - https://github.com/CesiumGS/cesium
  3. *
  4. * Copyright 2011-2020 Cesium Contributors
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * Columbus View (Pat. Pend.)
  19. *
  20. * Portions licensed separately.
  21. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
  22. */
  23. define(['./defaultValue-81eec7ed', './PrimitivePipeline-ed21cfbb', './createTaskProcessorWorker', './Transforms-f0a54c7b', './Matrix2-d35cf4b5', './RuntimeError-8952249c', './ComponentDatatype-9e86ac8f', './WebGLConstants-508b9636', './_commonjsHelpers-3aae1032-26891ab7', './combine-3c023bda', './GeometryAttribute-eeb38987', './GeometryAttributes-32b29525', './GeometryPipeline-55e02a41', './AttributeCompression-d0b97a83', './EncodedCartesian3-530d5328', './IndexDatatype-bed3935d', './IntersectionTests-a25e058d', './Plane-24f22488', './WebMercatorProjection-2d464b74'], (function (defaultValue, PrimitivePipeline, createTaskProcessorWorker, Transforms, Matrix2, RuntimeError, ComponentDatatype, WebGLConstants, _commonjsHelpers3aae1032, combine, GeometryAttribute, GeometryAttributes, GeometryPipeline, AttributeCompression, EncodedCartesian3, IndexDatatype, IntersectionTests, Plane, WebMercatorProjection) { 'use strict';
  24. /* global require */
  25. const moduleCache = {};
  26. function getModule(moduleName) {
  27. let module = moduleCache[moduleName];
  28. if (!defaultValue.defined(module)) {
  29. if (typeof exports === "object") {
  30. // Use CommonJS-style require.
  31. moduleCache[module] = module = require(`Workers/${moduleName}`);
  32. } else {
  33. // Use AMD-style require.
  34. // in web workers, require is synchronous
  35. require([`Workers/${moduleName}`], function (f) {
  36. module = f;
  37. moduleCache[module] = f;
  38. });
  39. }
  40. }
  41. return module;
  42. }
  43. function createGeometry(parameters, transferableObjects) {
  44. const subTasks = parameters.subTasks;
  45. const length = subTasks.length;
  46. const resultsOrPromises = new Array(length);
  47. for (let i = 0; i < length; i++) {
  48. const task = subTasks[i];
  49. const geometry = task.geometry;
  50. const moduleName = task.moduleName;
  51. if (defaultValue.defined(moduleName)) {
  52. const createFunction = getModule(moduleName);
  53. resultsOrPromises[i] = createFunction(geometry, task.offset);
  54. } else {
  55. //Already created geometry
  56. resultsOrPromises[i] = geometry;
  57. }
  58. }
  59. return Promise.all(resultsOrPromises).then(function (results) {
  60. return PrimitivePipeline.PrimitivePipeline.packCreateGeometryResults(
  61. results,
  62. transferableObjects
  63. );
  64. });
  65. }
  66. var createGeometry$1 = createTaskProcessorWorker(createGeometry);
  67. return createGeometry$1;
  68. }));
  69. //# sourceMappingURL=createGeometry.js.map