@math.gl/culling 3.5.6 → 3.6.0-alpha.1

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 (132) hide show
  1. package/dist/constants.d.ts +6 -0
  2. package/dist/constants.d.ts.map +1 -0
  3. package/dist/constants.js +8 -0
  4. package/dist/es5/constants.js +7 -5
  5. package/dist/es5/constants.js.map +1 -1
  6. package/dist/es5/index.js +12 -24
  7. package/dist/es5/index.js.map +1 -1
  8. package/dist/es5/lib/algorithms/bounding-box-from-points.js +72 -123
  9. package/dist/es5/lib/algorithms/bounding-box-from-points.js.map +1 -1
  10. package/dist/es5/lib/algorithms/bounding-sphere-from-points.js +81 -109
  11. package/dist/es5/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
  12. package/dist/es5/lib/algorithms/compute-eigen-decomposition.js +36 -37
  13. package/dist/es5/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
  14. package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js +68 -74
  15. package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
  16. package/dist/es5/lib/bounding-volumes/bounding-sphere.js +93 -110
  17. package/dist/es5/lib/bounding-volumes/bounding-sphere.js.map +1 -1
  18. package/dist/es5/lib/bounding-volumes/bounding-volume.js +2 -0
  19. package/dist/es5/lib/bounding-volumes/bounding-volume.js.map +1 -0
  20. package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js +190 -211
  21. package/dist/es5/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
  22. package/dist/es5/lib/culling-volume.js +80 -131
  23. package/dist/es5/lib/culling-volume.js.map +1 -1
  24. package/dist/es5/lib/perspective-frustum.js +73 -84
  25. package/dist/es5/lib/perspective-frustum.js.map +1 -1
  26. package/dist/es5/lib/perspective-off-center-frustum.js +114 -117
  27. package/dist/es5/lib/perspective-off-center-frustum.js.map +1 -1
  28. package/dist/es5/lib/plane.js +55 -69
  29. package/dist/es5/lib/plane.js.map +1 -1
  30. package/dist/esm/constants.js +7 -5
  31. package/dist/esm/constants.js.map +1 -1
  32. package/dist/esm/index.js +0 -2
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/esm/lib/algorithms/bounding-box-from-points.js.map +1 -1
  35. package/dist/esm/lib/algorithms/bounding-sphere-from-points.js.map +1 -1
  36. package/dist/esm/lib/algorithms/compute-eigen-decomposition.js.map +1 -1
  37. package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js +15 -6
  38. package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
  39. package/dist/esm/lib/bounding-volumes/bounding-sphere.js +9 -4
  40. package/dist/esm/lib/bounding-volumes/bounding-sphere.js.map +1 -1
  41. package/dist/esm/lib/bounding-volumes/bounding-volume.js +2 -0
  42. package/dist/esm/lib/bounding-volumes/bounding-volume.js.map +1 -0
  43. package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js +5 -0
  44. package/dist/esm/lib/bounding-volumes/oriented-bounding-box.js.map +1 -1
  45. package/dist/esm/lib/culling-volume.js +10 -16
  46. package/dist/esm/lib/culling-volume.js.map +1 -1
  47. package/dist/esm/lib/perspective-frustum.js +31 -5
  48. package/dist/esm/lib/perspective-frustum.js.map +1 -1
  49. package/dist/esm/lib/perspective-off-center-frustum.js +31 -3
  50. package/dist/esm/lib/perspective-off-center-frustum.js.map +1 -1
  51. package/dist/esm/lib/plane.js +6 -1
  52. package/dist/esm/lib/plane.js.map +1 -1
  53. package/dist/index.d.ts +12 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +13 -0
  56. package/{src → dist}/lib/algorithms/bounding-box-from-points.d.ts +3 -10
  57. package/dist/lib/algorithms/bounding-box-from-points.d.ts.map +1 -0
  58. package/dist/lib/algorithms/bounding-box-from-points.js +131 -0
  59. package/dist/{esm/lib → lib}/algorithms/bounding-sphere-from-points.d.ts +2 -5
  60. package/dist/lib/algorithms/bounding-sphere-from-points.d.ts.map +1 -0
  61. package/dist/lib/algorithms/bounding-sphere-from-points.js +142 -0
  62. package/dist/{es5/lib → lib}/algorithms/compute-eigen-decomposition.d.ts +7 -9
  63. package/dist/lib/algorithms/compute-eigen-decomposition.d.ts.map +1 -0
  64. package/dist/lib/algorithms/compute-eigen-decomposition.js +131 -0
  65. package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +56 -0
  66. package/dist/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -0
  67. package/dist/lib/bounding-volumes/axis-aligned-bounding-box.js +111 -0
  68. package/dist/lib/bounding-volumes/bounding-sphere.d.ts +40 -0
  69. package/dist/lib/bounding-volumes/bounding-sphere.d.ts.map +1 -0
  70. package/dist/lib/bounding-volumes/bounding-sphere.js +118 -0
  71. package/dist/lib/bounding-volumes/bounding-volume.d.ts +30 -0
  72. package/dist/lib/bounding-volumes/bounding-volume.d.ts.map +1 -0
  73. package/dist/lib/bounding-volumes/bounding-volume.js +1 -0
  74. package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts +67 -0
  75. package/dist/lib/bounding-volumes/oriented-bounding-box.d.ts.map +1 -0
  76. package/dist/lib/bounding-volumes/oriented-bounding-box.js +256 -0
  77. package/dist/lib/culling-volume.d.ts +46 -0
  78. package/dist/lib/culling-volume.d.ts.map +1 -0
  79. package/dist/lib/culling-volume.js +121 -0
  80. package/dist/lib/perspective-frustum.d.ts +140 -0
  81. package/dist/lib/perspective-frustum.d.ts.map +1 -0
  82. package/dist/lib/perspective-frustum.js +205 -0
  83. package/dist/lib/perspective-off-center-frustum.d.ts +122 -0
  84. package/dist/lib/perspective-off-center-frustum.d.ts.map +1 -0
  85. package/dist/lib/perspective-off-center-frustum.js +305 -0
  86. package/dist/lib/plane.d.ts +26 -0
  87. package/dist/lib/plane.d.ts.map +1 -0
  88. package/dist/lib/plane.js +63 -0
  89. package/package.json +4 -4
  90. package/src/constants.ts +8 -0
  91. package/src/{index.js → index.ts} +0 -4
  92. package/src/lib/algorithms/{bounding-box-from-points.js → bounding-box-from-points.ts} +17 -4
  93. package/src/lib/algorithms/{bounding-sphere-from-points.js → bounding-sphere-from-points.ts} +15 -1
  94. package/src/lib/algorithms/{compute-eigen-decomposition.js → compute-eigen-decomposition.ts} +40 -1
  95. package/src/lib/bounding-volumes/{axis-aligned-bounding-box.js → axis-aligned-bounding-box.ts} +45 -14
  96. package/src/lib/bounding-volumes/{bounding-sphere.js → bounding-sphere.ts} +44 -29
  97. package/src/lib/bounding-volumes/{bounding-volume.d.ts → bounding-volume.ts} +7 -7
  98. package/src/lib/bounding-volumes/{oriented-bounding-box.js → oriented-bounding-box.ts} +72 -14
  99. package/src/lib/{culling-volume.js → culling-volume.ts} +42 -34
  100. package/src/lib/{perspective-frustum.js → perspective-frustum.ts} +48 -66
  101. package/src/lib/{perspective-off-center-frustum.js → perspective-off-center-frustum.ts} +24 -14
  102. package/src/lib/{plane.js → plane.ts} +24 -17
  103. package/dist/es5/constants.d.ts +0 -6
  104. package/dist/es5/index.d.ts +0 -20
  105. package/dist/es5/lib/algorithms/bounding-box-from-points.d.ts +0 -22
  106. package/dist/es5/lib/algorithms/bounding-sphere-from-points.d.ts +0 -17
  107. package/dist/es5/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
  108. package/dist/es5/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
  109. package/dist/es5/lib/bounding-volumes/bounding-volume.d.ts +0 -32
  110. package/dist/es5/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
  111. package/dist/es5/lib/culling-volume.d.ts +0 -55
  112. package/dist/es5/lib/plane.d.ts +0 -38
  113. package/dist/esm/constants.d.ts +0 -6
  114. package/dist/esm/index.d.ts +0 -20
  115. package/dist/esm/lib/algorithms/bounding-box-from-points.d.ts +0 -22
  116. package/dist/esm/lib/algorithms/compute-eigen-decomposition.d.ts +0 -39
  117. package/dist/esm/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
  118. package/dist/esm/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
  119. package/dist/esm/lib/bounding-volumes/bounding-volume.d.ts +0 -32
  120. package/dist/esm/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
  121. package/dist/esm/lib/culling-volume.d.ts +0 -55
  122. package/dist/esm/lib/plane.d.ts +0 -38
  123. package/src/constants.d.ts +0 -6
  124. package/src/constants.js +0 -8
  125. package/src/index.d.ts +0 -20
  126. package/src/lib/algorithms/bounding-sphere-from-points.d.ts +0 -17
  127. package/src/lib/algorithms/compute-eigen-decomposition.d.ts +0 -39
  128. package/src/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +0 -51
  129. package/src/lib/bounding-volumes/bounding-sphere.d.ts +0 -52
  130. package/src/lib/bounding-volumes/oriented-bounding-box.d.ts +0 -83
  131. package/src/lib/culling-volume.d.ts +0 -55
  132. package/src/lib/plane.d.ts +0 -38
