qd-changjing/public/static/Build/CesiumUnminified/Workers/EncodedCartesian3-da8f96bc....

1 line
9.1 KiB
Plaintext
Raw Normal View History

2022-07-05 16:56:29 +08:00
{"version":3,"file":"EncodedCartesian3-da8f96bc.js","sources":["../../../../Source/Core/EncodedCartesian3.js"],"sourcesContent":["import Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defined from \"./defined.js\";\n\n/**\n * A fixed-point encoding of a {@link Cartesian3} with 64-bit floating-point components, as two {@link Cartesian3}\n * values that, when converted to 32-bit floating-point and added, approximate the original input.\n * <p>\n * This is used to encode positions in vertex buffers for rendering without jittering artifacts\n * as described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n * </p>\n *\n * @alias EncodedCartesian3\n * @constructor\n *\n * @private\n */\nfunction EncodedCartesian3() {\n /**\n * The high bits for each component. Bits 0 to 22 store the whole value. Bits 23 to 31 are not used.\n *\n * @type {Cartesian3}\n * @default {@link Cartesian3.ZERO}\n */\n this.high = Cartesian3.clone(Cartesian3.ZERO);\n\n /**\n * The low bits for each component. Bits 7 to 22 store the whole value, and bits 0 to 6 store the fraction. Bits 23 to 31 are not used.\n *\n * @type {Cartesian3}\n * @default {@link Cartesian3.ZERO}\n */\n this.low = Cartesian3.clone(Cartesian3.ZERO);\n}\n\n/**\n * Encodes a 64-bit floating-point value as two floating-point values that, when converted to\n * 32-bit floating-point and added, approximate the original input. The returned object\n * has <code>high</code> and <code>low</code> properties for the high and low bits, respectively.\n * <p>\n * The fixed-point encoding follows {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n * </p>\n *\n * @param {Number} value The floating-point value to encode.\n * @param {Object} [result] The object onto which to store the result.\n * @returns {Object} The modified result parameter or a new instance if one was not provided.\n *\n * @example\n * const value = 1234567.1234567;\n * const splitValue = Cesium.EncodedCartesian3.encode(value);\n */\nEncodedCartesian3.encode = function (value, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.number(\"value\", value);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = {\n high: 0.0,\n low: 0.0,\n };\n }\n\n let doubleHigh;\n if (value >= 0.0) {\n doubleHigh = Math.floor(value / 65536.0) * 65536.0;\n result.high = doubleHigh;\n result.low = value - doubleHigh;\n } else {\n doubleHigh = Math.floor(-value / 65536.0) * 65536.0;\n result.high = -doubleHigh;\n result.low = value + doubleHigh;\n }\n\n return result;\n};\n\nconst scratchEncode = {\n high: 0.0,\n low: 0.0,\n};\n\n/**\n * Encodes a {@link Cartesian3} with 64-bit floating-point components as two {@link Cartesian3}\n * values that, when converted to 32-bit floating-point and added, approximate the original input.\n * <p>\n * The fixed-point encoding follows {@link https://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.\n * </p>\n *\n * @param {Cartesian3} cartesian The cartesian to encode.\n * @param {EncodedCartesian3} [result] The object onto which to store the result.\n * @returns {EncodedCartesian3} The modified result parameter or a new EncodedCartesian3 instance if one was not provided.\n *\n * @example\n * const cart = new Cesium.Cartesian3(-10000000.0, 0.0, 10000000.0);\n * const encoded = Cesium.EncodedCartesian3.fromCartesian(cart);\n */\nEncodedCartesian3.fromCartesian = function (cartesian, result) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"cartesian\", cartesian);\n //>>includeEnd('debug');\n\n if (!defined(result)) {\n result = new EncodedCartesian3();\n }\n\n const high = result.high;\n const low = result.low;\n\n EncodedCartesian3.encode(cartesian.x, scratchEncode);\n high.x = scratchEncode.high;\n low.x = scratchEncode.low;\n\n EncodedCartesian3.encode(cartesian.y, scratchEncode);\n high.y = scratchEnc