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

1 line
31 KiB
Plaintext
Raw Normal View History

2022-07-05 16:56:29 +08:00
{"version":3,"file":"createCoplanarPolygonGeometry.js","sources":["../../../../Source/Core/CoplanarPolygonGeometry.js","../../../../Source/WorkersES6/createCoplanarPolygonGeometry.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 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 Ellipsoid from \"./Ellipsoid.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 CesiumMath from \"./Math.js\";\nimport Matrix3 from \"./Matrix3.js\";\nimport PolygonGeometryLibrary from \"./PolygonGeometryLibrary.js\";\nimport PolygonPipeline from \"./PolygonPipeline.js\";\nimport PrimitiveType from \"./PrimitiveType.js\";\nimport Quaternion from \"./Quaternion.js\";\nimport VertexFormat from \"./VertexFormat.js\";\n\nconst scratchPosition = new Cartesian3();\nconst scratchBR = new BoundingRectangle();\nconst stScratch = new Cartesian2();\nconst textureCoordinatesOrigin = new Cartesian2();\nconst scratchNormal = new Cartesian3();\nconst scratchTangent = new Cartesian3();\nconst scratchBitangent = new Cartesian3();\nconst centerScratch = new Cartesian3();\nconst axis1Scratch = new Cartesian3();\nconst axis2Scratch = new Cartesian3();\nconst quaternionScratch = new Quaternion();\nconst textureMatrixScratch = new Matrix3();\nconst tangentRotationScratch = new Matrix3();\nconst surfaceNormalScratch = new Cartesian3();\n\nfunction createGeometryFromPolygon(\n polygon,\n vertexFormat,\n boundingRectangle,\n stRotation,\n projectPointTo2D,\n normal,\n tangent,\n bitangent\n) {\n const positions = polygon.positions;\n let indices = PolygonPipeline.triangulate(polygon.positions2D, polygon.holes);\n\n /* If polygon is completely unrenderable, just use the first three vertices */\n if (indices.length < 3) {\n indices = [0, 1, 2];\n }\n\n const newIndices = IndexDatatype.createTypedArray(\n positions.length,\n indices.length\n );\n newIndices.set(indices);\n\n let textureMatrix = textureMatrixScratch;\n if (stRotation !== 0.0) {\n let rotation = Quaternion.fromAxisAngle(\n normal,\n stRotation,\n quaternionScratch\n );\n textureMatrix = Matrix3.fromQuaternion(rotation, textureMatrix);\n\n if (vertexFormat.tangent || vertexFormat.bitangent) {\n rotation = Quaternion.fromAxisAngle(\n normal,\n -stRotation,\n quaternionScratch\n );\n const tangentRotation = Matrix3.fromQuaternion(\n rotation,\n tangentRotationScratch\n );\n\n tangent = Cartesian3.normalize(\n Matrix3.multiplyByVector(tangentRotation, tangent, tangent),\n tangent\n );\n if (vertexFormat.bitangent) {\n bitangent = Cartesian3.normalize(\n Cartesian3.cross(normal, tangent, bitangent),\n bitangent\n );\n }\n }\n } else {\n textureMatrix = Matrix3.clone(Matrix3.IDENTITY, textureMatrix);\n }\n\n const stOrigin = textureCoordinatesOrigin;\n if (vertexFormat.st) {\n stOrigin.x = boundingRectangle.x;\n stOrigin.y = boundingRectangle.y;\n }\n\n const length = positions.length;\n const size = length * 3;\n const flatPositions = new Float64Array(size);\n const normals = vertexFormat.normal ? new Float32Array(size) : undefined;\n const tangents = vertexFormat.tangent ? new Float32Array(size) : undefined;\n const bitangents = vertexFormat.bitangent\n ? new Float32Array(