@@ -7,9 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
11
 
14
12
  var _core = require("@math.gl/core");
15
13
 
@@ -17,152 +15,103 @@ var _constants = require("../constants");
17
15
 
18
16
  var _plane = _interopRequireDefault(require("./plane"));
19
17
 
20
- 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; } } }; }
21
-
22
- 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); }
23
-
24
- 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; }
25
-
26
- var faces = [new _core.Vector3([1, 0, 0]), new _core.Vector3([0, 1, 0]), new _core.Vector3([0, 0, 1])];
27
- var scratchPlaneCenter = new _core.Vector3();
28
- var scratchPlaneNormal = new _core.Vector3();
29
- var scratchPlane = new _plane.default(new _core.Vector3(1.0, 0.0, 0.0), 0.0);
18
+ const faces = [new _core.Vector3([1, 0, 0]), new _core.Vector3([0, 1, 0]), new _core.Vector3([0, 0, 1])];
19
+ const scratchPlaneCenter = new _core.Vector3();
20
+ const scratchPlaneNormal = new _core.Vector3();
21
+ const scratchPlane = new _plane.default(new _core.Vector3(1.0, 0.0, 0.0), 0.0);
30
22
 
31
- var CullingVolume = function () {
32
- function CullingVolume() {
33
- var planes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
34
- (0, _classCallCheck2.default)(this, CullingVolume);
23
+ class CullingVolume {
24
+ constructor(planes = []) {
25
+ (0, _defineProperty2.default)(this, "planes", void 0);
35
26
  this.planes = planes;
36
- (0, _core.assert)(this.planes.every(function (plane) {
37
- return plane instanceof _plane.default;
38
- }));
39
27
  }
40
28
 
41
- (0, _createClass2.default)(CullingVolume, [{
42
- key: "fromBoundingSphere",
43
- value: function fromBoundingSphere(boundingSphere) {
44
- this.planes.length = 2 * faces.length;
45
- var center = boundingSphere.center;
46
- var radius = boundingSphere.radius;
47
- var planeIndex = 0;
48
-
49
- var _iterator = _createForOfIteratorHelper(faces),
50
- _step;
51
-
52
- try {
53
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
54
- var faceNormal = _step.value;
55
- var plane0 = this.planes[planeIndex];
56
- var plane1 = this.planes[planeIndex + 1];
57
-
58
- if (!plane0) {
59
- plane0 = this.planes[planeIndex] = new _plane.default();
60
- }
61
-
62
- if (!plane1) {
63
- plane1 = this.planes[planeIndex + 1] = new _plane.default();
64
- }
65
-
66
- var plane0Center = scratchPlaneCenter.copy(faceNormal).scale(-radius).add(center);
67
- var plane0Distance = -faceNormal.dot(plane0Center);
68
- plane0.fromPointNormal(plane0Center, faceNormal);
69
- var plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center);
70
- var negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate();
71
- var plane1Distance = -negatedFaceNormal.dot(plane1Center);
72
- plane1.fromPointNormal(plane1Center, negatedFaceNormal);
73
- planeIndex += 2;
74
- }
75
- } catch (err) {
76
- _iterator.e(err);
77
- } finally {
78
- _iterator.f();
29
+ fromBoundingSphere(boundingSphere) {
30
+ this.planes.length = 2 * faces.length;
31
+ const center = boundingSphere.center;
32
+ const radius = boundingSphere.radius;
33
+ let planeIndex = 0;
34
+
35
+ for (const faceNormal of faces) {
36
+ let plane0 = this.planes[planeIndex];
37
+ let plane1 = this.planes[planeIndex + 1];
38
+
39
+ if (!plane0) {
40
+ plane0 = this.planes[planeIndex] = new _plane.default();
79
41
  }
80
42
 
81
- return this;
82
- }
83
- }, {
84
- key: "computeVisibility",
85
- value: function computeVisibility(boundingVolume) {
86
- (0, _core.assert)(boundingVolume);
87
- var intersect = _constants.INTERSECTION.INSIDE;
88
-
89
- var _iterator2 = _createForOfIteratorHelper(this.planes),
90
- _step2;
91
-
92
- try {
93
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
94
- var plane = _step2.value;
95
- var result = boundingVolume.intersectPlane(plane);
96
-
97
- switch (result) {
98
- case _constants.INTERSECTION.OUTSIDE:
99
- return _constants.INTERSECTION.OUTSIDE;
100
-
101
- case _constants.INTERSECTION.INTERSECTING:
102
- intersect = _constants.INTERSECTION.INTERSECTING;
103
- break;
104
-
105
- default:
106
- }
107
- }
108
- } catch (err) {
109
- _iterator2.e(err);
110
- } finally {
111
- _iterator2.f();
43
+ if (!plane1) {
44
+ plane1 = this.planes[planeIndex + 1] = new _plane.default();
112
45
  }
113
46
 
114
- return intersect;
47
+ const plane0Center = scratchPlaneCenter.copy(faceNormal).scale(-radius).add(center);
48
+ const plane0Distance = -faceNormal.dot(plane0Center);
49
+ plane0.fromPointNormal(plane0Center, faceNormal);
50
+ const plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center);
51
+ const negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate();
52
+ const plane1Distance = -negatedFaceNormal.dot(plane1Center);
53
+ plane1.fromPointNormal(plane1Center, negatedFaceNormal);
54
+ planeIndex += 2;
115
55
  }
116
- }, {
117
- key: "computeVisibilityWithPlaneMask",
118
- value: function computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {
119
- (0, _core.assert)(boundingVolume, 'boundingVolume is required.');
120
- (0, _core.assert)(Number.isFinite(parentPlaneMask), 'parentPlaneMask is required.');
121
-
122
- if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
123
- return parentPlaneMask;
124
- }
125
56
 
126
- var mask = CullingVolume.MASK_INSIDE;
127
- var planes = this.planes;
57
+ return this;
58
+ }
128
59
 
129
- for (var k = 0; k < this.planes.length; ++k) {
130
- var flag = k < 31 ? 1 << k : 0;
60
+ computeVisibility(boundingVolume) {
61
+ let intersect = _constants.INTERSECTION.INSIDE;
131
62
 
132
- if (k < 31 && (parentPlaneMask & flag) === 0) {
133
- continue;
134
- }
63
+ for (const plane of this.planes) {
64
+ const result = boundingVolume.intersectPlane(plane);
135
65
 
136
- var plane = planes[k];
137
- var result = boundingVolume.intersectPlane(plane);
66
+ switch (result) {
67
+ case _constants.INTERSECTION.OUTSIDE:
68
+ return _constants.INTERSECTION.OUTSIDE;
138
69
 
139
- if (result === _constants.INTERSECTION.OUTSIDE) {
140
- return CullingVolume.MASK_OUTSIDE;
141
- } else if (result === _constants.INTERSECTION.INTERSECTING) {
142
- mask |= flag;
143
- }
144
- }
70
+ case _constants.INTERSECTION.INTERSECTING:
71
+ intersect = _constants.INTERSECTION.INTERSECTING;
72
+ break;
145
73
 
146
- return mask;
147
- }
148
- }], [{
149
- key: "MASK_OUTSIDE",
150
- get: function get() {
151
- return 0xffffffff;
74
+ default:
75
+ }
152
76
  }
153
- }, {
154
- key: "MASK_INSIDE",
155
- get: function get() {
156
- return 0x00000000;
77
+
78
+ return intersect;
79
+ }
80
+
81
+ computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {
82
+ (0, _core.assert)(Number.isFinite(parentPlaneMask), 'parentPlaneMask is required.');
83
+
84
+ if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
85
+ return parentPlaneMask;
157
86
  }
158
- }, {
159
- key: "MASK_INDETERMINATE",
160
- get: function get() {
161
- return 0x7fffffff;
87
+
88
+ let mask = CullingVolume.MASK_INSIDE;
89
+ const planes = this.planes;
90
+
91
+ for (let k = 0; k < this.planes.length; ++k) {
92
+ const flag = k < 31 ? 1 << k : 0;
93
+
94
+ if (k < 31 && (parentPlaneMask & flag) === 0) {
95
+ continue;
96
+ }
97
+
98
+ const plane = planes[k];
99
+ const result = boundingVolume.intersectPlane(plane);
100
+
101
+ if (result === _constants.INTERSECTION.OUTSIDE) {
102
+ return CullingVolume.MASK_OUTSIDE;
103
+ } else if (result === _constants.INTERSECTION.INTERSECTING) {
104
+ mask |= flag;
105
+ }
162
106
  }
163
- }]);
164
- return CullingVolume;
165
- }();
107
+
108
+ return mask;
109
+ }
110
+
111
+ }
166
112
 
167
113
  exports.default = CullingVolume;
114
+ (0, _defineProperty2.default)(CullingVolume, "MASK_OUTSIDE", 0xffffffff);
115
+ (0, _defineProperty2.default)(CullingVolume, "MASK_INSIDE", 0x00000000);
116
+ (0, _defineProperty2.default)(CullingVolume, "MASK_INDETERMINATE", 0x7fffffff);
168
117
  //# sourceMappingURL=culling-volume.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/culling-volume.js"],"names":["faces","Vector3","scratchPlaneCenter","scratchPlaneNormal","scratchPlane","Plane","CullingVolume","planes","every","plane","boundingSphere","length","center","radius","planeIndex","faceNormal","plane0","plane1","plane0Center","copy","scale","add","plane0Distance","dot","fromPointNormal","plane1Center","negatedFaceNormal","negate","plane1Distance","boundingVolume","intersect","INTERSECTION","INSIDE","result","intersectPlane","OUTSIDE","INTERSECTING","parentPlaneMask","Number","isFinite","MASK_OUTSIDE","MASK_INSIDE","mask","k","flag"],"mappings":";;;;;;;;;;;;;AAIA;;AACA;;AACA;;;;;;;;AAGA,IAAMA,KAAK,GAAG,CAAC,IAAIC,aAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAD,EAAyB,IAAIA,aAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAzB,EAAiD,IAAIA,aAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAjD,CAAd;AAEA,IAAMC,kBAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,IAAME,kBAAkB,GAAG,IAAIF,aAAJ,EAA3B;AACA,IAAMG,YAAY,GAAG,IAAIC,cAAJ,CAAU,IAAIJ,aAAJ,CAAY,GAAZ,EAAiB,GAAjB,EAAsB,GAAtB,CAAV,EAAsC,GAAtC,CAArB;;IAGqBK,a;AAmBnB,2B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AK,IAAIoC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG,KAAKpC,MAAL,CAAYI,MAAhC,EAAwC,EAAEgC,CAA1C,EAA6C;AAE3C,YAAMC,IAAI,GAAGD,CAAC,GAAG,EAAJ,GAAS,KAAKA,CAAd,GAAkB,CAA/B;;AACA,YAAIA,CAAC,GAAG,EAAJ,IAAU,CAACN,eAAe,GAAGO,IAAnB,MAA6B,CAA3C,EAA8C;AAE5C;AACD;;AAED,YAAMnC,KAAK,GAAGF,MAAM,CAACoC,CAAD,CAApB;AACA,YAAMV,MAAM,GAAGJ,cAAc,CAACK,cAAf,CAA8BzB,KAA9B,CAAf;;AACA,YAAIwB,MAAM,KAAKF,wBAAaI,OAA5B,EAAqC;AACnC,iBAAO7B,aAAa,CAACkC,YAArB;AACD,SAFD,MAEO,IAAIP,MAAM,KAAKF,wBAAaK,YAA5B,EAA0C;AAC/CM,UAAAA,IAAI,IAAIE,IAAR;AACD;AACF;;AAED,aAAOF,IAAP;AACD;;;SAhID,eAA0B;AACxB,aAAO,UAAP;AACD;;;SAID,eAAyB;AACvB,aAAO,UAAP;AACD;;;SAID,eAAgC;AAC9B,aAAO,UAAP;AACD","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Vector3, Vector4, assert} from '@math.gl/core';\nimport {INTERSECTION} from '../constants';\nimport Plane from './plane';\n\n// X, Y, Z Unit vectors\nconst faces = [new Vector3([1, 0, 0]), new Vector3([0, 1, 0]), new Vector3([0, 0, 1])];\n\nconst scratchPlaneCenter = new Vector3();\nconst scratchPlaneNormal = new Vector3();\nconst scratchPlane = new Plane(new Vector3(1.0, 0.0, 0.0), 0.0);\n\n// A culling volume defined by planes.\nexport default class CullingVolume {\n // For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value\n // represents the case where the object bounding volume is entirely outside the culling volume.\n static get MASK_OUTSIDE() {\n return 0xffffffff;\n }\n\n // For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value\n // represents the case where the object bounding volume is entirely inside the culling volume.\n static get MASK_INSIDE() {\n return 0x00000000;\n }\n\n // For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value\n // represents the case where the object bounding volume (may) intersect all planes of the culling volume.\n static get MASK_INDETERMINATE() {\n return 0x7fffffff;\n }\n\n constructor(planes = []) {\n // {Cartesian4[]} [planes] An array of clipping planes.\n this.planes = planes;\n assert(this.planes.every((plane) => plane instanceof Plane));\n }\n\n // Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.\n // The planes are aligned to the x, y, and z axes in world coordinates.\n fromBoundingSphere(boundingSphere) {\n this.planes.length = 2 * faces.length;\n\n const center = boundingSphere.center;\n const radius = boundingSphere.radius;\n\n let planeIndex = 0;\n\n for (const faceNormal of faces) {\n let plane0 = this.planes[planeIndex];\n let plane1 = this.planes[planeIndex + 1];\n\n if (!plane0) {\n plane0 = this.planes[planeIndex] = new Plane();\n }\n if (!plane1) {\n plane1 = this.planes[planeIndex + 1] = new Plane();\n }\n\n const plane0Center = scratchPlaneCenter.copy(faceNormal).scale(-radius).add(center);\n const plane0Distance = -faceNormal.dot(plane0Center);\n\n plane0.fromPointNormal(plane0Center, faceNormal);\n\n const plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center);\n\n const negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate();\n\n const plane1Distance = -negatedFaceNormal.dot(plane1Center);\n\n plane1.fromPointNormal(plane1Center, negatedFaceNormal);\n\n planeIndex += 2;\n }\n\n return this;\n }\n\n // Determines whether a bounding volume intersects the culling volume.\n computeVisibility(boundingVolume) {\n assert(boundingVolume);\n // const planes = this.planes;\n let intersect = INTERSECTION.INSIDE;\n for (const plane of this.planes) {\n const result = boundingVolume.intersectPlane(plane);\n switch (result) {\n case INTERSECTION.OUTSIDE:\n // We are done\n return INTERSECTION.OUTSIDE;\n\n case INTERSECTION.INTERSECTING:\n // If no other intersection is outside, return INTERSECTING\n intersect = INTERSECTION.INTERSECTING;\n break;\n\n default:\n }\n }\n\n return intersect;\n }\n\n // Determines whether a bounding volume intersects the culling volume.\n /*\n * @param {Number} parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling\n * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then\n * the parent (and therefore this) volume is completely inside plane[planeIndex]\n * and that plane check can be skipped.\n */\n computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {\n assert(boundingVolume, 'boundingVolume is required.');\n assert(Number.isFinite(parentPlaneMask), 'parentPlaneMask is required.');\n\n if (\n parentPlaneMask === CullingVolume.MASK_OUTSIDE ||\n parentPlaneMask === CullingVolume.MASK_INSIDE\n ) {\n // parent is completely outside or completely inside, so this child is as well.\n return parentPlaneMask;\n }\n\n // Start with MASK_INSIDE (all zeros) so that after the loop, the return value can be compared with MASK_INSIDE.\n // (Because if there are fewer than 31 planes, the upper bits wont be changed.)\n let mask = CullingVolume.MASK_INSIDE;\n\n const planes = this.planes;\n for (let k = 0; k < this.planes.length; ++k) {\n // For k greater than 31 (since 31 is the maximum number of INSIDE/INTERSECTING bits we can store), skip the optimization.\n const flag = k < 31 ? 1 << k : 0;\n if (k < 31 && (parentPlaneMask & flag) === 0) {\n // boundingVolume is known to be INSIDE this plane.\n continue;\n }\n\n const plane = planes[k];\n const result = boundingVolume.intersectPlane(plane);\n if (result === INTERSECTION.OUTSIDE) {\n return CullingVolume.MASK_OUTSIDE;\n } else if (result === INTERSECTION.INTERSECTING) {\n mask |= flag;\n }\n }\n\n return mask;\n }\n}\n"],"file":"culling-volume.js"}
1
+ {"version":3,"sources":["../../../src/lib/culling-volume.ts"],"names":["faces","Vector3","scratchPlaneCenter","scratchPlaneNormal","scratchPlane","Plane","CullingVolume","constructor","planes","fromBoundingSphere","boundingSphere","length","center","radius","planeIndex","faceNormal","plane0","plane1","plane0Center","copy","scale","add","plane0Distance","dot","fromPointNormal","plane1Center","negatedFaceNormal","negate","plane1Distance","computeVisibility","boundingVolume","intersect","INTERSECTION","INSIDE","plane","result","intersectPlane","OUTSIDE","INTERSECTING","computeVisibilityWithPlaneMask","parentPlaneMask","Number","isFinite","MASK_OUTSIDE","MASK_INSIDE","mask","k","flag"],"mappings":";;;;;;;;;;;AAIA;;AACA;;AACA;;AAKA,MAAMA,KAAK,GAAG,CAAC,IAAIC,aAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAD,EAAyB,IAAIA,aAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAzB,EAAiD,IAAIA,aAAJ,CAAY,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,CAAZ,CAAjD,CAAd;AAEA,MAAMC,kBAAkB,GAAG,IAAID,aAAJ,EAA3B;AACA,MAAME,kBAAkB,GAAG,IAAIF,aAAJ,EAA3B;AACA,MAAMG,YAAY,GAAG,IAAIC,cAAJ,CAAU,IAAIJ,aAAJ,CAAY,GAAZ,EAAiB,GAAjB,EAAsB,GAAtB,CAAV,EAAsC,GAAtC,CAArB;;AAGe,MAAMK,aAAN,CAAoB;AA0BjCC,EAAAA,WAAW,CAACC,MAAe,GAAG,EAAnB,EAAuB;AAAA;AAChC,SAAKA,MAAL,GAAcA,MAAd;AACD;;AAMDC,EAAAA,kBAAkB,CAACC,cAAD,EAAgD;AAChE,SAAKF,MAAL,CAAYG,MAAZ,GAAqB,IAAIX,KAAK,CAACW,MAA/B;AAEA,UAAMC,MAAM,GAAGF,cAAc,CAACE,MAA9B;AACA,UAAMC,MAAM,GAAGH,cAAc,CAACG,MAA9B;AAEA,QAAIC,UAAU,GAAG,CAAjB;;AAEA,SAAK,MAAMC,UAAX,IAAyBf,KAAzB,EAAgC;AAC9B,UAAIgB,MAAM,GAAG,KAAKR,MAAL,CAAYM,UAAZ,CAAb;AACA,UAAIG,MAAM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is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Vector3, assert} from '@math.gl/core';\nimport {INTERSECTION} from '../constants';\nimport Plane from './plane';\nimport type {BoundingVolume} from './bounding-volumes/bounding-volume';\nimport type BoundingSphere from './bounding-volumes/bounding-sphere';\n\n// X, Y, Z Unit vectors\nconst faces = [new Vector3([1, 0, 0]), new Vector3([0, 1, 0]), new Vector3([0, 0, 1])];\n\nconst scratchPlaneCenter = new Vector3();\nconst scratchPlaneNormal = new Vector3();\nconst scratchPlane = new Plane(new Vector3(1.0, 0.0, 0.0), 0.0);\n\n/** A culling volume defined by planes. */\nexport default class CullingVolume {\n /**\n * For plane masks (as used in {@link CullingVolume#computeVisibilityWithPlaneMask}), this special value\n * represents the case where the object bounding volume is entirely outside the culling volume.\n */\n static MASK_OUTSIDE = 0xffffffff;\n\n /**\n * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value\n * represents the case where the object bounding volume is entirely inside the culling volume.\n */\n static MASK_INSIDE = 0x00000000;\n\n /**\n * For plane masks (as used in {@link CullingVolume.prototype.computeVisibilityWithPlaneMask}), this value\n * represents the case where the object bounding volume (may) intersect all planes of the culling volume.\n */\n static MASK_INDETERMINATE = 0x7fffffff;\n\n /** Array of clipping planes. */\n readonly planes: Plane[];\n\n /**\n * Create a new `CullingVolume` bounded by an array of clipping planed\n * @param planes Array of clipping planes.\n * */\n constructor(planes: Plane[] = []) {\n this.planes = planes;\n }\n\n /**\n * Constructs a culling volume from a bounding sphere. Creates six planes that create a box containing the sphere.\n * The planes are aligned to the x, y, and z axes in world coordinates.\n */\n fromBoundingSphere(boundingSphere: BoundingSphere): CullingVolume {\n this.planes.length = 2 * faces.length;\n\n const center = boundingSphere.center;\n const radius = boundingSphere.radius;\n\n let planeIndex = 0;\n\n for (const faceNormal of faces) {\n let plane0 = this.planes[planeIndex];\n let plane1 = this.planes[planeIndex + 1];\n\n if (!plane0) {\n plane0 = this.planes[planeIndex] = new Plane();\n }\n if (!plane1) {\n plane1 = this.planes[planeIndex + 1] = new Plane();\n }\n\n const plane0Center = scratchPlaneCenter.copy(faceNormal).scale(-radius).add(center);\n const plane0Distance = -faceNormal.dot(plane0Center);\n\n plane0.fromPointNormal(plane0Center, faceNormal);\n\n const plane1Center = scratchPlaneCenter.copy(faceNormal).scale(radius).add(center);\n\n const negatedFaceNormal = scratchPlaneNormal.copy(faceNormal).negate();\n\n const plane1Distance = -negatedFaceNormal.dot(plane1Center);\n\n plane1.fromPointNormal(plane1Center, negatedFaceNormal);\n\n planeIndex += 2;\n }\n\n return this;\n }\n\n /** Determines whether a bounding volume intersects the culling volume. */\n computeVisibility(boundingVolume: BoundingVolume): INTERSECTION {\n // const planes = this.planes;\n let intersect = INTERSECTION.INSIDE;\n for (const plane of this.planes) {\n const result = boundingVolume.intersectPlane(plane);\n switch (result) {\n case INTERSECTION.OUTSIDE:\n // We are done\n return INTERSECTION.OUTSIDE;\n\n case INTERSECTION.INTERSECTING:\n // If no other intersection is outside, return INTERSECTING\n intersect = INTERSECTION.INTERSECTING;\n break;\n\n default:\n }\n }\n\n return intersect;\n }\n\n /**\n * Determines whether a bounding volume intersects the culling volume.\n *\n * @param parentPlaneMask A bit mask from the boundingVolume's parent's check against the same culling\n * volume, such that if (planeMask & (1 << planeIndex) === 0), for k < 31, then\n * the parent (and therefore this) volume is completely inside plane[planeIndex]\n * and that plane check can be skipped.\n */\n computeVisibilityWithPlaneMask(boundingVolume: BoundingVolume, parentPlaneMask: number): number {\n assert(Number.isFinite(parentPlaneMask), 'parentPlaneMask is required.');\n\n if (\n parentPlaneMask === CullingVolume.MASK_OUTSIDE ||\n parentPlaneMask === CullingVolume.MASK_INSIDE\n ) {\n // parent is completely outside or completely inside, so this child is as well.\n return parentPlaneMask;\n }\n\n // Start with MASK_INSIDE (all zeros) so that after the loop, the return value can be compared with MASK_INSIDE.\n // (Because if there are fewer than 31 planes, the upper bits wont be changed.)\n let mask = CullingVolume.MASK_INSIDE;\n\n const planes = this.planes;\n for (let k = 0; k < this.planes.length; ++k) {\n // For k greater than 31 (since 31 is the maximum number of INSIDE/INTERSECTING bits we can store), skip the optimization.\n const flag = k < 31 ? 1 << k : 0;\n if (k < 31 && (parentPlaneMask & flag) === 0) {\n // boundingVolume is known to be INSIDE this plane.\n continue;\n }\n\n const plane = planes[k];\n const result = boundingVolume.intersectPlane(plane);\n if (result === INTERSECTION.OUTSIDE) {\n return CullingVolume.MASK_OUTSIDE;\n } else if (result === INTERSECTION.INTERSECTING) {\n mask |= flag;\n }\n }\n\n return mask;\n }\n}\n"],"file":"culling-volume.js"}
@@ -9,39 +9,38 @@ exports.default = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
12
  var _core = require("@math.gl/core");
