qd-changjing/public/static/Build/CesiumUnminified/Workers/createCoplanarPolygonOutlin...

1 line
14 KiB
Plaintext

{"version":3,"file":"createCoplanarPolygonOutlineGeometry.js","sources":["../../../../Source/Core/CoplanarPolygonOutlineGeometry.js","../../../../Source/WorkersES6/createCoplanarPolygonOutlineGeometry.js"],"sourcesContent":["import arrayRemoveDuplicates from \"./arrayRemoveDuplicates.js\";\nimport BoundingSphere from \"./BoundingSphere.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport Check from \"./Check.js\";\nimport ComponentDatatype from \"./ComponentDatatype.js\";\nimport CoplanarPolygonGeometryLibrary from \"./CoplanarPolygonGeometryLibrary.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport Geometry from \"./Geometry.js\";\nimport GeometryAttribute from \"./GeometryAttribute.js\";\nimport GeometryAttributes from \"./GeometryAttributes.js\";\nimport GeometryInstance from \"./GeometryInstance.js\";\nimport GeometryPipeline from \"./GeometryPipeline.js\";\nimport IndexDatatype from \"./IndexDatatype.js\";\nimport PolygonGeometryLibrary from \"./PolygonGeometryLibrary.js\";\nimport PrimitiveType from \"./PrimitiveType.js\";\n\nfunction createGeometryFromPositions(positions) {\n const length = positions.length;\n const flatPositions = new Float64Array(length * 3);\n const indices = IndexDatatype.createTypedArray(length, length * 2);\n\n let positionIndex = 0;\n let index = 0;\n\n for (let i = 0; i < length; i++) {\n const position = positions[i];\n flatPositions[positionIndex++] = position.x;\n flatPositions[positionIndex++] = position.y;\n flatPositions[positionIndex++] = position.z;\n\n indices[index++] = i;\n indices[index++] = (i + 1) % length;\n }\n\n const attributes = new GeometryAttributes({\n position: new GeometryAttribute({\n componentDatatype: ComponentDatatype.DOUBLE,\n componentsPerAttribute: 3,\n values: flatPositions,\n }),\n });\n\n return new Geometry({\n attributes: attributes,\n indices: indices,\n primitiveType: PrimitiveType.LINES,\n });\n}\n\n/**\n * A description of the outline of a polygon composed of arbitrary coplanar positions.\n *\n * @alias CoplanarPolygonOutlineGeometry\n * @constructor\n *\n * @param {Object} options Object with the following properties:\n * @param {PolygonHierarchy} options.polygonHierarchy A polygon hierarchy that can include holes.\n *\n * @see CoplanarPolygonOutlineGeometry.createGeometry\n *\n * @example\n * const polygonOutline = new Cesium.CoplanarPolygonOutlineGeometry({\n * positions : Cesium.Cartesian3.fromDegreesArrayHeights([\n * -90.0, 30.0, 0.0,\n * -90.0, 30.0, 1000.0,\n * -80.0, 30.0, 1000.0,\n * -80.0, 30.0, 0.0\n * ])\n * });\n * const geometry = Cesium.CoplanarPolygonOutlineGeometry.createGeometry(polygonOutline);\n */\nfunction CoplanarPolygonOutlineGeometry(options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n const polygonHierarchy = options.polygonHierarchy;\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.polygonHierarchy\", polygonHierarchy);\n //>>includeEnd('debug');\n\n this._polygonHierarchy = polygonHierarchy;\n this._workerName = \"createCoplanarPolygonOutlineGeometry\";\n\n /**\n * The number of elements used to pack the object into an array.\n * @type {Number}\n */\n this.packedLength =\n PolygonGeometryLibrary.computeHierarchyPackedLength(polygonHierarchy) + 1;\n}\n\n/**\n * A description of a coplanar polygon outline from an array of positions.\n *\n * @param {Object} options Object with the following properties:\n * @param {Cartesian3[]} options.positions An array of positions that defined the corner points of the polygon.\n * @returns {CoplanarPolygonOutlineGeometry}\n */\nCoplanarPolygonOutlineGeometry.fromPositions = function (options) {\n options = defaultValue(options, defaultValue.EMPTY_OBJECT);\n\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"options.positions\", options.positions);\n //>>includeEnd('debug');\n\n const newOptions = {\n polygonHierarchy: {\n positions: options.positions,\n },\n };\n return new CoplanarPolygonOutlineGeometry(newOptions);\n};\n\n/**\n * Stores the provided instance into the provided array.\n *\n * @param {CoplanarPolygonOutlineGeometry} 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 */\nCoplanarPolygonOutlineGeometry.pack = function (value, array, startingIndex) {\n //>>includeStart('debug', pragmas.debug);\n Check.typeOf.object(\"value\", value);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n startingIndex = PolygonGeometryLibrary.packPolygonHierarchy(\n value._polygonHierarchy,\n array,\n startingIndex\n );\n\n array[startingIndex] = value.packedLength;\n\n return array;\n};\n\nconst scratchOptions = {\n polygonHierarchy: {},\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 {CoplanarPolygonOutlineGeometry} [result] The object into which to store the result.\n * @returns {CoplanarPolygonOutlineGeometry} The modified result parameter or a new CoplanarPolygonOutlineGeometry instance if one was not provided.\n */\nCoplanarPolygonOutlineGeometry.unpack = function (\n array,\n startingIndex,\n result\n) {\n //>>includeStart('debug', pragmas.debug);\n Check.defined(\"array\", array);\n //>>includeEnd('debug');\n\n startingIndex = defaultValue(startingIndex, 0);\n\n const polygonHierarchy = PolygonGeometryLibrary.unpackPolygonHierarchy(\n array,\n startingIndex\n );\n startingIndex = polygonHierarchy.startingIndex;\n delete polygonHierarchy.startingIndex;\n const packedLength = array[startingIndex];\n\n if (!defined(result)) {\n result = new CoplanarPolygonOutlineGeometry(scratchOptions);\n }\n\n result._polygonHierarchy = polygonHierarchy;\n result.packedLength = packedLength;\n\n return result;\n};\n\n/**\n * Computes the geometric representation of an arbitrary coplanar polygon, including its vertices, indices, and a bounding sphere.\n *\n * @param {CoplanarPolygonOutlineGeometry} polygonGeometry A description of the polygon.\n * @returns {Geometry|undefined} The computed vertices and indices.\n */\nCoplanarPolygonOutlineGeometry.createGeometry = function (polygonGeometry) {\n const polygonHierarchy = polygonGeometry._polygonHierarchy;\n\n let outerPositions = polygonHierarchy.positions;\n outerPositions = arrayRemoveDuplicates(\n outerPositions,\n Cartesian3.equalsEpsilon,\n true\n );\n if (outerPositions.length < 3) {\n return;\n }\n const isValid = CoplanarPolygonGeometryLibrary.validOutline(outerPositions);\n if (!isValid) {\n return undefined;\n }\n\n const polygons = PolygonGeometryLibrary.polygonOutlinesFromHierarchy(\n polygonHierarchy,\n false\n );\n\n if (polygons.length === 0) {\n return undefined;\n }\n\n const geometries = [];\n\n for (let i = 0; i < polygons.length; i++) {\n const geometryInstance = new GeometryInstance({\n geometry: createGeometryFromPositions(polygons[i]),\n });\n geometries.push(geometryInstance);\n }\n\n const geometry = GeometryPipeline.combineInstances(geometries)[0];\n const boundingSphere = BoundingSphere.fromPoints(polygonHierarchy.positions);\n\n return new Geometry({\n attributes: geometry.attributes,\n indices: geometry.indices,\n primitiveType: geometry.primitiveType,\n boundingSphere: boundingSphere,\n });\n};\nexport default CoplanarPolygonOutlineGeometry;\n","import CoplanarPolygonOutlineGeometry from \"../Core/CoplanarPolygonOutlineGeometry.js\";\nimport defined from \"../Core/defined.js\";\nimport Ellipsoid from \"../Core/Ellipsoid.js\";\n\nfunction createCoplanarPolygonOutlineGeometry(polygonGeometry, offset) {\n if (defined(offset)) {\n polygonGeometry = CoplanarPolygonOutlineGeometry.unpack(\n polygonGeometry,\n offset\n );\n }\n polygonGeometry._ellipsoid = Ellipsoid.clone(polygonGeometry._ellipsoid);\n return CoplanarPolygonOutlineGeometry.createGeometry(polygonGeometry);\n}\nexport default createCoplanarPolygonOutlineGeometry;\n"],"names":["IndexDatatype","GeometryAttributes","GeometryAttribute","ComponentDatatype","Geometry","PrimitiveType","defaultValue","Check","PolygonGeometryLibrary","defined","arrayRemoveDuplicates","Cartesian3","CoplanarPolygonGeometryLibrary","GeometryInstance","GeometryPipeline","BoundingSphere","Ellipsoid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAiBA,SAAS,2BAA2B,CAAC,SAAS,EAAE;EAChD,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;EAClC,EAAE,MAAM,aAAa,GAAG,IAAI,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