PageSourceSearch

https://satvis.space/cesium/Workers/chunk-L73K5UPP.js

js satvis.space collected 2026-10-02 06:40:35 UTC 8,500 bytes, 288 lines download raw bytes

vendor: 8,500 bytes, lines 1-288
1/**
2 * @license
3 * Cesium - https://github.com/CesiumGS/cesium
4 * Version 1.145.0
5 *
6 * Copyright 2011-2022 Cesium Contributors
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 * Columbus View (Pat. Pend.)
21 *
22 * Portions licensed separately.
23 * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
24 */
25
26import {
27  AxisAlignedBoundingBox_default
28} from "./chunk-N5YK44FS.js";
29import {
30  IntersectionTests_default,
31  Ray_default
32} from "./chunk-75BC2IHI.js";
33import {
34  Plane_default
35} from "./chunk-LL2SGJYH.js";
36import {
37  Transforms_default
38} from "./chunk-XRZCS3HE.js";
39import {
40  Cartesian4_default,
41  Matrix4_default
42} from "./chunk-6R6SGKYN.js";
43import {
44  Cartesian2_default,
45  Ellipsoid_default
46} from "./chunk-6BSNYZZG.js";
47import {
48  Cartesian3_default
49} from "./chunk-Z2DW5NM2.js";
50import {
51  Check_default,
52  DeveloperError_default
53} from "./chunk-XSIUYAT6.js";
54import {
55  defined_default
56} from "./chunk-B4AVL7VI.js";
57
58// packages/engine/Source/Core/EllipsoidTangentPlane.js
59var scratchCart4 = new Cartesian4_default();
60function EllipsoidTangentPlane(origin, ellipsoid) {
61  Check_default.defined("origin", origin);
62  ellipsoid = ellipsoid ?? Ellipsoid_default.default;
63  origin = ellipsoid.scaleToGeodeticSurface(origin);
64  if (!defined_default(origin)) {
65    throw new DeveloperError_default(
66      "origin must not be at the center of the ellipsoid."
67    );
68  }
69  const eastNorthUp = Transforms_default.eastNorthUpToFixedFrame(origin, ellipsoid);
70  this._ellipsoid = ellipsoid;
71  this._origin = origin;
72  this._xAxis = Cartesian3_default.fromCartesian4(
73    Matrix4_default.getColumn(eastNorthUp, 0, scratchCart4)
74  );
75  this._yAxis = Cartesian3_default.fromCartesian4(
76    Matrix4_default.getColumn(eastNorthUp, 1, scratchCart4)
77  );
78  const normal = Cartesian3_default.fromCartesian4(
79    Matrix4_default.getColumn(eastNorthUp, 2, scratchCart4)
80  );
81  this._plane = Plane_default.fromPointNormal(origin, normal);
82}
83Object.defineProperties(EllipsoidTangentPlane.prototype, {
84  /**
85   * Gets the ellipsoid.
86   * @memberof EllipsoidTangentPlane.prototype
87   * @type {Ellipsoid}
88   */
89  ellipsoid: {
90    get: function() {
91      return this._ellipsoid;
92    }
93  },
94  /**
95   * Gets the origin.
96   * @memberof EllipsoidTangentPlane.prototype
97   * @type {Cartesian3}
98   */
99  origin: {
100    get: function() {
101      return this._origin;
102    }
103  },
104  /**
105   * Gets the plane which is tangent to the ellipsoid.
106   * @memberof EllipsoidTangentPlane.prototype
107   * @readonly
108   * @type {Plane}
109   */
110  plane: {
111    get: function() {
112      return this._plane;
113    }
114  },
115  /**
116   * Gets the local X-axis (east) of the tangent plane.
117   * @memberof EllipsoidTangentPlane.prototype
118   * @readonly
119   * @type {Cartesian3}
120   */
121  xAxis: {
122    get: function() {
123      return this._xAxis;
124    }
125  },
126  /**
127   * Gets the local Y-axis (north) of the tangent plane.
128   * @memberof EllipsoidTangentPlane.prototype
129   * @readonly
130   * @type {Cartesian3}
131   */
132  yAxis: {
133    get: function() {
134      return this._yAxis;
135    }
136  },
137  /**
138   * Gets the local Z-axis (up) of the tangent plane.
139   * @memberof EllipsoidTangentPlane.prototype
140   * @readonly
141   * @type {Cartesian3}
142   */
143  zAxis: {
144    get: function() {
145      return this._plane.normal;
146    }
147  }
148});
149var tmp = new AxisAlignedBoundingBox_default();
150EllipsoidTangentPlane.fromPoints = function(cartesians, ellipsoid) {
151  Check_default.defined("cartesians", cartesians);
152  const box = AxisAlignedBoundingBox_default.fromPoints(cartesians, tmp);
153  return new EllipsoidTangentPlane(box.center, ellipsoid);
154};
155var scratchProjectPointOntoPlaneRay = new Ray_default();
156var scratchProjectPointOntoPlaneCartesian3 = new Cartesian3_default();
157EllipsoidTangentPlane.prototype.projectPointOntoPlane = function(cartesian, result) {
158  Check_default.defined("cartesian", cartesian);
159  const ray = scratchProjectPointOntoPlaneRay;
160  ray.origin = cartesian;
161  Cartesian3_default.normalize(cartesian, ray.direction);
162  let intersectionPoint = IntersectionTests_default.rayPlane(
163    ray,
164    this._plane,
165    scratchProjectPointOntoPlaneCartesian3
166  );
167  if (!defined_default(intersectionPoint)) {
168    Cartesian3_default.negate(ray.direction, ray.direction);
169    intersectionPoint = IntersectionTests_default.rayPlane(
170      ray,
171      this._plane,
172      scratchProjectPointOntoPlaneCartesian3
173    );
174  }
175  if (defined_default(intersectionPoint)) {
176    const v = Cartesian3_default.subtract(
177      intersectionPoint,
178      this._origin,
179      intersectionPoint
180    );
181    const x = Cartesian3_default.dot(this._xAxis, v);
182    const y = Cartesian3_default.dot(this._yAxis, v);
183    if (!defined_default(result)) {
184      return new Cartesian2_default(x, y);
185    }
186    result.x = x;
187    result.y = y;
188    return result;
189  }
190  return void 0;
191};
192EllipsoidTangentPlane.prototype.projectPointsOntoPlane = function(cartesians, result) {
193  Check_default.defined("cartesians", cartesians);
194  if (!defined_default(result)) {
195    result = [];
196  }
197  let count = 0;
198  const length = cartesians.length;
199  for (let i = 0; i < length; i++) {
200    const p = this.projectPointOntoPlane(cartesians[i], result[count]);
201    if (defined_default(p)) {
202      result[count] = p;
203      count++;
204    }
205  }
206  result.length = count;
207  return result;
208};
209EllipsoidTangentPlane.prototype.projectPointToNearestOnPlane = function(cartesian, result) {
210  Check_default.defined("cartesian", cartesian);
211  if (!defined_default(result)) {
212    result = new Cartesian2_default();
213  }
214  const ray = scratchProjectPointOntoPlaneRay;
215  ray.origin = cartesian;
216  Cartesian3_default.clone(this._plane.normal, ray.direction);
217  let intersectionPoint = IntersectionTests_default.rayPlane(
218    ray,
219    this._plane,
220    scratchProjectPointOntoPlaneCartesian3
221  );
222  if (!defined_default(intersectionPoint)) {
223    Cartesian3_default.negate(ray.direction, ray.direction);
224    intersectionPoint = IntersectionTests_default.rayPlane(
225      ray,
226      this._plane,
227      scratchProjectPointOntoPlaneCartesian3
228    );
229  }
230  const v = Cartesian3_default.subtract(
231    intersectionPoint,
232    this._origin,
233    intersectionPoint
234  );
235  const x = Cartesian3_default.dot(this._xAxis, v);
236  const y = Cartesian3_default.dot(this._yAxis, v);
237  result.x = x;
238  result.y = y;
239  return result;
240};
241EllipsoidTangentPlane.prototype.projectPointsToNearestOnPlane = function(cartesians, result) {
242  Check_default.defined("cartesians", cartesians);
243  if (!defined_default(result)) {
244    result = [];
245  }
246  const length = cartesians.length;
247  result.length = length;
248  for (let i = 0; i < length; i++) {
249    result[i] = this.projectPointToNearestOnPlane(cartesians[i], result[i]);
250  }
251  return result;
252};
253var projectPointsOntoEllipsoidScratch = new Cartesian3_default();
254EllipsoidTangentPlane.prototype.projectPointOntoEllipsoid = function(cartesian, result) {
255  Check_default.defined("cartesian", cartesian);
256  if (!defined_default(result)) {
257    result = new Cartesian3_default();
258  }
259  const ellipsoid = this._ellipsoid;
260  const origin = this._origin;
261  const xAxis = this._xAxis;
262  const yAxis = this._yAxis;
263  const tmp2 = projectPointsOntoEllipsoidScratch;
264  Cartesian3_default.multiplyByScalar(xAxis, cartesian.x, tmp2);
265  result = Cartesian3_default.add(origin, tmp2, result);
266  Cartesian3_default.multiplyByScalar(yAxis, cartesian.y, tmp2);
267  Cartesian3_default.add(result, tmp2, result);
268  ellipsoid.scaleToGeocentricSurface(result, result);
269  return result;
270};
271EllipsoidTangentPlane.prototype.projectPointsOntoEllipsoid = function(cartesians, result) {
272  Check_default.defined("cartesians", cartesians);
273  const length = cartesians.length;
274  if (!defined_default(result)) {
275    result = new Array(length);
276  } else {
277    result.length = length;
278  }
279  for (let i = 0; i < length; ++i) {
280    result[i] = this.projectPointOntoEllipsoid(cartesians[i], result[i]);
281  }
282  return result;
283};
284var EllipsoidTangentPlane_default = EllipsoidTangentPlane;
285
286export {
287  EllipsoidTangentPlane_default
288};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.