1 line
7.3 KiB
Plaintext
1 line
7.3 KiB
Plaintext
|
{"version":3,"file":"createSphereGeometry.js","sources":["../../../../Source/Core/SphereGeometry.js","../../../../Source/WorkersES6/createSphereGeometry.js"],"sourcesContent":["import Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport EllipsoidGeometry from \"./EllipsoidGeometry.js\";\nimport VertexFormat from \"./VertexFormat.js\";\n\n/**\n * A description of a sphere centered at the origin.\n *\n * @alias SphereGeometry\n * @constructor\n *\n * @param {Object} [options] Object with the following properties:\n * @param {Number} [options.radius=1.0] The radius of the sphere.\n * @param {Number} [options.stackPartitions=64] The number of times to partition the ellipsoid into stacks.\n * @param {Number} [options.slicePartitions=64] The number of times to partition the ellipsoid into radial slices.\n * @param {VertexFormat} [options.vertexFormat=VertexFormat.DEFAULT] The vertex attributes to be computed.\n *\n * @exception {DeveloperError} options.slicePartitions cannot be less than three.\n * @exception {DeveloperError} options.stackPartitions cannot be less than three.\n *\n * @see SphereGeometry#createGeometry\n *\n * @example\n * const sphere = new Cesium.SphereGeometry({\n * radius : 100.0,\n * vertexFormat : Cesium.VertexFormat.POSITION_ONLY\n * });\n * const geometry = Cesium.SphereGeometry.createGeometry(sphere);\n */\nfunction SphereGeometry(options) {\n const radius = defaultValue(options.radius, 1.0);\n const radii = new Cartesian3(radius, radius, radius);\n const ellipsoidOptions = {\n radii: radii,\n stackPartitions: options.stackPartitions,\n slicePartitions: options.slicePartitions,\n vertexFormat: options.vertexFormat,\n };\n\n this._ellipsoidGeometry = new EllipsoidGeometry(ellipsoidOptions);\n this._workerName = \"createSphereGeometry\";\n}\n\n/**\n * The number of elements used to pack the object into an array.\n * @type {Number}\n */\nSphereGeometry.packedLength = EllipsoidGeometry.packedLength;\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {SphereGeometry} value The value to pack.\n * @param {Number[]} array The array to pack into.\n * @param {Number} [startingIndex=0] The index into the array at which to start packing the elements.\n *\n * @returns {Number[]} The array that was packed into\n */\nSphereGeometry.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n //>>includeEnd('debug');\n\n return EllipsoidGeometry.pack(value._ellipsoidGeometry, array, startingIndex);\n};\n\nconst scratchEllipsoidGeometry = new EllipsoidGeometry();\nconst scratchOptions = {\n radius: undefined,\n radii: new Cartesian3(),\n vertexFormat: new VertexFormat(),\n stackPartitions: undefined,\n slicePartitions: undefined,\n};\n\n/**\n * Retrieves an instance from a packed array.\n *\n * @param {Number[]} array The packed array.\n * @param {Number} [startingIndex=0] The starting index of the element to be unpacked.\n * @param {SphereGeometry} [result] The object into which to store the result.\n * @returns {SphereGeometry} The modified result parameter or a new SphereGeometry instance if one was not provided.\n */\nSphereGeometry.unpack = function (array, startingIndex, result) {\n const ellipsoidGeometry = EllipsoidGeometry.unpack(\n array,\n startingIndex,\n scratchEllipsoidGeometry\n );\n scratchOptions.vertexFormat = VertexFormat.clone(\n ellipsoidGeometry._vertexFormat,\n scratchOptions.vertexFormat\n );\n scratchOptions.stackPartitions = ellipsoidGeometry._stackPartitions;\n scratchOptions.slicePartitions = ellipsoidGeometry._slicePartitions;\n\n if (!defined(result)) {\n scratchOptions.radius = ellipsoidGeometry._radii.x;\n return new SphereGeometry(scratchOptions);\n }\n\n Cartesian3.clone(ellipsoidGeometry._radii, scratchOptions.radii);\n result._ellipsoidGeometry = new EllipsoidGeometry(scratchOptions);\n return result;\n};\n
|