17
13
 
18
14
  var _perspectiveOffCenterFrustum = _interopRequireDefault(require("./perspective-off-center-frustum"));
19
15
 
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
-
24
- var defined = function defined(val) {
25
- return val !== null && typeof val !== 'undefined';
26
- };
27
-
28
- var PerspectiveFrustum = function () {
29
- function PerspectiveFrustum() {
30
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
31
- (0, _classCallCheck2.default)(this, PerspectiveFrustum);
32
- options = _objectSpread({
16
+ const defined = val => val !== null && typeof val !== 'undefined';
17
+
18
+ class PerspectiveFrustum {
19
+ constructor(options = {}) {
20
+ (0, _defineProperty2.default)(this, "_offCenterFrustum", new _perspectiveOffCenterFrustum.default());
21
+ (0, _defineProperty2.default)(this, "fov", void 0);
22
+ (0, _defineProperty2.default)(this, "_fov", void 0);
23
+ (0, _defineProperty2.default)(this, "_fovy", void 0);
24
+ (0, _defineProperty2.default)(this, "_sseDenominator", void 0);
25
+ (0, _defineProperty2.default)(this, "aspectRatio", void 0);
26
+ (0, _defineProperty2.default)(this, "_aspectRatio", void 0);
27
+ (0, _defineProperty2.default)(this, "near", void 0);
28
+ (0, _defineProperty2.default)(this, "_near", void 0);
29
+ (0, _defineProperty2.default)(this, "far", void 0);
30
+ (0, _defineProperty2.default)(this, "_far", void 0);
31
+ (0, _defineProperty2.default)(this, "xOffset", void 0);
32
+ (0, _defineProperty2.default)(this, "_xOffset", void 0);
33
+ (0, _defineProperty2.default)(this, "yOffset", void 0);
34
+ (0, _defineProperty2.default)(this, "_yOffset", void 0);
35
+ options = {
33
36
  near: 1.0,
34
37
  far: 500000000.0,
35
38
  xOffset: 0.0,
36
- yOffset: 0.0
37
- }, options);
38
- this._offCenterFrustum = new _perspectiveOffCenterFrustum.default();
39
+ yOffset: 0.0,
40
+ ...options
41
+ };
39
42
  this.fov = options.fov;
40
- this._fov = undefined;
41
- this._fovy = undefined;
42
- this._sseDenominator = undefined;
43
43
  this.aspectRatio = options.aspectRatio;
44
- this._aspectRatio = undefined;
45
44
  this.near = options.near;
46
45
  this._near = this.near;
47
46
  this.far = options.far;
@@ -52,72 +51,62 @@ var PerspectiveFrustum = function () {
52
51
  this._yOffset = this.yOffset;
53
52
  }
54
53
 
55
- (0, _createClass2.default)(PerspectiveFrustum, [{
56
- key: "clone",
57
- value: function clone() {
58
- return new PerspectiveFrustum({
59
- aspectRatio: this.aspectRatio,
60
- fov: this.fov,
61
- near: this.near,
62
- far: this.far
63
- });
64
- }
65
- }, {
66
- key: "equals",
67
- value: function equals(other) {
68
- if (!defined(other) || !(other instanceof PerspectiveFrustum)) {
69
- return false;
70
- }
71
-
72
- update(this);
73
- update(other);
74
- return this.fov === other.fov && this.aspectRatio === other.aspectRatio && this.near === other.near && this.far === other.far && this._offCenterFrustum.equals(other._offCenterFrustum);
75
- }
76
- }, {
77
- key: "projectionMatrix",
78
- get: function get() {
79
- update(this);
80
- return this._offCenterFrustum.projectionMatrix;
81
- }
82
- }, {
83
- key: "infiniteProjectionMatrix",
84
- get: function get() {
85
- update(this);
86
- return this._offCenterFrustum.infiniteProjectionMatrix;
87
- }
88
- }, {
89
- key: "fovy",
90
- get: function get() {
91
- update(this);
92
- return this._fovy;
93
- }
94
- }, {
95
- key: "sseDenominator",
96
- get: function get() {
97
- update(this);
98
- return this._sseDenominator;
99
- }
100
- }, {
101
- key: "computeCullingVolume",
102
- value: function computeCullingVolume(position, direction, up) {
103
- update(this);
104
- return this._offCenterFrustum.computeCullingVolume(position, direction, up);
105
- }
106
- }, {
107
- key: "getPixelDimensions",
108
- value: function getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {
109
- update(this);
110
- return this._offCenterFrustum.getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result);
54
+ clone() {
55
+ return new PerspectiveFrustum({
56
+ aspectRatio: this.aspectRatio,
57
+ fov: this.fov,
58
+ near: this.near,
59
+ far: this.far
60
+ });
61
+ }
62
+
63
+ equals(other) {
64
+ if (!defined(other) || !(other instanceof PerspectiveFrustum)) {
65
+ return false;
111
66
  }
112
- }]);
113
- return PerspectiveFrustum;
114
- }();
67
+
68
+ update(this);
69
+ update(other);
70
+ return this.fov === other.fov && this.aspectRatio === other.aspectRatio && this.near === other.near && this.far === other.far && this._offCenterFrustum.equals(other._offCenterFrustum);
71
+ }
72
+
73
+ get projectionMatrix() {
74
+ update(this);
75
+ return this._offCenterFrustum.projectionMatrix;
76
+ }
77
+
78
+ get infiniteProjectionMatrix() {
79
+ update(this);
80
+ return this._offCenterFrustum.infiniteProjectionMatrix;
81
+ }
82
+
83
+ get fovy() {
84
+ update(this);
85
+ return this._fovy;
86
+ }
87
+
88
+ get sseDenominator() {
89
+ update(this);
90
+ return this._sseDenominator;
91
+ }
92
+
93
+ computeCullingVolume(position, direction, up) {
94
+ update(this);
95
+ return this._offCenterFrustum.computeCullingVolume(position, direction, up);
96
+ }
97
+
98
+ getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {
99
+ update(this);
100
+ return this._offCenterFrustum.getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result);
101
+ }
102
+
103
+ }
115
104
 
116
105
  exports.default = PerspectiveFrustum;
117
106
 
118
107
  function update(frustum) {
119
108
  (0, _core.assert)(Number.isFinite(frustum.fov) && Number.isFinite(frustum.aspectRatio) && Number.isFinite(frustum.near) && Number.isFinite(frustum.far));
120
- var f = frustum._offCenterFrustum;
109
+ const f = frustum._offCenterFrustum;
121
110
 
122
111
  if (frustum.fov !== frustum._fov || frustum.aspectRatio !== frustum._aspectRatio || frustum.near !== frustum._near || frustum.far !== frustum._far || frustum.xOffset !== frustum._xOffset || frustum.yOffset !== frustum._yOffset) {
123
112
  (0, _core.assert)(frustum.fov >= 0 && frustum.fov < Math.PI);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/perspective-frustum.js"],"names":["defined","val","PerspectiveFrustum","options","near","far","xOffset","yOffset","_offCenterFrustum","PerspectiveOffCenterFrustum","fov","_fov","undefined","_fovy","_sseDenominator","aspectRatio","_aspectRatio","_near","_far","_xOffset","_yOffset","other","update","equals","projectionMatrix","infiniteProjectionMatrix","position","direction","up","computeCullingVolume","drawingBufferWidth","drawingBufferHeight","distance","result","getPixelDimensions","frustum","Number","isFinite","f","Math","PI","atan","tan","top","bottom","right","left"],"mappings":";;;;;;;;;;;;;;;AASA;;AACA;;;;;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,GAAD;AAAA,SAASA,GAAG,KAAK,IAAR,IAAgB,OAAOA,GAAP,KAAe,WAAxC;AAAA,CAAhB;;IA6BqBC,kB;AACnB,gCAA0B;AAAA,QAAdC,OAAc,uEAAJ,EAAI;AAAA;AACxBA,IAAAA,OAAO;AACLC,MAAAA,IAAI,EAAE,GADD;AAELC,MAAAA,GAAG,EAAE,WAFA;AAGLC,MAAAA,OAAO,EAAE,GAHJ;AAILC,MAAAA,OAAO,EAAE;AAJJ,OAKFJ,OALE,CAAP;AAQA,SAAKK,iBAAL,GAAyB,IAAIC,oCAAJ,EAAzB;AASA,SAAKC,GAAL,GAAWP,OAAO,CAACO,GAAnB;AACA,SAAKC,IAAL,GAAYC,SAAZ;AACA,SAAKC,KAAL,GAAaD,SAAb;AAEA,SAAKE,eAAL,GAAuBF,SAAvB;AAOA,SAAKG,WAAL,GAAmBZ,OAAO,CAACY,WAA3B;AACA,SAAKC,YAAL,GAAoBJ,SAApB;AAOA,SAAKR,IAAL,GAAYD,OAAO,CAACC,IAApB;AACA,SAAKa,KAAL,GAAa,KAAKb,IAAlB;AAOA,SAAKC,GAAL,GAAWF,OAAO,CAACE,GAAnB;AACA,SAAKa,IAAL,GAAY,KAAKb,GAAjB;AAOA,SAAKC,OAAL,GAAeH,OAAO,CAACG,OAAvB;AACA,SAAKa,QAAL,GAAgB,KAAKb,OAArB;AAOA,SAAKC,OAAL,GAAeJ,OAAO,CAACI,OAAvB;AACA,SAAKa,QAAL,GAAgB,KAAKb,OAArB;AACD;;;;WAQD,iBAAQ;AACN,aAAO,IAAIL,kBAAJ,CAAuB;AAC5Ba,QAAAA,WAAW,EAAE,KAAKA,WADU;AAE5BL,QAAAA,GAAG,EAAE,KAAKA,GAFkB;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,CAAC,CAACK,GAAF,IAASR,OAAO,CAAC5B,OAAjB;AACA+B,IAAAA,CAAC,CAACM,MAAF,IAAYT,OAAO,CAAC5B,OAApB;AACD;AACF","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// Note: This class is still an experimental export, mainly used by other test cases\n// - It has not been fully adapted to math.gl conventions\n// - Documentation has not been ported\n\n// @ts-nocheck\n\nimport {assert} from '@math.gl/core';\nimport PerspectiveOffCenterFrustum from './perspective-off-center-frustum';\n\nconst defined = (val) => val !== null && typeof val !== 'undefined';\n\n/**\n * The viewing frustum is defined by 6 planes.\n * Each plane is represented by a {@link Vector4} object, where the x, y, and z components\n * define the unit vector normal to the plane, and the w component is the distance of the\n * plane from the origin/camera position.\n *\n * @alias PerspectiveFrustum\n * @constructor\n *\n * @param {Object} [options] An object with the following properties:\n * @param {Number} [options.fov] The angle of the field of view (FOV), in radians.\n * @param {Number} [options.aspectRatio] The aspect ratio of the frustum's width to it's height.\n * @param {Number} [options.near=1.0] The distance of the near plane.\n * @param {Number} [options.far=500000000.0] The distance of the far plane.\n * @param {Number} [options.xOffset=0.0] The offset in the x direction.\n * @param {Number} [options.yOffset=0.0] The offset in the y direction.\n *\n * @example\n * var frustum = new PerspectiveFrustum({\n * fov : Math.PI_OVER_THREE,\n * aspectRatio : canvas.clientWidth / canvas.clientHeight\n * near : 1.0,\n * far : 1000.0\n * });\n *\n * @see PerspectiveOffCenterFrustum\n */\nexport default class PerspectiveFrustum {\n constructor(options = {}) {\n options = {\n near: 1.0,\n far: 500000000.0,\n xOffset: 0.0,\n yOffset: 0.0,\n ...options\n };\n\n this._offCenterFrustum = new PerspectiveOffCenterFrustum();\n\n /**\n * The angle of the field of view (FOV), in radians. This angle will be used\n * as the horizontal FOV if the width is greater than the height, otherwise\n * it will be the vertical FOV.\n * @type {Number}\n * @default undefined\n */\n this.fov = options.fov;\n this._fov = undefined;\n this._fovy = undefined;\n\n this._sseDenominator = undefined;\n\n /**\n * The aspect ratio of the frustum's width to it's height.\n * @type {Number}\n * @default undefined\n */\n this.aspectRatio = options.aspectRatio;\n this._aspectRatio = undefined;\n\n /**\n * The distance of the near plane.\n * @type {Number}\n * @default 1.0\n */\n this.near = options.near;\n this._near = this.near;\n\n /**\n * The distance of the far plane.\n * @type {Number}\n * @default 500000000.0\n */\n this.far = options.far;\n this._far = this.far;\n\n /**\n * Offsets the frustum in the x direction.\n * @type {Number}\n * @default 0.0\n */\n this.xOffset = options.xOffset;\n this._xOffset = this.xOffset;\n\n /**\n * Offsets the frustum in the y direction.\n * @type {Number}\n * @default 0.0\n */\n this.yOffset = options.yOffset;\n this._yOffset = this.yOffset;\n }\n\n /**\n * Returns a duplicate of a PerspectiveFrustum instance.\n *\n * @param {PerspectiveFrustum} [result] The object onto which to store the result.\n * @returns {PerspectiveFrustum} The modified result parameter or a new PerspectiveFrustum instance if one was not provided.\n */\n clone() {\n return new PerspectiveFrustum({\n aspectRatio: this.aspectRatio,\n fov: this.fov,\n near: this.near,\n far: this.far\n });\n }\n\n /**\n * Compares the provided PerspectiveFrustum componentwise and returns\n * <code>true</code> if they are equal, <code>false</code> otherwise.\n *\n * @param {PerspectiveFrustum} [other] The right hand side PerspectiveFrustum.\n * @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.\n */\n equals(other) {\n if (!defined(other) || !(other instanceof PerspectiveFrustum)) {\n return false;\n }\n\n update(this);\n update(other);\n\n return (\n this.fov === other.fov &&\n this.aspectRatio === other.aspectRatio &&\n this.near === other.near &&\n this.far === other.far &&\n this._offCenterFrustum.equals(other._offCenterFrustum)\n );\n }\n\n /**\n * Gets the perspective projection matrix computed from the view frustum.\n * @memberof PerspectiveFrustum.prototype\n * @type {Matrix4}\n * @readonly\n */\n get projectionMatrix() {\n update(this);\n return this._offCenterFrustum.projectionMatrix;\n }\n\n /**\n * The perspective projection matrix computed from the view frustum with an infinite far plane.\n * @memberof PerspectiveFrustum.prototype\n * @type {Matrix4}\n * @readonly\n *\n * @see PerspectiveFrustum#projectionMatrix\n */\n get infiniteProjectionMatrix() {\n update(this);\n return this._offCenterFrustum.infiniteProjectionMatrix;\n }\n\n /**\n * Gets the angle of the vertical field of view, in radians.\n * @memberof PerspectiveFrustum.prototype\n * @type {Number}\n * @readonly\n * @default undefined\n */\n get fovy() {\n update(this);\n return this._fovy;\n }\n\n /**\n * @readonly\n * @private\n */\n get sseDenominator() {\n update(this);\n return this._sseDenominator;\n }\n\n /**\n * Creates a culling volume for this frustum.\n *\n * @param {Vector3} position The eye position.\n * @param {Vector3} direction The view direction.\n * @param {Vector3} up The up direction.\n * @returns {CullingVolume} A culling volume at the given position and orientation.\n *\n * @example\n * // Check if a bounding volume intersects the frustum.\n * var cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);\n * var intersect = cullingVolume.computeVisibility(boundingVolume);\n */\n computeCullingVolume(position, direction, up) {\n update(this);\n return this._offCenterFrustum.computeCullingVolume(position, direction, up);\n }\n\n /**\n * Returns the pixel's width and height in meters.\n *\n * @param {Number} drawingBufferWidth The width of the drawing buffer.\n * @param {Number} drawingBufferHeight The height of the drawing buffer.\n * @param {Number} distance The distance to the near plane in meters.\n * @param {Vector2} result The object onto which to store the result.\n * @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.\n *\n * @exception {DeveloperError} drawingBufferWidth must be greater than zero.\n * @exception {DeveloperError} drawingBufferHeight must be greater than zero.\n *\n * @example\n * // Example 1\n * // Get the width and height of a pixel.\n * var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());\n *\n * @example\n * // Example 2\n * // Get the width and height of a pixel if the near plane was set to 'distance'.\n * // For example, get the size of a pixel of an image on a billboard.\n * var position = camera.position;\n * var direction = camera.direction;\n * var toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive\n * var toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector\n * var distance = Vector3.magnitude(toCenterProj);\n * var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());\n */\n getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {\n update(this);\n return this._offCenterFrustum.getPixelDimensions(\n drawingBufferWidth,\n drawingBufferHeight,\n distance,\n result\n );\n }\n}\n\n// eslint-disable-next-line complexity, max-statements\nfunction update(frustum) {\n assert(\n Number.isFinite(frustum.fov) &&\n Number.isFinite(frustum.aspectRatio) &&\n Number.isFinite(frustum.near) &&\n Number.isFinite(frustum.far)\n );\n // 'fov, aspectRatio, near, or far parameters are not set.'\n\n const f = frustum._offCenterFrustum;\n\n if (\n frustum.fov !== frustum._fov ||\n frustum.aspectRatio !== frustum._aspectRatio ||\n frustum.near !== frustum._near ||\n frustum.far !== frustum._far ||\n frustum.xOffset !== frustum._xOffset ||\n frustum.yOffset !== frustum._yOffset\n ) {\n assert(frustum.fov >= 0 && frustum.fov < Math.PI);\n // throw new DeveloperError('fov must be in the range [0, PI).');\n\n assert(frustum.aspectRatio > 0);\n // throw new DeveloperError('aspectRatio must be positive.');\n\n assert(frustum.near >= 0 && frustum.near < frustum.far);\n // throw new DeveloperError('near must be greater than zero and less than far.');\n\n frustum._aspectRatio = frustum.aspectRatio;\n frustum._fov = frustum.fov;\n frustum._fovy =\n frustum.aspectRatio <= 1\n ? frustum.fov\n : Math.atan(Math.tan(frustum.fov * 0.5) / frustum.aspectRatio) * 2.0;\n frustum._near = frustum.near;\n frustum._far = frustum.far;\n frustum._sseDenominator = 2.0 * Math.tan(0.5 * frustum._fovy);\n frustum._xOffset = frustum.xOffset;\n frustum._yOffset = frustum.yOffset;\n\n f.top = frustum.near * Math.tan(0.5 * frustum._fovy);\n f.bottom = -f.top;\n f.right = frustum.aspectRatio * f.top;\n f.left = -f.right;\n f.near = frustum.near;\n f.far = frustum.far;\n\n f.right += frustum.xOffset;\n f.left += frustum.xOffset;\n f.top += frustum.yOffset;\n f.bottom += frustum.yOffset;\n }\n}\n"],"file":"perspective-frustum.js"}
1
+ {"version":3,"sources":["../../../src/lib/perspective-frustum.ts"],"names":["defined","val","PerspectiveFrustum","constructor","options","PerspectiveOffCenterFrustum","near","far","xOffset","yOffset","fov","aspectRatio","_near","_far","_xOffset","_yOffset","clone","equals","other","update","_offCenterFrustum","projectionMatrix","infiniteProjectionMatrix","fovy","_fovy","sseDenominator","_sseDenominator","computeCullingVolume","position","direction","up","getPixelDimensions","drawingBufferWidth","drawingBufferHeight","distance","result","frustum","Number","isFinite","f","_fov","_aspectRatio","Math","PI","atan","tan","top","bottom","right","left"],"mappings":";;;;;;;;;;;AASA;;AACA;;AAEA,MAAMA,OAAO,GAAIC,GAAD,IAASA,GAAG,KAAK,IAAR,IAAgB,OAAOA,GAAP,KAAe,WAAxD;;AA6Be,MAAMC,kBAAN,CAAyB;AAyCtCC,EAAAA,WAAW,CAACC,OAA4B,GAAG,EAAhC,EAAoC;AAAA,6DAxC3B,IAAIC,oCAAJ,EAwC2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAC7CD,IAAAA,OAAO,GAAG;AACRE,MAAAA,IAAI,EAAE,GADE;AAERC,MAAAA,GAAG,EAAE,WAFG;AAGRC,MAAAA,OAAO,EAAE,GAHD;AAIRC,MAAAA,OAAO,EAAE,GAJD;AAKR,SAAGL;AALK,KAAV;AAQA,SAAKM,GAAL,GAAWN,OAAO,CAACM,GAAnB;AAEA,SAAKC,WAAL,GAAmBP,OAAO,CAACO,WAA3B;AAEA,SAAKL,IAAL,GAAYF,OAAO,CAACE,IAApB;AACA,SAAKM,KAAL,GAAa,KAAKN,IAAlB;AAEA,SAAKC,GAAL,GAAWH,OAAO,CAACG,GAAnB;AACA,SAAKM,IAAL,GAAY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ACR,CAAC,CAACO,GAAd;AACAP,IAAAA,CAAC,CAACS,KAAF,GAAUZ,OAAO,CAACzB,WAAR,GAAsB4B,CAAC,CAACO,GAAlC;AACAP,IAAAA,CAAC,CAACU,IAAF,GAAS,CAACV,CAAC,CAACS,KAAZ;AACAT,IAAAA,CAAC,CAACjC,IAAF,GAAS8B,OAAO,CAAC9B,IAAjB;AACAiC,IAAAA,CAAC,CAAChC,GAAF,GAAQ6B,OAAO,CAAC7B,GAAhB;AAEAgC,IAAAA,CAAC,CAACS,KAAF,IAAWZ,OAAO,CAAC5B,OAAnB;AACA+B,IAAAA,CAAC,CAACU,IAAF,IAAUb,OAAO,CAAC5B,OAAlB;AACA+B,IAAAA,CAAC,CAACO,GAAF,IAASV,OAAO,CAAC3B,OAAjB;AACA8B,IAAAA,CAAC,CAACQ,MAAF,IAAYX,OAAO,CAAC3B,OAApB;AACD;AACF","sourcesContent":["// This file is derived from the Cesium math library under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// Note: This class is still an experimental export, mainly used by other test cases\n// - It has not been fully adapted to math.gl conventions\n// - Documentation has not been ported\n\n// @ts-nocheck\n\nimport {assert, Matrix4} from '@math.gl/core';\nimport PerspectiveOffCenterFrustum from './perspective-off-center-frustum';\n\nconst defined = (val) => val !== null && typeof val !== 'undefined';\n\n/**\n * The viewing frustum is defined by 6 planes.\n * Each plane is represented by a {@link Vector4} object, where the x, y, and z components\n * define the unit vector normal to the plane, and the w component is the distance of the\n * plane from the origin/camera position.\n *\n * @alias PerspectiveFrustum\n * @constructor\n *\n * @param {Object} [options] An object with the following properties:\n * @param {Number} [options.fov] The angle of the field of view (FOV), in radians.\n * @param {Number} [options.aspectRatio] The aspect ratio of the frustum's width to it's height.\n * @param {Number} [options.near=1.0] The distance of the near plane.\n * @param {Number} [options.far=500000000.0] The distance of the far plane.\n * @param {Number} [options.xOffset=0.0] The offset in the x direction.\n * @param {Number} [options.yOffset=0.0] The offset in the y direction.\n *\n * @example\n * var frustum = new PerspectiveFrustum({\n * fov : Math.PI_OVER_THREE,\n * aspectRatio : canvas.clientWidth / canvas.clientHeight\n * near : 1.0,\n * far : 1000.0\n * });\n *\n * @see PerspectiveOffCenterFrustum\n */\nexport default class PerspectiveFrustum {\n _offCenterFrustum = new PerspectiveOffCenterFrustum();\n /**\n * The angle of the field of view (FOV), in radians. This angle will be used\n * as the horizontal FOV if the width is greater than the height, otherwise\n * it will be the vertical FOV.\n */\n fov: number;\n _fov;\n _fovy;\n _sseDenominator;\n /**\n * The aspect ratio of the frustum's width to it's height.\n */\n aspectRatio: number;\n _aspectRatio;\n /**\n * The distance of the near plane.\n * @default 1.0\n */\n near: number;\n _near;\n /**\n * The distance of the far plane.\n * @default 500000000.0\n */\n far: number;\n _far;\n /**\n * Offsets the frustum in the x direction.\n * @default 0.0\n */\n xOffset: number;\n _xOffset;\n /**\n * Offsets the frustum in the y direction.\n * @default 0.0\n */\n yOffset: number;\n _yOffset;\n\n constructor(options: Record<string, any> = {}) {\n options = {\n near: 1.0,\n far: 500000000.0,\n xOffset: 0.0,\n yOffset: 0.0,\n ...options\n };\n\n this.fov = options.fov;\n\n this.aspectRatio = options.aspectRatio;\n\n this.near = options.near;\n this._near = this.near;\n\n this.far = options.far;\n this._far = this.far;\n\n this.xOffset = options.xOffset;\n this._xOffset = this.xOffset;\n\n this.yOffset = options.yOffset;\n this._yOffset = this.yOffset;\n }\n\n /**\n * Returns a duplicate of a PerspectiveFrustum instance.\n */\n clone(): PerspectiveFrustum {\n return new PerspectiveFrustum({\n aspectRatio: this.aspectRatio,\n fov: this.fov,\n near: this.near,\n far: this.far\n });\n }\n\n /**\n * Compares the provided PerspectiveFrustum componentwise and returns\n * <code>true</code> if they are equal, <code>false</code> otherwise.\n */\n equals(other: PerspectiveFrustum): boolean {\n if (!defined(other) || !(other instanceof PerspectiveFrustum)) {\n return false;\n }\n\n update(this);\n update(other);\n\n return (\n this.fov === other.fov &&\n this.aspectRatio === other.aspectRatio &&\n this.near === other.near &&\n this.far === other.far &&\n this._offCenterFrustum.equals(other._offCenterFrustum)\n );\n }\n\n /**\n * Gets the perspective projection matrix computed from the view frustum.\n */\n get projectionMatrix(): Matrix4 {\n update(this);\n return this._offCenterFrustum.projectionMatrix;\n }\n\n /**\n * The perspective projection matrix computed from the view frustum with an infinite far plane.\n */\n get infiniteProjectionMatrix(): Matrix4 {\n update(this);\n return this._offCenterFrustum.infiniteProjectionMatrix;\n }\n\n /**\n * Gets the angle of the vertical field of view, in radians.\n */\n get fovy(): number {\n update(this);\n return this._fovy;\n }\n\n /**\n * @private\n */\n get sseDenominator(): number {\n update(this);\n return this._sseDenominator;\n }\n\n /**\n * Creates a culling volume for this frustum.\n *\n * @param {Vector3} position The eye position.\n * @param {Vector3} direction The view direction.\n * @param {Vector3} up The up direction.\n * @returns {CullingVolume} A culling volume at the given position and orientation.\n *\n * @example\n * // Check if a bounding volume intersects the frustum.\n * var cullingVolume = frustum.computeCullingVolume(cameraPosition, cameraDirection, cameraUp);\n * var intersect = cullingVolume.computeVisibility(boundingVolume);\n */\n computeCullingVolume(position, direction, up) {\n update(this);\n return this._offCenterFrustum.computeCullingVolume(position, direction, up);\n }\n\n /**\n * Returns the pixel's width and height in meters.\n *\n * @param {Number} drawingBufferWidth The width of the drawing buffer.\n * @param {Number} drawingBufferHeight The height of the drawing buffer.\n * @param {Number} distance The distance to the near plane in meters.\n * @param {Vector2} result The object onto which to store the result.\n * @returns {Vector2} The modified result parameter or a new instance of {@link Vector2} with the pixel's width and height in the x and y properties, respectively.\n *\n * @exception {DeveloperError} drawingBufferWidth must be greater than zero.\n * @exception {DeveloperError} drawingBufferHeight must be greater than zero.\n *\n * @example\n * // Example 1\n * // Get the width and height of a pixel.\n * var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, 1.0, new Vector2());\n *\n * @example\n * // Example 2\n * // Get the width and height of a pixel if the near plane was set to 'distance'.\n * // For example, get the size of a pixel of an image on a billboard.\n * var position = camera.position;\n * var direction = camera.direction;\n * var toCenter = Vector3.subtract(primitive.boundingVolume.center, position, new Vector3()); // vector from camera to a primitive\n * var toCenterProj = Vector3.multiplyByScalar(direction, Vector3.dot(direction, toCenter), new Vector3()); // project vector onto camera direction vector\n * var distance = Vector3.magnitude(toCenterProj);\n * var pixelSize = camera.frustum.getPixelDimensions(scene.drawingBufferWidth, scene.drawingBufferHeight, distance, new Vector2());\n */\n getPixelDimensions(drawingBufferWidth, drawingBufferHeight, distance, result) {\n update(this);\n return this._offCenterFrustum.getPixelDimensions(\n drawingBufferWidth,\n drawingBufferHeight,\n distance,\n result\n );\n }\n}\n\n// eslint-disable-next-line complexity, max-statements\nfunction update(frustum) {\n assert(\n Number.isFinite(frustum.fov) &&\n Number.isFinite(frustum.aspectRatio) &&\n Number.isFinite(frustum.near) &&\n Number.isFinite(frustum.far)\n );\n // 'fov, aspectRatio, near, or far parameters are not set.'\n\n const f = frustum._offCenterFrustum;\n\n if (\n frustum.fov !== frustum._fov ||\n frustum.aspectRatio !== frustum._aspectRatio ||\n frustum.near !== frustum._near ||\n frustum.far !== frustum._far ||\n frustum.xOffset !== frustum._xOffset ||\n frustum.yOffset !== frustum._yOffset\n ) {\n assert(frustum.fov >= 0 && frustum.fov < Math.PI);\n // throw new DeveloperError('fov must be in the range [0, PI).');\n\n assert(frustum.aspectRatio > 0);\n // throw new DeveloperError('aspectRatio must be positive.');\n\n assert(frustum.near >= 0 && frustum.near < frustum.far);\n // throw new DeveloperError('near must be greater than zero and less than far.');\n\n frustum._aspectRatio = frustum.aspectRatio;\n frustum._fov = frustum.fov;\n frustum._fovy =\n frustum.aspectRatio <= 1\n ? frustum.fov\n : Math.atan(Math.tan(frustum.fov * 0.5) / frustum.aspectRatio) * 2.0;\n frustum._near = frustum.near;\n frustum._far = frustum.far;\n frustum._sseDenominator = 2.0 * Math.tan(0.5 * frustum._fovy);\n frustum._xOffset = frustum.xOffset;\n frustum._yOffset = frustum.yOffset;\n\n f.top = frustum.near * Math.tan(0.5 * frustum._fovy);\n f.bottom = -f.top;\n f.right = frustum.aspectRatio * f.top;\n f.left = -f.right;\n f.near = frustum.near;\n f.far = frustum.far;\n\n f.right += frustum.xOffset;\n f.left += frustum.xOffset;\n f.top += frustum.yOffset;\n f.bottom += frustum.yOffset;\n }\n}\n"],"file":"perspective-frustum.js"}