1 line
14 KiB
Plaintext
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
|