GeometryOffsetAttribute-ca302482.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Cesium - https://github.com/AnalyticalGraphicsInc/cesium
  3. *
  4. * Copyright 2011-2017 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/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
  22. */
  23. define(['exports', './when-8d13db60', './Check-70bec281'], function (exports, when, Check) { 'use strict';
  24. /**
  25. * Fill an array or a portion of an array with a given value.
  26. *
  27. * @param {Array} array The array to fill.
  28. * @param {*} value The value to fill the array with.
  29. * @param {Number} [start=0] The index to start filling at.
  30. * @param {Number} [end=array.length] The index to end stop at.
  31. *
  32. * @returns {Array} The resulting array.
  33. * @private
  34. */
  35. function arrayFill(array, value, start, end) {
  36. //>>includeStart('debug', pragmas.debug);
  37. Check.Check.defined('array', array);
  38. Check.Check.defined('value', value);
  39. if (when.defined(start)) {
  40. Check.Check.typeOf.number('start', start);
  41. }
  42. if (when.defined(end)) {
  43. Check.Check.typeOf.number('end', end);
  44. }
  45. //>>includeEnd('debug');
  46. if (typeof array.fill === 'function') {
  47. return array.fill(value, start, end);
  48. }
  49. var length = array.length >>> 0;
  50. var relativeStart = when.defaultValue(start, 0);
  51. // If negative, find wrap around position
  52. var k = (relativeStart < 0) ? Math.max(length + relativeStart, 0) : Math.min(relativeStart, length);
  53. var relativeEnd = when.defaultValue(end, length);
  54. // If negative, find wrap around position
  55. var last = (relativeEnd < 0) ? Math.max(length + relativeEnd, 0) : Math.min(relativeEnd, length);
  56. // Fill array accordingly
  57. while (k < last) {
  58. array[k] = value;
  59. k++;
  60. }
  61. return array;
  62. }
  63. /**
  64. * Represents which vertices should have a value of `true` for the `applyOffset` attribute
  65. * @private
  66. */
  67. var GeometryOffsetAttribute = {
  68. NONE : 0,
  69. TOP : 1,
  70. ALL : 2
  71. };
  72. var GeometryOffsetAttribute$1 = Object.freeze(GeometryOffsetAttribute);
  73. exports.GeometryOffsetAttribute = GeometryOffsetAttribute$1;
  74. exports.arrayFill = arrayFill;
  75. });