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

1 line
20 KiB
Plaintext
Raw Normal View History

2022-07-05 16:56:29 +08:00
{"version":3,"file":"createPolylineVolumeOutlineGeometry.js","sources":["../../../../Source/Core/PolylineVolumeOutlineGeometry.js","../../../../Source/WorkersES6/createPolylineVolumeOutlineGeometry.js"],"sourcesContent":["import arrayRemoveDuplicates from \"./arrayRemoveDuplicates.js\";\nimport BoundingRectangle from \"./BoundingRectangle.js\";\nimport BoundingSphere from \"./BoundingSphere.js\";\nimport Cartesian2 from \"./Cartesian2.js\";\nimport Cartesian3 from \"./Cartesian3.js\";\nimport ComponentDatatype from \"./ComponentDatatype.js\";\nimport CornerType from \"./CornerType.js\";\nimport defaultValue from \"./defaultValue.js\";\nimport defined from \"./defined.js\";\nimport DeveloperError from \"./DeveloperError.js\";\nimport Ellipsoid from \"./Ellipsoid.js\";\nimport Geometry from \"./Geometry.js\";\nimport GeometryAttribute from \"./GeometryAttribute.js\";\nimport GeometryAttributes from \"./GeometryAttributes.js\";\nimport IndexDatatype from \"./IndexDatatype.js\";\nimport CesiumMath from \"./Math.js\";\nimport PolygonPipeline from \"./PolygonPipeline.js\";\nimport PolylineVolumeGeometryLibrary from \"./PolylineVolumeGeometryLibrary.js\";\nimport PrimitiveType from \"./PrimitiveType.js\";\nimport WindingOrder from \"./WindingOrder.js\";\n\nfunction computeAttributes(positions, shape) {\n const attributes = new GeometryAttributes();\n attributes.position = new GeometryAttribute({\n componentDatatype: ComponentDatatype.DOUBLE,\n componentsPerAttribute: 3,\n values: positions,\n });\n\n const shapeLength = shape.length;\n const vertexCount = attributes.position.values.length / 3;\n const positionLength = positions.length / 3;\n const shapeCount = positionLength / shapeLength;\n const indices = IndexDatatype.createTypedArray(\n vertexCount,\n 2 * shapeLength * (shapeCount + 1)\n );\n let i, j;\n let index = 0;\n i = 0;\n let offset = i * shapeLength;\n for (j = 0; j < shapeLength - 1; j++) {\n indices[index++] = j + offset;\n indices[index++] = j + offset + 1;\n }\n indices[index++] = shapeLength - 1 + offset;\n indices[index++] = offset;\n\n i = shapeCount - 1;\n offset = i * shapeLength;\n for (j = 0; j < shapeLength - 1; j++) {\n indices[index++] = j + offset;\n indices[index++] = j + offset + 1;\n }\n indices[index++] = shapeLength - 1 + offset;\n indices[index++] = offset;\n\n for (i = 0; i < shapeCount - 1; i++) {\n const firstOffset = shapeLength * i;\n const secondOffset = firstOffset + shapeLength;\n for (j = 0; j < shapeLength; j++) {\n indices[index++] = j + firstOffset;\n indices[index++] = j + secondOffset;\n }\n }\n\n const geometry = new Geometry({\n attributes: attributes,\n indices: IndexDatatype.createTypedArray(vertexCount, indices),\n boundingSphere: BoundingSphere.fromVertices(positions),\n primitiveType: PrimitiveType.LINES,\n });\n\n return geometry;\n}\n\n/**\n * A description of a polyline with a volume (a 2D shape extruded along a polyline).\n *\n * @alias PolylineVolumeOutlineGeometry\n * @constructor\n *\n * @param {Object} options Object with the following properties:\n * @param {Cartesian3[]} options.polylinePositions An array of positions that define the center of the polyline volume.\n * @param {Cartesian2[]} options.shapePositions An array of positions that define the shape to be extruded along the polyline\n * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid to be used as a reference.\n * @param {Number} [options.granularity=CesiumMath.RADIANS_PER_DEGREE] The distance, in radians, between each latitude and longitude. Determines the number of positions in the buffer.\n * @param {CornerType} [options.cornerType=CornerType.ROUNDED] Determines the style of the corners.\n *\n * @see PolylineVolumeOutlineGeometry#createGeometry\n *\n * @example\n * function computeCircle(radius) {\n * const positions = [];\n * for (let i = 0; i < 360; i++) {\n * const radians = Cesium.Math.toRadians(i);\n * positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math