This commit is contained in:
2023-04-23 09:41:12 +08:00
parent 0339a49d2b
commit d20a1e0ca1
1552 changed files with 98219 additions and 190234 deletions

View File

@ -1,59 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports'], function (exports) { 'use strict';
/**
* ArcType defines the path that should be taken connecting vertices.
*
* @exports ArcType
*/
var ArcType = {
/**
* Straight line that does not conform to the surface of the ellipsoid.
*
* @type {Number}
* @constant
*/
NONE : 0,
/**
* Follow geodesic path.
*
* @type {Number}
* @constant
*/
GEODESIC : 1,
/**
* Follow rhumb or loxodrome path.
*
* @type {Number}
* @constant
*/
RHUMB : 2
};
var ArcType$1 = Object.freeze(ArcType);
exports.ArcType = ArcType$1;
});

View File

@ -0,0 +1 @@
define(["exports","./Matrix2-413c4048","./Matrix3-81054f0f","./ComponentDatatype-ab629b88","./defaultValue-f6d5e6da","./Math-2ce22ee9"],(function(t,e,n,o,a,r){"use strict";const c={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4",getMathType:function(t){switch(t){case c.SCALAR:return Number;case c.VEC2:return e.Cartesian2;case c.VEC3:return n.Cartesian3;case c.VEC4:return e.Cartesian4;case c.MAT2:return e.Matrix2;case c.MAT3:return n.Matrix3;case c.MAT4:return e.Matrix4}},getNumberOfComponents:function(t){switch(t){case c.SCALAR:return 1;case c.VEC2:return 2;case c.VEC3:return 3;case c.VEC4:case c.MAT2:return 4;case c.MAT3:return 9;case c.MAT4:return 16}},getAttributeLocationCount:function(t){switch(t){case c.SCALAR:case c.VEC2:case c.VEC3:case c.VEC4:return 1;case c.MAT2:return 2;case c.MAT3:return 3;case c.MAT4:return 4}},getGlslType:function(t){switch(t){case c.SCALAR:return"float";case c.VEC2:return"vec2";case c.VEC3:return"vec3";case c.VEC4:return"vec4";case c.MAT2:return"mat2";case c.MAT3:return"mat3";case c.MAT4:return"mat4"}}};var s=Object.freeze(c);const u=1/256,i={octEncodeInRange:function(t,e,n){if(n.x=t.x/(Math.abs(t.x)+Math.abs(t.y)+Math.abs(t.z)),n.y=t.y/(Math.abs(t.x)+Math.abs(t.y)+Math.abs(t.z)),t.z<0){const t=n.x,e=n.y;n.x=(1-Math.abs(e))*r.CesiumMath.signNotZero(t),n.y=(1-Math.abs(t))*r.CesiumMath.signNotZero(e)}return n.x=r.CesiumMath.toSNorm(n.x,e),n.y=r.CesiumMath.toSNorm(n.y,e),n},octEncode:function(t,e){return i.octEncodeInRange(t,255,e)}},C=new e.Cartesian2,M=new Uint8Array(1);function f(t){return M[0]=t,M[0]}i.octEncodeToCartesian4=function(t,e){return i.octEncodeInRange(t,65535,C),e.x=f(C.x*u),e.y=f(C.x),e.z=f(C.y*u),e.w=f(C.y),e},i.octDecodeInRange=function(t,e,o,a){if(a.x=r.CesiumMath.fromSNorm(t,o),a.y=r.CesiumMath.fromSNorm(e,o),a.z=1-(Math.abs(a.x)+Math.abs(a.y)),a.z<0){const t=a.x;a.x=(1-Math.abs(a.y))*r.CesiumMath.signNotZero(t),a.y=(1-Math.abs(t))*r.CesiumMath.signNotZero(a.y)}return n.Cartesian3.normalize(a,a)},i.octDecode=function(t,e,n){return i.octDecodeInRange(t,e,255,n)},i.octDecodeFromCartesian4=function(t,e){const n=256*t.x+t.y,o=256*t.z+t.w;return i.octDecodeInRange(n,o,65535,e)},i.octPackFloat=function(t){return 256*t.x+t.y};const m=new e.Cartesian2;function y(t){return t>>1^-(1&t)}i.octEncodeFloat=function(t){return i.octEncode(t,m),i.octPackFloat(m)},i.octDecodeFloat=function(t,e){const n=t/256,o=Math.floor(n),a=256*(n-o);return i.octDecode(o,a,e)},i.octPack=function(t,e,n,o){const a=i.octEncodeFloat(t),r=i.octEncodeFloat(e),c=i.octEncode(n,m);return o.x=65536*c.x+a,o.y=65536*c.y+r,o},i.octUnpack=function(t,e,n,o){let a=t.x/65536;const r=Math.floor(a),c=65536*(a-r);a=t.y/65536;const s=Math.floor(a),u=65536*(a-s);i.octDecodeFloat(c,e),i.octDecodeFloat(u,n),i.octDecode(r,s,o)},i.compressTextureCoordinates=function(t){return 4096*(4095*t.x|0)+(4095*t.y|0)},i.decompressTextureCoordinates=function(t,e){const n=t/4096,o=Math.floor(n);return e.x=o/4095,e.y=(t-4096*o)/4095,e},i.zigZagDeltaDecode=function(t,e,n){const o=t.length;let r=0,c=0,s=0;for(let u=0;u<o;++u)r+=y(t[u]),c+=y(e[u]),t[u]=r,e[u]=c,a.defined(n)&&(s+=y(n[u]),n[u]=s)},i.dequantize=function(t,e,n,a){const r=s.getNumberOfComponents(n);let c;switch(e){case o.ComponentDatatype.BYTE:c=127;break;case o.ComponentDatatype.UNSIGNED_BYTE:c=255;break;case o.ComponentDatatype.SHORT:c=32767;break;case o.ComponentDatatype.UNSIGNED_SHORT:c=65535;break;case o.ComponentDatatype.INT:c=2147483647;break;case o.ComponentDatatype.UNSIGNED_INT:c=4294967295}const u=new Float32Array(a*r);for(let e=0;e<a;e++)for(let n=0;n<r;n++){const o=e*r+n;u[o]=Math.max(t[o]/c,-1)}return u},i.decodeRGB565=function(t,e){const n=t.length;a.defined(e)||(e=new Float32Array(3*n));const o=1/31;for(let a=0;a<n;a++){const n=t[a],r=n>>11,c=n>>5&63,s=31&n,u=3*a;e[u]=r*o,e[u+1]=.015873015873015872*c,e[u+2]=s*o}return e};var A=i;t.AttributeCompression=A}));

View File

@ -1,415 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09'], function (exports, when, Check, _Math, Cartographic, Cartesian2) { 'use strict';
var RIGHT_SHIFT = 1.0 / 256.0;
var LEFT_SHIFT = 256.0;
/**
* Attribute compression and decompression functions.
*
* @exports AttributeCompression
*
* @private
*/
var AttributeCompression = {};
/**
* Encodes a normalized vector into 2 SNORM values in the range of [0-rangeMax] following the 'oct' encoding.
*
* Oct encoding is a compact representation of unit length vectors.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: {@link http://jcgt.org/published/0003/02/01/}
*
* @param {Cartesian3} vector The normalized vector to be compressed into 2 component 'oct' encoding.
* @param {Cartesian2} result The 2 component oct-encoded unit length vector.
* @param {Number} rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
* @returns {Cartesian2} The 2 component oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*
* @see AttributeCompression.octDecodeInRange
*/
AttributeCompression.octEncodeInRange = function(vector, rangeMax, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('vector', vector);
Check.Check.defined('result', result);
var magSquared = Cartographic.Cartesian3.magnitudeSquared(vector);
if (Math.abs(magSquared - 1.0) > _Math.CesiumMath.EPSILON6) {
throw new Check.DeveloperError('vector must be normalized.');
}
//>>includeEnd('debug');
result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
if (vector.z < 0) {
var x = result.x;
var y = result.y;
result.x = (1.0 - Math.abs(y)) * _Math.CesiumMath.signNotZero(x);
result.y = (1.0 - Math.abs(x)) * _Math.CesiumMath.signNotZero(y);
}
result.x = _Math.CesiumMath.toSNorm(result.x, rangeMax);
result.y = _Math.CesiumMath.toSNorm(result.y, rangeMax);
return result;
};
/**
* Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding.
*
* @param {Cartesian3} vector The normalized vector to be compressed into 2 byte 'oct' encoding.
* @param {Cartesian2} result The 2 byte oct-encoded unit length vector.
* @returns {Cartesian2} The 2 byte oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*
* @see AttributeCompression.octEncodeInRange
* @see AttributeCompression.octDecode
*/
AttributeCompression.octEncode = function(vector, result) {
return AttributeCompression.octEncodeInRange(vector, 255, result);
};
var octEncodeScratch = new Cartesian2.Cartesian2();
var uint8ForceArray = new Uint8Array(1);
function forceUint8(value) {
uint8ForceArray[0] = value;
return uint8ForceArray[0];
}
/**
* @param {Cartesian3} vector The normalized vector to be compressed into 4 byte 'oct' encoding.
* @param {Cartesian4} result The 4 byte oct-encoded unit length vector.
* @returns {Cartesian4} The 4 byte oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*
* @see AttributeCompression.octEncodeInRange
* @see AttributeCompression.octDecodeFromCartesian4
*/
AttributeCompression.octEncodeToCartesian4 = function(vector, result) {
AttributeCompression.octEncodeInRange(vector, 65535, octEncodeScratch);
result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT);
result.y = forceUint8(octEncodeScratch.x);
result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT);
result.w = forceUint8(octEncodeScratch.y);
return result;
};
/**
* Decodes a unit-length vector in 'oct' encoding to a normalized 3-component vector.
*
* @param {Number} x The x component of the oct-encoded unit length vector.
* @param {Number} y The y component of the oct-encoded unit length vector.
* @param {Number} rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
* @param {Cartesian3} result The decoded and normalized vector
* @returns {Cartesian3} The decoded and normalized vector.
*
* @exception {DeveloperError} x and y must be unsigned normalized integers between 0 and rangeMax.
*
* @see AttributeCompression.octEncodeInRange
*/
AttributeCompression.octDecodeInRange = function(x, y, rangeMax, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('result', result);
if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
throw new Check.DeveloperError('x and y must be unsigned normalized integers between 0 and ' + rangeMax);
}
//>>includeEnd('debug');
result.x = _Math.CesiumMath.fromSNorm(x, rangeMax);
result.y = _Math.CesiumMath.fromSNorm(y, rangeMax);
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
if (result.z < 0.0)
{
var oldVX = result.x;
result.x = (1.0 - Math.abs(result.y)) * _Math.CesiumMath.signNotZero(oldVX);
result.y = (1.0 - Math.abs(oldVX)) * _Math.CesiumMath.signNotZero(result.y);
}
return Cartographic.Cartesian3.normalize(result, result);
};
/**
* Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.
*
* @param {Number} x The x component of the oct-encoded unit length vector.
* @param {Number} y The y component of the oct-encoded unit length vector.
* @param {Cartesian3} result The decoded and normalized vector.
* @returns {Cartesian3} The decoded and normalized vector.
*
* @exception {DeveloperError} x and y must be an unsigned normalized integer between 0 and 255.
*
* @see AttributeCompression.octDecodeInRange
*/
AttributeCompression.octDecode = function(x, y, result) {
return AttributeCompression.octDecodeInRange(x, y, 255, result);
};
/**
* Decodes a unit-length vector in 4 byte 'oct' encoding to a normalized 3-component vector.
*
* @param {Cartesian4} encoded The oct-encoded unit length vector.
* @param {Cartesian3} result The decoded and normalized vector.
* @returns {Cartesian3} The decoded and normalized vector.
*
* @exception {DeveloperError} x, y, z, and w must be unsigned normalized integers between 0 and 255.
*
* @see AttributeCompression.octDecodeInRange
* @see AttributeCompression.octEncodeToCartesian4
*/
AttributeCompression.octDecodeFromCartesian4 = function(encoded, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('encoded', encoded);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = encoded.x;
var y = encoded.y;
var z = encoded.z;
var w = encoded.w;
//>>includeStart('debug', pragmas.debug);
if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
throw new Check.DeveloperError('x, y, z, and w must be unsigned normalized integers between 0 and 255');
}
//>>includeEnd('debug');
var xOct16 = x * LEFT_SHIFT + y;
var yOct16 = z * LEFT_SHIFT + w;
return AttributeCompression.octDecodeInRange(xOct16, yOct16, 65535, result);
};
/**
* Packs an oct encoded vector into a single floating-point number.
*
* @param {Cartesian2} encoded The oct encoded vector.
* @returns {Number} The oct encoded vector packed into a single float.
*
*/
AttributeCompression.octPackFloat = function(encoded) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('encoded', encoded);
//>>includeEnd('debug');
return 256.0 * encoded.x + encoded.y;
};
var scratchEncodeCart2 = new Cartesian2.Cartesian2();
/**
* Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding and
* stores those values in a single float-point number.
*
* @param {Cartesian3} vector The normalized vector to be compressed into 2 byte 'oct' encoding.
* @returns {Number} The 2 byte oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*/
AttributeCompression.octEncodeFloat = function(vector) {
AttributeCompression.octEncode(vector, scratchEncodeCart2);
return AttributeCompression.octPackFloat(scratchEncodeCart2);
};
/**
* Decodes a unit-length vector in 'oct' encoding packed in a floating-point number to a normalized 3-component vector.
*
* @param {Number} value The oct-encoded unit length vector stored as a single floating-point number.
* @param {Cartesian3} result The decoded and normalized vector
* @returns {Cartesian3} The decoded and normalized vector.
*
*/
AttributeCompression.octDecodeFloat = function(value, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('value', value);
//>>includeEnd('debug');
var temp = value / 256.0;
var x = Math.floor(temp);
var y = (temp - x) * 256.0;
return AttributeCompression.octDecode(x, y, result);
};
/**
* Encodes three normalized vectors into 6 SNORM values in the range of [0-255] following the 'oct' encoding and
* packs those into two floating-point numbers.
*
* @param {Cartesian3} v1 A normalized vector to be compressed.
* @param {Cartesian3} v2 A normalized vector to be compressed.
* @param {Cartesian3} v3 A normalized vector to be compressed.
* @param {Cartesian2} result The 'oct' encoded vectors packed into two floating-point numbers.
* @returns {Cartesian2} The 'oct' encoded vectors packed into two floating-point numbers.
*
*/
AttributeCompression.octPack = function(v1, v2, v3, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('v1', v1);
Check.Check.defined('v2', v2);
Check.Check.defined('v3', v3);
Check.Check.defined('result', result);
//>>includeEnd('debug');
var encoded1 = AttributeCompression.octEncodeFloat(v1);
var encoded2 = AttributeCompression.octEncodeFloat(v2);
var encoded3 = AttributeCompression.octEncode(v3, scratchEncodeCart2);
result.x = 65536.0 * encoded3.x + encoded1;
result.y = 65536.0 * encoded3.y + encoded2;
return result;
};
/**
* Decodes three unit-length vectors in 'oct' encoding packed into a floating-point number to a normalized 3-component vector.
*
* @param {Cartesian2} packed The three oct-encoded unit length vectors stored as two floating-point number.
* @param {Cartesian3} v1 One decoded and normalized vector.
* @param {Cartesian3} v2 One decoded and normalized vector.
* @param {Cartesian3} v3 One decoded and normalized vector.
*/
AttributeCompression.octUnpack = function(packed, v1, v2, v3) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('packed', packed);
Check.Check.defined('v1', v1);
Check.Check.defined('v2', v2);
Check.Check.defined('v3', v3);
//>>includeEnd('debug');
var temp = packed.x / 65536.0;
var x = Math.floor(temp);
var encodedFloat1 = (temp - x) * 65536.0;
temp = packed.y / 65536.0;
var y = Math.floor(temp);
var encodedFloat2 = (temp - y) * 65536.0;
AttributeCompression.octDecodeFloat(encodedFloat1, v1);
AttributeCompression.octDecodeFloat(encodedFloat2, v2);
AttributeCompression.octDecode(x, y, v3);
};
/**
* Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.
*
* @param {Cartesian2} textureCoordinates The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.
* @returns {Number} The packed texture coordinates.
*
*/
AttributeCompression.compressTextureCoordinates = function(textureCoordinates) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('textureCoordinates', textureCoordinates);
//>>includeEnd('debug');
// Move x and y to the range 0-4095;
var x = (textureCoordinates.x * 4095.0) | 0;
var y = (textureCoordinates.y * 4095.0) | 0;
return 4096.0 * x + y;
};
/**
* Decompresses texture coordinates that were packed into a single float.
*
* @param {Number} compressed The compressed texture coordinates.
* @param {Cartesian2} result The decompressed texture coordinates.
* @returns {Cartesian2} The modified result parameter.
*
*/
AttributeCompression.decompressTextureCoordinates = function(compressed, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('compressed', compressed);
Check.Check.defined('result', result);
//>>includeEnd('debug');
var temp = compressed / 4096.0;
var xZeroTo4095 = Math.floor(temp);
result.x = xZeroTo4095 / 4095.0;
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
return result;
};
function zigZagDecode(value) {
return (value >> 1) ^ (-(value & 1));
}
/**
* Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.
*
* @param {Uint16Array} uBuffer The buffer view of u values.
* @param {Uint16Array} vBuffer The buffer view of v values.
* @param {Uint16Array} [heightBuffer] The buffer view of height values.
*
* @see {@link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format}
*/
AttributeCompression.zigZagDeltaDecode = function(uBuffer, vBuffer, heightBuffer) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('uBuffer', uBuffer);
Check.Check.defined('vBuffer', vBuffer);
Check.Check.typeOf.number.equals('uBuffer.length', 'vBuffer.length', uBuffer.length, vBuffer.length);
if (when.defined(heightBuffer)) {
Check.Check.typeOf.number.equals('uBuffer.length', 'heightBuffer.length', uBuffer.length, heightBuffer.length);
}
//>>includeEnd('debug');
var count = uBuffer.length;
var u = 0;
var v = 0;
var height = 0;
for (var i = 0; i < count; ++i) {
u += zigZagDecode(uBuffer[i]);
v += zigZagDecode(vBuffer[i]);
uBuffer[i] = u;
vBuffer[i] = v;
if (when.defined(heightBuffer)) {
height += zigZagDecode(heightBuffer[i]);
heightBuffer[i] = height;
}
}
};
// 将oct压缩的short转化为float
AttributeCompression.octShortToFloat = function(s){
//var tempF = s * 1.0 / ((1 << 15) - 1);
return _Math.CesiumMath.clamp(s * 0.00003051850947599719, -1.0, 1.0);
};
// 将oct压缩的两个short解压为三个float
AttributeCompression.octShortDecode = function(x, y, result) {
Check.Check.defined('result', result);
result.x = AttributeCompression.octShortToFloat(x);
result.y = AttributeCompression.octShortToFloat(y);
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
if (result.z < 0.0)
{
var oldVX = result.x;
result.x = (1.0 - Math.abs(result.y)) * _Math.CesiumMath.signNotZero(oldVX);
result.y = (1.0 - Math.abs(oldVX)) * _Math.CesiumMath.signNotZero(result.y);
}
return Cartographic.Cartesian3.normalize(result, result);
};
exports.AttributeCompression = AttributeCompression;
});

View File

@ -1 +0,0 @@
define(["exports","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./Math-119be1a3"],(function(t,o,e,a,n,r){"use strict";var c=1/256,i={octEncodeInRange:function(t,o,e){if(e.x=t.x/(Math.abs(t.x)+Math.abs(t.y)+Math.abs(t.z)),e.y=t.y/(Math.abs(t.x)+Math.abs(t.y)+Math.abs(t.z)),t.z<0){var a=e.x,n=e.y;e.x=(1-Math.abs(n))*r.CesiumMath.signNotZero(a),e.y=(1-Math.abs(a))*r.CesiumMath.signNotZero(n)}return e.x=r.CesiumMath.toSNorm(e.x,o),e.y=r.CesiumMath.toSNorm(e.y,o),e},octEncode:function(t,o){return i.octEncodeInRange(t,255,o)}},s=new o.Cartesian2,u=new Uint8Array(1);function h(t){return u[0]=t,u[0]}i.octEncodeToCartesian4=function(t,o){return i.octEncodeInRange(t,65535,s),o.x=h(s.x*c),o.y=h(s.x),o.z=h(s.y*c),o.w=h(s.y),o},i.octDecodeInRange=function(t,o,a,n){if(n.x=r.CesiumMath.fromSNorm(t,a),n.y=r.CesiumMath.fromSNorm(o,a),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){var c=n.x;n.x=(1-Math.abs(n.y))*r.CesiumMath.signNotZero(c),n.y=(1-Math.abs(c))*r.CesiumMath.signNotZero(n.y)}return e.Cartesian3.normalize(n,n)},i.octDecode=function(t,o,e){return i.octDecodeInRange(t,o,255,e)},i.octDecodeFromCartesian4=function(t,o){var e=256*t.x+t.y,a=256*t.z+t.w;return i.octDecodeInRange(e,a,65535,o)},i.octPackFloat=function(t){return 256*t.x+t.y};var d=new o.Cartesian2;function f(t){return t>>1^-(1&t)}i.octEncodeFloat=function(t){return i.octEncode(t,d),i.octPackFloat(d)},i.octDecodeFloat=function(t,o){var e=t/256,a=Math.floor(e),n=256*(e-a);return i.octDecode(a,n,o)},i.octPack=function(t,o,e,a){var n=i.octEncodeFloat(t),r=i.octEncodeFloat(o),c=i.octEncode(e,d);return a.x=65536*c.x+n,a.y=65536*c.y+r,a},i.octUnpack=function(t,o,e,a){var n=t.x/65536,r=Math.floor(n),c=65536*(n-r);n=t.y/65536;var s=Math.floor(n),u=65536*(n-s);i.octDecodeFloat(c,o),i.octDecodeFloat(u,e),i.octDecode(r,s,a)},i.compressTextureCoordinates=function(t){return 4096*(4095*t.x|0)+(4095*t.y|0)},i.decompressTextureCoordinates=function(t,o){var e=t/4096,a=Math.floor(e);return o.x=a/4095,o.y=(t-4096*a)/4095,o},i.zigZagDeltaDecode=function(t,o,e){for(var a=t.length,r=0,c=0,i=0,s=0;s<a;++s)r+=f(t[s]),c+=f(o[s]),t[s]=r,o[s]=c,n.defined(e)&&(i+=f(e[s]),e[s]=i)},i.octShortToFloat=function(t){return r.CesiumMath.clamp(3051850947599719e-20*t,-1,1)},i.octShortDecode=function(t,o,n){if(a.Check.defined("result",n),n.x=i.octShortToFloat(t),n.y=i.octShortToFloat(o),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){var c=n.x;n.x=(1-Math.abs(n.y))*r.CesiumMath.signNotZero(c),n.y=(1-Math.abs(c))*r.CesiumMath.signNotZero(n.y)}return e.Cartesian3.normalize(n,n)},t.AttributeCompression=i}));

View File

@ -1,415 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632'], function (exports, when, Check, _Math, Cartographic, Cartesian2) { 'use strict';
var RIGHT_SHIFT = 1.0 / 256.0;
var LEFT_SHIFT = 256.0;
/**
* Attribute compression and decompression functions.
*
* @exports AttributeCompression
*
* @private
*/
var AttributeCompression = {};
/**
* Encodes a normalized vector into 2 SNORM values in the range of [0-rangeMax] following the 'oct' encoding.
*
* Oct encoding is a compact representation of unit length vectors.
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
* Cigolle et al 2014: {@link http://jcgt.org/published/0003/02/01/}
*
* @param {Cartesian3} vector The normalized vector to be compressed into 2 component 'oct' encoding.
* @param {Cartesian2} result The 2 component oct-encoded unit length vector.
* @param {Number} rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
* @returns {Cartesian2} The 2 component oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*
* @see AttributeCompression.octDecodeInRange
*/
AttributeCompression.octEncodeInRange = function(vector, rangeMax, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('vector', vector);
Check.Check.defined('result', result);
var magSquared = Cartographic.Cartesian3.magnitudeSquared(vector);
if (Math.abs(magSquared - 1.0) > _Math.CesiumMath.EPSILON6) {
throw new Check.DeveloperError('vector must be normalized.');
}
//>>includeEnd('debug');
result.x = vector.x / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
result.y = vector.y / (Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z));
if (vector.z < 0) {
var x = result.x;
var y = result.y;
result.x = (1.0 - Math.abs(y)) * _Math.CesiumMath.signNotZero(x);
result.y = (1.0 - Math.abs(x)) * _Math.CesiumMath.signNotZero(y);
}
result.x = _Math.CesiumMath.toSNorm(result.x, rangeMax);
result.y = _Math.CesiumMath.toSNorm(result.y, rangeMax);
return result;
};
/**
* Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding.
*
* @param {Cartesian3} vector The normalized vector to be compressed into 2 byte 'oct' encoding.
* @param {Cartesian2} result The 2 byte oct-encoded unit length vector.
* @returns {Cartesian2} The 2 byte oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*
* @see AttributeCompression.octEncodeInRange
* @see AttributeCompression.octDecode
*/
AttributeCompression.octEncode = function(vector, result) {
return AttributeCompression.octEncodeInRange(vector, 255, result);
};
var octEncodeScratch = new Cartesian2.Cartesian2();
var uint8ForceArray = new Uint8Array(1);
function forceUint8(value) {
uint8ForceArray[0] = value;
return uint8ForceArray[0];
}
/**
* @param {Cartesian3} vector The normalized vector to be compressed into 4 byte 'oct' encoding.
* @param {Cartesian4} result The 4 byte oct-encoded unit length vector.
* @returns {Cartesian4} The 4 byte oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*
* @see AttributeCompression.octEncodeInRange
* @see AttributeCompression.octDecodeFromCartesian4
*/
AttributeCompression.octEncodeToCartesian4 = function(vector, result) {
AttributeCompression.octEncodeInRange(vector, 65535, octEncodeScratch);
result.x = forceUint8(octEncodeScratch.x * RIGHT_SHIFT);
result.y = forceUint8(octEncodeScratch.x);
result.z = forceUint8(octEncodeScratch.y * RIGHT_SHIFT);
result.w = forceUint8(octEncodeScratch.y);
return result;
};
/**
* Decodes a unit-length vector in 'oct' encoding to a normalized 3-component vector.
*
* @param {Number} x The x component of the oct-encoded unit length vector.
* @param {Number} y The y component of the oct-encoded unit length vector.
* @param {Number} rangeMax The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
* @param {Cartesian3} result The decoded and normalized vector
* @returns {Cartesian3} The decoded and normalized vector.
*
* @exception {DeveloperError} x and y must be unsigned normalized integers between 0 and rangeMax.
*
* @see AttributeCompression.octEncodeInRange
*/
AttributeCompression.octDecodeInRange = function(x, y, rangeMax, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('result', result);
if (x < 0 || x > rangeMax || y < 0 || y > rangeMax) {
throw new Check.DeveloperError('x and y must be unsigned normalized integers between 0 and ' + rangeMax);
}
//>>includeEnd('debug');
result.x = _Math.CesiumMath.fromSNorm(x, rangeMax);
result.y = _Math.CesiumMath.fromSNorm(y, rangeMax);
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
if (result.z < 0.0)
{
var oldVX = result.x;
result.x = (1.0 - Math.abs(result.y)) * _Math.CesiumMath.signNotZero(oldVX);
result.y = (1.0 - Math.abs(oldVX)) * _Math.CesiumMath.signNotZero(result.y);
}
return Cartographic.Cartesian3.normalize(result, result);
};
/**
* Decodes a unit-length vector in 2 byte 'oct' encoding to a normalized 3-component vector.
*
* @param {Number} x The x component of the oct-encoded unit length vector.
* @param {Number} y The y component of the oct-encoded unit length vector.
* @param {Cartesian3} result The decoded and normalized vector.
* @returns {Cartesian3} The decoded and normalized vector.
*
* @exception {DeveloperError} x and y must be an unsigned normalized integer between 0 and 255.
*
* @see AttributeCompression.octDecodeInRange
*/
AttributeCompression.octDecode = function(x, y, result) {
return AttributeCompression.octDecodeInRange(x, y, 255, result);
};
/**
* Decodes a unit-length vector in 4 byte 'oct' encoding to a normalized 3-component vector.
*
* @param {Cartesian4} encoded The oct-encoded unit length vector.
* @param {Cartesian3} result The decoded and normalized vector.
* @returns {Cartesian3} The decoded and normalized vector.
*
* @exception {DeveloperError} x, y, z, and w must be unsigned normalized integers between 0 and 255.
*
* @see AttributeCompression.octDecodeInRange
* @see AttributeCompression.octEncodeToCartesian4
*/
AttributeCompression.octDecodeFromCartesian4 = function(encoded, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('encoded', encoded);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
var x = encoded.x;
var y = encoded.y;
var z = encoded.z;
var w = encoded.w;
//>>includeStart('debug', pragmas.debug);
if (x < 0 || x > 255 || y < 0 || y > 255 || z < 0 || z > 255 || w < 0 || w > 255) {
throw new Check.DeveloperError('x, y, z, and w must be unsigned normalized integers between 0 and 255');
}
//>>includeEnd('debug');
var xOct16 = x * LEFT_SHIFT + y;
var yOct16 = z * LEFT_SHIFT + w;
return AttributeCompression.octDecodeInRange(xOct16, yOct16, 65535, result);
};
/**
* Packs an oct encoded vector into a single floating-point number.
*
* @param {Cartesian2} encoded The oct encoded vector.
* @returns {Number} The oct encoded vector packed into a single float.
*
*/
AttributeCompression.octPackFloat = function(encoded) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('encoded', encoded);
//>>includeEnd('debug');
return 256.0 * encoded.x + encoded.y;
};
var scratchEncodeCart2 = new Cartesian2.Cartesian2();
/**
* Encodes a normalized vector into 2 SNORM values in the range of [0-255] following the 'oct' encoding and
* stores those values in a single float-point number.
*
* @param {Cartesian3} vector The normalized vector to be compressed into 2 byte 'oct' encoding.
* @returns {Number} The 2 byte oct-encoded unit length vector.
*
* @exception {DeveloperError} vector must be normalized.
*/
AttributeCompression.octEncodeFloat = function(vector) {
AttributeCompression.octEncode(vector, scratchEncodeCart2);
return AttributeCompression.octPackFloat(scratchEncodeCart2);
};
/**
* Decodes a unit-length vector in 'oct' encoding packed in a floating-point number to a normalized 3-component vector.
*
* @param {Number} value The oct-encoded unit length vector stored as a single floating-point number.
* @param {Cartesian3} result The decoded and normalized vector
* @returns {Cartesian3} The decoded and normalized vector.
*
*/
AttributeCompression.octDecodeFloat = function(value, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('value', value);
//>>includeEnd('debug');
var temp = value / 256.0;
var x = Math.floor(temp);
var y = (temp - x) * 256.0;
return AttributeCompression.octDecode(x, y, result);
};
/**
* Encodes three normalized vectors into 6 SNORM values in the range of [0-255] following the 'oct' encoding and
* packs those into two floating-point numbers.
*
* @param {Cartesian3} v1 A normalized vector to be compressed.
* @param {Cartesian3} v2 A normalized vector to be compressed.
* @param {Cartesian3} v3 A normalized vector to be compressed.
* @param {Cartesian2} result The 'oct' encoded vectors packed into two floating-point numbers.
* @returns {Cartesian2} The 'oct' encoded vectors packed into two floating-point numbers.
*
*/
AttributeCompression.octPack = function(v1, v2, v3, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('v1', v1);
Check.Check.defined('v2', v2);
Check.Check.defined('v3', v3);
Check.Check.defined('result', result);
//>>includeEnd('debug');
var encoded1 = AttributeCompression.octEncodeFloat(v1);
var encoded2 = AttributeCompression.octEncodeFloat(v2);
var encoded3 = AttributeCompression.octEncode(v3, scratchEncodeCart2);
result.x = 65536.0 * encoded3.x + encoded1;
result.y = 65536.0 * encoded3.y + encoded2;
return result;
};
/**
* Decodes three unit-length vectors in 'oct' encoding packed into a floating-point number to a normalized 3-component vector.
*
* @param {Cartesian2} packed The three oct-encoded unit length vectors stored as two floating-point number.
* @param {Cartesian3} v1 One decoded and normalized vector.
* @param {Cartesian3} v2 One decoded and normalized vector.
* @param {Cartesian3} v3 One decoded and normalized vector.
*/
AttributeCompression.octUnpack = function(packed, v1, v2, v3) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('packed', packed);
Check.Check.defined('v1', v1);
Check.Check.defined('v2', v2);
Check.Check.defined('v3', v3);
//>>includeEnd('debug');
var temp = packed.x / 65536.0;
var x = Math.floor(temp);
var encodedFloat1 = (temp - x) * 65536.0;
temp = packed.y / 65536.0;
var y = Math.floor(temp);
var encodedFloat2 = (temp - y) * 65536.0;
AttributeCompression.octDecodeFloat(encodedFloat1, v1);
AttributeCompression.octDecodeFloat(encodedFloat2, v2);
AttributeCompression.octDecode(x, y, v3);
};
/**
* Pack texture coordinates into a single float. The texture coordinates will only preserve 12 bits of precision.
*
* @param {Cartesian2} textureCoordinates The texture coordinates to compress. Both coordinates must be in the range 0.0-1.0.
* @returns {Number} The packed texture coordinates.
*
*/
AttributeCompression.compressTextureCoordinates = function(textureCoordinates) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('textureCoordinates', textureCoordinates);
//>>includeEnd('debug');
// Move x and y to the range 0-4095;
var x = (textureCoordinates.x * 4095.0) | 0;
var y = (textureCoordinates.y * 4095.0) | 0;
return 4096.0 * x + y;
};
/**
* Decompresses texture coordinates that were packed into a single float.
*
* @param {Number} compressed The compressed texture coordinates.
* @param {Cartesian2} result The decompressed texture coordinates.
* @returns {Cartesian2} The modified result parameter.
*
*/
AttributeCompression.decompressTextureCoordinates = function(compressed, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('compressed', compressed);
Check.Check.defined('result', result);
//>>includeEnd('debug');
var temp = compressed / 4096.0;
var xZeroTo4095 = Math.floor(temp);
result.x = xZeroTo4095 / 4095.0;
result.y = (compressed - xZeroTo4095 * 4096) / 4095;
return result;
};
function zigZagDecode(value) {
return (value >> 1) ^ (-(value & 1));
}
/**
* Decodes delta and ZigZag encoded vertices. This modifies the buffers in place.
*
* @param {Uint16Array} uBuffer The buffer view of u values.
* @param {Uint16Array} vBuffer The buffer view of v values.
* @param {Uint16Array} [heightBuffer] The buffer view of height values.
*
* @see {@link https://github.com/AnalyticalGraphicsInc/quantized-mesh|quantized-mesh-1.0 terrain format}
*/
AttributeCompression.zigZagDeltaDecode = function(uBuffer, vBuffer, heightBuffer) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('uBuffer', uBuffer);
Check.Check.defined('vBuffer', vBuffer);
Check.Check.typeOf.number.equals('uBuffer.length', 'vBuffer.length', uBuffer.length, vBuffer.length);
if (when.defined(heightBuffer)) {
Check.Check.typeOf.number.equals('uBuffer.length', 'heightBuffer.length', uBuffer.length, heightBuffer.length);
}
//>>includeEnd('debug');
var count = uBuffer.length;
var u = 0;
var v = 0;
var height = 0;
for (var i = 0; i < count; ++i) {
u += zigZagDecode(uBuffer[i]);
v += zigZagDecode(vBuffer[i]);
uBuffer[i] = u;
vBuffer[i] = v;
if (when.defined(heightBuffer)) {
height += zigZagDecode(heightBuffer[i]);
heightBuffer[i] = height;
}
}
};
// 将oct压缩的short转化为float
AttributeCompression.octShortToFloat = function(s){
//var tempF = s * 1.0 / ((1 << 15) - 1);
return _Math.CesiumMath.clamp(s * 0.00003051850947599719, -1.0, 1.0);
};
// 将oct压缩的两个short解压为三个float
AttributeCompression.octShortDecode = function(x, y, result) {
Check.Check.defined('result', result);
result.x = AttributeCompression.octShortToFloat(x);
result.y = AttributeCompression.octShortToFloat(y);
result.z = 1.0 - (Math.abs(result.x) + Math.abs(result.y));
if (result.z < 0.0)
{
var oldVX = result.x;
result.x = (1.0 - Math.abs(result.y)) * _Math.CesiumMath.signNotZero(oldVX);
result.y = (1.0 - Math.abs(oldVX)) * _Math.CesiumMath.signNotZero(result.y);
}
return Cartographic.Cartesian3.normalize(result, result);
};
exports.AttributeCompression = AttributeCompression;
});

View File

@ -0,0 +1 @@
define(["exports","./Matrix3-81054f0f","./defaultValue-f6d5e6da","./Transforms-20461479"],(function(n,e,t,i){"use strict";function a(n,i,a){this.minimum=e.Cartesian3.clone(t.defaultValue(n,e.Cartesian3.ZERO)),this.maximum=e.Cartesian3.clone(t.defaultValue(i,e.Cartesian3.ZERO)),a=t.defined(a)?e.Cartesian3.clone(a):e.Cartesian3.midpoint(this.minimum,this.maximum,new e.Cartesian3),this.center=a}a.fromCorners=function(n,i,m){return t.defined(m)||(m=new a),m.minimum=e.Cartesian3.clone(n,m.minimum),m.maximum=e.Cartesian3.clone(i,m.maximum),m.center=e.Cartesian3.midpoint(n,i,m.center),m},a.fromPoints=function(n,i){if(t.defined(i)||(i=new a),!t.defined(n)||0===n.length)return i.minimum=e.Cartesian3.clone(e.Cartesian3.ZERO,i.minimum),i.maximum=e.Cartesian3.clone(e.Cartesian3.ZERO,i.maximum),i.center=e.Cartesian3.clone(e.Cartesian3.ZERO,i.center),i;let m=n[0].x,r=n[0].y,s=n[0].z,u=n[0].x,c=n[0].y,o=n[0].z;const l=n.length;for(let e=1;e<l;e++){const t=n[e],i=t.x,a=t.y,l=t.z;m=Math.min(i,m),u=Math.max(i,u),r=Math.min(a,r),c=Math.max(a,c),s=Math.min(l,s),o=Math.max(l,o)}const C=i.minimum;C.x=m,C.y=r,C.z=s;const f=i.maximum;return f.x=u,f.y=c,f.z=o,i.center=e.Cartesian3.midpoint(C,f,i.center),i},a.clone=function(n,i){if(t.defined(n))return t.defined(i)?(i.minimum=e.Cartesian3.clone(n.minimum,i.minimum),i.maximum=e.Cartesian3.clone(n.maximum,i.maximum),i.center=e.Cartesian3.clone(n.center,i.center),i):new a(n.minimum,n.maximum,n.center)},a.equals=function(n,i){return n===i||t.defined(n)&&t.defined(i)&&e.Cartesian3.equals(n.center,i.center)&&e.Cartesian3.equals(n.minimum,i.minimum)&&e.Cartesian3.equals(n.maximum,i.maximum)};let m=new e.Cartesian3;a.intersectPlane=function(n,t){m=e.Cartesian3.subtract(n.maximum,n.minimum,m);const a=e.Cartesian3.multiplyByScalar(m,.5,m),r=t.normal,s=a.x*Math.abs(r.x)+a.y*Math.abs(r.y)+a.z*Math.abs(r.z),u=e.Cartesian3.dot(n.center,r)+t.distance;return u-s>0?i.Intersect.INSIDE:u+s<0?i.Intersect.OUTSIDE:i.Intersect.INTERSECTING},a.prototype.clone=function(n){return a.clone(this,n)},a.prototype.intersectPlane=function(n){return a.intersectPlane(this,n)},a.prototype.equals=function(n){return a.equals(this,n)},n.AxisAlignedBoundingBox=a}));

View File

@ -1 +0,0 @@
define(["exports","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./BoundingSphere-561b54d0"],(function(t,e,n,i,h,r){"use strict";function a(t,e,n,i){this.x=h.defaultValue(t,0),this.y=h.defaultValue(e,0),this.width=h.defaultValue(n,0),this.height=h.defaultValue(i,0)}a.packedLength=4,a.pack=function(t,e,n){return n=h.defaultValue(n,0),e[n++]=t.x,e[n++]=t.y,e[n++]=t.width,e[n]=t.height,e},a.unpack=function(t,e,n){return e=h.defaultValue(e,0),h.defined(n)||(n=new a),n.x=t[e++],n.y=t[e++],n.width=t[e++],n.height=t[e],n},a.fromPoints=function(t,e){if(h.defined(e)||(e=new a),!h.defined(t)||0===t.length)return e.x=0,e.y=0,e.width=0,e.height=0,e;for(var n=t.length,i=t[0].x,r=t[0].y,d=t[0].x,u=t[0].y,c=1;c<n;c++){var o=t[c],f=o.x,x=o.y;i=Math.min(f,i),d=Math.max(f,d),r=Math.min(x,r),u=Math.max(x,u)}return e.x=i,e.y=r,e.width=d-i,e.height=u-r,e};var d=new r.GeographicProjection,u=new n.Cartographic,c=new n.Cartographic;a.fromRectangle=function(t,n,i){if(h.defined(i)||(i=new a),!h.defined(t))return i.x=0,i.y=0,i.width=0,i.height=0,i;var r=(n=h.defaultValue(n,d)).project(e.Rectangle.southwest(t,u)),o=n.project(e.Rectangle.northeast(t,c));return e.Cartesian2.subtract(o,r,o),i.x=r.x,i.y=r.y,i.width=o.x,i.height=o.y,i},a.clone=function(t,e){if(h.defined(t))return h.defined(e)?(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e):new a(t.x,t.y,t.width,t.height)},a.union=function(t,e,n){h.defined(n)||(n=new a);var i=Math.min(t.x,e.x),r=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),u=Math.max(t.y+t.height,e.y+e.height);return n.x=i,n.y=r,n.width=d-i,n.height=u-r,n},a.expand=function(t,e,n){n=a.clone(t,n);var i=e.x-n.x,h=e.y-n.y;return i>n.width?n.width=i:i<0&&(n.width-=i,n.x=e.x),h>n.height?n.height=h:h<0&&(n.height-=h,n.y=e.y),n},a.intersect=function(t,e){var n=t.x,i=t.y,h=e.x,a=e.y;return n>h+e.width||n+t.width<h||i+t.height<a||i>a+e.height?r.Intersect.OUTSIDE:r.Intersect.INTERSECTING},a.equals=function(t,e){return t===e||h.defined(t)&&h.defined(e)&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},a.prototype.clone=function(t){return a.clone(this,t)},a.prototype.intersect=function(t){return a.intersect(this,t)},a.prototype.equals=function(t){return a.equals(this,t)},t.BoundingRectangle=a}));

View File

@ -0,0 +1 @@
define(["exports","./Matrix2-413c4048","./Matrix3-81054f0f","./defaultValue-f6d5e6da","./Transforms-20461479"],(function(t,e,n,i,h){"use strict";function r(t,e,n,h){this.x=i.defaultValue(t,0),this.y=i.defaultValue(e,0),this.width=i.defaultValue(n,0),this.height=i.defaultValue(h,0)}r.packedLength=4,r.pack=function(t,e,n){return n=i.defaultValue(n,0),e[n++]=t.x,e[n++]=t.y,e[n++]=t.width,e[n]=t.height,e},r.unpack=function(t,e,n){return e=i.defaultValue(e,0),i.defined(n)||(n=new r),n.x=t[e++],n.y=t[e++],n.width=t[e++],n.height=t[e],n},r.fromPoints=function(t,e){if(i.defined(e)||(e=new r),!i.defined(t)||0===t.length)return e.x=0,e.y=0,e.width=0,e.height=0,e;const n=t.length;let h=t[0].x,u=t[0].y,d=t[0].x,a=t[0].y;for(let e=1;e<n;e++){const n=t[e],i=n.x,r=n.y;h=Math.min(i,h),d=Math.max(i,d),u=Math.min(r,u),a=Math.max(r,a)}return e.x=h,e.y=u,e.width=d-h,e.height=a-u,e};const u=new h.GeographicProjection,d=new n.Cartographic,a=new n.Cartographic;r.fromRectangle=function(t,n,h){if(i.defined(h)||(h=new r),!i.defined(t))return h.x=0,h.y=0,h.width=0,h.height=0,h;const o=(n=i.defaultValue(n,u)).project(e.Rectangle.southwest(t,d)),c=n.project(e.Rectangle.northeast(t,a));return e.Cartesian2.subtract(c,o,c),h.x=o.x,h.y=o.y,h.width=c.x,h.height=c.y,h},r.clone=function(t,e){if(i.defined(t))return i.defined(e)?(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e):new r(t.x,t.y,t.width,t.height)},r.union=function(t,e,n){i.defined(n)||(n=new r);const h=Math.min(t.x,e.x),u=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),a=Math.max(t.y+t.height,e.y+e.height);return n.x=h,n.y=u,n.width=d-h,n.height=a-u,n},r.expand=function(t,e,n){n=r.clone(t,n);const i=e.x-n.x,h=e.y-n.y;return i>n.width?n.width=i:i<0&&(n.width-=i,n.x=e.x),h>n.height?n.height=h:h<0&&(n.height-=h,n.y=e.y),n},r.intersect=function(t,e){const n=t.x,i=t.y,r=e.x,u=e.y;return n>r+e.width||n+t.width<r||i+t.height<u||i>u+e.height?h.Intersect.OUTSIDE:h.Intersect.INTERSECTING},r.equals=function(t,e){return t===e||i.defined(t)&&i.defined(e)&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},r.prototype.clone=function(t){return r.clone(this,t)},r.prototype.intersect=function(t){return r.intersect(this,t)},r.prototype.equals=function(t){return r.equals(this,t)},t.BoundingRectangle=r}));

View File

@ -1 +0,0 @@
define(["exports","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./buildModuleUrl-4e1b81e7"],(function(t,e,i,n,h,r){"use strict";function a(t,e,i,n){this.x=h.defaultValue(t,0),this.y=h.defaultValue(e,0),this.width=h.defaultValue(i,0),this.height=h.defaultValue(n,0)}a.packedLength=4,a.pack=function(t,e,i){return i=h.defaultValue(i,0),e[i++]=t.x,e[i++]=t.y,e[i++]=t.width,e[i]=t.height,e},a.unpack=function(t,e,i){return e=h.defaultValue(e,0),h.defined(i)||(i=new a),i.x=t[e++],i.y=t[e++],i.width=t[e++],i.height=t[e],i},a.fromPoints=function(t,e){if(h.defined(e)||(e=new a),!h.defined(t)||0===t.length)return e.x=0,e.y=0,e.width=0,e.height=0,e;for(var i=t.length,n=t[0].x,r=t[0].y,d=t[0].x,u=t[0].y,c=1;c<i;c++){var o=t[c],f=o.x,x=o.y;n=Math.min(f,n),d=Math.max(f,d),r=Math.min(x,r),u=Math.max(x,u)}return e.x=n,e.y=r,e.width=d-n,e.height=u-r,e};var d=new r.GeographicProjection,u=new i.Cartographic,c=new i.Cartographic;a.fromRectangle=function(t,i,n){if(h.defined(n)||(n=new a),!h.defined(t))return n.x=0,n.y=0,n.width=0,n.height=0,n;var r=(i=h.defaultValue(i,d)).project(e.Rectangle.southwest(t,u)),o=i.project(e.Rectangle.northeast(t,c));return e.Cartesian2.subtract(o,r,o),n.x=r.x,n.y=r.y,n.width=o.x,n.height=o.y,n},a.clone=function(t,e){if(h.defined(t))return h.defined(e)?(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e):new a(t.x,t.y,t.width,t.height)},a.union=function(t,e,i){h.defined(i)||(i=new a);var n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),u=Math.max(t.y+t.height,e.y+e.height);return i.x=n,i.y=r,i.width=d-n,i.height=u-r,i},a.expand=function(t,e,i){i=a.clone(t,i);var n=e.x-i.x,h=e.y-i.y;return n>i.width?i.width=n:n<0&&(i.width-=n,i.x=e.x),h>i.height?i.height=h:h<0&&(i.height-=h,i.y=e.y),i},a.intersect=function(t,e){var i=t.x,n=t.y,h=e.x,a=e.y;return i>h+e.width||i+t.width<h||n+t.height<a||n>a+e.height?r.Intersect.OUTSIDE:r.Intersect.INTERSECTING},a.equals=function(t,e){return t===e||h.defined(t)&&h.defined(e)&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height},a.prototype.clone=function(t){return a.clone(this,t)},a.prototype.intersect=function(t){return a.intersect(this,t)},a.prototype.equals=function(t){return a.equals(this,t)},t.BoundingRectangle=a}));

View File

@ -1,376 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565'], function (exports, when, Check, Cartographic, Cartesian2, BoundingSphere) { 'use strict';
/**
* A bounding rectangle given by a corner, width and height.
* @alias BoundingRectangle
* @constructor
*
* @param {Number} [x=0.0] The x coordinate of the rectangle.
* @param {Number} [y=0.0] The y coordinate of the rectangle.
* @param {Number} [width=0.0] The width of the rectangle.
* @param {Number} [height=0.0] The height of the rectangle.
*
* @see BoundingSphere
* @see Packable
*/
function BoundingRectangle(x, y, width, height) {
/**
* The x coordinate of the rectangle.
* @type {Number}
* @default 0.0
*/
this.x = when.defaultValue(x, 0.0);
/**
* The y coordinate of the rectangle.
* @type {Number}
* @default 0.0
*/
this.y = when.defaultValue(y, 0.0);
/**
* The width of the rectangle.
* @type {Number}
* @default 0.0
*/
this.width = when.defaultValue(width, 0.0);
/**
* The height of the rectangle.
* @type {Number}
* @default 0.0
*/
this.height = when.defaultValue(height, 0.0);
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
BoundingRectangle.packedLength = 4;
/**
* Stores the provided instance into the provided array.
*
* @param {BoundingRectangle} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
BoundingRectangle.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex++] = value.width;
array[startingIndex] = value.height;
return array;
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {BoundingRectangle} [result] The object into which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
if (!when.defined(result)) {
result = new BoundingRectangle();
}
result.x = array[startingIndex++];
result.y = array[startingIndex++];
result.width = array[startingIndex++];
result.height = array[startingIndex];
return result;
};
/**
* Computes a bounding rectangle enclosing the list of 2D points.
* The rectangle is oriented with the corner at the bottom left.
*
* @param {Cartesian2[]} positions List of points that the bounding rectangle will enclose. Each point must have <code>x</code> and <code>y</code> properties.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.fromPoints = function(positions, result) {
if (!when.defined(result)) {
result = new BoundingRectangle();
}
if (!when.defined(positions) || positions.length === 0) {
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
return result;
}
var length = positions.length;
var minimumX = positions[0].x;
var minimumY = positions[0].y;
var maximumX = positions[0].x;
var maximumY = positions[0].y;
for ( var i = 1; i < length; i++) {
var p = positions[i];
var x = p.x;
var y = p.y;
minimumX = Math.min(x, minimumX);
maximumX = Math.max(x, maximumX);
minimumY = Math.min(y, minimumY);
maximumY = Math.max(y, maximumY);
}
result.x = minimumX;
result.y = minimumY;
result.width = maximumX - minimumX;
result.height = maximumY - minimumY;
return result;
};
var defaultProjection = new BoundingSphere.GeographicProjection();
var fromRectangleLowerLeft = new Cartographic.Cartographic();
var fromRectangleUpperRight = new Cartographic.Cartographic();
/**
* Computes a bounding rectangle from a rectangle.
*
* @param {Rectangle} rectangle The valid rectangle used to create a bounding rectangle.
* @param {Object} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.fromRectangle = function(rectangle, projection, result) {
if (!when.defined(result)) {
result = new BoundingRectangle();
}
if (!when.defined(rectangle)) {
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
return result;
}
projection = when.defaultValue(projection, defaultProjection);
var lowerLeft = projection.project(Cartesian2.Rectangle.southwest(rectangle, fromRectangleLowerLeft));
var upperRight = projection.project(Cartesian2.Rectangle.northeast(rectangle, fromRectangleUpperRight));
Cartesian2.Cartesian2.subtract(upperRight, lowerLeft, upperRight);
result.x = lowerLeft.x;
result.y = lowerLeft.y;
result.width = upperRight.x;
result.height = upperRight.y;
return result;
};
/**
* Duplicates a BoundingRectangle instance.
*
* @param {BoundingRectangle} rectangle The bounding rectangle to duplicate.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided. (Returns undefined if rectangle is undefined)
*/
BoundingRectangle.clone = function(rectangle, result) {
if (!when.defined(rectangle)) {
return undefined;
}
if (!when.defined(result)) {
return new BoundingRectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
result.x = rectangle.x;
result.y = rectangle.y;
result.width = rectangle.width;
result.height = rectangle.height;
return result;
};
/**
* Computes a bounding rectangle that is the union of the left and right bounding rectangles.
*
* @param {BoundingRectangle} left A rectangle to enclose in bounding rectangle.
* @param {BoundingRectangle} right A rectangle to enclose in a bounding rectangle.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.union = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
if (!when.defined(result)) {
result = new BoundingRectangle();
}
var lowerLeftX = Math.min(left.x, right.x);
var lowerLeftY = Math.min(left.y, right.y);
var upperRightX = Math.max(left.x + left.width, right.x + right.width);
var upperRightY = Math.max(left.y + left.height, right.y + right.height);
result.x = lowerLeftX;
result.y = lowerLeftY;
result.width = upperRightX - lowerLeftX;
result.height = upperRightY - lowerLeftY;
return result;
};
/**
* Computes a bounding rectangle by enlarging the provided rectangle until it contains the provided point.
*
* @param {BoundingRectangle} rectangle A rectangle to expand.
* @param {Cartesian2} point A point to enclose in a bounding rectangle.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.expand = function(rectangle, point, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('rectangle', rectangle);
Check.Check.typeOf.object('point', point);
//>>includeEnd('debug');
result = BoundingRectangle.clone(rectangle, result);
var width = point.x - result.x;
var height = point.y - result.y;
if (width > result.width) {
result.width = width;
} else if (width < 0) {
result.width -= width;
result.x = point.x;
}
if (height > result.height) {
result.height = height;
} else if (height < 0) {
result.height -= height;
result.y = point.y;
}
return result;
};
/**
* Determines if two rectangles intersect.
*
* @param {BoundingRectangle} left A rectangle to check for intersection.
* @param {BoundingRectangle} right The other rectangle to check for intersection.
* @returns {Intersect} <code>Intersect.INTESECTING</code> if the rectangles intersect, <code>Intersect.OUTSIDE</code> otherwise.
*/
BoundingRectangle.intersect = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
var leftX = left.x;
var leftY = left.y;
var rightX = right.x;
var rightY = right.y;
if (!(leftX > rightX + right.width ||
leftX + left.width < rightX ||
leftY + left.height < rightY ||
leftY > rightY + right.height)) {
return BoundingSphere.Intersect.INTERSECTING;
}
return BoundingSphere.Intersect.OUTSIDE;
};
/**
* Compares the provided BoundingRectangles componentwise and returns
* <code>true</code> if they are equal, <code>false</code> otherwise.
*
* @param {BoundingRectangle} [left] The first BoundingRectangle.
* @param {BoundingRectangle} [right] The second BoundingRectangle.
* @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
*/
BoundingRectangle.equals = function(left, right) {
return (left === right) ||
((when.defined(left)) &&
(when.defined(right)) &&
(left.x === right.x) &&
(left.y === right.y) &&
(left.width === right.width) &&
(left.height === right.height));
};
/**
* Duplicates this BoundingRectangle instance.
*
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.prototype.clone = function(result) {
return BoundingRectangle.clone(this, result);
};
/**
* Determines if this rectangle intersects with another.
*
* @param {BoundingRectangle} right A rectangle to check for intersection.
* @returns {Intersect} <code>Intersect.INTESECTING</code> if the rectangles intersect, <code>Intersect.OUTSIDE</code> otherwise.
*/
BoundingRectangle.prototype.intersect = function(right) {
return BoundingRectangle.intersect(this, right);
};
/**
* Compares this BoundingRectangle against the provided BoundingRectangle componentwise and returns
* <code>true</code> if they are equal, <code>false</code> otherwise.
*
* @param {BoundingRectangle} [right] The right hand side BoundingRectangle.
* @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
*/
BoundingRectangle.prototype.equals = function(right) {
return BoundingRectangle.equals(this, right);
};
exports.BoundingRectangle = BoundingRectangle;
});

View File

@ -1,376 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788'], function (exports, when, Check, Cartographic, Cartesian2, BoundingSphere) { 'use strict';
/**
* A bounding rectangle given by a corner, width and height.
* @alias BoundingRectangle
* @constructor
*
* @param {Number} [x=0.0] The x coordinate of the rectangle.
* @param {Number} [y=0.0] The y coordinate of the rectangle.
* @param {Number} [width=0.0] The width of the rectangle.
* @param {Number} [height=0.0] The height of the rectangle.
*
* @see BoundingSphere
* @see Packable
*/
function BoundingRectangle(x, y, width, height) {
/**
* The x coordinate of the rectangle.
* @type {Number}
* @default 0.0
*/
this.x = when.defaultValue(x, 0.0);
/**
* The y coordinate of the rectangle.
* @type {Number}
* @default 0.0
*/
this.y = when.defaultValue(y, 0.0);
/**
* The width of the rectangle.
* @type {Number}
* @default 0.0
*/
this.width = when.defaultValue(width, 0.0);
/**
* The height of the rectangle.
* @type {Number}
* @default 0.0
*/
this.height = when.defaultValue(height, 0.0);
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
BoundingRectangle.packedLength = 4;
/**
* Stores the provided instance into the provided array.
*
* @param {BoundingRectangle} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
BoundingRectangle.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex++] = value.width;
array[startingIndex] = value.height;
return array;
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {BoundingRectangle} [result] The object into which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
if (!when.defined(result)) {
result = new BoundingRectangle();
}
result.x = array[startingIndex++];
result.y = array[startingIndex++];
result.width = array[startingIndex++];
result.height = array[startingIndex];
return result;
};
/**
* Computes a bounding rectangle enclosing the list of 2D points.
* The rectangle is oriented with the corner at the bottom left.
*
* @param {Cartesian2[]} positions List of points that the bounding rectangle will enclose. Each point must have <code>x</code> and <code>y</code> properties.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.fromPoints = function(positions, result) {
if (!when.defined(result)) {
result = new BoundingRectangle();
}
if (!when.defined(positions) || positions.length === 0) {
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
return result;
}
var length = positions.length;
var minimumX = positions[0].x;
var minimumY = positions[0].y;
var maximumX = positions[0].x;
var maximumY = positions[0].y;
for ( var i = 1; i < length; i++) {
var p = positions[i];
var x = p.x;
var y = p.y;
minimumX = Math.min(x, minimumX);
maximumX = Math.max(x, maximumX);
minimumY = Math.min(y, minimumY);
maximumY = Math.max(y, maximumY);
}
result.x = minimumX;
result.y = minimumY;
result.width = maximumX - minimumX;
result.height = maximumY - minimumY;
return result;
};
var defaultProjection = new BoundingSphere.GeographicProjection();
var fromRectangleLowerLeft = new Cartographic.Cartographic();
var fromRectangleUpperRight = new Cartographic.Cartographic();
/**
* Computes a bounding rectangle from a rectangle.
*
* @param {Rectangle} rectangle The valid rectangle used to create a bounding rectangle.
* @param {Object} [projection=GeographicProjection] The projection used to project the rectangle into 2D.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.fromRectangle = function(rectangle, projection, result) {
if (!when.defined(result)) {
result = new BoundingRectangle();
}
if (!when.defined(rectangle)) {
result.x = 0;
result.y = 0;
result.width = 0;
result.height = 0;
return result;
}
projection = when.defaultValue(projection, defaultProjection);
var lowerLeft = projection.project(Cartesian2.Rectangle.southwest(rectangle, fromRectangleLowerLeft));
var upperRight = projection.project(Cartesian2.Rectangle.northeast(rectangle, fromRectangleUpperRight));
Cartesian2.Cartesian2.subtract(upperRight, lowerLeft, upperRight);
result.x = lowerLeft.x;
result.y = lowerLeft.y;
result.width = upperRight.x;
result.height = upperRight.y;
return result;
};
/**
* Duplicates a BoundingRectangle instance.
*
* @param {BoundingRectangle} rectangle The bounding rectangle to duplicate.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided. (Returns undefined if rectangle is undefined)
*/
BoundingRectangle.clone = function(rectangle, result) {
if (!when.defined(rectangle)) {
return undefined;
}
if (!when.defined(result)) {
return new BoundingRectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
}
result.x = rectangle.x;
result.y = rectangle.y;
result.width = rectangle.width;
result.height = rectangle.height;
return result;
};
/**
* Computes a bounding rectangle that is the union of the left and right bounding rectangles.
*
* @param {BoundingRectangle} left A rectangle to enclose in bounding rectangle.
* @param {BoundingRectangle} right A rectangle to enclose in a bounding rectangle.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.union = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
if (!when.defined(result)) {
result = new BoundingRectangle();
}
var lowerLeftX = Math.min(left.x, right.x);
var lowerLeftY = Math.min(left.y, right.y);
var upperRightX = Math.max(left.x + left.width, right.x + right.width);
var upperRightY = Math.max(left.y + left.height, right.y + right.height);
result.x = lowerLeftX;
result.y = lowerLeftY;
result.width = upperRightX - lowerLeftX;
result.height = upperRightY - lowerLeftY;
return result;
};
/**
* Computes a bounding rectangle by enlarging the provided rectangle until it contains the provided point.
*
* @param {BoundingRectangle} rectangle A rectangle to expand.
* @param {Cartesian2} point A point to enclose in a bounding rectangle.
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.expand = function(rectangle, point, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('rectangle', rectangle);
Check.Check.typeOf.object('point', point);
//>>includeEnd('debug');
result = BoundingRectangle.clone(rectangle, result);
var width = point.x - result.x;
var height = point.y - result.y;
if (width > result.width) {
result.width = width;
} else if (width < 0) {
result.width -= width;
result.x = point.x;
}
if (height > result.height) {
result.height = height;
} else if (height < 0) {
result.height -= height;
result.y = point.y;
}
return result;
};
/**
* Determines if two rectangles intersect.
*
* @param {BoundingRectangle} left A rectangle to check for intersection.
* @param {BoundingRectangle} right The other rectangle to check for intersection.
* @returns {Intersect} <code>Intersect.INTESECTING</code> if the rectangles intersect, <code>Intersect.OUTSIDE</code> otherwise.
*/
BoundingRectangle.intersect = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
var leftX = left.x;
var leftY = left.y;
var rightX = right.x;
var rightY = right.y;
if (!(leftX > rightX + right.width ||
leftX + left.width < rightX ||
leftY + left.height < rightY ||
leftY > rightY + right.height)) {
return BoundingSphere.Intersect.INTERSECTING;
}
return BoundingSphere.Intersect.OUTSIDE;
};
/**
* Compares the provided BoundingRectangles componentwise and returns
* <code>true</code> if they are equal, <code>false</code> otherwise.
*
* @param {BoundingRectangle} [left] The first BoundingRectangle.
* @param {BoundingRectangle} [right] The second BoundingRectangle.
* @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
*/
BoundingRectangle.equals = function(left, right) {
return (left === right) ||
((when.defined(left)) &&
(when.defined(right)) &&
(left.x === right.x) &&
(left.y === right.y) &&
(left.width === right.width) &&
(left.height === right.height));
};
/**
* Duplicates this BoundingRectangle instance.
*
* @param {BoundingRectangle} [result] The object onto which to store the result.
* @returns {BoundingRectangle} The modified result parameter or a new BoundingRectangle instance if one was not provided.
*/
BoundingRectangle.prototype.clone = function(result) {
return BoundingRectangle.clone(this, result);
};
/**
* Determines if this rectangle intersects with another.
*
* @param {BoundingRectangle} right A rectangle to check for intersection.
* @returns {Intersect} <code>Intersect.INTESECTING</code> if the rectangles intersect, <code>Intersect.OUTSIDE</code> otherwise.
*/
BoundingRectangle.prototype.intersect = function(right) {
return BoundingRectangle.intersect(this, right);
};
/**
* Compares this BoundingRectangle against the provided BoundingRectangle componentwise and returns
* <code>true</code> if they are equal, <code>false</code> otherwise.
*
* @param {BoundingRectangle} [right] The right hand side BoundingRectangle.
* @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
*/
BoundingRectangle.prototype.equals = function(right) {
return BoundingRectangle.equals(this, right);
};
exports.BoundingRectangle = BoundingRectangle;
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,913 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-fe4be337', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-ed9d707f', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402'], function (exports, when, Check, Cartographic, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, arrayFill, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var diffScratch = new Cartographic.Cartesian3();
/**
* Describes a cube centered at the origin.
*
* @alias BoxGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box.
* @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @see BoxGeometry.fromDimensions
* @see BoxGeometry.createGeometry
* @see Packable
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Box.html|Cesium Sandcastle Box Demo}
*
* @example
* var box = new Cesium.BoxGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0),
* minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*/
function BoxGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var min = options.minimum;
var max = options.maximum;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('min', min);
Check.Check.typeOf.object('max', max);
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
this._minimum = Cartographic.Cartesian3.clone(min);
this._maximum = Cartographic.Cartesian3.clone(max);
this._vertexFormat = vertexFormat;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createBoxGeometry';
}
/**
* Creates a cube centered at the origin given its dimensions.
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.dimensions The width, depth, and height of the box stored in the x, y, and z coordinates of the <code>Cartesian3</code>, respectively.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
* @returns {BoxGeometry}
*
* @exception {DeveloperError} All dimensions components must be greater than or equal to zero.
*
*
* @example
* var box = Cesium.BoxGeometry.fromDimensions({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* dimensions : new Cesium.Cartesian3(500000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromDimensions = function(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var dimensions = options.dimensions;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('dimensions', dimensions);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.x', dimensions.x, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.y', dimensions.y, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.z', dimensions.z, 0);
//>>includeEnd('debug');
var corner = Cartographic.Cartesian3.multiplyByScalar(dimensions, 0.5, new Cartographic.Cartesian3());
return new BoxGeometry({
minimum : Cartographic.Cartesian3.negate(corner, new Cartographic.Cartesian3()),
maximum : corner,
vertexFormat : options.vertexFormat,
offsetAttribute: options.offsetAttribute
});
};
/**
* Creates a cube from the dimensions of an AxisAlignedBoundingBox.
*
* @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox.
* @returns {BoxGeometry}
*
*
*
* @example
* var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([
* -72.0, 40.0,
* -70.0, 35.0,
* -75.0, 30.0,
* -70.0, 30.0,
* -68.0, 40.0
* ]));
* var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox(aabb);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('boundingBox', boundingBox);
//>>includeEnd('debug');
return new BoxGeometry({
minimum : boundingBox.minimum,
maximum : boundingBox.maximum
});
};
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
BoxGeometry.packedLength = 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength + 1;
/**
* Stores the provided instance into the provided array.
*
* @param {BoxGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
BoxGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._minimum, array, startingIndex);
Cartographic.Cartesian3.pack(value._maximum, array, startingIndex + Cartographic.Cartesian3.packedLength);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartographic.Cartesian3.packedLength);
array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchMin = new Cartographic.Cartesian3();
var scratchMax = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
minimum: scratchMin,
maximum: scratchMax,
vertexFormat: scratchVertexFormat,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {BoxGeometry} [result] The object into which to store the result.
* @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided.
*/
BoxGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var min = Cartographic.Cartesian3.unpack(array, startingIndex, scratchMin);
var max = Cartographic.Cartesian3.unpack(array, startingIndex + Cartographic.Cartesian3.packedLength, scratchMax);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex + 2 * Cartographic.Cartesian3.packedLength, scratchVertexFormat);
var offsetAttribute = array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength];
if (!when.defined(result)) {
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new BoxGeometry(scratchOptions);
}
result._minimum = Cartographic.Cartesian3.clone(min, result._minimum);
result._maximum = Cartographic.Cartesian3.clone(max, result._maximum);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a box, including its vertices, indices, and a bounding sphere.
*
* @param {BoxGeometry} boxGeometry A description of the box.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
BoxGeometry.createGeometry = function(boxGeometry) {
var min = boxGeometry._minimum;
var max = boxGeometry._maximum;
var vertexFormat = boxGeometry._vertexFormat;
if (Cartographic.Cartesian3.equals(min, max)) {
return;
}
var attributes = new GeometryAttributes.GeometryAttributes();
var indices;
var positions;
if (vertexFormat.position &&
(vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent)) {
if (vertexFormat.position) {
// 8 corner points. Duplicated 3 times each for each incident edge/face.
positions = new Float64Array(6 * 4 * 3);
// +z face
positions[0] = min.x;
positions[1] = min.y;
positions[2] = max.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = max.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = max.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = max.z;
// -z face
positions[12] = min.x;
positions[13] = min.y;
positions[14] = min.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = min.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = min.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = min.z;
// +x face
positions[24] = max.x;
positions[25] = min.y;
positions[26] = min.z;
positions[27] = max.x;
positions[28] = max.y;
positions[29] = min.z;
positions[30] = max.x;
positions[31] = max.y;
positions[32] = max.z;
positions[33] = max.x;
positions[34] = min.y;
positions[35] = max.z;
// -x face
positions[36] = min.x;
positions[37] = min.y;
positions[38] = min.z;
positions[39] = min.x;
positions[40] = max.y;
positions[41] = min.z;
positions[42] = min.x;
positions[43] = max.y;
positions[44] = max.z;
positions[45] = min.x;
positions[46] = min.y;
positions[47] = max.z;
// +y face
positions[48] = min.x;
positions[49] = max.y;
positions[50] = min.z;
positions[51] = max.x;
positions[52] = max.y;
positions[53] = min.z;
positions[54] = max.x;
positions[55] = max.y;
positions[56] = max.z;
positions[57] = min.x;
positions[58] = max.y;
positions[59] = max.z;
// -y face
positions[60] = min.x;
positions[61] = min.y;
positions[62] = min.z;
positions[63] = max.x;
positions[64] = min.y;
positions[65] = min.z;
positions[66] = max.x;
positions[67] = min.y;
positions[68] = max.z;
positions[69] = min.x;
positions[70] = min.y;
positions[71] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
if (vertexFormat.normal) {
var normals = new Float32Array(6 * 4 * 3);
// +z face
normals[0] = 0.0;
normals[1] = 0.0;
normals[2] = 1.0;
normals[3] = 0.0;
normals[4] = 0.0;
normals[5] = 1.0;
normals[6] = 0.0;
normals[7] = 0.0;
normals[8] = 1.0;
normals[9] = 0.0;
normals[10] = 0.0;
normals[11] = 1.0;
// -z face
normals[12] = 0.0;
normals[13] = 0.0;
normals[14] = -1.0;
normals[15] = 0.0;
normals[16] = 0.0;
normals[17] = -1.0;
normals[18] = 0.0;
normals[19] = 0.0;
normals[20] = -1.0;
normals[21] = 0.0;
normals[22] = 0.0;
normals[23] = -1.0;
// +x face
normals[24] = 1.0;
normals[25] = 0.0;
normals[26] = 0.0;
normals[27] = 1.0;
normals[28] = 0.0;
normals[29] = 0.0;
normals[30] = 1.0;
normals[31] = 0.0;
normals[32] = 0.0;
normals[33] = 1.0;
normals[34] = 0.0;
normals[35] = 0.0;
// -x face
normals[36] = -1.0;
normals[37] = 0.0;
normals[38] = 0.0;
normals[39] = -1.0;
normals[40] = 0.0;
normals[41] = 0.0;
normals[42] = -1.0;
normals[43] = 0.0;
normals[44] = 0.0;
normals[45] = -1.0;
normals[46] = 0.0;
normals[47] = 0.0;
// +y face
normals[48] = 0.0;
normals[49] = 1.0;
normals[50] = 0.0;
normals[51] = 0.0;
normals[52] = 1.0;
normals[53] = 0.0;
normals[54] = 0.0;
normals[55] = 1.0;
normals[56] = 0.0;
normals[57] = 0.0;
normals[58] = 1.0;
normals[59] = 0.0;
// -y face
normals[60] = 0.0;
normals[61] = -1.0;
normals[62] = 0.0;
normals[63] = 0.0;
normals[64] = -1.0;
normals[65] = 0.0;
normals[66] = 0.0;
normals[67] = -1.0;
normals[68] = 0.0;
normals[69] = 0.0;
normals[70] = -1.0;
normals[71] = 0.0;
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.st) {
// 纹理坐标多用一位存储顶点数据哪个面BOX剖面分析贴纹理需要用
var texCoords = new Float32Array(6 * 4 * 3);
var texValueIndex = 0;
// +z face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
// -z face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
//+x face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// -x face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// +y face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
// -y face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : texCoords
});
}
if (vertexFormat.tangent) {
var tangents = new Float32Array(6 * 4 * 3);
// +z face
tangents[0] = 1.0;
tangents[1] = 0.0;
tangents[2] = 0.0;
tangents[3] = 1.0;
tangents[4] = 0.0;
tangents[5] = 0.0;
tangents[6] = 1.0;
tangents[7] = 0.0;
tangents[8] = 0.0;
tangents[9] = 1.0;
tangents[10] = 0.0;
tangents[11] = 0.0;
// -z face
tangents[12] = -1.0;
tangents[13] = 0.0;
tangents[14] = 0.0;
tangents[15] = -1.0;
tangents[16] = 0.0;
tangents[17] = 0.0;
tangents[18] = -1.0;
tangents[19] = 0.0;
tangents[20] = 0.0;
tangents[21] = -1.0;
tangents[22] = 0.0;
tangents[23] = 0.0;
// +x face
tangents[24] = 0.0;
tangents[25] = 1.0;
tangents[26] = 0.0;
tangents[27] = 0.0;
tangents[28] = 1.0;
tangents[29] = 0.0;
tangents[30] = 0.0;
tangents[31] = 1.0;
tangents[32] = 0.0;
tangents[33] = 0.0;
tangents[34] = 1.0;
tangents[35] = 0.0;
// -x face
tangents[36] = 0.0;
tangents[37] = -1.0;
tangents[38] = 0.0;
tangents[39] = 0.0;
tangents[40] = -1.0;
tangents[41] = 0.0;
tangents[42] = 0.0;
tangents[43] = -1.0;
tangents[44] = 0.0;
tangents[45] = 0.0;
tangents[46] = -1.0;
tangents[47] = 0.0;
// +y face
tangents[48] = -1.0;
tangents[49] = 0.0;
tangents[50] = 0.0;
tangents[51] = -1.0;
tangents[52] = 0.0;
tangents[53] = 0.0;
tangents[54] = -1.0;
tangents[55] = 0.0;
tangents[56] = 0.0;
tangents[57] = -1.0;
tangents[58] = 0.0;
tangents[59] = 0.0;
// -y face
tangents[60] = 1.0;
tangents[61] = 0.0;
tangents[62] = 0.0;
tangents[63] = 1.0;
tangents[64] = 0.0;
tangents[65] = 0.0;
tangents[66] = 1.0;
tangents[67] = 0.0;
tangents[68] = 0.0;
tangents[69] = 1.0;
tangents[70] = 0.0;
tangents[71] = 0.0;
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
var bitangents = new Float32Array(6 * 4 * 3);
// +z face
bitangents[0] = 0.0;
bitangents[1] = 1.0;
bitangents[2] = 0.0;
bitangents[3] = 0.0;
bitangents[4] = 1.0;
bitangents[5] = 0.0;
bitangents[6] = 0.0;
bitangents[7] = 1.0;
bitangents[8] = 0.0;
bitangents[9] = 0.0;
bitangents[10] = 1.0;
bitangents[11] = 0.0;
// -z face
bitangents[12] = 0.0;
bitangents[13] = 1.0;
bitangents[14] = 0.0;
bitangents[15] = 0.0;
bitangents[16] = 1.0;
bitangents[17] = 0.0;
bitangents[18] = 0.0;
bitangents[19] = 1.0;
bitangents[20] = 0.0;
bitangents[21] = 0.0;
bitangents[22] = 1.0;
bitangents[23] = 0.0;
// +x face
bitangents[24] = 0.0;
bitangents[25] = 0.0;
bitangents[26] = 1.0;
bitangents[27] = 0.0;
bitangents[28] = 0.0;
bitangents[29] = 1.0;
bitangents[30] = 0.0;
bitangents[31] = 0.0;
bitangents[32] = 1.0;
bitangents[33] = 0.0;
bitangents[34] = 0.0;
bitangents[35] = 1.0;
// -x face
bitangents[36] = 0.0;
bitangents[37] = 0.0;
bitangents[38] = 1.0;
bitangents[39] = 0.0;
bitangents[40] = 0.0;
bitangents[41] = 1.0;
bitangents[42] = 0.0;
bitangents[43] = 0.0;
bitangents[44] = 1.0;
bitangents[45] = 0.0;
bitangents[46] = 0.0;
bitangents[47] = 1.0;
// +y face
bitangents[48] = 0.0;
bitangents[49] = 0.0;
bitangents[50] = 1.0;
bitangents[51] = 0.0;
bitangents[52] = 0.0;
bitangents[53] = 1.0;
bitangents[54] = 0.0;
bitangents[55] = 0.0;
bitangents[56] = 1.0;
bitangents[57] = 0.0;
bitangents[58] = 0.0;
bitangents[59] = 1.0;
// -y face
bitangents[60] = 0.0;
bitangents[61] = 0.0;
bitangents[62] = 1.0;
bitangents[63] = 0.0;
bitangents[64] = 0.0;
bitangents[65] = 1.0;
bitangents[66] = 0.0;
bitangents[67] = 0.0;
bitangents[68] = 1.0;
bitangents[69] = 0.0;
bitangents[70] = 0.0;
bitangents[71] = 1.0;
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// +z face
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
// -z face
indices[6] = 4 + 2;
indices[7] = 4 + 1;
indices[8] = 4 + 0;
indices[9] = 4 + 3;
indices[10] = 4 + 2;
indices[11] = 4 + 0;
// +x face
indices[12] = 8 + 0;
indices[13] = 8 + 1;
indices[14] = 8 + 2;
indices[15] = 8 + 0;
indices[16] = 8 + 2;
indices[17] = 8 + 3;
// -x face
indices[18] = 12 + 2;
indices[19] = 12 + 1;
indices[20] = 12 + 0;
indices[21] = 12 + 3;
indices[22] = 12 + 2;
indices[23] = 12 + 0;
// +y face
indices[24] = 16 + 2;
indices[25] = 16 + 1;
indices[26] = 16 + 0;
indices[27] = 16 + 3;
indices[28] = 16 + 2;
indices[29] = 16 + 0;
// -y face
indices[30] = 20 + 0;
indices[31] = 20 + 1;
indices[32] = 20 + 2;
indices[33] = 20 + 0;
indices[34] = 20 + 2;
indices[35] = 20 + 3;
} else {
// Positions only - no need to duplicate corner points
positions = new Float64Array(8 * 3);
positions[0] = min.x;
positions[1] = min.y;
positions[2] = min.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = min.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = min.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = min.z;
positions[12] = min.x;
positions[13] = min.y;
positions[14] = max.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = max.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = max.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// plane z = corner.Z
indices[0] = 4;
indices[1] = 5;
indices[2] = 6;
indices[3] = 4;
indices[4] = 6;
indices[5] = 7;
// plane z = -corner.Z
indices[6] = 1;
indices[7] = 0;
indices[8] = 3;
indices[9] = 1;
indices[10] = 3;
indices[11] = 2;
// plane x = corner.X
indices[12] = 1;
indices[13] = 6;
indices[14] = 5;
indices[15] = 1;
indices[16] = 2;
indices[17] = 6;
// plane y = corner.Y
indices[18] = 2;
indices[19] = 3;
indices[20] = 7;
indices[21] = 2;
indices[22] = 7;
indices[23] = 6;
// plane x = -corner.X
indices[24] = 3;
indices[25] = 0;
indices[26] = 4;
indices[27] = 3;
indices[28] = 4;
indices[29] = 7;
// plane y = -corner.Y
indices[30] = 0;
indices[31] = 1;
indices[32] = 5;
indices[33] = 0;
indices[34] = 5;
indices[35] = 4;
}
var diff = Cartographic.Cartesian3.subtract(max, min, diffScratch);
var radius = Cartographic.Cartesian3.magnitude(diff) * 0.5;
if (when.defined(boxGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = boxGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, radius),
offsetAttribute : boxGeometry._offsetAttribute
});
};
var unitBoxGeometry;
/**
* Returns the geometric representation of a unit box, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
BoxGeometry.getUnitBox = function() {
if (!when.defined(unitBoxGeometry)) {
unitBoxGeometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions({
dimensions : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitBoxGeometry;
};
exports.BoxGeometry = BoxGeometry;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,913 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-f2a06374', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-773da12d', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402'], function (exports, when, Check, Cartographic, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, arrayFill, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var diffScratch = new Cartographic.Cartesian3();
/**
* Describes a cube centered at the origin.
*
* @alias BoxGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box.
* @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @see BoxGeometry.fromDimensions
* @see BoxGeometry.createGeometry
* @see Packable
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Box.html|Cesium Sandcastle Box Demo}
*
* @example
* var box = new Cesium.BoxGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0),
* minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*/
function BoxGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var min = options.minimum;
var max = options.maximum;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('min', min);
Check.Check.typeOf.object('max', max);
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
this._minimum = Cartographic.Cartesian3.clone(min);
this._maximum = Cartographic.Cartesian3.clone(max);
this._vertexFormat = vertexFormat;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createBoxGeometry';
}
/**
* Creates a cube centered at the origin given its dimensions.
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.dimensions The width, depth, and height of the box stored in the x, y, and z coordinates of the <code>Cartesian3</code>, respectively.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
* @returns {BoxGeometry}
*
* @exception {DeveloperError} All dimensions components must be greater than or equal to zero.
*
*
* @example
* var box = Cesium.BoxGeometry.fromDimensions({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* dimensions : new Cesium.Cartesian3(500000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromDimensions = function(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var dimensions = options.dimensions;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('dimensions', dimensions);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.x', dimensions.x, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.y', dimensions.y, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.z', dimensions.z, 0);
//>>includeEnd('debug');
var corner = Cartographic.Cartesian3.multiplyByScalar(dimensions, 0.5, new Cartographic.Cartesian3());
return new BoxGeometry({
minimum : Cartographic.Cartesian3.negate(corner, new Cartographic.Cartesian3()),
maximum : corner,
vertexFormat : options.vertexFormat,
offsetAttribute: options.offsetAttribute
});
};
/**
* Creates a cube from the dimensions of an AxisAlignedBoundingBox.
*
* @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox.
* @returns {BoxGeometry}
*
*
*
* @example
* var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([
* -72.0, 40.0,
* -70.0, 35.0,
* -75.0, 30.0,
* -70.0, 30.0,
* -68.0, 40.0
* ]));
* var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox(aabb);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('boundingBox', boundingBox);
//>>includeEnd('debug');
return new BoxGeometry({
minimum : boundingBox.minimum,
maximum : boundingBox.maximum
});
};
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
BoxGeometry.packedLength = 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength + 1;
/**
* Stores the provided instance into the provided array.
*
* @param {BoxGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
BoxGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._minimum, array, startingIndex);
Cartographic.Cartesian3.pack(value._maximum, array, startingIndex + Cartographic.Cartesian3.packedLength);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartographic.Cartesian3.packedLength);
array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchMin = new Cartographic.Cartesian3();
var scratchMax = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
minimum: scratchMin,
maximum: scratchMax,
vertexFormat: scratchVertexFormat,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {BoxGeometry} [result] The object into which to store the result.
* @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided.
*/
BoxGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var min = Cartographic.Cartesian3.unpack(array, startingIndex, scratchMin);
var max = Cartographic.Cartesian3.unpack(array, startingIndex + Cartographic.Cartesian3.packedLength, scratchMax);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex + 2 * Cartographic.Cartesian3.packedLength, scratchVertexFormat);
var offsetAttribute = array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength];
if (!when.defined(result)) {
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new BoxGeometry(scratchOptions);
}
result._minimum = Cartographic.Cartesian3.clone(min, result._minimum);
result._maximum = Cartographic.Cartesian3.clone(max, result._maximum);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a box, including its vertices, indices, and a bounding sphere.
*
* @param {BoxGeometry} boxGeometry A description of the box.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
BoxGeometry.createGeometry = function(boxGeometry) {
var min = boxGeometry._minimum;
var max = boxGeometry._maximum;
var vertexFormat = boxGeometry._vertexFormat;
if (Cartographic.Cartesian3.equals(min, max)) {
return;
}
var attributes = new GeometryAttributes.GeometryAttributes();
var indices;
var positions;
if (vertexFormat.position &&
(vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent)) {
if (vertexFormat.position) {
// 8 corner points. Duplicated 3 times each for each incident edge/face.
positions = new Float64Array(6 * 4 * 3);
// +z face
positions[0] = min.x;
positions[1] = min.y;
positions[2] = max.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = max.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = max.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = max.z;
// -z face
positions[12] = min.x;
positions[13] = min.y;
positions[14] = min.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = min.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = min.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = min.z;
// +x face
positions[24] = max.x;
positions[25] = min.y;
positions[26] = min.z;
positions[27] = max.x;
positions[28] = max.y;
positions[29] = min.z;
positions[30] = max.x;
positions[31] = max.y;
positions[32] = max.z;
positions[33] = max.x;
positions[34] = min.y;
positions[35] = max.z;
// -x face
positions[36] = min.x;
positions[37] = min.y;
positions[38] = min.z;
positions[39] = min.x;
positions[40] = max.y;
positions[41] = min.z;
positions[42] = min.x;
positions[43] = max.y;
positions[44] = max.z;
positions[45] = min.x;
positions[46] = min.y;
positions[47] = max.z;
// +y face
positions[48] = min.x;
positions[49] = max.y;
positions[50] = min.z;
positions[51] = max.x;
positions[52] = max.y;
positions[53] = min.z;
positions[54] = max.x;
positions[55] = max.y;
positions[56] = max.z;
positions[57] = min.x;
positions[58] = max.y;
positions[59] = max.z;
// -y face
positions[60] = min.x;
positions[61] = min.y;
positions[62] = min.z;
positions[63] = max.x;
positions[64] = min.y;
positions[65] = min.z;
positions[66] = max.x;
positions[67] = min.y;
positions[68] = max.z;
positions[69] = min.x;
positions[70] = min.y;
positions[71] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
if (vertexFormat.normal) {
var normals = new Float32Array(6 * 4 * 3);
// +z face
normals[0] = 0.0;
normals[1] = 0.0;
normals[2] = 1.0;
normals[3] = 0.0;
normals[4] = 0.0;
normals[5] = 1.0;
normals[6] = 0.0;
normals[7] = 0.0;
normals[8] = 1.0;
normals[9] = 0.0;
normals[10] = 0.0;
normals[11] = 1.0;
// -z face
normals[12] = 0.0;
normals[13] = 0.0;
normals[14] = -1.0;
normals[15] = 0.0;
normals[16] = 0.0;
normals[17] = -1.0;
normals[18] = 0.0;
normals[19] = 0.0;
normals[20] = -1.0;
normals[21] = 0.0;
normals[22] = 0.0;
normals[23] = -1.0;
// +x face
normals[24] = 1.0;
normals[25] = 0.0;
normals[26] = 0.0;
normals[27] = 1.0;
normals[28] = 0.0;
normals[29] = 0.0;
normals[30] = 1.0;
normals[31] = 0.0;
normals[32] = 0.0;
normals[33] = 1.0;
normals[34] = 0.0;
normals[35] = 0.0;
// -x face
normals[36] = -1.0;
normals[37] = 0.0;
normals[38] = 0.0;
normals[39] = -1.0;
normals[40] = 0.0;
normals[41] = 0.0;
normals[42] = -1.0;
normals[43] = 0.0;
normals[44] = 0.0;
normals[45] = -1.0;
normals[46] = 0.0;
normals[47] = 0.0;
// +y face
normals[48] = 0.0;
normals[49] = 1.0;
normals[50] = 0.0;
normals[51] = 0.0;
normals[52] = 1.0;
normals[53] = 0.0;
normals[54] = 0.0;
normals[55] = 1.0;
normals[56] = 0.0;
normals[57] = 0.0;
normals[58] = 1.0;
normals[59] = 0.0;
// -y face
normals[60] = 0.0;
normals[61] = -1.0;
normals[62] = 0.0;
normals[63] = 0.0;
normals[64] = -1.0;
normals[65] = 0.0;
normals[66] = 0.0;
normals[67] = -1.0;
normals[68] = 0.0;
normals[69] = 0.0;
normals[70] = -1.0;
normals[71] = 0.0;
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.st) {
// 纹理坐标多用一位存储顶点数据哪个面BOX剖面分析贴纹理需要用
var texCoords = new Float32Array(6 * 4 * 3);
var texValueIndex = 0;
// +z face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
// -z face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
//+x face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// -x face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// +y face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
// -y face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : texCoords
});
}
if (vertexFormat.tangent) {
var tangents = new Float32Array(6 * 4 * 3);
// +z face
tangents[0] = 1.0;
tangents[1] = 0.0;
tangents[2] = 0.0;
tangents[3] = 1.0;
tangents[4] = 0.0;
tangents[5] = 0.0;
tangents[6] = 1.0;
tangents[7] = 0.0;
tangents[8] = 0.0;
tangents[9] = 1.0;
tangents[10] = 0.0;
tangents[11] = 0.0;
// -z face
tangents[12] = -1.0;
tangents[13] = 0.0;
tangents[14] = 0.0;
tangents[15] = -1.0;
tangents[16] = 0.0;
tangents[17] = 0.0;
tangents[18] = -1.0;
tangents[19] = 0.0;
tangents[20] = 0.0;
tangents[21] = -1.0;
tangents[22] = 0.0;
tangents[23] = 0.0;
// +x face
tangents[24] = 0.0;
tangents[25] = 1.0;
tangents[26] = 0.0;
tangents[27] = 0.0;
tangents[28] = 1.0;
tangents[29] = 0.0;
tangents[30] = 0.0;
tangents[31] = 1.0;
tangents[32] = 0.0;
tangents[33] = 0.0;
tangents[34] = 1.0;
tangents[35] = 0.0;
// -x face
tangents[36] = 0.0;
tangents[37] = -1.0;
tangents[38] = 0.0;
tangents[39] = 0.0;
tangents[40] = -1.0;
tangents[41] = 0.0;
tangents[42] = 0.0;
tangents[43] = -1.0;
tangents[44] = 0.0;
tangents[45] = 0.0;
tangents[46] = -1.0;
tangents[47] = 0.0;
// +y face
tangents[48] = -1.0;
tangents[49] = 0.0;
tangents[50] = 0.0;
tangents[51] = -1.0;
tangents[52] = 0.0;
tangents[53] = 0.0;
tangents[54] = -1.0;
tangents[55] = 0.0;
tangents[56] = 0.0;
tangents[57] = -1.0;
tangents[58] = 0.0;
tangents[59] = 0.0;
// -y face
tangents[60] = 1.0;
tangents[61] = 0.0;
tangents[62] = 0.0;
tangents[63] = 1.0;
tangents[64] = 0.0;
tangents[65] = 0.0;
tangents[66] = 1.0;
tangents[67] = 0.0;
tangents[68] = 0.0;
tangents[69] = 1.0;
tangents[70] = 0.0;
tangents[71] = 0.0;
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
var bitangents = new Float32Array(6 * 4 * 3);
// +z face
bitangents[0] = 0.0;
bitangents[1] = 1.0;
bitangents[2] = 0.0;
bitangents[3] = 0.0;
bitangents[4] = 1.0;
bitangents[5] = 0.0;
bitangents[6] = 0.0;
bitangents[7] = 1.0;
bitangents[8] = 0.0;
bitangents[9] = 0.0;
bitangents[10] = 1.0;
bitangents[11] = 0.0;
// -z face
bitangents[12] = 0.0;
bitangents[13] = 1.0;
bitangents[14] = 0.0;
bitangents[15] = 0.0;
bitangents[16] = 1.0;
bitangents[17] = 0.0;
bitangents[18] = 0.0;
bitangents[19] = 1.0;
bitangents[20] = 0.0;
bitangents[21] = 0.0;
bitangents[22] = 1.0;
bitangents[23] = 0.0;
// +x face
bitangents[24] = 0.0;
bitangents[25] = 0.0;
bitangents[26] = 1.0;
bitangents[27] = 0.0;
bitangents[28] = 0.0;
bitangents[29] = 1.0;
bitangents[30] = 0.0;
bitangents[31] = 0.0;
bitangents[32] = 1.0;
bitangents[33] = 0.0;
bitangents[34] = 0.0;
bitangents[35] = 1.0;
// -x face
bitangents[36] = 0.0;
bitangents[37] = 0.0;
bitangents[38] = 1.0;
bitangents[39] = 0.0;
bitangents[40] = 0.0;
bitangents[41] = 1.0;
bitangents[42] = 0.0;
bitangents[43] = 0.0;
bitangents[44] = 1.0;
bitangents[45] = 0.0;
bitangents[46] = 0.0;
bitangents[47] = 1.0;
// +y face
bitangents[48] = 0.0;
bitangents[49] = 0.0;
bitangents[50] = 1.0;
bitangents[51] = 0.0;
bitangents[52] = 0.0;
bitangents[53] = 1.0;
bitangents[54] = 0.0;
bitangents[55] = 0.0;
bitangents[56] = 1.0;
bitangents[57] = 0.0;
bitangents[58] = 0.0;
bitangents[59] = 1.0;
// -y face
bitangents[60] = 0.0;
bitangents[61] = 0.0;
bitangents[62] = 1.0;
bitangents[63] = 0.0;
bitangents[64] = 0.0;
bitangents[65] = 1.0;
bitangents[66] = 0.0;
bitangents[67] = 0.0;
bitangents[68] = 1.0;
bitangents[69] = 0.0;
bitangents[70] = 0.0;
bitangents[71] = 1.0;
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// +z face
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
// -z face
indices[6] = 4 + 2;
indices[7] = 4 + 1;
indices[8] = 4 + 0;
indices[9] = 4 + 3;
indices[10] = 4 + 2;
indices[11] = 4 + 0;
// +x face
indices[12] = 8 + 0;
indices[13] = 8 + 1;
indices[14] = 8 + 2;
indices[15] = 8 + 0;
indices[16] = 8 + 2;
indices[17] = 8 + 3;
// -x face
indices[18] = 12 + 2;
indices[19] = 12 + 1;
indices[20] = 12 + 0;
indices[21] = 12 + 3;
indices[22] = 12 + 2;
indices[23] = 12 + 0;
// +y face
indices[24] = 16 + 2;
indices[25] = 16 + 1;
indices[26] = 16 + 0;
indices[27] = 16 + 3;
indices[28] = 16 + 2;
indices[29] = 16 + 0;
// -y face
indices[30] = 20 + 0;
indices[31] = 20 + 1;
indices[32] = 20 + 2;
indices[33] = 20 + 0;
indices[34] = 20 + 2;
indices[35] = 20 + 3;
} else {
// Positions only - no need to duplicate corner points
positions = new Float64Array(8 * 3);
positions[0] = min.x;
positions[1] = min.y;
positions[2] = min.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = min.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = min.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = min.z;
positions[12] = min.x;
positions[13] = min.y;
positions[14] = max.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = max.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = max.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// plane z = corner.Z
indices[0] = 4;
indices[1] = 5;
indices[2] = 6;
indices[3] = 4;
indices[4] = 6;
indices[5] = 7;
// plane z = -corner.Z
indices[6] = 1;
indices[7] = 0;
indices[8] = 3;
indices[9] = 1;
indices[10] = 3;
indices[11] = 2;
// plane x = corner.X
indices[12] = 1;
indices[13] = 6;
indices[14] = 5;
indices[15] = 1;
indices[16] = 2;
indices[17] = 6;
// plane y = corner.Y
indices[18] = 2;
indices[19] = 3;
indices[20] = 7;
indices[21] = 2;
indices[22] = 7;
indices[23] = 6;
// plane x = -corner.X
indices[24] = 3;
indices[25] = 0;
indices[26] = 4;
indices[27] = 3;
indices[28] = 4;
indices[29] = 7;
// plane y = -corner.Y
indices[30] = 0;
indices[31] = 1;
indices[32] = 5;
indices[33] = 0;
indices[34] = 5;
indices[35] = 4;
}
var diff = Cartographic.Cartesian3.subtract(max, min, diffScratch);
var radius = Cartographic.Cartesian3.magnitude(diff) * 0.5;
if (when.defined(boxGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = boxGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, radius),
offsetAttribute : boxGeometry._offsetAttribute
});
};
var unitBoxGeometry;
/**
* Returns the geometric representation of a unit box, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
BoxGeometry.getUnitBox = function() {
if (!when.defined(unitBoxGeometry)) {
unitBoxGeometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions({
dimensions : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitBoxGeometry;
};
exports.BoxGeometry = BoxGeometry;
});

File diff suppressed because one or more lines are too long

View File

@ -1,913 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-fe4be337', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-91704ebb', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './GeometryOffsetAttribute-ca302482', './VertexFormat-fe4db402'], function (exports, when, Check, Cartographic, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var diffScratch = new Cartographic.Cartesian3();
/**
* Describes a cube centered at the origin.
*
* @alias BoxGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box.
* @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @see BoxGeometry.fromDimensions
* @see BoxGeometry.createGeometry
* @see Packable
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Box.html|Cesium Sandcastle Box Demo}
*
* @example
* var box = new Cesium.BoxGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0),
* minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*/
function BoxGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var min = options.minimum;
var max = options.maximum;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('min', min);
Check.Check.typeOf.object('max', max);
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
this._minimum = Cartographic.Cartesian3.clone(min);
this._maximum = Cartographic.Cartesian3.clone(max);
this._vertexFormat = vertexFormat;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createBoxGeometry';
}
/**
* Creates a cube centered at the origin given its dimensions.
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.dimensions The width, depth, and height of the box stored in the x, y, and z coordinates of the <code>Cartesian3</code>, respectively.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
* @returns {BoxGeometry}
*
* @exception {DeveloperError} All dimensions components must be greater than or equal to zero.
*
*
* @example
* var box = Cesium.BoxGeometry.fromDimensions({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* dimensions : new Cesium.Cartesian3(500000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromDimensions = function(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var dimensions = options.dimensions;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('dimensions', dimensions);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.x', dimensions.x, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.y', dimensions.y, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.z', dimensions.z, 0);
//>>includeEnd('debug');
var corner = Cartographic.Cartesian3.multiplyByScalar(dimensions, 0.5, new Cartographic.Cartesian3());
return new BoxGeometry({
minimum : Cartographic.Cartesian3.negate(corner, new Cartographic.Cartesian3()),
maximum : corner,
vertexFormat : options.vertexFormat,
offsetAttribute: options.offsetAttribute
});
};
/**
* Creates a cube from the dimensions of an AxisAlignedBoundingBox.
*
* @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox.
* @returns {BoxGeometry}
*
*
*
* @example
* var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([
* -72.0, 40.0,
* -70.0, 35.0,
* -75.0, 30.0,
* -70.0, 30.0,
* -68.0, 40.0
* ]));
* var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox(aabb);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('boundingBox', boundingBox);
//>>includeEnd('debug');
return new BoxGeometry({
minimum : boundingBox.minimum,
maximum : boundingBox.maximum
});
};
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
BoxGeometry.packedLength = 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength + 1;
/**
* Stores the provided instance into the provided array.
*
* @param {BoxGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
BoxGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._minimum, array, startingIndex);
Cartographic.Cartesian3.pack(value._maximum, array, startingIndex + Cartographic.Cartesian3.packedLength);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartographic.Cartesian3.packedLength);
array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchMin = new Cartographic.Cartesian3();
var scratchMax = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
minimum: scratchMin,
maximum: scratchMax,
vertexFormat: scratchVertexFormat,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {BoxGeometry} [result] The object into which to store the result.
* @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided.
*/
BoxGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var min = Cartographic.Cartesian3.unpack(array, startingIndex, scratchMin);
var max = Cartographic.Cartesian3.unpack(array, startingIndex + Cartographic.Cartesian3.packedLength, scratchMax);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex + 2 * Cartographic.Cartesian3.packedLength, scratchVertexFormat);
var offsetAttribute = array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength];
if (!when.defined(result)) {
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new BoxGeometry(scratchOptions);
}
result._minimum = Cartographic.Cartesian3.clone(min, result._minimum);
result._maximum = Cartographic.Cartesian3.clone(max, result._maximum);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a box, including its vertices, indices, and a bounding sphere.
*
* @param {BoxGeometry} boxGeometry A description of the box.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
BoxGeometry.createGeometry = function(boxGeometry) {
var min = boxGeometry._minimum;
var max = boxGeometry._maximum;
var vertexFormat = boxGeometry._vertexFormat;
if (Cartographic.Cartesian3.equals(min, max)) {
return;
}
var attributes = new GeometryAttributes.GeometryAttributes();
var indices;
var positions;
if (vertexFormat.position &&
(vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent)) {
if (vertexFormat.position) {
// 8 corner points. Duplicated 3 times each for each incident edge/face.
positions = new Float64Array(6 * 4 * 3);
// +z face
positions[0] = min.x;
positions[1] = min.y;
positions[2] = max.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = max.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = max.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = max.z;
// -z face
positions[12] = min.x;
positions[13] = min.y;
positions[14] = min.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = min.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = min.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = min.z;
// +x face
positions[24] = max.x;
positions[25] = min.y;
positions[26] = min.z;
positions[27] = max.x;
positions[28] = max.y;
positions[29] = min.z;
positions[30] = max.x;
positions[31] = max.y;
positions[32] = max.z;
positions[33] = max.x;
positions[34] = min.y;
positions[35] = max.z;
// -x face
positions[36] = min.x;
positions[37] = min.y;
positions[38] = min.z;
positions[39] = min.x;
positions[40] = max.y;
positions[41] = min.z;
positions[42] = min.x;
positions[43] = max.y;
positions[44] = max.z;
positions[45] = min.x;
positions[46] = min.y;
positions[47] = max.z;
// +y face
positions[48] = min.x;
positions[49] = max.y;
positions[50] = min.z;
positions[51] = max.x;
positions[52] = max.y;
positions[53] = min.z;
positions[54] = max.x;
positions[55] = max.y;
positions[56] = max.z;
positions[57] = min.x;
positions[58] = max.y;
positions[59] = max.z;
// -y face
positions[60] = min.x;
positions[61] = min.y;
positions[62] = min.z;
positions[63] = max.x;
positions[64] = min.y;
positions[65] = min.z;
positions[66] = max.x;
positions[67] = min.y;
positions[68] = max.z;
positions[69] = min.x;
positions[70] = min.y;
positions[71] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
if (vertexFormat.normal) {
var normals = new Float32Array(6 * 4 * 3);
// +z face
normals[0] = 0.0;
normals[1] = 0.0;
normals[2] = 1.0;
normals[3] = 0.0;
normals[4] = 0.0;
normals[5] = 1.0;
normals[6] = 0.0;
normals[7] = 0.0;
normals[8] = 1.0;
normals[9] = 0.0;
normals[10] = 0.0;
normals[11] = 1.0;
// -z face
normals[12] = 0.0;
normals[13] = 0.0;
normals[14] = -1.0;
normals[15] = 0.0;
normals[16] = 0.0;
normals[17] = -1.0;
normals[18] = 0.0;
normals[19] = 0.0;
normals[20] = -1.0;
normals[21] = 0.0;
normals[22] = 0.0;
normals[23] = -1.0;
// +x face
normals[24] = 1.0;
normals[25] = 0.0;
normals[26] = 0.0;
normals[27] = 1.0;
normals[28] = 0.0;
normals[29] = 0.0;
normals[30] = 1.0;
normals[31] = 0.0;
normals[32] = 0.0;
normals[33] = 1.0;
normals[34] = 0.0;
normals[35] = 0.0;
// -x face
normals[36] = -1.0;
normals[37] = 0.0;
normals[38] = 0.0;
normals[39] = -1.0;
normals[40] = 0.0;
normals[41] = 0.0;
normals[42] = -1.0;
normals[43] = 0.0;
normals[44] = 0.0;
normals[45] = -1.0;
normals[46] = 0.0;
normals[47] = 0.0;
// +y face
normals[48] = 0.0;
normals[49] = 1.0;
normals[50] = 0.0;
normals[51] = 0.0;
normals[52] = 1.0;
normals[53] = 0.0;
normals[54] = 0.0;
normals[55] = 1.0;
normals[56] = 0.0;
normals[57] = 0.0;
normals[58] = 1.0;
normals[59] = 0.0;
// -y face
normals[60] = 0.0;
normals[61] = -1.0;
normals[62] = 0.0;
normals[63] = 0.0;
normals[64] = -1.0;
normals[65] = 0.0;
normals[66] = 0.0;
normals[67] = -1.0;
normals[68] = 0.0;
normals[69] = 0.0;
normals[70] = -1.0;
normals[71] = 0.0;
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.st) {
// 纹理坐标多用一位存储顶点数据哪个面BOX剖面分析贴纹理需要用
var texCoords = new Float32Array(6 * 4 * 3);
var texValueIndex = 0;
// +z face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
// -z face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
//+x face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// -x face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// +y face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
// -y face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : texCoords
});
}
if (vertexFormat.tangent) {
var tangents = new Float32Array(6 * 4 * 3);
// +z face
tangents[0] = 1.0;
tangents[1] = 0.0;
tangents[2] = 0.0;
tangents[3] = 1.0;
tangents[4] = 0.0;
tangents[5] = 0.0;
tangents[6] = 1.0;
tangents[7] = 0.0;
tangents[8] = 0.0;
tangents[9] = 1.0;
tangents[10] = 0.0;
tangents[11] = 0.0;
// -z face
tangents[12] = -1.0;
tangents[13] = 0.0;
tangents[14] = 0.0;
tangents[15] = -1.0;
tangents[16] = 0.0;
tangents[17] = 0.0;
tangents[18] = -1.0;
tangents[19] = 0.0;
tangents[20] = 0.0;
tangents[21] = -1.0;
tangents[22] = 0.0;
tangents[23] = 0.0;
// +x face
tangents[24] = 0.0;
tangents[25] = 1.0;
tangents[26] = 0.0;
tangents[27] = 0.0;
tangents[28] = 1.0;
tangents[29] = 0.0;
tangents[30] = 0.0;
tangents[31] = 1.0;
tangents[32] = 0.0;
tangents[33] = 0.0;
tangents[34] = 1.0;
tangents[35] = 0.0;
// -x face
tangents[36] = 0.0;
tangents[37] = -1.0;
tangents[38] = 0.0;
tangents[39] = 0.0;
tangents[40] = -1.0;
tangents[41] = 0.0;
tangents[42] = 0.0;
tangents[43] = -1.0;
tangents[44] = 0.0;
tangents[45] = 0.0;
tangents[46] = -1.0;
tangents[47] = 0.0;
// +y face
tangents[48] = -1.0;
tangents[49] = 0.0;
tangents[50] = 0.0;
tangents[51] = -1.0;
tangents[52] = 0.0;
tangents[53] = 0.0;
tangents[54] = -1.0;
tangents[55] = 0.0;
tangents[56] = 0.0;
tangents[57] = -1.0;
tangents[58] = 0.0;
tangents[59] = 0.0;
// -y face
tangents[60] = 1.0;
tangents[61] = 0.0;
tangents[62] = 0.0;
tangents[63] = 1.0;
tangents[64] = 0.0;
tangents[65] = 0.0;
tangents[66] = 1.0;
tangents[67] = 0.0;
tangents[68] = 0.0;
tangents[69] = 1.0;
tangents[70] = 0.0;
tangents[71] = 0.0;
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
var bitangents = new Float32Array(6 * 4 * 3);
// +z face
bitangents[0] = 0.0;
bitangents[1] = 1.0;
bitangents[2] = 0.0;
bitangents[3] = 0.0;
bitangents[4] = 1.0;
bitangents[5] = 0.0;
bitangents[6] = 0.0;
bitangents[7] = 1.0;
bitangents[8] = 0.0;
bitangents[9] = 0.0;
bitangents[10] = 1.0;
bitangents[11] = 0.0;
// -z face
bitangents[12] = 0.0;
bitangents[13] = 1.0;
bitangents[14] = 0.0;
bitangents[15] = 0.0;
bitangents[16] = 1.0;
bitangents[17] = 0.0;
bitangents[18] = 0.0;
bitangents[19] = 1.0;
bitangents[20] = 0.0;
bitangents[21] = 0.0;
bitangents[22] = 1.0;
bitangents[23] = 0.0;
// +x face
bitangents[24] = 0.0;
bitangents[25] = 0.0;
bitangents[26] = 1.0;
bitangents[27] = 0.0;
bitangents[28] = 0.0;
bitangents[29] = 1.0;
bitangents[30] = 0.0;
bitangents[31] = 0.0;
bitangents[32] = 1.0;
bitangents[33] = 0.0;
bitangents[34] = 0.0;
bitangents[35] = 1.0;
// -x face
bitangents[36] = 0.0;
bitangents[37] = 0.0;
bitangents[38] = 1.0;
bitangents[39] = 0.0;
bitangents[40] = 0.0;
bitangents[41] = 1.0;
bitangents[42] = 0.0;
bitangents[43] = 0.0;
bitangents[44] = 1.0;
bitangents[45] = 0.0;
bitangents[46] = 0.0;
bitangents[47] = 1.0;
// +y face
bitangents[48] = 0.0;
bitangents[49] = 0.0;
bitangents[50] = 1.0;
bitangents[51] = 0.0;
bitangents[52] = 0.0;
bitangents[53] = 1.0;
bitangents[54] = 0.0;
bitangents[55] = 0.0;
bitangents[56] = 1.0;
bitangents[57] = 0.0;
bitangents[58] = 0.0;
bitangents[59] = 1.0;
// -y face
bitangents[60] = 0.0;
bitangents[61] = 0.0;
bitangents[62] = 1.0;
bitangents[63] = 0.0;
bitangents[64] = 0.0;
bitangents[65] = 1.0;
bitangents[66] = 0.0;
bitangents[67] = 0.0;
bitangents[68] = 1.0;
bitangents[69] = 0.0;
bitangents[70] = 0.0;
bitangents[71] = 1.0;
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// +z face
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
// -z face
indices[6] = 4 + 2;
indices[7] = 4 + 1;
indices[8] = 4 + 0;
indices[9] = 4 + 3;
indices[10] = 4 + 2;
indices[11] = 4 + 0;
// +x face
indices[12] = 8 + 0;
indices[13] = 8 + 1;
indices[14] = 8 + 2;
indices[15] = 8 + 0;
indices[16] = 8 + 2;
indices[17] = 8 + 3;
// -x face
indices[18] = 12 + 2;
indices[19] = 12 + 1;
indices[20] = 12 + 0;
indices[21] = 12 + 3;
indices[22] = 12 + 2;
indices[23] = 12 + 0;
// +y face
indices[24] = 16 + 2;
indices[25] = 16 + 1;
indices[26] = 16 + 0;
indices[27] = 16 + 3;
indices[28] = 16 + 2;
indices[29] = 16 + 0;
// -y face
indices[30] = 20 + 0;
indices[31] = 20 + 1;
indices[32] = 20 + 2;
indices[33] = 20 + 0;
indices[34] = 20 + 2;
indices[35] = 20 + 3;
} else {
// Positions only - no need to duplicate corner points
positions = new Float64Array(8 * 3);
positions[0] = min.x;
positions[1] = min.y;
positions[2] = min.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = min.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = min.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = min.z;
positions[12] = min.x;
positions[13] = min.y;
positions[14] = max.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = max.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = max.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// plane z = corner.Z
indices[0] = 4;
indices[1] = 5;
indices[2] = 6;
indices[3] = 4;
indices[4] = 6;
indices[5] = 7;
// plane z = -corner.Z
indices[6] = 1;
indices[7] = 0;
indices[8] = 3;
indices[9] = 1;
indices[10] = 3;
indices[11] = 2;
// plane x = corner.X
indices[12] = 1;
indices[13] = 6;
indices[14] = 5;
indices[15] = 1;
indices[16] = 2;
indices[17] = 6;
// plane y = corner.Y
indices[18] = 2;
indices[19] = 3;
indices[20] = 7;
indices[21] = 2;
indices[22] = 7;
indices[23] = 6;
// plane x = -corner.X
indices[24] = 3;
indices[25] = 0;
indices[26] = 4;
indices[27] = 3;
indices[28] = 4;
indices[29] = 7;
// plane y = -corner.Y
indices[30] = 0;
indices[31] = 1;
indices[32] = 5;
indices[33] = 0;
indices[34] = 5;
indices[35] = 4;
}
var diff = Cartographic.Cartesian3.subtract(max, min, diffScratch);
var radius = Cartographic.Cartesian3.magnitude(diff) * 0.5;
if (when.defined(boxGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = boxGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
GeometryOffsetAttribute.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, radius),
offsetAttribute : boxGeometry._offsetAttribute
});
};
var unitBoxGeometry;
/**
* Returns the geometric representation of a unit box, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
BoxGeometry.getUnitBox = function() {
if (!when.defined(unitBoxGeometry)) {
unitBoxGeometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions({
dimensions : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitBoxGeometry;
};
exports.BoxGeometry = BoxGeometry;
});

View File

@ -1,913 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Cartographic-f2a06374', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-1e248a71', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402'], function (exports, when, Check, Cartographic, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, arrayFill, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var diffScratch = new Cartographic.Cartesian3();
/**
* Describes a cube centered at the origin.
*
* @alias BoxGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.minimum The minimum x, y, and z coordinates of the box.
* @param {Cartesian3} options.maximum The maximum x, y, and z coordinates of the box.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @see BoxGeometry.fromDimensions
* @see BoxGeometry.createGeometry
* @see Packable
*
* @demo {@link https://sandcastle.cesium.com/index.html?src=Box.html|Cesium Sandcastle Box Demo}
*
* @example
* var box = new Cesium.BoxGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* maximum : new Cesium.Cartesian3(250000.0, 250000.0, 250000.0),
* minimum : new Cesium.Cartesian3(-250000.0, -250000.0, -250000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*/
function BoxGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var min = options.minimum;
var max = options.maximum;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('min', min);
Check.Check.typeOf.object('max', max);
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
this._minimum = Cartographic.Cartesian3.clone(min);
this._maximum = Cartographic.Cartesian3.clone(max);
this._vertexFormat = vertexFormat;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createBoxGeometry';
}
/**
* Creates a cube centered at the origin given its dimensions.
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.dimensions The width, depth, and height of the box stored in the x, y, and z coordinates of the <code>Cartesian3</code>, respectively.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
* @returns {BoxGeometry}
*
* @exception {DeveloperError} All dimensions components must be greater than or equal to zero.
*
*
* @example
* var box = Cesium.BoxGeometry.fromDimensions({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* dimensions : new Cesium.Cartesian3(500000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.BoxGeometry.createGeometry(box);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromDimensions = function(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var dimensions = options.dimensions;
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('dimensions', dimensions);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.x', dimensions.x, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.y', dimensions.y, 0);
Check.Check.typeOf.number.greaterThanOrEquals('dimensions.z', dimensions.z, 0);
//>>includeEnd('debug');
var corner = Cartographic.Cartesian3.multiplyByScalar(dimensions, 0.5, new Cartographic.Cartesian3());
return new BoxGeometry({
minimum : Cartographic.Cartesian3.negate(corner, new Cartographic.Cartesian3()),
maximum : corner,
vertexFormat : options.vertexFormat,
offsetAttribute: options.offsetAttribute
});
};
/**
* Creates a cube from the dimensions of an AxisAlignedBoundingBox.
*
* @param {AxisAlignedBoundingBox} boundingBox A description of the AxisAlignedBoundingBox.
* @returns {BoxGeometry}
*
*
*
* @example
* var aabb = Cesium.AxisAlignedBoundingBox.fromPoints(Cesium.Cartesian3.fromDegreesArray([
* -72.0, 40.0,
* -70.0, 35.0,
* -75.0, 30.0,
* -70.0, 30.0,
* -68.0, 40.0
* ]));
* var box = Cesium.BoxGeometry.fromAxisAlignedBoundingBox(aabb);
*
* @see BoxGeometry.createGeometry
*/
BoxGeometry.fromAxisAlignedBoundingBox = function (boundingBox) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('boundingBox', boundingBox);
//>>includeEnd('debug');
return new BoxGeometry({
minimum : boundingBox.minimum,
maximum : boundingBox.maximum
});
};
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
BoxGeometry.packedLength = 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength + 1;
/**
* Stores the provided instance into the provided array.
*
* @param {BoxGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
BoxGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._minimum, array, startingIndex);
Cartographic.Cartesian3.pack(value._maximum, array, startingIndex + Cartographic.Cartesian3.packedLength);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex + 2 * Cartographic.Cartesian3.packedLength);
array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchMin = new Cartographic.Cartesian3();
var scratchMax = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
minimum: scratchMin,
maximum: scratchMax,
vertexFormat: scratchVertexFormat,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {BoxGeometry} [result] The object into which to store the result.
* @returns {BoxGeometry} The modified result parameter or a new BoxGeometry instance if one was not provided.
*/
BoxGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var min = Cartographic.Cartesian3.unpack(array, startingIndex, scratchMin);
var max = Cartographic.Cartesian3.unpack(array, startingIndex + Cartographic.Cartesian3.packedLength, scratchMax);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex + 2 * Cartographic.Cartesian3.packedLength, scratchVertexFormat);
var offsetAttribute = array[startingIndex + 2 * Cartographic.Cartesian3.packedLength + VertexFormat.VertexFormat.packedLength];
if (!when.defined(result)) {
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new BoxGeometry(scratchOptions);
}
result._minimum = Cartographic.Cartesian3.clone(min, result._minimum);
result._maximum = Cartographic.Cartesian3.clone(max, result._maximum);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a box, including its vertices, indices, and a bounding sphere.
*
* @param {BoxGeometry} boxGeometry A description of the box.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
BoxGeometry.createGeometry = function(boxGeometry) {
var min = boxGeometry._minimum;
var max = boxGeometry._maximum;
var vertexFormat = boxGeometry._vertexFormat;
if (Cartographic.Cartesian3.equals(min, max)) {
return;
}
var attributes = new GeometryAttributes.GeometryAttributes();
var indices;
var positions;
if (vertexFormat.position &&
(vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent)) {
if (vertexFormat.position) {
// 8 corner points. Duplicated 3 times each for each incident edge/face.
positions = new Float64Array(6 * 4 * 3);
// +z face
positions[0] = min.x;
positions[1] = min.y;
positions[2] = max.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = max.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = max.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = max.z;
// -z face
positions[12] = min.x;
positions[13] = min.y;
positions[14] = min.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = min.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = min.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = min.z;
// +x face
positions[24] = max.x;
positions[25] = min.y;
positions[26] = min.z;
positions[27] = max.x;
positions[28] = max.y;
positions[29] = min.z;
positions[30] = max.x;
positions[31] = max.y;
positions[32] = max.z;
positions[33] = max.x;
positions[34] = min.y;
positions[35] = max.z;
// -x face
positions[36] = min.x;
positions[37] = min.y;
positions[38] = min.z;
positions[39] = min.x;
positions[40] = max.y;
positions[41] = min.z;
positions[42] = min.x;
positions[43] = max.y;
positions[44] = max.z;
positions[45] = min.x;
positions[46] = min.y;
positions[47] = max.z;
// +y face
positions[48] = min.x;
positions[49] = max.y;
positions[50] = min.z;
positions[51] = max.x;
positions[52] = max.y;
positions[53] = min.z;
positions[54] = max.x;
positions[55] = max.y;
positions[56] = max.z;
positions[57] = min.x;
positions[58] = max.y;
positions[59] = max.z;
// -y face
positions[60] = min.x;
positions[61] = min.y;
positions[62] = min.z;
positions[63] = max.x;
positions[64] = min.y;
positions[65] = min.z;
positions[66] = max.x;
positions[67] = min.y;
positions[68] = max.z;
positions[69] = min.x;
positions[70] = min.y;
positions[71] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
if (vertexFormat.normal) {
var normals = new Float32Array(6 * 4 * 3);
// +z face
normals[0] = 0.0;
normals[1] = 0.0;
normals[2] = 1.0;
normals[3] = 0.0;
normals[4] = 0.0;
normals[5] = 1.0;
normals[6] = 0.0;
normals[7] = 0.0;
normals[8] = 1.0;
normals[9] = 0.0;
normals[10] = 0.0;
normals[11] = 1.0;
// -z face
normals[12] = 0.0;
normals[13] = 0.0;
normals[14] = -1.0;
normals[15] = 0.0;
normals[16] = 0.0;
normals[17] = -1.0;
normals[18] = 0.0;
normals[19] = 0.0;
normals[20] = -1.0;
normals[21] = 0.0;
normals[22] = 0.0;
normals[23] = -1.0;
// +x face
normals[24] = 1.0;
normals[25] = 0.0;
normals[26] = 0.0;
normals[27] = 1.0;
normals[28] = 0.0;
normals[29] = 0.0;
normals[30] = 1.0;
normals[31] = 0.0;
normals[32] = 0.0;
normals[33] = 1.0;
normals[34] = 0.0;
normals[35] = 0.0;
// -x face
normals[36] = -1.0;
normals[37] = 0.0;
normals[38] = 0.0;
normals[39] = -1.0;
normals[40] = 0.0;
normals[41] = 0.0;
normals[42] = -1.0;
normals[43] = 0.0;
normals[44] = 0.0;
normals[45] = -1.0;
normals[46] = 0.0;
normals[47] = 0.0;
// +y face
normals[48] = 0.0;
normals[49] = 1.0;
normals[50] = 0.0;
normals[51] = 0.0;
normals[52] = 1.0;
normals[53] = 0.0;
normals[54] = 0.0;
normals[55] = 1.0;
normals[56] = 0.0;
normals[57] = 0.0;
normals[58] = 1.0;
normals[59] = 0.0;
// -y face
normals[60] = 0.0;
normals[61] = -1.0;
normals[62] = 0.0;
normals[63] = 0.0;
normals[64] = -1.0;
normals[65] = 0.0;
normals[66] = 0.0;
normals[67] = -1.0;
normals[68] = 0.0;
normals[69] = 0.0;
normals[70] = -1.0;
normals[71] = 0.0;
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.st) {
// 纹理坐标多用一位存储顶点数据哪个面BOX剖面分析贴纹理需要用
var texCoords = new Float32Array(6 * 4 * 3);
var texValueIndex = 0;
// +z face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
// -z face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = -1.0;
//+x face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// -x face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
// +y face
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
// -y face
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 0.0;
texCoords[texValueIndex++] = 1.0;
texCoords[texValueIndex++] = 1.0;
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : texCoords
});
}
if (vertexFormat.tangent) {
var tangents = new Float32Array(6 * 4 * 3);
// +z face
tangents[0] = 1.0;
tangents[1] = 0.0;
tangents[2] = 0.0;
tangents[3] = 1.0;
tangents[4] = 0.0;
tangents[5] = 0.0;
tangents[6] = 1.0;
tangents[7] = 0.0;
tangents[8] = 0.0;
tangents[9] = 1.0;
tangents[10] = 0.0;
tangents[11] = 0.0;
// -z face
tangents[12] = -1.0;
tangents[13] = 0.0;
tangents[14] = 0.0;
tangents[15] = -1.0;
tangents[16] = 0.0;
tangents[17] = 0.0;
tangents[18] = -1.0;
tangents[19] = 0.0;
tangents[20] = 0.0;
tangents[21] = -1.0;
tangents[22] = 0.0;
tangents[23] = 0.0;
// +x face
tangents[24] = 0.0;
tangents[25] = 1.0;
tangents[26] = 0.0;
tangents[27] = 0.0;
tangents[28] = 1.0;
tangents[29] = 0.0;
tangents[30] = 0.0;
tangents[31] = 1.0;
tangents[32] = 0.0;
tangents[33] = 0.0;
tangents[34] = 1.0;
tangents[35] = 0.0;
// -x face
tangents[36] = 0.0;
tangents[37] = -1.0;
tangents[38] = 0.0;
tangents[39] = 0.0;
tangents[40] = -1.0;
tangents[41] = 0.0;
tangents[42] = 0.0;
tangents[43] = -1.0;
tangents[44] = 0.0;
tangents[45] = 0.0;
tangents[46] = -1.0;
tangents[47] = 0.0;
// +y face
tangents[48] = -1.0;
tangents[49] = 0.0;
tangents[50] = 0.0;
tangents[51] = -1.0;
tangents[52] = 0.0;
tangents[53] = 0.0;
tangents[54] = -1.0;
tangents[55] = 0.0;
tangents[56] = 0.0;
tangents[57] = -1.0;
tangents[58] = 0.0;
tangents[59] = 0.0;
// -y face
tangents[60] = 1.0;
tangents[61] = 0.0;
tangents[62] = 0.0;
tangents[63] = 1.0;
tangents[64] = 0.0;
tangents[65] = 0.0;
tangents[66] = 1.0;
tangents[67] = 0.0;
tangents[68] = 0.0;
tangents[69] = 1.0;
tangents[70] = 0.0;
tangents[71] = 0.0;
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
var bitangents = new Float32Array(6 * 4 * 3);
// +z face
bitangents[0] = 0.0;
bitangents[1] = 1.0;
bitangents[2] = 0.0;
bitangents[3] = 0.0;
bitangents[4] = 1.0;
bitangents[5] = 0.0;
bitangents[6] = 0.0;
bitangents[7] = 1.0;
bitangents[8] = 0.0;
bitangents[9] = 0.0;
bitangents[10] = 1.0;
bitangents[11] = 0.0;
// -z face
bitangents[12] = 0.0;
bitangents[13] = 1.0;
bitangents[14] = 0.0;
bitangents[15] = 0.0;
bitangents[16] = 1.0;
bitangents[17] = 0.0;
bitangents[18] = 0.0;
bitangents[19] = 1.0;
bitangents[20] = 0.0;
bitangents[21] = 0.0;
bitangents[22] = 1.0;
bitangents[23] = 0.0;
// +x face
bitangents[24] = 0.0;
bitangents[25] = 0.0;
bitangents[26] = 1.0;
bitangents[27] = 0.0;
bitangents[28] = 0.0;
bitangents[29] = 1.0;
bitangents[30] = 0.0;
bitangents[31] = 0.0;
bitangents[32] = 1.0;
bitangents[33] = 0.0;
bitangents[34] = 0.0;
bitangents[35] = 1.0;
// -x face
bitangents[36] = 0.0;
bitangents[37] = 0.0;
bitangents[38] = 1.0;
bitangents[39] = 0.0;
bitangents[40] = 0.0;
bitangents[41] = 1.0;
bitangents[42] = 0.0;
bitangents[43] = 0.0;
bitangents[44] = 1.0;
bitangents[45] = 0.0;
bitangents[46] = 0.0;
bitangents[47] = 1.0;
// +y face
bitangents[48] = 0.0;
bitangents[49] = 0.0;
bitangents[50] = 1.0;
bitangents[51] = 0.0;
bitangents[52] = 0.0;
bitangents[53] = 1.0;
bitangents[54] = 0.0;
bitangents[55] = 0.0;
bitangents[56] = 1.0;
bitangents[57] = 0.0;
bitangents[58] = 0.0;
bitangents[59] = 1.0;
// -y face
bitangents[60] = 0.0;
bitangents[61] = 0.0;
bitangents[62] = 1.0;
bitangents[63] = 0.0;
bitangents[64] = 0.0;
bitangents[65] = 1.0;
bitangents[66] = 0.0;
bitangents[67] = 0.0;
bitangents[68] = 1.0;
bitangents[69] = 0.0;
bitangents[70] = 0.0;
bitangents[71] = 1.0;
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// +z face
indices[0] = 0;
indices[1] = 1;
indices[2] = 2;
indices[3] = 0;
indices[4] = 2;
indices[5] = 3;
// -z face
indices[6] = 4 + 2;
indices[7] = 4 + 1;
indices[8] = 4 + 0;
indices[9] = 4 + 3;
indices[10] = 4 + 2;
indices[11] = 4 + 0;
// +x face
indices[12] = 8 + 0;
indices[13] = 8 + 1;
indices[14] = 8 + 2;
indices[15] = 8 + 0;
indices[16] = 8 + 2;
indices[17] = 8 + 3;
// -x face
indices[18] = 12 + 2;
indices[19] = 12 + 1;
indices[20] = 12 + 0;
indices[21] = 12 + 3;
indices[22] = 12 + 2;
indices[23] = 12 + 0;
// +y face
indices[24] = 16 + 2;
indices[25] = 16 + 1;
indices[26] = 16 + 0;
indices[27] = 16 + 3;
indices[28] = 16 + 2;
indices[29] = 16 + 0;
// -y face
indices[30] = 20 + 0;
indices[31] = 20 + 1;
indices[32] = 20 + 2;
indices[33] = 20 + 0;
indices[34] = 20 + 2;
indices[35] = 20 + 3;
} else {
// Positions only - no need to duplicate corner points
positions = new Float64Array(8 * 3);
positions[0] = min.x;
positions[1] = min.y;
positions[2] = min.z;
positions[3] = max.x;
positions[4] = min.y;
positions[5] = min.z;
positions[6] = max.x;
positions[7] = max.y;
positions[8] = min.z;
positions[9] = min.x;
positions[10] = max.y;
positions[11] = min.z;
positions[12] = min.x;
positions[13] = min.y;
positions[14] = max.z;
positions[15] = max.x;
positions[16] = min.y;
positions[17] = max.z;
positions[18] = max.x;
positions[19] = max.y;
positions[20] = max.z;
positions[21] = min.x;
positions[22] = max.y;
positions[23] = max.z;
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
// 12 triangles: 6 faces, 2 triangles each.
indices = new Uint16Array(6 * 2 * 3);
// plane z = corner.Z
indices[0] = 4;
indices[1] = 5;
indices[2] = 6;
indices[3] = 4;
indices[4] = 6;
indices[5] = 7;
// plane z = -corner.Z
indices[6] = 1;
indices[7] = 0;
indices[8] = 3;
indices[9] = 1;
indices[10] = 3;
indices[11] = 2;
// plane x = corner.X
indices[12] = 1;
indices[13] = 6;
indices[14] = 5;
indices[15] = 1;
indices[16] = 2;
indices[17] = 6;
// plane y = corner.Y
indices[18] = 2;
indices[19] = 3;
indices[20] = 7;
indices[21] = 2;
indices[22] = 7;
indices[23] = 6;
// plane x = -corner.X
indices[24] = 3;
indices[25] = 0;
indices[26] = 4;
indices[27] = 3;
indices[28] = 4;
indices[29] = 7;
// plane y = -corner.Y
indices[30] = 0;
indices[31] = 1;
indices[32] = 5;
indices[33] = 0;
indices[34] = 5;
indices[35] = 4;
}
var diff = Cartographic.Cartesian3.subtract(max, min, diffScratch);
var radius = Cartographic.Cartesian3.magnitude(diff) * 0.5;
if (when.defined(boxGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = boxGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, radius),
offsetAttribute : boxGeometry._offsetAttribute
});
};
var unitBoxGeometry;
/**
* Returns the geometric representation of a unit box, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
BoxGeometry.getUnitBox = function() {
if (!when.defined(unitBoxGeometry)) {
unitBoxGeometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions({
dimensions : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitBoxGeometry;
};
exports.BoxGeometry = BoxGeometry;
});

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
define(["exports","./Check-7b2a090c","./when-b60132fc","./Math-119be1a3"],(function(n,e,t,r){"use strict";function a(n,e,r,a){this.x=t.defaultValue(n,0),this.y=t.defaultValue(e,0),this.z=t.defaultValue(r,0),this.w=t.defaultValue(a,0)}a.fromElements=function(n,e,r,u,i){return t.defined(i)?(i.x=n,i.y=e,i.z=r,i.w=u,i):new a(n,e,r,u)},a.fromColor=function(n,e){return t.defined(e)?(e.x=n.red,e.y=n.green,e.z=n.blue,e.w=n.alpha,e):new a(n.red,n.green,n.blue,n.alpha)},a.clone=function(n,e){if(t.defined(n))return t.defined(e)?(e.x=n.x,e.y=n.y,e.z=n.z,e.w=n.w,e):new a(n.x,n.y,n.z,n.w)},a.packedLength=4,a.pack=function(n,e,r){return r=t.defaultValue(r,0),e[r++]=n.x,e[r++]=n.y,e[r++]=n.z,e[r]=n.w,e},a.unpack=function(n,e,r){return e=t.defaultValue(e,0),t.defined(r)||(r=new a),r.x=n[e++],r.y=n[e++],r.z=n[e++],r.w=n[e],r},a.packArray=function(n,r){var u=n.length,i=4*u;if(t.defined(r)){if(!Array.isArray(r)&&r.length!==i)throw new e.DeveloperError("If result is a typed array, it must have exactly array.length * 4 elements");r.length!==i&&(r.length=i)}else r=new Array(i);for(var o=0;o<u;++o)a.pack(n[o],r,4*o);return r},a.unpackArray=function(n,e){var r=n.length;t.defined(e)?e.length=r/4:e=new Array(r/4);for(var u=0;u<r;u+=4){var i=u/4;e[i]=a.unpack(n,u,e[i])}return e},a.fromArray=a.unpack,a.maximumComponent=function(n){return Math.max(n.x,n.y,n.z,n.w)},a.minimumComponent=function(n){return Math.min(n.x,n.y,n.z,n.w)},a.minimumByComponent=function(n,e,t){return t.x=Math.min(n.x,e.x),t.y=Math.min(n.y,e.y),t.z=Math.min(n.z,e.z),t.w=Math.min(n.w,e.w),t},a.maximumByComponent=function(n,e,t){return t.x=Math.max(n.x,e.x),t.y=Math.max(n.y,e.y),t.z=Math.max(n.z,e.z),t.w=Math.max(n.w,e.w),t},a.magnitudeSquared=function(n){return n.x*n.x+n.y*n.y+n.z*n.z+n.w*n.w},a.magnitude=function(n){return Math.sqrt(a.magnitudeSquared(n))};var u=new a;a.distance=function(n,e){return a.subtract(n,e,u),a.magnitude(u)},a.distanceSquared=function(n,e){return a.subtract(n,e,u),a.magnitudeSquared(u)},a.normalize=function(n,e){var t=a.magnitude(n);return e.x=n.x/t,e.y=n.y/t,e.z=n.z/t,e.w=n.w/t,e},a.dot=function(n,e){return n.x*e.x+n.y*e.y+n.z*e.z+n.w*e.w},a.multiplyComponents=function(n,e,t){return t.x=n.x*e.x,t.y=n.y*e.y,t.z=n.z*e.z,t.w=n.w*e.w,t},a.divideComponents=function(n,e,t){return t.x=n.x/e.x,t.y=n.y/e.y,t.z=n.z/e.z,t.w=n.w/e.w,t},a.add=function(n,e,t){return t.x=n.x+e.x,t.y=n.y+e.y,t.z=n.z+e.z,t.w=n.w+e.w,t},a.subtract=function(n,e,t){return t.x=n.x-e.x,t.y=n.y-e.y,t.z=n.z-e.z,t.w=n.w-e.w,t},a.multiplyByScalar=function(n,e,t){return t.x=n.x*e,t.y=n.y*e,t.z=n.z*e,t.w=n.w*e,t},a.divideByScalar=function(n,e,t){return t.x=n.x/e,t.y=n.y/e,t.z=n.z/e,t.w=n.w/e,t},a.negate=function(n,e){return e.x=-n.x,e.y=-n.y,e.z=-n.z,e.w=-n.w,e},a.abs=function(n,e){return e.x=Math.abs(n.x),e.y=Math.abs(n.y),e.z=Math.abs(n.z),e.w=Math.abs(n.w),e};var i=new a;a.lerp=function(n,e,t,r){return a.multiplyByScalar(e,t,i),r=a.multiplyByScalar(n,1-t,r),a.add(i,r,r)};var o=new a;a.mostOrthogonalAxis=function(n,e){var t=a.normalize(n,o);return a.abs(t,t),e=t.x<=t.y?t.x<=t.z?t.x<=t.w?a.clone(a.UNIT_X,e):a.clone(a.UNIT_W,e):t.z<=t.w?a.clone(a.UNIT_Z,e):a.clone(a.UNIT_W,e):t.y<=t.z?t.y<=t.w?a.clone(a.UNIT_Y,e):a.clone(a.UNIT_W,e):t.z<=t.w?a.clone(a.UNIT_Z,e):a.clone(a.UNIT_W,e)},a.equals=function(n,e){return n===e||t.defined(n)&&t.defined(e)&&n.x===e.x&&n.y===e.y&&n.z===e.z&&n.w===e.w},a.equalsArray=function(n,e,t){return n.x===e[t]&&n.y===e[t+1]&&n.z===e[t+2]&&n.w===e[t+3]},a.equalsEpsilon=function(n,e,a,u){return n===e||t.defined(n)&&t.defined(e)&&r.CesiumMath.equalsEpsilon(n.x,e.x,a,u)&&r.CesiumMath.equalsEpsilon(n.y,e.y,a,u)&&r.CesiumMath.equalsEpsilon(n.z,e.z,a,u)&&r.CesiumMath.equalsEpsilon(n.w,e.w,a,u)},a.ZERO=Object.freeze(new a(0,0,0,0)),a.UNIT_X=Object.freeze(new a(1,0,0,0)),a.UNIT_Y=Object.freeze(new a(0,1,0,0)),a.UNIT_Z=Object.freeze(new a(0,0,1,0)),a.UNIT_W=Object.freeze(new a(0,0,0,1)),a.prototype.clone=function(n){return a.clone(this,n)},a.prototype.equals=function(n){return a.equals(this,n)},a.prototype.equalsEpsilon=function(n,e,t){return a.equalsEpsilon(this,n,e,t)},a.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+", "+this.w+")"};var l=new Float32Array(1),y=256;a.packFloat=function(n,e){if(t.defined(e)||(e=new a),l[0]=n,0===(n=l[0]))return a.clone(a.ZERO,e);var u,i=n<0?1:0;isFinite(n)?(n=Math.abs(n),u=Math.floor(r.CesiumMath.logBase(n,10))+1,n/=Math.pow(10,u)):(n=.1,u=38);var o=n*y;return e.x=Math.floor(o),o=(o-e.x)*y,e.y=Math.floor(o),o=(o-e.y)*y,e.z=Math.floor(o),e.w=2*(u+38)+i,e},a.unpackFloat=function(n){var e=n.w/2,t=Math.floor(e),r=2*(e-t);if(r=-(r=2*r-1),(t-=38)>=38)return r<0?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY;var a=r*n.x*.00390625;return a+=r*n.y*152587890625e-16,(a+=r*n.z*5.960464477539063e-8)*Math.pow(10,t)},n.Cartesian4=a}));

View File

@ -1,927 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240'], function (exports, when, Check, _Math) { 'use strict';
/**
* A 4D Cartesian point.
* @alias Cartesian4
* @constructor
*
* @param {Number} [x=0.0] The X component.
* @param {Number} [y=0.0] The Y component.
* @param {Number} [z=0.0] The Z component.
* @param {Number} [w=0.0] The W component.
*
* @see Cartesian2
* @see Cartesian3
* @see Packable
*/
function Cartesian4(x, y, z, w) {
/**
* The X component.
* @type {Number}
* @default 0.0
*/
this.x = when.defaultValue(x, 0.0);
/**
* The Y component.
* @type {Number}
* @default 0.0
*/
this.y = when.defaultValue(y, 0.0);
/**
* The Z component.
* @type {Number}
* @default 0.0
*/
this.z = when.defaultValue(z, 0.0);
/**
* The W component.
* @type {Number}
* @default 0.0
*/
this.w = when.defaultValue(w, 0.0);
}
/**
* Creates a Cartesian4 instance from x, y, z and w coordinates.
*
* @param {Number} x The x coordinate.
* @param {Number} y The y coordinate.
* @param {Number} z The z coordinate.
* @param {Number} w The w coordinate.
* @param {Cartesian4} [result] The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*/
Cartesian4.fromElements = function(x, y, z, w, result) {
if (!when.defined(result)) {
return new Cartesian4(x, y, z, w);
}
result.x = x;
result.y = y;
result.z = z;
result.w = w;
return result;
};
/**
* Creates a Cartesian4 instance from a {@link Color}. <code>red</code>, <code>green</code>, <code>blue</code>,
* and <code>alpha</code> map to <code>x</code>, <code>y</code>, <code>z</code>, and <code>w</code>, respectively.
*
* @param {Color} color The source color.
* @param {Cartesian4} [result] The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*/
Cartesian4.fromColor = function(color, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('color', color);
//>>includeEnd('debug');
if (!when.defined(result)) {
return new Cartesian4(color.red, color.green, color.blue, color.alpha);
}
result.x = color.red;
result.y = color.green;
result.z = color.blue;
result.w = color.alpha;
return result;
};
/**
* Duplicates a Cartesian4 instance.
*
* @param {Cartesian4} cartesian The Cartesian to duplicate.
* @param {Cartesian4} [result] The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided. (Returns undefined if cartesian is undefined)
*/
Cartesian4.clone = function(cartesian, result) {
if (!when.defined(cartesian)) {
return undefined;
}
if (!when.defined(result)) {
return new Cartesian4(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
}
result.x = cartesian.x;
result.y = cartesian.y;
result.z = cartesian.z;
result.w = cartesian.w;
return result;
};
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
Cartesian4.packedLength = 4;
/**
* Stores the provided instance into the provided array.
*
* @param {Cartesian4} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
Cartesian4.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('value', value);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
array[startingIndex++] = value.x;
array[startingIndex++] = value.y;
array[startingIndex++] = value.z;
array[startingIndex] = value.w;
return array;
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {Cartesian4} [result] The object into which to store the result.
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*/
Cartesian4.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
if (!when.defined(result)) {
result = new Cartesian4();
}
result.x = array[startingIndex++];
result.y = array[startingIndex++];
result.z = array[startingIndex++];
result.w = array[startingIndex];
return result;
};
/**
* Flattens an array of Cartesian4s into and array of components.
*
* @param {Cartesian4[]} array The array of cartesians to pack.
* @param {Number[]} [result] The array onto which to store the result. If this is a typed array, it must have array.length * 4 components, else a {@link DeveloperError} will be thrown. If it is a regular array, it will be resized to have (array.length * 4) elements.
* @returns {Number[]} The packed array.
*/
Cartesian4.packArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
//>>includeEnd('debug');
var length = array.length;
var resultLength = length * 4;
if (!when.defined(result)) {
result = new Array(resultLength);
} else if (!Array.isArray(result) && result.length !== resultLength) {
throw new Check.DeveloperError('If result is a typed array, it must have exactly array.length * 4 elements');
} else if (result.length !== resultLength) {
result.length = resultLength;
}
for (var i = 0; i < length; ++i) {
Cartesian4.pack(array[i], result, i * 4);
}
return result;
};
/**
* Unpacks an array of cartesian components into and array of Cartesian4s.
*
* @param {Number[]} array The array of components to unpack.
* @param {Cartesian4[]} [result] The array onto which to store the result.
* @returns {Cartesian4[]} The unpacked array.
*/
Cartesian4.unpackArray = function(array, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('array', array);
Check.Check.typeOf.number.greaterThanOrEquals('array.length', array.length, 4);
if (array.length % 4 !== 0) {
throw new Check.DeveloperError('array length must be a multiple of 4.');
}
//>>includeEnd('debug');
var length = array.length;
if (!when.defined(result)) {
result = new Array(length / 4);
} else {
result.length = length / 4;
}
for (var i = 0; i < length; i += 4) {
var index = i / 4;
result[index] = Cartesian4.unpack(array, i, result[index]);
}
return result;
};
/**
* Creates a Cartesian4 from four consecutive elements in an array.
* @function
*
* @param {Number[]} array The array whose four consecutive elements correspond to the x, y, z, and w components, respectively.
* @param {Number} [startingIndex=0] The offset into the array of the first element, which corresponds to the x component.
* @param {Cartesian4} [result] The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*
* @example
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0)
* var v = [1.0, 2.0, 3.0, 4.0];
* var p = Cesium.Cartesian4.fromArray(v);
*
* // Create a Cartesian4 with (1.0, 2.0, 3.0, 4.0) using an offset into an array
* var v2 = [0.0, 0.0, 1.0, 2.0, 3.0, 4.0];
* var p2 = Cesium.Cartesian4.fromArray(v2, 2);
*/
Cartesian4.fromArray = Cartesian4.unpack;
/**
* Computes the value of the maximum component for the supplied Cartesian.
*
* @param {Cartesian4} cartesian The cartesian to use.
* @returns {Number} The value of the maximum component.
*/
Cartesian4.maximumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.max(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
};
/**
* Computes the value of the minimum component for the supplied Cartesian.
*
* @param {Cartesian4} cartesian The cartesian to use.
* @returns {Number} The value of the minimum component.
*/
Cartesian4.minimumComponent = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return Math.min(cartesian.x, cartesian.y, cartesian.z, cartesian.w);
};
/**
* Compares two Cartesians and computes a Cartesian which contains the minimum components of the supplied Cartesians.
*
* @param {Cartesian4} first A cartesian to compare.
* @param {Cartesian4} second A cartesian to compare.
* @param {Cartesian4} result The object into which to store the result.
* @returns {Cartesian4} A cartesian with the minimum components.
*/
Cartesian4.minimumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('first', first);
Check.Check.typeOf.object('second', second);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.min(first.x, second.x);
result.y = Math.min(first.y, second.y);
result.z = Math.min(first.z, second.z);
result.w = Math.min(first.w, second.w);
return result;
};
/**
* Compares two Cartesians and computes a Cartesian which contains the maximum components of the supplied Cartesians.
*
* @param {Cartesian4} first A cartesian to compare.
* @param {Cartesian4} second A cartesian to compare.
* @param {Cartesian4} result The object into which to store the result.
* @returns {Cartesian4} A cartesian with the maximum components.
*/
Cartesian4.maximumByComponent = function(first, second, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('first', first);
Check.Check.typeOf.object('second', second);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.max(first.x, second.x);
result.y = Math.max(first.y, second.y);
result.z = Math.max(first.z, second.z);
result.w = Math.max(first.w, second.w);
return result;
};
/**
* Computes the provided Cartesian's squared magnitude.
*
* @param {Cartesian4} cartesian The Cartesian instance whose squared magnitude is to be computed.
* @returns {Number} The squared magnitude.
*/
Cartesian4.magnitudeSquared = function(cartesian) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
//>>includeEnd('debug');
return cartesian.x * cartesian.x + cartesian.y * cartesian.y + cartesian.z * cartesian.z + cartesian.w * cartesian.w;
};
/**
* Computes the Cartesian's magnitude (length).
*
* @param {Cartesian4} cartesian The Cartesian instance whose magnitude is to be computed.
* @returns {Number} The magnitude.
*/
Cartesian4.magnitude = function(cartesian) {
return Math.sqrt(Cartesian4.magnitudeSquared(cartesian));
};
var distanceScratch = new Cartesian4();
/**
* Computes the 4-space distance between two points.
*
* @param {Cartesian4} left The first point to compute the distance from.
* @param {Cartesian4} right The second point to compute the distance to.
* @returns {Number} The distance between two points.
*
* @example
* // Returns 1.0
* var d = Cesium.Cartesian4.distance(
* new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
* new Cesium.Cartesian4(2.0, 0.0, 0.0, 0.0));
*/
Cartesian4.distance = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian4.subtract(left, right, distanceScratch);
return Cartesian4.magnitude(distanceScratch);
};
/**
* Computes the squared distance between two points. Comparing squared distances
* using this function is more efficient than comparing distances using {@link Cartesian4#distance}.
*
* @param {Cartesian4} left The first point to compute the distance from.
* @param {Cartesian4} right The second point to compute the distance to.
* @returns {Number} The distance between two points.
*
* @example
* // Returns 4.0, not 2.0
* var d = Cesium.Cartesian4.distance(
* new Cesium.Cartesian4(1.0, 0.0, 0.0, 0.0),
* new Cesium.Cartesian4(3.0, 0.0, 0.0, 0.0));
*/
Cartesian4.distanceSquared = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
Cartesian4.subtract(left, right, distanceScratch);
return Cartesian4.magnitudeSquared(distanceScratch);
};
/**
* Computes the normalized form of the supplied Cartesian.
*
* @param {Cartesian4} cartesian The Cartesian to be normalized.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.normalize = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
var magnitude = Cartesian4.magnitude(cartesian);
result.x = cartesian.x / magnitude;
result.y = cartesian.y / magnitude;
result.z = cartesian.z / magnitude;
result.w = cartesian.w / magnitude;
//>>includeStart('debug', pragmas.debug);
if (isNaN(result.x) || isNaN(result.y) || isNaN(result.z) || isNaN(result.w)) {
throw new Check.DeveloperError('normalized result is not a number');
}
//>>includeEnd('debug');
return result;
};
/**
* Computes the dot (scalar) product of two Cartesians.
*
* @param {Cartesian4} left The first Cartesian.
* @param {Cartesian4} right The second Cartesian.
* @returns {Number} The dot product.
*/
Cartesian4.dot = function(left, right) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
//>>includeEnd('debug');
return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w;
};
/**
* Computes the componentwise product of two Cartesians.
*
* @param {Cartesian4} left The first Cartesian.
* @param {Cartesian4} right The second Cartesian.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.multiplyComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x * right.x;
result.y = left.y * right.y;
result.z = left.z * right.z;
result.w = left.w * right.w;
return result;
};
/**
* Computes the componentwise quotient of two Cartesians.
*
* @param {Cartesian4} left The first Cartesian.
* @param {Cartesian4} right The second Cartesian.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.divideComponents = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x / right.x;
result.y = left.y / right.y;
result.z = left.z / right.z;
result.w = left.w / right.w;
return result;
};
/**
* Computes the componentwise sum of two Cartesians.
*
* @param {Cartesian4} left The first Cartesian.
* @param {Cartesian4} right The second Cartesian.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.add = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x + right.x;
result.y = left.y + right.y;
result.z = left.z + right.z;
result.w = left.w + right.w;
return result;
};
/**
* Computes the componentwise difference of two Cartesians.
*
* @param {Cartesian4} left The first Cartesian.
* @param {Cartesian4} right The second Cartesian.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.subtract = function(left, right, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('left', left);
Check.Check.typeOf.object('right', right);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = left.x - right.x;
result.y = left.y - right.y;
result.z = left.z - right.z;
result.w = left.w - right.w;
return result;
};
/**
* Multiplies the provided Cartesian componentwise by the provided scalar.
*
* @param {Cartesian4} cartesian The Cartesian to be scaled.
* @param {Number} scalar The scalar to multiply with.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.multiplyByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
Check.Check.typeOf.number('scalar', scalar);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x * scalar;
result.y = cartesian.y * scalar;
result.z = cartesian.z * scalar;
result.w = cartesian.w * scalar;
return result;
};
/**
* Divides the provided Cartesian componentwise by the provided scalar.
*
* @param {Cartesian4} cartesian The Cartesian to be divided.
* @param {Number} scalar The scalar to divide by.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.divideByScalar = function(cartesian, scalar, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
Check.Check.typeOf.number('scalar', scalar);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = cartesian.x / scalar;
result.y = cartesian.y / scalar;
result.z = cartesian.z / scalar;
result.w = cartesian.w / scalar;
return result;
};
/**
* Negates the provided Cartesian.
*
* @param {Cartesian4} cartesian The Cartesian to be negated.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.negate = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = -cartesian.x;
result.y = -cartesian.y;
result.z = -cartesian.z;
result.w = -cartesian.w;
return result;
};
/**
* Computes the absolute value of the provided Cartesian.
*
* @param {Cartesian4} cartesian The Cartesian whose absolute value is to be computed.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.abs = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
result.x = Math.abs(cartesian.x);
result.y = Math.abs(cartesian.y);
result.z = Math.abs(cartesian.z);
result.w = Math.abs(cartesian.w);
return result;
};
var lerpScratch = new Cartesian4();
/**
* Computes the linear interpolation or extrapolation at t using the provided cartesians.
*
* @param {Cartesian4} start The value corresponding to t at 0.0.
* @param {Cartesian4}end The value corresponding to t at 1.0.
* @param {Number} t The point along t at which to interpolate.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter.
*/
Cartesian4.lerp = function(start, end, t, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('start', start);
Check.Check.typeOf.object('end', end);
Check.Check.typeOf.number('t', t);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
Cartesian4.multiplyByScalar(end, t, lerpScratch);
result = Cartesian4.multiplyByScalar(start, 1.0 - t, result);
return Cartesian4.add(lerpScratch, result, result);
};
var mostOrthogonalAxisScratch = new Cartesian4();
/**
* Returns the axis that is most orthogonal to the provided Cartesian.
*
* @param {Cartesian4} cartesian The Cartesian on which to find the most orthogonal axis.
* @param {Cartesian4} result The object onto which to store the result.
* @returns {Cartesian4} The most orthogonal axis.
*/
Cartesian4.mostOrthogonalAxis = function(cartesian, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('cartesian', cartesian);
Check.Check.typeOf.object('result', result);
//>>includeEnd('debug');
var f = Cartesian4.normalize(cartesian, mostOrthogonalAxisScratch);
Cartesian4.abs(f, f);
if (f.x <= f.y) {
if (f.x <= f.z) {
if (f.x <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_X, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
} else if (f.z <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
} else if (f.y <= f.z) {
if (f.y <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_Y, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
} else if (f.z <= f.w) {
result = Cartesian4.clone(Cartesian4.UNIT_Z, result);
} else {
result = Cartesian4.clone(Cartesian4.UNIT_W, result);
}
return result;
};
/**
* Compares the provided Cartesians componentwise and returns
* <code>true</code> if they are equal, <code>false</code> otherwise.
*
* @param {Cartesian4} [left] The first Cartesian.
* @param {Cartesian4} [right] The second Cartesian.
* @returns {Boolean} <code>true</code> if left and right are equal, <code>false</code> otherwise.
*/
Cartesian4.equals = function(left, right) {
return (left === right) ||
((when.defined(left)) &&
(when.defined(right)) &&
(left.x === right.x) &&
(left.y === right.y) &&
(left.z === right.z) &&
(left.w === right.w));
};
/**
* @private
*/
Cartesian4.equalsArray = function(cartesian, array, offset) {
return cartesian.x === array[offset] &&
cartesian.y === array[offset + 1] &&
cartesian.z === array[offset + 2] &&
cartesian.w === array[offset + 3];
};
/**
* Compares the provided Cartesians componentwise and returns
* <code>true</code> if they pass an absolute or relative tolerance test,
* <code>false</code> otherwise.
*
* @param {Cartesian4} [left] The first Cartesian.
* @param {Cartesian4} [right] The second Cartesian.
* @param {Number} relativeEpsilon The relative epsilon tolerance to use for equality testing.
* @param {Number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
* @returns {Boolean} <code>true</code> if left and right are within the provided epsilon, <code>false</code> otherwise.
*/
Cartesian4.equalsEpsilon = function(left, right, relativeEpsilon, absoluteEpsilon) {
return (left === right) ||
(when.defined(left) &&
when.defined(right) &&
_Math.CesiumMath.equalsEpsilon(left.x, right.x, relativeEpsilon, absoluteEpsilon) &&
_Math.CesiumMath.equalsEpsilon(left.y, right.y, relativeEpsilon, absoluteEpsilon) &&
_Math.CesiumMath.equalsEpsilon(left.z, right.z, relativeEpsilon, absoluteEpsilon) &&
_Math.CesiumMath.equalsEpsilon(left.w, right.w, relativeEpsilon, absoluteEpsilon));
};
/**
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 0.0).
*
* @type {Cartesian4}
* @constant
*/
Cartesian4.ZERO = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 0.0));
/**
* An immutable Cartesian4 instance initialized to (1.0, 0.0, 0.0, 0.0).
*
* @type {Cartesian4}
* @constant
*/
Cartesian4.UNIT_X = Object.freeze(new Cartesian4(1.0, 0.0, 0.0, 0.0));
/**
* An immutable Cartesian4 instance initialized to (0.0, 1.0, 0.0, 0.0).
*
* @type {Cartesian4}
* @constant
*/
Cartesian4.UNIT_Y = Object.freeze(new Cartesian4(0.0, 1.0, 0.0, 0.0));
/**
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 1.0, 0.0).
*
* @type {Cartesian4}
* @constant
*/
Cartesian4.UNIT_Z = Object.freeze(new Cartesian4(0.0, 0.0, 1.0, 0.0));
/**
* An immutable Cartesian4 instance initialized to (0.0, 0.0, 0.0, 1.0).
*
* @type {Cartesian4}
* @constant
*/
Cartesian4.UNIT_W = Object.freeze(new Cartesian4(0.0, 0.0, 0.0, 1.0));
/**
* Duplicates this Cartesian4 instance.
*
* @param {Cartesian4} [result] The object onto which to store the result.
* @returns {Cartesian4} The modified result parameter or a new Cartesian4 instance if one was not provided.
*/
Cartesian4.prototype.clone = function(result) {
return Cartesian4.clone(this, result);
};
/**
* Compares this Cartesian against the provided Cartesian componentwise and returns
* <code>true</code> if they are equal, <code>false</code> otherwise.
*
* @param {Cartesian4} [right] The right hand side Cartesian.
* @returns {Boolean} <code>true</code> if they are equal, <code>false</code> otherwise.
*/
Cartesian4.prototype.equals = function(right) {
return Cartesian4.equals(this, right);
};
/**
* Compares this Cartesian against the provided Cartesian componentwise and returns
* <code>true</code> if they pass an absolute or relative tolerance test,
* <code>false</code> otherwise.
*
* @param {Cartesian4} [right] The right hand side Cartesian.
* @param {Number} relativeEpsilon The relative epsilon tolerance to use for equality testing.
* @param {Number} [absoluteEpsilon=relativeEpsilon] The absolute epsilon tolerance to use for equality testing.
* @returns {Boolean} <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.
*/
Cartesian4.prototype.equalsEpsilon = function(right, relativeEpsilon, absoluteEpsilon) {
return Cartesian4.equalsEpsilon(this, right, relativeEpsilon, absoluteEpsilon);
};
/**
* Creates a string representing this Cartesian in the format '(x, y, z, w)'.
*
* @returns {String} A string representing the provided Cartesian in the format '(x, y, z, w)'.
*/
Cartesian4.prototype.toString = function() {
return '(' + this.x + ', ' + this.y + ', ' + this.z + ', ' + this.w + ')';
};
var scratchFloatArray = new Float32Array(1);
var SHIFT_LEFT_8 = 256.0;
var SHIFT_LEFT_16 = 65536.0;
var SHIFT_LEFT_24 = 16777216.0;
var SHIFT_RIGHT_8 = 1.0 / SHIFT_LEFT_8;
var SHIFT_RIGHT_16 = 1.0 / SHIFT_LEFT_16;
var SHIFT_RIGHT_24 = 1.0 / SHIFT_LEFT_24;
var BIAS = 38.0;
/**
* Packs an arbitrary floating point value to 4 values representable using uint8.
*
* @param {Number} value A floating point number
* @param {Cartesian4} [result] The Cartesian4 that will contain the packed float.
* @returns {Cartesian4} A Cartesian4 representing the float packed to values in x, y, z, and w.
*/
Cartesian4.packFloat = function(value, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.number('value', value);
//>>includeEnd('debug');
if (!when.defined(result)) {
result = new Cartesian4();
}
// Force the value to 32 bit precision
scratchFloatArray[0] = value;
value = scratchFloatArray[0];
if (value === 0.0) {
return Cartesian4.clone(Cartesian4.ZERO, result);
}
var sign = value < 0.0 ? 1.0 : 0.0;
var exponent;
if (!isFinite(value)) {
value = 0.1;
exponent = BIAS;
} else {
value = Math.abs(value);
exponent = Math.floor(_Math.CesiumMath.logBase(value, 10)) + 1.0;
value = value / Math.pow(10.0, exponent);
}
var temp = value * SHIFT_LEFT_8;
result.x = Math.floor(temp);
temp = (temp - result.x) * SHIFT_LEFT_8;
result.y = Math.floor(temp);
temp = (temp - result.y) * SHIFT_LEFT_8;
result.z = Math.floor(temp);
result.w = (exponent + BIAS) * 2.0 + sign;
return result;
};
/**
* Unpacks a float packed using Cartesian4.packFloat.
*
* @param {Cartesian4} packedFloat A Cartesian4 containing a float packed to 4 values representable using uint8.
* @returns {Number} The unpacked float.
* @private
*/
Cartesian4.unpackFloat = function(packedFloat) {
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.object('packedFloat', packedFloat);
//>>includeEnd('debug');
var temp = packedFloat.w / 2.0;
var exponent = Math.floor(temp);
var sign = (temp - exponent) * 2.0;
exponent = exponent - BIAS;
sign = sign * 2.0 - 1.0;
sign = -sign;
if (exponent >= BIAS) {
return sign < 0.0 ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY;
}
var unpacked = sign * packedFloat.x * SHIFT_RIGHT_8;
unpacked += sign * packedFloat.y * SHIFT_RIGHT_16;
unpacked += sign * packedFloat.z * SHIFT_RIGHT_24;
return unpacked * Math.pow(10.0, exponent);
};
exports.Cartesian4 = Cartesian4;
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,274 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60'], function (exports, when) { 'use strict';
/**
* Constructs an exception object that is thrown due to a developer error, e.g., invalid argument,
* argument out of range, etc. This exception should only be thrown during development;
* it usually indicates a bug in the calling code. This exception should never be
* caught; instead the calling code should strive not to generate it.
* <br /><br />
* On the other hand, a {@link RuntimeError} indicates an exception that may
* be thrown at runtime, e.g., out of memory, that the calling code should be prepared
* to catch.
*
* @alias DeveloperError
* @constructor
* @extends Error
*
* @param {String} [message] The error message for this exception.
*
* @see RuntimeError
*/
function DeveloperError(message) {
/**
* 'DeveloperError' indicating that this exception was thrown due to a developer error.
* @type {String}
* @readonly
*/
this.name = 'DeveloperError';
/**
* The explanation for why this exception was thrown.
* @type {String}
* @readonly
*/
this.message = message;
//Browsers such as IE don't have a stack property until you actually throw the error.
var stack;
try {
throw new Error();
} catch (e) {
stack = e.stack;
}
/**
* The stack trace of this exception, if available.
* @type {String}
* @readonly
*/
this.stack = stack;
}
if (when.defined(Object.create)) {
DeveloperError.prototype = Object.create(Error.prototype);
DeveloperError.prototype.constructor = DeveloperError;
}
DeveloperError.prototype.toString = function() {
var str = this.name + ': ' + this.message;
if (when.defined(this.stack)) {
str += '\n' + this.stack.toString();
}
return str;
};
/**
* @private
*/
DeveloperError.throwInstantiationError = function() {
throw new DeveloperError('This function defines an interface and should not be called directly.');
};
/**
* Contains functions for checking that supplied arguments are of a specified type
* or meet specified conditions
* @private
*/
var Check = {};
/**
* Contains type checking functions, all using the typeof operator
*/
Check.typeOf = {};
function getUndefinedErrorMessage(name) {
return name + ' is required, actual value was undefined';
}
function getFailedTypeErrorMessage(actual, expected, name) {
return 'Expected ' + name + ' to be typeof ' + expected + ', actual typeof was ' + actual;
}
/**
* Throws if test is not defined
*
* @param {String} name The name of the variable being tested
* @param {*} test The value that is to be checked
* @exception {DeveloperError} test must be defined
*/
Check.defined = function (name, test) {
if (!when.defined(test)) {
throw new DeveloperError(getUndefinedErrorMessage(name));
}
};
/**
* Throws if test is not typeof 'function'
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'function'
*/
Check.typeOf.func = function (name, test) {
if (typeof test !== 'function') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'function', name));
}
};
/**
* Throws if test is not typeof 'string'
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'string'
*/
Check.typeOf.string = function (name, test) {
if (typeof test !== 'string') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'string', name));
}
};
/**
* Throws if test is not typeof 'number'
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'number'
*/
Check.typeOf.number = function (name, test) {
if (typeof test !== 'number') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'number', name));
}
};
/**
* Throws if test is not typeof 'number' and less than limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and less than limit
*/
Check.typeOf.number.lessThan = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test >= limit) {
throw new DeveloperError('Expected ' + name + ' to be less than ' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'number' and less than or equal to limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and less than or equal to limit
*/
Check.typeOf.number.lessThanOrEquals = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test > limit) {
throw new DeveloperError('Expected ' + name + ' to be less than or equal to ' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'number' and greater than limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and greater than limit
*/
Check.typeOf.number.greaterThan = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test <= limit) {
throw new DeveloperError('Expected ' + name + ' to be greater than ' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'number' and greater than or equal to limit
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @param {Number} limit The limit value to compare against
* @exception {DeveloperError} test must be typeof 'number' and greater than or equal to limit
*/
Check.typeOf.number.greaterThanOrEquals = function (name, test, limit) {
Check.typeOf.number(name, test);
if (test < limit) {
throw new DeveloperError('Expected ' + name + ' to be greater than or equal to' + limit + ', actual value was ' + test);
}
};
/**
* Throws if test is not typeof 'object'
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'object'
*/
Check.typeOf.object = function (name, test) {
if (typeof test !== 'object') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'object', name));
}
};
/**
* Throws if test is not typeof 'boolean'
*
* @param {String} name The name of the variable being tested
* @param {*} test The value to test
* @exception {DeveloperError} test must be typeof 'boolean'
*/
Check.typeOf.bool = function (name, test) {
if (typeof test !== 'boolean') {
throw new DeveloperError(getFailedTypeErrorMessage(typeof test, 'boolean', name));
}
};
/**
* Throws if test1 and test2 is not typeof 'number' and not equal in value
*
* @param {String} name1 The name of the first variable being tested
* @param {String} name2 The name of the second variable being tested against
* @param {*} test1 The value to test
* @param {*} test2 The value to test against
* @exception {DeveloperError} test1 and test2 should be type of 'number' and be equal in value
*/
Check.typeOf.number.equals = function (name1, name2, test1, test2) {
Check.typeOf.number(name1, test1);
Check.typeOf.number(name2, test2);
if (test1 !== test2) {
throw new DeveloperError(name1 + ' must be equal to ' + name2 + ', the actual values are ' + test1 + ' and ' + test2);
}
};
exports.Check = Check;
exports.DeveloperError = DeveloperError;
});

View File

@ -1 +0,0 @@
define(["exports","./when-b60132fc"],(function(e,t){"use strict";function n(e){var t;this.name="DeveloperError",this.message=e;try{throw new Error}catch(e){t=e.stack}this.stack=t}t.defined(Object.create)&&(n.prototype=Object.create(Error.prototype),n.prototype.constructor=n),n.prototype.toString=function(){var e=this.name+": "+this.message;return t.defined(this.stack)&&(e+="\n"+this.stack.toString()),e},n.throwInstantiationError=function(){throw new n("This function defines an interface and should not be called directly.")};var o={};function r(e,t,n){return"Expected "+n+" to be typeof "+t+", actual typeof was "+e}o.typeOf={},o.defined=function(e,o){if(!t.defined(o))throw new n(function(e){return e+" is required, actual value was undefined"}(e))},o.typeOf.func=function(e,t){if("function"!=typeof t)throw new n(r(typeof t,"function",e))},o.typeOf.string=function(e,t){if("string"!=typeof t)throw new n(r(typeof t,"string",e))},o.typeOf.number=function(e,t){if("number"!=typeof t)throw new n(r(typeof t,"number",e))},o.typeOf.number.lessThan=function(e,t,r){if(o.typeOf.number(e,t),t>=r)throw new n("Expected "+e+" to be less than "+r+", actual value was "+t)},o.typeOf.number.lessThanOrEquals=function(e,t,r){if(o.typeOf.number(e,t),t>r)throw new n("Expected "+e+" to be less than or equal to "+r+", actual value was "+t)},o.typeOf.number.greaterThan=function(e,t,r){if(o.typeOf.number(e,t),t<=r)throw new n("Expected "+e+" to be greater than "+r+", actual value was "+t)},o.typeOf.number.greaterThanOrEquals=function(e,t,r){if(o.typeOf.number(e,t),t<r)throw new n("Expected "+e+" to be greater than or equal to"+r+", actual value was "+t)},o.typeOf.object=function(e,t){if("object"!=typeof t)throw new n(r(typeof t,"object",e))},o.typeOf.bool=function(e,t){if("boolean"!=typeof t)throw new n(r(typeof t,"boolean",e))},o.typeOf.number.equals=function(e,t,r,f){if(o.typeOf.number(e,r),o.typeOf.number(t,f),r!==f)throw new n(e+" must be equal to "+t+", the actual values are "+r+" and "+f)},e.Check=o,e.DeveloperError=n}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,343 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './WebGLConstants-4c11ee5f'], function (exports, when, Check, WebGLConstants) { 'use strict';
/**
* WebGL component datatypes. Components are intrinsics,
* which form attributes, which form vertices.
*
* @exports ComponentDatatype
*/
var ComponentDatatype = {
/**
* 8-bit signed byte corresponding to <code>gl.BYTE</code> and the type
* of an element in <code>Int8Array</code>.
*
* @type {Number}
* @constant
*/
BYTE : WebGLConstants.WebGLConstants.BYTE,
/**
* 8-bit unsigned byte corresponding to <code>UNSIGNED_BYTE</code> and the type
* of an element in <code>Uint8Array</code>.
*
* @type {Number}
* @constant
*/
UNSIGNED_BYTE : WebGLConstants.WebGLConstants.UNSIGNED_BYTE,
/**
* 16-bit signed short corresponding to <code>SHORT</code> and the type
* of an element in <code>Int16Array</code>.
*
* @type {Number}
* @constant
*/
SHORT : WebGLConstants.WebGLConstants.SHORT,
/**
* 16-bit unsigned short corresponding to <code>UNSIGNED_SHORT</code> and the type
* of an element in <code>Uint16Array</code>.
*
* @type {Number}
* @constant
*/
UNSIGNED_SHORT : WebGLConstants.WebGLConstants.UNSIGNED_SHORT,
/**
* 32-bit signed int corresponding to <code>INT</code> and the type
* of an element in <code>Int32Array</code>.
*
* @memberOf ComponentDatatype
*
* @type {Number}
* @constant
*/
INT : WebGLConstants.WebGLConstants.INT,
/**
* 32-bit unsigned int corresponding to <code>UNSIGNED_INT</code> and the type
* of an element in <code>Uint32Array</code>.
*
* @memberOf ComponentDatatype
*
* @type {Number}
* @constant
*/
UNSIGNED_INT : WebGLConstants.WebGLConstants.UNSIGNED_INT,
/**
* 32-bit floating-point corresponding to <code>FLOAT</code> and the type
* of an element in <code>Float32Array</code>.
*
* @type {Number}
* @constant
*/
FLOAT : WebGLConstants.WebGLConstants.FLOAT,
/**
* 64-bit floating-point corresponding to <code>gl.DOUBLE</code> (in Desktop OpenGL;
* this is not supported in WebGL, and is emulated in Cesium via {@link GeometryPipeline.encodeAttribute})
* and the type of an element in <code>Float64Array</code>.
*
* @memberOf ComponentDatatype
*
* @type {Number}
* @constant
* @default 0x140A
*/
DOUBLE : WebGLConstants.WebGLConstants.DOUBLE
};
/**
* Returns the size, in bytes, of the corresponding datatype.
*
* @param {ComponentDatatype} componentDatatype The component datatype to get the size of.
* @returns {Number} The size in bytes.
*
* @exception {DeveloperError} componentDatatype is not a valid value.
*
* @example
* // Returns Int8Array.BYTES_PER_ELEMENT
* var size = Cesium.ComponentDatatype.getSizeInBytes(Cesium.ComponentDatatype.BYTE);
*/
ComponentDatatype.getSizeInBytes = function(componentDatatype){
//>>includeStart('debug', pragmas.debug);
if (!when.defined(componentDatatype)) {
throw new Check.DeveloperError('value is required.');
}
//>>includeEnd('debug');
switch (componentDatatype) {
case ComponentDatatype.BYTE:
return Int8Array.BYTES_PER_ELEMENT;
case ComponentDatatype.UNSIGNED_BYTE:
return Uint8Array.BYTES_PER_ELEMENT;
case ComponentDatatype.SHORT:
return Int16Array.BYTES_PER_ELEMENT;
case ComponentDatatype.UNSIGNED_SHORT:
return Uint16Array.BYTES_PER_ELEMENT;
case ComponentDatatype.INT:
return Int32Array.BYTES_PER_ELEMENT;
case ComponentDatatype.UNSIGNED_INT:
return Uint32Array.BYTES_PER_ELEMENT;
case ComponentDatatype.FLOAT:
return Float32Array.BYTES_PER_ELEMENT;
case ComponentDatatype.DOUBLE:
return Float64Array.BYTES_PER_ELEMENT;
//>>includeStart('debug', pragmas.debug);
default:
throw new Check.DeveloperError('componentDatatype is not a valid value.');
//>>includeEnd('debug');
}
};
/**
* Gets the {@link ComponentDatatype} for the provided TypedArray instance.
*
* @param {TypedArray} array The typed array.
* @returns {ComponentDatatype} The ComponentDatatype for the provided array, or undefined if the array is not a TypedArray.
*/
ComponentDatatype.fromTypedArray = function(array) {
if (array instanceof Int8Array) {
return ComponentDatatype.BYTE;
}
if (array instanceof Uint8Array) {
return ComponentDatatype.UNSIGNED_BYTE;
}
if (array instanceof Int16Array) {
return ComponentDatatype.SHORT;
}
if (array instanceof Uint16Array) {
return ComponentDatatype.UNSIGNED_SHORT;
}
if (array instanceof Int32Array) {
return ComponentDatatype.INT;
}
if (array instanceof Uint32Array) {
return ComponentDatatype.UNSIGNED_INT;
}
if (array instanceof Float32Array) {
return ComponentDatatype.FLOAT;
}
if (array instanceof Float64Array) {
return ComponentDatatype.DOUBLE;
}
};
/**
* Validates that the provided component datatype is a valid {@link ComponentDatatype}
*
* @param {ComponentDatatype} componentDatatype The component datatype to validate.
* @returns {Boolean} <code>true</code> if the provided component datatype is a valid value; otherwise, <code>false</code>.
*
* @example
* if (!Cesium.ComponentDatatype.validate(componentDatatype)) {
* throw new Cesium.DeveloperError('componentDatatype must be a valid value.');
* }
*/
ComponentDatatype.validate = function(componentDatatype) {
return when.defined(componentDatatype) &&
(componentDatatype === ComponentDatatype.BYTE ||
componentDatatype === ComponentDatatype.UNSIGNED_BYTE ||
componentDatatype === ComponentDatatype.SHORT ||
componentDatatype === ComponentDatatype.UNSIGNED_SHORT ||
componentDatatype === ComponentDatatype.INT ||
componentDatatype === ComponentDatatype.UNSIGNED_INT ||
componentDatatype === ComponentDatatype.FLOAT ||
componentDatatype === ComponentDatatype.DOUBLE);
};
/**
* Creates a typed array corresponding to component data type.
*
* @param {ComponentDatatype} componentDatatype The component data type.
* @param {Number|Array} valuesOrLength The length of the array to create or an array.
* @returns {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} A typed array.
*
* @exception {DeveloperError} componentDatatype is not a valid value.
*
* @example
* // creates a Float32Array with length of 100
* var typedArray = Cesium.ComponentDatatype.createTypedArray(Cesium.ComponentDatatype.FLOAT, 100);
*/
ComponentDatatype.createTypedArray = function(componentDatatype, valuesOrLength) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(componentDatatype)) {
throw new Check.DeveloperError('componentDatatype is required.');
}
if (!when.defined(valuesOrLength)) {
throw new Check.DeveloperError('valuesOrLength is required.');
}
//>>includeEnd('debug');
switch (componentDatatype) {
case ComponentDatatype.BYTE:
return new Int8Array(valuesOrLength);
case ComponentDatatype.UNSIGNED_BYTE:
return new Uint8Array(valuesOrLength);
case ComponentDatatype.SHORT:
return new Int16Array(valuesOrLength);
case ComponentDatatype.UNSIGNED_SHORT:
return new Uint16Array(valuesOrLength);
case ComponentDatatype.INT:
return new Int32Array(valuesOrLength);
case ComponentDatatype.UNSIGNED_INT:
return new Uint32Array(valuesOrLength);
case ComponentDatatype.FLOAT:
return new Float32Array(valuesOrLength);
case ComponentDatatype.DOUBLE:
return new Float64Array(valuesOrLength);
//>>includeStart('debug', pragmas.debug);
default:
throw new Check.DeveloperError('componentDatatype is not a valid value.');
//>>includeEnd('debug');
}
};
/**
* Creates a typed view of an array of bytes.
*
* @param {ComponentDatatype} componentDatatype The type of the view to create.
* @param {ArrayBuffer} buffer The buffer storage to use for the view.
* @param {Number} [byteOffset] The offset, in bytes, to the first element in the view.
* @param {Number} [length] The number of elements in the view.
* @returns {Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array} A typed array view of the buffer.
*
* @exception {DeveloperError} componentDatatype is not a valid value.
*/
ComponentDatatype.createArrayBufferView = function(componentDatatype, buffer, byteOffset, length) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(componentDatatype)) {
throw new Check.DeveloperError('componentDatatype is required.');
}
if (!when.defined(buffer)) {
throw new Check.DeveloperError('buffer is required.');
}
//>>includeEnd('debug');
byteOffset = when.defaultValue(byteOffset, 0);
length = when.defaultValue(length, (buffer.byteLength - byteOffset) / ComponentDatatype.getSizeInBytes(componentDatatype));
switch (componentDatatype) {
case ComponentDatatype.BYTE:
return new Int8Array(buffer, byteOffset, length);
case ComponentDatatype.UNSIGNED_BYTE:
return new Uint8Array(buffer, byteOffset, length);
case ComponentDatatype.SHORT:
return new Int16Array(buffer, byteOffset, length);
case ComponentDatatype.UNSIGNED_SHORT:
return new Uint16Array(buffer, byteOffset, length);
case ComponentDatatype.INT:
return new Int32Array(buffer, byteOffset, length);
case ComponentDatatype.UNSIGNED_INT:
return new Uint32Array(buffer, byteOffset, length);
case ComponentDatatype.FLOAT:
return new Float32Array(buffer, byteOffset, length);
case ComponentDatatype.DOUBLE:
return new Float64Array(buffer, byteOffset, length);
//>>includeStart('debug', pragmas.debug);
default:
throw new Check.DeveloperError('componentDatatype is not a valid value.');
//>>includeEnd('debug');
}
};
/**
* Get the ComponentDatatype from its name.
*
* @param {String} name The name of the ComponentDatatype.
* @returns {ComponentDatatype} The ComponentDatatype.
*
* @exception {DeveloperError} name is not a valid value.
*/
ComponentDatatype.fromName = function(name) {
switch (name) {
case 'BYTE':
return ComponentDatatype.BYTE;
case 'UNSIGNED_BYTE':
return ComponentDatatype.UNSIGNED_BYTE;
case 'SHORT':
return ComponentDatatype.SHORT;
case 'UNSIGNED_SHORT':
return ComponentDatatype.UNSIGNED_SHORT;
case 'INT':
return ComponentDatatype.INT;
case 'UNSIGNED_INT':
return ComponentDatatype.UNSIGNED_INT;
case 'FLOAT':
return ComponentDatatype.FLOAT;
case 'DOUBLE':
return ComponentDatatype.DOUBLE;
//>>includeStart('debug', pragmas.debug);
default:
throw new Check.DeveloperError('name is not a valid value.');
//>>includeEnd('debug');
}
};
var ComponentDatatype$1 = Object.freeze(ComponentDatatype);
exports.ComponentDatatype = ComponentDatatype$1;
});

View File

@ -0,0 +1 @@
define(["exports","./defaultValue-f6d5e6da","./WebGLConstants-7f557f93"],(function(r,e,n){"use strict";const t={BYTE:n.WebGLConstants.BYTE,UNSIGNED_BYTE:n.WebGLConstants.UNSIGNED_BYTE,SHORT:n.WebGLConstants.SHORT,UNSIGNED_SHORT:n.WebGLConstants.UNSIGNED_SHORT,INT:n.WebGLConstants.INT,UNSIGNED_INT:n.WebGLConstants.UNSIGNED_INT,FLOAT:n.WebGLConstants.FLOAT,DOUBLE:n.WebGLConstants.DOUBLE,getSizeInBytes:function(r){switch(r){case t.BYTE:return Int8Array.BYTES_PER_ELEMENT;case t.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case t.SHORT:return Int16Array.BYTES_PER_ELEMENT;case t.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case t.INT:return Int32Array.BYTES_PER_ELEMENT;case t.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case t.FLOAT:return Float32Array.BYTES_PER_ELEMENT;case t.DOUBLE:return Float64Array.BYTES_PER_ELEMENT}},fromTypedArray:function(r){return r instanceof Int8Array?t.BYTE:r instanceof Uint8Array?t.UNSIGNED_BYTE:r instanceof Int16Array?t.SHORT:r instanceof Uint16Array?t.UNSIGNED_SHORT:r instanceof Int32Array?t.INT:r instanceof Uint32Array?t.UNSIGNED_INT:r instanceof Float32Array?t.FLOAT:r instanceof Float64Array?t.DOUBLE:void 0},validate:function(r){return e.defined(r)&&(r===t.BYTE||r===t.UNSIGNED_BYTE||r===t.SHORT||r===t.UNSIGNED_SHORT||r===t.INT||r===t.UNSIGNED_INT||r===t.FLOAT||r===t.DOUBLE)},createTypedArray:function(r,e){switch(r){case t.BYTE:return new Int8Array(e);case t.UNSIGNED_BYTE:return new Uint8Array(e);case t.SHORT:return new Int16Array(e);case t.UNSIGNED_SHORT:return new Uint16Array(e);case t.INT:return new Int32Array(e);case t.UNSIGNED_INT:return new Uint32Array(e);case t.FLOAT:return new Float32Array(e);case t.DOUBLE:return new Float64Array(e)}},createArrayBufferView:function(r,n,a,E){switch(a=e.defaultValue(a,0),E=e.defaultValue(E,(n.byteLength-a)/t.getSizeInBytes(r)),r){case t.BYTE:return new Int8Array(n,a,E);case t.UNSIGNED_BYTE:return new Uint8Array(n,a,E);case t.SHORT:return new Int16Array(n,a,E);case t.UNSIGNED_SHORT:return new Uint16Array(n,a,E);case t.INT:return new Int32Array(n,a,E);case t.UNSIGNED_INT:return new Uint32Array(n,a,E);case t.FLOAT:return new Float32Array(n,a,E);case t.DOUBLE:return new Float64Array(n,a,E)}},fromName:function(r){switch(r){case"BYTE":return t.BYTE;case"UNSIGNED_BYTE":return t.UNSIGNED_BYTE;case"SHORT":return t.SHORT;case"UNSIGNED_SHORT":return t.UNSIGNED_SHORT;case"INT":return t.INT;case"UNSIGNED_INT":return t.UNSIGNED_INT;case"FLOAT":return t.FLOAT;case"DOUBLE":return t.DOUBLE}}};var a=Object.freeze(t);r.ComponentDatatype=a}));

View File

@ -1 +0,0 @@
define(["exports","./when-b60132fc","./Check-7b2a090c","./WebGLConstants-4ae0db90"],(function(r,e,n,t){"use strict";var a={BYTE:t.WebGLConstants.BYTE,UNSIGNED_BYTE:t.WebGLConstants.UNSIGNED_BYTE,SHORT:t.WebGLConstants.SHORT,UNSIGNED_SHORT:t.WebGLConstants.UNSIGNED_SHORT,INT:t.WebGLConstants.INT,UNSIGNED_INT:t.WebGLConstants.UNSIGNED_INT,FLOAT:t.WebGLConstants.FLOAT,DOUBLE:t.WebGLConstants.DOUBLE,getSizeInBytes:function(r){switch(r){case a.BYTE:return Int8Array.BYTES_PER_ELEMENT;case a.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case a.SHORT:return Int16Array.BYTES_PER_ELEMENT;case a.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case a.INT:return Int32Array.BYTES_PER_ELEMENT;case a.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT;case a.FLOAT:return Float32Array.BYTES_PER_ELEMENT;case a.DOUBLE:return Float64Array.BYTES_PER_ELEMENT}},fromTypedArray:function(r){return r instanceof Int8Array?a.BYTE:r instanceof Uint8Array?a.UNSIGNED_BYTE:r instanceof Int16Array?a.SHORT:r instanceof Uint16Array?a.UNSIGNED_SHORT:r instanceof Int32Array?a.INT:r instanceof Uint32Array?a.UNSIGNED_INT:r instanceof Float32Array?a.FLOAT:r instanceof Float64Array?a.DOUBLE:void 0},validate:function(r){return e.defined(r)&&(r===a.BYTE||r===a.UNSIGNED_BYTE||r===a.SHORT||r===a.UNSIGNED_SHORT||r===a.INT||r===a.UNSIGNED_INT||r===a.FLOAT||r===a.DOUBLE)},createTypedArray:function(r,e){switch(r){case a.BYTE:return new Int8Array(e);case a.UNSIGNED_BYTE:return new Uint8Array(e);case a.SHORT:return new Int16Array(e);case a.UNSIGNED_SHORT:return new Uint16Array(e);case a.INT:return new Int32Array(e);case a.UNSIGNED_INT:return new Uint32Array(e);case a.FLOAT:return new Float32Array(e);case a.DOUBLE:return new Float64Array(e)}},createArrayBufferView:function(r,n,t,E){switch(t=e.defaultValue(t,0),E=e.defaultValue(E,(n.byteLength-t)/a.getSizeInBytes(r)),r){case a.BYTE:return new Int8Array(n,t,E);case a.UNSIGNED_BYTE:return new Uint8Array(n,t,E);case a.SHORT:return new Int16Array(n,t,E);case a.UNSIGNED_SHORT:return new Uint16Array(n,t,E);case a.INT:return new Int32Array(n,t,E);case a.UNSIGNED_INT:return new Uint32Array(n,t,E);case a.FLOAT:return new Float32Array(n,t,E);case a.DOUBLE:return new Float64Array(n,t,E)}},fromName:function(r){switch(r){case"BYTE":return a.BYTE;case"UNSIGNED_BYTE":return a.UNSIGNED_BYTE;case"SHORT":return a.SHORT;case"UNSIGNED_SHORT":return a.UNSIGNED_SHORT;case"INT":return a.INT;case"UNSIGNED_INT":return a.UNSIGNED_INT;case"FLOAT":return a.FLOAT;case"DOUBLE":return a.DOUBLE}}},E=Object.freeze(a);r.ComponentDatatype=E}));

View File

@ -1 +0,0 @@
define(["exports","./when-b60132fc"],(function(t,e){"use strict";function i(t,e,i,n,r){this._format=t,this._width=e,this._height=i,this._buffer=n,this._datatype=r}Object.defineProperties(i.prototype,{internalFormat:{get:function(){return this._format}},width:{get:function(){return this._width}},height:{get:function(){return this._height}},bufferView:{get:function(){return this._buffer}},pixelDatatype:{get:function(){return this._datatype}}}),i.clone=function(t){if(e.defined(t))return new i(t._format,t._width,t._height,t._buffer,t._datatype)},i.prototype.clone=function(){return i.clone(this)},t.CompressedTextureBuffer=i}));

View File

@ -0,0 +1 @@
define(["exports","./Matrix2-413c4048","./Matrix3-81054f0f","./OrientedBoundingBox-fc7f7ca4"],(function(n,t,e,r){"use strict";const a={},i=new e.Cartesian3,o=new e.Cartesian3,u=new e.Cartesian3,s=new e.Cartesian3,c=new r.OrientedBoundingBox;function C(n,r,a,o,u){const s=e.Cartesian3.subtract(n,r,i),c=e.Cartesian3.dot(a,s),C=e.Cartesian3.dot(o,s);return t.Cartesian2.fromElements(c,C,u)}a.validOutline=function(n){const t=r.OrientedBoundingBox.fromPoints(n,c).halfAxes,a=e.Matrix3.getColumn(t,0,o),i=e.Matrix3.getColumn(t,1,u),C=e.Matrix3.getColumn(t,2,s),m=e.Cartesian3.magnitude(a),g=e.Cartesian3.magnitude(i),l=e.Cartesian3.magnitude(C);return!(0===m&&(0===g||0===l)||0===g&&0===l)},a.computeProjectTo2DArguments=function(n,t,a,i){const C=r.OrientedBoundingBox.fromPoints(n,c),m=C.halfAxes,g=e.Matrix3.getColumn(m,0,o),l=e.Matrix3.getColumn(m,1,u),d=e.Matrix3.getColumn(m,2,s),f=e.Cartesian3.magnitude(g),x=e.Cartesian3.magnitude(l),M=e.Cartesian3.magnitude(d),B=Math.min(f,x,M);if(0===f&&(0===x||0===M)||0===x&&0===M)return!1;let P,w;return B!==x&&B!==M||(P=g),B===f?P=l:B===M&&(w=l),B!==f&&B!==x||(w=d),e.Cartesian3.normalize(P,a),e.Cartesian3.normalize(w,i),e.Cartesian3.clone(C.center,t),!0},a.createProjectPointsTo2DFunction=function(n,t,e){return function(r){const a=new Array(r.length);for(let i=0;i<r.length;i++)a[i]=C(r[i],n,t,e);return a}},a.createProjectPointTo2DFunction=function(n,t,e){return function(r,a){return C(r,n,t,e,a)}};var m=a;n.CoplanarPolygonGeometryLibrary=m}));

View File

@ -1,128 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Check-70bec281', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './OrientedBoundingBox-0ede1598'], function (exports, Check, Cartographic, Cartesian2, BoundingSphere, OrientedBoundingBox) { 'use strict';
/**
* @private
*/
var CoplanarPolygonGeometryLibrary = {};
var scratchIntersectionPoint = new Cartographic.Cartesian3();
var scratchXAxis = new Cartographic.Cartesian3();
var scratchYAxis = new Cartographic.Cartesian3();
var scratchZAxis = new Cartographic.Cartesian3();
var obbScratch = new OrientedBoundingBox.OrientedBoundingBox();
CoplanarPolygonGeometryLibrary.validOutline = function(positions) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
// If all the points are on a line return undefined because we can't draw a polygon
return !((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0));
};
// call after removeDuplicates
CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments = function(positions, centerResult, planeAxis1Result, planeAxis2Result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
Check.Check.defined('centerResult', centerResult);
Check.Check.defined('planeAxis1Result', planeAxis1Result);
Check.Check.defined('planeAxis2Result', planeAxis2Result);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
var min = Math.min(xMag, yMag, zMag);
// If all the points are on a line return undefined because we can't draw a polygon
if ((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0)) {
return false;
}
var planeAxis1;
var planeAxis2;
if (min === yMag || min === zMag) {
planeAxis1 = xAxis;
}
if (min === xMag) {
planeAxis1 = yAxis;
} else if (min === zMag) {
planeAxis2 = yAxis;
}
if (min === xMag || min === yMag) {
planeAxis2 = zAxis;
}
Cartographic.Cartesian3.normalize(planeAxis1, planeAxis1Result);
Cartographic.Cartesian3.normalize(planeAxis2, planeAxis2Result);
Cartographic.Cartesian3.clone(orientedBoundingBox.center, centerResult);
return true;
};
function projectTo2D(position, center, axis1, axis2, result) {
var v = Cartographic.Cartesian3.subtract(position, center, scratchIntersectionPoint);
var x = Cartographic.Cartesian3.dot(axis1, v);
var y = Cartographic.Cartesian3.dot(axis2, v);
return Cartesian2.Cartesian2.fromElements(x, y, result);
}
CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction = function(center, axis1, axis2) {
return function(positions) {
var positionResults = new Array(positions.length);
for (var i = 0; i < positions.length; i++) {
positionResults[i] = projectTo2D(positions[i], center, axis1, axis2);
}
return positionResults;
};
};
CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction = function(center, axis1, axis2) {
return function(position, result) {
return projectTo2D(position, center, axis1, axis2, result);
};
};
exports.CoplanarPolygonGeometryLibrary = CoplanarPolygonGeometryLibrary;
});

View File

@ -1,128 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Check-70bec281', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './OrientedBoundingBox-772746db'], function (exports, Check, Cartographic, Cartesian2, BoundingSphere, OrientedBoundingBox) { 'use strict';
/**
* @private
*/
var CoplanarPolygonGeometryLibrary = {};
var scratchIntersectionPoint = new Cartographic.Cartesian3();
var scratchXAxis = new Cartographic.Cartesian3();
var scratchYAxis = new Cartographic.Cartesian3();
var scratchZAxis = new Cartographic.Cartesian3();
var obbScratch = new OrientedBoundingBox.OrientedBoundingBox();
CoplanarPolygonGeometryLibrary.validOutline = function(positions) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
// If all the points are on a line return undefined because we can't draw a polygon
return !((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0));
};
// call after removeDuplicates
CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments = function(positions, centerResult, planeAxis1Result, planeAxis2Result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
Check.Check.defined('centerResult', centerResult);
Check.Check.defined('planeAxis1Result', planeAxis1Result);
Check.Check.defined('planeAxis2Result', planeAxis2Result);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
var min = Math.min(xMag, yMag, zMag);
// If all the points are on a line return undefined because we can't draw a polygon
if ((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0)) {
return false;
}
var planeAxis1;
var planeAxis2;
if (min === yMag || min === zMag) {
planeAxis1 = xAxis;
}
if (min === xMag) {
planeAxis1 = yAxis;
} else if (min === zMag) {
planeAxis2 = yAxis;
}
if (min === xMag || min === yMag) {
planeAxis2 = zAxis;
}
Cartographic.Cartesian3.normalize(planeAxis1, planeAxis1Result);
Cartographic.Cartesian3.normalize(planeAxis2, planeAxis2Result);
Cartographic.Cartesian3.clone(orientedBoundingBox.center, centerResult);
return true;
};
function projectTo2D(position, center, axis1, axis2, result) {
var v = Cartographic.Cartesian3.subtract(position, center, scratchIntersectionPoint);
var x = Cartographic.Cartesian3.dot(axis1, v);
var y = Cartographic.Cartesian3.dot(axis2, v);
return Cartesian2.Cartesian2.fromElements(x, y, result);
}
CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction = function(center, axis1, axis2) {
return function(positions) {
var positionResults = new Array(positions.length);
for (var i = 0; i < positions.length; i++) {
positionResults[i] = projectTo2D(positions[i], center, axis1, axis2);
}
return positionResults;
};
};
CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction = function(center, axis1, axis2) {
return function(position, result) {
return projectTo2D(position, center, axis1, axis2, result);
};
};
exports.CoplanarPolygonGeometryLibrary = CoplanarPolygonGeometryLibrary;
});

View File

@ -1,128 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Check-70bec281', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './OrientedBoundingBox-a30be34f'], function (exports, Check, Cartographic, Cartesian2, BoundingSphere, OrientedBoundingBox) { 'use strict';
/**
* @private
*/
var CoplanarPolygonGeometryLibrary = {};
var scratchIntersectionPoint = new Cartographic.Cartesian3();
var scratchXAxis = new Cartographic.Cartesian3();
var scratchYAxis = new Cartographic.Cartesian3();
var scratchZAxis = new Cartographic.Cartesian3();
var obbScratch = new OrientedBoundingBox.OrientedBoundingBox();
CoplanarPolygonGeometryLibrary.validOutline = function(positions) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
// If all the points are on a line return undefined because we can't draw a polygon
return !((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0));
};
// call after removeDuplicates
CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments = function(positions, centerResult, planeAxis1Result, planeAxis2Result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
Check.Check.defined('centerResult', centerResult);
Check.Check.defined('planeAxis1Result', planeAxis1Result);
Check.Check.defined('planeAxis2Result', planeAxis2Result);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
var min = Math.min(xMag, yMag, zMag);
// If all the points are on a line return undefined because we can't draw a polygon
if ((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0)) {
return false;
}
var planeAxis1;
var planeAxis2;
if (min === yMag || min === zMag) {
planeAxis1 = xAxis;
}
if (min === xMag) {
planeAxis1 = yAxis;
} else if (min === zMag) {
planeAxis2 = yAxis;
}
if (min === xMag || min === yMag) {
planeAxis2 = zAxis;
}
Cartographic.Cartesian3.normalize(planeAxis1, planeAxis1Result);
Cartographic.Cartesian3.normalize(planeAxis2, planeAxis2Result);
Cartographic.Cartesian3.clone(orientedBoundingBox.center, centerResult);
return true;
};
function projectTo2D(position, center, axis1, axis2, result) {
var v = Cartographic.Cartesian3.subtract(position, center, scratchIntersectionPoint);
var x = Cartographic.Cartesian3.dot(axis1, v);
var y = Cartographic.Cartesian3.dot(axis2, v);
return Cartesian2.Cartesian2.fromElements(x, y, result);
}
CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction = function(center, axis1, axis2) {
return function(positions) {
var positionResults = new Array(positions.length);
for (var i = 0; i < positions.length; i++) {
positionResults[i] = projectTo2D(positions[i], center, axis1, axis2);
}
return positionResults;
};
};
CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction = function(center, axis1, axis2) {
return function(position, result) {
return projectTo2D(position, center, axis1, axis2, result);
};
};
exports.CoplanarPolygonGeometryLibrary = CoplanarPolygonGeometryLibrary;
});

View File

@ -1 +0,0 @@
define(["exports","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./BoundingSphere-561b54d0","./OrientedBoundingBox-f1d7843f"],(function(n,t,e,r,a,i){"use strict";var o={},u=new e.Cartesian3,s=new e.Cartesian3,C=new e.Cartesian3,d=new e.Cartesian3,c=new i.OrientedBoundingBox;function g(n,r,a,i,o){var s=e.Cartesian3.subtract(n,r,u),C=e.Cartesian3.dot(a,s),d=e.Cartesian3.dot(i,s);return t.Cartesian2.fromElements(C,d,o)}o.validOutline=function(n){var t=i.OrientedBoundingBox.fromPoints(n,c).halfAxes,r=a.Matrix3.getColumn(t,0,s),o=a.Matrix3.getColumn(t,1,C),u=a.Matrix3.getColumn(t,2,d),g=e.Cartesian3.magnitude(r),m=e.Cartesian3.magnitude(o),l=e.Cartesian3.magnitude(u);return!(0===g&&(0===m||0===l)||0===m&&0===l)},o.computeProjectTo2DArguments=function(n,t,r,o){var u,g,m=i.OrientedBoundingBox.fromPoints(n,c),l=m.halfAxes,f=a.Matrix3.getColumn(l,0,s),x=a.Matrix3.getColumn(l,1,C),B=a.Matrix3.getColumn(l,2,d),h=e.Cartesian3.magnitude(f),P=e.Cartesian3.magnitude(x),M=e.Cartesian3.magnitude(B),v=Math.min(h,P,M);return(0!==h||0!==P&&0!==M)&&(0!==P||0!==M)&&(v!==P&&v!==M||(u=f),v===h?u=x:v===M&&(g=x),v!==h&&v!==P||(g=B),e.Cartesian3.normalize(u,r),e.Cartesian3.normalize(g,o),e.Cartesian3.clone(m.center,t),!0)},o.createProjectPointsTo2DFunction=function(n,t,e){return function(r){for(var a=new Array(r.length),i=0;i<r.length;i++)a[i]=g(r[i],n,t,e);return a}},o.createProjectPointTo2DFunction=function(n,t,e){return function(r,a){return g(r,n,t,e,a)}},n.CoplanarPolygonGeometryLibrary=o}));

View File

@ -1 +0,0 @@
define(["exports","./Cartesian2-47311507","./Cartographic-3309dd0d","./Check-7b2a090c","./PrimitiveType-a54dc62f","./OrientedBoundingBox-87d59c2a"],(function(n,t,e,r,a,i){"use strict";var o={},u=new e.Cartesian3,s=new e.Cartesian3,C=new e.Cartesian3,c=new e.Cartesian3,d=new i.OrientedBoundingBox;function m(n,r,a,i,o){var s=e.Cartesian3.subtract(n,r,u),C=e.Cartesian3.dot(a,s),c=e.Cartesian3.dot(i,s);return t.Cartesian2.fromElements(C,c,o)}o.validOutline=function(n){var t=i.OrientedBoundingBox.fromPoints(n,d).halfAxes,r=a.Matrix3.getColumn(t,0,s),o=a.Matrix3.getColumn(t,1,C),u=a.Matrix3.getColumn(t,2,c),m=e.Cartesian3.magnitude(r),g=e.Cartesian3.magnitude(o),l=e.Cartesian3.magnitude(u);return!(0===m&&(0===g||0===l)||0===g&&0===l)},o.computeProjectTo2DArguments=function(n,t,r,o){var u,m,g=i.OrientedBoundingBox.fromPoints(n,d),l=g.halfAxes,f=a.Matrix3.getColumn(l,0,s),x=a.Matrix3.getColumn(l,1,C),P=a.Matrix3.getColumn(l,2,c),B=e.Cartesian3.magnitude(f),h=e.Cartesian3.magnitude(x),v=e.Cartesian3.magnitude(P),M=Math.min(B,h,v);return(0!==B||0!==h&&0!==v)&&(0!==h||0!==v)&&(M!==h&&M!==v||(u=f),M===B?u=x:M===v&&(m=x),M!==B&&M!==h||(m=P),e.Cartesian3.normalize(u,r),e.Cartesian3.normalize(m,o),e.Cartesian3.clone(g.center,t),!0)},o.createProjectPointsTo2DFunction=function(n,t,e){return function(r){for(var a=new Array(r.length),i=0;i<r.length;i++)a[i]=m(r[i],n,t,e);return a}},o.createProjectPointTo2DFunction=function(n,t,e){return function(r,a){return m(r,n,t,e,a)}},n.CoplanarPolygonGeometryLibrary=o}));

View File

@ -1,128 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Check-70bec281', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './OrientedBoundingBox-635e6e10'], function (exports, Check, Cartographic, Cartesian2, BoundingSphere, OrientedBoundingBox) { 'use strict';
/**
* @private
*/
var CoplanarPolygonGeometryLibrary = {};
var scratchIntersectionPoint = new Cartographic.Cartesian3();
var scratchXAxis = new Cartographic.Cartesian3();
var scratchYAxis = new Cartographic.Cartesian3();
var scratchZAxis = new Cartographic.Cartesian3();
var obbScratch = new OrientedBoundingBox.OrientedBoundingBox();
CoplanarPolygonGeometryLibrary.validOutline = function(positions) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
// If all the points are on a line return undefined because we can't draw a polygon
return !((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0));
};
// call after removeDuplicates
CoplanarPolygonGeometryLibrary.computeProjectTo2DArguments = function(positions, centerResult, planeAxis1Result, planeAxis2Result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('positions', positions);
Check.Check.defined('centerResult', centerResult);
Check.Check.defined('planeAxis1Result', planeAxis1Result);
Check.Check.defined('planeAxis2Result', planeAxis2Result);
//>>includeEnd('debug');
var orientedBoundingBox = OrientedBoundingBox.OrientedBoundingBox.fromPoints(positions, obbScratch);
var halfAxes = orientedBoundingBox.halfAxes;
var xAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 0, scratchXAxis);
var yAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 1, scratchYAxis);
var zAxis = BoundingSphere.Matrix3.getColumn(halfAxes, 2, scratchZAxis);
var xMag = Cartographic.Cartesian3.magnitude(xAxis);
var yMag = Cartographic.Cartesian3.magnitude(yAxis);
var zMag = Cartographic.Cartesian3.magnitude(zAxis);
var min = Math.min(xMag, yMag, zMag);
// If all the points are on a line return undefined because we can't draw a polygon
if ((xMag === 0 && (yMag === 0 || zMag === 0)) || (yMag === 0 && zMag === 0)) {
return false;
}
var planeAxis1;
var planeAxis2;
if (min === yMag || min === zMag) {
planeAxis1 = xAxis;
}
if (min === xMag) {
planeAxis1 = yAxis;
} else if (min === zMag) {
planeAxis2 = yAxis;
}
if (min === xMag || min === yMag) {
planeAxis2 = zAxis;
}
Cartographic.Cartesian3.normalize(planeAxis1, planeAxis1Result);
Cartographic.Cartesian3.normalize(planeAxis2, planeAxis2Result);
Cartographic.Cartesian3.clone(orientedBoundingBox.center, centerResult);
return true;
};
function projectTo2D(position, center, axis1, axis2, result) {
var v = Cartographic.Cartesian3.subtract(position, center, scratchIntersectionPoint);
var x = Cartographic.Cartesian3.dot(axis1, v);
var y = Cartographic.Cartesian3.dot(axis2, v);
return Cartesian2.Cartesian2.fromElements(x, y, result);
}
CoplanarPolygonGeometryLibrary.createProjectPointsTo2DFunction = function(center, axis1, axis2) {
return function(positions) {
var positionResults = new Array(positions.length);
for (var i = 0; i < positions.length; i++) {
positionResults[i] = projectTo2D(positions[i], center, axis1, axis2);
}
return positionResults;
};
};
CoplanarPolygonGeometryLibrary.createProjectPointTo2DFunction = function(center, axis1, axis2) {
return function(position, result) {
return projectTo2D(position, center, axis1, axis2, result);
};
};
exports.CoplanarPolygonGeometryLibrary = CoplanarPolygonGeometryLibrary;
});

View File

@ -1,318 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Math-61ede240', './Cartographic-fe4be337', './BoundingSphere-775c5788', './Transforms-b2e71640', './PolylineVolumeGeometryLibrary-934b338a', './PolylinePipeline-a9f32196'], function (exports, when, _Math, Cartographic, BoundingSphere, Transforms, PolylineVolumeGeometryLibrary, PolylinePipeline) { 'use strict';
/**
* @private
*/
var CorridorGeometryLibrary = {};
var scratch1 = new Cartographic.Cartesian3();
var scratch2 = new Cartographic.Cartesian3();
var scratch3 = new Cartographic.Cartesian3();
var scratch4 = new Cartographic.Cartesian3();
var scaleArray2 = [new Cartographic.Cartesian3(), new Cartographic.Cartesian3()];
var cartesian1 = new Cartographic.Cartesian3();
var cartesian2 = new Cartographic.Cartesian3();
var cartesian3 = new Cartographic.Cartesian3();
var cartesian4 = new Cartographic.Cartesian3();
var cartesian5 = new Cartographic.Cartesian3();
var cartesian6 = new Cartographic.Cartesian3();
var cartesian7 = new Cartographic.Cartesian3();
var cartesian8 = new Cartographic.Cartesian3();
var cartesian9 = new Cartographic.Cartesian3();
var cartesian10 = new Cartographic.Cartesian3();
var quaterion = new Transforms.Quaternion();
var rotMatrix = new BoundingSphere.Matrix3();
function computeRoundCorner(cornerPoint, startPoint, endPoint, cornerType, leftIsOutside) {
var angle = Cartographic.Cartesian3.angleBetween(Cartographic.Cartesian3.subtract(startPoint, cornerPoint, scratch1), Cartographic.Cartesian3.subtract(endPoint, cornerPoint, scratch2));
var granularity = (cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) ? 1 : Math.ceil(angle / _Math.CesiumMath.toRadians(5)) + 1;
var size = granularity * 3;
var array = new Array(size);
array[size - 3] = endPoint.x;
array[size - 2] = endPoint.y;
array[size - 1] = endPoint.z;
var m;
if (leftIsOutside) {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(Cartographic.Cartesian3.negate(cornerPoint, scratch1), angle / granularity, quaterion), rotMatrix);
} else {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(cornerPoint, angle / granularity, quaterion), rotMatrix);
}
var index = 0;
startPoint = Cartographic.Cartesian3.clone(startPoint, scratch1);
for (var i = 0; i < granularity; i++) {
startPoint = BoundingSphere.Matrix3.multiplyByVector(m, startPoint, startPoint);
array[index++] = startPoint.x;
array[index++] = startPoint.y;
array[index++] = startPoint.z;
}
return array;
}
function addEndCaps(calculatedPositions) {
var cornerPoint = cartesian1;
var startPoint = cartesian2;
var endPoint = cartesian3;
var leftEdge = calculatedPositions[1];
startPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[1], leftEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[0], 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var firstEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
var length = calculatedPositions.length - 1;
var rightEdge = calculatedPositions[length - 1];
leftEdge = calculatedPositions[length];
startPoint = Cartographic.Cartesian3.fromArray(rightEdge, rightEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(leftEdge, 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var lastEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
return [firstEndCap, lastEndCap];
}
function computeMiteredCorner(position, leftCornerDirection, lastPoint, leftIsOutside) {
var cornerPoint = scratch1;
if (leftIsOutside) {
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
} else {
leftCornerDirection = Cartographic.Cartesian3.negate(leftCornerDirection, leftCornerDirection);
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
}
return [cornerPoint.x, cornerPoint.y, cornerPoint.z, lastPoint.x, lastPoint.y, lastPoint.z];
}
function addShiftedPositions(positions, left, scalar, calculatedPositions) {
var rightPositions = new Array(positions.length);
var leftPositions = new Array(positions.length);
var scaledLeft = Cartographic.Cartesian3.multiplyByScalar(left, scalar, scratch1);
var scaledRight = Cartographic.Cartesian3.negate(scaledLeft, scratch2);
var rightIndex = 0;
var leftIndex = positions.length - 1;
for (var i = 0; i < positions.length; i += 3) {
var pos = Cartographic.Cartesian3.fromArray(positions, i, scratch3);
var rightPos = Cartographic.Cartesian3.add(pos, scaledRight, scratch4);
rightPositions[rightIndex++] = rightPos.x;
rightPositions[rightIndex++] = rightPos.y;
rightPositions[rightIndex++] = rightPos.z;
var leftPos = Cartographic.Cartesian3.add(pos, scaledLeft, scratch4);
leftPositions[leftIndex--] = leftPos.z;
leftPositions[leftIndex--] = leftPos.y;
leftPositions[leftIndex--] = leftPos.x;
}
calculatedPositions.push(rightPositions, leftPositions);
return calculatedPositions;
}
/**
* @private
*/
CorridorGeometryLibrary.addAttribute = function(attribute, value, front, back) {
var x = value.x;
var y = value.y;
var z = value.z;
if (when.defined(front)) {
attribute[front] = x;
attribute[front + 1] = y;
attribute[front + 2] = z;
}
if (when.defined(back)) {
attribute[back] = z;
attribute[back - 1] = y;
attribute[back - 2] = x;
}
};
var scratchForwardProjection = new Cartographic.Cartesian3();
var scratchBackwardProjection = new Cartographic.Cartesian3();
/**
* @private
*/
CorridorGeometryLibrary.computePositions = function(params) {
var granularity = params.granularity;
var positions = params.positions;
var ellipsoid = params.ellipsoid;
var width = params.width / 2;
var cornerType = params.cornerType;
var saveAttributes = params.saveAttributes;
var normal = cartesian1;
var forward = cartesian2;
var backward = cartesian3;
var left = cartesian4;
var cornerDirection = cartesian5;
var startPoint = cartesian6;
var previousPos = cartesian7;
var rightPos = cartesian8;
var leftPos = cartesian9;
var center = cartesian10;
var calculatedPositions = [];
var calculatedLefts = (saveAttributes) ? [] : undefined;
var calculatedNormals = (saveAttributes) ? [] : undefined;
var position = positions[0]; //add first point
var nextPosition = positions[1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
previousPos = Cartographic.Cartesian3.clone(position, previousPos);
position = nextPosition;
backward = Cartographic.Cartesian3.negate(forward, backward);
var subdividedPositions;
var corners = [];
var i;
var length = positions.length;
for (i = 1; i < length - 1; i++) { // add middle points and corners
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
nextPosition = positions[i + 1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
cornerDirection = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.add(forward, backward, cornerDirection), cornerDirection);
var forwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(forward, normal), scratchForwardProjection);
Cartographic.Cartesian3.subtract(forward, forwardProjection, forwardProjection);
Cartographic.Cartesian3.normalize(forwardProjection, forwardProjection);
var backwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(backward, normal), scratchBackwardProjection);
Cartographic.Cartesian3.subtract(backward, backwardProjection, backwardProjection);
Cartographic.Cartesian3.normalize(backwardProjection, backwardProjection);
var doCorner = !_Math.CesiumMath.equalsEpsilon(Math.abs(Cartographic.Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, _Math.CesiumMath.EPSILON7);
if (doCorner) {
cornerDirection = Cartographic.Cartesian3.cross(cornerDirection, normal, cornerDirection);
cornerDirection = Cartographic.Cartesian3.cross(normal, cornerDirection, cornerDirection);
cornerDirection = Cartographic.Cartesian3.normalize(cornerDirection, cornerDirection);
var scalar = width / Math.max(0.25, Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.cross(cornerDirection, backward, scratch1)));
var leftIsOutside = PolylineVolumeGeometryLibrary.PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(forward, backward, position, ellipsoid);
cornerDirection = Cartographic.Cartesian3.multiplyByScalar(cornerDirection, scalar, cornerDirection);
if (leftIsOutside) {
rightPos = Cartographic.Cartesian3.add(position, cornerDirection, rightPos);
center = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, center), center);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(leftPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
previousPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
leftPositions : computeRoundCorner(rightPos, startPoint, leftPos, cornerType, leftIsOutside)
});
} else {
corners.push({
leftPositions : computeMiteredCorner(position, Cartographic.Cartesian3.negate(cornerDirection, cornerDirection), leftPos, leftIsOutside)
});
}
} else {
leftPos = Cartographic.Cartesian3.add(position, cornerDirection, leftPos);
center = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, center), center), center);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(rightPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
previousPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
rightPositions : computeRoundCorner(leftPos, startPoint, rightPos, cornerType, leftIsOutside)
});
} else {
corners.push({
rightPositions : computeMiteredCorner(position, cornerDirection, rightPos, leftIsOutside)
});
}
}
backward = Cartographic.Cartesian3.negate(forward, backward);
}
position = nextPosition;
}
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(position, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
var endPositions;
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED) {
endPositions = addEndCaps(calculatedPositions);
}
return {
positions : calculatedPositions,
corners : corners,
lefts : calculatedLefts,
normals : calculatedNormals,
endPositions : endPositions
};
};
exports.CorridorGeometryLibrary = CorridorGeometryLibrary;
});

File diff suppressed because one or more lines are too long

View File

@ -1,318 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Math-61ede240', './Cartographic-f2a06374', './BoundingSphere-d018a565', './Transforms-cd52cbaf', './PolylineVolumeGeometryLibrary-dd05fa5f', './PolylinePipeline-f937854b'], function (exports, when, _Math, Cartographic, BoundingSphere, Transforms, PolylineVolumeGeometryLibrary, PolylinePipeline) { 'use strict';
/**
* @private
*/
var CorridorGeometryLibrary = {};
var scratch1 = new Cartographic.Cartesian3();
var scratch2 = new Cartographic.Cartesian3();
var scratch3 = new Cartographic.Cartesian3();
var scratch4 = new Cartographic.Cartesian3();
var scaleArray2 = [new Cartographic.Cartesian3(), new Cartographic.Cartesian3()];
var cartesian1 = new Cartographic.Cartesian3();
var cartesian2 = new Cartographic.Cartesian3();
var cartesian3 = new Cartographic.Cartesian3();
var cartesian4 = new Cartographic.Cartesian3();
var cartesian5 = new Cartographic.Cartesian3();
var cartesian6 = new Cartographic.Cartesian3();
var cartesian7 = new Cartographic.Cartesian3();
var cartesian8 = new Cartographic.Cartesian3();
var cartesian9 = new Cartographic.Cartesian3();
var cartesian10 = new Cartographic.Cartesian3();
var quaterion = new Transforms.Quaternion();
var rotMatrix = new BoundingSphere.Matrix3();
function computeRoundCorner(cornerPoint, startPoint, endPoint, cornerType, leftIsOutside) {
var angle = Cartographic.Cartesian3.angleBetween(Cartographic.Cartesian3.subtract(startPoint, cornerPoint, scratch1), Cartographic.Cartesian3.subtract(endPoint, cornerPoint, scratch2));
var granularity = (cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) ? 1 : Math.ceil(angle / _Math.CesiumMath.toRadians(5)) + 1;
var size = granularity * 3;
var array = new Array(size);
array[size - 3] = endPoint.x;
array[size - 2] = endPoint.y;
array[size - 1] = endPoint.z;
var m;
if (leftIsOutside) {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(Cartographic.Cartesian3.negate(cornerPoint, scratch1), angle / granularity, quaterion), rotMatrix);
} else {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(cornerPoint, angle / granularity, quaterion), rotMatrix);
}
var index = 0;
startPoint = Cartographic.Cartesian3.clone(startPoint, scratch1);
for (var i = 0; i < granularity; i++) {
startPoint = BoundingSphere.Matrix3.multiplyByVector(m, startPoint, startPoint);
array[index++] = startPoint.x;
array[index++] = startPoint.y;
array[index++] = startPoint.z;
}
return array;
}
function addEndCaps(calculatedPositions) {
var cornerPoint = cartesian1;
var startPoint = cartesian2;
var endPoint = cartesian3;
var leftEdge = calculatedPositions[1];
startPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[1], leftEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[0], 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var firstEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
var length = calculatedPositions.length - 1;
var rightEdge = calculatedPositions[length - 1];
leftEdge = calculatedPositions[length];
startPoint = Cartographic.Cartesian3.fromArray(rightEdge, rightEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(leftEdge, 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var lastEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
return [firstEndCap, lastEndCap];
}
function computeMiteredCorner(position, leftCornerDirection, lastPoint, leftIsOutside) {
var cornerPoint = scratch1;
if (leftIsOutside) {
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
} else {
leftCornerDirection = Cartographic.Cartesian3.negate(leftCornerDirection, leftCornerDirection);
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
}
return [cornerPoint.x, cornerPoint.y, cornerPoint.z, lastPoint.x, lastPoint.y, lastPoint.z];
}
function addShiftedPositions(positions, left, scalar, calculatedPositions) {
var rightPositions = new Array(positions.length);
var leftPositions = new Array(positions.length);
var scaledLeft = Cartographic.Cartesian3.multiplyByScalar(left, scalar, scratch1);
var scaledRight = Cartographic.Cartesian3.negate(scaledLeft, scratch2);
var rightIndex = 0;
var leftIndex = positions.length - 1;
for (var i = 0; i < positions.length; i += 3) {
var pos = Cartographic.Cartesian3.fromArray(positions, i, scratch3);
var rightPos = Cartographic.Cartesian3.add(pos, scaledRight, scratch4);
rightPositions[rightIndex++] = rightPos.x;
rightPositions[rightIndex++] = rightPos.y;
rightPositions[rightIndex++] = rightPos.z;
var leftPos = Cartographic.Cartesian3.add(pos, scaledLeft, scratch4);
leftPositions[leftIndex--] = leftPos.z;
leftPositions[leftIndex--] = leftPos.y;
leftPositions[leftIndex--] = leftPos.x;
}
calculatedPositions.push(rightPositions, leftPositions);
return calculatedPositions;
}
/**
* @private
*/
CorridorGeometryLibrary.addAttribute = function(attribute, value, front, back) {
var x = value.x;
var y = value.y;
var z = value.z;
if (when.defined(front)) {
attribute[front] = x;
attribute[front + 1] = y;
attribute[front + 2] = z;
}
if (when.defined(back)) {
attribute[back] = z;
attribute[back - 1] = y;
attribute[back - 2] = x;
}
};
var scratchForwardProjection = new Cartographic.Cartesian3();
var scratchBackwardProjection = new Cartographic.Cartesian3();
/**
* @private
*/
CorridorGeometryLibrary.computePositions = function(params) {
var granularity = params.granularity;
var positions = params.positions;
var ellipsoid = params.ellipsoid;
var width = params.width / 2;
var cornerType = params.cornerType;
var saveAttributes = params.saveAttributes;
var normal = cartesian1;
var forward = cartesian2;
var backward = cartesian3;
var left = cartesian4;
var cornerDirection = cartesian5;
var startPoint = cartesian6;
var previousPos = cartesian7;
var rightPos = cartesian8;
var leftPos = cartesian9;
var center = cartesian10;
var calculatedPositions = [];
var calculatedLefts = (saveAttributes) ? [] : undefined;
var calculatedNormals = (saveAttributes) ? [] : undefined;
var position = positions[0]; //add first point
var nextPosition = positions[1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
previousPos = Cartographic.Cartesian3.clone(position, previousPos);
position = nextPosition;
backward = Cartographic.Cartesian3.negate(forward, backward);
var subdividedPositions;
var corners = [];
var i;
var length = positions.length;
for (i = 1; i < length - 1; i++) { // add middle points and corners
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
nextPosition = positions[i + 1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
cornerDirection = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.add(forward, backward, cornerDirection), cornerDirection);
var forwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(forward, normal), scratchForwardProjection);
Cartographic.Cartesian3.subtract(forward, forwardProjection, forwardProjection);
Cartographic.Cartesian3.normalize(forwardProjection, forwardProjection);
var backwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(backward, normal), scratchBackwardProjection);
Cartographic.Cartesian3.subtract(backward, backwardProjection, backwardProjection);
Cartographic.Cartesian3.normalize(backwardProjection, backwardProjection);
var doCorner = !_Math.CesiumMath.equalsEpsilon(Math.abs(Cartographic.Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, _Math.CesiumMath.EPSILON7);
if (doCorner) {
cornerDirection = Cartographic.Cartesian3.cross(cornerDirection, normal, cornerDirection);
cornerDirection = Cartographic.Cartesian3.cross(normal, cornerDirection, cornerDirection);
cornerDirection = Cartographic.Cartesian3.normalize(cornerDirection, cornerDirection);
var scalar = width / Math.max(0.25, Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.cross(cornerDirection, backward, scratch1)));
var leftIsOutside = PolylineVolumeGeometryLibrary.PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(forward, backward, position, ellipsoid);
cornerDirection = Cartographic.Cartesian3.multiplyByScalar(cornerDirection, scalar, cornerDirection);
if (leftIsOutside) {
rightPos = Cartographic.Cartesian3.add(position, cornerDirection, rightPos);
center = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, center), center);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(leftPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
previousPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
leftPositions : computeRoundCorner(rightPos, startPoint, leftPos, cornerType, leftIsOutside)
});
} else {
corners.push({
leftPositions : computeMiteredCorner(position, Cartographic.Cartesian3.negate(cornerDirection, cornerDirection), leftPos, leftIsOutside)
});
}
} else {
leftPos = Cartographic.Cartesian3.add(position, cornerDirection, leftPos);
center = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, center), center), center);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(rightPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
previousPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
rightPositions : computeRoundCorner(leftPos, startPoint, rightPos, cornerType, leftIsOutside)
});
} else {
corners.push({
rightPositions : computeMiteredCorner(position, cornerDirection, rightPos, leftIsOutside)
});
}
}
backward = Cartographic.Cartesian3.negate(forward, backward);
}
position = nextPosition;
}
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(position, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
var endPositions;
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED) {
endPositions = addEndCaps(calculatedPositions);
}
return {
positions : calculatedPositions,
corners : corners,
lefts : calculatedLefts,
normals : calculatedNormals,
endPositions : endPositions
};
};
exports.CorridorGeometryLibrary = CorridorGeometryLibrary;
});

File diff suppressed because one or more lines are too long

View File

@ -1,318 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Math-61ede240', './Cartographic-f2a06374', './BoundingSphere-d018a565', './Transforms-f77c92da', './PolylineVolumeGeometryLibrary-44de161b', './PolylinePipeline-f937854b'], function (exports, when, _Math, Cartographic, BoundingSphere, Transforms, PolylineVolumeGeometryLibrary, PolylinePipeline) { 'use strict';
/**
* @private
*/
var CorridorGeometryLibrary = {};
var scratch1 = new Cartographic.Cartesian3();
var scratch2 = new Cartographic.Cartesian3();
var scratch3 = new Cartographic.Cartesian3();
var scratch4 = new Cartographic.Cartesian3();
var scaleArray2 = [new Cartographic.Cartesian3(), new Cartographic.Cartesian3()];
var cartesian1 = new Cartographic.Cartesian3();
var cartesian2 = new Cartographic.Cartesian3();
var cartesian3 = new Cartographic.Cartesian3();
var cartesian4 = new Cartographic.Cartesian3();
var cartesian5 = new Cartographic.Cartesian3();
var cartesian6 = new Cartographic.Cartesian3();
var cartesian7 = new Cartographic.Cartesian3();
var cartesian8 = new Cartographic.Cartesian3();
var cartesian9 = new Cartographic.Cartesian3();
var cartesian10 = new Cartographic.Cartesian3();
var quaterion = new Transforms.Quaternion();
var rotMatrix = new BoundingSphere.Matrix3();
function computeRoundCorner(cornerPoint, startPoint, endPoint, cornerType, leftIsOutside) {
var angle = Cartographic.Cartesian3.angleBetween(Cartographic.Cartesian3.subtract(startPoint, cornerPoint, scratch1), Cartographic.Cartesian3.subtract(endPoint, cornerPoint, scratch2));
var granularity = (cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) ? 1 : Math.ceil(angle / _Math.CesiumMath.toRadians(5)) + 1;
var size = granularity * 3;
var array = new Array(size);
array[size - 3] = endPoint.x;
array[size - 2] = endPoint.y;
array[size - 1] = endPoint.z;
var m;
if (leftIsOutside) {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(Cartographic.Cartesian3.negate(cornerPoint, scratch1), angle / granularity, quaterion), rotMatrix);
} else {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(cornerPoint, angle / granularity, quaterion), rotMatrix);
}
var index = 0;
startPoint = Cartographic.Cartesian3.clone(startPoint, scratch1);
for (var i = 0; i < granularity; i++) {
startPoint = BoundingSphere.Matrix3.multiplyByVector(m, startPoint, startPoint);
array[index++] = startPoint.x;
array[index++] = startPoint.y;
array[index++] = startPoint.z;
}
return array;
}
function addEndCaps(calculatedPositions) {
var cornerPoint = cartesian1;
var startPoint = cartesian2;
var endPoint = cartesian3;
var leftEdge = calculatedPositions[1];
startPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[1], leftEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[0], 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var firstEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
var length = calculatedPositions.length - 1;
var rightEdge = calculatedPositions[length - 1];
leftEdge = calculatedPositions[length];
startPoint = Cartographic.Cartesian3.fromArray(rightEdge, rightEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(leftEdge, 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var lastEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
return [firstEndCap, lastEndCap];
}
function computeMiteredCorner(position, leftCornerDirection, lastPoint, leftIsOutside) {
var cornerPoint = scratch1;
if (leftIsOutside) {
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
} else {
leftCornerDirection = Cartographic.Cartesian3.negate(leftCornerDirection, leftCornerDirection);
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
}
return [cornerPoint.x, cornerPoint.y, cornerPoint.z, lastPoint.x, lastPoint.y, lastPoint.z];
}
function addShiftedPositions(positions, left, scalar, calculatedPositions) {
var rightPositions = new Array(positions.length);
var leftPositions = new Array(positions.length);
var scaledLeft = Cartographic.Cartesian3.multiplyByScalar(left, scalar, scratch1);
var scaledRight = Cartographic.Cartesian3.negate(scaledLeft, scratch2);
var rightIndex = 0;
var leftIndex = positions.length - 1;
for (var i = 0; i < positions.length; i += 3) {
var pos = Cartographic.Cartesian3.fromArray(positions, i, scratch3);
var rightPos = Cartographic.Cartesian3.add(pos, scaledRight, scratch4);
rightPositions[rightIndex++] = rightPos.x;
rightPositions[rightIndex++] = rightPos.y;
rightPositions[rightIndex++] = rightPos.z;
var leftPos = Cartographic.Cartesian3.add(pos, scaledLeft, scratch4);
leftPositions[leftIndex--] = leftPos.z;
leftPositions[leftIndex--] = leftPos.y;
leftPositions[leftIndex--] = leftPos.x;
}
calculatedPositions.push(rightPositions, leftPositions);
return calculatedPositions;
}
/**
* @private
*/
CorridorGeometryLibrary.addAttribute = function(attribute, value, front, back) {
var x = value.x;
var y = value.y;
var z = value.z;
if (when.defined(front)) {
attribute[front] = x;
attribute[front + 1] = y;
attribute[front + 2] = z;
}
if (when.defined(back)) {
attribute[back] = z;
attribute[back - 1] = y;
attribute[back - 2] = x;
}
};
var scratchForwardProjection = new Cartographic.Cartesian3();
var scratchBackwardProjection = new Cartographic.Cartesian3();
/**
* @private
*/
CorridorGeometryLibrary.computePositions = function(params) {
var granularity = params.granularity;
var positions = params.positions;
var ellipsoid = params.ellipsoid;
var width = params.width / 2;
var cornerType = params.cornerType;
var saveAttributes = params.saveAttributes;
var normal = cartesian1;
var forward = cartesian2;
var backward = cartesian3;
var left = cartesian4;
var cornerDirection = cartesian5;
var startPoint = cartesian6;
var previousPos = cartesian7;
var rightPos = cartesian8;
var leftPos = cartesian9;
var center = cartesian10;
var calculatedPositions = [];
var calculatedLefts = (saveAttributes) ? [] : undefined;
var calculatedNormals = (saveAttributes) ? [] : undefined;
var position = positions[0]; //add first point
var nextPosition = positions[1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
previousPos = Cartographic.Cartesian3.clone(position, previousPos);
position = nextPosition;
backward = Cartographic.Cartesian3.negate(forward, backward);
var subdividedPositions;
var corners = [];
var i;
var length = positions.length;
for (i = 1; i < length - 1; i++) { // add middle points and corners
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
nextPosition = positions[i + 1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
cornerDirection = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.add(forward, backward, cornerDirection), cornerDirection);
var forwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(forward, normal), scratchForwardProjection);
Cartographic.Cartesian3.subtract(forward, forwardProjection, forwardProjection);
Cartographic.Cartesian3.normalize(forwardProjection, forwardProjection);
var backwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(backward, normal), scratchBackwardProjection);
Cartographic.Cartesian3.subtract(backward, backwardProjection, backwardProjection);
Cartographic.Cartesian3.normalize(backwardProjection, backwardProjection);
var doCorner = !_Math.CesiumMath.equalsEpsilon(Math.abs(Cartographic.Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, _Math.CesiumMath.EPSILON7);
if (doCorner) {
cornerDirection = Cartographic.Cartesian3.cross(cornerDirection, normal, cornerDirection);
cornerDirection = Cartographic.Cartesian3.cross(normal, cornerDirection, cornerDirection);
cornerDirection = Cartographic.Cartesian3.normalize(cornerDirection, cornerDirection);
var scalar = width / Math.max(0.25, Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.cross(cornerDirection, backward, scratch1)));
var leftIsOutside = PolylineVolumeGeometryLibrary.PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(forward, backward, position, ellipsoid);
cornerDirection = Cartographic.Cartesian3.multiplyByScalar(cornerDirection, scalar, cornerDirection);
if (leftIsOutside) {
rightPos = Cartographic.Cartesian3.add(position, cornerDirection, rightPos);
center = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, center), center);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(leftPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
previousPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
leftPositions : computeRoundCorner(rightPos, startPoint, leftPos, cornerType, leftIsOutside)
});
} else {
corners.push({
leftPositions : computeMiteredCorner(position, Cartographic.Cartesian3.negate(cornerDirection, cornerDirection), leftPos, leftIsOutside)
});
}
} else {
leftPos = Cartographic.Cartesian3.add(position, cornerDirection, leftPos);
center = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, center), center), center);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(rightPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
previousPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
rightPositions : computeRoundCorner(leftPos, startPoint, rightPos, cornerType, leftIsOutside)
});
} else {
corners.push({
rightPositions : computeMiteredCorner(position, cornerDirection, rightPos, leftIsOutside)
});
}
}
backward = Cartographic.Cartesian3.negate(forward, backward);
}
position = nextPosition;
}
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(position, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
var endPositions;
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED) {
endPositions = addEndCaps(calculatedPositions);
}
return {
positions : calculatedPositions,
corners : corners,
lefts : calculatedLefts,
normals : calculatedNormals,
endPositions : endPositions
};
};
exports.CorridorGeometryLibrary = CorridorGeometryLibrary;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,318 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Math-61ede240', './Cartographic-fe4be337', './BoundingSphere-775c5788', './Transforms-a1cf7267', './PolylineVolumeGeometryLibrary-5bb7662e', './PolylinePipeline-a9f32196'], function (exports, when, _Math, Cartographic, BoundingSphere, Transforms, PolylineVolumeGeometryLibrary, PolylinePipeline) { 'use strict';
/**
* @private
*/
var CorridorGeometryLibrary = {};
var scratch1 = new Cartographic.Cartesian3();
var scratch2 = new Cartographic.Cartesian3();
var scratch3 = new Cartographic.Cartesian3();
var scratch4 = new Cartographic.Cartesian3();
var scaleArray2 = [new Cartographic.Cartesian3(), new Cartographic.Cartesian3()];
var cartesian1 = new Cartographic.Cartesian3();
var cartesian2 = new Cartographic.Cartesian3();
var cartesian3 = new Cartographic.Cartesian3();
var cartesian4 = new Cartographic.Cartesian3();
var cartesian5 = new Cartographic.Cartesian3();
var cartesian6 = new Cartographic.Cartesian3();
var cartesian7 = new Cartographic.Cartesian3();
var cartesian8 = new Cartographic.Cartesian3();
var cartesian9 = new Cartographic.Cartesian3();
var cartesian10 = new Cartographic.Cartesian3();
var quaterion = new Transforms.Quaternion();
var rotMatrix = new BoundingSphere.Matrix3();
function computeRoundCorner(cornerPoint, startPoint, endPoint, cornerType, leftIsOutside) {
var angle = Cartographic.Cartesian3.angleBetween(Cartographic.Cartesian3.subtract(startPoint, cornerPoint, scratch1), Cartographic.Cartesian3.subtract(endPoint, cornerPoint, scratch2));
var granularity = (cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) ? 1 : Math.ceil(angle / _Math.CesiumMath.toRadians(5)) + 1;
var size = granularity * 3;
var array = new Array(size);
array[size - 3] = endPoint.x;
array[size - 2] = endPoint.y;
array[size - 1] = endPoint.z;
var m;
if (leftIsOutside) {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(Cartographic.Cartesian3.negate(cornerPoint, scratch1), angle / granularity, quaterion), rotMatrix);
} else {
m = BoundingSphere.Matrix3.fromQuaternion(Transforms.Quaternion.fromAxisAngle(cornerPoint, angle / granularity, quaterion), rotMatrix);
}
var index = 0;
startPoint = Cartographic.Cartesian3.clone(startPoint, scratch1);
for (var i = 0; i < granularity; i++) {
startPoint = BoundingSphere.Matrix3.multiplyByVector(m, startPoint, startPoint);
array[index++] = startPoint.x;
array[index++] = startPoint.y;
array[index++] = startPoint.z;
}
return array;
}
function addEndCaps(calculatedPositions) {
var cornerPoint = cartesian1;
var startPoint = cartesian2;
var endPoint = cartesian3;
var leftEdge = calculatedPositions[1];
startPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[1], leftEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(calculatedPositions[0], 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var firstEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
var length = calculatedPositions.length - 1;
var rightEdge = calculatedPositions[length - 1];
leftEdge = calculatedPositions[length];
startPoint = Cartographic.Cartesian3.fromArray(rightEdge, rightEdge.length - 3, startPoint);
endPoint = Cartographic.Cartesian3.fromArray(leftEdge, 0, endPoint);
cornerPoint = Cartographic.Cartesian3.midpoint(startPoint, endPoint, cornerPoint);
var lastEndCap = computeRoundCorner(cornerPoint, startPoint, endPoint, PolylineVolumeGeometryLibrary.CornerType.ROUNDED, false);
return [firstEndCap, lastEndCap];
}
function computeMiteredCorner(position, leftCornerDirection, lastPoint, leftIsOutside) {
var cornerPoint = scratch1;
if (leftIsOutside) {
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
} else {
leftCornerDirection = Cartographic.Cartesian3.negate(leftCornerDirection, leftCornerDirection);
cornerPoint = Cartographic.Cartesian3.add(position, leftCornerDirection, cornerPoint);
}
return [cornerPoint.x, cornerPoint.y, cornerPoint.z, lastPoint.x, lastPoint.y, lastPoint.z];
}
function addShiftedPositions(positions, left, scalar, calculatedPositions) {
var rightPositions = new Array(positions.length);
var leftPositions = new Array(positions.length);
var scaledLeft = Cartographic.Cartesian3.multiplyByScalar(left, scalar, scratch1);
var scaledRight = Cartographic.Cartesian3.negate(scaledLeft, scratch2);
var rightIndex = 0;
var leftIndex = positions.length - 1;
for (var i = 0; i < positions.length; i += 3) {
var pos = Cartographic.Cartesian3.fromArray(positions, i, scratch3);
var rightPos = Cartographic.Cartesian3.add(pos, scaledRight, scratch4);
rightPositions[rightIndex++] = rightPos.x;
rightPositions[rightIndex++] = rightPos.y;
rightPositions[rightIndex++] = rightPos.z;
var leftPos = Cartographic.Cartesian3.add(pos, scaledLeft, scratch4);
leftPositions[leftIndex--] = leftPos.z;
leftPositions[leftIndex--] = leftPos.y;
leftPositions[leftIndex--] = leftPos.x;
}
calculatedPositions.push(rightPositions, leftPositions);
return calculatedPositions;
}
/**
* @private
*/
CorridorGeometryLibrary.addAttribute = function(attribute, value, front, back) {
var x = value.x;
var y = value.y;
var z = value.z;
if (when.defined(front)) {
attribute[front] = x;
attribute[front + 1] = y;
attribute[front + 2] = z;
}
if (when.defined(back)) {
attribute[back] = z;
attribute[back - 1] = y;
attribute[back - 2] = x;
}
};
var scratchForwardProjection = new Cartographic.Cartesian3();
var scratchBackwardProjection = new Cartographic.Cartesian3();
/**
* @private
*/
CorridorGeometryLibrary.computePositions = function(params) {
var granularity = params.granularity;
var positions = params.positions;
var ellipsoid = params.ellipsoid;
var width = params.width / 2;
var cornerType = params.cornerType;
var saveAttributes = params.saveAttributes;
var normal = cartesian1;
var forward = cartesian2;
var backward = cartesian3;
var left = cartesian4;
var cornerDirection = cartesian5;
var startPoint = cartesian6;
var previousPos = cartesian7;
var rightPos = cartesian8;
var leftPos = cartesian9;
var center = cartesian10;
var calculatedPositions = [];
var calculatedLefts = (saveAttributes) ? [] : undefined;
var calculatedNormals = (saveAttributes) ? [] : undefined;
var position = positions[0]; //add first point
var nextPosition = positions[1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
previousPos = Cartographic.Cartesian3.clone(position, previousPos);
position = nextPosition;
backward = Cartographic.Cartesian3.negate(forward, backward);
var subdividedPositions;
var corners = [];
var i;
var length = positions.length;
for (i = 1; i < length - 1; i++) { // add middle points and corners
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
nextPosition = positions[i + 1];
forward = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.subtract(nextPosition, position, forward), forward);
cornerDirection = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.add(forward, backward, cornerDirection), cornerDirection);
var forwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(forward, normal), scratchForwardProjection);
Cartographic.Cartesian3.subtract(forward, forwardProjection, forwardProjection);
Cartographic.Cartesian3.normalize(forwardProjection, forwardProjection);
var backwardProjection = Cartographic.Cartesian3.multiplyByScalar(normal, Cartographic.Cartesian3.dot(backward, normal), scratchBackwardProjection);
Cartographic.Cartesian3.subtract(backward, backwardProjection, backwardProjection);
Cartographic.Cartesian3.normalize(backwardProjection, backwardProjection);
var doCorner = !_Math.CesiumMath.equalsEpsilon(Math.abs(Cartographic.Cartesian3.dot(forwardProjection, backwardProjection)), 1.0, _Math.CesiumMath.EPSILON7);
if (doCorner) {
cornerDirection = Cartographic.Cartesian3.cross(cornerDirection, normal, cornerDirection);
cornerDirection = Cartographic.Cartesian3.cross(normal, cornerDirection, cornerDirection);
cornerDirection = Cartographic.Cartesian3.normalize(cornerDirection, cornerDirection);
var scalar = width / Math.max(0.25, Cartographic.Cartesian3.magnitude(Cartographic.Cartesian3.cross(cornerDirection, backward, scratch1)));
var leftIsOutside = PolylineVolumeGeometryLibrary.PolylineVolumeGeometryLibrary.angleIsGreaterThanPi(forward, backward, position, ellipsoid);
cornerDirection = Cartographic.Cartesian3.multiplyByScalar(cornerDirection, scalar, cornerDirection);
if (leftIsOutside) {
rightPos = Cartographic.Cartesian3.add(position, cornerDirection, rightPos);
center = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, center), center);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(leftPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
leftPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width * 2, leftPos), leftPos);
previousPos = Cartographic.Cartesian3.add(rightPos, Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
leftPositions : computeRoundCorner(rightPos, startPoint, leftPos, cornerType, leftIsOutside)
});
} else {
corners.push({
leftPositions : computeMiteredCorner(position, Cartographic.Cartesian3.negate(cornerDirection, cornerDirection), leftPos, leftIsOutside)
});
}
} else {
leftPos = Cartographic.Cartesian3.add(position, cornerDirection, leftPos);
center = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, center), center), center);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(center, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
startPoint = Cartographic.Cartesian3.clone(rightPos, startPoint);
left = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, forward, left), left);
rightPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width * 2, rightPos), rightPos), rightPos);
previousPos = Cartographic.Cartesian3.add(leftPos, Cartographic.Cartesian3.negate(Cartographic.Cartesian3.multiplyByScalar(left, width, previousPos), previousPos), previousPos);
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED || cornerType === PolylineVolumeGeometryLibrary.CornerType.BEVELED) {
corners.push({
rightPositions : computeRoundCorner(leftPos, startPoint, rightPos, cornerType, leftIsOutside)
});
} else {
corners.push({
rightPositions : computeMiteredCorner(position, cornerDirection, rightPos, leftIsOutside)
});
}
}
backward = Cartographic.Cartesian3.negate(forward, backward);
}
position = nextPosition;
}
normal = ellipsoid.geodeticSurfaceNormal(position, normal);
scaleArray2[0] = Cartographic.Cartesian3.clone(previousPos, scaleArray2[0]);
scaleArray2[1] = Cartographic.Cartesian3.clone(position, scaleArray2[1]);
subdividedPositions = PolylinePipeline.PolylinePipeline.generateArc({
positions: scaleArray2,
granularity: granularity,
ellipsoid: ellipsoid
});
calculatedPositions = addShiftedPositions(subdividedPositions, left, width, calculatedPositions);
if (saveAttributes) {
calculatedLefts.push(left.x, left.y, left.z);
calculatedNormals.push(normal.x, normal.y, normal.z);
}
var endPositions;
if (cornerType === PolylineVolumeGeometryLibrary.CornerType.ROUNDED) {
endPositions = addEndCaps(calculatedPositions);
}
return {
positions : calculatedPositions,
corners : corners,
lefts : calculatedLefts,
normals : calculatedNormals,
endPositions : endPositions
};
};
exports.CorridorGeometryLibrary = CorridorGeometryLibrary;
});

View File

@ -0,0 +1 @@
define(["exports","./Transforms-20461479","./Matrix2-413c4048","./Matrix3-81054f0f","./ComponentDatatype-ab629b88","./CylinderGeometryLibrary-f49f33a8","./defaultValue-f6d5e6da","./GeometryAttribute-b8117bde","./GeometryAttributes-1e4ddcd2","./GeometryOffsetAttribute-2579b8d2","./IndexDatatype-d3db4e7d","./Math-2ce22ee9","./VertexFormat-fbdec922"],(function(t,e,n,a,o,r,i,s,u,m,l,c,p){"use strict";const y=new n.Cartesian2,d=new a.Cartesian3,f=new a.Cartesian3,b=new a.Cartesian3,A=new a.Cartesian3;function x(t){const e=(t=i.defaultValue(t,i.defaultValue.EMPTY_OBJECT)).length,n=t.topRadius,a=t.bottomRadius,o=i.defaultValue(t.vertexFormat,p.VertexFormat.DEFAULT),r=i.defaultValue(t.slices,128);this._length=e,this._topRadius=n,this._bottomRadius=a,this._vertexFormat=p.VertexFormat.clone(o),this._slices=r,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderGeometry"}x.packedLength=p.VertexFormat.packedLength+5,x.pack=function(t,e,n){return n=i.defaultValue(n,0),p.VertexFormat.pack(t._vertexFormat,e,n),n+=p.VertexFormat.packedLength,e[n++]=t._length,e[n++]=t._topRadius,e[n++]=t._bottomRadius,e[n++]=t._slices,e[n]=i.defaultValue(t._offsetAttribute,-1),e};const g=new p.VertexFormat,_={vertexFormat:g,length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,offsetAttribute:void 0};let h;x.unpack=function(t,e,n){e=i.defaultValue(e,0);const a=p.VertexFormat.unpack(t,e,g);e+=p.VertexFormat.packedLength;const o=t[e++],r=t[e++],s=t[e++],u=t[e++],m=t[e];return i.defined(n)?(n._vertexFormat=p.VertexFormat.clone(a,n._vertexFormat),n._length=o,n._topRadius=r,n._bottomRadius=s,n._slices=u,n._offsetAttribute=-1===m?void 0:m,n):(_.length=o,_.topRadius=r,_.bottomRadius=s,_.slices=u,_.offsetAttribute=-1===m?void 0:m,new x(_))},x.createGeometry=function(t){let p=t._length;const x=t._topRadius,g=t._bottomRadius,_=t._vertexFormat,h=t._slices;if(p<=0||x<0||g<0||0===x&&0===g)return;const F=h+h,v=h+F,C=F+F,w=r.CylinderGeometryLibrary.computePositions(p,x,g,h,!0),G=_.st?new Float32Array(2*C):void 0,V=_.normal?new Float32Array(3*C):void 0,D=_.tangent?new Float32Array(3*C):void 0,R=_.bitangent?new Float32Array(3*C):void 0;let T;const O=_.normal||_.tangent||_.bitangent;if(O){const t=_.tangent||_.bitangent;let e=0,n=0,o=0;const r=Math.atan2(g-x,p),i=d;i.z=Math.sin(r);const s=Math.cos(r);let u=b,m=f;for(T=0;T<h;T++){const r=T/h*c.CesiumMath.TWO_PI,l=s*Math.cos(r),p=s*Math.sin(r);O&&(i.x=l,i.y=p,t&&(u=a.Cartesian3.normalize(a.Cartesian3.cross(a.Cartesian3.UNIT_Z,i,u),u)),_.normal&&(V[e++]=i.x,V[e++]=i.y,V[e++]=i.z,V[e++]=i.x,V[e++]=i.y,V[e++]=i.z),_.tangent&&(D[n++]=u.x,D[n++]=u.y,D[n++]=u.z,D[n++]=u.x,D[n++]=u.y,D[n++]=u.z),_.bitangent&&(m=a.Cartesian3.normalize(a.Cartesian3.cross(i,u,m),m),R[o++]=m.x,R[o++]=m.y,R[o++]=m.z,R[o++]=m.x,R[o++]=m.y,R[o++]=m.z))}for(T=0;T<h;T++)_.normal&&(V[e++]=0,V[e++]=0,V[e++]=-1),_.tangent&&(D[n++]=1,D[n++]=0,D[n++]=0),_.bitangent&&(R[o++]=0,R[o++]=-1,R[o++]=0);for(T=0;T<h;T++)_.normal&&(V[e++]=0,V[e++]=0,V[e++]=1),_.tangent&&(D[n++]=1,D[n++]=0,D[n++]=0),_.bitangent&&(R[o++]=0,R[o++]=1,R[o++]=0)}const L=12*h-12,M=l.IndexDatatype.createTypedArray(C,L);let P=0,k=0;for(T=0;T<h-1;T++)M[P++]=k,M[P++]=k+2,M[P++]=k+3,M[P++]=k,M[P++]=k+3,M[P++]=k+1,k+=2;for(M[P++]=F-2,M[P++]=0,M[P++]=1,M[P++]=F-2,M[P++]=1,M[P++]=F-1,T=1;T<h-1;T++)M[P++]=F+T+1,M[P++]=F+T,M[P++]=F;for(T=1;T<h-1;T++)M[P++]=v,M[P++]=v+T,M[P++]=v+T+1;let z=0;if(_.st){const t=Math.max(x,g);for(T=0;T<C;T++){const e=a.Cartesian3.fromArray(w,3*T,A);G[z++]=(e.x+t)/(2*t),G[z++]=(e.y+t)/(2*t)}}const E=new u.GeometryAttributes;_.position&&(E.position=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:w})),_.normal&&(E.normal=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:V})),_.tangent&&(E.tangent=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:D})),_.bitangent&&(E.bitangent=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:R})),_.st&&(E.st=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:G})),y.x=.5*p,y.y=Math.max(g,x);const N=new e.BoundingSphere(a.Cartesian3.ZERO,n.Cartesian2.magnitude(y));if(i.defined(t._offsetAttribute)){p=w.length;const e=t._offsetAttribute===m.GeometryOffsetAttribute.NONE?0:1,n=new Uint8Array(p/3).fill(e);E.applyOffset=new s.GeometryAttribute({componentDatatype:o.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:n})}return new s.Geometry({attributes:E,indices:M,primitiveType:s.PrimitiveType.TRIANGLES,boundingSphere:N,offsetAttribute:t._offsetAttribute})},x.getUnitCylinder=function(){return i.defined(h)||(h=x.createGeometry(new x({topRadius:1,bottomRadius:1,length:1,vertexFormat:p.VertexFormat.POSITION_ONLY}))),h},t.CylinderGeometry=x}));

View File

@ -1 +0,0 @@
define(["exports","./arrayFill-4513d7ad","./BoundingSphere-561b54d0","./Cartesian2-47311507","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./CylinderGeometryLibrary-aa453214","./when-b60132fc","./Check-7b2a090c","./GeometryAttribute-3a42bbdc","./GeometryAttributes-252e9929","./GeometryOffsetAttribute-fbeb6f1a","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-39acab88","./VertexFormat-6446fca0"],(function(t,e,a,r,n,o,i,s,m,u,d,p,y,l,f,b){"use strict";var c=new r.Cartesian2,v=new n.Cartesian3,A=new n.Cartesian3,g=new n.Cartesian3,h=new n.Cartesian3;function x(t){var e=(t=s.defaultValue(t,s.defaultValue.EMPTY_OBJECT)).length,a=t.topRadius,r=t.bottomRadius,n=s.defaultValue(t.vertexFormat,b.VertexFormat.DEFAULT),o=s.defaultValue(t.slices,128);this._length=e,this._topRadius=a,this._bottomRadius=r,this._vertexFormat=b.VertexFormat.clone(n),this._slices=o,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderGeometry"}x.packedLength=b.VertexFormat.packedLength+5,x.pack=function(t,e,a){return a=s.defaultValue(a,0),b.VertexFormat.pack(t._vertexFormat,e,a),a+=b.VertexFormat.packedLength,e[a++]=t._length,e[a++]=t._topRadius,e[a++]=t._bottomRadius,e[a++]=t._slices,e[a]=s.defaultValue(t._offsetAttribute,-1),e};var _,C=new b.VertexFormat,F={vertexFormat:C,length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,offsetAttribute:void 0};x.unpack=function(t,e,a){e=s.defaultValue(e,0);var r=b.VertexFormat.unpack(t,e,C);e+=b.VertexFormat.packedLength;var n=t[e++],o=t[e++],i=t[e++],m=t[e++],u=t[e];return s.defined(a)?(a._vertexFormat=b.VertexFormat.clone(r,a._vertexFormat),a._length=n,a._topRadius=o,a._bottomRadius=i,a._slices=m,a._offsetAttribute=-1===u?void 0:u,a):(F.length=n,F.topRadius=o,F.bottomRadius=i,F.slices=m,F.offsetAttribute=-1===u?void 0:u,new x(F))},x.createGeometry=function(t){var m=t._length,b=t._topRadius,x=t._bottomRadius,_=t._vertexFormat,C=t._slices;if(!(m<=0||b<0||x<0||0===b&&0===x)){var F,w=C+C,G=C+w,D=w+w,R=i.CylinderGeometryLibrary.computePositions(m,b,x,C,!0),V=_.st?new Float32Array(2*D):void 0,T=_.normal?new Float32Array(3*D):void 0,O=_.tangent?new Float32Array(3*D):void 0,L=_.bitangent?new Float32Array(3*D):void 0,P=_.normal||_.tangent||_.bitangent;if(P){var k=_.tangent||_.bitangent,M=0,z=0,E=0,N=Math.atan2(x-b,m),I=v;I.z=Math.sin(N);var S=Math.cos(N),U=g,B=A;for(F=0;F<C;F++){var Y=F/C*l.CesiumMath.TWO_PI,Z=S*Math.cos(Y),J=S*Math.sin(Y);P&&(I.x=Z,I.y=J,k&&(U=n.Cartesian3.normalize(n.Cartesian3.cross(n.Cartesian3.UNIT_Z,I,U),U)),_.normal&&(T[M++]=I.x,T[M++]=I.y,T[M++]=I.z,T[M++]=I.x,T[M++]=I.y,T[M++]=I.z),_.tangent&&(O[z++]=U.x,O[z++]=U.y,O[z++]=U.z,O[z++]=U.x,O[z++]=U.y,O[z++]=U.z),_.bitangent&&(B=n.Cartesian3.normalize(n.Cartesian3.cross(I,U,B),B),L[E++]=B.x,L[E++]=B.y,L[E++]=B.z,L[E++]=B.x,L[E++]=B.y,L[E++]=B.z))}for(F=0;F<C;F++)_.normal&&(T[M++]=0,T[M++]=0,T[M++]=-1),_.tangent&&(O[z++]=1,O[z++]=0,O[z++]=0),_.bitangent&&(L[E++]=0,L[E++]=-1,L[E++]=0);for(F=0;F<C;F++)_.normal&&(T[M++]=0,T[M++]=0,T[M++]=1),_.tangent&&(O[z++]=1,O[z++]=0,O[z++]=0),_.bitangent&&(L[E++]=0,L[E++]=1,L[E++]=0)}var W=12*C-12,j=y.IndexDatatype.createTypedArray(D,W),q=0,H=0;for(F=0;F<C-1;F++)j[q++]=H,j[q++]=H+2,j[q++]=H+3,j[q++]=H,j[q++]=H+3,j[q++]=H+1,H+=2;for(j[q++]=w-2,j[q++]=0,j[q++]=1,j[q++]=w-2,j[q++]=1,j[q++]=w-1,F=1;F<C-1;F++)j[q++]=w+F+1,j[q++]=w+F,j[q++]=w;for(F=1;F<C-1;F++)j[q++]=G,j[q++]=G+F,j[q++]=G+F+1;var K=0;if(_.st){var Q=Math.max(b,x);for(F=0;F<D;F++){var X=n.Cartesian3.fromArray(R,3*F,h);V[K++]=(X.x+Q)/(2*Q),V[K++]=(X.y+Q)/(2*Q)}}var $=new d.GeometryAttributes;_.position&&($.position=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:R})),_.normal&&($.normal=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T})),_.tangent&&($.tangent=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:O})),_.bitangent&&($.bitangent=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),_.st&&($.st=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:V})),c.x=.5*m,c.y=Math.max(x,b);var tt=new a.BoundingSphere(n.Cartesian3.ZERO,r.Cartesian2.magnitude(c));if(s.defined(t._offsetAttribute)){m=R.length;var et=new Uint8Array(m/3),at=t._offsetAttribute===p.GeometryOffsetAttribute.NONE?0:1;e.arrayFill(et,at),$.applyOffset=new u.GeometryAttribute({componentDatatype:o.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:et})}return new u.Geometry({attributes:$,indices:j,primitiveType:f.PrimitiveType.TRIANGLES,boundingSphere:tt,offsetAttribute:t._offsetAttribute})}},x.getUnitCylinder=function(){return s.defined(_)||(_=x.createGeometry(new x({topRadius:1,bottomRadius:1,length:1,vertexFormat:b.VertexFormat.POSITION_ONLY}))),_},t.CylinderGeometry=x}));

View File

@ -1,445 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-ed9d707f', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402', './CylinderGeometryLibrary-8c0fda9f'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, VertexFormat, CylinderGeometryLibrary) { 'use strict';
var radiusScratch = new Cartesian2.Cartesian2();
var normalScratch = new Cartographic.Cartesian3();
var bitangentScratch = new Cartographic.Cartesian3();
var tangentScratch = new Cartographic.Cartesian3();
var positionScratch = new Cartographic.Cartesian3();
/**
* A description of a cylinder.
*
* @alias CylinderGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Number} options.length The length of the cylinder.
* @param {Number} options.topRadius The radius of the top of the cylinder.
* @param {Number} options.bottomRadius The radius of the bottom of the cylinder.
* @param {Number} [options.slices=128] The number of edges around the perimeter of the cylinder.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slices must be greater than or equal to 3.
*
* @see CylinderGeometry.createGeometry
*
* @example
* // create cylinder geometry
* var cylinder = new Cesium.CylinderGeometry({
* length: 200000,
* topRadius: 80000,
* bottomRadius: 200000,
* });
* var geometry = Cesium.CylinderGeometry.createGeometry(cylinder);
*/
function CylinderGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var length = options.length;
var topRadius = options.topRadius;
var bottomRadius = options.bottomRadius;
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
var slices = when.defaultValue(options.slices, 128);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(length)) {
throw new Check.DeveloperError('options.length must be defined.');
}
if (!when.defined(topRadius)) {
throw new Check.DeveloperError('options.topRadius must be defined.');
}
if (!when.defined(bottomRadius)) {
throw new Check.DeveloperError('options.bottomRadius must be defined.');
}
if (slices < 3) {
throw new Check.DeveloperError('options.slices must be greater than or equal to 3.');
}
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
this._length = length;
this._topRadius = topRadius;
this._bottomRadius = bottomRadius;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._slices = slices;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createCylinderGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
CylinderGeometry.packedLength = VertexFormat.VertexFormat.packedLength + 5;
/**
* Stores the provided instance into the provided array.
*
* @param {CylinderGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
CylinderGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
vertexFormat : scratchVertexFormat,
length : undefined,
topRadius : undefined,
bottomRadius : undefined,
slices : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {CylinderGeometry} [result] The object into which to store the result.
* @returns {CylinderGeometry} The modified result parameter or a new CylinderGeometry instance if one was not provided.
*/
CylinderGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var length = array[startingIndex++];
var topRadius = array[startingIndex++];
var bottomRadius = array[startingIndex++];
var slices = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.length = length;
scratchOptions.topRadius = topRadius;
scratchOptions.bottomRadius = bottomRadius;
scratchOptions.slices = slices;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new CylinderGeometry(scratchOptions);
}
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._length = length;
result._topRadius = topRadius;
result._bottomRadius = bottomRadius;
result._slices = slices;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a cylinder, including its vertices, indices, and a bounding sphere.
*
* @param {CylinderGeometry} cylinderGeometry A description of the cylinder.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
CylinderGeometry.createGeometry = function(cylinderGeometry) {
var length = cylinderGeometry._length;
var topRadius = cylinderGeometry._topRadius;
var bottomRadius = cylinderGeometry._bottomRadius;
var vertexFormat = cylinderGeometry._vertexFormat;
var slices = cylinderGeometry._slices;
if ((length <= 0) || (topRadius < 0) || (bottomRadius < 0) || ((topRadius === 0) && (bottomRadius === 0))) {
return;
}
var twoSlices = slices + slices;
var threeSlices = slices + twoSlices;
var numVertices = twoSlices + twoSlices;
var positions = CylinderGeometryLibrary.CylinderGeometryLibrary.computePositions(length, topRadius, bottomRadius, slices, true);
var st = (vertexFormat.st) ? new Float32Array(numVertices * 2) : undefined;
var normals = (vertexFormat.normal) ? new Float32Array(numVertices * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(numVertices * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(numVertices * 3) : undefined;
var i;
var computeNormal = (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent);
if (computeNormal) {
var computeTangent = (vertexFormat.tangent || vertexFormat.bitangent);
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var theta = Math.atan2(bottomRadius - topRadius, length);
var normal = normalScratch;
normal.z = Math.sin(theta);
var normalScale = Math.cos(theta);
var tangent = tangentScratch;
var bitangent = bitangentScratch;
for (i = 0; i < slices; i++) {
var angle = i / slices * _Math.CesiumMath.TWO_PI;
var x = normalScale * Math.cos(angle);
var y = normalScale * Math.sin(angle);
if (computeNormal) {
normal.x = x;
normal.y = y;
if (computeTangent) {
tangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, normal, tangent), tangent);
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, tangent, bitangent), bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = -1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = -1;
bitangents[bitangentIndex++] = 0;
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = 1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = 1;
bitangents[bitangentIndex++] = 0;
}
}
}
var numIndices = 12 * slices - 12;
var indices = IndexDatatype.IndexDatatype.createTypedArray(numVertices, numIndices);
var index = 0;
var j = 0;
for (i = 0; i < slices - 1; i++) {
indices[index++] = j;
indices[index++] = j + 2;
indices[index++] = j + 3;
indices[index++] = j;
indices[index++] = j + 3;
indices[index++] = j + 1;
j += 2;
}
indices[index++] = twoSlices - 2;
indices[index++] = 0;
indices[index++] = 1;
indices[index++] = twoSlices - 2;
indices[index++] = 1;
indices[index++] = twoSlices - 1;
for (i = 1; i < slices - 1; i++) {
indices[index++] = twoSlices + i + 1;
indices[index++] = twoSlices + i;
indices[index++] = twoSlices;
}
for (i = 1; i < slices - 1; i++) {
indices[index++] = threeSlices;
indices[index++] = threeSlices + i;
indices[index++] = threeSlices + i + 1;
}
var textureCoordIndex = 0;
if (vertexFormat.st) {
var rad = Math.max(topRadius, bottomRadius);
for (i = 0; i < numVertices; i++) {
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, positionScratch);
st[textureCoordIndex++] = (position.x + rad) / (2.0 * rad);
st[textureCoordIndex++] = (position.y + rad) / (2.0 * rad);
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
radiusScratch.x = length * 0.5;
radiusScratch.y = Math.max(bottomRadius, topRadius);
var boundingSphere = new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, Cartesian2.Cartesian2.magnitude(radiusScratch));
if (when.defined(cylinderGeometry._offsetAttribute)) {
length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : boundingSphere,
offsetAttribute : cylinderGeometry._offsetAttribute
});
};
var unitCylinderGeometry;
/**
* Returns the geometric representation of a unit cylinder, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
CylinderGeometry.getUnitCylinder = function() {
if (!when.defined(unitCylinderGeometry)) {
unitCylinderGeometry = CylinderGeometry.createGeometry(new CylinderGeometry({
topRadius : 1.0,
bottomRadius : 1.0,
length : 1.0,
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitCylinderGeometry;
};
exports.CylinderGeometry = CylinderGeometry;
});

View File

@ -1 +0,0 @@
define(["exports","./arrayFill-4513d7ad","./buildModuleUrl-4e1b81e7","./Cartesian2-47311507","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./CylinderGeometryLibrary-aa453214","./when-b60132fc","./Check-7b2a090c","./GeometryAttribute-3a88ba31","./GeometryAttributes-252e9929","./GeometryOffsetAttribute-fbeb6f1a","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-a54dc62f","./VertexFormat-6446fca0"],(function(t,e,a,r,n,o,i,s,u,m,d,l,p,y,f,b){"use strict";var c=new r.Cartesian2,v=new n.Cartesian3,A=new n.Cartesian3,g=new n.Cartesian3,h=new n.Cartesian3;function x(t){var e=(t=s.defaultValue(t,s.defaultValue.EMPTY_OBJECT)).length,a=t.topRadius,r=t.bottomRadius,n=s.defaultValue(t.vertexFormat,b.VertexFormat.DEFAULT),o=s.defaultValue(t.slices,128);this._length=e,this._topRadius=a,this._bottomRadius=r,this._vertexFormat=b.VertexFormat.clone(n),this._slices=o,this._offsetAttribute=t.offsetAttribute,this._workerName="createCylinderGeometry"}x.packedLength=b.VertexFormat.packedLength+5,x.pack=function(t,e,a){return a=s.defaultValue(a,0),b.VertexFormat.pack(t._vertexFormat,e,a),a+=b.VertexFormat.packedLength,e[a++]=t._length,e[a++]=t._topRadius,e[a++]=t._bottomRadius,e[a++]=t._slices,e[a]=s.defaultValue(t._offsetAttribute,-1),e};var _,C=new b.VertexFormat,F={vertexFormat:C,length:void 0,topRadius:void 0,bottomRadius:void 0,slices:void 0,offsetAttribute:void 0};x.unpack=function(t,e,a){e=s.defaultValue(e,0);var r=b.VertexFormat.unpack(t,e,C);e+=b.VertexFormat.packedLength;var n=t[e++],o=t[e++],i=t[e++],u=t[e++],m=t[e];return s.defined(a)?(a._vertexFormat=b.VertexFormat.clone(r,a._vertexFormat),a._length=n,a._topRadius=o,a._bottomRadius=i,a._slices=u,a._offsetAttribute=-1===m?void 0:m,a):(F.length=n,F.topRadius=o,F.bottomRadius=i,F.slices=u,F.offsetAttribute=-1===m?void 0:m,new x(F))},x.createGeometry=function(t){var u=t._length,b=t._topRadius,x=t._bottomRadius,_=t._vertexFormat,C=t._slices;if(!(u<=0||b<0||x<0||0===b&&0===x)){var F,w=C+C,G=C+w,D=w+w,R=i.CylinderGeometryLibrary.computePositions(u,b,x,C,!0),V=_.st?new Float32Array(2*D):void 0,T=_.normal?new Float32Array(3*D):void 0,O=_.tangent?new Float32Array(3*D):void 0,L=_.bitangent?new Float32Array(3*D):void 0,P=_.normal||_.tangent||_.bitangent;if(P){var M=_.tangent||_.bitangent,k=0,z=0,E=0,N=Math.atan2(x-b,u),I=v;I.z=Math.sin(N);var U=Math.cos(N),S=g,B=A;for(F=0;F<C;F++){var Y=F/C*y.CesiumMath.TWO_PI,Z=U*Math.cos(Y),J=U*Math.sin(Y);P&&(I.x=Z,I.y=J,M&&(S=n.Cartesian3.normalize(n.Cartesian3.cross(n.Cartesian3.UNIT_Z,I,S),S)),_.normal&&(T[k++]=I.x,T[k++]=I.y,T[k++]=I.z,T[k++]=I.x,T[k++]=I.y,T[k++]=I.z),_.tangent&&(O[z++]=S.x,O[z++]=S.y,O[z++]=S.z,O[z++]=S.x,O[z++]=S.y,O[z++]=S.z),_.bitangent&&(B=n.Cartesian3.normalize(n.Cartesian3.cross(I,S,B),B),L[E++]=B.x,L[E++]=B.y,L[E++]=B.z,L[E++]=B.x,L[E++]=B.y,L[E++]=B.z))}for(F=0;F<C;F++)_.normal&&(T[k++]=0,T[k++]=0,T[k++]=-1),_.tangent&&(O[z++]=1,O[z++]=0,O[z++]=0),_.bitangent&&(L[E++]=0,L[E++]=-1,L[E++]=0);for(F=0;F<C;F++)_.normal&&(T[k++]=0,T[k++]=0,T[k++]=1),_.tangent&&(O[z++]=1,O[z++]=0,O[z++]=0),_.bitangent&&(L[E++]=0,L[E++]=1,L[E++]=0)}var W=12*C-12,j=p.IndexDatatype.createTypedArray(D,W),q=0,H=0;for(F=0;F<C-1;F++)j[q++]=H,j[q++]=H+2,j[q++]=H+3,j[q++]=H,j[q++]=H+3,j[q++]=H+1,H+=2;for(j[q++]=w-2,j[q++]=0,j[q++]=1,j[q++]=w-2,j[q++]=1,j[q++]=w-1,F=1;F<C-1;F++)j[q++]=w+F+1,j[q++]=w+F,j[q++]=w;for(F=1;F<C-1;F++)j[q++]=G,j[q++]=G+F,j[q++]=G+F+1;var K=0;if(_.st){var Q=Math.max(b,x);for(F=0;F<D;F++){var X=n.Cartesian3.fromArray(R,3*F,h);V[K++]=(X.x+Q)/(2*Q),V[K++]=(X.y+Q)/(2*Q)}}var $=new d.GeometryAttributes;_.position&&($.position=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:R})),_.normal&&($.normal=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:T})),_.tangent&&($.tangent=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:O})),_.bitangent&&($.bitangent=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:3,values:L})),_.st&&($.st=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.FLOAT,componentsPerAttribute:2,values:V})),c.x=.5*u,c.y=Math.max(x,b);var tt=new a.BoundingSphere(n.Cartesian3.ZERO,r.Cartesian2.magnitude(c));if(s.defined(t._offsetAttribute)){u=R.length;var et=new Uint8Array(u/3),at=t._offsetAttribute===l.GeometryOffsetAttribute.NONE?0:1;e.arrayFill(et,at),$.applyOffset=new m.GeometryAttribute({componentDatatype:o.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:et})}return new m.Geometry({attributes:$,indices:j,primitiveType:f.PrimitiveType.TRIANGLES,boundingSphere:tt,offsetAttribute:t._offsetAttribute})}},x.getUnitCylinder=function(){return s.defined(_)||(_=x.createGeometry(new x({topRadius:1,bottomRadius:1,length:1,vertexFormat:b.VertexFormat.POSITION_ONLY}))),_},t.CylinderGeometry=x}));

View File

@ -1,445 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-91704ebb', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './GeometryOffsetAttribute-ca302482', './VertexFormat-fe4db402', './CylinderGeometryLibrary-8c0fda9f'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, GeometryOffsetAttribute, VertexFormat, CylinderGeometryLibrary) { 'use strict';
var radiusScratch = new Cartesian2.Cartesian2();
var normalScratch = new Cartographic.Cartesian3();
var bitangentScratch = new Cartographic.Cartesian3();
var tangentScratch = new Cartographic.Cartesian3();
var positionScratch = new Cartographic.Cartesian3();
/**
* A description of a cylinder.
*
* @alias CylinderGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Number} options.length The length of the cylinder.
* @param {Number} options.topRadius The radius of the top of the cylinder.
* @param {Number} options.bottomRadius The radius of the bottom of the cylinder.
* @param {Number} [options.slices=128] The number of edges around the perimeter of the cylinder.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slices must be greater than or equal to 3.
*
* @see CylinderGeometry.createGeometry
*
* @example
* // create cylinder geometry
* var cylinder = new Cesium.CylinderGeometry({
* length: 200000,
* topRadius: 80000,
* bottomRadius: 200000,
* });
* var geometry = Cesium.CylinderGeometry.createGeometry(cylinder);
*/
function CylinderGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var length = options.length;
var topRadius = options.topRadius;
var bottomRadius = options.bottomRadius;
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
var slices = when.defaultValue(options.slices, 128);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(length)) {
throw new Check.DeveloperError('options.length must be defined.');
}
if (!when.defined(topRadius)) {
throw new Check.DeveloperError('options.topRadius must be defined.');
}
if (!when.defined(bottomRadius)) {
throw new Check.DeveloperError('options.bottomRadius must be defined.');
}
if (slices < 3) {
throw new Check.DeveloperError('options.slices must be greater than or equal to 3.');
}
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
this._length = length;
this._topRadius = topRadius;
this._bottomRadius = bottomRadius;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._slices = slices;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createCylinderGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
CylinderGeometry.packedLength = VertexFormat.VertexFormat.packedLength + 5;
/**
* Stores the provided instance into the provided array.
*
* @param {CylinderGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
CylinderGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
vertexFormat : scratchVertexFormat,
length : undefined,
topRadius : undefined,
bottomRadius : undefined,
slices : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {CylinderGeometry} [result] The object into which to store the result.
* @returns {CylinderGeometry} The modified result parameter or a new CylinderGeometry instance if one was not provided.
*/
CylinderGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var length = array[startingIndex++];
var topRadius = array[startingIndex++];
var bottomRadius = array[startingIndex++];
var slices = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.length = length;
scratchOptions.topRadius = topRadius;
scratchOptions.bottomRadius = bottomRadius;
scratchOptions.slices = slices;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new CylinderGeometry(scratchOptions);
}
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._length = length;
result._topRadius = topRadius;
result._bottomRadius = bottomRadius;
result._slices = slices;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a cylinder, including its vertices, indices, and a bounding sphere.
*
* @param {CylinderGeometry} cylinderGeometry A description of the cylinder.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
CylinderGeometry.createGeometry = function(cylinderGeometry) {
var length = cylinderGeometry._length;
var topRadius = cylinderGeometry._topRadius;
var bottomRadius = cylinderGeometry._bottomRadius;
var vertexFormat = cylinderGeometry._vertexFormat;
var slices = cylinderGeometry._slices;
if ((length <= 0) || (topRadius < 0) || (bottomRadius < 0) || ((topRadius === 0) && (bottomRadius === 0))) {
return;
}
var twoSlices = slices + slices;
var threeSlices = slices + twoSlices;
var numVertices = twoSlices + twoSlices;
var positions = CylinderGeometryLibrary.CylinderGeometryLibrary.computePositions(length, topRadius, bottomRadius, slices, true);
var st = (vertexFormat.st) ? new Float32Array(numVertices * 2) : undefined;
var normals = (vertexFormat.normal) ? new Float32Array(numVertices * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(numVertices * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(numVertices * 3) : undefined;
var i;
var computeNormal = (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent);
if (computeNormal) {
var computeTangent = (vertexFormat.tangent || vertexFormat.bitangent);
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var theta = Math.atan2(bottomRadius - topRadius, length);
var normal = normalScratch;
normal.z = Math.sin(theta);
var normalScale = Math.cos(theta);
var tangent = tangentScratch;
var bitangent = bitangentScratch;
for (i = 0; i < slices; i++) {
var angle = i / slices * _Math.CesiumMath.TWO_PI;
var x = normalScale * Math.cos(angle);
var y = normalScale * Math.sin(angle);
if (computeNormal) {
normal.x = x;
normal.y = y;
if (computeTangent) {
tangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, normal, tangent), tangent);
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, tangent, bitangent), bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = -1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = -1;
bitangents[bitangentIndex++] = 0;
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = 1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = 1;
bitangents[bitangentIndex++] = 0;
}
}
}
var numIndices = 12 * slices - 12;
var indices = IndexDatatype.IndexDatatype.createTypedArray(numVertices, numIndices);
var index = 0;
var j = 0;
for (i = 0; i < slices - 1; i++) {
indices[index++] = j;
indices[index++] = j + 2;
indices[index++] = j + 3;
indices[index++] = j;
indices[index++] = j + 3;
indices[index++] = j + 1;
j += 2;
}
indices[index++] = twoSlices - 2;
indices[index++] = 0;
indices[index++] = 1;
indices[index++] = twoSlices - 2;
indices[index++] = 1;
indices[index++] = twoSlices - 1;
for (i = 1; i < slices - 1; i++) {
indices[index++] = twoSlices + i + 1;
indices[index++] = twoSlices + i;
indices[index++] = twoSlices;
}
for (i = 1; i < slices - 1; i++) {
indices[index++] = threeSlices;
indices[index++] = threeSlices + i;
indices[index++] = threeSlices + i + 1;
}
var textureCoordIndex = 0;
if (vertexFormat.st) {
var rad = Math.max(topRadius, bottomRadius);
for (i = 0; i < numVertices; i++) {
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, positionScratch);
st[textureCoordIndex++] = (position.x + rad) / (2.0 * rad);
st[textureCoordIndex++] = (position.y + rad) / (2.0 * rad);
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
radiusScratch.x = length * 0.5;
radiusScratch.y = Math.max(bottomRadius, topRadius);
var boundingSphere = new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, Cartesian2.Cartesian2.magnitude(radiusScratch));
if (when.defined(cylinderGeometry._offsetAttribute)) {
length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
GeometryOffsetAttribute.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : boundingSphere,
offsetAttribute : cylinderGeometry._offsetAttribute
});
};
var unitCylinderGeometry;
/**
* Returns the geometric representation of a unit cylinder, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
CylinderGeometry.getUnitCylinder = function() {
if (!when.defined(unitCylinderGeometry)) {
unitCylinderGeometry = CylinderGeometry.createGeometry(new CylinderGeometry({
topRadius : 1.0,
bottomRadius : 1.0,
length : 1.0,
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitCylinderGeometry;
};
exports.CylinderGeometry = CylinderGeometry;
});

View File

@ -1,445 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-773da12d', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402', './CylinderGeometryLibrary-8c0fda9f'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, VertexFormat, CylinderGeometryLibrary) { 'use strict';
var radiusScratch = new Cartesian2.Cartesian2();
var normalScratch = new Cartographic.Cartesian3();
var bitangentScratch = new Cartographic.Cartesian3();
var tangentScratch = new Cartographic.Cartesian3();
var positionScratch = new Cartographic.Cartesian3();
/**
* A description of a cylinder.
*
* @alias CylinderGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Number} options.length The length of the cylinder.
* @param {Number} options.topRadius The radius of the top of the cylinder.
* @param {Number} options.bottomRadius The radius of the bottom of the cylinder.
* @param {Number} [options.slices=128] The number of edges around the perimeter of the cylinder.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slices must be greater than or equal to 3.
*
* @see CylinderGeometry.createGeometry
*
* @example
* // create cylinder geometry
* var cylinder = new Cesium.CylinderGeometry({
* length: 200000,
* topRadius: 80000,
* bottomRadius: 200000,
* });
* var geometry = Cesium.CylinderGeometry.createGeometry(cylinder);
*/
function CylinderGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var length = options.length;
var topRadius = options.topRadius;
var bottomRadius = options.bottomRadius;
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
var slices = when.defaultValue(options.slices, 128);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(length)) {
throw new Check.DeveloperError('options.length must be defined.');
}
if (!when.defined(topRadius)) {
throw new Check.DeveloperError('options.topRadius must be defined.');
}
if (!when.defined(bottomRadius)) {
throw new Check.DeveloperError('options.bottomRadius must be defined.');
}
if (slices < 3) {
throw new Check.DeveloperError('options.slices must be greater than or equal to 3.');
}
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
this._length = length;
this._topRadius = topRadius;
this._bottomRadius = bottomRadius;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._slices = slices;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createCylinderGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
CylinderGeometry.packedLength = VertexFormat.VertexFormat.packedLength + 5;
/**
* Stores the provided instance into the provided array.
*
* @param {CylinderGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
CylinderGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
vertexFormat : scratchVertexFormat,
length : undefined,
topRadius : undefined,
bottomRadius : undefined,
slices : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {CylinderGeometry} [result] The object into which to store the result.
* @returns {CylinderGeometry} The modified result parameter or a new CylinderGeometry instance if one was not provided.
*/
CylinderGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var length = array[startingIndex++];
var topRadius = array[startingIndex++];
var bottomRadius = array[startingIndex++];
var slices = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.length = length;
scratchOptions.topRadius = topRadius;
scratchOptions.bottomRadius = bottomRadius;
scratchOptions.slices = slices;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new CylinderGeometry(scratchOptions);
}
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._length = length;
result._topRadius = topRadius;
result._bottomRadius = bottomRadius;
result._slices = slices;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a cylinder, including its vertices, indices, and a bounding sphere.
*
* @param {CylinderGeometry} cylinderGeometry A description of the cylinder.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
CylinderGeometry.createGeometry = function(cylinderGeometry) {
var length = cylinderGeometry._length;
var topRadius = cylinderGeometry._topRadius;
var bottomRadius = cylinderGeometry._bottomRadius;
var vertexFormat = cylinderGeometry._vertexFormat;
var slices = cylinderGeometry._slices;
if ((length <= 0) || (topRadius < 0) || (bottomRadius < 0) || ((topRadius === 0) && (bottomRadius === 0))) {
return;
}
var twoSlices = slices + slices;
var threeSlices = slices + twoSlices;
var numVertices = twoSlices + twoSlices;
var positions = CylinderGeometryLibrary.CylinderGeometryLibrary.computePositions(length, topRadius, bottomRadius, slices, true);
var st = (vertexFormat.st) ? new Float32Array(numVertices * 2) : undefined;
var normals = (vertexFormat.normal) ? new Float32Array(numVertices * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(numVertices * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(numVertices * 3) : undefined;
var i;
var computeNormal = (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent);
if (computeNormal) {
var computeTangent = (vertexFormat.tangent || vertexFormat.bitangent);
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var theta = Math.atan2(bottomRadius - topRadius, length);
var normal = normalScratch;
normal.z = Math.sin(theta);
var normalScale = Math.cos(theta);
var tangent = tangentScratch;
var bitangent = bitangentScratch;
for (i = 0; i < slices; i++) {
var angle = i / slices * _Math.CesiumMath.TWO_PI;
var x = normalScale * Math.cos(angle);
var y = normalScale * Math.sin(angle);
if (computeNormal) {
normal.x = x;
normal.y = y;
if (computeTangent) {
tangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, normal, tangent), tangent);
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, tangent, bitangent), bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = -1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = -1;
bitangents[bitangentIndex++] = 0;
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = 1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = 1;
bitangents[bitangentIndex++] = 0;
}
}
}
var numIndices = 12 * slices - 12;
var indices = IndexDatatype.IndexDatatype.createTypedArray(numVertices, numIndices);
var index = 0;
var j = 0;
for (i = 0; i < slices - 1; i++) {
indices[index++] = j;
indices[index++] = j + 2;
indices[index++] = j + 3;
indices[index++] = j;
indices[index++] = j + 3;
indices[index++] = j + 1;
j += 2;
}
indices[index++] = twoSlices - 2;
indices[index++] = 0;
indices[index++] = 1;
indices[index++] = twoSlices - 2;
indices[index++] = 1;
indices[index++] = twoSlices - 1;
for (i = 1; i < slices - 1; i++) {
indices[index++] = twoSlices + i + 1;
indices[index++] = twoSlices + i;
indices[index++] = twoSlices;
}
for (i = 1; i < slices - 1; i++) {
indices[index++] = threeSlices;
indices[index++] = threeSlices + i;
indices[index++] = threeSlices + i + 1;
}
var textureCoordIndex = 0;
if (vertexFormat.st) {
var rad = Math.max(topRadius, bottomRadius);
for (i = 0; i < numVertices; i++) {
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, positionScratch);
st[textureCoordIndex++] = (position.x + rad) / (2.0 * rad);
st[textureCoordIndex++] = (position.y + rad) / (2.0 * rad);
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
radiusScratch.x = length * 0.5;
radiusScratch.y = Math.max(bottomRadius, topRadius);
var boundingSphere = new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, Cartesian2.Cartesian2.magnitude(radiusScratch));
if (when.defined(cylinderGeometry._offsetAttribute)) {
length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : boundingSphere,
offsetAttribute : cylinderGeometry._offsetAttribute
});
};
var unitCylinderGeometry;
/**
* Returns the geometric representation of a unit cylinder, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
CylinderGeometry.getUnitCylinder = function() {
if (!when.defined(unitCylinderGeometry)) {
unitCylinderGeometry = CylinderGeometry.createGeometry(new CylinderGeometry({
topRadius : 1.0,
bottomRadius : 1.0,
length : 1.0,
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitCylinderGeometry;
};
exports.CylinderGeometry = CylinderGeometry;
});

View File

@ -1,445 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-1e248a71', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402', './CylinderGeometryLibrary-8c0fda9f'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, VertexFormat, CylinderGeometryLibrary) { 'use strict';
var radiusScratch = new Cartesian2.Cartesian2();
var normalScratch = new Cartographic.Cartesian3();
var bitangentScratch = new Cartographic.Cartesian3();
var tangentScratch = new Cartographic.Cartesian3();
var positionScratch = new Cartographic.Cartesian3();
/**
* A description of a cylinder.
*
* @alias CylinderGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Number} options.length The length of the cylinder.
* @param {Number} options.topRadius The radius of the top of the cylinder.
* @param {Number} options.bottomRadius The radius of the bottom of the cylinder.
* @param {Number} [options.slices=128] The number of edges around the perimeter of the cylinder.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slices must be greater than or equal to 3.
*
* @see CylinderGeometry.createGeometry
*
* @example
* // create cylinder geometry
* var cylinder = new Cesium.CylinderGeometry({
* length: 200000,
* topRadius: 80000,
* bottomRadius: 200000,
* });
* var geometry = Cesium.CylinderGeometry.createGeometry(cylinder);
*/
function CylinderGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var length = options.length;
var topRadius = options.topRadius;
var bottomRadius = options.bottomRadius;
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
var slices = when.defaultValue(options.slices, 128);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(length)) {
throw new Check.DeveloperError('options.length must be defined.');
}
if (!when.defined(topRadius)) {
throw new Check.DeveloperError('options.topRadius must be defined.');
}
if (!when.defined(bottomRadius)) {
throw new Check.DeveloperError('options.bottomRadius must be defined.');
}
if (slices < 3) {
throw new Check.DeveloperError('options.slices must be greater than or equal to 3.');
}
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
this._length = length;
this._topRadius = topRadius;
this._bottomRadius = bottomRadius;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._slices = slices;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createCylinderGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
CylinderGeometry.packedLength = VertexFormat.VertexFormat.packedLength + 5;
/**
* Stores the provided instance into the provided array.
*
* @param {CylinderGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
CylinderGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._length;
array[startingIndex++] = value._topRadius;
array[startingIndex++] = value._bottomRadius;
array[startingIndex++] = value._slices;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
vertexFormat : scratchVertexFormat,
length : undefined,
topRadius : undefined,
bottomRadius : undefined,
slices : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {CylinderGeometry} [result] The object into which to store the result.
* @returns {CylinderGeometry} The modified result parameter or a new CylinderGeometry instance if one was not provided.
*/
CylinderGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var length = array[startingIndex++];
var topRadius = array[startingIndex++];
var bottomRadius = array[startingIndex++];
var slices = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.length = length;
scratchOptions.topRadius = topRadius;
scratchOptions.bottomRadius = bottomRadius;
scratchOptions.slices = slices;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new CylinderGeometry(scratchOptions);
}
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._length = length;
result._topRadius = topRadius;
result._bottomRadius = bottomRadius;
result._slices = slices;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of a cylinder, including its vertices, indices, and a bounding sphere.
*
* @param {CylinderGeometry} cylinderGeometry A description of the cylinder.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
CylinderGeometry.createGeometry = function(cylinderGeometry) {
var length = cylinderGeometry._length;
var topRadius = cylinderGeometry._topRadius;
var bottomRadius = cylinderGeometry._bottomRadius;
var vertexFormat = cylinderGeometry._vertexFormat;
var slices = cylinderGeometry._slices;
if ((length <= 0) || (topRadius < 0) || (bottomRadius < 0) || ((topRadius === 0) && (bottomRadius === 0))) {
return;
}
var twoSlices = slices + slices;
var threeSlices = slices + twoSlices;
var numVertices = twoSlices + twoSlices;
var positions = CylinderGeometryLibrary.CylinderGeometryLibrary.computePositions(length, topRadius, bottomRadius, slices, true);
var st = (vertexFormat.st) ? new Float32Array(numVertices * 2) : undefined;
var normals = (vertexFormat.normal) ? new Float32Array(numVertices * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(numVertices * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(numVertices * 3) : undefined;
var i;
var computeNormal = (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent);
if (computeNormal) {
var computeTangent = (vertexFormat.tangent || vertexFormat.bitangent);
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var theta = Math.atan2(bottomRadius - topRadius, length);
var normal = normalScratch;
normal.z = Math.sin(theta);
var normalScale = Math.cos(theta);
var tangent = tangentScratch;
var bitangent = bitangentScratch;
for (i = 0; i < slices; i++) {
var angle = i / slices * _Math.CesiumMath.TWO_PI;
var x = normalScale * Math.cos(angle);
var y = normalScale * Math.sin(angle);
if (computeNormal) {
normal.x = x;
normal.y = y;
if (computeTangent) {
tangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, normal, tangent), tangent);
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangent = Cartographic.Cartesian3.normalize(Cartographic.Cartesian3.cross(normal, tangent, bitangent), bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = -1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = -1;
bitangents[bitangentIndex++] = 0;
}
}
for (i = 0; i < slices; i++) {
if (vertexFormat.normal) {
normals[normalIndex++] = 0;
normals[normalIndex++] = 0;
normals[normalIndex++] = 1;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = 1;
tangents[tangentIndex++] = 0;
tangents[tangentIndex++] = 0;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = 0;
bitangents[bitangentIndex++] = 1;
bitangents[bitangentIndex++] = 0;
}
}
}
var numIndices = 12 * slices - 12;
var indices = IndexDatatype.IndexDatatype.createTypedArray(numVertices, numIndices);
var index = 0;
var j = 0;
for (i = 0; i < slices - 1; i++) {
indices[index++] = j;
indices[index++] = j + 2;
indices[index++] = j + 3;
indices[index++] = j;
indices[index++] = j + 3;
indices[index++] = j + 1;
j += 2;
}
indices[index++] = twoSlices - 2;
indices[index++] = 0;
indices[index++] = 1;
indices[index++] = twoSlices - 2;
indices[index++] = 1;
indices[index++] = twoSlices - 1;
for (i = 1; i < slices - 1; i++) {
indices[index++] = twoSlices + i + 1;
indices[index++] = twoSlices + i;
indices[index++] = twoSlices;
}
for (i = 1; i < slices - 1; i++) {
indices[index++] = threeSlices;
indices[index++] = threeSlices + i;
indices[index++] = threeSlices + i + 1;
}
var textureCoordIndex = 0;
if (vertexFormat.st) {
var rad = Math.max(topRadius, bottomRadius);
for (i = 0; i < numVertices; i++) {
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, positionScratch);
st[textureCoordIndex++] = (position.x + rad) / (2.0 * rad);
st[textureCoordIndex++] = (position.y + rad) / (2.0 * rad);
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype: ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
radiusScratch.x = length * 0.5;
radiusScratch.y = Math.max(bottomRadius, topRadius);
var boundingSphere = new BoundingSphere.BoundingSphere(Cartographic.Cartesian3.ZERO, Cartesian2.Cartesian2.magnitude(radiusScratch));
if (when.defined(cylinderGeometry._offsetAttribute)) {
length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = cylinderGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : boundingSphere,
offsetAttribute : cylinderGeometry._offsetAttribute
});
};
var unitCylinderGeometry;
/**
* Returns the geometric representation of a unit cylinder, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
CylinderGeometry.getUnitCylinder = function() {
if (!when.defined(unitCylinderGeometry)) {
unitCylinderGeometry = CylinderGeometry.createGeometry(new CylinderGeometry({
topRadius : 1.0,
bottomRadius : 1.0,
length : 1.0,
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
}));
}
return unitCylinderGeometry;
};
exports.CylinderGeometry = CylinderGeometry;
});

View File

@ -1,78 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Math-61ede240'], function (exports, _Math) { 'use strict';
/**
* @private
*/
var CylinderGeometryLibrary = {};
/**
* @private
*/
CylinderGeometryLibrary.computePositions = function(length, topRadius, bottomRadius, slices, fill){
var topZ = length * 0.5;
var bottomZ = -topZ;
var twoSlice = slices + slices;
var size = (fill) ? 2 * twoSlice : twoSlice;
var positions = new Float64Array(size*3);
var i;
var index = 0;
var tbIndex = 0;
var bottomOffset = (fill) ? twoSlice*3 : 0;
var topOffset = (fill) ? (twoSlice + slices)*3 : slices*3;
for (i = 0; i < slices; i++) {
var angle = i / slices * _Math.CesiumMath.TWO_PI;
var x = Math.cos(angle);
var y = Math.sin(angle);
var bottomX = x * bottomRadius;
var bottomY = y * bottomRadius;
var topX = x * topRadius;
var topY = y * topRadius;
positions[tbIndex + bottomOffset] = bottomX;
positions[tbIndex + bottomOffset + 1] = bottomY;
positions[tbIndex + bottomOffset + 2] = bottomZ;
positions[tbIndex + topOffset] = topX;
positions[tbIndex + topOffset + 1] = topY;
positions[tbIndex + topOffset + 2] = topZ;
tbIndex += 3;
if (fill) {
positions[index++] = bottomX;
positions[index++] = bottomY;
positions[index++] = bottomZ;
positions[index++] = topX;
positions[index++] = topY;
positions[index++] = topZ;
}
}
return positions;
};
exports.CylinderGeometryLibrary = CylinderGeometryLibrary;
});

View File

@ -1 +0,0 @@
define(["exports","./Math-119be1a3"],(function(r,t){"use strict";var e={computePositions:function(r,e,a,i,n){var o,s=.5*r,u=-s,c=i+i,f=new Float64Array(3*(n?2*c:c)),h=0,y=0,M=n?3*c:0,m=n?3*(c+i):3*i;for(o=0;o<i;o++){var v=o/i*t.CesiumMath.TWO_PI,b=Math.cos(v),d=Math.sin(v),l=b*a,p=d*a,C=b*e,P=d*e;f[y+M]=l,f[y+M+1]=p,f[y+M+2]=u,f[y+m]=C,f[y+m+1]=P,f[y+m+2]=s,y+=3,n&&(f[h++]=l,f[h++]=p,f[h++]=u,f[h++]=C,f[h++]=P,f[h++]=s)}return f}};r.CylinderGeometryLibrary=e}));

View File

@ -0,0 +1 @@
define(["exports","./Math-2ce22ee9"],(function(t,n){"use strict";const o={computePositions:function(t,o,e,r,s){const i=.5*t,c=-i,a=r+r,u=new Float64Array(3*(s?2*a:a));let f,h=0,y=0;const M=s?3*a:0,l=s?3*(a+r):3*r;for(f=0;f<r;f++){const t=f/r*n.CesiumMath.TWO_PI,a=Math.cos(t),m=Math.sin(t),d=a*e,p=m*e,C=a*o,P=m*o;u[y+M]=d,u[y+M+1]=p,u[y+M+2]=c,u[y+l]=C,u[y+l+1]=P,u[y+l+2]=i,y+=3,s&&(u[h++]=d,u[h++]=p,u[h++]=c,u[h++]=C,u[h++]=P,u[h++]=i)}return u}};var e=o;t.CylinderGeometryLibrary=e}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,285 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Math-61ede240', './Cartographic-fe4be337', './BoundingSphere-775c5788', './Transforms-b2e71640'], function (exports, _Math, Cartographic, BoundingSphere, Transforms) { 'use strict';
var EllipseGeometryLibrary = {};
var rotAxis = new Cartographic.Cartesian3();
var tempVec = new Cartographic.Cartesian3();
var unitQuat = new Transforms.Quaternion();
var rotMtx = new BoundingSphere.Matrix3();
function pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, result) {
var azimuth = theta + rotation;
Cartographic.Cartesian3.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);
Cartographic.Cartesian3.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);
Cartographic.Cartesian3.add(rotAxis, tempVec, rotAxis);
var cosThetaSquared = Math.cos(theta);
cosThetaSquared = cosThetaSquared * cosThetaSquared;
var sinThetaSquared = Math.sin(theta);
sinThetaSquared = sinThetaSquared * sinThetaSquared;
var radius = ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);
var angle = radius / mag;
// Create the quaternion to rotate the position vector to the boundary of the ellipse.
Transforms.Quaternion.fromAxisAngle(rotAxis, angle, unitQuat);
BoundingSphere.Matrix3.fromQuaternion(unitQuat, rotMtx);
BoundingSphere.Matrix3.multiplyByVector(rotMtx, unitPos, result);
Cartographic.Cartesian3.normalize(result, result);
Cartographic.Cartesian3.multiplyByScalar(result, mag, result);
return result;
}
var scratchCartesian1 = new Cartographic.Cartesian3();
var scratchCartesian2 = new Cartographic.Cartesian3();
var scratchCartesian3 = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
/**
* Returns the positions raised to the given heights
* @private
*/
EllipseGeometryLibrary.raisePositionsToHeight = function(positions, options, extrude) {
var ellipsoid = options.ellipsoid;
var height = options.height;
var extrudedHeight = options.extrudedHeight;
var size = (extrude) ? positions.length / 3 * 2 : positions.length / 3;
var finalPositions = new Float64Array(size * 3);
var length = positions.length;
var bottomOffset = (extrude) ? length : 0;
for (var i = 0; i < length; i += 3) {
var i1 = i + 1;
var i2 = i + 2;
var position = Cartographic.Cartesian3.fromArray(positions, i, scratchCartesian1);
ellipsoid.scaleToGeodeticSurface(position, position);
var extrudedPosition = Cartographic.Cartesian3.clone(position, scratchCartesian2);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(normal, height, scratchCartesian3);
Cartographic.Cartesian3.add(position, scaledNormal, position);
if (extrude) {
Cartographic.Cartesian3.multiplyByScalar(normal, extrudedHeight, scaledNormal);
Cartographic.Cartesian3.add(extrudedPosition, scaledNormal, extrudedPosition);
finalPositions[i + bottomOffset] = extrudedPosition.x;
finalPositions[i1 + bottomOffset] = extrudedPosition.y;
finalPositions[i2 + bottomOffset] = extrudedPosition.z;
}
finalPositions[i] = position.x;
finalPositions[i1] = position.y;
finalPositions[i2] = position.z;
}
return finalPositions;
};
var unitPosScratch = new Cartographic.Cartesian3();
var eastVecScratch = new Cartographic.Cartesian3();
var northVecScratch = new Cartographic.Cartesian3();
/**
* Returns an array of positions that make up the ellipse.
* @private
*/
EllipseGeometryLibrary.computeEllipsePositions = function(options, addFillPositions, addEdgePositions) {
var semiMinorAxis = options.semiMinorAxis;
var semiMajorAxis = options.semiMajorAxis;
var rotation = options.rotation;
var center = options.center;
// Computing the arc-length of the ellipse is too expensive to be practical. Estimating it using the
// arc length of the sphere is too inaccurate and creates sharp edges when either the semi-major or
// semi-minor axis is much bigger than the other. Instead, scale the angle delta to make
// the distance along the ellipse boundary more closely match the granularity.
var granularity = options.granularity * 8.0;
var aSqr = semiMinorAxis * semiMinorAxis;
var bSqr = semiMajorAxis * semiMajorAxis;
var ab = semiMajorAxis * semiMinorAxis;
var mag = Cartographic.Cartesian3.magnitude(center);
var unitPos = Cartographic.Cartesian3.normalize(center, unitPosScratch);
var eastVec = Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, center, eastVecScratch);
eastVec = Cartographic.Cartesian3.normalize(eastVec, eastVec);
var northVec = Cartographic.Cartesian3.cross(unitPos, eastVec, northVecScratch);
// The number of points in the first quadrant
var numPts = 1 + Math.ceil(_Math.CesiumMath.PI_OVER_TWO / granularity);
var deltaTheta = _Math.CesiumMath.PI_OVER_TWO / (numPts - 1);
var theta = _Math.CesiumMath.PI_OVER_TWO - numPts * deltaTheta;
if (theta < 0.0) {
numPts -= Math.ceil(Math.abs(theta) / deltaTheta);
}
// If the number of points were three, the ellipse
// would be tessellated like below:
//
// *---*
// / | \ | \
// *---*---*---*
// / | \ | \ | \ | \
// / .*---*---*---*. \
// * ` | \ | \ | \ | `*
// \`.*---*---*---*.`/
// \ | \ | \ | \ | /
// *---*---*---*
// \ | \ | /
// *---*
// The first and last column have one position and fan to connect to the adjacent column.
// Each other vertical column contains an even number of positions.
var size = 2 * (numPts * (numPts + 2));
var positions = (addFillPositions) ? new Array(size * 3) : undefined;
var positionIndex = 0;
var position = scratchCartesian1;
var reflectedPosition = scratchCartesian2;
var outerPositionsLength = (numPts * 4) * 3;
var outerRightIndex = outerPositionsLength - 1;
var outerLeftIndex = 0;
var outerPositions = (addEdgePositions) ? new Array(outerPositionsLength) : undefined;
var i;
var j;
var numInterior;
var t;
var interiorPosition;
// Compute points in the 'eastern' half of the ellipse
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
}
theta = _Math.CesiumMath.PI_OVER_TWO - deltaTheta;
for (i = 1; i < numPts + 1; ++i) {
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(Math.PI - theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * i + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
theta = _Math.CesiumMath.PI_OVER_TWO - (i + 1) * deltaTheta;
}
// Compute points in the 'western' half of the ellipse
for (i = numPts; i > 1; --i) {
theta = _Math.CesiumMath.PI_OVER_TWO - (i - 1) * deltaTheta;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(theta + Math.PI, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * (i - 1) + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
}
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
var r = {};
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
r.positions = positions;
r.numPts = numPts;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
r.outerPositions = outerPositions;
}
return r;
};
exports.EllipseGeometryLibrary = EllipseGeometryLibrary;
});

View File

@ -1 +0,0 @@
define(["exports","./Cartographic-3309dd0d","./Math-119be1a3","./BoundingSphere-561b54d0","./Transforms-cb0006b0"],(function(a,r,e,i,t){"use strict";var n={},s=new r.Cartesian3,o=new r.Cartesian3,l=new t.Quaternion,C=new i.Matrix3;function y(a,e,n,y,u,h,m,c,x,M){var d=a+e;r.Cartesian3.multiplyByScalar(y,Math.cos(d),s),r.Cartesian3.multiplyByScalar(n,Math.sin(d),o),r.Cartesian3.add(s,o,s);var z=Math.cos(a);z*=z;var f=Math.sin(a);f*=f;var _=h/Math.sqrt(m*z+u*f)/c;return t.Quaternion.fromAxisAngle(s,_,l),i.Matrix3.fromQuaternion(l,C),i.Matrix3.multiplyByVector(C,x,M),r.Cartesian3.normalize(M,M),r.Cartesian3.multiplyByScalar(M,c,M),M}var u=new r.Cartesian3,h=new r.Cartesian3,m=new r.Cartesian3,c=new r.Cartesian3;n.raisePositionsToHeight=function(a,e,i){for(var t=e.ellipsoid,n=e.height,s=e.extrudedHeight,o=i?a.length/3*2:a.length/3,l=new Float64Array(3*o),C=a.length,y=i?C:0,x=0;x<C;x+=3){var M=x+1,d=x+2,z=r.Cartesian3.fromArray(a,x,u);t.scaleToGeodeticSurface(z,z);var f=r.Cartesian3.clone(z,h),_=t.geodeticSurfaceNormal(z,c),p=r.Cartesian3.multiplyByScalar(_,n,m);r.Cartesian3.add(z,p,z),i&&(r.Cartesian3.multiplyByScalar(_,s,p),r.Cartesian3.add(f,p,f),l[x+y]=f.x,l[M+y]=f.y,l[d+y]=f.z),l[x]=z.x,l[M]=z.y,l[d]=z.z}return l};var x=new r.Cartesian3,M=new r.Cartesian3,d=new r.Cartesian3;n.computeEllipsePositions=function(a,i,t){var n=a.semiMinorAxis,s=a.semiMajorAxis,o=a.rotation,l=a.center,C=8*a.granularity,c=n*n,z=s*s,f=s*n,_=r.Cartesian3.magnitude(l),p=r.Cartesian3.normalize(l,x),v=r.Cartesian3.cross(r.Cartesian3.UNIT_Z,l,M);v=r.Cartesian3.normalize(v,v);var O=r.Cartesian3.cross(p,v,d),w=1+Math.ceil(e.CesiumMath.PI_OVER_TWO/C),P=e.CesiumMath.PI_OVER_TWO/(w-1),g=e.CesiumMath.PI_OVER_TWO-w*P;g<0&&(w-=Math.ceil(Math.abs(g)/P));var T,I,E,V,A,R=i?new Array(3*(w*(w+2)*2)):void 0,S=0,W=u,B=h,b=4*w*3,Q=b-1,G=0,H=t?new Array(b):void 0;for(W=y(g=e.CesiumMath.PI_OVER_TWO,o,O,v,c,f,z,_,p,W),i&&(R[S++]=W.x,R[S++]=W.y,R[S++]=W.z),t&&(H[Q--]=W.z,H[Q--]=W.y,H[Q--]=W.x),g=e.CesiumMath.PI_OVER_TWO-P,T=1;T<w+1;++T){if(W=y(g,o,O,v,c,f,z,_,p,W),B=y(Math.PI-g,o,O,v,c,f,z,_,p,B),i){for(R[S++]=W.x,R[S++]=W.y,R[S++]=W.z,E=2*T+2,I=1;I<E-1;++I)V=I/(E-1),A=r.Cartesian3.lerp(W,B,V,m),R[S++]=A.x,R[S++]=A.y,R[S++]=A.z;R[S++]=B.x,R[S++]=B.y,R[S++]=B.z}t&&(H[Q--]=W.z,H[Q--]=W.y,H[Q--]=W.x,H[G++]=B.x,H[G++]=B.y,H[G++]=B.z),g=e.CesiumMath.PI_OVER_TWO-(T+1)*P}for(T=w;T>1;--T){if(W=y(-(g=e.CesiumMath.PI_OVER_TWO-(T-1)*P),o,O,v,c,f,z,_,p,W),B=y(g+Math.PI,o,O,v,c,f,z,_,p,B),i){for(R[S++]=W.x,R[S++]=W.y,R[S++]=W.z,E=2*(T-1)+2,I=1;I<E-1;++I)V=I/(E-1),A=r.Cartesian3.lerp(W,B,V,m),R[S++]=A.x,R[S++]=A.y,R[S++]=A.z;R[S++]=B.x,R[S++]=B.y,R[S++]=B.z}t&&(H[Q--]=W.z,H[Q--]=W.y,H[Q--]=W.x,H[G++]=B.x,H[G++]=B.y,H[G++]=B.z)}W=y(-(g=e.CesiumMath.PI_OVER_TWO),o,O,v,c,f,z,_,p,W);var N={};return i&&(R[S++]=W.x,R[S++]=W.y,R[S++]=W.z,N.positions=R,N.numPts=w),t&&(H[Q--]=W.z,H[Q--]=W.y,H[Q--]=W.x,N.outerPositions=H),N},a.EllipseGeometryLibrary=n}));

View File

@ -0,0 +1 @@
define(["exports","./Matrix3-81054f0f","./Math-2ce22ee9","./Transforms-20461479"],(function(t,a,e,n){"use strict";const i={},r=new a.Cartesian3,s=new a.Cartesian3,o=new n.Quaternion,l=new a.Matrix3;function c(t,e,i,c,C,y,u,m,h,x){const M=t+e;a.Cartesian3.multiplyByScalar(c,Math.cos(M),r),a.Cartesian3.multiplyByScalar(i,Math.sin(M),s),a.Cartesian3.add(r,s,r);let z=Math.cos(t);z*=z;let f=Math.sin(t);f*=f;const _=y/Math.sqrt(u*z+C*f)/m;return n.Quaternion.fromAxisAngle(r,_,o),a.Matrix3.fromQuaternion(o,l),a.Matrix3.multiplyByVector(l,h,x),a.Cartesian3.normalize(x,x),a.Cartesian3.multiplyByScalar(x,m,x),x}const C=new a.Cartesian3,y=new a.Cartesian3,u=new a.Cartesian3,m=new a.Cartesian3;i.raisePositionsToHeight=function(t,e,n){const i=e.ellipsoid,r=e.height,s=e.extrudedHeight,o=n?t.length/3*2:t.length/3,l=new Float64Array(3*o),c=t.length,h=n?c:0;for(let e=0;e<c;e+=3){const o=e+1,c=e+2,x=a.Cartesian3.fromArray(t,e,C);i.scaleToGeodeticSurface(x,x);const M=a.Cartesian3.clone(x,y),z=i.geodeticSurfaceNormal(x,m),f=a.Cartesian3.multiplyByScalar(z,r,u);a.Cartesian3.add(x,f,x),n&&(a.Cartesian3.multiplyByScalar(z,s,f),a.Cartesian3.add(M,f,M),l[e+h]=M.x,l[o+h]=M.y,l[c+h]=M.z),l[e]=x.x,l[o]=x.y,l[c]=x.z}return l};const h=new a.Cartesian3,x=new a.Cartesian3,M=new a.Cartesian3;i.computeEllipsePositions=function(t,n,i){const r=t.semiMinorAxis,s=t.semiMajorAxis,o=t.rotation,l=t.center,m=8*t.granularity,z=r*r,f=s*s,_=s*r,O=a.Cartesian3.magnitude(l),d=a.Cartesian3.normalize(l,h);let p=a.Cartesian3.cross(a.Cartesian3.UNIT_Z,l,x);p=a.Cartesian3.normalize(p,p);const w=a.Cartesian3.cross(d,p,M);let P=1+Math.ceil(e.CesiumMath.PI_OVER_TWO/m);const T=e.CesiumMath.PI_OVER_TWO/(P-1);let I=e.CesiumMath.PI_OVER_TWO-P*T;I<0&&(P-=Math.ceil(Math.abs(I)/T));const g=n?new Array(3*(P*(P+2)*2)):void 0;let E=0,V=C,A=y;const R=4*P*3;let W=R-1,S=0;const B=i?new Array(R):void 0;let v,Q,b,G,H;for(I=e.CesiumMath.PI_OVER_TWO,V=c(I,o,w,p,z,_,f,O,d,V),n&&(g[E++]=V.x,g[E++]=V.y,g[E++]=V.z),i&&(B[W--]=V.z,B[W--]=V.y,B[W--]=V.x),I=e.CesiumMath.PI_OVER_TWO-T,v=1;v<P+1;++v){if(V=c(I,o,w,p,z,_,f,O,d,V),A=c(Math.PI-I,o,w,p,z,_,f,O,d,A),n){for(g[E++]=V.x,g[E++]=V.y,g[E++]=V.z,b=2*v+2,Q=1;Q<b-1;++Q)G=Q/(b-1),H=a.Cartesian3.lerp(V,A,G,u),g[E++]=H.x,g[E++]=H.y,g[E++]=H.z;g[E++]=A.x,g[E++]=A.y,g[E++]=A.z}i&&(B[W--]=V.z,B[W--]=V.y,B[W--]=V.x,B[S++]=A.x,B[S++]=A.y,B[S++]=A.z),I=e.CesiumMath.PI_OVER_TWO-(v+1)*T}for(v=P;v>1;--v){if(I=e.CesiumMath.PI_OVER_TWO-(v-1)*T,V=c(-I,o,w,p,z,_,f,O,d,V),A=c(I+Math.PI,o,w,p,z,_,f,O,d,A),n){for(g[E++]=V.x,g[E++]=V.y,g[E++]=V.z,b=2*(v-1)+2,Q=1;Q<b-1;++Q)G=Q/(b-1),H=a.Cartesian3.lerp(V,A,G,u),g[E++]=H.x,g[E++]=H.y,g[E++]=H.z;g[E++]=A.x,g[E++]=A.y,g[E++]=A.z}i&&(B[W--]=V.z,B[W--]=V.y,B[W--]=V.x,B[S++]=A.x,B[S++]=A.y,B[S++]=A.z)}I=e.CesiumMath.PI_OVER_TWO,V=c(-I,o,w,p,z,_,f,O,d,V);const N={};return n&&(g[E++]=V.x,g[E++]=V.y,g[E++]=V.z,N.positions=g,N.numPts=P),i&&(B[W--]=V.z,B[W--]=V.y,B[W--]=V.x,N.outerPositions=B),N};var z=i;t.EllipseGeometryLibrary=z}));

View File

@ -1,285 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Math-61ede240', './Cartographic-fe4be337', './BoundingSphere-775c5788', './Transforms-a1cf7267'], function (exports, _Math, Cartographic, BoundingSphere, Transforms) { 'use strict';
var EllipseGeometryLibrary = {};
var rotAxis = new Cartographic.Cartesian3();
var tempVec = new Cartographic.Cartesian3();
var unitQuat = new Transforms.Quaternion();
var rotMtx = new BoundingSphere.Matrix3();
function pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, result) {
var azimuth = theta + rotation;
Cartographic.Cartesian3.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);
Cartographic.Cartesian3.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);
Cartographic.Cartesian3.add(rotAxis, tempVec, rotAxis);
var cosThetaSquared = Math.cos(theta);
cosThetaSquared = cosThetaSquared * cosThetaSquared;
var sinThetaSquared = Math.sin(theta);
sinThetaSquared = sinThetaSquared * sinThetaSquared;
var radius = ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);
var angle = radius / mag;
// Create the quaternion to rotate the position vector to the boundary of the ellipse.
Transforms.Quaternion.fromAxisAngle(rotAxis, angle, unitQuat);
BoundingSphere.Matrix3.fromQuaternion(unitQuat, rotMtx);
BoundingSphere.Matrix3.multiplyByVector(rotMtx, unitPos, result);
Cartographic.Cartesian3.normalize(result, result);
Cartographic.Cartesian3.multiplyByScalar(result, mag, result);
return result;
}
var scratchCartesian1 = new Cartographic.Cartesian3();
var scratchCartesian2 = new Cartographic.Cartesian3();
var scratchCartesian3 = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
/**
* Returns the positions raised to the given heights
* @private
*/
EllipseGeometryLibrary.raisePositionsToHeight = function(positions, options, extrude) {
var ellipsoid = options.ellipsoid;
var height = options.height;
var extrudedHeight = options.extrudedHeight;
var size = (extrude) ? positions.length / 3 * 2 : positions.length / 3;
var finalPositions = new Float64Array(size * 3);
var length = positions.length;
var bottomOffset = (extrude) ? length : 0;
for (var i = 0; i < length; i += 3) {
var i1 = i + 1;
var i2 = i + 2;
var position = Cartographic.Cartesian3.fromArray(positions, i, scratchCartesian1);
ellipsoid.scaleToGeodeticSurface(position, position);
var extrudedPosition = Cartographic.Cartesian3.clone(position, scratchCartesian2);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(normal, height, scratchCartesian3);
Cartographic.Cartesian3.add(position, scaledNormal, position);
if (extrude) {
Cartographic.Cartesian3.multiplyByScalar(normal, extrudedHeight, scaledNormal);
Cartographic.Cartesian3.add(extrudedPosition, scaledNormal, extrudedPosition);
finalPositions[i + bottomOffset] = extrudedPosition.x;
finalPositions[i1 + bottomOffset] = extrudedPosition.y;
finalPositions[i2 + bottomOffset] = extrudedPosition.z;
}
finalPositions[i] = position.x;
finalPositions[i1] = position.y;
finalPositions[i2] = position.z;
}
return finalPositions;
};
var unitPosScratch = new Cartographic.Cartesian3();
var eastVecScratch = new Cartographic.Cartesian3();
var northVecScratch = new Cartographic.Cartesian3();
/**
* Returns an array of positions that make up the ellipse.
* @private
*/
EllipseGeometryLibrary.computeEllipsePositions = function(options, addFillPositions, addEdgePositions) {
var semiMinorAxis = options.semiMinorAxis;
var semiMajorAxis = options.semiMajorAxis;
var rotation = options.rotation;
var center = options.center;
// Computing the arc-length of the ellipse is too expensive to be practical. Estimating it using the
// arc length of the sphere is too inaccurate and creates sharp edges when either the semi-major or
// semi-minor axis is much bigger than the other. Instead, scale the angle delta to make
// the distance along the ellipse boundary more closely match the granularity.
var granularity = options.granularity * 8.0;
var aSqr = semiMinorAxis * semiMinorAxis;
var bSqr = semiMajorAxis * semiMajorAxis;
var ab = semiMajorAxis * semiMinorAxis;
var mag = Cartographic.Cartesian3.magnitude(center);
var unitPos = Cartographic.Cartesian3.normalize(center, unitPosScratch);
var eastVec = Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, center, eastVecScratch);
eastVec = Cartographic.Cartesian3.normalize(eastVec, eastVec);
var northVec = Cartographic.Cartesian3.cross(unitPos, eastVec, northVecScratch);
// The number of points in the first quadrant
var numPts = 1 + Math.ceil(_Math.CesiumMath.PI_OVER_TWO / granularity);
var deltaTheta = _Math.CesiumMath.PI_OVER_TWO / (numPts - 1);
var theta = _Math.CesiumMath.PI_OVER_TWO - numPts * deltaTheta;
if (theta < 0.0) {
numPts -= Math.ceil(Math.abs(theta) / deltaTheta);
}
// If the number of points were three, the ellipse
// would be tessellated like below:
//
// *---*
// / | \ | \
// *---*---*---*
// / | \ | \ | \ | \
// / .*---*---*---*. \
// * ` | \ | \ | \ | `*
// \`.*---*---*---*.`/
// \ | \ | \ | \ | /
// *---*---*---*
// \ | \ | /
// *---*
// The first and last column have one position and fan to connect to the adjacent column.
// Each other vertical column contains an even number of positions.
var size = 2 * (numPts * (numPts + 2));
var positions = (addFillPositions) ? new Array(size * 3) : undefined;
var positionIndex = 0;
var position = scratchCartesian1;
var reflectedPosition = scratchCartesian2;
var outerPositionsLength = (numPts * 4) * 3;
var outerRightIndex = outerPositionsLength - 1;
var outerLeftIndex = 0;
var outerPositions = (addEdgePositions) ? new Array(outerPositionsLength) : undefined;
var i;
var j;
var numInterior;
var t;
var interiorPosition;
// Compute points in the 'eastern' half of the ellipse
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
}
theta = _Math.CesiumMath.PI_OVER_TWO - deltaTheta;
for (i = 1; i < numPts + 1; ++i) {
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(Math.PI - theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * i + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
theta = _Math.CesiumMath.PI_OVER_TWO - (i + 1) * deltaTheta;
}
// Compute points in the 'western' half of the ellipse
for (i = numPts; i > 1; --i) {
theta = _Math.CesiumMath.PI_OVER_TWO - (i - 1) * deltaTheta;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(theta + Math.PI, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * (i - 1) + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
}
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
var r = {};
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
r.positions = positions;
r.numPts = numPts;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
r.outerPositions = outerPositions;
}
return r;
};
exports.EllipseGeometryLibrary = EllipseGeometryLibrary;
});

View File

@ -1 +0,0 @@
define(["exports","./Cartographic-3309dd0d","./Math-119be1a3","./PrimitiveType-a54dc62f","./GeometryAttribute-3a88ba31"],(function(a,r,e,t,i){"use strict";var n={},s=new r.Cartesian3,o=new r.Cartesian3,l=new i.Quaternion,y=new t.Matrix3;function C(a,e,n,C,u,m,c,h,x,M){var d=a+e;r.Cartesian3.multiplyByScalar(C,Math.cos(d),s),r.Cartesian3.multiplyByScalar(n,Math.sin(d),o),r.Cartesian3.add(s,o,s);var z=Math.cos(a);z*=z;var f=Math.sin(a);f*=f;var v=m/Math.sqrt(c*z+u*f)/h;return i.Quaternion.fromAxisAngle(s,v,l),t.Matrix3.fromQuaternion(l,y),t.Matrix3.multiplyByVector(y,x,M),r.Cartesian3.normalize(M,M),r.Cartesian3.multiplyByScalar(M,h,M),M}var u=new r.Cartesian3,m=new r.Cartesian3,c=new r.Cartesian3,h=new r.Cartesian3;n.raisePositionsToHeight=function(a,e,t){for(var i=e.ellipsoid,n=e.height,s=e.extrudedHeight,o=t?a.length/3*2:a.length/3,l=new Float64Array(3*o),y=a.length,C=t?y:0,x=0;x<y;x+=3){var M=x+1,d=x+2,z=r.Cartesian3.fromArray(a,x,u);i.scaleToGeodeticSurface(z,z);var f=r.Cartesian3.clone(z,m),v=i.geodeticSurfaceNormal(z,h),_=r.Cartesian3.multiplyByScalar(v,n,c);r.Cartesian3.add(z,_,z),t&&(r.Cartesian3.multiplyByScalar(v,s,_),r.Cartesian3.add(f,_,f),l[x+C]=f.x,l[M+C]=f.y,l[d+C]=f.z),l[x]=z.x,l[M]=z.y,l[d]=z.z}return l};var x=new r.Cartesian3,M=new r.Cartesian3,d=new r.Cartesian3;n.computeEllipsePositions=function(a,t,i){var n=a.semiMinorAxis,s=a.semiMajorAxis,o=a.rotation,l=a.center,y=8*a.granularity,h=n*n,z=s*s,f=s*n,v=r.Cartesian3.magnitude(l),_=r.Cartesian3.normalize(l,x),p=r.Cartesian3.cross(r.Cartesian3.UNIT_Z,l,M);p=r.Cartesian3.normalize(p,p);var O=r.Cartesian3.cross(_,p,d),P=1+Math.ceil(e.CesiumMath.PI_OVER_TWO/y),w=e.CesiumMath.PI_OVER_TWO/(P-1),T=e.CesiumMath.PI_OVER_TWO-P*w;T<0&&(P-=Math.ceil(Math.abs(T)/w));var g,I,E,A,V,R=t?new Array(3*(P*(P+2)*2)):void 0,W=0,S=u,B=m,b=4*P*3,G=b-1,Q=0,H=i?new Array(b):void 0;for(S=C(T=e.CesiumMath.PI_OVER_TWO,o,O,p,h,f,z,v,_,S),t&&(R[W++]=S.x,R[W++]=S.y,R[W++]=S.z),i&&(H[G--]=S.z,H[G--]=S.y,H[G--]=S.x),T=e.CesiumMath.PI_OVER_TWO-w,g=1;g<P+1;++g){if(S=C(T,o,O,p,h,f,z,v,_,S),B=C(Math.PI-T,o,O,p,h,f,z,v,_,B),t){for(R[W++]=S.x,R[W++]=S.y,R[W++]=S.z,E=2*g+2,I=1;I<E-1;++I)A=I/(E-1),V=r.Cartesian3.lerp(S,B,A,c),R[W++]=V.x,R[W++]=V.y,R[W++]=V.z;R[W++]=B.x,R[W++]=B.y,R[W++]=B.z}i&&(H[G--]=S.z,H[G--]=S.y,H[G--]=S.x,H[Q++]=B.x,H[Q++]=B.y,H[Q++]=B.z),T=e.CesiumMath.PI_OVER_TWO-(g+1)*w}for(g=P;g>1;--g){if(S=C(-(T=e.CesiumMath.PI_OVER_TWO-(g-1)*w),o,O,p,h,f,z,v,_,S),B=C(T+Math.PI,o,O,p,h,f,z,v,_,B),t){for(R[W++]=S.x,R[W++]=S.y,R[W++]=S.z,E=2*(g-1)+2,I=1;I<E-1;++I)A=I/(E-1),V=r.Cartesian3.lerp(S,B,A,c),R[W++]=V.x,R[W++]=V.y,R[W++]=V.z;R[W++]=B.x,R[W++]=B.y,R[W++]=B.z}i&&(H[G--]=S.z,H[G--]=S.y,H[G--]=S.x,H[Q++]=B.x,H[Q++]=B.y,H[Q++]=B.z)}S=C(-(T=e.CesiumMath.PI_OVER_TWO),o,O,p,h,f,z,v,_,S);var N={};return t&&(R[W++]=S.x,R[W++]=S.y,R[W++]=S.z,N.positions=R,N.numPts=P),i&&(H[G--]=S.z,H[G--]=S.y,H[G--]=S.x,N.outerPositions=H),N},a.EllipseGeometryLibrary=n}));

View File

@ -1,285 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Math-61ede240', './Cartographic-f2a06374', './BoundingSphere-d018a565', './Transforms-cd52cbaf'], function (exports, _Math, Cartographic, BoundingSphere, Transforms) { 'use strict';
var EllipseGeometryLibrary = {};
var rotAxis = new Cartographic.Cartesian3();
var tempVec = new Cartographic.Cartesian3();
var unitQuat = new Transforms.Quaternion();
var rotMtx = new BoundingSphere.Matrix3();
function pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, result) {
var azimuth = theta + rotation;
Cartographic.Cartesian3.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);
Cartographic.Cartesian3.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);
Cartographic.Cartesian3.add(rotAxis, tempVec, rotAxis);
var cosThetaSquared = Math.cos(theta);
cosThetaSquared = cosThetaSquared * cosThetaSquared;
var sinThetaSquared = Math.sin(theta);
sinThetaSquared = sinThetaSquared * sinThetaSquared;
var radius = ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);
var angle = radius / mag;
// Create the quaternion to rotate the position vector to the boundary of the ellipse.
Transforms.Quaternion.fromAxisAngle(rotAxis, angle, unitQuat);
BoundingSphere.Matrix3.fromQuaternion(unitQuat, rotMtx);
BoundingSphere.Matrix3.multiplyByVector(rotMtx, unitPos, result);
Cartographic.Cartesian3.normalize(result, result);
Cartographic.Cartesian3.multiplyByScalar(result, mag, result);
return result;
}
var scratchCartesian1 = new Cartographic.Cartesian3();
var scratchCartesian2 = new Cartographic.Cartesian3();
var scratchCartesian3 = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
/**
* Returns the positions raised to the given heights
* @private
*/
EllipseGeometryLibrary.raisePositionsToHeight = function(positions, options, extrude) {
var ellipsoid = options.ellipsoid;
var height = options.height;
var extrudedHeight = options.extrudedHeight;
var size = (extrude) ? positions.length / 3 * 2 : positions.length / 3;
var finalPositions = new Float64Array(size * 3);
var length = positions.length;
var bottomOffset = (extrude) ? length : 0;
for (var i = 0; i < length; i += 3) {
var i1 = i + 1;
var i2 = i + 2;
var position = Cartographic.Cartesian3.fromArray(positions, i, scratchCartesian1);
ellipsoid.scaleToGeodeticSurface(position, position);
var extrudedPosition = Cartographic.Cartesian3.clone(position, scratchCartesian2);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(normal, height, scratchCartesian3);
Cartographic.Cartesian3.add(position, scaledNormal, position);
if (extrude) {
Cartographic.Cartesian3.multiplyByScalar(normal, extrudedHeight, scaledNormal);
Cartographic.Cartesian3.add(extrudedPosition, scaledNormal, extrudedPosition);
finalPositions[i + bottomOffset] = extrudedPosition.x;
finalPositions[i1 + bottomOffset] = extrudedPosition.y;
finalPositions[i2 + bottomOffset] = extrudedPosition.z;
}
finalPositions[i] = position.x;
finalPositions[i1] = position.y;
finalPositions[i2] = position.z;
}
return finalPositions;
};
var unitPosScratch = new Cartographic.Cartesian3();
var eastVecScratch = new Cartographic.Cartesian3();
var northVecScratch = new Cartographic.Cartesian3();
/**
* Returns an array of positions that make up the ellipse.
* @private
*/
EllipseGeometryLibrary.computeEllipsePositions = function(options, addFillPositions, addEdgePositions) {
var semiMinorAxis = options.semiMinorAxis;
var semiMajorAxis = options.semiMajorAxis;
var rotation = options.rotation;
var center = options.center;
// Computing the arc-length of the ellipse is too expensive to be practical. Estimating it using the
// arc length of the sphere is too inaccurate and creates sharp edges when either the semi-major or
// semi-minor axis is much bigger than the other. Instead, scale the angle delta to make
// the distance along the ellipse boundary more closely match the granularity.
var granularity = options.granularity * 8.0;
var aSqr = semiMinorAxis * semiMinorAxis;
var bSqr = semiMajorAxis * semiMajorAxis;
var ab = semiMajorAxis * semiMinorAxis;
var mag = Cartographic.Cartesian3.magnitude(center);
var unitPos = Cartographic.Cartesian3.normalize(center, unitPosScratch);
var eastVec = Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, center, eastVecScratch);
eastVec = Cartographic.Cartesian3.normalize(eastVec, eastVec);
var northVec = Cartographic.Cartesian3.cross(unitPos, eastVec, northVecScratch);
// The number of points in the first quadrant
var numPts = 1 + Math.ceil(_Math.CesiumMath.PI_OVER_TWO / granularity);
var deltaTheta = _Math.CesiumMath.PI_OVER_TWO / (numPts - 1);
var theta = _Math.CesiumMath.PI_OVER_TWO - numPts * deltaTheta;
if (theta < 0.0) {
numPts -= Math.ceil(Math.abs(theta) / deltaTheta);
}
// If the number of points were three, the ellipse
// would be tessellated like below:
//
// *---*
// / | \ | \
// *---*---*---*
// / | \ | \ | \ | \
// / .*---*---*---*. \
// * ` | \ | \ | \ | `*
// \`.*---*---*---*.`/
// \ | \ | \ | \ | /
// *---*---*---*
// \ | \ | /
// *---*
// The first and last column have one position and fan to connect to the adjacent column.
// Each other vertical column contains an even number of positions.
var size = 2 * (numPts * (numPts + 2));
var positions = (addFillPositions) ? new Array(size * 3) : undefined;
var positionIndex = 0;
var position = scratchCartesian1;
var reflectedPosition = scratchCartesian2;
var outerPositionsLength = (numPts * 4) * 3;
var outerRightIndex = outerPositionsLength - 1;
var outerLeftIndex = 0;
var outerPositions = (addEdgePositions) ? new Array(outerPositionsLength) : undefined;
var i;
var j;
var numInterior;
var t;
var interiorPosition;
// Compute points in the 'eastern' half of the ellipse
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
}
theta = _Math.CesiumMath.PI_OVER_TWO - deltaTheta;
for (i = 1; i < numPts + 1; ++i) {
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(Math.PI - theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * i + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
theta = _Math.CesiumMath.PI_OVER_TWO - (i + 1) * deltaTheta;
}
// Compute points in the 'western' half of the ellipse
for (i = numPts; i > 1; --i) {
theta = _Math.CesiumMath.PI_OVER_TWO - (i - 1) * deltaTheta;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(theta + Math.PI, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * (i - 1) + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
}
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
var r = {};
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
r.positions = positions;
r.numPts = numPts;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
r.outerPositions = outerPositions;
}
return r;
};
exports.EllipseGeometryLibrary = EllipseGeometryLibrary;
});

View File

@ -1,285 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './Math-61ede240', './Cartographic-f2a06374', './BoundingSphere-d018a565', './Transforms-f77c92da'], function (exports, _Math, Cartographic, BoundingSphere, Transforms) { 'use strict';
var EllipseGeometryLibrary = {};
var rotAxis = new Cartographic.Cartesian3();
var tempVec = new Cartographic.Cartesian3();
var unitQuat = new Transforms.Quaternion();
var rotMtx = new BoundingSphere.Matrix3();
function pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, result) {
var azimuth = theta + rotation;
Cartographic.Cartesian3.multiplyByScalar(eastVec, Math.cos(azimuth), rotAxis);
Cartographic.Cartesian3.multiplyByScalar(northVec, Math.sin(azimuth), tempVec);
Cartographic.Cartesian3.add(rotAxis, tempVec, rotAxis);
var cosThetaSquared = Math.cos(theta);
cosThetaSquared = cosThetaSquared * cosThetaSquared;
var sinThetaSquared = Math.sin(theta);
sinThetaSquared = sinThetaSquared * sinThetaSquared;
var radius = ab / Math.sqrt(bSqr * cosThetaSquared + aSqr * sinThetaSquared);
var angle = radius / mag;
// Create the quaternion to rotate the position vector to the boundary of the ellipse.
Transforms.Quaternion.fromAxisAngle(rotAxis, angle, unitQuat);
BoundingSphere.Matrix3.fromQuaternion(unitQuat, rotMtx);
BoundingSphere.Matrix3.multiplyByVector(rotMtx, unitPos, result);
Cartographic.Cartesian3.normalize(result, result);
Cartographic.Cartesian3.multiplyByScalar(result, mag, result);
return result;
}
var scratchCartesian1 = new Cartographic.Cartesian3();
var scratchCartesian2 = new Cartographic.Cartesian3();
var scratchCartesian3 = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
/**
* Returns the positions raised to the given heights
* @private
*/
EllipseGeometryLibrary.raisePositionsToHeight = function(positions, options, extrude) {
var ellipsoid = options.ellipsoid;
var height = options.height;
var extrudedHeight = options.extrudedHeight;
var size = (extrude) ? positions.length / 3 * 2 : positions.length / 3;
var finalPositions = new Float64Array(size * 3);
var length = positions.length;
var bottomOffset = (extrude) ? length : 0;
for (var i = 0; i < length; i += 3) {
var i1 = i + 1;
var i2 = i + 2;
var position = Cartographic.Cartesian3.fromArray(positions, i, scratchCartesian1);
ellipsoid.scaleToGeodeticSurface(position, position);
var extrudedPosition = Cartographic.Cartesian3.clone(position, scratchCartesian2);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(normal, height, scratchCartesian3);
Cartographic.Cartesian3.add(position, scaledNormal, position);
if (extrude) {
Cartographic.Cartesian3.multiplyByScalar(normal, extrudedHeight, scaledNormal);
Cartographic.Cartesian3.add(extrudedPosition, scaledNormal, extrudedPosition);
finalPositions[i + bottomOffset] = extrudedPosition.x;
finalPositions[i1 + bottomOffset] = extrudedPosition.y;
finalPositions[i2 + bottomOffset] = extrudedPosition.z;
}
finalPositions[i] = position.x;
finalPositions[i1] = position.y;
finalPositions[i2] = position.z;
}
return finalPositions;
};
var unitPosScratch = new Cartographic.Cartesian3();
var eastVecScratch = new Cartographic.Cartesian3();
var northVecScratch = new Cartographic.Cartesian3();
/**
* Returns an array of positions that make up the ellipse.
* @private
*/
EllipseGeometryLibrary.computeEllipsePositions = function(options, addFillPositions, addEdgePositions) {
var semiMinorAxis = options.semiMinorAxis;
var semiMajorAxis = options.semiMajorAxis;
var rotation = options.rotation;
var center = options.center;
// Computing the arc-length of the ellipse is too expensive to be practical. Estimating it using the
// arc length of the sphere is too inaccurate and creates sharp edges when either the semi-major or
// semi-minor axis is much bigger than the other. Instead, scale the angle delta to make
// the distance along the ellipse boundary more closely match the granularity.
var granularity = options.granularity * 8.0;
var aSqr = semiMinorAxis * semiMinorAxis;
var bSqr = semiMajorAxis * semiMajorAxis;
var ab = semiMajorAxis * semiMinorAxis;
var mag = Cartographic.Cartesian3.magnitude(center);
var unitPos = Cartographic.Cartesian3.normalize(center, unitPosScratch);
var eastVec = Cartographic.Cartesian3.cross(Cartographic.Cartesian3.UNIT_Z, center, eastVecScratch);
eastVec = Cartographic.Cartesian3.normalize(eastVec, eastVec);
var northVec = Cartographic.Cartesian3.cross(unitPos, eastVec, northVecScratch);
// The number of points in the first quadrant
var numPts = 1 + Math.ceil(_Math.CesiumMath.PI_OVER_TWO / granularity);
var deltaTheta = _Math.CesiumMath.PI_OVER_TWO / (numPts - 1);
var theta = _Math.CesiumMath.PI_OVER_TWO - numPts * deltaTheta;
if (theta < 0.0) {
numPts -= Math.ceil(Math.abs(theta) / deltaTheta);
}
// If the number of points were three, the ellipse
// would be tessellated like below:
//
// *---*
// / | \ | \
// *---*---*---*
// / | \ | \ | \ | \
// / .*---*---*---*. \
// * ` | \ | \ | \ | `*
// \`.*---*---*---*.`/
// \ | \ | \ | \ | /
// *---*---*---*
// \ | \ | /
// *---*
// The first and last column have one position and fan to connect to the adjacent column.
// Each other vertical column contains an even number of positions.
var size = 2 * (numPts * (numPts + 2));
var positions = (addFillPositions) ? new Array(size * 3) : undefined;
var positionIndex = 0;
var position = scratchCartesian1;
var reflectedPosition = scratchCartesian2;
var outerPositionsLength = (numPts * 4) * 3;
var outerRightIndex = outerPositionsLength - 1;
var outerLeftIndex = 0;
var outerPositions = (addEdgePositions) ? new Array(outerPositionsLength) : undefined;
var i;
var j;
var numInterior;
var t;
var interiorPosition;
// Compute points in the 'eastern' half of the ellipse
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
}
theta = _Math.CesiumMath.PI_OVER_TWO - deltaTheta;
for (i = 1; i < numPts + 1; ++i) {
position = pointOnEllipsoid(theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(Math.PI - theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * i + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
theta = _Math.CesiumMath.PI_OVER_TWO - (i + 1) * deltaTheta;
}
// Compute points in the 'western' half of the ellipse
for (i = numPts; i > 1; --i) {
theta = _Math.CesiumMath.PI_OVER_TWO - (i - 1) * deltaTheta;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
reflectedPosition = pointOnEllipsoid(theta + Math.PI, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, reflectedPosition);
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
numInterior = 2 * (i - 1) + 2;
for (j = 1; j < numInterior - 1; ++j) {
t = j / (numInterior - 1);
interiorPosition = Cartographic.Cartesian3.lerp(position, reflectedPosition, t, scratchCartesian3);
positions[positionIndex++] = interiorPosition.x;
positions[positionIndex++] = interiorPosition.y;
positions[positionIndex++] = interiorPosition.z;
}
positions[positionIndex++] = reflectedPosition.x;
positions[positionIndex++] = reflectedPosition.y;
positions[positionIndex++] = reflectedPosition.z;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
outerPositions[outerLeftIndex++] = reflectedPosition.x;
outerPositions[outerLeftIndex++] = reflectedPosition.y;
outerPositions[outerLeftIndex++] = reflectedPosition.z;
}
}
theta = _Math.CesiumMath.PI_OVER_TWO;
position = pointOnEllipsoid(-theta, rotation, northVec, eastVec, aSqr, ab, bSqr, mag, unitPos, position);
var r = {};
if (addFillPositions) {
positions[positionIndex++] = position.x;
positions[positionIndex++] = position.y;
positions[positionIndex++] = position.z;
r.positions = positions;
r.numPts = numPts;
}
if (addEdgePositions) {
outerPositions[outerRightIndex--] = position.z;
outerPositions[outerRightIndex--] = position.y;
outerPositions[outerRightIndex--] = position.x;
r.outerPositions = outerPositions;
}
return r;
};
exports.EllipseGeometryLibrary = EllipseGeometryLibrary;
});

View File

@ -1,387 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-1e248a71', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './EllipseGeometryLibrary-c4c6a578'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, EllipseGeometryLibrary) { 'use strict';
var scratchCartesian1 = new Cartographic.Cartesian3();
var boundingSphereCenter = new Cartographic.Cartesian3();
function computeEllipse(options) {
var center = options.center;
boundingSphereCenter = Cartographic.Cartesian3.multiplyByScalar(options.ellipsoid.geodeticSurfaceNormal(center, boundingSphereCenter), options.height, boundingSphereCenter);
boundingSphereCenter = Cartographic.Cartesian3.add(center, boundingSphereCenter, boundingSphereCenter);
var boundingSphere = new BoundingSphere.BoundingSphere(boundingSphereCenter, options.semiMajorAxis);
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, false)
})
});
var length = positions.length / 3;
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2);
var index = 0;
for ( var i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
var topBoundingSphere = new BoundingSphere.BoundingSphere();
var bottomBoundingSphere = new BoundingSphere.BoundingSphere();
function computeExtrudedEllipse(options) {
var center = options.center;
var ellipsoid = options.ellipsoid;
var semiMajorAxis = options.semiMajorAxis;
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scratchCartesian1), options.height, scratchCartesian1);
topBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, topBoundingSphere.center);
topBoundingSphere.radius = semiMajorAxis;
scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scaledNormal), options.extrudedHeight, scaledNormal);
bottomBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, bottomBoundingSphere.center);
bottomBoundingSphere.radius = semiMajorAxis;
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, true)
})
});
positions = attributes.position.values;
var boundingSphere = BoundingSphere.BoundingSphere.union(topBoundingSphere, bottomBoundingSphere);
var length = positions.length/3;
if (when.defined(options.offsetAttribute)) {
var applyOffset = new Uint8Array(length);
if (options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
applyOffset = arrayFill.arrayFill(applyOffset, 1, 0, length / 2);
} else {
var offsetValue = options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
applyOffset = arrayFill.arrayFill(applyOffset, offsetValue);
}
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
var numberOfVerticalLines = when.defaultValue(options.numberOfVerticalLines, 16);
numberOfVerticalLines = _Math.CesiumMath.clamp(numberOfVerticalLines, 0, length/2);
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2 + numberOfVerticalLines * 2);
length /= 2;
var index = 0;
var i;
for (i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
indices[index++] = i + length;
indices[index++] = ((i + 1) % length) + length;
}
var numSide;
if (numberOfVerticalLines > 0) {
var numSideLines = Math.min(numberOfVerticalLines, length);
numSide = Math.round(length / numSideLines);
var maxI = Math.min(numSide * numberOfVerticalLines, length);
for (i = 0; i < maxI; i += numSide) {
indices[index++] = i;
indices[index++] = i + length;
}
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
/**
* A description of the outline of an ellipse on an ellipsoid.
*
* @alias EllipseOutlineGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.center The ellipse's center point in the fixed frame.
* @param {Number} options.semiMajorAxis The length of the ellipse's semi-major axis in meters.
* @param {Number} options.semiMinorAxis The length of the ellipse's semi-minor axis in meters.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the ellipse will be on.
* @param {Number} [options.height=0.0] The distance in meters between the ellipse and the ellipsoid surface.
* @param {Number} [options.extrudedHeight] The distance in meters between the ellipse's extruded face and the ellipsoid surface.
* @param {Number} [options.rotation=0.0] The angle from north (counter-clockwise) in radians.
* @param {Number} [options.granularity=0.02] The angular distance between points on the ellipse in radians.
* @param {Number} [options.numberOfVerticalLines=16] Number of lines to draw between the top and bottom surface of an extruded ellipse.
*
* @exception {DeveloperError} semiMajorAxis and semiMinorAxis must be greater than zero.
* @exception {DeveloperError} semiMajorAxis must be greater than or equal to the semiMinorAxis.
* @exception {DeveloperError} granularity must be greater than zero.
*
* @see EllipseOutlineGeometry.createGeometry
*
* @example
* var ellipse = new Cesium.EllipseOutlineGeometry({
* center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
* semiMajorAxis : 500000.0,
* semiMinorAxis : 300000.0,
* rotation : Cesium.Math.toRadians(60.0)
* });
* var geometry = Cesium.EllipseOutlineGeometry.createGeometry(ellipse);
*/
function EllipseOutlineGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var center = options.center;
var ellipsoid = when.defaultValue(options.ellipsoid, Cartesian2.Ellipsoid.WGS84);
var semiMajorAxis = options.semiMajorAxis;
var semiMinorAxis = options.semiMinorAxis;
var granularity = when.defaultValue(options.granularity, _Math.CesiumMath.RADIANS_PER_DEGREE);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(center)) {
throw new Check.DeveloperError('center is required.');
}
if (!when.defined(semiMajorAxis)) {
throw new Check.DeveloperError('semiMajorAxis is required.');
}
if (!when.defined(semiMinorAxis)) {
throw new Check.DeveloperError('semiMinorAxis is required.');
}
if (semiMajorAxis < semiMinorAxis) {
throw new Check.DeveloperError('semiMajorAxis must be greater than or equal to the semiMinorAxis.');
}
if (granularity <= 0.0) {
throw new Check.DeveloperError('granularity must be greater than zero.');
}
//>>includeEnd('debug');
var height = when.defaultValue(options.height, 0.0);
var extrudedHeight = when.defaultValue(options.extrudedHeight, height);
this._center = Cartographic.Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid);
this._rotation = when.defaultValue(options.rotation, 0.0);
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(when.defaultValue(options.numberOfVerticalLines, 16), 0);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipseOutlineGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipseOutlineGeometry.packedLength = Cartographic.Cartesian3.packedLength + Cartesian2.Ellipsoid.packedLength + 8;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipseOutlineGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipseOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._center, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartesian2.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
startingIndex += Cartesian2.Ellipsoid.packedLength;
array[startingIndex++] = value._semiMajorAxis;
array[startingIndex++] = value._semiMinorAxis;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchCenter = new Cartographic.Cartesian3();
var scratchEllipsoid = new Cartesian2.Ellipsoid();
var scratchOptions = {
center : scratchCenter,
ellipsoid : scratchEllipsoid,
semiMajorAxis : undefined,
semiMinorAxis : undefined,
rotation : undefined,
height : undefined,
granularity : undefined,
extrudedHeight : undefined,
numberOfVerticalLines : undefined,
offsetAttribute: undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipseOutlineGeometry} [result] The object into which to store the result.
* @returns {EllipseOutlineGeometry} The modified result parameter or a new EllipseOutlineGeometry instance if one was not provided.
*/
EllipseOutlineGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var center = Cartographic.Cartesian3.unpack(array, startingIndex, scratchCenter);
startingIndex += Cartographic.Cartesian3.packedLength;
var ellipsoid = Cartesian2.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Cartesian2.Ellipsoid.packedLength;
var semiMajorAxis = array[startingIndex++];
var semiMinorAxis = array[startingIndex++];
var rotation = array[startingIndex++];
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var numberOfVerticalLines = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.height = height;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.granularity = granularity;
scratchOptions.rotation = rotation;
scratchOptions.semiMajorAxis = semiMajorAxis;
scratchOptions.semiMinorAxis = semiMinorAxis;
scratchOptions.numberOfVerticalLines = numberOfVerticalLines;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipseOutlineGeometry(scratchOptions);
}
result._center = Cartographic.Cartesian3.clone(center, result._center);
result._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid, result._ellipsoid);
result._semiMajorAxis = semiMajorAxis;
result._semiMinorAxis = semiMinorAxis;
result._rotation = rotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._numberOfVerticalLines = numberOfVerticalLines;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an outline of an ellipse on an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipseOutlineGeometry} ellipseGeometry A description of the ellipse.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipseOutlineGeometry.createGeometry = function(ellipseGeometry) {
if ((ellipseGeometry._semiMajorAxis <= 0.0) || (ellipseGeometry._semiMinorAxis <= 0.0)) {
return;
}
var height = ellipseGeometry._height;
var extrudedHeight = ellipseGeometry._extrudedHeight;
var extrude = !_Math.CesiumMath.equalsEpsilon(height, extrudedHeight, 0, _Math.CesiumMath.EPSILON2);
ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(ellipseGeometry._center, ellipseGeometry._center);
var options = {
center : ellipseGeometry._center,
semiMajorAxis : ellipseGeometry._semiMajorAxis,
semiMinorAxis : ellipseGeometry._semiMinorAxis,
ellipsoid : ellipseGeometry._ellipsoid,
rotation : ellipseGeometry._rotation,
height : height,
granularity : ellipseGeometry._granularity,
numberOfVerticalLines : ellipseGeometry._numberOfVerticalLines
};
var geometry;
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.offsetAttribute = ellipseGeometry._offsetAttribute;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
if (when.defined(ellipseGeometry._offsetAttribute)) {
var length = geometry.attributes.position.values.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipseGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
}
return new GeometryAttribute.Geometry({
attributes : geometry.attributes,
indices : geometry.indices,
primitiveType : PrimitiveType.PrimitiveType.LINES,
boundingSphere : geometry.boundingSphere,
offsetAttribute : ellipseGeometry._offsetAttribute
});
};
exports.EllipseOutlineGeometry = EllipseOutlineGeometry;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,387 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-ed9d707f', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './EllipseGeometryLibrary-7533a967'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, EllipseGeometryLibrary) { 'use strict';
var scratchCartesian1 = new Cartographic.Cartesian3();
var boundingSphereCenter = new Cartographic.Cartesian3();
function computeEllipse(options) {
var center = options.center;
boundingSphereCenter = Cartographic.Cartesian3.multiplyByScalar(options.ellipsoid.geodeticSurfaceNormal(center, boundingSphereCenter), options.height, boundingSphereCenter);
boundingSphereCenter = Cartographic.Cartesian3.add(center, boundingSphereCenter, boundingSphereCenter);
var boundingSphere = new BoundingSphere.BoundingSphere(boundingSphereCenter, options.semiMajorAxis);
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, false)
})
});
var length = positions.length / 3;
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2);
var index = 0;
for ( var i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
var topBoundingSphere = new BoundingSphere.BoundingSphere();
var bottomBoundingSphere = new BoundingSphere.BoundingSphere();
function computeExtrudedEllipse(options) {
var center = options.center;
var ellipsoid = options.ellipsoid;
var semiMajorAxis = options.semiMajorAxis;
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scratchCartesian1), options.height, scratchCartesian1);
topBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, topBoundingSphere.center);
topBoundingSphere.radius = semiMajorAxis;
scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scaledNormal), options.extrudedHeight, scaledNormal);
bottomBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, bottomBoundingSphere.center);
bottomBoundingSphere.radius = semiMajorAxis;
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, true)
})
});
positions = attributes.position.values;
var boundingSphere = BoundingSphere.BoundingSphere.union(topBoundingSphere, bottomBoundingSphere);
var length = positions.length/3;
if (when.defined(options.offsetAttribute)) {
var applyOffset = new Uint8Array(length);
if (options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
applyOffset = arrayFill.arrayFill(applyOffset, 1, 0, length / 2);
} else {
var offsetValue = options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
applyOffset = arrayFill.arrayFill(applyOffset, offsetValue);
}
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
var numberOfVerticalLines = when.defaultValue(options.numberOfVerticalLines, 16);
numberOfVerticalLines = _Math.CesiumMath.clamp(numberOfVerticalLines, 0, length/2);
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2 + numberOfVerticalLines * 2);
length /= 2;
var index = 0;
var i;
for (i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
indices[index++] = i + length;
indices[index++] = ((i + 1) % length) + length;
}
var numSide;
if (numberOfVerticalLines > 0) {
var numSideLines = Math.min(numberOfVerticalLines, length);
numSide = Math.round(length / numSideLines);
var maxI = Math.min(numSide * numberOfVerticalLines, length);
for (i = 0; i < maxI; i += numSide) {
indices[index++] = i;
indices[index++] = i + length;
}
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
/**
* A description of the outline of an ellipse on an ellipsoid.
*
* @alias EllipseOutlineGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.center The ellipse's center point in the fixed frame.
* @param {Number} options.semiMajorAxis The length of the ellipse's semi-major axis in meters.
* @param {Number} options.semiMinorAxis The length of the ellipse's semi-minor axis in meters.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the ellipse will be on.
* @param {Number} [options.height=0.0] The distance in meters between the ellipse and the ellipsoid surface.
* @param {Number} [options.extrudedHeight] The distance in meters between the ellipse's extruded face and the ellipsoid surface.
* @param {Number} [options.rotation=0.0] The angle from north (counter-clockwise) in radians.
* @param {Number} [options.granularity=0.02] The angular distance between points on the ellipse in radians.
* @param {Number} [options.numberOfVerticalLines=16] Number of lines to draw between the top and bottom surface of an extruded ellipse.
*
* @exception {DeveloperError} semiMajorAxis and semiMinorAxis must be greater than zero.
* @exception {DeveloperError} semiMajorAxis must be greater than or equal to the semiMinorAxis.
* @exception {DeveloperError} granularity must be greater than zero.
*
* @see EllipseOutlineGeometry.createGeometry
*
* @example
* var ellipse = new Cesium.EllipseOutlineGeometry({
* center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
* semiMajorAxis : 500000.0,
* semiMinorAxis : 300000.0,
* rotation : Cesium.Math.toRadians(60.0)
* });
* var geometry = Cesium.EllipseOutlineGeometry.createGeometry(ellipse);
*/
function EllipseOutlineGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var center = options.center;
var ellipsoid = when.defaultValue(options.ellipsoid, Cartesian2.Ellipsoid.WGS84);
var semiMajorAxis = options.semiMajorAxis;
var semiMinorAxis = options.semiMinorAxis;
var granularity = when.defaultValue(options.granularity, _Math.CesiumMath.RADIANS_PER_DEGREE);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(center)) {
throw new Check.DeveloperError('center is required.');
}
if (!when.defined(semiMajorAxis)) {
throw new Check.DeveloperError('semiMajorAxis is required.');
}
if (!when.defined(semiMinorAxis)) {
throw new Check.DeveloperError('semiMinorAxis is required.');
}
if (semiMajorAxis < semiMinorAxis) {
throw new Check.DeveloperError('semiMajorAxis must be greater than or equal to the semiMinorAxis.');
}
if (granularity <= 0.0) {
throw new Check.DeveloperError('granularity must be greater than zero.');
}
//>>includeEnd('debug');
var height = when.defaultValue(options.height, 0.0);
var extrudedHeight = when.defaultValue(options.extrudedHeight, height);
this._center = Cartographic.Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid);
this._rotation = when.defaultValue(options.rotation, 0.0);
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(when.defaultValue(options.numberOfVerticalLines, 16), 0);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipseOutlineGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipseOutlineGeometry.packedLength = Cartographic.Cartesian3.packedLength + Cartesian2.Ellipsoid.packedLength + 8;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipseOutlineGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipseOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._center, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartesian2.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
startingIndex += Cartesian2.Ellipsoid.packedLength;
array[startingIndex++] = value._semiMajorAxis;
array[startingIndex++] = value._semiMinorAxis;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchCenter = new Cartographic.Cartesian3();
var scratchEllipsoid = new Cartesian2.Ellipsoid();
var scratchOptions = {
center : scratchCenter,
ellipsoid : scratchEllipsoid,
semiMajorAxis : undefined,
semiMinorAxis : undefined,
rotation : undefined,
height : undefined,
granularity : undefined,
extrudedHeight : undefined,
numberOfVerticalLines : undefined,
offsetAttribute: undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipseOutlineGeometry} [result] The object into which to store the result.
* @returns {EllipseOutlineGeometry} The modified result parameter or a new EllipseOutlineGeometry instance if one was not provided.
*/
EllipseOutlineGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var center = Cartographic.Cartesian3.unpack(array, startingIndex, scratchCenter);
startingIndex += Cartographic.Cartesian3.packedLength;
var ellipsoid = Cartesian2.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Cartesian2.Ellipsoid.packedLength;
var semiMajorAxis = array[startingIndex++];
var semiMinorAxis = array[startingIndex++];
var rotation = array[startingIndex++];
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var numberOfVerticalLines = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.height = height;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.granularity = granularity;
scratchOptions.rotation = rotation;
scratchOptions.semiMajorAxis = semiMajorAxis;
scratchOptions.semiMinorAxis = semiMinorAxis;
scratchOptions.numberOfVerticalLines = numberOfVerticalLines;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipseOutlineGeometry(scratchOptions);
}
result._center = Cartographic.Cartesian3.clone(center, result._center);
result._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid, result._ellipsoid);
result._semiMajorAxis = semiMajorAxis;
result._semiMinorAxis = semiMinorAxis;
result._rotation = rotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._numberOfVerticalLines = numberOfVerticalLines;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an outline of an ellipse on an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipseOutlineGeometry} ellipseGeometry A description of the ellipse.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipseOutlineGeometry.createGeometry = function(ellipseGeometry) {
if ((ellipseGeometry._semiMajorAxis <= 0.0) || (ellipseGeometry._semiMinorAxis <= 0.0)) {
return;
}
var height = ellipseGeometry._height;
var extrudedHeight = ellipseGeometry._extrudedHeight;
var extrude = !_Math.CesiumMath.equalsEpsilon(height, extrudedHeight, 0, _Math.CesiumMath.EPSILON2);
ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(ellipseGeometry._center, ellipseGeometry._center);
var options = {
center : ellipseGeometry._center,
semiMajorAxis : ellipseGeometry._semiMajorAxis,
semiMinorAxis : ellipseGeometry._semiMinorAxis,
ellipsoid : ellipseGeometry._ellipsoid,
rotation : ellipseGeometry._rotation,
height : height,
granularity : ellipseGeometry._granularity,
numberOfVerticalLines : ellipseGeometry._numberOfVerticalLines
};
var geometry;
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.offsetAttribute = ellipseGeometry._offsetAttribute;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
if (when.defined(ellipseGeometry._offsetAttribute)) {
var length = geometry.attributes.position.values.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipseGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
}
return new GeometryAttribute.Geometry({
attributes : geometry.attributes,
indices : geometry.indices,
primitiveType : PrimitiveType.PrimitiveType.LINES,
boundingSphere : geometry.boundingSphere,
offsetAttribute : ellipseGeometry._offsetAttribute
});
};
exports.EllipseOutlineGeometry = EllipseOutlineGeometry;
});

File diff suppressed because one or more lines are too long

View File

@ -1,387 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-773da12d', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './EllipseGeometryLibrary-fbc85a33'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, EllipseGeometryLibrary) { 'use strict';
var scratchCartesian1 = new Cartographic.Cartesian3();
var boundingSphereCenter = new Cartographic.Cartesian3();
function computeEllipse(options) {
var center = options.center;
boundingSphereCenter = Cartographic.Cartesian3.multiplyByScalar(options.ellipsoid.geodeticSurfaceNormal(center, boundingSphereCenter), options.height, boundingSphereCenter);
boundingSphereCenter = Cartographic.Cartesian3.add(center, boundingSphereCenter, boundingSphereCenter);
var boundingSphere = new BoundingSphere.BoundingSphere(boundingSphereCenter, options.semiMajorAxis);
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, false)
})
});
var length = positions.length / 3;
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2);
var index = 0;
for ( var i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
var topBoundingSphere = new BoundingSphere.BoundingSphere();
var bottomBoundingSphere = new BoundingSphere.BoundingSphere();
function computeExtrudedEllipse(options) {
var center = options.center;
var ellipsoid = options.ellipsoid;
var semiMajorAxis = options.semiMajorAxis;
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scratchCartesian1), options.height, scratchCartesian1);
topBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, topBoundingSphere.center);
topBoundingSphere.radius = semiMajorAxis;
scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scaledNormal), options.extrudedHeight, scaledNormal);
bottomBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, bottomBoundingSphere.center);
bottomBoundingSphere.radius = semiMajorAxis;
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, true)
})
});
positions = attributes.position.values;
var boundingSphere = BoundingSphere.BoundingSphere.union(topBoundingSphere, bottomBoundingSphere);
var length = positions.length/3;
if (when.defined(options.offsetAttribute)) {
var applyOffset = new Uint8Array(length);
if (options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
applyOffset = arrayFill.arrayFill(applyOffset, 1, 0, length / 2);
} else {
var offsetValue = options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
applyOffset = arrayFill.arrayFill(applyOffset, offsetValue);
}
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
var numberOfVerticalLines = when.defaultValue(options.numberOfVerticalLines, 16);
numberOfVerticalLines = _Math.CesiumMath.clamp(numberOfVerticalLines, 0, length/2);
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2 + numberOfVerticalLines * 2);
length /= 2;
var index = 0;
var i;
for (i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
indices[index++] = i + length;
indices[index++] = ((i + 1) % length) + length;
}
var numSide;
if (numberOfVerticalLines > 0) {
var numSideLines = Math.min(numberOfVerticalLines, length);
numSide = Math.round(length / numSideLines);
var maxI = Math.min(numSide * numberOfVerticalLines, length);
for (i = 0; i < maxI; i += numSide) {
indices[index++] = i;
indices[index++] = i + length;
}
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
/**
* A description of the outline of an ellipse on an ellipsoid.
*
* @alias EllipseOutlineGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.center The ellipse's center point in the fixed frame.
* @param {Number} options.semiMajorAxis The length of the ellipse's semi-major axis in meters.
* @param {Number} options.semiMinorAxis The length of the ellipse's semi-minor axis in meters.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the ellipse will be on.
* @param {Number} [options.height=0.0] The distance in meters between the ellipse and the ellipsoid surface.
* @param {Number} [options.extrudedHeight] The distance in meters between the ellipse's extruded face and the ellipsoid surface.
* @param {Number} [options.rotation=0.0] The angle from north (counter-clockwise) in radians.
* @param {Number} [options.granularity=0.02] The angular distance between points on the ellipse in radians.
* @param {Number} [options.numberOfVerticalLines=16] Number of lines to draw between the top and bottom surface of an extruded ellipse.
*
* @exception {DeveloperError} semiMajorAxis and semiMinorAxis must be greater than zero.
* @exception {DeveloperError} semiMajorAxis must be greater than or equal to the semiMinorAxis.
* @exception {DeveloperError} granularity must be greater than zero.
*
* @see EllipseOutlineGeometry.createGeometry
*
* @example
* var ellipse = new Cesium.EllipseOutlineGeometry({
* center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
* semiMajorAxis : 500000.0,
* semiMinorAxis : 300000.0,
* rotation : Cesium.Math.toRadians(60.0)
* });
* var geometry = Cesium.EllipseOutlineGeometry.createGeometry(ellipse);
*/
function EllipseOutlineGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var center = options.center;
var ellipsoid = when.defaultValue(options.ellipsoid, Cartesian2.Ellipsoid.WGS84);
var semiMajorAxis = options.semiMajorAxis;
var semiMinorAxis = options.semiMinorAxis;
var granularity = when.defaultValue(options.granularity, _Math.CesiumMath.RADIANS_PER_DEGREE);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(center)) {
throw new Check.DeveloperError('center is required.');
}
if (!when.defined(semiMajorAxis)) {
throw new Check.DeveloperError('semiMajorAxis is required.');
}
if (!when.defined(semiMinorAxis)) {
throw new Check.DeveloperError('semiMinorAxis is required.');
}
if (semiMajorAxis < semiMinorAxis) {
throw new Check.DeveloperError('semiMajorAxis must be greater than or equal to the semiMinorAxis.');
}
if (granularity <= 0.0) {
throw new Check.DeveloperError('granularity must be greater than zero.');
}
//>>includeEnd('debug');
var height = when.defaultValue(options.height, 0.0);
var extrudedHeight = when.defaultValue(options.extrudedHeight, height);
this._center = Cartographic.Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid);
this._rotation = when.defaultValue(options.rotation, 0.0);
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(when.defaultValue(options.numberOfVerticalLines, 16), 0);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipseOutlineGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipseOutlineGeometry.packedLength = Cartographic.Cartesian3.packedLength + Cartesian2.Ellipsoid.packedLength + 8;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipseOutlineGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipseOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._center, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartesian2.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
startingIndex += Cartesian2.Ellipsoid.packedLength;
array[startingIndex++] = value._semiMajorAxis;
array[startingIndex++] = value._semiMinorAxis;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchCenter = new Cartographic.Cartesian3();
var scratchEllipsoid = new Cartesian2.Ellipsoid();
var scratchOptions = {
center : scratchCenter,
ellipsoid : scratchEllipsoid,
semiMajorAxis : undefined,
semiMinorAxis : undefined,
rotation : undefined,
height : undefined,
granularity : undefined,
extrudedHeight : undefined,
numberOfVerticalLines : undefined,
offsetAttribute: undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipseOutlineGeometry} [result] The object into which to store the result.
* @returns {EllipseOutlineGeometry} The modified result parameter or a new EllipseOutlineGeometry instance if one was not provided.
*/
EllipseOutlineGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var center = Cartographic.Cartesian3.unpack(array, startingIndex, scratchCenter);
startingIndex += Cartographic.Cartesian3.packedLength;
var ellipsoid = Cartesian2.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Cartesian2.Ellipsoid.packedLength;
var semiMajorAxis = array[startingIndex++];
var semiMinorAxis = array[startingIndex++];
var rotation = array[startingIndex++];
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var numberOfVerticalLines = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.height = height;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.granularity = granularity;
scratchOptions.rotation = rotation;
scratchOptions.semiMajorAxis = semiMajorAxis;
scratchOptions.semiMinorAxis = semiMinorAxis;
scratchOptions.numberOfVerticalLines = numberOfVerticalLines;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipseOutlineGeometry(scratchOptions);
}
result._center = Cartographic.Cartesian3.clone(center, result._center);
result._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid, result._ellipsoid);
result._semiMajorAxis = semiMajorAxis;
result._semiMinorAxis = semiMinorAxis;
result._rotation = rotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._numberOfVerticalLines = numberOfVerticalLines;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an outline of an ellipse on an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipseOutlineGeometry} ellipseGeometry A description of the ellipse.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipseOutlineGeometry.createGeometry = function(ellipseGeometry) {
if ((ellipseGeometry._semiMajorAxis <= 0.0) || (ellipseGeometry._semiMinorAxis <= 0.0)) {
return;
}
var height = ellipseGeometry._height;
var extrudedHeight = ellipseGeometry._extrudedHeight;
var extrude = !_Math.CesiumMath.equalsEpsilon(height, extrudedHeight, 0, _Math.CesiumMath.EPSILON2);
ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(ellipseGeometry._center, ellipseGeometry._center);
var options = {
center : ellipseGeometry._center,
semiMajorAxis : ellipseGeometry._semiMajorAxis,
semiMinorAxis : ellipseGeometry._semiMinorAxis,
ellipsoid : ellipseGeometry._ellipsoid,
rotation : ellipseGeometry._rotation,
height : height,
granularity : ellipseGeometry._granularity,
numberOfVerticalLines : ellipseGeometry._numberOfVerticalLines
};
var geometry;
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.offsetAttribute = ellipseGeometry._offsetAttribute;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
if (when.defined(ellipseGeometry._offsetAttribute)) {
var length = geometry.attributes.position.values.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipseGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
}
return new GeometryAttribute.Geometry({
attributes : geometry.attributes,
indices : geometry.indices,
primitiveType : PrimitiveType.PrimitiveType.LINES,
boundingSphere : geometry.boundingSphere,
offsetAttribute : ellipseGeometry._offsetAttribute
});
};
exports.EllipseOutlineGeometry = EllipseOutlineGeometry;
});

View File

@ -1,387 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-91704ebb', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './GeometryOffsetAttribute-ca302482', './EllipseGeometryLibrary-08dbcdef'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, GeometryOffsetAttribute, EllipseGeometryLibrary) { 'use strict';
var scratchCartesian1 = new Cartographic.Cartesian3();
var boundingSphereCenter = new Cartographic.Cartesian3();
function computeEllipse(options) {
var center = options.center;
boundingSphereCenter = Cartographic.Cartesian3.multiplyByScalar(options.ellipsoid.geodeticSurfaceNormal(center, boundingSphereCenter), options.height, boundingSphereCenter);
boundingSphereCenter = Cartographic.Cartesian3.add(center, boundingSphereCenter, boundingSphereCenter);
var boundingSphere = new BoundingSphere.BoundingSphere(boundingSphereCenter, options.semiMajorAxis);
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, false)
})
});
var length = positions.length / 3;
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2);
var index = 0;
for ( var i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
var topBoundingSphere = new BoundingSphere.BoundingSphere();
var bottomBoundingSphere = new BoundingSphere.BoundingSphere();
function computeExtrudedEllipse(options) {
var center = options.center;
var ellipsoid = options.ellipsoid;
var semiMajorAxis = options.semiMajorAxis;
var scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scratchCartesian1), options.height, scratchCartesian1);
topBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, topBoundingSphere.center);
topBoundingSphere.radius = semiMajorAxis;
scaledNormal = Cartographic.Cartesian3.multiplyByScalar(ellipsoid.geodeticSurfaceNormal(center, scaledNormal), options.extrudedHeight, scaledNormal);
bottomBoundingSphere.center = Cartographic.Cartesian3.add(center, scaledNormal, bottomBoundingSphere.center);
bottomBoundingSphere.radius = semiMajorAxis;
var positions = EllipseGeometryLibrary.EllipseGeometryLibrary.computeEllipsePositions(options, false, true).outerPositions;
var attributes = new GeometryAttributes.GeometryAttributes({
position: new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : EllipseGeometryLibrary.EllipseGeometryLibrary.raisePositionsToHeight(positions, options, true)
})
});
positions = attributes.position.values;
var boundingSphere = BoundingSphere.BoundingSphere.union(topBoundingSphere, bottomBoundingSphere);
var length = positions.length/3;
if (when.defined(options.offsetAttribute)) {
var applyOffset = new Uint8Array(length);
if (options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
applyOffset = GeometryOffsetAttribute.arrayFill(applyOffset, 1, 0, length / 2);
} else {
var offsetValue = options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
applyOffset = GeometryOffsetAttribute.arrayFill(applyOffset, offsetValue);
}
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
var numberOfVerticalLines = when.defaultValue(options.numberOfVerticalLines, 16);
numberOfVerticalLines = _Math.CesiumMath.clamp(numberOfVerticalLines, 0, length/2);
var indices = IndexDatatype.IndexDatatype.createTypedArray(length, length * 2 + numberOfVerticalLines * 2);
length /= 2;
var index = 0;
var i;
for (i = 0; i < length; ++i) {
indices[index++] = i;
indices[index++] = (i + 1) % length;
indices[index++] = i + length;
indices[index++] = ((i + 1) % length) + length;
}
var numSide;
if (numberOfVerticalLines > 0) {
var numSideLines = Math.min(numberOfVerticalLines, length);
numSide = Math.round(length / numSideLines);
var maxI = Math.min(numSide * numberOfVerticalLines, length);
for (i = 0; i < maxI; i += numSide) {
indices[index++] = i;
indices[index++] = i + length;
}
}
return {
boundingSphere : boundingSphere,
attributes : attributes,
indices : indices
};
}
/**
* A description of the outline of an ellipse on an ellipsoid.
*
* @alias EllipseOutlineGeometry
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {Cartesian3} options.center The ellipse's center point in the fixed frame.
* @param {Number} options.semiMajorAxis The length of the ellipse's semi-major axis in meters.
* @param {Number} options.semiMinorAxis The length of the ellipse's semi-minor axis in meters.
* @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid the ellipse will be on.
* @param {Number} [options.height=0.0] The distance in meters between the ellipse and the ellipsoid surface.
* @param {Number} [options.extrudedHeight] The distance in meters between the ellipse's extruded face and the ellipsoid surface.
* @param {Number} [options.rotation=0.0] The angle from north (counter-clockwise) in radians.
* @param {Number} [options.granularity=0.02] The angular distance between points on the ellipse in radians.
* @param {Number} [options.numberOfVerticalLines=16] Number of lines to draw between the top and bottom surface of an extruded ellipse.
*
* @exception {DeveloperError} semiMajorAxis and semiMinorAxis must be greater than zero.
* @exception {DeveloperError} semiMajorAxis must be greater than or equal to the semiMinorAxis.
* @exception {DeveloperError} granularity must be greater than zero.
*
* @see EllipseOutlineGeometry.createGeometry
*
* @example
* var ellipse = new Cesium.EllipseOutlineGeometry({
* center : Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883),
* semiMajorAxis : 500000.0,
* semiMinorAxis : 300000.0,
* rotation : Cesium.Math.toRadians(60.0)
* });
* var geometry = Cesium.EllipseOutlineGeometry.createGeometry(ellipse);
*/
function EllipseOutlineGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var center = options.center;
var ellipsoid = when.defaultValue(options.ellipsoid, Cartesian2.Ellipsoid.WGS84);
var semiMajorAxis = options.semiMajorAxis;
var semiMinorAxis = options.semiMinorAxis;
var granularity = when.defaultValue(options.granularity, _Math.CesiumMath.RADIANS_PER_DEGREE);
//>>includeStart('debug', pragmas.debug);
if (!when.defined(center)) {
throw new Check.DeveloperError('center is required.');
}
if (!when.defined(semiMajorAxis)) {
throw new Check.DeveloperError('semiMajorAxis is required.');
}
if (!when.defined(semiMinorAxis)) {
throw new Check.DeveloperError('semiMinorAxis is required.');
}
if (semiMajorAxis < semiMinorAxis) {
throw new Check.DeveloperError('semiMajorAxis must be greater than or equal to the semiMinorAxis.');
}
if (granularity <= 0.0) {
throw new Check.DeveloperError('granularity must be greater than zero.');
}
//>>includeEnd('debug');
var height = when.defaultValue(options.height, 0.0);
var extrudedHeight = when.defaultValue(options.extrudedHeight, height);
this._center = Cartographic.Cartesian3.clone(center);
this._semiMajorAxis = semiMajorAxis;
this._semiMinorAxis = semiMinorAxis;
this._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid);
this._rotation = when.defaultValue(options.rotation, 0.0);
this._height = Math.max(extrudedHeight, height);
this._granularity = granularity;
this._extrudedHeight = Math.min(extrudedHeight, height);
this._numberOfVerticalLines = Math.max(when.defaultValue(options.numberOfVerticalLines, 16), 0);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipseOutlineGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipseOutlineGeometry.packedLength = Cartographic.Cartesian3.packedLength + Cartesian2.Ellipsoid.packedLength + 8;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipseOutlineGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipseOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._center, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartesian2.Ellipsoid.pack(value._ellipsoid, array, startingIndex);
startingIndex += Cartesian2.Ellipsoid.packedLength;
array[startingIndex++] = value._semiMajorAxis;
array[startingIndex++] = value._semiMinorAxis;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._height;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._numberOfVerticalLines;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchCenter = new Cartographic.Cartesian3();
var scratchEllipsoid = new Cartesian2.Ellipsoid();
var scratchOptions = {
center : scratchCenter,
ellipsoid : scratchEllipsoid,
semiMajorAxis : undefined,
semiMinorAxis : undefined,
rotation : undefined,
height : undefined,
granularity : undefined,
extrudedHeight : undefined,
numberOfVerticalLines : undefined,
offsetAttribute: undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipseOutlineGeometry} [result] The object into which to store the result.
* @returns {EllipseOutlineGeometry} The modified result parameter or a new EllipseOutlineGeometry instance if one was not provided.
*/
EllipseOutlineGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var center = Cartographic.Cartesian3.unpack(array, startingIndex, scratchCenter);
startingIndex += Cartographic.Cartesian3.packedLength;
var ellipsoid = Cartesian2.Ellipsoid.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Cartesian2.Ellipsoid.packedLength;
var semiMajorAxis = array[startingIndex++];
var semiMinorAxis = array[startingIndex++];
var rotation = array[startingIndex++];
var height = array[startingIndex++];
var granularity = array[startingIndex++];
var extrudedHeight = array[startingIndex++];
var numberOfVerticalLines = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.height = height;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.granularity = granularity;
scratchOptions.rotation = rotation;
scratchOptions.semiMajorAxis = semiMajorAxis;
scratchOptions.semiMinorAxis = semiMinorAxis;
scratchOptions.numberOfVerticalLines = numberOfVerticalLines;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipseOutlineGeometry(scratchOptions);
}
result._center = Cartographic.Cartesian3.clone(center, result._center);
result._ellipsoid = Cartesian2.Ellipsoid.clone(ellipsoid, result._ellipsoid);
result._semiMajorAxis = semiMajorAxis;
result._semiMinorAxis = semiMinorAxis;
result._rotation = rotation;
result._height = height;
result._granularity = granularity;
result._extrudedHeight = extrudedHeight;
result._numberOfVerticalLines = numberOfVerticalLines;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an outline of an ellipse on an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipseOutlineGeometry} ellipseGeometry A description of the ellipse.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipseOutlineGeometry.createGeometry = function(ellipseGeometry) {
if ((ellipseGeometry._semiMajorAxis <= 0.0) || (ellipseGeometry._semiMinorAxis <= 0.0)) {
return;
}
var height = ellipseGeometry._height;
var extrudedHeight = ellipseGeometry._extrudedHeight;
var extrude = !_Math.CesiumMath.equalsEpsilon(height, extrudedHeight, 0, _Math.CesiumMath.EPSILON2);
ellipseGeometry._center = ellipseGeometry._ellipsoid.scaleToGeodeticSurface(ellipseGeometry._center, ellipseGeometry._center);
var options = {
center : ellipseGeometry._center,
semiMajorAxis : ellipseGeometry._semiMajorAxis,
semiMinorAxis : ellipseGeometry._semiMinorAxis,
ellipsoid : ellipseGeometry._ellipsoid,
rotation : ellipseGeometry._rotation,
height : height,
granularity : ellipseGeometry._granularity,
numberOfVerticalLines : ellipseGeometry._numberOfVerticalLines
};
var geometry;
if (extrude) {
options.extrudedHeight = extrudedHeight;
options.offsetAttribute = ellipseGeometry._offsetAttribute;
geometry = computeExtrudedEllipse(options);
} else {
geometry = computeEllipse(options);
if (when.defined(ellipseGeometry._offsetAttribute)) {
var length = geometry.attributes.position.values.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipseGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
GeometryOffsetAttribute.arrayFill(applyOffset, offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values: applyOffset
});
}
}
return new GeometryAttribute.Geometry({
attributes : geometry.attributes,
indices : geometry.indices,
primitiveType : PrimitiveType.PrimitiveType.LINES,
boundingSphere : geometry.boundingSphere,
offsetAttribute : ellipseGeometry._offsetAttribute
});
};
exports.EllipseOutlineGeometry = EllipseOutlineGeometry;
});

View File

@ -1 +0,0 @@
define(["exports","./Cartographic-3309dd0d","./Check-7b2a090c","./when-b60132fc","./Cartesian2-47311507","./Math-119be1a3"],(function(t,a,i,n,e,s){"use strict";function r(t,a,i,n,e,s,r){var h=function(t,a){return t*a*(4+t*(4-3*a))/16}(t,i);return(1-h)*t*a*(n+h*e*(r+h*s*(2*r*r-1)))}var h=new a.Cartesian3,o=new a.Cartesian3;function d(t,i,n,e){a.Cartesian3.normalize(e.cartographicToCartesian(i,o),h),a.Cartesian3.normalize(e.cartographicToCartesian(n,o),o),function(t,a,i,n,e,h,o){var d,c,u,M,g,l=(a-i)/a,_=h-n,p=Math.atan((1-l)*Math.tan(e)),f=Math.atan((1-l)*Math.tan(o)),v=Math.cos(p),m=Math.sin(p),C=Math.cos(f),H=Math.sin(f),O=v*C,S=v*H,q=m*H,b=m*C,U=_,w=s.CesiumMath.TWO_PI,A=Math.cos(U),R=Math.sin(U);do{A=Math.cos(U),R=Math.sin(U);var y,E=S-b*A;u=Math.sqrt(C*C*R*R+E*E),c=q+O*A,d=Math.atan2(u,c),0===u?(y=0,M=1):M=1-(y=O*R/u)*y,w=U,g=c-2*q/M,isNaN(g)&&(g=0),U=_+r(l,y,M,d,u,c,g)}while(Math.abs(U-w)>s.CesiumMath.EPSILON12);var P=M*(a*a-i*i)/(i*i),x=P*(256+P*(P*(74-47*P)-128))/1024,D=g*g,N=i*(1+P*(4096+P*(P*(320-175*P)-768))/16384)*(d-x*u*(g+x*(c*(2*D-1)-x*g*(4*u*u-3)*(4*D-3)/6)/4)),T=Math.atan2(C*R,S-b*A),z=Math.atan2(v*R,S*A-b);t._distance=N,t._startHeading=T,t._endHeading=z,t._uSquared=P}(t,e.maximumRadius,e.minimumRadius,i.longitude,i.latitude,n.longitude,n.latitude),t._start=a.Cartographic.clone(i,t._start),t._end=a.Cartographic.clone(n,t._end),t._start.height=0,t._end.height=0,function(t){var a=t._uSquared,i=t._ellipsoid.maximumRadius,n=t._ellipsoid.minimumRadius,e=(i-n)/i,s=Math.cos(t._startHeading),r=Math.sin(t._startHeading),h=(1-e)*Math.tan(t._start.latitude),o=1/Math.sqrt(1+h*h),d=o*h,c=Math.atan2(h,s),u=o*r,M=u*u,g=1-M,l=Math.sqrt(g),_=a/4,p=_*_,f=p*_,v=p*p,m=1+_-3*p/4+5*f/4-175*v/64,C=1-_+15*p/8-35*f/8,H=1-3*_+35*p/4,O=1-5*_,S=m*c-C*Math.sin(2*c)*_/2-H*Math.sin(4*c)*p/16-O*Math.sin(6*c)*f/48-5*Math.sin(8*c)*v/512,q=t._constants;q.a=i,q.b=n,q.f=e,q.cosineHeading=s,q.sineHeading=r,q.tanU=h,q.cosineU=o,q.sineU=d,q.sigma=c,q.sineAlpha=u,q.sineSquaredAlpha=M,q.cosineSquaredAlpha=g,q.cosineAlpha=l,q.u2Over4=_,q.u4Over16=p,q.u6Over64=f,q.u8Over256=v,q.a0=m,q.a1=C,q.a2=H,q.a3=O,q.distanceRatio=S}(t)}function c(t,i,s){var r=n.defaultValue(s,e.Ellipsoid.WGS84);this._ellipsoid=r,this._start=new a.Cartographic,this._end=new a.Cartographic,this._constants={},this._startHeading=void 0,this._endHeading=void 0,this._distance=void 0,this._uSquared=void 0,n.defined(t)&&n.defined(i)&&d(this,t,i,r)}Object.defineProperties(c.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},surfaceDistance:{get:function(){return this._distance}},start:{get:function(){return this._start}},end:{get:function(){return this._end}},startHeading:{get:function(){return this._startHeading}},endHeading:{get:function(){return this._endHeading}}}),c.prototype.setEndPoints=function(t,a){d(this,t,a,this._ellipsoid)},c.prototype.interpolateUsingFraction=function(t,a){return this.interpolateUsingSurfaceDistance(this._distance*t,a)},c.prototype.interpolateUsingSurfaceDistance=function(t,i){var e=this._constants,s=e.distanceRatio+t/e.b,h=Math.cos(2*s),o=Math.cos(4*s),d=Math.cos(6*s),c=Math.sin(2*s),u=Math.sin(4*s),M=Math.sin(6*s),g=Math.sin(8*s),l=s*s,_=s*l,p=e.u8Over256,f=e.u2Over4,v=e.u6Over64,m=e.u4Over16,C=2*_*p*h/3+s*(1-f+7*m/4-15*v/4+579*p/64-(m-15*v/4+187*p/16)*h-(5*v/4-115*p/16)*o-29*p*d/16)+(f/2-m+71*v/32-85*p/16)*c+(5*m/16-5*v/4+383*p/96)*u-l*((v-11*p/2)*c+5*p*u/2)+(29*v/96-29*p/16)*M+539*p*g/1536,H=Math.asin(Math.sin(C)*e.cosineAlpha),O=Math.atan(e.a/e.b*Math.tan(H));C-=e.sigma;var S=Math.cos(2*e.sigma+C),q=Math.sin(C),b=Math.cos(C),U=e.cosineU*b,w=e.sineU*q,A=Math.atan2(q*e.sineHeading,U-w*e.cosineHeading)-r(e.f,e.sineAlpha,e.cosineSquaredAlpha,C,q,b,S);return n.defined(i)?(i.longitude=this._start.longitude+A,i.latitude=O,i.height=0,i):new a.Cartographic(this._start.longitude+A,O,0)},t.EllipsoidGeodesic=c}));

View File

@ -0,0 +1 @@
define(["exports","./Matrix3-81054f0f","./defaultValue-f6d5e6da","./Math-2ce22ee9"],(function(t,a,i,n){"use strict";function e(t,a,i,n,e,s,o){const r=function(t,a){return t*a*(4+t*(4-3*a))/16}(t,i);return(1-r)*t*a*(n+r*e*(o+r*s*(2*o*o-1)))}const s=new a.Cartesian3,o=new a.Cartesian3;function r(t,i,r,h){a.Cartesian3.normalize(h.cartographicToCartesian(i,o),s),a.Cartesian3.normalize(h.cartographicToCartesian(r,o),o),function(t,a,i,s,o,r,h){const c=(a-i)/a,d=r-s,u=Math.atan((1-c)*Math.tan(o)),l=Math.atan((1-c)*Math.tan(h)),M=Math.cos(u),g=Math.sin(u),_=Math.cos(l),p=Math.sin(l),f=M*_,m=M*p,H=g*p,C=g*_;let v,O,S,q,U,A=d,w=n.CesiumMath.TWO_PI,R=Math.cos(A),b=Math.sin(A);do{R=Math.cos(A),b=Math.sin(A);const t=m-C*R;let a;S=Math.sqrt(_*_*b*b+t*t),O=H+f*R,v=Math.atan2(S,O),0===S?(a=0,q=1):(a=f*b/S,q=1-a*a),w=A,U=O-2*H/q,isFinite(U)||(U=0),A=d+e(c,a,q,v,S,O,U)}while(Math.abs(A-w)>n.CesiumMath.EPSILON12);const x=q*(a*a-i*i)/(i*i),y=x*(256+x*(x*(74-47*x)-128))/1024,E=U*U,P=i*(1+x*(4096+x*(x*(320-175*x)-768))/16384)*(v-y*S*(U+y*(O*(2*E-1)-y*U*(4*S*S-3)*(4*E-3)/6)/4)),D=Math.atan2(_*b,m-C*R),T=Math.atan2(M*b,m*R-C);t._distance=P,t._startHeading=D,t._endHeading=T,t._uSquared=x}(t,h.maximumRadius,h.minimumRadius,i.longitude,i.latitude,r.longitude,r.latitude),t._start=a.Cartographic.clone(i,t._start),t._end=a.Cartographic.clone(r,t._end),t._start.height=0,t._end.height=0,function(t){const a=t._uSquared,i=t._ellipsoid.maximumRadius,n=t._ellipsoid.minimumRadius,e=(i-n)/i,s=Math.cos(t._startHeading),o=Math.sin(t._startHeading),r=(1-e)*Math.tan(t._start.latitude),h=1/Math.sqrt(1+r*r),c=h*r,d=Math.atan2(r,s),u=h*o,l=u*u,M=1-l,g=Math.sqrt(M),_=a/4,p=_*_,f=p*_,m=p*p,H=1+_-3*p/4+5*f/4-175*m/64,C=1-_+15*p/8-35*f/8,v=1-3*_+35*p/4,O=1-5*_,S=H*d-C*Math.sin(2*d)*_/2-v*Math.sin(4*d)*p/16-O*Math.sin(6*d)*f/48-5*Math.sin(8*d)*m/512,q=t._constants;q.a=i,q.b=n,q.f=e,q.cosineHeading=s,q.sineHeading=o,q.tanU=r,q.cosineU=h,q.sineU=c,q.sigma=d,q.sineAlpha=u,q.sineSquaredAlpha=l,q.cosineSquaredAlpha=M,q.cosineAlpha=g,q.u2Over4=_,q.u4Over16=p,q.u6Over64=f,q.u8Over256=m,q.a0=H,q.a1=C,q.a2=v,q.a3=O,q.distanceRatio=S}(t)}function h(t,n,e){const s=i.defaultValue(e,a.Ellipsoid.WGS84);this._ellipsoid=s,this._start=new a.Cartographic,this._end=new a.Cartographic,this._constants={},this._startHeading=void 0,this._endHeading=void 0,this._distance=void 0,this._uSquared=void 0,i.defined(t)&&i.defined(n)&&r(this,t,n,s)}Object.defineProperties(h.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},surfaceDistance:{get:function(){return this._distance}},start:{get:function(){return this._start}},end:{get:function(){return this._end}},startHeading:{get:function(){return this._startHeading}},endHeading:{get:function(){return this._endHeading}}}),h.prototype.setEndPoints=function(t,a){r(this,t,a,this._ellipsoid)},h.prototype.interpolateUsingFraction=function(t,a){return this.interpolateUsingSurfaceDistance(this._distance*t,a)},h.prototype.interpolateUsingSurfaceDistance=function(t,n){const s=this._constants,o=s.distanceRatio+t/s.b,r=Math.cos(2*o),h=Math.cos(4*o),c=Math.cos(6*o),d=Math.sin(2*o),u=Math.sin(4*o),l=Math.sin(6*o),M=Math.sin(8*o),g=o*o,_=o*g,p=s.u8Over256,f=s.u2Over4,m=s.u6Over64,H=s.u4Over16;let C=2*_*p*r/3+o*(1-f+7*H/4-15*m/4+579*p/64-(H-15*m/4+187*p/16)*r-(5*m/4-115*p/16)*h-29*p*c/16)+(f/2-H+71*m/32-85*p/16)*d+(5*H/16-5*m/4+383*p/96)*u-g*((m-11*p/2)*d+5*p*u/2)+(29*m/96-29*p/16)*l+539*p*M/1536;const v=Math.asin(Math.sin(C)*s.cosineAlpha),O=Math.atan(s.a/s.b*Math.tan(v));C-=s.sigma;const S=Math.cos(2*s.sigma+C),q=Math.sin(C),U=Math.cos(C),A=s.cosineU*U,w=s.sineU*q,R=Math.atan2(q*s.sineHeading,A-w*s.cosineHeading)-e(s.f,s.sineAlpha,s.cosineSquaredAlpha,C,q,U,S);return i.defined(n)?(n.longitude=this._start.longitude+R,n.latitude=O,n.height=0,n):new a.Cartographic(this._start.longitude+R,O,0)},t.EllipsoidGeodesic=h}));

View File

@ -1,413 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09'], function (exports, when, Check, _Math, Cartographic, Cartesian2) { 'use strict';
function setConstants(ellipsoidGeodesic) {
var uSquared = ellipsoidGeodesic._uSquared;
var a = ellipsoidGeodesic._ellipsoid.maximumRadius;
var b = ellipsoidGeodesic._ellipsoid.minimumRadius;
var f = (a - b) / a;
var cosineHeading = Math.cos(ellipsoidGeodesic._startHeading);
var sineHeading = Math.sin(ellipsoidGeodesic._startHeading);
var tanU = (1 - f) * Math.tan(ellipsoidGeodesic._start.latitude);
var cosineU = 1.0 / Math.sqrt(1.0 + tanU * tanU);
var sineU = cosineU * tanU;
var sigma = Math.atan2(tanU, cosineHeading);
var sineAlpha = cosineU * sineHeading;
var sineSquaredAlpha = sineAlpha * sineAlpha;
var cosineSquaredAlpha = 1.0 - sineSquaredAlpha;
var cosineAlpha = Math.sqrt(cosineSquaredAlpha);
var u2Over4 = uSquared / 4.0;
var u4Over16 = u2Over4 * u2Over4;
var u6Over64 = u4Over16 * u2Over4;
var u8Over256 = u4Over16 * u4Over16;
var a0 = (1.0 + u2Over4 - 3.0 * u4Over16 / 4.0 + 5.0 * u6Over64 / 4.0 - 175.0 * u8Over256 / 64.0);
var a1 = (1.0 - u2Over4 + 15.0 * u4Over16 / 8.0 - 35.0 * u6Over64 / 8.0);
var a2 = (1.0 - 3.0 * u2Over4 + 35.0 * u4Over16 / 4.0);
var a3 = (1.0 - 5.0 * u2Over4);
var distanceRatio = a0 * sigma - a1 * Math.sin(2.0 * sigma) * u2Over4 / 2.0 - a2 * Math.sin(4.0 * sigma) * u4Over16 / 16.0 -
a3 * Math.sin(6.0 * sigma) * u6Over64 / 48.0 - Math.sin(8.0 * sigma) * 5.0 * u8Over256 / 512;
var constants = ellipsoidGeodesic._constants;
constants.a = a;
constants.b = b;
constants.f = f;
constants.cosineHeading = cosineHeading;
constants.sineHeading = sineHeading;
constants.tanU = tanU;
constants.cosineU = cosineU;
constants.sineU = sineU;
constants.sigma = sigma;
constants.sineAlpha = sineAlpha;
constants.sineSquaredAlpha = sineSquaredAlpha;
constants.cosineSquaredAlpha = cosineSquaredAlpha;
constants.cosineAlpha = cosineAlpha;
constants.u2Over4 = u2Over4;
constants.u4Over16 = u4Over16;
constants.u6Over64 = u6Over64;
constants.u8Over256 = u8Over256;
constants.a0 = a0;
constants.a1 = a1;
constants.a2 = a2;
constants.a3 = a3;
constants.distanceRatio = distanceRatio;
}
function computeC(f, cosineSquaredAlpha) {
return f * cosineSquaredAlpha * (4.0 + f * (4.0 - 3.0 * cosineSquaredAlpha)) / 16.0;
}
function computeDeltaLambda(f, sineAlpha, cosineSquaredAlpha, sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint) {
var C = computeC(f, cosineSquaredAlpha);
return (1.0 - C) * f * sineAlpha * (sigma + C * sineSigma * (cosineTwiceSigmaMidpoint +
C * cosineSigma * (2.0 * cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint - 1.0)));
}
function vincentyInverseFormula(ellipsoidGeodesic, major, minor, firstLongitude, firstLatitude, secondLongitude, secondLatitude) {
var eff = (major - minor) / major;
var l = secondLongitude - firstLongitude;
var u1 = Math.atan((1 - eff) * Math.tan(firstLatitude));
var u2 = Math.atan((1 - eff) * Math.tan(secondLatitude));
var cosineU1 = Math.cos(u1);
var sineU1 = Math.sin(u1);
var cosineU2 = Math.cos(u2);
var sineU2 = Math.sin(u2);
var cc = cosineU1 * cosineU2;
var cs = cosineU1 * sineU2;
var ss = sineU1 * sineU2;
var sc = sineU1 * cosineU2;
var lambda = l;
var lambdaDot = _Math.CesiumMath.TWO_PI;
var cosineLambda = Math.cos(lambda);
var sineLambda = Math.sin(lambda);
var sigma;
var cosineSigma;
var sineSigma;
var cosineSquaredAlpha;
var cosineTwiceSigmaMidpoint;
do {
cosineLambda = Math.cos(lambda);
sineLambda = Math.sin(lambda);
var temp = cs - sc * cosineLambda;
sineSigma = Math.sqrt(cosineU2 * cosineU2 * sineLambda * sineLambda + temp * temp);
cosineSigma = ss + cc * cosineLambda;
sigma = Math.atan2(sineSigma, cosineSigma);
var sineAlpha;
if (sineSigma === 0.0) {
sineAlpha = 0.0;
cosineSquaredAlpha = 1.0;
} else {
sineAlpha = cc * sineLambda / sineSigma;
cosineSquaredAlpha = 1.0 - sineAlpha * sineAlpha;
}
lambdaDot = lambda;
cosineTwiceSigmaMidpoint = cosineSigma - 2.0 * ss / cosineSquaredAlpha;
if (isNaN(cosineTwiceSigmaMidpoint)) {
cosineTwiceSigmaMidpoint = 0.0;
}
lambda = l + computeDeltaLambda(eff, sineAlpha, cosineSquaredAlpha,
sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint);
} while (Math.abs(lambda - lambdaDot) > _Math.CesiumMath.EPSILON12);
var uSquared = cosineSquaredAlpha * (major * major - minor * minor) / (minor * minor);
var A = 1.0 + uSquared * (4096.0 + uSquared * (uSquared * (320.0 - 175.0 * uSquared) - 768.0)) / 16384.0;
var B = uSquared * (256.0 + uSquared * (uSquared * (74.0 - 47.0 * uSquared) - 128.0)) / 1024.0;
var cosineSquaredTwiceSigmaMidpoint = cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint;
var deltaSigma = B * sineSigma * (cosineTwiceSigmaMidpoint + B * (cosineSigma *
(2.0 * cosineSquaredTwiceSigmaMidpoint - 1.0) - B * cosineTwiceSigmaMidpoint *
(4.0 * sineSigma * sineSigma - 3.0) * (4.0 * cosineSquaredTwiceSigmaMidpoint - 3.0) / 6.0) / 4.0);
var distance = minor * A * (sigma - deltaSigma);
var startHeading = Math.atan2(cosineU2 * sineLambda, cs - sc * cosineLambda);
var endHeading = Math.atan2(cosineU1 * sineLambda, cs * cosineLambda - sc);
ellipsoidGeodesic._distance = distance;
ellipsoidGeodesic._startHeading = startHeading;
ellipsoidGeodesic._endHeading = endHeading;
ellipsoidGeodesic._uSquared = uSquared;
}
var scratchCart1 = new Cartographic.Cartesian3();
var scratchCart2 = new Cartographic.Cartesian3();
function computeProperties(ellipsoidGeodesic, start, end, ellipsoid) {
var firstCartesian = Cartographic.Cartesian3.normalize(ellipsoid.cartographicToCartesian(start, scratchCart2), scratchCart1);
var lastCartesian = Cartographic.Cartesian3.normalize(ellipsoid.cartographicToCartesian(end, scratchCart2), scratchCart2);
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.number.greaterThanOrEquals('value', Math.abs(Math.abs(Cartographic.Cartesian3.angleBetween(firstCartesian, lastCartesian)) - Math.PI), 0.0125);
//>>includeEnd('debug');
vincentyInverseFormula(ellipsoidGeodesic, ellipsoid.maximumRadius, ellipsoid.minimumRadius,
start.longitude, start.latitude, end.longitude, end.latitude);
ellipsoidGeodesic._start = Cartographic.Cartographic.clone(start, ellipsoidGeodesic._start);
ellipsoidGeodesic._end = Cartographic.Cartographic.clone(end, ellipsoidGeodesic._end);
ellipsoidGeodesic._start.height = 0;
ellipsoidGeodesic._end.height = 0;
setConstants(ellipsoidGeodesic);
}
/**
* Initializes a geodesic on the ellipsoid connecting the two provided planetodetic points.
*
* @alias EllipsoidGeodesic
* @constructor
*
* @param {Cartographic} [start] The initial planetodetic point on the path.
* @param {Cartographic} [end] The final planetodetic point on the path.
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the geodesic lies.
*/
function EllipsoidGeodesic(start, end, ellipsoid) {
var e = when.defaultValue(ellipsoid, Cartesian2.Ellipsoid.WGS84);
this._ellipsoid = e;
this._start = new Cartographic.Cartographic();
this._end = new Cartographic.Cartographic();
this._constants = {};
this._startHeading = undefined;
this._endHeading = undefined;
this._distance = undefined;
this._uSquared = undefined;
if (when.defined(start) && when.defined(end)) {
computeProperties(this, start, end, e);
}
}
Object.defineProperties(EllipsoidGeodesic.prototype, {
/**
* Gets the ellipsoid.
* @memberof EllipsoidGeodesic.prototype
* @type {Ellipsoid}
* @readonly
*/
ellipsoid : {
get : function() {
return this._ellipsoid;
}
},
/**
* Gets the surface distance between the start and end point
* @memberof EllipsoidGeodesic.prototype
* @type {Number}
* @readonly
*/
surfaceDistance : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
return this._distance;
}
},
/**
* Gets the initial planetodetic point on the path.
* @memberof EllipsoidGeodesic.prototype
* @type {Cartographic}
* @readonly
*/
start : {
get : function() {
return this._start;
}
},
/**
* Gets the final planetodetic point on the path.
* @memberof EllipsoidGeodesic.prototype
* @type {Cartographic}
* @readonly
*/
end : {
get : function() {
return this._end;
}
},
/**
* Gets the heading at the initial point.
* @memberof EllipsoidGeodesic.prototype
* @type {Number}
* @readonly
*/
startHeading : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
return this._startHeading;
}
},
/**
* Gets the heading at the final point.
* @memberof EllipsoidGeodesic.prototype
* @type {Number}
* @readonly
*/
endHeading : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
return this._endHeading;
}
}
});
/**
* Sets the start and end points of the geodesic
*
* @param {Cartographic} start The initial planetodetic point on the path.
* @param {Cartographic} end The final planetodetic point on the path.
*/
EllipsoidGeodesic.prototype.setEndPoints = function(start, end) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('start', start);
Check.Check.defined('end', end);
//>>includeEnd('debug');
computeProperties(this, start, end, this._ellipsoid);
};
/**
* Provides the location of a point at the indicated portion along the geodesic.
*
* @param {Number} fraction The portion of the distance between the initial and final points.
* @param {Cartographic} result The object in which to store the result.
* @returns {Cartographic} The location of the point along the geodesic.
*/
EllipsoidGeodesic.prototype.interpolateUsingFraction = function(fraction, result) {
return this.interpolateUsingSurfaceDistance(this._distance * fraction, result);
};
/**
* Provides the location of a point at the indicated distance along the geodesic.
*
* @param {Number} distance The distance from the inital point to the point of interest along the geodesic
* @param {Cartographic} result The object in which to store the result.
* @returns {Cartographic} The location of the point along the geodesic.
*
* @exception {DeveloperError} start and end must be set before calling function interpolateUsingSurfaceDistance
*/
EllipsoidGeodesic.prototype.interpolateUsingSurfaceDistance = function(distance, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
var constants = this._constants;
var s = constants.distanceRatio + distance / constants.b;
var cosine2S = Math.cos(2.0 * s);
var cosine4S = Math.cos(4.0 * s);
var cosine6S = Math.cos(6.0 * s);
var sine2S = Math.sin(2.0 * s);
var sine4S = Math.sin(4.0 * s);
var sine6S = Math.sin(6.0 * s);
var sine8S = Math.sin(8.0 * s);
var s2 = s * s;
var s3 = s * s2;
var u8Over256 = constants.u8Over256;
var u2Over4 = constants.u2Over4;
var u6Over64 = constants.u6Over64;
var u4Over16 = constants.u4Over16;
var sigma = 2.0 * s3 * u8Over256 * cosine2S / 3.0 +
s * (1.0 - u2Over4 + 7.0 * u4Over16 / 4.0 - 15.0 * u6Over64 / 4.0 + 579.0 * u8Over256 / 64.0 -
(u4Over16 - 15.0 * u6Over64 / 4.0 + 187.0 * u8Over256 / 16.0) * cosine2S -
(5.0 * u6Over64 / 4.0 - 115.0 * u8Over256 / 16.0) * cosine4S -
29.0 * u8Over256 * cosine6S / 16.0) +
(u2Over4 / 2.0 - u4Over16 + 71.0 * u6Over64 / 32.0 - 85.0 * u8Over256 / 16.0) * sine2S +
(5.0 * u4Over16 / 16.0 - 5.0 * u6Over64 / 4.0 + 383.0 * u8Over256 / 96.0) * sine4S -
s2 * ((u6Over64 - 11.0 * u8Over256 / 2.0) * sine2S + 5.0 * u8Over256 * sine4S / 2.0) +
(29.0 * u6Over64 / 96.0 - 29.0 * u8Over256 / 16.0) * sine6S +
539.0 * u8Over256 * sine8S / 1536.0;
var theta = Math.asin(Math.sin(sigma) * constants.cosineAlpha);
var latitude = Math.atan(constants.a / constants.b * Math.tan(theta));
// Redefine in terms of relative argument of latitude.
sigma = sigma - constants.sigma;
var cosineTwiceSigmaMidpoint = Math.cos(2.0 * constants.sigma + sigma);
var sineSigma = Math.sin(sigma);
var cosineSigma = Math.cos(sigma);
var cc = constants.cosineU * cosineSigma;
var ss = constants.sineU * sineSigma;
var lambda = Math.atan2(sineSigma * constants.sineHeading, cc - ss * constants.cosineHeading);
var l = lambda - computeDeltaLambda(constants.f, constants.sineAlpha, constants.cosineSquaredAlpha,
sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint);
if (when.defined(result)) {
result.longitude = this._start.longitude + l;
result.latitude = latitude;
result.height = 0.0;
return result;
}
return new Cartographic.Cartographic(this._start.longitude + l, latitude, 0.0);
};
exports.EllipsoidGeodesic = EllipsoidGeodesic;
});

View File

@ -1,413 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632'], function (exports, when, Check, _Math, Cartographic, Cartesian2) { 'use strict';
function setConstants(ellipsoidGeodesic) {
var uSquared = ellipsoidGeodesic._uSquared;
var a = ellipsoidGeodesic._ellipsoid.maximumRadius;
var b = ellipsoidGeodesic._ellipsoid.minimumRadius;
var f = (a - b) / a;
var cosineHeading = Math.cos(ellipsoidGeodesic._startHeading);
var sineHeading = Math.sin(ellipsoidGeodesic._startHeading);
var tanU = (1 - f) * Math.tan(ellipsoidGeodesic._start.latitude);
var cosineU = 1.0 / Math.sqrt(1.0 + tanU * tanU);
var sineU = cosineU * tanU;
var sigma = Math.atan2(tanU, cosineHeading);
var sineAlpha = cosineU * sineHeading;
var sineSquaredAlpha = sineAlpha * sineAlpha;
var cosineSquaredAlpha = 1.0 - sineSquaredAlpha;
var cosineAlpha = Math.sqrt(cosineSquaredAlpha);
var u2Over4 = uSquared / 4.0;
var u4Over16 = u2Over4 * u2Over4;
var u6Over64 = u4Over16 * u2Over4;
var u8Over256 = u4Over16 * u4Over16;
var a0 = (1.0 + u2Over4 - 3.0 * u4Over16 / 4.0 + 5.0 * u6Over64 / 4.0 - 175.0 * u8Over256 / 64.0);
var a1 = (1.0 - u2Over4 + 15.0 * u4Over16 / 8.0 - 35.0 * u6Over64 / 8.0);
var a2 = (1.0 - 3.0 * u2Over4 + 35.0 * u4Over16 / 4.0);
var a3 = (1.0 - 5.0 * u2Over4);
var distanceRatio = a0 * sigma - a1 * Math.sin(2.0 * sigma) * u2Over4 / 2.0 - a2 * Math.sin(4.0 * sigma) * u4Over16 / 16.0 -
a3 * Math.sin(6.0 * sigma) * u6Over64 / 48.0 - Math.sin(8.0 * sigma) * 5.0 * u8Over256 / 512;
var constants = ellipsoidGeodesic._constants;
constants.a = a;
constants.b = b;
constants.f = f;
constants.cosineHeading = cosineHeading;
constants.sineHeading = sineHeading;
constants.tanU = tanU;
constants.cosineU = cosineU;
constants.sineU = sineU;
constants.sigma = sigma;
constants.sineAlpha = sineAlpha;
constants.sineSquaredAlpha = sineSquaredAlpha;
constants.cosineSquaredAlpha = cosineSquaredAlpha;
constants.cosineAlpha = cosineAlpha;
constants.u2Over4 = u2Over4;
constants.u4Over16 = u4Over16;
constants.u6Over64 = u6Over64;
constants.u8Over256 = u8Over256;
constants.a0 = a0;
constants.a1 = a1;
constants.a2 = a2;
constants.a3 = a3;
constants.distanceRatio = distanceRatio;
}
function computeC(f, cosineSquaredAlpha) {
return f * cosineSquaredAlpha * (4.0 + f * (4.0 - 3.0 * cosineSquaredAlpha)) / 16.0;
}
function computeDeltaLambda(f, sineAlpha, cosineSquaredAlpha, sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint) {
var C = computeC(f, cosineSquaredAlpha);
return (1.0 - C) * f * sineAlpha * (sigma + C * sineSigma * (cosineTwiceSigmaMidpoint +
C * cosineSigma * (2.0 * cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint - 1.0)));
}
function vincentyInverseFormula(ellipsoidGeodesic, major, minor, firstLongitude, firstLatitude, secondLongitude, secondLatitude) {
var eff = (major - minor) / major;
var l = secondLongitude - firstLongitude;
var u1 = Math.atan((1 - eff) * Math.tan(firstLatitude));
var u2 = Math.atan((1 - eff) * Math.tan(secondLatitude));
var cosineU1 = Math.cos(u1);
var sineU1 = Math.sin(u1);
var cosineU2 = Math.cos(u2);
var sineU2 = Math.sin(u2);
var cc = cosineU1 * cosineU2;
var cs = cosineU1 * sineU2;
var ss = sineU1 * sineU2;
var sc = sineU1 * cosineU2;
var lambda = l;
var lambdaDot = _Math.CesiumMath.TWO_PI;
var cosineLambda = Math.cos(lambda);
var sineLambda = Math.sin(lambda);
var sigma;
var cosineSigma;
var sineSigma;
var cosineSquaredAlpha;
var cosineTwiceSigmaMidpoint;
do {
cosineLambda = Math.cos(lambda);
sineLambda = Math.sin(lambda);
var temp = cs - sc * cosineLambda;
sineSigma = Math.sqrt(cosineU2 * cosineU2 * sineLambda * sineLambda + temp * temp);
cosineSigma = ss + cc * cosineLambda;
sigma = Math.atan2(sineSigma, cosineSigma);
var sineAlpha;
if (sineSigma === 0.0) {
sineAlpha = 0.0;
cosineSquaredAlpha = 1.0;
} else {
sineAlpha = cc * sineLambda / sineSigma;
cosineSquaredAlpha = 1.0 - sineAlpha * sineAlpha;
}
lambdaDot = lambda;
cosineTwiceSigmaMidpoint = cosineSigma - 2.0 * ss / cosineSquaredAlpha;
if (isNaN(cosineTwiceSigmaMidpoint)) {
cosineTwiceSigmaMidpoint = 0.0;
}
lambda = l + computeDeltaLambda(eff, sineAlpha, cosineSquaredAlpha,
sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint);
} while (Math.abs(lambda - lambdaDot) > _Math.CesiumMath.EPSILON12);
var uSquared = cosineSquaredAlpha * (major * major - minor * minor) / (minor * minor);
var A = 1.0 + uSquared * (4096.0 + uSquared * (uSquared * (320.0 - 175.0 * uSquared) - 768.0)) / 16384.0;
var B = uSquared * (256.0 + uSquared * (uSquared * (74.0 - 47.0 * uSquared) - 128.0)) / 1024.0;
var cosineSquaredTwiceSigmaMidpoint = cosineTwiceSigmaMidpoint * cosineTwiceSigmaMidpoint;
var deltaSigma = B * sineSigma * (cosineTwiceSigmaMidpoint + B * (cosineSigma *
(2.0 * cosineSquaredTwiceSigmaMidpoint - 1.0) - B * cosineTwiceSigmaMidpoint *
(4.0 * sineSigma * sineSigma - 3.0) * (4.0 * cosineSquaredTwiceSigmaMidpoint - 3.0) / 6.0) / 4.0);
var distance = minor * A * (sigma - deltaSigma);
var startHeading = Math.atan2(cosineU2 * sineLambda, cs - sc * cosineLambda);
var endHeading = Math.atan2(cosineU1 * sineLambda, cs * cosineLambda - sc);
ellipsoidGeodesic._distance = distance;
ellipsoidGeodesic._startHeading = startHeading;
ellipsoidGeodesic._endHeading = endHeading;
ellipsoidGeodesic._uSquared = uSquared;
}
var scratchCart1 = new Cartographic.Cartesian3();
var scratchCart2 = new Cartographic.Cartesian3();
function computeProperties(ellipsoidGeodesic, start, end, ellipsoid) {
var firstCartesian = Cartographic.Cartesian3.normalize(ellipsoid.cartographicToCartesian(start, scratchCart2), scratchCart1);
var lastCartesian = Cartographic.Cartesian3.normalize(ellipsoid.cartographicToCartesian(end, scratchCart2), scratchCart2);
//>>includeStart('debug', pragmas.debug);
Check.Check.typeOf.number.greaterThanOrEquals('value', Math.abs(Math.abs(Cartographic.Cartesian3.angleBetween(firstCartesian, lastCartesian)) - Math.PI), 0.0125);
//>>includeEnd('debug');
vincentyInverseFormula(ellipsoidGeodesic, ellipsoid.maximumRadius, ellipsoid.minimumRadius,
start.longitude, start.latitude, end.longitude, end.latitude);
ellipsoidGeodesic._start = Cartographic.Cartographic.clone(start, ellipsoidGeodesic._start);
ellipsoidGeodesic._end = Cartographic.Cartographic.clone(end, ellipsoidGeodesic._end);
ellipsoidGeodesic._start.height = 0;
ellipsoidGeodesic._end.height = 0;
setConstants(ellipsoidGeodesic);
}
/**
* Initializes a geodesic on the ellipsoid connecting the two provided planetodetic points.
*
* @alias EllipsoidGeodesic
* @constructor
*
* @param {Cartographic} [start] The initial planetodetic point on the path.
* @param {Cartographic} [end] The final planetodetic point on the path.
* @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid on which the geodesic lies.
*/
function EllipsoidGeodesic(start, end, ellipsoid) {
var e = when.defaultValue(ellipsoid, Cartesian2.Ellipsoid.WGS84);
this._ellipsoid = e;
this._start = new Cartographic.Cartographic();
this._end = new Cartographic.Cartographic();
this._constants = {};
this._startHeading = undefined;
this._endHeading = undefined;
this._distance = undefined;
this._uSquared = undefined;
if (when.defined(start) && when.defined(end)) {
computeProperties(this, start, end, e);
}
}
Object.defineProperties(EllipsoidGeodesic.prototype, {
/**
* Gets the ellipsoid.
* @memberof EllipsoidGeodesic.prototype
* @type {Ellipsoid}
* @readonly
*/
ellipsoid : {
get : function() {
return this._ellipsoid;
}
},
/**
* Gets the surface distance between the start and end point
* @memberof EllipsoidGeodesic.prototype
* @type {Number}
* @readonly
*/
surfaceDistance : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
return this._distance;
}
},
/**
* Gets the initial planetodetic point on the path.
* @memberof EllipsoidGeodesic.prototype
* @type {Cartographic}
* @readonly
*/
start : {
get : function() {
return this._start;
}
},
/**
* Gets the final planetodetic point on the path.
* @memberof EllipsoidGeodesic.prototype
* @type {Cartographic}
* @readonly
*/
end : {
get : function() {
return this._end;
}
},
/**
* Gets the heading at the initial point.
* @memberof EllipsoidGeodesic.prototype
* @type {Number}
* @readonly
*/
startHeading : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
return this._startHeading;
}
},
/**
* Gets the heading at the final point.
* @memberof EllipsoidGeodesic.prototype
* @type {Number}
* @readonly
*/
endHeading : {
get : function() {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
return this._endHeading;
}
}
});
/**
* Sets the start and end points of the geodesic
*
* @param {Cartographic} start The initial planetodetic point on the path.
* @param {Cartographic} end The final planetodetic point on the path.
*/
EllipsoidGeodesic.prototype.setEndPoints = function(start, end) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('start', start);
Check.Check.defined('end', end);
//>>includeEnd('debug');
computeProperties(this, start, end, this._ellipsoid);
};
/**
* Provides the location of a point at the indicated portion along the geodesic.
*
* @param {Number} fraction The portion of the distance between the initial and final points.
* @param {Cartographic} result The object in which to store the result.
* @returns {Cartographic} The location of the point along the geodesic.
*/
EllipsoidGeodesic.prototype.interpolateUsingFraction = function(fraction, result) {
return this.interpolateUsingSurfaceDistance(this._distance * fraction, result);
};
/**
* Provides the location of a point at the indicated distance along the geodesic.
*
* @param {Number} distance The distance from the inital point to the point of interest along the geodesic
* @param {Cartographic} result The object in which to store the result.
* @returns {Cartographic} The location of the point along the geodesic.
*
* @exception {DeveloperError} start and end must be set before calling function interpolateUsingSurfaceDistance
*/
EllipsoidGeodesic.prototype.interpolateUsingSurfaceDistance = function(distance, result) {
//>>includeStart('debug', pragmas.debug);
Check.Check.defined('distance', this._distance);
//>>includeEnd('debug');
var constants = this._constants;
var s = constants.distanceRatio + distance / constants.b;
var cosine2S = Math.cos(2.0 * s);
var cosine4S = Math.cos(4.0 * s);
var cosine6S = Math.cos(6.0 * s);
var sine2S = Math.sin(2.0 * s);
var sine4S = Math.sin(4.0 * s);
var sine6S = Math.sin(6.0 * s);
var sine8S = Math.sin(8.0 * s);
var s2 = s * s;
var s3 = s * s2;
var u8Over256 = constants.u8Over256;
var u2Over4 = constants.u2Over4;
var u6Over64 = constants.u6Over64;
var u4Over16 = constants.u4Over16;
var sigma = 2.0 * s3 * u8Over256 * cosine2S / 3.0 +
s * (1.0 - u2Over4 + 7.0 * u4Over16 / 4.0 - 15.0 * u6Over64 / 4.0 + 579.0 * u8Over256 / 64.0 -
(u4Over16 - 15.0 * u6Over64 / 4.0 + 187.0 * u8Over256 / 16.0) * cosine2S -
(5.0 * u6Over64 / 4.0 - 115.0 * u8Over256 / 16.0) * cosine4S -
29.0 * u8Over256 * cosine6S / 16.0) +
(u2Over4 / 2.0 - u4Over16 + 71.0 * u6Over64 / 32.0 - 85.0 * u8Over256 / 16.0) * sine2S +
(5.0 * u4Over16 / 16.0 - 5.0 * u6Over64 / 4.0 + 383.0 * u8Over256 / 96.0) * sine4S -
s2 * ((u6Over64 - 11.0 * u8Over256 / 2.0) * sine2S + 5.0 * u8Over256 * sine4S / 2.0) +
(29.0 * u6Over64 / 96.0 - 29.0 * u8Over256 / 16.0) * sine6S +
539.0 * u8Over256 * sine8S / 1536.0;
var theta = Math.asin(Math.sin(sigma) * constants.cosineAlpha);
var latitude = Math.atan(constants.a / constants.b * Math.tan(theta));
// Redefine in terms of relative argument of latitude.
sigma = sigma - constants.sigma;
var cosineTwiceSigmaMidpoint = Math.cos(2.0 * constants.sigma + sigma);
var sineSigma = Math.sin(sigma);
var cosineSigma = Math.cos(sigma);
var cc = constants.cosineU * cosineSigma;
var ss = constants.sineU * sineSigma;
var lambda = Math.atan2(sineSigma * constants.sineHeading, cc - ss * constants.cosineHeading);
var l = lambda - computeDeltaLambda(constants.f, constants.sineAlpha, constants.cosineSquaredAlpha,
sigma, sineSigma, cosineSigma, cosineTwiceSigmaMidpoint);
if (when.defined(result)) {
result.longitude = this._start.longitude + l;
result.latitude = latitude;
result.height = 0.0;
return result;
}
return new Cartographic.Cartographic(this._start.longitude + l, latitude, 0.0);
};
exports.EllipsoidGeodesic = EllipsoidGeodesic;
});

File diff suppressed because one or more lines are too long

View File

@ -1,611 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-1e248a71', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var scratchPosition = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
var scratchTangent = new Cartographic.Cartesian3();
var scratchBitangent = new Cartographic.Cartesian3();
var scratchNormalST = new Cartographic.Cartesian3();
var defaultRadii = new Cartographic.Cartesian3(1.0, 1.0, 1.0);
var cos = Math.cos;
var sin = Math.sin;
/**
* A description of an ellipsoid centered at the origin.
*
* @alias EllipsoidGeometry
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Cartesian3} [options.radii=Cartesian3(1.0, 1.0, 1.0)] The radii of the ellipsoid in the x, y, and z directions.
* @param {Cartesian3} [options.innerRadii=options.radii] The inner radii of the ellipsoid in the x, y, and z directions.
* @param {Number} [options.minimumClock=0.0] The minimum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.maximumClock=2*PI] The maximum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.minimumCone=0.0] The minimum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.maximumCone=PI] The maximum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.stackPartitions=64] The number of times to partition the ellipsoid into stacks.
* @param {Number} [options.slicePartitions=64] The number of times to partition the ellipsoid into radial slices.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slicePartitions cannot be less than three.
* @exception {DeveloperError} options.stackPartitions cannot be less than three.
*
* @see EllipsoidGeometry#createGeometry
*
* @example
* var ellipsoid = new Cesium.EllipsoidGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* radii : new Cesium.Cartesian3(1000000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.EllipsoidGeometry.createGeometry(ellipsoid);
*/
function EllipsoidGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var radii = when.defaultValue(options.radii, defaultRadii);
var innerRadii = when.defaultValue(options.innerRadii, radii);
var minimumClock = when.defaultValue(options.minimumClock, 0.0);
var maximumClock = when.defaultValue(options.maximumClock, _Math.CesiumMath.TWO_PI);
var minimumCone = when.defaultValue(options.minimumCone, 0.0);
var maximumCone = when.defaultValue(options.maximumCone, _Math.CesiumMath.PI);
var stackPartitions = Math.round(when.defaultValue(options.stackPartitions, 64));
var slicePartitions = Math.round(when.defaultValue(options.slicePartitions, 64));
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
//>>includeStart('debug', pragmas.debug);
if (slicePartitions < 3) {
throw new Check.DeveloperError('options.slicePartitions cannot be less than three.');
}
if (stackPartitions < 3) {
throw new Check.DeveloperError('options.stackPartitions cannot be less than three.');
}
//>>includeEnd('debug');
this._radii = Cartographic.Cartesian3.clone(radii);
this._innerRadii = Cartographic.Cartesian3.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipsoidGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipsoidGeometry.packedLength = 2 * (Cartographic.Cartesian3.packedLength) + VertexFormat.VertexFormat.packedLength + 7;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipsoidGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipsoidGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartographic.Cartesian3.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartographic.Cartesian3();
var scratchInnerRadii = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
radii : scratchRadii,
innerRadii : scratchInnerRadii,
vertexFormat : scratchVertexFormat,
minimumClock : undefined,
maximumClock : undefined,
minimumCone : undefined,
maximumCone : undefined,
stackPartitions : undefined,
slicePartitions : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipsoidGeometry} [result] The object into which to store the result.
* @returns {EllipsoidGeometry} The modified result parameter or a new EllipsoidGeometry instance if one was not provided.
*/
EllipsoidGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var radii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var innerRadii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var minimumClock = array[startingIndex++];
var maximumClock = array[startingIndex++];
var minimumCone = array[startingIndex++];
var maximumCone = array[startingIndex++];
var stackPartitions = array[startingIndex++];
var slicePartitions = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.minimumClock = minimumClock;
scratchOptions.maximumClock = maximumClock;
scratchOptions.minimumCone = minimumCone;
scratchOptions.maximumCone = maximumCone;
scratchOptions.stackPartitions = stackPartitions;
scratchOptions.slicePartitions = slicePartitions;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipsoidGeometry(scratchOptions);
}
result._radii = Cartographic.Cartesian3.clone(radii, result._radii);
result._innerRadii = Cartographic.Cartesian3.clone(innerRadii, result._innerRadii);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipsoidGeometry} ellipsoidGeometry A description of the ellipsoid.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipsoidGeometry.createGeometry = function(ellipsoidGeometry) {
var radii = ellipsoidGeometry._radii;
if ((radii.x <= 0) || (radii.y <= 0) || (radii.z <= 0)) {
return;
}
var innerRadii = ellipsoidGeometry._innerRadii;
if ((innerRadii.x <= 0) || (innerRadii.y <= 0) || innerRadii.z <= 0) {
return;
}
var minimumClock = ellipsoidGeometry._minimumClock;
var maximumClock = ellipsoidGeometry._maximumClock;
var minimumCone = ellipsoidGeometry._minimumCone;
var maximumCone = ellipsoidGeometry._maximumCone;
var vertexFormat = ellipsoidGeometry._vertexFormat;
// Add an extra slice and stack so that the number of partitions is the
// number of surfaces rather than the number of joints
var slicePartitions = ellipsoidGeometry._slicePartitions + 1;
var stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(slicePartitions * Math.abs(maximumClock - minimumClock) / _Math.CesiumMath.TWO_PI);
stackPartitions = Math.round(stackPartitions * Math.abs(maximumCone - minimumCone) / _Math.CesiumMath.PI);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
var i;
var j;
var index = 0;
// Create arrays for theta and phi. Duplicate first and last angle to
// allow different normals at the intersections.
var phis = [minimumCone];
var thetas = [minimumClock];
for (i = 0; i < stackPartitions; i++) {
phis.push(minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1));
}
phis.push(maximumCone);
for (j = 0; j < slicePartitions; j++) {
thetas.push(minimumClock + j * (maximumClock - minimumClock) / (slicePartitions - 1));
}
thetas.push(maximumClock);
var numPhis = phis.length;
var numThetas = thetas.length;
// Allow for extra indices if there is an inner surface and if we need
// to close the sides if the clock range is not a full circle
var extraIndices = 0;
var vertexMultiplier = 1.0;
var hasInnerSurface = ((innerRadii.x !== radii.x) || (innerRadii.y !== radii.y) || innerRadii.z !== radii.z);
var isTopOpen = false;
var isBotOpen = false;
var isClockOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2.0;
if (minimumCone > 0.0) {
isTopOpen = true;
extraIndices += (slicePartitions - 1);
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += (slicePartitions - 1);
}
if ((maximumClock - minimumClock) % _Math.CesiumMath.TWO_PI) {
isClockOpen = true;
extraIndices += ((stackPartitions - 1) * 2) + 1;
} else {
extraIndices += 1;
}
}
var vertexCount = numThetas * numPhis * vertexMultiplier;
var positions = new Float64Array(vertexCount * 3);
var isInner = arrayFill.arrayFill(new Array(vertexCount), false);
var negateNormal = arrayFill.arrayFill(new Array(vertexCount), false);
// Multiply by 6 because there are two triangles per sector
var indexCount = slicePartitions * stackPartitions * vertexMultiplier;
var numIndices = 6 * (indexCount + extraIndices + 1 - (slicePartitions + stackPartitions) * vertexMultiplier);
var indices = IndexDatatype.IndexDatatype.createTypedArray(indexCount, numIndices);
var normals = (vertexFormat.normal) ? new Float32Array(vertexCount * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(vertexCount * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(vertexCount * 3) : undefined;
var st = (vertexFormat.st) ? new Float32Array(vertexCount * 2) : undefined;
// Calculate sin/cos phi
var sinPhi = new Array(numPhis);
var cosPhi = new Array(numPhis);
for (i = 0; i < numPhis; i++) {
sinPhi[i] = sin(phis[i]);
cosPhi[i] = cos(phis[i]);
}
// Calculate sin/cos theta
var sinTheta = new Array(numThetas);
var cosTheta = new Array(numThetas);
for (j = 0; j < numThetas; j++) {
cosTheta[j] = cos(thetas[j]);
sinTheta[j] = sin(thetas[j]);
}
// Create outer surface
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Create inner surface
var vertexIndex = vertexCount / 2.0;
if (hasInnerSurface) {
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
// Keep track of which vertices are the inner and which ones
// need the normal to be negated
isInner[vertexIndex] = true;
if (i > 0 && i !== (numPhis - 1) && j !== 0 && j !== (numThetas - 1)) {
negateNormal[vertexIndex] = true;
}
vertexIndex++;
}
}
}
// Create indices for outer surface
index = 0;
var topOffset;
var bottomOffset;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = i * numThetas;
bottomOffset = (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = bottomOffset + j + 1;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = topOffset + j;
}
}
// Create indices for inner surface
if (hasInnerSurface) {
var offset = numPhis * numThetas;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = offset + i * numThetas;
bottomOffset = offset + (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j + 1;
}
}
}
var outerOffset;
var innerOffset;
if (hasInnerSurface) {
if (isTopOpen) {
// Connect the top of the inner surface to the top of the outer surface
innerOffset = numPhis * numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = i;
indices[index++] = i + 1;
indices[index++] = innerOffset + i + 1;
indices[index++] = i;
indices[index++] = innerOffset + i + 1;
indices[index++] = innerOffset + i;
}
}
if (isBotOpen) {
// Connect the bottom of the inner surface to the bottom of the outer surface
outerOffset = numPhis * numThetas - numThetas;
innerOffset = numPhis * numThetas * vertexMultiplier - numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = outerOffset + i + 1;
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
indices[index++] = outerOffset + i + 1;
indices[index++] = innerOffset + i;
indices[index++] = innerOffset + i + 1;
}
}
}
// Connect the edges if clock is not closed
if (isClockOpen) {
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * i);
outerOffset = numThetas * i;
indices[index++] = innerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = outerOffset;
indices[index++] = innerOffset;
indices[index++] = innerOffset + numThetas;
indices[index++] = outerOffset + numThetas;
}
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * (i + 1)) - 1;
outerOffset = numThetas * (i + 1) - 1;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset;
indices[index++] = outerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset + numThetas;
indices[index++] = innerOffset;
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
var stIndex = 0;
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var vertexCountHalf = vertexCount / 2.0;
var ellipsoid;
var ellipsoidOuter = Cartesian2.Ellipsoid.fromCartesian3(radii);
var ellipsoidInner = Cartesian2.Ellipsoid.fromCartesian3(innerRadii);
if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (i = 0; i < vertexCount; i++) {
ellipsoid = (isInner[i]) ? ellipsoidInner : ellipsoidOuter;
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, scratchPosition);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
if (negateNormal[i]) {
Cartographic.Cartesian3.negate(normal, normal);
}
if (vertexFormat.st) {
var normalST = Cartesian2.Cartesian2.negate(normal, scratchNormalST);
st[stIndex++] = (Math.atan2(normalST.y, normalST.x) / _Math.CesiumMath.TWO_PI) + 0.5;
st[stIndex++] = (Math.asin(normal.z) / Math.PI) + 0.5;
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
var tangent = scratchTangent;
// Use UNIT_X for the poles
var tangetOffset = 0;
var unit;
if (isInner[i]) {
tangetOffset = vertexCountHalf;
}
if ((!isTopOpen && (i >= tangetOffset && i < (tangetOffset + numThetas * 2)))) {
unit = Cartographic.Cartesian3.UNIT_X;
} else {
unit = Cartographic.Cartesian3.UNIT_Z;
}
Cartographic.Cartesian3.cross(unit, normal, tangent);
Cartographic.Cartesian3.normalize(tangent, tangent);
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
var bitangent = Cartographic.Cartesian3.cross(normal, tangent, scratchBitangent);
Cartographic.Cartesian3.normalize(bitangent, bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
}
if (when.defined(ellipsoidGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values : applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : BoundingSphere.BoundingSphere.fromEllipsoid(ellipsoidOuter),
offsetAttribute : ellipsoidGeometry._offsetAttribute
});
};
var unitEllipsoidGeometry;
/**
* Returns the geometric representation of a unit ellipsoid, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
EllipsoidGeometry.getUnitEllipsoid = function() {
if (!when.defined(unitEllipsoidGeometry)) {
unitEllipsoidGeometry = EllipsoidGeometry.createGeometry((new EllipsoidGeometry({
radii : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
})));
}
return unitEllipsoidGeometry;
};
exports.EllipsoidGeometry = EllipsoidGeometry;
});

View File

@ -1,611 +0,0 @@
/**
* Cesium - https://github.com/AnalyticalGraphicsInc/cesium
*
* Copyright 2011-2017 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-91704ebb', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './GeometryOffsetAttribute-ca302482', './VertexFormat-fe4db402'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var scratchPosition = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
var scratchTangent = new Cartographic.Cartesian3();
var scratchBitangent = new Cartographic.Cartesian3();
var scratchNormalST = new Cartographic.Cartesian3();
var defaultRadii = new Cartographic.Cartesian3(1.0, 1.0, 1.0);
var cos = Math.cos;
var sin = Math.sin;
/**
* A description of an ellipsoid centered at the origin.
*
* @alias EllipsoidGeometry
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Cartesian3} [options.radii=Cartesian3(1.0, 1.0, 1.0)] The radii of the ellipsoid in the x, y, and z directions.
* @param {Cartesian3} [options.innerRadii=options.radii] The inner radii of the ellipsoid in the x, y, and z directions.
* @param {Number} [options.minimumClock=0.0] The minimum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.maximumClock=2*PI] The maximum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.minimumCone=0.0] The minimum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.maximumCone=PI] The maximum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.stackPartitions=64] The number of times to partition the ellipsoid into stacks.
* @param {Number} [options.slicePartitions=64] The number of times to partition the ellipsoid into radial slices.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slicePartitions cannot be less than three.
* @exception {DeveloperError} options.stackPartitions cannot be less than three.
*
* @see EllipsoidGeometry#createGeometry
*
* @example
* var ellipsoid = new Cesium.EllipsoidGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* radii : new Cesium.Cartesian3(1000000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.EllipsoidGeometry.createGeometry(ellipsoid);
*/
function EllipsoidGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var radii = when.defaultValue(options.radii, defaultRadii);
var innerRadii = when.defaultValue(options.innerRadii, radii);
var minimumClock = when.defaultValue(options.minimumClock, 0.0);
var maximumClock = when.defaultValue(options.maximumClock, _Math.CesiumMath.TWO_PI);
var minimumCone = when.defaultValue(options.minimumCone, 0.0);
var maximumCone = when.defaultValue(options.maximumCone, _Math.CesiumMath.PI);
var stackPartitions = Math.round(when.defaultValue(options.stackPartitions, 64));
var slicePartitions = Math.round(when.defaultValue(options.slicePartitions, 64));
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
//>>includeStart('debug', pragmas.debug);
if (slicePartitions < 3) {
throw new Check.DeveloperError('options.slicePartitions cannot be less than three.');
}
if (stackPartitions < 3) {
throw new Check.DeveloperError('options.stackPartitions cannot be less than three.');
}
//>>includeEnd('debug');
this._radii = Cartographic.Cartesian3.clone(radii);
this._innerRadii = Cartographic.Cartesian3.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipsoidGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipsoidGeometry.packedLength = 2 * (Cartographic.Cartesian3.packedLength) + VertexFormat.VertexFormat.packedLength + 7;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipsoidGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipsoidGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartographic.Cartesian3.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartographic.Cartesian3();
var scratchInnerRadii = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
radii : scratchRadii,
innerRadii : scratchInnerRadii,
vertexFormat : scratchVertexFormat,
minimumClock : undefined,
maximumClock : undefined,
minimumCone : undefined,
maximumCone : undefined,
stackPartitions : undefined,
slicePartitions : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipsoidGeometry} [result] The object into which to store the result.
* @returns {EllipsoidGeometry} The modified result parameter or a new EllipsoidGeometry instance if one was not provided.
*/
EllipsoidGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var radii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var innerRadii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var minimumClock = array[startingIndex++];
var maximumClock = array[startingIndex++];
var minimumCone = array[startingIndex++];
var maximumCone = array[startingIndex++];
var stackPartitions = array[startingIndex++];
var slicePartitions = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.minimumClock = minimumClock;
scratchOptions.maximumClock = maximumClock;
scratchOptions.minimumCone = minimumCone;
scratchOptions.maximumCone = maximumCone;
scratchOptions.stackPartitions = stackPartitions;
scratchOptions.slicePartitions = slicePartitions;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipsoidGeometry(scratchOptions);
}
result._radii = Cartographic.Cartesian3.clone(radii, result._radii);
result._innerRadii = Cartographic.Cartesian3.clone(innerRadii, result._innerRadii);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipsoidGeometry} ellipsoidGeometry A description of the ellipsoid.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipsoidGeometry.createGeometry = function(ellipsoidGeometry) {
var radii = ellipsoidGeometry._radii;
if ((radii.x <= 0) || (radii.y <= 0) || (radii.z <= 0)) {
return;
}
var innerRadii = ellipsoidGeometry._innerRadii;
if ((innerRadii.x <= 0) || (innerRadii.y <= 0) || innerRadii.z <= 0) {
return;
}
var minimumClock = ellipsoidGeometry._minimumClock;
var maximumClock = ellipsoidGeometry._maximumClock;
var minimumCone = ellipsoidGeometry._minimumCone;
var maximumCone = ellipsoidGeometry._maximumCone;
var vertexFormat = ellipsoidGeometry._vertexFormat;
// Add an extra slice and stack so that the number of partitions is the
// number of surfaces rather than the number of joints
var slicePartitions = ellipsoidGeometry._slicePartitions + 1;
var stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(slicePartitions * Math.abs(maximumClock - minimumClock) / _Math.CesiumMath.TWO_PI);
stackPartitions = Math.round(stackPartitions * Math.abs(maximumCone - minimumCone) / _Math.CesiumMath.PI);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
var i;
var j;
var index = 0;
// Create arrays for theta and phi. Duplicate first and last angle to
// allow different normals at the intersections.
var phis = [minimumCone];
var thetas = [minimumClock];
for (i = 0; i < stackPartitions; i++) {
phis.push(minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1));
}
phis.push(maximumCone);
for (j = 0; j < slicePartitions; j++) {
thetas.push(minimumClock + j * (maximumClock - minimumClock) / (slicePartitions - 1));
}
thetas.push(maximumClock);
var numPhis = phis.length;
var numThetas = thetas.length;
// Allow for extra indices if there is an inner surface and if we need
// to close the sides if the clock range is not a full circle
var extraIndices = 0;
var vertexMultiplier = 1.0;
var hasInnerSurface = ((innerRadii.x !== radii.x) || (innerRadii.y !== radii.y) || innerRadii.z !== radii.z);
var isTopOpen = false;
var isBotOpen = false;
var isClockOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2.0;
if (minimumCone > 0.0) {
isTopOpen = true;
extraIndices += (slicePartitions - 1);
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += (slicePartitions - 1);
}
if ((maximumClock - minimumClock) % _Math.CesiumMath.TWO_PI) {
isClockOpen = true;
extraIndices += ((stackPartitions - 1) * 2) + 1;
} else {
extraIndices += 1;
}
}
var vertexCount = numThetas * numPhis * vertexMultiplier;
var positions = new Float64Array(vertexCount * 3);
var isInner = GeometryOffsetAttribute.arrayFill(new Array(vertexCount), false);
var negateNormal = GeometryOffsetAttribute.arrayFill(new Array(vertexCount), false);
// Multiply by 6 because there are two triangles per sector
var indexCount = slicePartitions * stackPartitions * vertexMultiplier;
var numIndices = 6 * (indexCount + extraIndices + 1 - (slicePartitions + stackPartitions) * vertexMultiplier);
var indices = IndexDatatype.IndexDatatype.createTypedArray(indexCount, numIndices);
var normals = (vertexFormat.normal) ? new Float32Array(vertexCount * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(vertexCount * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(vertexCount * 3) : undefined;
var st = (vertexFormat.st) ? new Float32Array(vertexCount * 2) : undefined;
// Calculate sin/cos phi
var sinPhi = new Array(numPhis);
var cosPhi = new Array(numPhis);
for (i = 0; i < numPhis; i++) {
sinPhi[i] = sin(phis[i]);
cosPhi[i] = cos(phis[i]);
}
// Calculate sin/cos theta
var sinTheta = new Array(numThetas);
var cosTheta = new Array(numThetas);
for (j = 0; j < numThetas; j++) {
cosTheta[j] = cos(thetas[j]);
sinTheta[j] = sin(thetas[j]);
}
// Create outer surface
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Create inner surface
var vertexIndex = vertexCount / 2.0;
if (hasInnerSurface) {
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
// Keep track of which vertices are the inner and which ones
// need the normal to be negated
isInner[vertexIndex] = true;
if (i > 0 && i !== (numPhis - 1) && j !== 0 && j !== (numThetas - 1)) {
negateNormal[vertexIndex] = true;
}
vertexIndex++;
}
}
}
// Create indices for outer surface
index = 0;
var topOffset;
var bottomOffset;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = i * numThetas;
bottomOffset = (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = bottomOffset + j + 1;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = topOffset + j;
}
}
// Create indices for inner surface
if (hasInnerSurface) {
var offset = numPhis * numThetas;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = offset + i * numThetas;
bottomOffset = offset + (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j + 1;
}
}
}
var outerOffset;
var innerOffset;
if (hasInnerSurface) {
if (isTopOpen) {
// Connect the top of the inner surface to the top of the outer surface
innerOffset = numPhis * numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = i;
indices[index++] = i + 1;
indices[index++] = innerOffset + i + 1;
indices[index++] = i;
indices[index++] = innerOffset + i + 1;
indices[index++] = innerOffset + i;
}
}
if (isBotOpen) {
// Connect the bottom of the inner surface to the bottom of the outer surface
outerOffset = numPhis * numThetas - numThetas;
innerOffset = numPhis * numThetas * vertexMultiplier - numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = outerOffset + i + 1;
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
indices[index++] = outerOffset + i + 1;
indices[index++] = innerOffset + i;
indices[index++] = innerOffset + i + 1;
}
}
}
// Connect the edges if clock is not closed
if (isClockOpen) {
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * i);
outerOffset = numThetas * i;
indices[index++] = innerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = outerOffset;
indices[index++] = innerOffset;
indices[index++] = innerOffset + numThetas;
indices[index++] = outerOffset + numThetas;
}
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * (i + 1)) - 1;
outerOffset = numThetas * (i + 1) - 1;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset;
indices[index++] = outerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset + numThetas;
indices[index++] = innerOffset;
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
var stIndex = 0;
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var vertexCountHalf = vertexCount / 2.0;
var ellipsoid;
var ellipsoidOuter = Cartesian2.Ellipsoid.fromCartesian3(radii);
var ellipsoidInner = Cartesian2.Ellipsoid.fromCartesian3(innerRadii);
if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (i = 0; i < vertexCount; i++) {
ellipsoid = (isInner[i]) ? ellipsoidInner : ellipsoidOuter;
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, scratchPosition);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
if (negateNormal[i]) {
Cartographic.Cartesian3.negate(normal, normal);
}
if (vertexFormat.st) {
var normalST = Cartesian2.Cartesian2.negate(normal, scratchNormalST);
st[stIndex++] = (Math.atan2(normalST.y, normalST.x) / _Math.CesiumMath.TWO_PI) + 0.5;
st[stIndex++] = (Math.asin(normal.z) / Math.PI) + 0.5;
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
var tangent = scratchTangent;
// Use UNIT_X for the poles
var tangetOffset = 0;
var unit;
if (isInner[i]) {
tangetOffset = vertexCountHalf;
}
if ((!isTopOpen && (i >= tangetOffset && i < (tangetOffset + numThetas * 2)))) {
unit = Cartographic.Cartesian3.UNIT_X;
} else {
unit = Cartographic.Cartesian3.UNIT_Z;
}
Cartographic.Cartesian3.cross(unit, normal, tangent);
Cartographic.Cartesian3.normalize(tangent, tangent);
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
var bitangent = Cartographic.Cartesian3.cross(normal, tangent, scratchBitangent);
Cartographic.Cartesian3.normalize(bitangent, bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
}
if (when.defined(ellipsoidGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
GeometryOffsetAttribute.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values : applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : BoundingSphere.BoundingSphere.fromEllipsoid(ellipsoidOuter),
offsetAttribute : ellipsoidGeometry._offsetAttribute
});
};
var unitEllipsoidGeometry;
/**
* Returns the geometric representation of a unit ellipsoid, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
EllipsoidGeometry.getUnitEllipsoid = function() {
if (!when.defined(unitEllipsoidGeometry)) {
unitEllipsoidGeometry = EllipsoidGeometry.createGeometry((new EllipsoidGeometry({
radii : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
})));
}
return unitEllipsoidGeometry;
};
exports.EllipsoidGeometry = EllipsoidGeometry;
});

View File

@ -1,611 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-773da12d', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var scratchPosition = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
var scratchTangent = new Cartographic.Cartesian3();
var scratchBitangent = new Cartographic.Cartesian3();
var scratchNormalST = new Cartographic.Cartesian3();
var defaultRadii = new Cartographic.Cartesian3(1.0, 1.0, 1.0);
var cos = Math.cos;
var sin = Math.sin;
/**
* A description of an ellipsoid centered at the origin.
*
* @alias EllipsoidGeometry
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Cartesian3} [options.radii=Cartesian3(1.0, 1.0, 1.0)] The radii of the ellipsoid in the x, y, and z directions.
* @param {Cartesian3} [options.innerRadii=options.radii] The inner radii of the ellipsoid in the x, y, and z directions.
* @param {Number} [options.minimumClock=0.0] The minimum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.maximumClock=2*PI] The maximum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.minimumCone=0.0] The minimum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.maximumCone=PI] The maximum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.stackPartitions=64] The number of times to partition the ellipsoid into stacks.
* @param {Number} [options.slicePartitions=64] The number of times to partition the ellipsoid into radial slices.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slicePartitions cannot be less than three.
* @exception {DeveloperError} options.stackPartitions cannot be less than three.
*
* @see EllipsoidGeometry#createGeometry
*
* @example
* var ellipsoid = new Cesium.EllipsoidGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* radii : new Cesium.Cartesian3(1000000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.EllipsoidGeometry.createGeometry(ellipsoid);
*/
function EllipsoidGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var radii = when.defaultValue(options.radii, defaultRadii);
var innerRadii = when.defaultValue(options.innerRadii, radii);
var minimumClock = when.defaultValue(options.minimumClock, 0.0);
var maximumClock = when.defaultValue(options.maximumClock, _Math.CesiumMath.TWO_PI);
var minimumCone = when.defaultValue(options.minimumCone, 0.0);
var maximumCone = when.defaultValue(options.maximumCone, _Math.CesiumMath.PI);
var stackPartitions = Math.round(when.defaultValue(options.stackPartitions, 64));
var slicePartitions = Math.round(when.defaultValue(options.slicePartitions, 64));
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
//>>includeStart('debug', pragmas.debug);
if (slicePartitions < 3) {
throw new Check.DeveloperError('options.slicePartitions cannot be less than three.');
}
if (stackPartitions < 3) {
throw new Check.DeveloperError('options.stackPartitions cannot be less than three.');
}
//>>includeEnd('debug');
this._radii = Cartographic.Cartesian3.clone(radii);
this._innerRadii = Cartographic.Cartesian3.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipsoidGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipsoidGeometry.packedLength = 2 * (Cartographic.Cartesian3.packedLength) + VertexFormat.VertexFormat.packedLength + 7;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipsoidGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipsoidGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartographic.Cartesian3.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartographic.Cartesian3();
var scratchInnerRadii = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
radii : scratchRadii,
innerRadii : scratchInnerRadii,
vertexFormat : scratchVertexFormat,
minimumClock : undefined,
maximumClock : undefined,
minimumCone : undefined,
maximumCone : undefined,
stackPartitions : undefined,
slicePartitions : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipsoidGeometry} [result] The object into which to store the result.
* @returns {EllipsoidGeometry} The modified result parameter or a new EllipsoidGeometry instance if one was not provided.
*/
EllipsoidGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var radii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var innerRadii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var minimumClock = array[startingIndex++];
var maximumClock = array[startingIndex++];
var minimumCone = array[startingIndex++];
var maximumCone = array[startingIndex++];
var stackPartitions = array[startingIndex++];
var slicePartitions = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.minimumClock = minimumClock;
scratchOptions.maximumClock = maximumClock;
scratchOptions.minimumCone = minimumCone;
scratchOptions.maximumCone = maximumCone;
scratchOptions.stackPartitions = stackPartitions;
scratchOptions.slicePartitions = slicePartitions;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipsoidGeometry(scratchOptions);
}
result._radii = Cartographic.Cartesian3.clone(radii, result._radii);
result._innerRadii = Cartographic.Cartesian3.clone(innerRadii, result._innerRadii);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipsoidGeometry} ellipsoidGeometry A description of the ellipsoid.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipsoidGeometry.createGeometry = function(ellipsoidGeometry) {
var radii = ellipsoidGeometry._radii;
if ((radii.x <= 0) || (radii.y <= 0) || (radii.z <= 0)) {
return;
}
var innerRadii = ellipsoidGeometry._innerRadii;
if ((innerRadii.x <= 0) || (innerRadii.y <= 0) || innerRadii.z <= 0) {
return;
}
var minimumClock = ellipsoidGeometry._minimumClock;
var maximumClock = ellipsoidGeometry._maximumClock;
var minimumCone = ellipsoidGeometry._minimumCone;
var maximumCone = ellipsoidGeometry._maximumCone;
var vertexFormat = ellipsoidGeometry._vertexFormat;
// Add an extra slice and stack so that the number of partitions is the
// number of surfaces rather than the number of joints
var slicePartitions = ellipsoidGeometry._slicePartitions + 1;
var stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(slicePartitions * Math.abs(maximumClock - minimumClock) / _Math.CesiumMath.TWO_PI);
stackPartitions = Math.round(stackPartitions * Math.abs(maximumCone - minimumCone) / _Math.CesiumMath.PI);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
var i;
var j;
var index = 0;
// Create arrays for theta and phi. Duplicate first and last angle to
// allow different normals at the intersections.
var phis = [minimumCone];
var thetas = [minimumClock];
for (i = 0; i < stackPartitions; i++) {
phis.push(minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1));
}
phis.push(maximumCone);
for (j = 0; j < slicePartitions; j++) {
thetas.push(minimumClock + j * (maximumClock - minimumClock) / (slicePartitions - 1));
}
thetas.push(maximumClock);
var numPhis = phis.length;
var numThetas = thetas.length;
// Allow for extra indices if there is an inner surface and if we need
// to close the sides if the clock range is not a full circle
var extraIndices = 0;
var vertexMultiplier = 1.0;
var hasInnerSurface = ((innerRadii.x !== radii.x) || (innerRadii.y !== radii.y) || innerRadii.z !== radii.z);
var isTopOpen = false;
var isBotOpen = false;
var isClockOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2.0;
if (minimumCone > 0.0) {
isTopOpen = true;
extraIndices += (slicePartitions - 1);
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += (slicePartitions - 1);
}
if ((maximumClock - minimumClock) % _Math.CesiumMath.TWO_PI) {
isClockOpen = true;
extraIndices += ((stackPartitions - 1) * 2) + 1;
} else {
extraIndices += 1;
}
}
var vertexCount = numThetas * numPhis * vertexMultiplier;
var positions = new Float64Array(vertexCount * 3);
var isInner = arrayFill.arrayFill(new Array(vertexCount), false);
var negateNormal = arrayFill.arrayFill(new Array(vertexCount), false);
// Multiply by 6 because there are two triangles per sector
var indexCount = slicePartitions * stackPartitions * vertexMultiplier;
var numIndices = 6 * (indexCount + extraIndices + 1 - (slicePartitions + stackPartitions) * vertexMultiplier);
var indices = IndexDatatype.IndexDatatype.createTypedArray(indexCount, numIndices);
var normals = (vertexFormat.normal) ? new Float32Array(vertexCount * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(vertexCount * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(vertexCount * 3) : undefined;
var st = (vertexFormat.st) ? new Float32Array(vertexCount * 2) : undefined;
// Calculate sin/cos phi
var sinPhi = new Array(numPhis);
var cosPhi = new Array(numPhis);
for (i = 0; i < numPhis; i++) {
sinPhi[i] = sin(phis[i]);
cosPhi[i] = cos(phis[i]);
}
// Calculate sin/cos theta
var sinTheta = new Array(numThetas);
var cosTheta = new Array(numThetas);
for (j = 0; j < numThetas; j++) {
cosTheta[j] = cos(thetas[j]);
sinTheta[j] = sin(thetas[j]);
}
// Create outer surface
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Create inner surface
var vertexIndex = vertexCount / 2.0;
if (hasInnerSurface) {
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
// Keep track of which vertices are the inner and which ones
// need the normal to be negated
isInner[vertexIndex] = true;
if (i > 0 && i !== (numPhis - 1) && j !== 0 && j !== (numThetas - 1)) {
negateNormal[vertexIndex] = true;
}
vertexIndex++;
}
}
}
// Create indices for outer surface
index = 0;
var topOffset;
var bottomOffset;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = i * numThetas;
bottomOffset = (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = bottomOffset + j + 1;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = topOffset + j;
}
}
// Create indices for inner surface
if (hasInnerSurface) {
var offset = numPhis * numThetas;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = offset + i * numThetas;
bottomOffset = offset + (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j + 1;
}
}
}
var outerOffset;
var innerOffset;
if (hasInnerSurface) {
if (isTopOpen) {
// Connect the top of the inner surface to the top of the outer surface
innerOffset = numPhis * numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = i;
indices[index++] = i + 1;
indices[index++] = innerOffset + i + 1;
indices[index++] = i;
indices[index++] = innerOffset + i + 1;
indices[index++] = innerOffset + i;
}
}
if (isBotOpen) {
// Connect the bottom of the inner surface to the bottom of the outer surface
outerOffset = numPhis * numThetas - numThetas;
innerOffset = numPhis * numThetas * vertexMultiplier - numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = outerOffset + i + 1;
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
indices[index++] = outerOffset + i + 1;
indices[index++] = innerOffset + i;
indices[index++] = innerOffset + i + 1;
}
}
}
// Connect the edges if clock is not closed
if (isClockOpen) {
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * i);
outerOffset = numThetas * i;
indices[index++] = innerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = outerOffset;
indices[index++] = innerOffset;
indices[index++] = innerOffset + numThetas;
indices[index++] = outerOffset + numThetas;
}
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * (i + 1)) - 1;
outerOffset = numThetas * (i + 1) - 1;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset;
indices[index++] = outerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset + numThetas;
indices[index++] = innerOffset;
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
var stIndex = 0;
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var vertexCountHalf = vertexCount / 2.0;
var ellipsoid;
var ellipsoidOuter = Cartesian2.Ellipsoid.fromCartesian3(radii);
var ellipsoidInner = Cartesian2.Ellipsoid.fromCartesian3(innerRadii);
if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (i = 0; i < vertexCount; i++) {
ellipsoid = (isInner[i]) ? ellipsoidInner : ellipsoidOuter;
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, scratchPosition);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
if (negateNormal[i]) {
Cartographic.Cartesian3.negate(normal, normal);
}
if (vertexFormat.st) {
var normalST = Cartesian2.Cartesian2.negate(normal, scratchNormalST);
st[stIndex++] = (Math.atan2(normalST.y, normalST.x) / _Math.CesiumMath.TWO_PI) + 0.5;
st[stIndex++] = (Math.asin(normal.z) / Math.PI) + 0.5;
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
var tangent = scratchTangent;
// Use UNIT_X for the poles
var tangetOffset = 0;
var unit;
if (isInner[i]) {
tangetOffset = vertexCountHalf;
}
if ((!isTopOpen && (i >= tangetOffset && i < (tangetOffset + numThetas * 2)))) {
unit = Cartographic.Cartesian3.UNIT_X;
} else {
unit = Cartographic.Cartesian3.UNIT_Z;
}
Cartographic.Cartesian3.cross(unit, normal, tangent);
Cartographic.Cartesian3.normalize(tangent, tangent);
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
var bitangent = Cartographic.Cartesian3.cross(normal, tangent, scratchBitangent);
Cartographic.Cartesian3.normalize(bitangent, bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
}
if (when.defined(ellipsoidGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values : applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : BoundingSphere.BoundingSphere.fromEllipsoid(ellipsoidOuter),
offsetAttribute : ellipsoidGeometry._offsetAttribute
});
};
var unitEllipsoidGeometry;
/**
* Returns the geometric representation of a unit ellipsoid, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
EllipsoidGeometry.getUnitEllipsoid = function() {
if (!when.defined(unitEllipsoidGeometry)) {
unitEllipsoidGeometry = EllipsoidGeometry.createGeometry((new EllipsoidGeometry({
radii : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
})));
}
return unitEllipsoidGeometry;
};
exports.EllipsoidGeometry = EllipsoidGeometry;
});

View File

@ -1,611 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-ed9d707f', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023', './VertexFormat-fe4db402'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute, VertexFormat) { 'use strict';
var scratchPosition = new Cartographic.Cartesian3();
var scratchNormal = new Cartographic.Cartesian3();
var scratchTangent = new Cartographic.Cartesian3();
var scratchBitangent = new Cartographic.Cartesian3();
var scratchNormalST = new Cartographic.Cartesian3();
var defaultRadii = new Cartographic.Cartesian3(1.0, 1.0, 1.0);
var cos = Math.cos;
var sin = Math.sin;
/**
* A description of an ellipsoid centered at the origin.
*
* @alias EllipsoidGeometry
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Cartesian3} [options.radii=Cartesian3(1.0, 1.0, 1.0)] The radii of the ellipsoid in the x, y, and z directions.
* @param {Cartesian3} [options.innerRadii=options.radii] The inner radii of the ellipsoid in the x, y, and z directions.
* @param {Number} [options.minimumClock=0.0] The minimum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.maximumClock=2*PI] The maximum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.minimumCone=0.0] The minimum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.maximumCone=PI] The maximum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.stackPartitions=64] The number of times to partition the ellipsoid into stacks.
* @param {Number} [options.slicePartitions=64] The number of times to partition the ellipsoid into radial slices.
* @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.
*
* @exception {DeveloperError} options.slicePartitions cannot be less than three.
* @exception {DeveloperError} options.stackPartitions cannot be less than three.
*
* @see EllipsoidGeometry#createGeometry
*
* @example
* var ellipsoid = new Cesium.EllipsoidGeometry({
* vertexFormat : Cesium.VertexFormat.POSITION_ONLY,
* radii : new Cesium.Cartesian3(1000000.0, 500000.0, 500000.0)
* });
* var geometry = Cesium.EllipsoidGeometry.createGeometry(ellipsoid);
*/
function EllipsoidGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var radii = when.defaultValue(options.radii, defaultRadii);
var innerRadii = when.defaultValue(options.innerRadii, radii);
var minimumClock = when.defaultValue(options.minimumClock, 0.0);
var maximumClock = when.defaultValue(options.maximumClock, _Math.CesiumMath.TWO_PI);
var minimumCone = when.defaultValue(options.minimumCone, 0.0);
var maximumCone = when.defaultValue(options.maximumCone, _Math.CesiumMath.PI);
var stackPartitions = Math.round(when.defaultValue(options.stackPartitions, 64));
var slicePartitions = Math.round(when.defaultValue(options.slicePartitions, 64));
var vertexFormat = when.defaultValue(options.vertexFormat, VertexFormat.VertexFormat.DEFAULT);
//>>includeStart('debug', pragmas.debug);
if (slicePartitions < 3) {
throw new Check.DeveloperError('options.slicePartitions cannot be less than three.');
}
if (stackPartitions < 3) {
throw new Check.DeveloperError('options.stackPartitions cannot be less than three.');
}
//>>includeEnd('debug');
this._radii = Cartographic.Cartesian3.clone(radii);
this._innerRadii = Cartographic.Cartesian3.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat);
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipsoidGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipsoidGeometry.packedLength = 2 * (Cartographic.Cartesian3.packedLength) + VertexFormat.VertexFormat.packedLength + 7;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipsoidGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipsoidGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartographic.Cartesian3.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
VertexFormat.VertexFormat.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat.VertexFormat.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartographic.Cartesian3();
var scratchInnerRadii = new Cartographic.Cartesian3();
var scratchVertexFormat = new VertexFormat.VertexFormat();
var scratchOptions = {
radii : scratchRadii,
innerRadii : scratchInnerRadii,
vertexFormat : scratchVertexFormat,
minimumClock : undefined,
maximumClock : undefined,
minimumCone : undefined,
maximumCone : undefined,
stackPartitions : undefined,
slicePartitions : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipsoidGeometry} [result] The object into which to store the result.
* @returns {EllipsoidGeometry} The modified result parameter or a new EllipsoidGeometry instance if one was not provided.
*/
EllipsoidGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var radii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var innerRadii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var vertexFormat = VertexFormat.VertexFormat.unpack(array, startingIndex, scratchVertexFormat);
startingIndex += VertexFormat.VertexFormat.packedLength;
var minimumClock = array[startingIndex++];
var maximumClock = array[startingIndex++];
var minimumCone = array[startingIndex++];
var maximumCone = array[startingIndex++];
var stackPartitions = array[startingIndex++];
var slicePartitions = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.minimumClock = minimumClock;
scratchOptions.maximumClock = maximumClock;
scratchOptions.minimumCone = minimumCone;
scratchOptions.maximumCone = maximumCone;
scratchOptions.stackPartitions = stackPartitions;
scratchOptions.slicePartitions = slicePartitions;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipsoidGeometry(scratchOptions);
}
result._radii = Cartographic.Cartesian3.clone(radii, result._radii);
result._innerRadii = Cartographic.Cartesian3.clone(innerRadii, result._innerRadii);
result._vertexFormat = VertexFormat.VertexFormat.clone(vertexFormat, result._vertexFormat);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipsoidGeometry} ellipsoidGeometry A description of the ellipsoid.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipsoidGeometry.createGeometry = function(ellipsoidGeometry) {
var radii = ellipsoidGeometry._radii;
if ((radii.x <= 0) || (radii.y <= 0) || (radii.z <= 0)) {
return;
}
var innerRadii = ellipsoidGeometry._innerRadii;
if ((innerRadii.x <= 0) || (innerRadii.y <= 0) || innerRadii.z <= 0) {
return;
}
var minimumClock = ellipsoidGeometry._minimumClock;
var maximumClock = ellipsoidGeometry._maximumClock;
var minimumCone = ellipsoidGeometry._minimumCone;
var maximumCone = ellipsoidGeometry._maximumCone;
var vertexFormat = ellipsoidGeometry._vertexFormat;
// Add an extra slice and stack so that the number of partitions is the
// number of surfaces rather than the number of joints
var slicePartitions = ellipsoidGeometry._slicePartitions + 1;
var stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(slicePartitions * Math.abs(maximumClock - minimumClock) / _Math.CesiumMath.TWO_PI);
stackPartitions = Math.round(stackPartitions * Math.abs(maximumCone - minimumCone) / _Math.CesiumMath.PI);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
var i;
var j;
var index = 0;
// Create arrays for theta and phi. Duplicate first and last angle to
// allow different normals at the intersections.
var phis = [minimumCone];
var thetas = [minimumClock];
for (i = 0; i < stackPartitions; i++) {
phis.push(minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1));
}
phis.push(maximumCone);
for (j = 0; j < slicePartitions; j++) {
thetas.push(minimumClock + j * (maximumClock - minimumClock) / (slicePartitions - 1));
}
thetas.push(maximumClock);
var numPhis = phis.length;
var numThetas = thetas.length;
// Allow for extra indices if there is an inner surface and if we need
// to close the sides if the clock range is not a full circle
var extraIndices = 0;
var vertexMultiplier = 1.0;
var hasInnerSurface = ((innerRadii.x !== radii.x) || (innerRadii.y !== radii.y) || innerRadii.z !== radii.z);
var isTopOpen = false;
var isBotOpen = false;
var isClockOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2.0;
if (minimumCone > 0.0) {
isTopOpen = true;
extraIndices += (slicePartitions - 1);
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += (slicePartitions - 1);
}
if ((maximumClock - minimumClock) % _Math.CesiumMath.TWO_PI) {
isClockOpen = true;
extraIndices += ((stackPartitions - 1) * 2) + 1;
} else {
extraIndices += 1;
}
}
var vertexCount = numThetas * numPhis * vertexMultiplier;
var positions = new Float64Array(vertexCount * 3);
var isInner = arrayFill.arrayFill(new Array(vertexCount), false);
var negateNormal = arrayFill.arrayFill(new Array(vertexCount), false);
// Multiply by 6 because there are two triangles per sector
var indexCount = slicePartitions * stackPartitions * vertexMultiplier;
var numIndices = 6 * (indexCount + extraIndices + 1 - (slicePartitions + stackPartitions) * vertexMultiplier);
var indices = IndexDatatype.IndexDatatype.createTypedArray(indexCount, numIndices);
var normals = (vertexFormat.normal) ? new Float32Array(vertexCount * 3) : undefined;
var tangents = (vertexFormat.tangent) ? new Float32Array(vertexCount * 3) : undefined;
var bitangents = (vertexFormat.bitangent) ? new Float32Array(vertexCount * 3) : undefined;
var st = (vertexFormat.st) ? new Float32Array(vertexCount * 2) : undefined;
// Calculate sin/cos phi
var sinPhi = new Array(numPhis);
var cosPhi = new Array(numPhis);
for (i = 0; i < numPhis; i++) {
sinPhi[i] = sin(phis[i]);
cosPhi[i] = cos(phis[i]);
}
// Calculate sin/cos theta
var sinTheta = new Array(numThetas);
var cosTheta = new Array(numThetas);
for (j = 0; j < numThetas; j++) {
cosTheta[j] = cos(thetas[j]);
sinTheta[j] = sin(thetas[j]);
}
// Create outer surface
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Create inner surface
var vertexIndex = vertexCount / 2.0;
if (hasInnerSurface) {
for (i = 0; i < numPhis; i++) {
for (j = 0; j < numThetas; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
// Keep track of which vertices are the inner and which ones
// need the normal to be negated
isInner[vertexIndex] = true;
if (i > 0 && i !== (numPhis - 1) && j !== 0 && j !== (numThetas - 1)) {
negateNormal[vertexIndex] = true;
}
vertexIndex++;
}
}
}
// Create indices for outer surface
index = 0;
var topOffset;
var bottomOffset;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = i * numThetas;
bottomOffset = (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = bottomOffset + j + 1;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = topOffset + j;
}
}
// Create indices for inner surface
if (hasInnerSurface) {
var offset = numPhis * numThetas;
for (i = 1; i < (numPhis - 2); i++) {
topOffset = offset + i * numThetas;
bottomOffset = offset + (i + 1) * numThetas;
for (j = 1; j < numThetas - 2; j++) {
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j;
indices[index++] = topOffset + j + 1;
indices[index++] = bottomOffset + j + 1;
}
}
}
var outerOffset;
var innerOffset;
if (hasInnerSurface) {
if (isTopOpen) {
// Connect the top of the inner surface to the top of the outer surface
innerOffset = numPhis * numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = i;
indices[index++] = i + 1;
indices[index++] = innerOffset + i + 1;
indices[index++] = i;
indices[index++] = innerOffset + i + 1;
indices[index++] = innerOffset + i;
}
}
if (isBotOpen) {
// Connect the bottom of the inner surface to the bottom of the outer surface
outerOffset = numPhis * numThetas - numThetas;
innerOffset = numPhis * numThetas * vertexMultiplier - numThetas;
for (i = 1; i < numThetas - 2; i++) {
indices[index++] = outerOffset + i + 1;
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
indices[index++] = outerOffset + i + 1;
indices[index++] = innerOffset + i;
indices[index++] = innerOffset + i + 1;
}
}
}
// Connect the edges if clock is not closed
if (isClockOpen) {
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * i);
outerOffset = numThetas * i;
indices[index++] = innerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = outerOffset;
indices[index++] = innerOffset;
indices[index++] = innerOffset + numThetas;
indices[index++] = outerOffset + numThetas;
}
for (i = 1; i < numPhis - 2; i++) {
innerOffset = numThetas * numPhis + (numThetas * (i + 1)) - 1;
outerOffset = numThetas * (i + 1) - 1;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset;
indices[index++] = outerOffset;
indices[index++] = outerOffset + numThetas;
indices[index++] = innerOffset + numThetas;
indices[index++] = innerOffset;
}
}
var attributes = new GeometryAttributes.GeometryAttributes();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
});
}
var stIndex = 0;
var normalIndex = 0;
var tangentIndex = 0;
var bitangentIndex = 0;
var vertexCountHalf = vertexCount / 2.0;
var ellipsoid;
var ellipsoidOuter = Cartesian2.Ellipsoid.fromCartesian3(radii);
var ellipsoidInner = Cartesian2.Ellipsoid.fromCartesian3(innerRadii);
if (vertexFormat.st || vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (i = 0; i < vertexCount; i++) {
ellipsoid = (isInner[i]) ? ellipsoidInner : ellipsoidOuter;
var position = Cartographic.Cartesian3.fromArray(positions, i * 3, scratchPosition);
var normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
if (negateNormal[i]) {
Cartographic.Cartesian3.negate(normal, normal);
}
if (vertexFormat.st) {
var normalST = Cartesian2.Cartesian2.negate(normal, scratchNormalST);
st[stIndex++] = (Math.atan2(normalST.y, normalST.x) / _Math.CesiumMath.TWO_PI) + 0.5;
st[stIndex++] = (Math.asin(normal.z) / Math.PI) + 0.5;
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
var tangent = scratchTangent;
// Use UNIT_X for the poles
var tangetOffset = 0;
var unit;
if (isInner[i]) {
tangetOffset = vertexCountHalf;
}
if ((!isTopOpen && (i >= tangetOffset && i < (tangetOffset + numThetas * 2)))) {
unit = Cartographic.Cartesian3.UNIT_X;
} else {
unit = Cartographic.Cartesian3.UNIT_Z;
}
Cartographic.Cartesian3.cross(unit, normal, tangent);
Cartographic.Cartesian3.normalize(tangent, tangent);
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
var bitangent = Cartographic.Cartesian3.cross(normal, tangent, scratchBitangent);
Cartographic.Cartesian3.normalize(bitangent, bitangent);
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 2,
values : st
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : bitangents
});
}
}
if (when.defined(ellipsoidGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values : applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.TRIANGLES,
boundingSphere : BoundingSphere.BoundingSphere.fromEllipsoid(ellipsoidOuter),
offsetAttribute : ellipsoidGeometry._offsetAttribute
});
};
var unitEllipsoidGeometry;
/**
* Returns the geometric representation of a unit ellipsoid, including its vertices, indices, and a bounding sphere.
* @returns {Geometry} The computed vertices and indices.
*
* @private
*/
EllipsoidGeometry.getUnitEllipsoid = function() {
if (!when.defined(unitEllipsoidGeometry)) {
unitEllipsoidGeometry = EllipsoidGeometry.createGeometry((new EllipsoidGeometry({
radii : new Cartographic.Cartesian3(1.0, 1.0, 1.0),
vertexFormat : VertexFormat.VertexFormat.POSITION_ONLY
})));
}
return unitEllipsoidGeometry;
};
exports.EllipsoidGeometry = EllipsoidGeometry;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,446 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-fe4be337', './Cartesian2-85064f09', './BoundingSphere-775c5788', './ComponentDatatype-5862616f', './GeometryAttribute-ed9d707f', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute) { 'use strict';
var defaultRadii = new Cartographic.Cartesian3(1.0, 1.0, 1.0);
var cos = Math.cos;
var sin = Math.sin;
/**
* A description of the outline of an ellipsoid centered at the origin.
*
* @alias EllipsoidOutlineGeometry
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Cartesian3} [options.radii=Cartesian3(1.0, 1.0, 1.0)] The radii of the ellipsoid in the x, y, and z directions.
* @param {Cartesian3} [options.innerRadii=options.radii] The inner radii of the ellipsoid in the x, y, and z directions.
* @param {Number} [options.minimumClock=0.0] The minimum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.maximumClock=2*PI] The maximum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.minimumCone=0.0] The minimum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.maximumCone=PI] The maximum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.stackPartitions=10] The count of stacks for the ellipsoid (1 greater than the number of parallel lines).
* @param {Number} [options.slicePartitions=8] The count of slices for the ellipsoid (Equal to the number of radial lines).
* @param {Number} [options.subdivisions=128] The number of points per line, determining the granularity of the curvature.
*
* @exception {DeveloperError} options.stackPartitions must be greater than or equal to one.
* @exception {DeveloperError} options.slicePartitions must be greater than or equal to zero.
* @exception {DeveloperError} options.subdivisions must be greater than or equal to zero.
*
* @example
* var ellipsoid = new Cesium.EllipsoidOutlineGeometry({
* radii : new Cesium.Cartesian3(1000000.0, 500000.0, 500000.0),
* stackPartitions: 6,
* slicePartitions: 5
* });
* var geometry = Cesium.EllipsoidOutlineGeometry.createGeometry(ellipsoid);
*/
function EllipsoidOutlineGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var radii = when.defaultValue(options.radii, defaultRadii);
var innerRadii = when.defaultValue(options.innerRadii, radii);
var minimumClock = when.defaultValue(options.minimumClock, 0.0);
var maximumClock = when.defaultValue(options.maximumClock, _Math.CesiumMath.TWO_PI);
var minimumCone = when.defaultValue(options.minimumCone, 0.0);
var maximumCone = when.defaultValue(options.maximumCone, _Math.CesiumMath.PI);
var stackPartitions = Math.round(when.defaultValue(options.stackPartitions, 10));
var slicePartitions = Math.round(when.defaultValue(options.slicePartitions, 8));
var subdivisions = Math.round(when.defaultValue(options.subdivisions, 128));
//>>includeStart('debug', pragmas.debug);
if (stackPartitions < 1) {
throw new Check.DeveloperError('options.stackPartitions cannot be less than 1');
}
if (slicePartitions < 0) {
throw new Check.DeveloperError('options.slicePartitions cannot be less than 0');
}
if (subdivisions < 0) {
throw new Check.DeveloperError('options.subdivisions must be greater than or equal to zero.');
}
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
this._radii = Cartographic.Cartesian3.clone(radii);
this._innerRadii = Cartographic.Cartesian3.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._subdivisions = subdivisions;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipsoidOutlineGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipsoidOutlineGeometry.packedLength = 2 * (Cartographic.Cartesian3.packedLength) + 8;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipsoidOutlineGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipsoidOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartographic.Cartesian3.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex++] = value._subdivisions;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartographic.Cartesian3();
var scratchInnerRadii = new Cartographic.Cartesian3();
var scratchOptions = {
radii : scratchRadii,
innerRadii : scratchInnerRadii,
minimumClock : undefined,
maximumClock : undefined,
minimumCone : undefined,
maximumCone : undefined,
stackPartitions : undefined,
slicePartitions : undefined,
subdivisions : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipsoidOutlineGeometry} [result] The object into which to store the result.
* @returns {EllipsoidOutlineGeometry} The modified result parameter or a new EllipsoidOutlineGeometry instance if one was not provided.
*/
EllipsoidOutlineGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var radii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var innerRadii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var minimumClock = array[startingIndex++];
var maximumClock = array[startingIndex++];
var minimumCone = array[startingIndex++];
var maximumCone = array[startingIndex++];
var stackPartitions = array[startingIndex++];
var slicePartitions = array[startingIndex++];
var subdivisions = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.minimumClock = minimumClock;
scratchOptions.maximumClock = maximumClock;
scratchOptions.minimumCone = minimumCone;
scratchOptions.maximumCone = maximumCone;
scratchOptions.stackPartitions = stackPartitions;
scratchOptions.slicePartitions = slicePartitions;
scratchOptions.subdivisions = subdivisions;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipsoidOutlineGeometry(scratchOptions);
}
result._radii = Cartographic.Cartesian3.clone(radii, result._radii);
result._innerRadii = Cartographic.Cartesian3.clone(innerRadii, result._innerRadii);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._subdivisions = subdivisions;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an outline of an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipsoidOutlineGeometry} ellipsoidGeometry A description of the ellipsoid outline.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipsoidOutlineGeometry.createGeometry = function(ellipsoidGeometry) {
var radii = ellipsoidGeometry._radii;
if ((radii.x <= 0) || (radii.y <= 0) || (radii.z <= 0)) {
return;
}
var innerRadii = ellipsoidGeometry._innerRadii;
if ((innerRadii.x <= 0) || (innerRadii.y <= 0) || (innerRadii.z <= 0)) {
return;
}
var minimumClock = ellipsoidGeometry._minimumClock;
var maximumClock = ellipsoidGeometry._maximumClock;
var minimumCone = ellipsoidGeometry._minimumCone;
var maximumCone = ellipsoidGeometry._maximumCone;
var subdivisions = ellipsoidGeometry._subdivisions;
var ellipsoid = Cartesian2.Ellipsoid.fromCartesian3(radii);
// Add an extra slice and stack to remain consistent with EllipsoidGeometry
var slicePartitions = ellipsoidGeometry._slicePartitions + 1;
var stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(slicePartitions * Math.abs(maximumClock - minimumClock) / _Math.CesiumMath.TWO_PI);
stackPartitions = Math.round(stackPartitions * Math.abs(maximumCone - minimumCone) / _Math.CesiumMath.PI);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
var extraIndices = 0;
var vertexMultiplier = 1.0;
var hasInnerSurface = ((innerRadii.x !== radii.x) || (innerRadii.y !== radii.y) || innerRadii.z !== radii.z);
var isTopOpen = false;
var isBotOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2.0;
// Add 2x slicePartitions to connect the top/bottom of the outer to
// the top/bottom of the inner
if (minimumCone > 0.0) {
isTopOpen = true;
extraIndices += slicePartitions;
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += slicePartitions;
}
}
var vertexCount = subdivisions * vertexMultiplier * (stackPartitions + slicePartitions);
var positions = new Float64Array(vertexCount * 3);
// Multiply by two because two points define each line segment
var numIndices = 2 * (vertexCount + extraIndices - (slicePartitions + stackPartitions) * vertexMultiplier);
var indices = IndexDatatype.IndexDatatype.createTypedArray(vertexCount, numIndices);
var i;
var j;
var theta;
var phi;
var index = 0;
// Calculate sin/cos phi
var sinPhi = new Array(stackPartitions);
var cosPhi = new Array(stackPartitions);
for (i = 0; i < stackPartitions; i++) {
phi = minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1);
sinPhi[i] = sin(phi);
cosPhi[i] = cos(phi);
}
// Calculate sin/cos theta
var sinTheta = new Array(subdivisions);
var cosTheta = new Array(subdivisions);
for (i = 0; i < subdivisions; i++) {
theta = minimumClock + i * (maximumClock - minimumClock) / (subdivisions - 1);
sinTheta[i] = sin(theta);
cosTheta[i] = cos(theta);
}
// Calculate the latitude lines on the outer surface
for (i = 0; i < stackPartitions; i++) {
for (j = 0; j < subdivisions; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Calculate the latitude lines on the inner surface
if (hasInnerSurface) {
for (i = 0; i < stackPartitions; i++) {
for (j = 0; j < subdivisions; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
}
}
}
// Calculate sin/cos phi
sinPhi.length = subdivisions;
cosPhi.length = subdivisions;
for (i = 0; i < subdivisions; i++) {
phi = minimumCone + i * (maximumCone - minimumCone) / (subdivisions - 1);
sinPhi[i] = sin(phi);
cosPhi[i] = cos(phi);
}
// Calculate sin/cos theta for each slice partition
sinTheta.length = slicePartitions;
cosTheta.length = slicePartitions;
for (i = 0; i < slicePartitions; i++) {
theta = minimumClock + i * (maximumClock - minimumClock) / (slicePartitions - 1);
sinTheta[i] = sin(theta);
cosTheta[i] = cos(theta);
}
// Calculate the longitude lines on the outer surface
for (i = 0; i < subdivisions; i++) {
for (j = 0; j < slicePartitions; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Calculate the longitude lines on the inner surface
if (hasInnerSurface) {
for (i = 0; i < subdivisions; i++) {
for (j = 0; j < slicePartitions; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
}
}
}
// Create indices for the latitude lines
index = 0;
for (i = 0; i < stackPartitions * vertexMultiplier; i++) {
var topOffset = i * subdivisions;
for (j = 0; j < subdivisions - 1; j++) {
indices[index++] = topOffset + j;
indices[index++] = topOffset + j + 1;
}
}
// Create indices for the outer longitude lines
var offset = stackPartitions * subdivisions * vertexMultiplier;
for (i = 0; i < slicePartitions; i++) {
for (j = 0; j < subdivisions - 1; j++) {
indices[index++] = offset + i + (j * slicePartitions);
indices[index++] = offset + i + (j + 1) * slicePartitions;
}
}
// Create indices for the inner longitude lines
if (hasInnerSurface) {
offset = stackPartitions * subdivisions * vertexMultiplier + slicePartitions * subdivisions;
for (i = 0; i < slicePartitions; i++) {
for (j = 0; j < subdivisions - 1; j++) {
indices[index++] = offset + i + (j * slicePartitions);
indices[index++] = offset + i + (j + 1) * slicePartitions;
}
}
}
if (hasInnerSurface) {
var outerOffset = stackPartitions * subdivisions * vertexMultiplier;
var innerOffset = outerOffset + (subdivisions * slicePartitions);
if (isTopOpen) {
// Draw lines from the top of the inner surface to the top of the outer surface
for (i = 0; i < slicePartitions; i++) {
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
}
}
if (isBotOpen) {
// Draw lines from the top of the inner surface to the top of the outer surface
outerOffset += (subdivisions * slicePartitions) - slicePartitions;
innerOffset += (subdivisions * slicePartitions) - slicePartitions;
for (i = 0; i < slicePartitions; i++) {
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
}
}
}
var attributes = new GeometryAttributes.GeometryAttributes({
position : new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
})
});
if (when.defined(ellipsoidGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values : applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.LINES,
boundingSphere : BoundingSphere.BoundingSphere.fromEllipsoid(ellipsoid),
offsetAttribute : ellipsoidGeometry._offsetAttribute
});
};
exports.EllipsoidOutlineGeometry = EllipsoidOutlineGeometry;
});

View File

@ -1,446 +0,0 @@
/**
* Cesium - https://github.com/CesiumGS/cesium
*
* Copyright 2011-2020 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details.
*/
define(['exports', './when-8d13db60', './Check-70bec281', './Math-61ede240', './Cartographic-f2a06374', './Cartesian2-16a61632', './BoundingSphere-d018a565', './ComponentDatatype-5862616f', './GeometryAttribute-1e248a71', './PrimitiveType-97893bc7', './GeometryAttributes-aacecde6', './IndexDatatype-9435b55f', './arrayFill-9766fb2e', './GeometryOffsetAttribute-999fc023'], function (exports, when, Check, _Math, Cartographic, Cartesian2, BoundingSphere, ComponentDatatype, GeometryAttribute, PrimitiveType, GeometryAttributes, IndexDatatype, arrayFill, GeometryOffsetAttribute) { 'use strict';
var defaultRadii = new Cartographic.Cartesian3(1.0, 1.0, 1.0);
var cos = Math.cos;
var sin = Math.sin;
/**
* A description of the outline of an ellipsoid centered at the origin.
*
* @alias EllipsoidOutlineGeometry
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Cartesian3} [options.radii=Cartesian3(1.0, 1.0, 1.0)] The radii of the ellipsoid in the x, y, and z directions.
* @param {Cartesian3} [options.innerRadii=options.radii] The inner radii of the ellipsoid in the x, y, and z directions.
* @param {Number} [options.minimumClock=0.0] The minimum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.maximumClock=2*PI] The maximum angle lying in the xy-plane measured from the positive x-axis and toward the positive y-axis.
* @param {Number} [options.minimumCone=0.0] The minimum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.maximumCone=PI] The maximum angle measured from the positive z-axis and toward the negative z-axis.
* @param {Number} [options.stackPartitions=10] The count of stacks for the ellipsoid (1 greater than the number of parallel lines).
* @param {Number} [options.slicePartitions=8] The count of slices for the ellipsoid (Equal to the number of radial lines).
* @param {Number} [options.subdivisions=128] The number of points per line, determining the granularity of the curvature.
*
* @exception {DeveloperError} options.stackPartitions must be greater than or equal to one.
* @exception {DeveloperError} options.slicePartitions must be greater than or equal to zero.
* @exception {DeveloperError} options.subdivisions must be greater than or equal to zero.
*
* @example
* var ellipsoid = new Cesium.EllipsoidOutlineGeometry({
* radii : new Cesium.Cartesian3(1000000.0, 500000.0, 500000.0),
* stackPartitions: 6,
* slicePartitions: 5
* });
* var geometry = Cesium.EllipsoidOutlineGeometry.createGeometry(ellipsoid);
*/
function EllipsoidOutlineGeometry(options) {
options = when.defaultValue(options, when.defaultValue.EMPTY_OBJECT);
var radii = when.defaultValue(options.radii, defaultRadii);
var innerRadii = when.defaultValue(options.innerRadii, radii);
var minimumClock = when.defaultValue(options.minimumClock, 0.0);
var maximumClock = when.defaultValue(options.maximumClock, _Math.CesiumMath.TWO_PI);
var minimumCone = when.defaultValue(options.minimumCone, 0.0);
var maximumCone = when.defaultValue(options.maximumCone, _Math.CesiumMath.PI);
var stackPartitions = Math.round(when.defaultValue(options.stackPartitions, 10));
var slicePartitions = Math.round(when.defaultValue(options.slicePartitions, 8));
var subdivisions = Math.round(when.defaultValue(options.subdivisions, 128));
//>>includeStart('debug', pragmas.debug);
if (stackPartitions < 1) {
throw new Check.DeveloperError('options.stackPartitions cannot be less than 1');
}
if (slicePartitions < 0) {
throw new Check.DeveloperError('options.slicePartitions cannot be less than 0');
}
if (subdivisions < 0) {
throw new Check.DeveloperError('options.subdivisions must be greater than or equal to zero.');
}
if (when.defined(options.offsetAttribute) && options.offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.TOP) {
throw new Check.DeveloperError('GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.');
}
//>>includeEnd('debug');
this._radii = Cartographic.Cartesian3.clone(radii);
this._innerRadii = Cartographic.Cartesian3.clone(innerRadii);
this._minimumClock = minimumClock;
this._maximumClock = maximumClock;
this._minimumCone = minimumCone;
this._maximumCone = maximumCone;
this._stackPartitions = stackPartitions;
this._slicePartitions = slicePartitions;
this._subdivisions = subdivisions;
this._offsetAttribute = options.offsetAttribute;
this._workerName = 'createEllipsoidOutlineGeometry';
}
/**
* The number of elements used to pack the object into an array.
* @type {Number}
*/
EllipsoidOutlineGeometry.packedLength = 2 * (Cartographic.Cartesian3.packedLength) + 8;
/**
* Stores the provided instance into the provided array.
*
* @param {EllipsoidOutlineGeometry} value The value to pack.
* @param {Number[]} array The array to pack into.
* @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.
*
* @returns {Number[]} The array that was packed into
*/
EllipsoidOutlineGeometry.pack = function(value, array, startingIndex) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(value)) {
throw new Check.DeveloperError('value is required');
}
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
Cartographic.Cartesian3.pack(value._radii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
Cartographic.Cartesian3.pack(value._innerRadii, array, startingIndex);
startingIndex += Cartographic.Cartesian3.packedLength;
array[startingIndex++] = value._minimumClock;
array[startingIndex++] = value._maximumClock;
array[startingIndex++] = value._minimumCone;
array[startingIndex++] = value._maximumCone;
array[startingIndex++] = value._stackPartitions;
array[startingIndex++] = value._slicePartitions;
array[startingIndex++] = value._subdivisions;
array[startingIndex] = when.defaultValue(value._offsetAttribute, -1);
return array;
};
var scratchRadii = new Cartographic.Cartesian3();
var scratchInnerRadii = new Cartographic.Cartesian3();
var scratchOptions = {
radii : scratchRadii,
innerRadii : scratchInnerRadii,
minimumClock : undefined,
maximumClock : undefined,
minimumCone : undefined,
maximumCone : undefined,
stackPartitions : undefined,
slicePartitions : undefined,
subdivisions : undefined,
offsetAttribute : undefined
};
/**
* Retrieves an instance from a packed array.
*
* @param {Number[]} array The packed array.
* @param {Number} [startingIndex=0] The starting index of the element to be unpacked.
* @param {EllipsoidOutlineGeometry} [result] The object into which to store the result.
* @returns {EllipsoidOutlineGeometry} The modified result parameter or a new EllipsoidOutlineGeometry instance if one was not provided.
*/
EllipsoidOutlineGeometry.unpack = function(array, startingIndex, result) {
//>>includeStart('debug', pragmas.debug);
if (!when.defined(array)) {
throw new Check.DeveloperError('array is required');
}
//>>includeEnd('debug');
startingIndex = when.defaultValue(startingIndex, 0);
var radii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var innerRadii = Cartographic.Cartesian3.unpack(array, startingIndex, scratchInnerRadii);
startingIndex += Cartographic.Cartesian3.packedLength;
var minimumClock = array[startingIndex++];
var maximumClock = array[startingIndex++];
var minimumCone = array[startingIndex++];
var maximumCone = array[startingIndex++];
var stackPartitions = array[startingIndex++];
var slicePartitions = array[startingIndex++];
var subdivisions = array[startingIndex++];
var offsetAttribute = array[startingIndex];
if (!when.defined(result)) {
scratchOptions.minimumClock = minimumClock;
scratchOptions.maximumClock = maximumClock;
scratchOptions.minimumCone = minimumCone;
scratchOptions.maximumCone = maximumCone;
scratchOptions.stackPartitions = stackPartitions;
scratchOptions.slicePartitions = slicePartitions;
scratchOptions.subdivisions = subdivisions;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return new EllipsoidOutlineGeometry(scratchOptions);
}
result._radii = Cartographic.Cartesian3.clone(radii, result._radii);
result._innerRadii = Cartographic.Cartesian3.clone(innerRadii, result._innerRadii);
result._minimumClock = minimumClock;
result._maximumClock = maximumClock;
result._minimumCone = minimumCone;
result._maximumCone = maximumCone;
result._stackPartitions = stackPartitions;
result._slicePartitions = slicePartitions;
result._subdivisions = subdivisions;
result._offsetAttribute = offsetAttribute === -1 ? undefined : offsetAttribute;
return result;
};
/**
* Computes the geometric representation of an outline of an ellipsoid, including its vertices, indices, and a bounding sphere.
*
* @param {EllipsoidOutlineGeometry} ellipsoidGeometry A description of the ellipsoid outline.
* @returns {Geometry|undefined} The computed vertices and indices.
*/
EllipsoidOutlineGeometry.createGeometry = function(ellipsoidGeometry) {
var radii = ellipsoidGeometry._radii;
if ((radii.x <= 0) || (radii.y <= 0) || (radii.z <= 0)) {
return;
}
var innerRadii = ellipsoidGeometry._innerRadii;
if ((innerRadii.x <= 0) || (innerRadii.y <= 0) || (innerRadii.z <= 0)) {
return;
}
var minimumClock = ellipsoidGeometry._minimumClock;
var maximumClock = ellipsoidGeometry._maximumClock;
var minimumCone = ellipsoidGeometry._minimumCone;
var maximumCone = ellipsoidGeometry._maximumCone;
var subdivisions = ellipsoidGeometry._subdivisions;
var ellipsoid = Cartesian2.Ellipsoid.fromCartesian3(radii);
// Add an extra slice and stack to remain consistent with EllipsoidGeometry
var slicePartitions = ellipsoidGeometry._slicePartitions + 1;
var stackPartitions = ellipsoidGeometry._stackPartitions + 1;
slicePartitions = Math.round(slicePartitions * Math.abs(maximumClock - minimumClock) / _Math.CesiumMath.TWO_PI);
stackPartitions = Math.round(stackPartitions * Math.abs(maximumCone - minimumCone) / _Math.CesiumMath.PI);
if (slicePartitions < 2) {
slicePartitions = 2;
}
if (stackPartitions < 2) {
stackPartitions = 2;
}
var extraIndices = 0;
var vertexMultiplier = 1.0;
var hasInnerSurface = ((innerRadii.x !== radii.x) || (innerRadii.y !== radii.y) || innerRadii.z !== radii.z);
var isTopOpen = false;
var isBotOpen = false;
if (hasInnerSurface) {
vertexMultiplier = 2.0;
// Add 2x slicePartitions to connect the top/bottom of the outer to
// the top/bottom of the inner
if (minimumCone > 0.0) {
isTopOpen = true;
extraIndices += slicePartitions;
}
if (maximumCone < Math.PI) {
isBotOpen = true;
extraIndices += slicePartitions;
}
}
var vertexCount = subdivisions * vertexMultiplier * (stackPartitions + slicePartitions);
var positions = new Float64Array(vertexCount * 3);
// Multiply by two because two points define each line segment
var numIndices = 2 * (vertexCount + extraIndices - (slicePartitions + stackPartitions) * vertexMultiplier);
var indices = IndexDatatype.IndexDatatype.createTypedArray(vertexCount, numIndices);
var i;
var j;
var theta;
var phi;
var index = 0;
// Calculate sin/cos phi
var sinPhi = new Array(stackPartitions);
var cosPhi = new Array(stackPartitions);
for (i = 0; i < stackPartitions; i++) {
phi = minimumCone + i * (maximumCone - minimumCone) / (stackPartitions - 1);
sinPhi[i] = sin(phi);
cosPhi[i] = cos(phi);
}
// Calculate sin/cos theta
var sinTheta = new Array(subdivisions);
var cosTheta = new Array(subdivisions);
for (i = 0; i < subdivisions; i++) {
theta = minimumClock + i * (maximumClock - minimumClock) / (subdivisions - 1);
sinTheta[i] = sin(theta);
cosTheta[i] = cos(theta);
}
// Calculate the latitude lines on the outer surface
for (i = 0; i < stackPartitions; i++) {
for (j = 0; j < subdivisions; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Calculate the latitude lines on the inner surface
if (hasInnerSurface) {
for (i = 0; i < stackPartitions; i++) {
for (j = 0; j < subdivisions; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
}
}
}
// Calculate sin/cos phi
sinPhi.length = subdivisions;
cosPhi.length = subdivisions;
for (i = 0; i < subdivisions; i++) {
phi = minimumCone + i * (maximumCone - minimumCone) / (subdivisions - 1);
sinPhi[i] = sin(phi);
cosPhi[i] = cos(phi);
}
// Calculate sin/cos theta for each slice partition
sinTheta.length = slicePartitions;
cosTheta.length = slicePartitions;
for (i = 0; i < slicePartitions; i++) {
theta = minimumClock + i * (maximumClock - minimumClock) / (slicePartitions - 1);
sinTheta[i] = sin(theta);
cosTheta[i] = cos(theta);
}
// Calculate the longitude lines on the outer surface
for (i = 0; i < subdivisions; i++) {
for (j = 0; j < slicePartitions; j++) {
positions[index++] = radii.x * sinPhi[i] * cosTheta[j];
positions[index++] = radii.y * sinPhi[i] * sinTheta[j];
positions[index++] = radii.z * cosPhi[i];
}
}
// Calculate the longitude lines on the inner surface
if (hasInnerSurface) {
for (i = 0; i < subdivisions; i++) {
for (j = 0; j < slicePartitions; j++) {
positions[index++] = innerRadii.x * sinPhi[i] * cosTheta[j];
positions[index++] = innerRadii.y * sinPhi[i] * sinTheta[j];
positions[index++] = innerRadii.z * cosPhi[i];
}
}
}
// Create indices for the latitude lines
index = 0;
for (i = 0; i < stackPartitions * vertexMultiplier; i++) {
var topOffset = i * subdivisions;
for (j = 0; j < subdivisions - 1; j++) {
indices[index++] = topOffset + j;
indices[index++] = topOffset + j + 1;
}
}
// Create indices for the outer longitude lines
var offset = stackPartitions * subdivisions * vertexMultiplier;
for (i = 0; i < slicePartitions; i++) {
for (j = 0; j < subdivisions - 1; j++) {
indices[index++] = offset + i + (j * slicePartitions);
indices[index++] = offset + i + (j + 1) * slicePartitions;
}
}
// Create indices for the inner longitude lines
if (hasInnerSurface) {
offset = stackPartitions * subdivisions * vertexMultiplier + slicePartitions * subdivisions;
for (i = 0; i < slicePartitions; i++) {
for (j = 0; j < subdivisions - 1; j++) {
indices[index++] = offset + i + (j * slicePartitions);
indices[index++] = offset + i + (j + 1) * slicePartitions;
}
}
}
if (hasInnerSurface) {
var outerOffset = stackPartitions * subdivisions * vertexMultiplier;
var innerOffset = outerOffset + (subdivisions * slicePartitions);
if (isTopOpen) {
// Draw lines from the top of the inner surface to the top of the outer surface
for (i = 0; i < slicePartitions; i++) {
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
}
}
if (isBotOpen) {
// Draw lines from the top of the inner surface to the top of the outer surface
outerOffset += (subdivisions * slicePartitions) - slicePartitions;
innerOffset += (subdivisions * slicePartitions) - slicePartitions;
for (i = 0; i < slicePartitions; i++) {
indices[index++] = outerOffset + i;
indices[index++] = innerOffset + i;
}
}
}
var attributes = new GeometryAttributes.GeometryAttributes({
position : new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.DOUBLE,
componentsPerAttribute : 3,
values : positions
})
});
if (when.defined(ellipsoidGeometry._offsetAttribute)) {
var length = positions.length;
var applyOffset = new Uint8Array(length / 3);
var offsetValue = ellipsoidGeometry._offsetAttribute === GeometryOffsetAttribute.GeometryOffsetAttribute.NONE ? 0 : 1;
arrayFill.arrayFill(applyOffset, offsetValue);
attributes.applyOffset = new GeometryAttribute.GeometryAttribute({
componentDatatype : ComponentDatatype.ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 1,
values : applyOffset
});
}
return new GeometryAttribute.Geometry({
attributes : attributes,
indices : indices,
primitiveType : PrimitiveType.PrimitiveType.LINES,
boundingSphere : BoundingSphere.BoundingSphere.fromEllipsoid(ellipsoid),
offsetAttribute : ellipsoidGeometry._offsetAttribute
});
};
exports.EllipsoidOutlineGeometry = EllipsoidOutlineGeometry;
});

View File

@ -1 +0,0 @@
define(["exports","./arrayFill-4513d7ad","./BoundingSphere-561b54d0","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./when-b60132fc","./Check-7b2a090c","./Cartesian2-47311507","./GeometryAttribute-3a42bbdc","./GeometryAttributes-252e9929","./GeometryOffsetAttribute-fbeb6f1a","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-39acab88"],(function(i,t,e,a,n,r,o,s,m,u,f,d,l,c){"use strict";var C=new a.Cartesian3(1,1,1),_=Math.cos,h=Math.sin;function p(i){i=r.defaultValue(i,r.defaultValue.EMPTY_OBJECT);var t=r.defaultValue(i.radii,C),e=r.defaultValue(i.innerRadii,t),n=r.defaultValue(i.minimumClock,0),o=r.defaultValue(i.maximumClock,l.CesiumMath.TWO_PI),s=r.defaultValue(i.minimumCone,0),m=r.defaultValue(i.maximumCone,l.CesiumMath.PI),u=Math.round(r.defaultValue(i.stackPartitions,10)),f=Math.round(r.defaultValue(i.slicePartitions,8)),d=Math.round(r.defaultValue(i.subdivisions,128));this._radii=a.Cartesian3.clone(t),this._innerRadii=a.Cartesian3.clone(e),this._minimumClock=n,this._maximumClock=o,this._minimumCone=s,this._maximumCone=m,this._stackPartitions=u,this._slicePartitions=f,this._subdivisions=d,this._offsetAttribute=i.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}p.packedLength=2*a.Cartesian3.packedLength+8,p.pack=function(i,t,e){return e=r.defaultValue(e,0),a.Cartesian3.pack(i._radii,t,e),e+=a.Cartesian3.packedLength,a.Cartesian3.pack(i._innerRadii,t,e),e+=a.Cartesian3.packedLength,t[e++]=i._minimumClock,t[e++]=i._maximumClock,t[e++]=i._minimumCone,t[e++]=i._maximumCone,t[e++]=i._stackPartitions,t[e++]=i._slicePartitions,t[e++]=i._subdivisions,t[e]=r.defaultValue(i._offsetAttribute,-1),t};var y=new a.Cartesian3,b=new a.Cartesian3,v={radii:y,innerRadii:b,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,subdivisions:void 0,offsetAttribute:void 0};p.unpack=function(i,t,e){t=r.defaultValue(t,0);var n=a.Cartesian3.unpack(i,t,y);t+=a.Cartesian3.packedLength;var o=a.Cartesian3.unpack(i,t,b);t+=a.Cartesian3.packedLength;var s=i[t++],m=i[t++],u=i[t++],f=i[t++],d=i[t++],l=i[t++],c=i[t++],C=i[t];return r.defined(e)?(e._radii=a.Cartesian3.clone(n,e._radii),e._innerRadii=a.Cartesian3.clone(o,e._innerRadii),e._minimumClock=s,e._maximumClock=m,e._minimumCone=u,e._maximumCone=f,e._stackPartitions=d,e._slicePartitions=l,e._subdivisions=c,e._offsetAttribute=-1===C?void 0:C,e):(v.minimumClock=s,v.maximumClock=m,v.minimumCone=u,v.maximumCone=f,v.stackPartitions=d,v.slicePartitions=l,v.subdivisions=c,v.offsetAttribute=-1===C?void 0:C,new p(v))},p.createGeometry=function(i){var a=i._radii;if(!(a.x<=0||a.y<=0||a.z<=0)){var o=i._innerRadii;if(!(o.x<=0||o.y<=0||o.z<=0)){var C=i._minimumClock,p=i._maximumClock,y=i._minimumCone,b=i._maximumCone,v=i._subdivisions,k=s.Ellipsoid.fromCartesian3(a),A=i._slicePartitions+1,x=i._stackPartitions+1;(A=Math.round(A*Math.abs(p-C)/l.CesiumMath.TWO_PI))<2&&(A=2),(x=Math.round(x*Math.abs(b-y)/l.CesiumMath.PI))<2&&(x=2);var P=0,w=1,M=o.x!==a.x||o.y!==a.y||o.z!==a.z,g=!1,V=!1;M&&(w=2,y>0&&(g=!0,P+=A),b<Math.PI&&(V=!0,P+=A));var G,E,O,D,I=v*w*(x+A),T=new Float64Array(3*I),z=2*(I+P-(A+x)*w),L=d.IndexDatatype.createTypedArray(I,z),R=0,N=new Array(x),B=new Array(x);for(G=0;G<x;G++)D=y+G*(b-y)/(x-1),N[G]=h(D),B[G]=_(D);var S=new Array(v),F=new Array(v);for(G=0;G<v;G++)O=C+G*(p-C)/(v-1),S[G]=h(O),F[G]=_(O);for(G=0;G<x;G++)for(E=0;E<v;E++)T[R++]=a.x*N[G]*F[E],T[R++]=a.y*N[G]*S[E],T[R++]=a.z*B[G];if(M)for(G=0;G<x;G++)for(E=0;E<v;E++)T[R++]=o.x*N[G]*F[E],T[R++]=o.y*N[G]*S[E],T[R++]=o.z*B[G];for(N.length=v,B.length=v,G=0;G<v;G++)D=y+G*(b-y)/(v-1),N[G]=h(D),B[G]=_(D);for(S.length=A,F.length=A,G=0;G<A;G++)O=C+G*(p-C)/(A-1),S[G]=h(O),F[G]=_(O);for(G=0;G<v;G++)for(E=0;E<A;E++)T[R++]=a.x*N[G]*F[E],T[R++]=a.y*N[G]*S[E],T[R++]=a.z*B[G];if(M)for(G=0;G<v;G++)for(E=0;E<A;E++)T[R++]=o.x*N[G]*F[E],T[R++]=o.y*N[G]*S[E],T[R++]=o.z*B[G];for(R=0,G=0;G<x*w;G++){var U=G*v;for(E=0;E<v-1;E++)L[R++]=U+E,L[R++]=U+E+1}var W=x*v*w;for(G=0;G<A;G++)for(E=0;E<v-1;E++)L[R++]=W+G+E*A,L[R++]=W+G+(E+1)*A;if(M)for(W=x*v*w+A*v,G=0;G<A;G++)for(E=0;E<v-1;E++)L[R++]=W+G+E*A,L[R++]=W+G+(E+1)*A;if(M){var Y=x*v*w,J=Y+v*A;if(g)for(G=0;G<A;G++)L[R++]=Y+G,L[R++]=J+G;if(V)for(Y+=v*A-A,J+=v*A-A,G=0;G<A;G++)L[R++]=Y+G,L[R++]=J+G}var j=new u.GeometryAttributes({position:new m.GeometryAttribute({componentDatatype:n.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:T})});if(r.defined(i._offsetAttribute)){var q=T.length,H=new Uint8Array(q/3),K=i._offsetAttribute===f.GeometryOffsetAttribute.NONE?0:1;t.arrayFill(H,K),j.applyOffset=new m.GeometryAttribute({componentDatatype:n.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:H})}return new m.Geometry({attributes:j,indices:L,primitiveType:c.PrimitiveType.LINES,boundingSphere:e.BoundingSphere.fromEllipsoid(k),offsetAttribute:i._offsetAttribute})}}},i.EllipsoidOutlineGeometry=p}));

View File

@ -1 +0,0 @@
define(["exports","./arrayFill-4513d7ad","./buildModuleUrl-4e1b81e7","./Cartographic-3309dd0d","./ComponentDatatype-c140a87d","./when-b60132fc","./Check-7b2a090c","./Cartesian2-47311507","./GeometryAttribute-3a88ba31","./GeometryAttributes-252e9929","./GeometryOffsetAttribute-fbeb6f1a","./IndexDatatype-8a5eead4","./Math-119be1a3","./PrimitiveType-a54dc62f"],(function(i,t,e,a,r,n,o,s,m,u,f,d,l,c){"use strict";var C=new a.Cartesian3(1,1,1),_=Math.cos,h=Math.sin;function p(i){i=n.defaultValue(i,n.defaultValue.EMPTY_OBJECT);var t=n.defaultValue(i.radii,C),e=n.defaultValue(i.innerRadii,t),r=n.defaultValue(i.minimumClock,0),o=n.defaultValue(i.maximumClock,l.CesiumMath.TWO_PI),s=n.defaultValue(i.minimumCone,0),m=n.defaultValue(i.maximumCone,l.CesiumMath.PI),u=Math.round(n.defaultValue(i.stackPartitions,10)),f=Math.round(n.defaultValue(i.slicePartitions,8)),d=Math.round(n.defaultValue(i.subdivisions,128));this._radii=a.Cartesian3.clone(t),this._innerRadii=a.Cartesian3.clone(e),this._minimumClock=r,this._maximumClock=o,this._minimumCone=s,this._maximumCone=m,this._stackPartitions=u,this._slicePartitions=f,this._subdivisions=d,this._offsetAttribute=i.offsetAttribute,this._workerName="createEllipsoidOutlineGeometry"}p.packedLength=2*a.Cartesian3.packedLength+8,p.pack=function(i,t,e){return e=n.defaultValue(e,0),a.Cartesian3.pack(i._radii,t,e),e+=a.Cartesian3.packedLength,a.Cartesian3.pack(i._innerRadii,t,e),e+=a.Cartesian3.packedLength,t[e++]=i._minimumClock,t[e++]=i._maximumClock,t[e++]=i._minimumCone,t[e++]=i._maximumCone,t[e++]=i._stackPartitions,t[e++]=i._slicePartitions,t[e++]=i._subdivisions,t[e]=n.defaultValue(i._offsetAttribute,-1),t};var y=new a.Cartesian3,v=new a.Cartesian3,b={radii:y,innerRadii:v,minimumClock:void 0,maximumClock:void 0,minimumCone:void 0,maximumCone:void 0,stackPartitions:void 0,slicePartitions:void 0,subdivisions:void 0,offsetAttribute:void 0};p.unpack=function(i,t,e){t=n.defaultValue(t,0);var r=a.Cartesian3.unpack(i,t,y);t+=a.Cartesian3.packedLength;var o=a.Cartesian3.unpack(i,t,v);t+=a.Cartesian3.packedLength;var s=i[t++],m=i[t++],u=i[t++],f=i[t++],d=i[t++],l=i[t++],c=i[t++],C=i[t];return n.defined(e)?(e._radii=a.Cartesian3.clone(r,e._radii),e._innerRadii=a.Cartesian3.clone(o,e._innerRadii),e._minimumClock=s,e._maximumClock=m,e._minimumCone=u,e._maximumCone=f,e._stackPartitions=d,e._slicePartitions=l,e._subdivisions=c,e._offsetAttribute=-1===C?void 0:C,e):(b.minimumClock=s,b.maximumClock=m,b.minimumCone=u,b.maximumCone=f,b.stackPartitions=d,b.slicePartitions=l,b.subdivisions=c,b.offsetAttribute=-1===C?void 0:C,new p(b))},p.createGeometry=function(i){var a=i._radii;if(!(a.x<=0||a.y<=0||a.z<=0)){var o=i._innerRadii;if(!(o.x<=0||o.y<=0||o.z<=0)){var C=i._minimumClock,p=i._maximumClock,y=i._minimumCone,v=i._maximumCone,b=i._subdivisions,k=s.Ellipsoid.fromCartesian3(a),A=i._slicePartitions+1,x=i._stackPartitions+1;(A=Math.round(A*Math.abs(p-C)/l.CesiumMath.TWO_PI))<2&&(A=2),(x=Math.round(x*Math.abs(v-y)/l.CesiumMath.PI))<2&&(x=2);var P=0,M=1,w=o.x!==a.x||o.y!==a.y||o.z!==a.z,g=!1,V=!1;w&&(M=2,y>0&&(g=!0,P+=A),v<Math.PI&&(V=!0,P+=A));var G,E,O,D,I=b*M*(x+A),T=new Float64Array(3*I),z=2*(I+P-(A+x)*M),L=d.IndexDatatype.createTypedArray(I,z),R=0,N=new Array(x),B=new Array(x);for(G=0;G<x;G++)D=y+G*(v-y)/(x-1),N[G]=h(D),B[G]=_(D);var S=new Array(b),U=new Array(b);for(G=0;G<b;G++)O=C+G*(p-C)/(b-1),S[G]=h(O),U[G]=_(O);for(G=0;G<x;G++)for(E=0;E<b;E++)T[R++]=a.x*N[G]*U[E],T[R++]=a.y*N[G]*S[E],T[R++]=a.z*B[G];if(w)for(G=0;G<x;G++)for(E=0;E<b;E++)T[R++]=o.x*N[G]*U[E],T[R++]=o.y*N[G]*S[E],T[R++]=o.z*B[G];for(N.length=b,B.length=b,G=0;G<b;G++)D=y+G*(v-y)/(b-1),N[G]=h(D),B[G]=_(D);for(S.length=A,U.length=A,G=0;G<A;G++)O=C+G*(p-C)/(A-1),S[G]=h(O),U[G]=_(O);for(G=0;G<b;G++)for(E=0;E<A;E++)T[R++]=a.x*N[G]*U[E],T[R++]=a.y*N[G]*S[E],T[R++]=a.z*B[G];if(w)for(G=0;G<b;G++)for(E=0;E<A;E++)T[R++]=o.x*N[G]*U[E],T[R++]=o.y*N[G]*S[E],T[R++]=o.z*B[G];for(R=0,G=0;G<x*M;G++){var F=G*b;for(E=0;E<b-1;E++)L[R++]=F+E,L[R++]=F+E+1}var W=x*b*M;for(G=0;G<A;G++)for(E=0;E<b-1;E++)L[R++]=W+G+E*A,L[R++]=W+G+(E+1)*A;if(w)for(W=x*b*M+A*b,G=0;G<A;G++)for(E=0;E<b-1;E++)L[R++]=W+G+E*A,L[R++]=W+G+(E+1)*A;if(w){var Y=x*b*M,J=Y+b*A;if(g)for(G=0;G<A;G++)L[R++]=Y+G,L[R++]=J+G;if(V)for(Y+=b*A-A,J+=b*A-A,G=0;G<A;G++)L[R++]=Y+G,L[R++]=J+G}var j=new u.GeometryAttributes({position:new m.GeometryAttribute({componentDatatype:r.ComponentDatatype.DOUBLE,componentsPerAttribute:3,values:T})});if(n.defined(i._offsetAttribute)){var q=T.length,H=new Uint8Array(q/3),K=i._offsetAttribute===f.GeometryOffsetAttribute.NONE?0:1;t.arrayFill(H,K),j.applyOffset=new m.GeometryAttribute({componentDatatype:r.ComponentDatatype.UNSIGNED_BYTE,componentsPerAttribute:1,values:H})}return new m.Geometry({attributes:j,indices:L,primitiveType:c.PrimitiveType.LINES,boundingSphere:e.BoundingSphere.fromEllipsoid(k),offsetAttribute:i._offsetAttribute})}}},i.EllipsoidOutlineGeometry=p}));

Some files were not shown because too many files have changed in this diff Show More