2613 lines
134 KiB
Vue
2613 lines
134 KiB
Vue
<template>
|
||
<vc-datasource-czml v-if="czml" :czml="czml" @ready="onDataSourceReady" />
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { ref, computed } from "vue";
|
||
import { useStore } from "vuex";
|
||
|
||
import entity from "../../api/entity.js";
|
||
|
||
// 卫星轨道数据处理
|
||
let vcViewerInstance: any = null;
|
||
const store = useStore();
|
||
const czml = computed(() => "./CZML/" + store.getters["satelliteSystem/name"] + ".czml");
|
||
|
||
const onDataSourceReady = ({ viewer, cesiumObject }) => {
|
||
if (!vcViewerInstance) vcViewerInstance = viewer;
|
||
|
||
// 引入常用卫星模型
|
||
// 设置 minimumPixelSize 和 maximumPixelSize 都为 0 , show 为 false,使常用卫星模型无法被观察到
|
||
// 此处利用了缓存机制,因为在父组件中模型已经加载过一次了,所以在此处再次加载模型并引用时速度会加快
|
||
// 模型对象构造方法
|
||
class Model {
|
||
constructor(modelUrl) {
|
||
const modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
|
||
Cesium.Cartesian3.fromDegrees(108.55, 34.32, 0.0)
|
||
);
|
||
this.model = viewer.scene.primitives.add(
|
||
Cesium.Model.fromGltf({
|
||
url: `./models/geo/${modelUrl}.glb`,
|
||
modelMatrix: modelMatrix,
|
||
minimumPixelSize: 0,
|
||
maximumPixelSize: 0,
|
||
show: false,
|
||
})
|
||
);
|
||
}
|
||
}
|
||
|
||
const GEOModel = new Model("BeidouGEO");
|
||
const MEOModel = new Model("BeidouMEO");
|
||
const IGSOModel = new Model("BeidouIGSO");
|
||
const GPSIIFModel = new Model("GPSII-F");
|
||
const GPSIIRModel = new Model("GPSII-R");
|
||
const GPSIIIAModel = new Model("GPSIII-A");
|
||
const GPSIIRMModel = new Model("GPSIIR-M");
|
||
const GLONASSGLOKModel = new Model("GLONASSGLO-K");
|
||
const GLONASSGLOMModel = new Model("GLONASSGLO-M");
|
||
const GalileoMEOModel = new Model("GalileoMEO");
|
||
|
||
// cesiumObject.entities.values[i].model.uri._value 存放czml文件加载的卫星模型数据
|
||
// model._resource 存放上方代码加载的卫星模型数据
|
||
// cesiumObject.entities.values[i].model.uri._value 模型加载地址为 http://localhost:3000/models/geo/geo.glb
|
||
// model._resource 模型加载地址为 ../../../public/models/geo/geo.glb
|
||
// model._resource 的模型加载速度快于 cesiumObject.entities.values[i].model.uri._value 且在数据改变时不需要重复加载
|
||
// 此处使用了提前加载一个不可观察的常用模型对象后复用该模型对象的办法来优化模型的加载速度
|
||
|
||
class CustomPrimitive {
|
||
constructor(options) {
|
||
this.show = options.show;
|
||
this._primitives = options._primitives;
|
||
}
|
||
update(frameState) {
|
||
if (!this.show) {
|
||
return;
|
||
}
|
||
var t = this._primitives;
|
||
t.forEach((element) => {
|
||
element.update(frameState);
|
||
});
|
||
}
|
||
}
|
||
|
||
const removePolylines = (e) => {
|
||
if (e._polylinesRemoved) {
|
||
e._polylinesRemoved = !1;
|
||
var t,
|
||
i = [],
|
||
r = [],
|
||
n = 0;
|
||
e._polylines.forEach((element) => {
|
||
(t = element).isDestroyed || ((t._index = n++), r.push(t), i.push(t));
|
||
(e._polylines = i), (e._polylinesToUpdate = r);
|
||
});
|
||
}
|
||
};
|
||
|
||
const updateMode$1 = (e, t) => {
|
||
var i = t.mode;
|
||
(e._mode === i && Cesium.Matrix4.equals(e._modelMatrix, e.modelMatrix),
|
||
(e._createVertexArray = !0)) ||
|
||
((e._mode = i),
|
||
(e._modelMatrix = Cesium.Matrix4.clone(e.modelMatrix)),
|
||
(e._createVertexArray = !0));
|
||
};
|
||
|
||
const createBatchTable = (e, t) => {
|
||
defined(e._batchTable) && e._batchTable.destroy();
|
||
var i = [
|
||
{
|
||
functionName: "batchTable_getWidthAndShow",
|
||
componentDatatype: ComponentDatatype$1.UNSIGNED_BYTE,
|
||
componentsPerAttribute: 2,
|
||
},
|
||
{
|
||
functionName: "batchTable_getPickColor",
|
||
componentDatatype: ComponentDatatype$1.UNSIGNED_BYTE,
|
||
componentsPerAttribute: 4,
|
||
normalize: !0,
|
||
},
|
||
{
|
||
functionName: "batchTable_getCenterHigh",
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
componentsPerAttribute: 3,
|
||
},
|
||
{
|
||
functionName: "batchTable_getCenterLowAndRadius",
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
componentsPerAttribute: 4,
|
||
},
|
||
{
|
||
functionName: "batchTable_getDistanceDisplayCondition",
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
componentsPerAttribute: 2,
|
||
},
|
||
];
|
||
e._batchTable = new Cesium.BatchTable(t, i, e._polylines.length);
|
||
};
|
||
|
||
var POSITION_INDEX$4 = Cesium.Polyline.POSITION_INDEX;
|
||
|
||
const computeNewBuffersUsage = (e) => {
|
||
var t = !1,
|
||
i = e._propertiesChanged,
|
||
r = e._positionBufferUsage;
|
||
return (
|
||
i[POSITION_INDEX$4]
|
||
? r.bufferUsage !== BufferUsage$1.STREAM_DRAW
|
||
? ((t = !0), (r.bufferUsage = BufferUsage$1.STREAM_DRAW), (r.frameCount = 100))
|
||
: (r.frameCount = 100)
|
||
: r.bufferUsage !== BufferUsage$1.STATIC_DRAW &&
|
||
(0 === r.frameCount
|
||
? ((t = !0), (r.bufferUsage = BufferUsage$1.STATIC_DRAW))
|
||
: r.frameCount--),
|
||
t
|
||
);
|
||
};
|
||
|
||
const defined = (e) => {
|
||
return null != e;
|
||
};
|
||
|
||
const releaseShaders = (e) => {
|
||
var t = e._polylines;
|
||
t.forEach((element) => {
|
||
if (!element.isDestroyed) {
|
||
var n = element._bucket;
|
||
defined(n) && (n.shaderProgram = n.shaderProgram && n.shaderProgram.destroy());
|
||
}
|
||
});
|
||
};
|
||
|
||
const destroyVertexArrays = (e) => {
|
||
e._vertexArrays.forEach((element) => {
|
||
element.va.destroy();
|
||
});
|
||
e._vertexArrays.length = 0;
|
||
};
|
||
|
||
var SceneMode = {
|
||
MORPHING: 0,
|
||
COLUMBUS_VIEW: 1,
|
||
SCENE2D: 2,
|
||
SCENE3D: 3,
|
||
getMorphTime: (e) => {
|
||
return e === SceneMode.SCENE3D ? 1 : e !== SceneMode.MORPHING ? 0 : void 0;
|
||
},
|
||
},
|
||
SceneMode$1 = Object.freeze(SceneMode);
|
||
|
||
var Intersect = {
|
||
OUTSIDE: -1,
|
||
INTERSECTING: 0,
|
||
INSIDE: 1,
|
||
},
|
||
Intersect$1 = Object.freeze(Intersect);
|
||
|
||
const intersectsIDL = (e) => {
|
||
return (
|
||
Cesium.Cartesian3.dot(Cesium.Cartesian3.UNIT_X, e._boundingVolume.center) < 0 ||
|
||
e._boundingVolume.intersectPlane(Cesium.Plane.ORIGIN_ZX_PLANE) ===
|
||
Intersect$1.INTERSECTING
|
||
);
|
||
};
|
||
|
||
var isInternetExplorerResult,
|
||
theNavigator = navigator;
|
||
|
||
var FeatureDetection = {
|
||
isInternetExplorer: () => {
|
||
var e;
|
||
defined(isInternetExplorerResult) ||
|
||
((isInternetExplorerResult = !1),
|
||
"Microsoft Internet Explorer" === theNavigator.appName
|
||
? null !== (e = /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(theNavigator.userAgent)) &&
|
||
((isInternetExplorerResult = !0),
|
||
(internetExplorerVersionResult = extractVersion(e[1])))
|
||
: "Netscape" === theNavigator.appName &&
|
||
null !==
|
||
(e = /Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.exec(theNavigator.userAgent)) &&
|
||
((isInternetExplorerResult = !0),
|
||
(internetExplorerVersionResult = extractVersion(e[1]))));
|
||
return isInternetExplorerResult;
|
||
},
|
||
};
|
||
|
||
const defaultValue = (e, t) => {
|
||
return null != e ? e : t;
|
||
};
|
||
|
||
class ShaderSource {
|
||
constructor(e) {
|
||
var t = (e = defaultValue(e, defaultValue.EMPTY_OBJECT)).pickColorQualifier;
|
||
(this.defines = defined(e.defines) ? e.defines.slice(0) : []),
|
||
(this.sources = defined(e.sources) ? e.sources.slice(0) : []),
|
||
(this.pickColorQualifier = t),
|
||
(this.includeBuiltIns = defaultValue(e.includeBuiltIns, !0));
|
||
this._czmBuiltinsAndUniforms = {};
|
||
this.replaceMain = (e, t) => {
|
||
return (
|
||
(t = "void " + t + "()"), e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g, t)
|
||
);
|
||
};
|
||
}
|
||
createCombinedVertexShader(e) {
|
||
return combineShader(this, !1, e);
|
||
}
|
||
createPickFragmentShaderSource(e, t) {
|
||
return (
|
||
ShaderSource.replaceMain(e, "czm_old_main") +
|
||
"\n" +
|
||
(t +
|
||
" vec4 czm_pickColor; \nvoid main() \n{ \n czm_old_main(); \n if (gl_FragColor.a == 0.0) { \n discard; \n } \n gl_FragColor = czm_pickColor; \n}")
|
||
);
|
||
}
|
||
clone() {
|
||
return new ShaderSource({
|
||
sources: this.sources,
|
||
defines: this.defines,
|
||
pickColorQualifier: this.pickColorQualifier,
|
||
includeBuiltIns: this.includeBuiltIns,
|
||
});
|
||
}
|
||
}
|
||
|
||
class AutomaticUniform {
|
||
constructor(e) {
|
||
(this._size = e.size), (this._datatype = e.datatype), (this.getValue = e.getValue);
|
||
}
|
||
getDeclaration(e) {
|
||
var t = "uniform " + datatypeToGlsl[this._datatype] + " " + e,
|
||
i = this._size;
|
||
return (t += 1 === i ? ";" : "[" + i.toString() + "];");
|
||
}
|
||
}
|
||
|
||
var CzmBuiltins,
|
||
AutomaticUniforms = Cesium.AutomaticUniforms,
|
||
datatypeToGlsl = Cesium.datatypeToGlsl,
|
||
WebGLConstants = Cesium.WebGLConstants,
|
||
WebGLConstants$1 = Object.freeze(WebGLConstants);
|
||
|
||
const tobuild = () => {
|
||
var czm_degreesPerRadian = "const float czm_degreesPerRadian = 57.29577951308232;\n",
|
||
czm_depthRange =
|
||
"const czm_depthRangeStruct czm_depthRange = czm_depthRangeStruct(0.0, 1.0);\n",
|
||
czm_epsilon1 = "const float czm_epsilon1 = 0.1;\n",
|
||
czm_epsilon2 = "const float czm_epsilon2 = 0.01;\n",
|
||
czm_epsilon3 = "const float czm_epsilon3 = 0.001;\n",
|
||
czm_epsilon4 = "const float czm_epsilon4 = 0.0001;\n",
|
||
czm_epsilon5 = "const float czm_epsilon5 = 0.00001;\n",
|
||
czm_epsilon6 = "const float czm_epsilon6 = 0.000001;\n",
|
||
czm_epsilon7 = "const float czm_epsilon7 = 0.0000001;\n",
|
||
czm_infinity = "const float czm_infinity = 5906376272000.0;\n",
|
||
czm_oneOverPi = "const float czm_oneOverPi = 0.3183098861837907;\n",
|
||
czm_oneOverTwoPi = "const float czm_oneOverTwoPi = 0.15915494309189535;\n",
|
||
czm_passCesium3DTile = "const float czm_passCesium3DTile = 4.0;\n",
|
||
czm_passCesium3DTileClassification =
|
||
"const float czm_passCesium3DTileClassification = 5.0;\n",
|
||
czm_passCesium3DTileClassificationIgnoreShow =
|
||
"const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;\n",
|
||
czm_passClassification = "const float czm_passClassification = 7.0;\n",
|
||
czm_passCompute = "const float czm_passCompute = 1.0;\n",
|
||
czm_passEnvironment = "const float czm_passEnvironment = 0.0;\n",
|
||
czm_passGlobe = "const float czm_passGlobe = 2.0;\n",
|
||
czm_passOpaque = "const float czm_passOpaque = 7.0;\n",
|
||
czm_passOverlay = "const float czm_passOverlay = 9.0;\n",
|
||
czm_passTerrainClassification =
|
||
"const float czm_passTerrainClassification = 3.0;\n",
|
||
czm_passTranslucent = "const float czm_passTranslucent = 8.0;\n",
|
||
czm_pi = "const float czm_pi = 3.141592653589793;\n",
|
||
czm_piOverFour = "const float czm_piOverFour = 0.7853981633974483;\n",
|
||
czm_piOverSix = "const float czm_piOverSix = 0.5235987755982988;\n",
|
||
czm_piOverThree = "const float czm_piOverThree = 1.0471975511965976;\n",
|
||
czm_piOverTwo = "const float czm_piOverTwo = 1.5707963267948966;\n",
|
||
czm_radiansPerDegree = "const float czm_radiansPerDegree = 0.017453292519943295;\n",
|
||
czm_sceneMode2D = "const float czm_sceneMode2D = 2.0;\n",
|
||
czm_sceneMode3D = "const float czm_sceneMode3D = 3.0;\n",
|
||
czm_sceneModeColumbusView = "const float czm_sceneModeColumbusView = 1.0;\n",
|
||
czm_sceneModeMorphing = "const float czm_sceneModeMorphing = 0.0;\n",
|
||
czm_solarRadius = "const float czm_solarRadius = 695500000.0;\n",
|
||
czm_threePiOver2 = "const float czm_threePiOver2 = 4.71238898038469;\n",
|
||
czm_twoPi = "const float czm_twoPi = 6.283185307179586;\n",
|
||
czm_webMercatorMaxLatitude =
|
||
"const float czm_webMercatorMaxLatitude = 1.4844222297453324;\n",
|
||
czm_depthRangeStruct =
|
||
"struct czm_depthRangeStruct\n{\nfloat near;\nfloat far;\n};\n",
|
||
czm_material =
|
||
"struct czm_material\n{\nvec3 diffuse;\nfloat specular;\nfloat shininess;\nvec3 normal;\nvec3 emission;\nfloat alpha;\n};\n",
|
||
czm_materialInput =
|
||
"struct czm_materialInput\n{\nfloat s;\nvec2 st;\nvec3 str;\nvec3 normalEC;\nmat3 tangentToEyeMatrix;\nvec3 positionToEyeEC;\nfloat height;\nfloat slope;\nfloat aspect;\n};\n",
|
||
czm_modelMaterial =
|
||
"struct czm_modelMaterial {\nvec3 diffuse;\nfloat alpha;\nvec3 specular;\nfloat roughness;\nvec3 normalEC;\nfloat occlusion;\nvec3 emissive;\n};\n",
|
||
czm_pbrParameters =
|
||
"struct czm_pbrParameters\n{\nvec3 diffuseColor;\nfloat roughness;\nvec3 f0;\n};\n",
|
||
czm_ray = "struct czm_ray\n{\nvec3 origin;\nvec3 direction;\n};\n",
|
||
czm_raySegment =
|
||
"struct czm_raySegment\n{\nfloat start;\nfloat stop;\n};\nconst czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity);\nconst czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity);\n",
|
||
czm_shadowParameters =
|
||
"struct czm_shadowParameters\n{\n#ifdef USE_CUBE_MAP_SHADOW\nvec3 texCoords;\n#else\nvec2 texCoords;\n#endif\nfloat depthBias;\nfloat depth;\nfloat nDotL;\nvec2 texelStepSize;\nfloat normalShadingSmooth;\nfloat darkness;\n};\n",
|
||
czm_acesTonemapping =
|
||
"vec3 czm_acesTonemapping(vec3 color) {\nfloat g = 0.985;\nfloat a = 0.065;\nfloat b = 0.0001;\nfloat c = 0.433;\nfloat d = 0.238;\ncolor = (color * (color + a) - b) / (color * (g * color + c) + d);\ncolor = clamp(color, 0.0, 1.0);\nreturn color;\n}\n",
|
||
czm_alphaWeight =
|
||
"float czm_alphaWeight(float a)\n{\nfloat z = (gl_FragCoord.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];\nreturn pow(a + 0.01, 4.0) + max(1e-2, min(3.0 * 1e3, 0.003 / (1e-5 + pow(abs(z) / 200.0, 4.0))));\n}\n",
|
||
czm_antialias =
|
||
"vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)\n{\nfloat val1 = clamp(dist / fuzzFactor, 0.0, 1.0);\nfloat val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);\nval1 = val1 * (1.0 - val2);\nval1 = val1 * val1 * (3.0 - (2.0 * val1));\nval1 = pow(val1, 0.5);\nvec4 midColor = (color1 + color2) * 0.5;\nreturn mix(midColor, currentColor, val1);\n}\nvec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)\n{\nreturn czm_antialias(color1, color2, currentColor, dist, 0.1);\n}\n",
|
||
czm_approximateSphericalCoordinates =
|
||
"vec2 czm_approximateSphericalCoordinates(vec3 normal) {\nfloat latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);\nfloat longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);\nreturn vec2(latitudeApproximation, longitudeApproximation);\n}\n",
|
||
czm_backFacing = "bool czm_backFacing()\n{\nreturn gl_FrontFacing == false;\n}\n",
|
||
czm_branchFreeTernary =
|
||
"float czm_branchFreeTernary(bool comparison, float a, float b) {\nfloat useA = float(comparison);\nreturn a * useA + b * (1.0 - useA);\n}\nvec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {\nfloat useA = float(comparison);\nreturn a * useA + b * (1.0 - useA);\n}\nvec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {\nfloat useA = float(comparison);\nreturn a * useA + b * (1.0 - useA);\n}\nvec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {\nfloat useA = float(comparison);\nreturn a * useA + b * (1.0 - useA);\n}\n",
|
||
czm_cascadeColor =
|
||
"vec4 czm_cascadeColor(vec4 weights)\n{\nreturn vec4(1.0, 0.0, 0.0, 1.0) * weights.x +\nvec4(0.0, 1.0, 0.0, 1.0) * weights.y +\nvec4(0.0, 0.0, 1.0, 1.0) * weights.z +\nvec4(1.0, 0.0, 1.0, 1.0) * weights.w;\n}\n",
|
||
czm_cascadeDistance =
|
||
"uniform vec4 shadowMap_cascadeDistances;\nfloat czm_cascadeDistance(vec4 weights)\n{\nreturn dot(shadowMap_cascadeDistances, weights);\n}\n",
|
||
czm_cascadeMatrix =
|
||
"uniform mat4 shadowMap_cascadeMatrices[4];\nmat4 czm_cascadeMatrix(vec4 weights)\n{\nreturn shadowMap_cascadeMatrices[0] * weights.x +\nshadowMap_cascadeMatrices[1] * weights.y +\nshadowMap_cascadeMatrices[2] * weights.z +\nshadowMap_cascadeMatrices[3] * weights.w;\n}\n",
|
||
czm_cascadeWeights =
|
||
"uniform vec4 shadowMap_cascadeSplits[2];\nvec4 czm_cascadeWeights(float depthEye)\n{\nvec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));\nvec4 far = step(depthEye, shadowMap_cascadeSplits[1]);\nreturn near * far;\n}\n",
|
||
czm_columbusViewMorph =
|
||
"vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)\n{\nvec3 p = mix(position2D.xyz, position3D.xyz, time);\nreturn vec4(p, 1.0);\n}\n",
|
||
czm_computePosition = "vec4 czm_computePosition();\n",
|
||
czm_cosineAndSine =
|
||
"vec2 cordic(float angle)\n{\nvec2 vector = vec2(6.0725293500888267e-1, 0.0);\nfloat sense = (angle < 0.0) ? -1.0 : 1.0;\nmat2 rotation = mat2(1.0, sense, -sense, 1.0);\nvector = rotation * vector;\nangle -= sense * 7.8539816339744828e-1;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfloat factor = sense * 5.0e-1;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 4.6364760900080609e-1;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 2.5e-1;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 2.4497866312686414e-1;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.25e-1;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 1.2435499454676144e-1;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 6.25e-2;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 6.2418809995957350e-2;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 3.125e-2;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 3.1239833430268277e-2;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.5625e-2;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 1.5623728620476831e-2;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 7.8125e-3;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 7.8123410601011111e-3;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 3.90625e-3;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 3.9062301319669718e-3;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.953125e-3;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 1.9531225164788188e-3;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 9.765625e-4;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 9.7656218955931946e-4;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 4.8828125e-4;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 4.8828121119489829e-4;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 2.44140625e-4;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 2.4414062014936177e-4;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.220703125e-4;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 1.2207031189367021e-4;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 6.103515625e-5;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 6.1035156174208773e-5;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 3.0517578125e-5;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 3.0517578115526096e-5;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.52587890625e-5;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 1.5258789061315762e-5;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 7.62939453125e-6;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 7.6293945311019700e-6;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 3.814697265625e-6;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 3.8146972656064961e-6;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.9073486328125e-6;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 1.9073486328101870e-6;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 9.5367431640625e-7;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 9.5367431640596084e-7;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 4.76837158203125e-7;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 4.7683715820308884e-7;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 2.384185791015625e-7;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nangle -= sense * 2.3841857910155797e-7;\nsense = (angle < 0.0) ? -1.0 : 1.0;\nfactor = sense * 1.1920928955078125e-7;\nrotation[0][1] = factor;\nrotation[1][0] = -factor;\nvector = rotation * vector;\nreturn vector;\n}\nvec2 czm_cosineAndSine(float angle)\n{\nif (angle < -czm_piOverTwo || angle > czm_piOverTwo)\n{\nif (angle < 0.0)\n{\nreturn -cordic(angle + czm_pi);\n}\nelse\n{\nreturn -cordic(angle - czm_pi);\n}\n}\nelse\n{\nreturn cordic(angle);\n}\n}\n",
|
||
czm_decompressTextureCoordinates =
|
||
"vec2 czm_decompressTextureCoordinates(float encoded)\n{\nfloat temp = encoded / 4096.0;\nfloat xZeroTo4095 = floor(temp);\nfloat stx = xZeroTo4095 / 4095.0;\nfloat sty = (encoded - xZeroTo4095 * 4096.0) / 4095.0;\nreturn vec2(stx, sty);\n}\n",
|
||
czm_defaultPbrMaterial =
|
||
"czm_pbrParameters czm_defaultPbrMaterial()\n{\nczm_pbrParameters results;\nresults.diffuseColor = vec3(1.0);\nresults.roughness = 1.0;\nconst vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);\nresults.f0 = REFLECTANCE_DIELECTRIC;\nreturn results;\n}\n",
|
||
czm_depthClamp =
|
||
"#if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)\nvarying float v_WindowZ;\n#endif\nvec4 czm_depthClamp(vec4 coords)\n{\n#ifndef LOG_DEPTH\n#ifdef GL_EXT_frag_depth\nv_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;\ncoords.z = 0.0;\n#else\ncoords.z = min(coords.z, coords.w);\n#endif\n#endif\nreturn coords;\n}\n",
|
||
czm_eastNorthUpToEyeCoordinates =
|
||
"mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)\n{\nvec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0));\nvec3 tangentEC = normalize(czm_normal3D * tangentMC);\nvec3 bitangentEC = normalize(cross(normalEC, tangentEC));\nreturn mat3(\ntangentEC.x, tangentEC.y, tangentEC.z,\nbitangentEC.x, bitangentEC.y, bitangentEC.z,\nnormalEC.x, normalEC.y, normalEC.z);\n}\n",
|
||
czm_ellipsoidContainsPoint =
|
||
"bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)\n{\nvec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;\nreturn (dot(scaled, scaled) <= 1.0);\n}\n",
|
||
czm_ellipsoidWgs84TextureCoordinates =
|
||
"vec2 czm_ellipsoidWgs84TextureCoordinates(vec3 normal)\n{\nreturn vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);\n}\n",
|
||
czm_equalsEpsilon =
|
||
"bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {\nreturn all(lessThanEqual(abs(left - right), vec4(epsilon)));\n}\nbool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {\nreturn all(lessThanEqual(abs(left - right), vec3(epsilon)));\n}\nbool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {\nreturn all(lessThanEqual(abs(left - right), vec2(epsilon)));\n}\nbool czm_equalsEpsilon(float left, float right, float epsilon) {\nreturn (abs(left - right) <= epsilon);\n}\n",
|
||
czm_eyeOffset =
|
||
"vec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)\n{\nvec4 p = positionEC;\nvec4 zEyeOffset = normalize(p) * eyeOffset.z;\np.xy += eyeOffset.xy + zEyeOffset.xy;\np.z += zEyeOffset.z;\nreturn p;\n}\n",
|
||
czm_eyeToWindowCoordinates =
|
||
"vec4 czm_eyeToWindowCoordinates(vec4 positionEC)\n{\nvec4 q = czm_projection * positionEC;\nq.xyz /= q.w;\nq.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz;\nreturn q;\n}\n",
|
||
czm_fastApproximateAtan =
|
||
"float czm_fastApproximateAtan(float x) {\nreturn x * (-0.1784 * x - 0.0663 * x * x + 1.0301);\n}\nfloat czm_fastApproximateAtan(float x, float y) {\nfloat t = abs(x);\nfloat opposite = abs(y);\nfloat adjacent = max(t, opposite);\nopposite = min(t, opposite);\nt = czm_fastApproximateAtan(opposite / adjacent);\nt = czm_branchFreeTernary(abs(y) > abs(x), czm_piOverTwo - t, t);\nt = czm_branchFreeTernary(x < 0.0, czm_pi - t, t);\nt = czm_branchFreeTernary(y < 0.0, -t, t);\nreturn t;\n}\n",
|
||
czm_fog =
|
||
"vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor)\n{\nfloat scalar = distanceToCamera * czm_fogDensity;\nfloat fog = 1.0 - exp(-(scalar * scalar));\nreturn mix(color, fogColor, fog);\n}\nvec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant)\n{\nfloat scalar = distanceToCamera * czm_fogDensity;\nfloat fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant))));\nreturn mix(color, fogColor, fog);\n}\n",
|
||
czm_gammaCorrect =
|
||
"vec3 czm_gammaCorrect(vec3 color) {\n#ifdef HDR\ncolor = pow(color, vec3(czm_gamma));\n#endif\nreturn color;\n}\nvec4 czm_gammaCorrect(vec4 color) {\n#ifdef HDR\ncolor.rgb = pow(color.rgb, vec3(czm_gamma));\n#endif\nreturn color;\n}\n",
|
||
czm_geodeticSurfaceNormal =
|
||
"vec3 czm_geodeticSurfaceNormal(vec3 positionOnEllipsoid, vec3 ellipsoidCenter, vec3 oneOverEllipsoidRadiiSquared)\n{\nreturn normalize((positionOnEllipsoid - ellipsoidCenter) * oneOverEllipsoidRadiiSquared);\n}\n",
|
||
czm_getDefaultMaterial =
|
||
"czm_material czm_getDefaultMaterial(czm_materialInput materialInput)\n{\nczm_material material;\nmaterial.diffuse = vec3(0.0);\nmaterial.specular = 0.0;\nmaterial.shininess = 1.0;\nmaterial.normal = materialInput.normalEC;\nmaterial.emission = vec3(0.0);\nmaterial.alpha = 1.0;\nreturn material;\n}\n",
|
||
czm_getLambertDiffuse =
|
||
"float czm_getLambertDiffuse(vec3 lightDirectionEC, vec3 normalEC)\n{\nreturn max(dot(lightDirectionEC, normalEC), 0.0);\n}\n",
|
||
czm_getSpecular =
|
||
"float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float shininess)\n{\nvec3 toReflectedLight = reflect(-lightDirectionEC, normalEC);\nfloat specular = max(dot(toReflectedLight, toEyeEC), 0.0);\nreturn pow(specular, max(shininess, czm_epsilon2));\n}\n",
|
||
czm_getWaterNoise =
|
||
"vec4 czm_getWaterNoise(sampler2D normalMap, vec2 uv, float time, float angleInRadians)\n{\nfloat cosAngle = cos(angleInRadians);\nfloat sinAngle = sin(angleInRadians);\nvec2 s0 = vec2(1.0/17.0, 0.0);\nvec2 s1 = vec2(-1.0/29.0, 0.0);\nvec2 s2 = vec2(1.0/101.0, 1.0/59.0);\nvec2 s3 = vec2(-1.0/109.0, -1.0/57.0);\ns0 = vec2((cosAngle * s0.x) - (sinAngle * s0.y), (sinAngle * s0.x) + (cosAngle * s0.y));\ns1 = vec2((cosAngle * s1.x) - (sinAngle * s1.y), (sinAngle * s1.x) + (cosAngle * s1.y));\ns2 = vec2((cosAngle * s2.x) - (sinAngle * s2.y), (sinAngle * s2.x) + (cosAngle * s2.y));\ns3 = vec2((cosAngle * s3.x) - (sinAngle * s3.y), (sinAngle * s3.x) + (cosAngle * s3.y));\nvec2 uv0 = (uv/103.0) + (time * s0);\nvec2 uv1 = uv/107.0 + (time * s1) + vec2(0.23);\nvec2 uv2 = uv/vec2(897.0, 983.0) + (time * s2) + vec2(0.51);\nvec2 uv3 = uv/vec2(991.0, 877.0) + (time * s3) + vec2(0.71);\nuv0 = fract(uv0);\nuv1 = fract(uv1);\nuv2 = fract(uv2);\nuv3 = fract(uv3);\nvec4 noise = (texture2D(normalMap, uv0)) +\n(texture2D(normalMap, uv1)) +\n(texture2D(normalMap, uv2)) +\n(texture2D(normalMap, uv3));\nreturn ((noise / 4.0) - 0.5) * 2.0;\n}\n",
|
||
czm_HSBToRGB =
|
||
"const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\nvec3 czm_HSBToRGB(vec3 hsb)\n{\nvec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www);\nreturn hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y);\n}\n",
|
||
czm_HSLToRGB =
|
||
"vec3 hueToRGB(float hue)\n{\nfloat r = abs(hue * 6.0 - 3.0) - 1.0;\nfloat g = 2.0 - abs(hue * 6.0 - 2.0);\nfloat b = 2.0 - abs(hue * 6.0 - 4.0);\nreturn clamp(vec3(r, g, b), 0.0, 1.0);\n}\nvec3 czm_HSLToRGB(vec3 hsl)\n{\nvec3 rgb = hueToRGB(hsl.x);\nfloat c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;\nreturn (rgb - 0.5) * c + hsl.z;\n}\n",
|
||
czm_hue =
|
||
"vec3 czm_hue(vec3 rgb, float adjustment)\n{\nconst mat3 toYIQ = mat3(0.299, 0.587, 0.114,\n0.595716, -0.274453, -0.321263,\n0.211456, -0.522591, 0.311135);\nconst mat3 toRGB = mat3(1.0, 0.9563, 0.6210,\n1.0, -0.2721, -0.6474,\n1.0, -1.107, 1.7046);\nvec3 yiq = toYIQ * rgb;\nfloat hue = atan(yiq.z, yiq.y) + adjustment;\nfloat chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);\nvec3 color = vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));\nreturn toRGB * color;\n}\n",
|
||
czm_inverseGamma =
|
||
"vec3 czm_inverseGamma(vec3 color) {\nreturn pow(color, vec3(1.0 / czm_gamma));\n}\n",
|
||
czm_isEmpty =
|
||
"bool czm_isEmpty(czm_raySegment interval)\n{\nreturn (interval.stop < 0.0);\n}\n",
|
||
czm_isFull =
|
||
"bool czm_isFull(czm_raySegment interval)\n{\nreturn (interval.start == 0.0 && interval.stop == czm_infinity);\n}\n",
|
||
czm_latitudeToWebMercatorFraction =
|
||
"float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)\n{\nfloat sinLatitude = sin(latitude);\nfloat mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));\nreturn (mercatorY - southMercatorY) * oneOverMercatorHeight;\n}\n",
|
||
czm_lineDistance =
|
||
"float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {\nreturn abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1);\n}\n",
|
||
czm_luminance =
|
||
"float czm_luminance(vec3 rgb)\n{\nconst vec3 W = vec3(0.2125, 0.7154, 0.0721);\nreturn dot(rgb, W);\n}\n",
|
||
czm_metersPerPixel =
|
||
"float czm_metersPerPixel(vec4 positionEC, float pixelRatio)\n{\nfloat width = czm_viewport.z;\nfloat height = czm_viewport.w;\nfloat pixelWidth;\nfloat pixelHeight;\nfloat top = czm_frustumPlanes.x;\nfloat bottom = czm_frustumPlanes.y;\nfloat left = czm_frustumPlanes.z;\nfloat right = czm_frustumPlanes.w;\nif (czm_sceneMode == czm_sceneMode2D || czm_orthographicIn3D == 1.0)\n{\nfloat frustumWidth = right - left;\nfloat frustumHeight = top - bottom;\npixelWidth = frustumWidth / width;\npixelHeight = frustumHeight / height;\n}\nelse\n{\nfloat distanceToPixel = -positionEC.z;\nfloat inverseNear = 1.0 / czm_currentFrustum.x;\nfloat tanTheta = top * inverseNear;\npixelHeight = 2.0 * distanceToPixel * tanTheta / height;\ntanTheta = right * inverseNear;\npixelWidth = 2.0 * distanceToPixel * tanTheta / width;\n}\nreturn max(pixelWidth, pixelHeight) * pixelRatio;\n}\nfloat czm_metersPerPixel(vec4 positionEC)\n{\nreturn czm_metersPerPixel(positionEC, czm_pixelRatio);\n}\n",
|
||
czm_modelToWindowCoordinates =
|
||
"vec4 czm_modelToWindowCoordinates(vec4 position)\n{\nvec4 q = czm_modelViewProjection * position;\nq.xyz /= q.w;\nq.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz;\nreturn q;\n}\n",
|
||
czm_multiplyWithColorBalance =
|
||
"vec3 czm_multiplyWithColorBalance(vec3 left, vec3 right)\n{\nconst vec3 W = vec3(0.2125, 0.7154, 0.0721);\nvec3 target = left * right;\nfloat leftLuminance = dot(left, W);\nfloat rightLuminance = dot(right, W);\nfloat targetLuminance = dot(target, W);\nreturn ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target;\n}\n",
|
||
czm_nearFarScalar =
|
||
"float czm_nearFarScalar(vec4 nearFarScalar, float cameraDistSq)\n{\nfloat valueAtMin = nearFarScalar.y;\nfloat valueAtMax = nearFarScalar.w;\nfloat nearDistanceSq = nearFarScalar.x * nearFarScalar.x;\nfloat farDistanceSq = nearFarScalar.z * nearFarScalar.z;\nfloat t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);\nt = pow(clamp(t, 0.0, 1.0), 0.2);\nreturn mix(valueAtMin, valueAtMax, t);\n}\n",
|
||
czm_octDecode =
|
||
"vec3 czm_octDecode(vec2 encoded, float range)\n{\nif (encoded.x == 0.0 && encoded.y == 0.0) {\nreturn vec3(0.0, 0.0, 0.0);\n}\nencoded = encoded / range * 2.0 - 1.0;\nvec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\nif (v.z < 0.0)\n{\nv.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);\n}\nreturn normalize(v);\n}\nvec3 czm_octDecode(vec2 encoded)\n{\nreturn czm_octDecode(encoded, 255.0);\n}\nvec3 czm_octDecode(float encoded)\n{\nfloat temp = encoded / 256.0;\nfloat x = floor(temp);\nfloat y = (temp - x) * 256.0;\nreturn czm_octDecode(vec2(x, y));\n}\nvoid czm_octDecode(vec2 encoded, out vec3 vector1, out vec3 vector2, out vec3 vector3)\n{\nfloat temp = encoded.x / 65536.0;\nfloat x = floor(temp);\nfloat encodedFloat1 = (temp - x) * 65536.0;\ntemp = encoded.y / 65536.0;\nfloat y = floor(temp);\nfloat encodedFloat2 = (temp - y) * 65536.0;\nvector1 = czm_octDecode(encodedFloat1);\nvector2 = czm_octDecode(encodedFloat2);\nvector3 = czm_octDecode(vec2(x, y));\n}\n",
|
||
czm_packDepth =
|
||
"vec4 czm_packDepth(float depth)\n{\nvec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;\nenc = fract(enc);\nenc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\nreturn enc;\n}\n",
|
||
czm_pbrLighting =
|
||
"vec3 lambertianDiffuse(vec3 diffuseColor)\n{\nreturn diffuseColor / czm_pi;\n}\nvec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)\n{\nreturn f0 + (f90 - f0) * pow(clamp(1.0 - VdotH, 0.0, 1.0), 5.0);\n}\nfloat smithVisibilityG1(float NdotV, float roughness)\n{\nfloat k = (roughness + 1.0) * (roughness + 1.0) / 8.0;\nreturn NdotV / (NdotV * (1.0 - k) + k);\n}\nfloat smithVisibilityGGX(float roughness, float NdotL, float NdotV)\n{\nreturn (\nsmithVisibilityG1(NdotL, roughness) *\nsmithVisibilityG1(NdotV, roughness)\n);\n}\nfloat GGX(float roughness, float NdotH)\n{\nfloat roughnessSquared = roughness * roughness;\nfloat f = (NdotH * roughnessSquared - NdotH) * NdotH + 1.0;\nreturn roughnessSquared / (czm_pi * f * f);\n}\nvec3 czm_pbrLighting(\nvec3 positionEC,\nvec3 normalEC,\nvec3 lightDirectionEC,\nvec3 lightColorHdr,\nczm_pbrParameters pbrParameters\n)\n{\nvec3 v = -normalize(positionEC);\nvec3 l = normalize(lightDirectionEC);\nvec3 h = normalize(v + l);\nvec3 n = normalEC;\nfloat NdotL = clamp(dot(n, l), 0.001, 1.0);\nfloat NdotV = abs(dot(n, v)) + 0.001;\nfloat NdotH = clamp(dot(n, h), 0.0, 1.0);\nfloat LdotH = clamp(dot(l, h), 0.0, 1.0);\nfloat VdotH = clamp(dot(v, h), 0.0, 1.0);\nvec3 f0 = pbrParameters.f0;\nfloat reflectance = max(max(f0.r, f0.g), f0.b);\nvec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));\nvec3 F = fresnelSchlick2(f0, f90, VdotH);\nfloat alpha = pbrParameters.roughness;\nfloat G = smithVisibilityGGX(alpha, NdotL, NdotV);\nfloat D = GGX(alpha, NdotH);\nvec3 specularContribution = F * G * D / (4.0 * NdotL * NdotV);\nvec3 diffuseColor = pbrParameters.diffuseColor;\nvec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);\nreturn (diffuseContribution + specularContribution) * NdotL * lightColorHdr;\n}\n",
|
||
czm_pbrMetallicRoughnessMaterial =
|
||
"czm_pbrParameters czm_pbrMetallicRoughnessMaterial(\nvec3 baseColor,\nfloat metallic,\nfloat roughness\n)\n{\nczm_pbrParameters results;\nroughness = clamp(roughness, 0.0, 1.0);\nresults.roughness = roughness * roughness;\nmetallic = clamp(metallic, 0.0, 1.0);\nconst vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);\nvec3 f0 = mix(REFLECTANCE_DIELECTRIC, baseColor, metallic);\nresults.f0 = f0;\nresults.diffuseColor = baseColor * (1.0 - f0) * (1.0 - metallic);\nreturn results;\n}\n",
|
||
czm_pbrSpecularGlossinessMaterial =
|
||
"czm_pbrParameters czm_pbrSpecularGlossinessMaterial(\nvec3 diffuse,\nvec3 specular,\nfloat glossiness\n)\n{\nczm_pbrParameters results;\nfloat roughness = 1.0 - glossiness;\nresults.roughness = roughness * roughness;\nresults.diffuseColor = diffuse * (1.0 - max(max(specular.r, specular.g), specular.b));\nresults.f0 = specular;\nreturn results;\n}\n",
|
||
czm_phong =
|
||
"float czm_private_getLambertDiffuseOfMaterial(vec3 lightDirectionEC, czm_material material)\n{\nreturn czm_getLambertDiffuse(lightDirectionEC, material.normal);\n}\nfloat czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm_material material)\n{\nreturn czm_getSpecular(lightDirectionEC, toEyeEC, material.normal, material.shininess);\n}\nvec4 czm_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)\n{\nfloat diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material);\nif (czm_sceneMode == czm_sceneMode3D) {\ndiffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material);\n}\nfloat specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);\nvec3 materialDiffuse = material.diffuse * 0.5;\nvec3 ambient = materialDiffuse;\nvec3 color = ambient + material.emission;\ncolor += materialDiffuse * diffuse * czm_lightColor;\ncolor += material.specular * specular * czm_lightColor;\nreturn vec4(color, material.alpha);\n}\nvec4 czm_private_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)\n{\nfloat diffuse = czm_private_getLambertDiffuseOfMaterial(lightDirectionEC, material);\nfloat specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);\nvec3 ambient = vec3(0.0);\nvec3 color = ambient + material.emission;\ncolor += material.diffuse * diffuse * czm_lightColor;\ncolor += material.specular * specular * czm_lightColor;\nreturn vec4(color, material.alpha);\n}\n",
|
||
czm_planeDistance =
|
||
"float czm_planeDistance(vec4 plane, vec3 point) {\nreturn (dot(plane.xyz, point) + plane.w);\n}\nfloat czm_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) {\nreturn (dot(planeNormal, point) + planeDistance);\n}\n",
|
||
czm_pointAlongRay =
|
||
"vec3 czm_pointAlongRay(czm_ray ray, float time)\n{\nreturn ray.origin + (time * ray.direction);\n}\n",
|
||
czm_rayEllipsoidIntersectionInterval =
|
||
"czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii)\n{\nvec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz;\nvec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz;\nq = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz;\nfloat q2 = dot(q, q);\nfloat qw = dot(q, w);\nif (q2 > 1.0)\n{\nif (qw >= 0.0)\n{\nreturn czm_emptyRaySegment;\n}\nelse\n{\nfloat qw2 = qw * qw;\nfloat difference = q2 - 1.0;\nfloat w2 = dot(w, w);\nfloat product = w2 * difference;\nif (qw2 < product)\n{\nreturn czm_emptyRaySegment;\n}\nelse if (qw2 > product)\n{\nfloat discriminant = qw * qw - product;\nfloat temp = -qw + sqrt(discriminant);\nfloat root0 = temp / w2;\nfloat root1 = difference / temp;\nif (root0 < root1)\n{\nczm_raySegment i = czm_raySegment(root0, root1);\nreturn i;\n}\nelse\n{\nczm_raySegment i = czm_raySegment(root1, root0);\nreturn i;\n}\n}\nelse\n{\nfloat root = sqrt(difference / w2);\nczm_raySegment i = czm_raySegment(root, root);\nreturn i;\n}\n}\n}\nelse if (q2 < 1.0)\n{\nfloat difference = q2 - 1.0;\nfloat w2 = dot(w, w);\nfloat product = w2 * difference;\nfloat discriminant = qw * qw - product;\nfloat temp = -qw + sqrt(discriminant);\nczm_raySegment i = czm_raySegment(0.0, temp / w2);\nreturn i;\n}\nelse\n{\nif (qw < 0.0)\n{\nfloat w2 = dot(w, w);\nczm_raySegment i = czm_raySegment(0.0, -qw / w2);\nreturn i;\n}\nelse\n{\nreturn czm_emptyRaySegment;\n}\n}\n}\n",
|
||
czm_readDepth =
|
||
"float czm_readDepth(sampler2D depthTexture, vec2 texCoords)\n{\nreturn czm_reverseLogDepth(texture2D(depthTexture, texCoords).r);\n}\n",
|
||
czm_readNonPerspective =
|
||
"float czm_readNonPerspective(float value, float oneOverW) {\nreturn value * oneOverW;\n}\nvec2 czm_readNonPerspective(vec2 value, float oneOverW) {\nreturn value * oneOverW;\n}\nvec3 czm_readNonPerspective(vec3 value, float oneOverW) {\nreturn value * oneOverW;\n}\nvec4 czm_readNonPerspective(vec4 value, float oneOverW) {\nreturn value * oneOverW;\n}\n",
|
||
czm_reverseLogDepth =
|
||
"float czm_reverseLogDepth(float logZ)\n{\n#ifdef LOG_DEPTH\nfloat near = czm_currentFrustum.x;\nfloat far = czm_currentFrustum.y;\nfloat log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;\nfloat depthFromNear = pow(2.0, log2Depth) - 1.0;\nreturn far * (1.0 - near / (depthFromNear + near)) / (far - near);\n#endif\nreturn logZ;\n}\n",
|
||
czm_RGBToHSB =
|
||
"const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\nvec3 czm_RGBToHSB(vec3 rgb)\n{\nvec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g));\nvec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\nfloat d = q.x - min(q.w, q.y);\nreturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x);\n}\n",
|
||
czm_RGBToHSL =
|
||
"vec3 RGBtoHCV(vec3 rgb)\n{\nvec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);\nvec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);\nfloat c = q.x - min(q.w, q.y);\nfloat h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z);\nreturn vec3(h, c, q.x);\n}\nvec3 czm_RGBToHSL(vec3 rgb)\n{\nvec3 hcv = RGBtoHCV(rgb);\nfloat l = hcv.z - hcv.y * 0.5;\nfloat s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7);\nreturn vec3(hcv.x, s, l);\n}\n",
|
||
czm_RGBToXYZ =
|
||
"vec3 czm_RGBToXYZ(vec3 rgb)\n{\nconst mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,\n0.3576, 0.7152, 0.1192,\n0.1805, 0.0722, 0.9505);\nvec3 xyz = RGB2XYZ * rgb;\nvec3 Yxy;\nYxy.r = xyz.g;\nfloat temp = dot(vec3(1.0), xyz);\nYxy.gb = xyz.rg / temp;\nreturn Yxy;\n}\n",
|
||
czm_sampleOctahedralProjection =
|
||
"vec3 czm_sampleOctahedralProjectionWithFiltering(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod)\n{\ndirection /= dot(vec3(1.0), abs(direction));\nvec2 rev = abs(direction.zx) - vec2(1.0);\nvec2 neg = vec2(direction.x < 0.0 ? rev.x : -rev.x,\ndirection.z < 0.0 ? rev.y : -rev.y);\nvec2 uv = direction.y < 0.0 ? neg : direction.xz;\nvec2 coord = 0.5 * uv + vec2(0.5);\nvec2 pixel = 1.0 / textureSize;\nif (lod > 0.0)\n{\nfloat scale = 1.0 / pow(2.0, lod);\nfloat offset = ((textureSize.y + 1.0) / textureSize.x);\ncoord.x *= offset;\ncoord *= scale;\ncoord.x += offset + pixel.x;\ncoord.y += (1.0 - (1.0 / pow(2.0, lod - 1.0))) + pixel.y * (lod - 1.0) * 2.0;\n}\nelse\n{\ncoord.x *= (textureSize.y / textureSize.x);\n}\n#ifndef OES_texture_float_linear\nvec3 color1 = texture2D(projectedMap, coord + vec2(0.0, pixel.y)).rgb;\nvec3 color2 = texture2D(projectedMap, coord + vec2(pixel.x, 0.0)).rgb;\nvec3 color3 = texture2D(projectedMap, coord + pixel).rgb;\nvec3 color4 = texture2D(projectedMap, coord).rgb;\nvec2 texturePosition = coord * textureSize;\nfloat fu = fract(texturePosition.x);\nfloat fv = fract(texturePosition.y);\nvec3 average1 = mix(color4, color2, fu);\nvec3 average2 = mix(color1, color3, fu);\nvec3 color = mix(average1, average2, fv);\n#else\nvec3 color = texture2D(projectedMap, coord).rgb;\n#endif\nreturn color;\n}\nvec3 czm_sampleOctahedralProjection(sampler2D projectedMap, vec2 textureSize, vec3 direction, float lod, float maxLod) {\nfloat currentLod = floor(lod + 0.5);\nfloat nextLod = min(currentLod + 1.0, maxLod);\nvec3 colorCurrentLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, currentLod);\nvec3 colorNextLod = czm_sampleOctahedralProjectionWithFiltering(projectedMap, textureSize, direction, nextLod);\nreturn mix(colorNextLod, colorCurrentLod, nextLod - lod);\n}\n",
|
||
czm_saturation =
|
||
"vec3 czm_saturation(vec3 rgb, float adjustment)\n{\nconst vec3 W = vec3(0.2125, 0.7154, 0.0721);\nvec3 intensity = vec3(dot(rgb, W));\nreturn mix(intensity, rgb, adjustment);\n}\n",
|
||
czm_shadowDepthCompare =
|
||
"float czm_sampleShadowMap(highp samplerCube shadowMap, vec3 d)\n{\nreturn czm_unpackDepth(textureCube(shadowMap, d));\n}\nfloat czm_sampleShadowMap(highp sampler2D shadowMap, vec2 uv)\n{\n#ifdef USE_SHADOW_DEPTH_TEXTURE\nreturn texture2D(shadowMap, uv).r;\n#else\nreturn czm_unpackDepth(texture2D(shadowMap, uv));\n#endif\n}\nfloat czm_shadowDepthCompare(samplerCube shadowMap, vec3 uv, float depth)\n{\nreturn step(depth, czm_sampleShadowMap(shadowMap, uv));\n}\nfloat czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth)\n{\nreturn step(depth, czm_sampleShadowMap(shadowMap, uv));\n}\n",
|
||
czm_shadowVisibility =
|
||
"float czm_private_shadowVisibility(float visibility, float nDotL, float normalShadingSmooth, float darkness)\n{\n#ifdef USE_NORMAL_SHADING\n#ifdef USE_NORMAL_SHADING_SMOOTH\nfloat strength = clamp(nDotL / normalShadingSmooth, 0.0, 1.0);\n#else\nfloat strength = step(0.0, nDotL);\n#endif\nvisibility *= strength;\n#endif\nvisibility = max(visibility, darkness);\nreturn visibility;\n}\n#ifdef USE_CUBE_MAP_SHADOW\nfloat czm_shadowVisibility(samplerCube shadowMap, czm_shadowParameters shadowParameters)\n{\nfloat depthBias = shadowParameters.depthBias;\nfloat depth = shadowParameters.depth;\nfloat nDotL = shadowParameters.nDotL;\nfloat normalShadingSmooth = shadowParameters.normalShadingSmooth;\nfloat darkness = shadowParameters.darkness;\nvec3 uvw = shadowParameters.texCoords;\ndepth -= depthBias;\nfloat visibility = czm_shadowDepthCompare(shadowMap, uvw, depth);\nreturn czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);\n}\n#else\nfloat czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters)\n{\nfloat depthBias = shadowParameters.depthBias;\nfloat depth = shadowParameters.depth;\nfloat nDotL = shadowParameters.nDotL;\nfloat normalShadingSmooth = shadowParameters.normalShadingSmooth;\nfloat darkness = shadowParameters.darkness;\nvec2 uv = shadowParameters.texCoords;\ndepth -= depthBias;\n#ifdef USE_SOFT_SHADOWS\nvec2 texelStepSize = shadowParameters.texelStepSize;\nfloat radius = 1.0;\nfloat dx0 = -texelStepSize.x * radius;\nfloat dy0 = -texelStepSize.y * radius;\nfloat dx1 = texelStepSize.x * radius;\nfloat dy1 = texelStepSize.y * radius;\nfloat visibility = (\nczm_shadowDepthCompare(shadowMap, uv, depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) +\nczm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth)\n) * (1.0 / 9.0);\n#else\nfloat visibility = czm_shadowDepthCompare(shadowMap, uv, depth);\n#endif\nreturn czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);\n}\n#endif\n",
|
||
czm_signNotZero =
|
||
"float czm_signNotZero(float value)\n{\nreturn value >= 0.0 ? 1.0 : -1.0;\n}\nvec2 czm_signNotZero(vec2 value)\n{\nreturn vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));\n}\nvec3 czm_signNotZero(vec3 value)\n{\nreturn vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));\n}\nvec4 czm_signNotZero(vec4 value)\n{\nreturn vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));\n}\n",
|
||
czm_sphericalHarmonics =
|
||
"vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])\n{\nvec3 L00 = coefficients[0];\nvec3 L1_1 = coefficients[1];\nvec3 L10 = coefficients[2];\nvec3 L11 = coefficients[3];\nvec3 L2_2 = coefficients[4];\nvec3 L2_1 = coefficients[5];\nvec3 L20 = coefficients[6];\nvec3 L21 = coefficients[7];\nvec3 L22 = coefficients[8];\nfloat x = normal.x;\nfloat y = normal.y;\nfloat z = normal.z;\nreturn\nL00\n+ L1_1 * y\n+ L10 * z\n+ L11 * x\n+ L2_2 * (y * x)\n+ L2_1 * (y * z)\n+ L20 * (3.0 * z * z - 1.0)\n+ L21 * (z * x)\n+ L22 * (x * x - y * y);\n}\n",
|
||
czm_tangentToEyeSpaceMatrix =
|
||
"mat3 czm_tangentToEyeSpaceMatrix(vec3 normalEC, vec3 tangentEC, vec3 bitangentEC)\n{\nvec3 normal = normalize(normalEC);\nvec3 tangent = normalize(tangentEC);\nvec3 bitangent = normalize(bitangentEC);\nreturn mat3(tangent.x , tangent.y , tangent.z,\nbitangent.x, bitangent.y, bitangent.z,\nnormal.x , normal.y , normal.z);\n}\n",
|
||
czm_transformPlane =
|
||
"vec4 czm_transformPlane(vec4 plane, mat4 transform) {\nvec4 transformedPlane = transform * plane;\nfloat normalMagnitude = length(transformedPlane.xyz);\nreturn transformedPlane / normalMagnitude;\n}\n",
|
||
czm_translateRelativeToEye =
|
||
"vec4 czm_translateRelativeToEye(vec3 high, vec3 low)\n{\nvec3 highDifference = high - czm_encodedCameraPositionMCHigh;\nvec3 lowDifference = low - czm_encodedCameraPositionMCLow;\nreturn vec4(highDifference + lowDifference, 1.0);\n}\n",
|
||
czm_translucentPhong =
|
||
"vec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC)\n{\nfloat diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);\nif (czm_sceneMode == czm_sceneMode3D) {\ndiffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);\n}\ndiffuse = clamp(diffuse, 0.0, 1.0);\nfloat specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess);\nvec3 materialDiffuse = material.diffuse * 0.5;\nvec3 ambient = materialDiffuse;\nvec3 color = ambient + material.emission;\ncolor += materialDiffuse * diffuse * czm_lightColor;\ncolor += material.specular * specular * czm_lightColor;\nreturn vec4(color, material.alpha);\n}\n",
|
||
czm_transpose =
|
||
"mat2 czm_transpose(mat2 matrix)\n{\nreturn mat2(\nmatrix[0][0], matrix[1][0],\nmatrix[0][1], matrix[1][1]);\n}\nmat3 czm_transpose(mat3 matrix)\n{\nreturn mat3(\nmatrix[0][0], matrix[1][0], matrix[2][0],\nmatrix[0][1], matrix[1][1], matrix[2][1],\nmatrix[0][2], matrix[1][2], matrix[2][2]);\n}\nmat4 czm_transpose(mat4 matrix)\n{\nreturn mat4(\nmatrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],\nmatrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],\nmatrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],\nmatrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);\n}\n",
|
||
czm_unpackDepth =
|
||
"float czm_unpackDepth(vec4 packedDepth)\n{\nreturn dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));\n}\n",
|
||
czm_unpackFloat =
|
||
"float czm_unpackFloat(vec4 packedFloat)\n{\npackedFloat = floor(packedFloat * 255.0 + 0.5);\nfloat sign = 1.0 - step(128.0, packedFloat[3]) * 2.0;\nfloat exponent = 2.0 * mod(packedFloat[3], 128.0) + step(128.0, packedFloat[2]) - 127.0;\nif (exponent == -127.0)\n{\nreturn 0.0;\n}\nfloat mantissa = mod(packedFloat[2], 128.0) * 65536.0 + packedFloat[1] * 256.0 + packedFloat[0] + float(0x800000);\nfloat result = sign * exp2(exponent - 23.0) * mantissa;\nreturn result;\n}\n",
|
||
czm_vertexLogDepth =
|
||
"#ifdef LOG_DEPTH\nvarying float v_depthFromNearPlusOne;\n#ifdef SHADOW_MAP\nvarying vec3 v_logPositionEC;\n#endif\n#endif\nvec4 czm_updatePositionDepth(vec4 coords) {\n#if defined(LOG_DEPTH)\n#ifdef SHADOW_MAP\nvec3 logPositionEC = (czm_inverseProjection * coords).xyz;\nv_logPositionEC = logPositionEC;\n#endif\ncoords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w;\n#endif\nreturn coords;\n}\nvoid czm_vertexLogDepth()\n{\n#ifdef LOG_DEPTH\nv_depthFromNearPlusOne = (gl_Position.w - czm_currentFrustum.x) + 1.0;\ngl_Position = czm_updatePositionDepth(gl_Position);\n#endif\n}\nvoid czm_vertexLogDepth(vec4 clipCoords)\n{\n#ifdef LOG_DEPTH\nv_depthFromNearPlusOne = (clipCoords.w - czm_currentFrustum.x) + 1.0;\nczm_updatePositionDepth(clipCoords);\n#endif\n}\n",
|
||
czm_windowToEyeCoordinates =
|
||
"vec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate)\n{\nfloat x = 2.0 * (fragmentCoordinate.x - czm_viewport.x) / czm_viewport.z - 1.0;\nfloat y = 2.0 * (fragmentCoordinate.y - czm_viewport.y) / czm_viewport.w - 1.0;\nfloat z = (fragmentCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];\nvec4 q = vec4(x, y, z, 1.0);\nq /= fragmentCoordinate.w;\nif (!(czm_inverseProjection == mat4(0.0)))\n{\nq = czm_inverseProjection * q;\n}\nelse\n{\nfloat top = czm_frustumPlanes.x;\nfloat bottom = czm_frustumPlanes.y;\nfloat left = czm_frustumPlanes.z;\nfloat right = czm_frustumPlanes.w;\nfloat near = czm_currentFrustum.x;\nfloat far = czm_currentFrustum.y;\nq.x = (q.x * (right - left) + left + right) * 0.5;\nq.y = (q.y * (top - bottom) + bottom + top) * 0.5;\nq.z = (q.z * (near - far) - near - far) * 0.5;\nq.w = 1.0;\n}\nreturn q;\n}\nvec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth)\n{\n#ifdef LOG_DEPTH\nfloat near = czm_currentFrustum.x;\nfloat far = czm_currentFrustum.y;\nfloat log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne;\nfloat depthFromNear = pow(2.0, log2Depth) - 1.0;\nfloat depthFromCamera = depthFromNear + near;\nvec4 windowCoord = vec4(fragmentCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);\nvec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);\neyeCoordinate.w = 1.0 / depthFromCamera;\nreturn eyeCoordinate;\n#else\nvec4 windowCoord = vec4(fragmentCoordinateXY, depthOrLogDepth, 1.0);\nvec4 eyeCoordinate = czm_windowToEyeCoordinates(windowCoord);\n#endif\nreturn eyeCoordinate;\n}\n",
|
||
czm_writeDepthClamp =
|
||
"#if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)\nvarying float v_WindowZ;\n#endif\nvoid czm_writeDepthClamp()\n{\n#if defined(GL_EXT_frag_depth) && !defined(LOG_DEPTH)\ngl_FragDepthEXT = clamp(v_WindowZ * gl_FragCoord.w, 0.0, 1.0);\n#endif\n}\n",
|
||
czm_writeLogDepth =
|
||
"#ifdef LOG_DEPTH\nvarying float v_depthFromNearPlusOne;\n#ifdef POLYGON_OFFSET\nuniform vec2 u_polygonOffset;\n#endif\n#endif\nvoid czm_writeLogDepth(float depth)\n{\n#if defined(GL_EXT_frag_depth) && defined(LOG_DEPTH)\nif (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {\ndiscard;\n}\n#ifdef POLYGON_OFFSET\nfloat factor = u_polygonOffset[0];\nfloat units = u_polygonOffset[1];\n#ifdef GL_OES_standard_derivatives\nfloat x = dFdx(depth);\nfloat y = dFdy(depth);\nfloat m = sqrt(x * x + y * y);\ndepth += m * factor;\n#endif\n#endif\ngl_FragDepthEXT = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;\n#ifdef POLYGON_OFFSET\ngl_FragDepthEXT += czm_epsilon7 * units;\n#endif\n#endif\n}\nvoid czm_writeLogDepth() {\n#ifdef LOG_DEPTH\nczm_writeLogDepth(v_depthFromNearPlusOne);\n#endif\n}\n",
|
||
czm_writeNonPerspective =
|
||
"float czm_writeNonPerspective(float value, float w) {\nreturn value * w;\n}\nvec2 czm_writeNonPerspective(vec2 value, float w) {\nreturn value * w;\n}\nvec3 czm_writeNonPerspective(vec3 value, float w) {\nreturn value * w;\n}\nvec4 czm_writeNonPerspective(vec4 value, float w) {\nreturn value * w;\n}\n",
|
||
czm_XYZToRGB =
|
||
"vec3 czm_XYZToRGB(vec3 Yxy)\n{\nconst mat3 XYZ2RGB = mat3( 3.2405, -0.9693, 0.0556,\n-1.5371, 1.8760, -0.2040,\n-0.4985, 0.0416, 1.0572);\nvec3 xyz;\nxyz.r = Yxy.r * Yxy.g / Yxy.b;\nxyz.g = Yxy.r;\nxyz.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b;\nreturn XYZ2RGB * xyz;\n}\n";
|
||
|
||
CzmBuiltins = {
|
||
czm_degreesPerRadian: czm_degreesPerRadian,
|
||
czm_depthRange: czm_depthRange,
|
||
czm_epsilon1: czm_epsilon1,
|
||
czm_epsilon2: czm_epsilon2,
|
||
czm_epsilon3: czm_epsilon3,
|
||
czm_epsilon4: czm_epsilon4,
|
||
czm_epsilon5: czm_epsilon5,
|
||
czm_epsilon6: czm_epsilon6,
|
||
czm_epsilon7: czm_epsilon7,
|
||
czm_infinity: czm_infinity,
|
||
czm_oneOverPi: czm_oneOverPi,
|
||
czm_oneOverTwoPi: czm_oneOverTwoPi,
|
||
czm_passCesium3DTile: czm_passCesium3DTile,
|
||
czm_passCesium3DTileClassification: czm_passCesium3DTileClassification,
|
||
czm_passCesium3DTileClassificationIgnoreShow: czm_passCesium3DTileClassificationIgnoreShow,
|
||
czm_passClassification: czm_passClassification,
|
||
czm_passCompute: czm_passCompute,
|
||
czm_passEnvironment: czm_passEnvironment,
|
||
czm_passGlobe: czm_passGlobe,
|
||
czm_passOpaque: czm_passOpaque,
|
||
czm_passOverlay: czm_passOverlay,
|
||
czm_passTerrainClassification: czm_passTerrainClassification,
|
||
czm_passTranslucent: czm_passTranslucent,
|
||
czm_pi: czm_pi,
|
||
czm_piOverFour: czm_piOverFour,
|
||
czm_piOverSix: czm_piOverSix,
|
||
czm_piOverThree: czm_piOverThree,
|
||
czm_piOverTwo: czm_piOverTwo,
|
||
czm_radiansPerDegree: czm_radiansPerDegree,
|
||
czm_sceneMode2D: czm_sceneMode2D,
|
||
czm_sceneMode3D: czm_sceneMode3D,
|
||
czm_sceneModeColumbusView: czm_sceneModeColumbusView,
|
||
czm_sceneModeMorphing: czm_sceneModeMorphing,
|
||
czm_solarRadius: czm_solarRadius,
|
||
czm_threePiOver2: czm_threePiOver2,
|
||
czm_twoPi: czm_twoPi,
|
||
czm_webMercatorMaxLatitude: czm_webMercatorMaxLatitude,
|
||
czm_depthRangeStruct: czm_depthRangeStruct,
|
||
czm_material: czm_material,
|
||
czm_materialInput: czm_materialInput,
|
||
czm_modelMaterial: czm_modelMaterial,
|
||
czm_pbrParameters: czm_pbrParameters,
|
||
czm_ray: czm_ray,
|
||
czm_raySegment: czm_raySegment,
|
||
czm_shadowParameters: czm_shadowParameters,
|
||
czm_acesTonemapping: czm_acesTonemapping,
|
||
czm_alphaWeight: czm_alphaWeight,
|
||
czm_antialias: czm_antialias,
|
||
czm_approximateSphericalCoordinates: czm_approximateSphericalCoordinates,
|
||
czm_backFacing: czm_backFacing,
|
||
czm_branchFreeTernary: czm_branchFreeTernary,
|
||
czm_cascadeColor: czm_cascadeColor,
|
||
czm_cascadeDistance: czm_cascadeDistance,
|
||
czm_cascadeMatrix: czm_cascadeMatrix,
|
||
czm_cascadeWeights: czm_cascadeWeights,
|
||
czm_columbusViewMorph: czm_columbusViewMorph,
|
||
czm_computePosition: czm_computePosition,
|
||
czm_cosineAndSine: czm_cosineAndSine,
|
||
czm_decompressTextureCoordinates: czm_decompressTextureCoordinates,
|
||
czm_defaultPbrMaterial: czm_defaultPbrMaterial,
|
||
czm_depthClamp: czm_depthClamp,
|
||
czm_eastNorthUpToEyeCoordinates: czm_eastNorthUpToEyeCoordinates,
|
||
czm_ellipsoidContainsPoint: czm_ellipsoidContainsPoint,
|
||
czm_ellipsoidWgs84TextureCoordinates: czm_ellipsoidWgs84TextureCoordinates,
|
||
czm_equalsEpsilon: czm_equalsEpsilon,
|
||
czm_eyeOffset: czm_eyeOffset,
|
||
czm_eyeToWindowCoordinates: czm_eyeToWindowCoordinates,
|
||
czm_fastApproximateAtan: czm_fastApproximateAtan,
|
||
czm_fog: czm_fog,
|
||
czm_gammaCorrect: czm_gammaCorrect,
|
||
czm_geodeticSurfaceNormal: czm_geodeticSurfaceNormal,
|
||
czm_getDefaultMaterial: czm_getDefaultMaterial,
|
||
czm_getLambertDiffuse: czm_getLambertDiffuse,
|
||
czm_getSpecular: czm_getSpecular,
|
||
czm_getWaterNoise: czm_getWaterNoise,
|
||
czm_HSBToRGB: czm_HSBToRGB,
|
||
czm_HSLToRGB: czm_HSLToRGB,
|
||
czm_hue: czm_hue,
|
||
czm_inverseGamma: czm_inverseGamma,
|
||
czm_isEmpty: czm_isEmpty,
|
||
czm_isFull: czm_isFull,
|
||
czm_latitudeToWebMercatorFraction: czm_latitudeToWebMercatorFraction,
|
||
czm_lineDistance: czm_lineDistance,
|
||
czm_luminance: czm_luminance,
|
||
czm_metersPerPixel: czm_metersPerPixel,
|
||
czm_modelToWindowCoordinates: czm_modelToWindowCoordinates,
|
||
czm_multiplyWithColorBalance: czm_multiplyWithColorBalance,
|
||
czm_nearFarScalar: czm_nearFarScalar,
|
||
czm_octDecode: czm_octDecode,
|
||
czm_packDepth: czm_packDepth,
|
||
czm_pbrLighting: czm_pbrLighting,
|
||
czm_pbrMetallicRoughnessMaterial: czm_pbrMetallicRoughnessMaterial,
|
||
czm_pbrSpecularGlossinessMaterial: czm_pbrSpecularGlossinessMaterial,
|
||
czm_phong: czm_phong,
|
||
czm_planeDistance: czm_planeDistance,
|
||
czm_pointAlongRay: czm_pointAlongRay,
|
||
czm_rayEllipsoidIntersectionInterval: czm_rayEllipsoidIntersectionInterval,
|
||
czm_readDepth: czm_readDepth,
|
||
czm_readNonPerspective: czm_readNonPerspective,
|
||
czm_reverseLogDepth: czm_reverseLogDepth,
|
||
czm_RGBToHSB: czm_RGBToHSB,
|
||
czm_RGBToHSL: czm_RGBToHSL,
|
||
czm_RGBToXYZ: czm_RGBToXYZ,
|
||
czm_sampleOctahedralProjection: czm_sampleOctahedralProjection,
|
||
czm_saturation: czm_saturation,
|
||
czm_shadowDepthCompare: czm_shadowDepthCompare,
|
||
czm_shadowVisibility: czm_shadowVisibility,
|
||
czm_signNotZero: czm_signNotZero,
|
||
czm_sphericalHarmonics: czm_sphericalHarmonics,
|
||
czm_tangentToEyeSpaceMatrix: czm_tangentToEyeSpaceMatrix,
|
||
czm_transformPlane: czm_transformPlane,
|
||
czm_translateRelativeToEye: czm_translateRelativeToEye,
|
||
czm_translucentPhong: czm_translucentPhong,
|
||
czm_transpose: czm_transpose,
|
||
czm_unpackDepth: czm_unpackDepth,
|
||
czm_unpackFloat: czm_unpackFloat,
|
||
czm_vertexLogDepth: czm_vertexLogDepth,
|
||
czm_windowToEyeCoordinates: czm_windowToEyeCoordinates,
|
||
czm_writeDepthClamp: czm_writeDepthClamp,
|
||
czm_writeLogDepth: czm_writeLogDepth,
|
||
czm_writeNonPerspective: czm_writeNonPerspective,
|
||
czm_XYZToRGB: czm_XYZToRGB,
|
||
};
|
||
};
|
||
|
||
tobuild();
|
||
|
||
const tocreater = () => {
|
||
for (var builtinName in ((ShaderSource.prototype.clone = function () {
|
||
return new ShaderSource({
|
||
sources: this.sources,
|
||
defines: this.defines,
|
||
pickColorQualifier: this.pickColorQualifier,
|
||
includeBuiltIns: this.includeBuiltIns,
|
||
});
|
||
}),
|
||
(ShaderSource.replaceMain = function (e, t) {
|
||
return (t = "void " + t + "()"), e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g, t);
|
||
}),
|
||
(ShaderSource.prototype.createCombinedVertexShader = function (e) {
|
||
return combineShader(this, !1, e);
|
||
}),
|
||
(ShaderSource.prototype.createCombinedFragmentShader = function (e) {
|
||
return combineShader(this, !0, e);
|
||
}),
|
||
(ShaderSource._czmBuiltinsAndUniforms = {}),
|
||
CzmBuiltins))
|
||
CzmBuiltins.hasOwnProperty(builtinName) &&
|
||
(ShaderSource._czmBuiltinsAndUniforms[builtinName] = CzmBuiltins[builtinName]);
|
||
for (var uniformName in AutomaticUniforms)
|
||
if (AutomaticUniforms.hasOwnProperty(uniformName)) {
|
||
var uniform = AutomaticUniforms[uniformName];
|
||
"function" == typeof uniform.getDeclaration &&
|
||
(ShaderSource._czmBuiltinsAndUniforms[uniformName] = uniform.getDeclaration(
|
||
uniformName
|
||
));
|
||
}
|
||
};
|
||
|
||
tocreater();
|
||
|
||
const removeComments = (e) => {
|
||
return (e = e.replace(/\/\/.*/g, "")).replace(/\/\*\*[\s\S]*?\*\//gm, (e) => {
|
||
for (var t = e.match(/\n/gm).length, i = "", r = 0; r < t; ++r) i += "\n";
|
||
return i;
|
||
});
|
||
};
|
||
|
||
const getDependencyNode = (e, t, i) => {
|
||
var r;
|
||
i.forEach((element) => {
|
||
element.name === e && (r = element);
|
||
});
|
||
return (
|
||
defined(r) ||
|
||
((r = {
|
||
name: e,
|
||
glslSource: (t = removeComments(t)),
|
||
dependsOn: [],
|
||
requiredBy: [],
|
||
evaluated: !1,
|
||
}),
|
||
i.push(r)),
|
||
r
|
||
);
|
||
};
|
||
|
||
const generateDependencies = (e, t) => {
|
||
if (!e.evaluated) {
|
||
e.evaluated = !0;
|
||
var i = e.glslSource.match(/\bczm_[a-zA-Z0-9_]*/g);
|
||
defined(i) &&
|
||
null !== i &&
|
||
(i = i.filter(function (e, t) {
|
||
return i.indexOf(e) === t;
|
||
})).forEach(function (i) {
|
||
if (i !== e.name && ShaderSource._czmBuiltinsAndUniforms.hasOwnProperty(i)) {
|
||
var r = getDependencyNode(i, ShaderSource._czmBuiltinsAndUniforms[i], t);
|
||
e.dependsOn.push(r), r.requiredBy.push(e), generateDependencies(r, t);
|
||
}
|
||
});
|
||
}
|
||
};
|
||
|
||
const sortDependencies = (e) => {
|
||
for (var t = [], i = []; e.length > 0; ) {
|
||
var r = e.pop();
|
||
i.push(r), 0 === r.requiredBy.length && t.push(r);
|
||
}
|
||
for (; t.length > 0; ) {
|
||
var n = t.shift();
|
||
e.push(n);
|
||
for (var a = 0; a < n.dependsOn.length; ++a) {
|
||
var o = n.dependsOn[a],
|
||
s = o.requiredBy.indexOf(n);
|
||
o.requiredBy.splice(s, 1), 0 === o.requiredBy.length && t.push(o);
|
||
}
|
||
}
|
||
for (var l = 0; l < i.length; ++l) i[l].requiredBy.length;
|
||
};
|
||
|
||
const getBuiltinsAndAutomaticUniforms = (e) => {
|
||
var t = [],
|
||
i = getDependencyNode("main", e, t);
|
||
generateDependencies(i, t), sortDependencies(t);
|
||
for (var r = "", n = t.length - 1; n >= 0; --n) r = r + t[n].glslSource + "\n";
|
||
return r.replace(i.glslSource, "");
|
||
};
|
||
|
||
const combineShader = (e, t, i) => {
|
||
var r,
|
||
n,
|
||
a,
|
||
o = "",
|
||
s = e.sources;
|
||
if (defined(s)) for (r = 0, n = s.length; r < n; ++r) o += "\n#line 0\n" + s[r];
|
||
o = (o = removeComments(o)).replace(/#version\s+(.*?)\n/gm, (e, t) => {
|
||
return (a = t), "\n";
|
||
});
|
||
var l = [];
|
||
o = (o = o.replace(/#extension.*\n/gm, (e) => {
|
||
return l.push(e), "\n";
|
||
})).replace(/precision\s(lowp|mediump|highp)\s(float|int);/, "");
|
||
var c = e.pickColorQualifier;
|
||
defined(c) && (o = ShaderSource.createPickFragmentShaderSource(o, c));
|
||
var u = "";
|
||
defined(a) && (u = "#version " + a + "\n");
|
||
var d = l.length;
|
||
for (r = 0; r < d; r++) u += l[r];
|
||
t &&
|
||
(u +=
|
||
"#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n #define highp mediump\n#endif\n\n");
|
||
var h = e.defines;
|
||
if (defined(h))
|
||
for (r = 0, n = h.length; r < n; ++r) {
|
||
var p = h[r];
|
||
0 !== p.length && (u += "#define " + p + "\n");
|
||
}
|
||
return (
|
||
i.webgl2 && (u += "#define OUTPUT_DECLARATION\n\n"),
|
||
i.textureFloatLinear && (u += "#define OES_texture_float_linear\n\n"),
|
||
i.floatingPointTexture && (u += "#define OES_texture_float\n\n"),
|
||
e.includeBuiltIns && (u += getBuiltinsAndAutomaticUniforms(o)),
|
||
(u += "\n#line 0\n"),
|
||
(u += o),
|
||
i.webgl2 && (u = modernizeShader(u, t)),
|
||
u
|
||
);
|
||
};
|
||
|
||
var PolylineFS$1 =
|
||
"#ifdef VECTOR_TILE\nuniform vec4 u_highlightColor;\n#endif\nvarying vec2 v_st;\nvoid main()\n{\nczm_materialInput materialInput;\nvec2 st = v_st;\nst.t = czm_readNonPerspective(st.t, gl_FragCoord.w);\nmaterialInput.s = st.s;\nmaterialInput.st = st;\nmaterialInput.str = vec3(st, 0.0);\nczm_material material = czm_getMaterial(materialInput);\ngl_FragColor = vec4(material.diffuse + material.emission, material.alpha);\n#ifdef VECTOR_TILE\ngl_FragColor *= u_highlightColor;\n#endif\nczm_writeLogDepth();\n}\n";
|
||
|
||
var PolylineVS =
|
||
"attribute vec3 position3DHigh;\nattribute vec3 position3DLow;\nattribute vec3 position2DHigh;\nattribute vec3 position2DLow;\nattribute vec3 prevPosition3DHigh;\nattribute vec3 prevPosition3DLow;\nattribute vec3 prevPosition2DHigh;\nattribute vec3 prevPosition2DLow;\nattribute vec3 nextPosition3DHigh;\nattribute vec3 nextPosition3DLow;\nattribute vec3 nextPosition2DHigh;\nattribute vec3 nextPosition2DLow;\nattribute vec4 texCoordExpandAndBatchIndex;\nvarying vec2 v_st;\nvarying float v_width;\nvarying vec4 v_pickColor;\nvarying float v_polylineAngle;\nvoid main()\n{\nfloat texCoord = texCoordExpandAndBatchIndex.x;\nfloat expandDir = texCoordExpandAndBatchIndex.y;\nbool usePrev = texCoordExpandAndBatchIndex.z < 0.0;\nfloat batchTableIndex = texCoordExpandAndBatchIndex.w;\nvec2 widthAndShow = batchTable_getWidthAndShow(batchTableIndex);\nfloat width = widthAndShow.x + 0.5;\nfloat show = widthAndShow.y;\nif (width < 1.0)\n{\nshow = 0.0;\n}\nvec4 pickColor = batchTable_getPickColor(batchTableIndex);\nvec4 p, prev, next;\nif (czm_morphTime == 1.0)\n{\np = czm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz);\nprev = czm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz);\nnext = czm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz);\n}\nelse if (czm_morphTime == 0.0)\n{\np = czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy);\nprev = czm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy);\nnext = czm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy);\n}\nelse\n{\np = czm_columbusViewMorph(\nczm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy),\nczm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz),\nczm_morphTime);\nprev = czm_columbusViewMorph(\nczm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy),\nczm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz),\nczm_morphTime);\nnext = czm_columbusViewMorph(\nczm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy),\nczm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz),\nczm_morphTime);\n}\n#ifdef DISTANCE_DISPLAY_CONDITION\nvec3 centerHigh = batchTable_getCenterHigh(batchTableIndex);\nvec4 centerLowAndRadius = batchTable_getCenterLowAndRadius(batchTableIndex);\nvec3 centerLow = centerLowAndRadius.xyz;\nfloat radius = centerLowAndRadius.w;\nvec2 distanceDisplayCondition = batchTable_getDistanceDisplayCondition(batchTableIndex);\nfloat lengthSq;\nif (czm_sceneMode == czm_sceneMode2D)\n{\nlengthSq = czm_eyeHeight2D.y;\n}\nelse\n{\nvec4 center = czm_translateRelativeToEye(centerHigh.xyz, centerLow.xyz);\nlengthSq = max(0.0, dot(center.xyz, center.xyz) - radius * radius);\n}\nfloat nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x;\nfloat farSq = distanceDisplayCondition.y * distanceDisplayCondition.y;\nif (lengthSq < nearSq || lengthSq > farSq)\n{\nshow = 0.0;\n}\n#endif\nfloat polylineAngle;\nvec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, polylineAngle);\ngl_Position = czm_viewportOrthographic * positionWC * show;\nv_st.s = texCoord;\nv_st.t = czm_writeNonPerspective(clamp(expandDir, 0.0, 1.0), gl_Position.w);\nv_width = width;\nv_pickColor = pickColor;\nv_polylineAngle = polylineAngle;\n}\n";
|
||
|
||
var PolylineCommon =
|
||
"void clipLineSegmentToNearPlane(\nvec3 p0,\nvec3 p1,\nout vec4 positionWC,\nout bool clipped,\nout bool culledByNearPlane,\nout vec4 clippedPositionEC)\n{\nculledByNearPlane = false;\nclipped = false;\nvec3 p0ToP1 = p1 - p0;\nfloat magnitude = length(p0ToP1);\nvec3 direction = normalize(p0ToP1);\nfloat endPoint0Distance = czm_currentFrustum.x + p0.z;\nfloat denominator = -direction.z;\nif (endPoint0Distance > 0.0 && abs(denominator) < czm_epsilon7)\n{\nculledByNearPlane = true;\n}\nelse if (endPoint0Distance > 0.0)\n{\nfloat t = endPoint0Distance / denominator;\nif (t < 0.0 || t > magnitude)\n{\nculledByNearPlane = true;\n}\nelse\n{\np0 = p0 + t * direction;\np0.z = min(p0.z, -czm_currentFrustum.x);\nclipped = true;\n}\n}\nclippedPositionEC = vec4(p0, 1.0);\npositionWC = czm_eyeToWindowCoordinates(clippedPositionEC);\n}\nvec4 getPolylineWindowCoordinatesEC(vec4 positionEC, vec4 prevEC, vec4 nextEC, float expandDirection, float width, bool usePrevious, out float angle)\n{\n#ifdef POLYLINE_DASH\nvec4 positionWindow = czm_eyeToWindowCoordinates(positionEC);\nvec4 previousWindow = czm_eyeToWindowCoordinates(prevEC);\nvec4 nextWindow = czm_eyeToWindowCoordinates(nextEC);\nvec2 lineDir;\nif (usePrevious) {\nlineDir = normalize(positionWindow.xy - previousWindow.xy);\n}\nelse {\nlineDir = normalize(nextWindow.xy - positionWindow.xy);\n}\nangle = atan(lineDir.x, lineDir.y) - 1.570796327;\nangle = floor(angle / czm_piOverFour + 0.5) * czm_piOverFour;\n#endif\nvec4 clippedPrevWC, clippedPrevEC;\nbool prevSegmentClipped, prevSegmentCulled;\nclipLineSegmentToNearPlane(prevEC.xyz, positionEC.xyz, clippedPrevWC, prevSegmentClipped, prevSegmentCulled, clippedPrevEC);\nvec4 clippedNextWC, clippedNextEC;\nbool nextSegmentClipped, nextSegmentCulled;\nclipLineSegmentToNearPlane(nextEC.xyz, positionEC.xyz, clippedNextWC, nextSegmentClipped, nextSegmentCulled, clippedNextEC);\nbool segmentClipped, segmentCulled;\nvec4 clippedPositionWC, clippedPositionEC;\nclipLineSegmentToNearPlane(positionEC.xyz, usePrevious ? prevEC.xyz : nextEC.xyz, clippedPositionWC, segmentClipped, segmentCulled, clippedPositionEC);\nif (segmentCulled)\n{\nreturn vec4(0.0, 0.0, 0.0, 1.0);\n}\nvec2 directionToPrevWC = normalize(clippedPrevWC.xy - clippedPositionWC.xy);\nvec2 directionToNextWC = normalize(clippedNextWC.xy - clippedPositionWC.xy);\nif (prevSegmentCulled)\n{\ndirectionToPrevWC = -directionToNextWC;\n}\nelse if (nextSegmentCulled)\n{\ndirectionToNextWC = -directionToPrevWC;\n}\nvec2 thisSegmentForwardWC, otherSegmentForwardWC;\nif (usePrevious)\n{\nthisSegmentForwardWC = -directionToPrevWC;\notherSegmentForwardWC = directionToNextWC;\n}\nelse\n{\nthisSegmentForwardWC = directionToNextWC;\notherSegmentForwardWC = -directionToPrevWC;\n}\nvec2 thisSegmentLeftWC = vec2(-thisSegmentForwardWC.y, thisSegmentForwardWC.x);\nvec2 leftWC = thisSegmentLeftWC;\nfloat expandWidth = width * 0.5;\nif (!czm_equalsEpsilon(prevEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1) && !czm_equalsEpsilon(nextEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1))\n{\nvec2 otherSegmentLeftWC = vec2(-otherSegmentForwardWC.y, otherSegmentForwardWC.x);\nvec2 leftSumWC = thisSegmentLeftWC + otherSegmentLeftWC;\nfloat leftSumLength = length(leftSumWC);\nleftWC = leftSumLength < czm_epsilon6 ? thisSegmentLeftWC : (leftSumWC / leftSumLength);\nvec2 u = -thisSegmentForwardWC;\nvec2 v = leftWC;\nfloat sinAngle = abs(u.x * v.y - u.y * v.x);\nexpandWidth = clamp(expandWidth / sinAngle, 0.0, width * 2.0);\n}\nvec2 offset = leftWC * expandDirection * expandWidth * czm_pixelRatio;\nreturn vec4(clippedPositionWC.xy + offset, -clippedPositionWC.z, 1.0) * (czm_projection * clippedPositionEC).w;\n}\nvec4 getPolylineWindowCoordinates(vec4 position, vec4 previous, vec4 next, float expandDirection, float width, bool usePrevious, out float angle)\n{\nvec4 positionEC = czm_modelViewRelativeToEye * position;\nvec4 prevEC = czm_modelViewRelativeToEye * previous;\nvec4 nextEC = czm_modelViewRelativeToEye * next;\nreturn getPolylineWindowCoordinatesEC(positionEC, prevEC, nextEC, expandDirection, width, usePrevious, angle);\n}\n";
|
||
|
||
const ShaderProgram = (e) => {
|
||
var t = e.vertexShaderText,
|
||
i = e.fragmentShaderText;
|
||
"undefined" != typeof spector &&
|
||
((t = t.replace(/^#line/gm, "//#line")), (i = i.replace(/^#line/gm, "//#line")));
|
||
var r = handleUniformPrecisionMismatches(t, i);
|
||
(this._gl = e.gl),
|
||
(this._logShaderCompilation = e.logShaderCompilation),
|
||
(this._debugShaders = e.debugShaders),
|
||
(this._attributeLocations = e.attributeLocations),
|
||
(this._program = void 0),
|
||
(this._numberOfVertexAttributes = void 0),
|
||
(this._vertexAttributes = void 0),
|
||
(this._uniformsByName = void 0),
|
||
(this._uniforms = void 0),
|
||
(this._automaticUniforms = void 0),
|
||
(this._manualUniforms = void 0),
|
||
(this._duplicateUniformNames = r.duplicateUniformNames),
|
||
(this._cachedShader = void 0),
|
||
(this.maximumTextureUnitIndex = void 0),
|
||
(this._vertexShaderSource = e.vertexShaderSource),
|
||
(this._vertexShaderText = e.vertexShaderText),
|
||
(this._fragmentShaderSource = e.fragmentShaderSource),
|
||
(this._fragmentShaderText = r.fragmentShaderText),
|
||
(this.id = nextShaderProgramId++);
|
||
};
|
||
|
||
ShaderProgram.fromCache = (e) => {
|
||
return (e = defaultValue(
|
||
e,
|
||
defaultValue.EMPTY_OBJECT
|
||
)).context.shaderCache.getShaderProgram(e);
|
||
};
|
||
|
||
var attributeLocations$5 = {
|
||
texCoordExpandAndBatchIndex: 0,
|
||
position3DHigh: 1,
|
||
position3DLow: 2,
|
||
position2DHigh: 3,
|
||
position2DLow: 4,
|
||
prevPosition3DHigh: 5,
|
||
prevPosition3DLow: 6,
|
||
prevPosition2DHigh: 7,
|
||
prevPosition2DLow: 8,
|
||
nextPosition3DHigh: 9,
|
||
nextPosition3DLow: 10,
|
||
nextPosition2DHigh: 11,
|
||
nextPosition2DLow: 12,
|
||
};
|
||
|
||
class PolylineBucket {
|
||
constructor(e, t, i) {
|
||
(this.polylines = []),
|
||
(this.lengthOfPositions = 0),
|
||
(this.material = e),
|
||
(this.shaderProgram = void 0),
|
||
(this.mode = t),
|
||
(this.modelMatrix = i);
|
||
}
|
||
addPolyline(e) {
|
||
this.polylines.push(e),
|
||
(e._actualLength = this.getPolylinePositionsLength(e)),
|
||
(this.lengthOfPositions += e._actualLength),
|
||
(e._bucket = this);
|
||
}
|
||
getPolylinePositionsLength(e) {
|
||
var t;
|
||
if (this.mode === SceneMode$1.SCENE3D || !intersectsIDL(e))
|
||
return 4 * (t = e._actualPositions.length) - 4;
|
||
var i = 0,
|
||
r = e._segments.lengths;
|
||
r.forEach((element) => {
|
||
i += 4 * element - 4;
|
||
});
|
||
return i;
|
||
}
|
||
updateShader(e, t, i) {
|
||
if (!defined(this.shaderProgram)) {
|
||
var r = ["DISTANCE_DISPLAY_CONDITION"];
|
||
i && r.push("VECTOR_TILE"),
|
||
-1 !==
|
||
this.material.shaderSource.search(/varying\s+float\s+v_polylineAngle;/g) &&
|
||
r.push("POLYLINE_DASH"),
|
||
FeatureDetection.isInternetExplorer() || r.push("CLIP_POLYLINE");
|
||
//Cesium.ShaderSource
|
||
var n = new ShaderSource({
|
||
defines: r,
|
||
sources: [
|
||
"varying vec4 v_pickColor;\n",
|
||
this.material.shaderSource,
|
||
PolylineFS$1,
|
||
],
|
||
}),
|
||
a = t.getVertexShaderCallback()(PolylineVS),
|
||
o = new ShaderSource({ defines: r, sources: [PolylineCommon, a] });
|
||
this.shaderProgram = ShaderProgram.fromCache({
|
||
context: e,
|
||
vertexShaderSource: o,
|
||
fragmentShaderSource: n,
|
||
attributeLocations: attributeLocations$5,
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
const sortPolylinesIntoBuckets = (e) => {
|
||
var t = e._mode,
|
||
i = e._modelMatrix,
|
||
r = (e._polylineBuckets = {}),
|
||
n = e._polylines;
|
||
n.forEach((element) => {
|
||
var s = element;
|
||
if (s._actualPositions.length > 1) {
|
||
s.update();
|
||
var l = s.material,
|
||
c = r[l.type];
|
||
defined(c) || (c = r[l.type] = new PolylineBucket(l, t, i)), c.addPolyline(s);
|
||
}
|
||
});
|
||
};
|
||
|
||
var CesiumMath = {
|
||
EPSILON1: 0.1,
|
||
EPSILON2: 0.01,
|
||
EPSILON3: 0.001,
|
||
EPSILON4: 1e-4,
|
||
EPSILON5: 1e-5,
|
||
EPSILON6: 1e-6,
|
||
EPSILON7: 1e-7,
|
||
EPSILON8: 1e-8,
|
||
EPSILON9: 1e-9,
|
||
EPSILON10: 1e-10,
|
||
EPSILON11: 1e-11,
|
||
EPSILON12: 1e-12,
|
||
EPSILON13: 1e-13,
|
||
EPSILON14: 1e-14,
|
||
EPSILON15: 1e-15,
|
||
EPSILON16: 1e-16,
|
||
EPSILON17: 1e-17,
|
||
EPSILON18: 1e-18,
|
||
EPSILON19: 1e-19,
|
||
EPSILON20: 1e-20,
|
||
EPSILON21: 1e-21,
|
||
GRAVITATIONALPARAMETER: 3986004418e5,
|
||
SOLAR_RADIUS: 6955e5,
|
||
LUNAR_RADIUS: 1737400,
|
||
SIXTY_FOUR_KILOBYTES: 65536,
|
||
FOUR_GIGABYTES: 4294967296,
|
||
};
|
||
CesiumMath.PI = Math.PI;
|
||
|
||
var scratchLengths = new Array(1);
|
||
var scratchSegments = { positions: void 0, lengths: void 0 };
|
||
var pscratch = new Cesium.Cartesian3();
|
||
var scratchCartographic$a = new Cesium.Cartographic();
|
||
|
||
PolylineBucket.prototype.getSegments = function (e, t) {
|
||
var i = e._actualPositions;
|
||
if (this.mode === SceneMode$1.SCENE3D)
|
||
return (
|
||
(scratchLengths[0] = i.length),
|
||
(scratchSegments.positions = i),
|
||
(scratchSegments.lengths = scratchLengths),
|
||
scratchSegments
|
||
);
|
||
intersectsIDL(e) && (i = e._segments.positions);
|
||
var r,
|
||
n = t.ellipsoid,
|
||
a = [],
|
||
o = this.modelMatrix,
|
||
l = pscratch;
|
||
i.forEach((element) => {
|
||
r = element;
|
||
l = Cesium.Matrix4.multiplyByPoint(o, r, l);
|
||
a.push(t.project(n.cartesianToCartographic(l, scratchCartographic$a)));
|
||
});
|
||
if (a.length > 0) {
|
||
e._boundingVolume2D = Cesium.BoundingSphere.fromPoints(a, e._boundingVolume2D);
|
||
var u = e._boundingVolume2D.center;
|
||
e._boundingVolume2D.center = new Cesium.Cartesian3(u.z, u.x, u.y);
|
||
}
|
||
return (
|
||
(scratchSegments.positions = a),
|
||
(scratchSegments.lengths = e._segments.lengths),
|
||
scratchSegments
|
||
);
|
||
};
|
||
|
||
var scratchWriteVector = new Cesium.Cartesian3();
|
||
var scratchWriteNextPosition = new Cesium.Cartesian3();
|
||
var scratchWritePrevPosition = new Cesium.Cartesian3();
|
||
var scratchWritePosition = new Cesium.Cartesian3();
|
||
var scratchEncode = { high: 0, low: 0 };
|
||
var scratchPickColorCartesian = new Cesium.Cartesian4();
|
||
var scratchWidthShowCartesian = new Cesium.Cartesian2();
|
||
var scratchUpdatePolylineCartesian4 = new Cesium.Cartesian4();
|
||
var scratchNearFarCartesian2 = new Cesium.Cartesian2();
|
||
|
||
class EncodedCartesian3 {
|
||
constructor() {
|
||
(this.high = Cesium.Cartesian3.clone(Cesium.Cartesian3.ZERO)),
|
||
(this.low = Cesium.Cartesian3.clone(Cesium.Cartesian3.ZERO));
|
||
}
|
||
}
|
||
|
||
EncodedCartesian3.encode = function (e, t) {
|
||
var i;
|
||
return (
|
||
defined(t) || (t = { high: 0, low: 0 }),
|
||
e >= 0
|
||
? ((i = 65536 * Math.floor(e / 65536)), (t.high = i), (t.low = e - i))
|
||
: ((i = 65536 * Math.floor(-e / 65536)), (t.high = -i), (t.low = e + i)),
|
||
t
|
||
);
|
||
};
|
||
|
||
EncodedCartesian3.fromCartesian = function (e, t) {
|
||
defined(t) || (t = new EncodedCartesian3());
|
||
var i = t.high,
|
||
r = t.low;
|
||
return (
|
||
EncodedCartesian3.encode(e.x, scratchEncode),
|
||
(i.x = scratchEncode.high),
|
||
(r.x = scratchEncode.low),
|
||
EncodedCartesian3.encode(e.y, scratchEncode),
|
||
(i.y = scratchEncode.high),
|
||
(r.y = scratchEncode.low),
|
||
EncodedCartesian3.encode(e.z, scratchEncode),
|
||
(i.z = scratchEncode.high),
|
||
(r.z = scratchEncode.low),
|
||
t
|
||
);
|
||
};
|
||
|
||
var encodedP = new EncodedCartesian3();
|
||
|
||
EncodedCartesian3.writeElements = function (e, t, i) {
|
||
EncodedCartesian3.fromCartesian(e, encodedP);
|
||
var r = encodedP.high,
|
||
n = encodedP.low;
|
||
(t[i] = r.x),
|
||
(t[i + 1] = r.y),
|
||
(t[i + 2] = r.z),
|
||
(t[i + 3] = n.x),
|
||
(t[i + 4] = n.y),
|
||
(t[i + 5] = n.z);
|
||
};
|
||
|
||
var scratchUpdatePolylineEncodedCartesian = new EncodedCartesian3();
|
||
|
||
function Color(e, t, i, r) {
|
||
(this.red = defaultValue(e, 1)),
|
||
(this.green = defaultValue(t, 1)),
|
||
(this.blue = defaultValue(i, 1)),
|
||
(this.alpha = defaultValue(r, 1));
|
||
}
|
||
|
||
Color.floatToByte = function (e) {
|
||
return 1 === e ? 255 : (256 * e) | 0;
|
||
};
|
||
|
||
PolylineBucket.prototype.write = function (e, t, i, r, n, a, o, s) {
|
||
for (
|
||
var l = this.mode,
|
||
c = s.ellipsoid.maximumRadius * CesiumMath.PI,
|
||
u = this.polylines,
|
||
d = u.length,
|
||
h = 0;
|
||
h < d;
|
||
++h
|
||
) {
|
||
for (
|
||
var p,
|
||
f = u[h],
|
||
m = f.width,
|
||
g = f.show && m > 0,
|
||
_ = f._index,
|
||
y = this.getSegments(f, s),
|
||
v = y.positions,
|
||
C = y.lengths,
|
||
T = v.length,
|
||
S = f.getPickId(o).color,
|
||
A = 0,
|
||
x = 0,
|
||
E = 0;
|
||
E < T;
|
||
++E
|
||
) {
|
||
0 === E
|
||
? f._loop
|
||
? (p = v[T - 2])
|
||
: ((p = scratchWriteVector),
|
||
Cesium.Cartesian3.subtract(v[0], v[1], p),
|
||
Cesium.Cartesian3.add(v[0], p, p))
|
||
: (p = v[E - 1]),
|
||
Cesium.Cartesian3.clone(p, scratchWritePrevPosition),
|
||
Cesium.Cartesian3.clone(v[E], scratchWritePosition),
|
||
E === T - 1
|
||
? f._loop
|
||
? (p = v[1])
|
||
: ((p = scratchWriteVector),
|
||
Cesium.Cartesian3.subtract(v[T - 1], v[T - 2], p),
|
||
Cesium.Cartesian3.add(v[T - 1], p, p))
|
||
: (p = v[E + 1]),
|
||
Cesium.Cartesian3.clone(p, scratchWriteNextPosition);
|
||
var b = C[A];
|
||
E === x + b && ((x += b), ++A);
|
||
var P = E - x == 0,
|
||
D = E === x + C[A] - 1;
|
||
l === SceneMode$1.SCENE2D &&
|
||
((scratchWritePrevPosition.z = 0),
|
||
(scratchWritePosition.z = 0),
|
||
(scratchWriteNextPosition.z = 0)),
|
||
(l !== SceneMode$1.SCENE2D && l !== SceneMode$1.MORPHING) ||
|
||
((P || D) &&
|
||
c - Math.abs(scratchWritePosition.x) < 1 &&
|
||
(((scratchWritePosition.x < 0 && scratchWritePrevPosition.x > 0) ||
|
||
(scratchWritePosition.x > 0 && scratchWritePrevPosition.x < 0)) &&
|
||
Cesium.Cartesian3.clone(scratchWritePosition, scratchWritePrevPosition),
|
||
((scratchWritePosition.x < 0 && scratchWriteNextPosition.x > 0) ||
|
||
(scratchWritePosition.x > 0 && scratchWriteNextPosition.x < 0)) &&
|
||
Cesium.Cartesian3.clone(scratchWritePosition, scratchWriteNextPosition)));
|
||
for (var w = D ? 2 : 4, M = P ? 2 : 0; M < w; ++M) {
|
||
EncodedCartesian3.writeElements(scratchWritePosition, e, i),
|
||
EncodedCartesian3.writeElements(scratchWritePrevPosition, e, i + 6),
|
||
EncodedCartesian3.writeElements(scratchWriteNextPosition, e, i + 12);
|
||
var I = M - 2 < 0 ? -1 : 1;
|
||
(t[n] = E / (T - 1)),
|
||
(t[n + 1] = (M % 2) * 2 - 1),
|
||
(t[n + 2] = I),
|
||
(t[n + 3] = _),
|
||
(i += 18),
|
||
(n += 4);
|
||
}
|
||
}
|
||
var R = scratchPickColorCartesian;
|
||
(R.x = Color.floatToByte(S.red)),
|
||
(R.y = Color.floatToByte(S.green)),
|
||
(R.z = Color.floatToByte(S.blue)),
|
||
(R.w = Color.floatToByte(S.alpha));
|
||
var O = scratchWidthShowCartesian;
|
||
(O.x = m), (O.y = g ? 1 : 0);
|
||
var B = l === SceneMode$1.SCENE2D ? f._boundingVolume2D : f._boundingVolumeWC,
|
||
L = EncodedCartesian3.fromCartesian(
|
||
B.center,
|
||
scratchUpdatePolylineEncodedCartesian
|
||
),
|
||
F = L.high,
|
||
N = Cesium.Cartesian4.fromElements(
|
||
L.low.x,
|
||
L.low.y,
|
||
L.low.z,
|
||
B.radius,
|
||
scratchUpdatePolylineCartesian4
|
||
),
|
||
V = scratchNearFarCartesian2;
|
||
(V.x = 0), (V.y = Number.MAX_VALUE);
|
||
var k = f.distanceDisplayCondition;
|
||
defined(k) && ((V.x = k.near), (V.y = k.far)),
|
||
a.setBatchedAttribute(_, 0, O),
|
||
a.setBatchedAttribute(_, 1, R),
|
||
a.attributes.length > 2 &&
|
||
(a.setBatchedAttribute(_, 2, F),
|
||
a.setBatchedAttribute(_, 3, N),
|
||
a.setBatchedAttribute(_, 4, V));
|
||
}
|
||
};
|
||
|
||
var morphVectorScratch = new Cesium.Cartesian3();
|
||
var morphNextPositionScratch = new Cesium.Cartesian3();
|
||
var morphPrevPositionScratch = new Cesium.Cartesian3();
|
||
var morphPositionScratch = new Cesium.Cartesian3();
|
||
|
||
PolylineBucket.prototype.writeForMorph = function (e, t) {
|
||
var i = this.modelMatrix;
|
||
this.polylines.forEach((element) => {
|
||
for (
|
||
var o = element,
|
||
s = o._segments.positions,
|
||
l = o._segments.lengths,
|
||
c = s.length,
|
||
u = 0,
|
||
d = 0,
|
||
h = 0;
|
||
h < c;
|
||
++h
|
||
) {
|
||
var p;
|
||
0 === h
|
||
? o._loop
|
||
? (p = s[c - 2])
|
||
: ((p = morphVectorScratch),
|
||
Cesium.Cartesian3.subtract(s[0], s[1], p),
|
||
Cesium.Cartesian3.add(s[0], p, p))
|
||
: (p = s[h - 1]),
|
||
(p = Cesium.Matrix4.multiplyByPoint(i, p, morphPrevPositionScratch));
|
||
var f,
|
||
m = Cesium.Matrix4.multiplyByPoint(i, s[h], morphPositionScratch);
|
||
h === c - 1
|
||
? o._loop
|
||
? (f = s[1])
|
||
: ((f = morphVectorScratch),
|
||
Cesium.Cartesian3.subtract(s[c - 1], s[c - 2], f),
|
||
Cesium.Cartesian3.add(s[c - 1], f, f))
|
||
: (f = s[h + 1]),
|
||
(f = Cesium.Matrix4.multiplyByPoint(i, f, morphNextPositionScratch));
|
||
var g = l[u];
|
||
h === d + g && ((d += g), ++u);
|
||
for (
|
||
var _ = h - d == 0, y = h === d + l[u] - 1 ? 2 : 4, v = _ ? 2 : 0;
|
||
v < y;
|
||
++v
|
||
)
|
||
EncodedCartesian3.writeElements(m, e, t),
|
||
EncodedCartesian3.writeElements(p, e, t + 6),
|
||
EncodedCartesian3.writeElements(f, e, t + 12),
|
||
(t += 18);
|
||
}
|
||
});
|
||
};
|
||
|
||
var scratchSegmentLengths = new Array(1);
|
||
|
||
class VertexArrayBucketLocator {
|
||
constructor(e, t, i) {
|
||
(this.count = e), (this.offset = t), (this.bucket = i);
|
||
}
|
||
}
|
||
|
||
PolylineBucket.prototype.updateIndices = function (e, t, i, r) {
|
||
var n = i.length - 1,
|
||
a = new VertexArrayBucketLocator(0, r, this);
|
||
i[n].push(a);
|
||
var o = 0,
|
||
s = e[e.length - 1],
|
||
l = 0;
|
||
s.length > 0 && (l = s[s.length - 1] + 1);
|
||
for (var c = this.polylines, u = c.length, d = 0; d < u; ++d) {
|
||
var h,
|
||
p = c[d];
|
||
if (((p._locatorBuckets = []), this.mode === SceneMode$1.SCENE3D)) {
|
||
h = scratchSegmentLengths;
|
||
var f = p._actualPositions.length;
|
||
if (!(f > 0)) continue;
|
||
h[0] = f;
|
||
} else h = p._segments.lengths;
|
||
var m = h.length;
|
||
if (m > 0) {
|
||
for (var g = 0, _ = 0; _ < m; ++_)
|
||
for (var y = h[_] - 1, v = 0; v < y; ++v)
|
||
l + 4 > CesiumMath.SIXTY_FOUR_KILOBYTES &&
|
||
(p._locatorBuckets.push({ locator: a, count: g }),
|
||
(g = 0),
|
||
t.push(4),
|
||
(s = []),
|
||
e.push(s),
|
||
(l = 0),
|
||
(a.count = o),
|
||
(o = 0),
|
||
(r = 0),
|
||
(a = new VertexArrayBucketLocator(0, 0, this)),
|
||
(i[++n] = [a])),
|
||
s.push(l, l + 2, l + 1),
|
||
s.push(l + 1, l + 2, l + 3),
|
||
(g += 6),
|
||
(o += 6),
|
||
(r += 6),
|
||
(l += 4);
|
||
p._locatorBuckets.push({ locator: a, count: g }),
|
||
l + 4 > CesiumMath.SIXTY_FOUR_KILOBYTES &&
|
||
(t.push(0),
|
||
(s = []),
|
||
e.push(s),
|
||
(l = 0),
|
||
(a.count = o),
|
||
(r = 0),
|
||
(o = 0),
|
||
(a = new VertexArrayBucketLocator(0, 0, this)),
|
||
(i[++n] = [a]));
|
||
}
|
||
p._clean();
|
||
}
|
||
return (a.count = o), r;
|
||
};
|
||
|
||
var BufferUsage = {
|
||
STREAM_DRAW: WebGLConstants$1.STREAM_DRAW,
|
||
STATIC_DRAW: WebGLConstants$1.STATIC_DRAW,
|
||
DYNAMIC_DRAW: WebGLConstants$1.DYNAMIC_DRAW,
|
||
validate: function (e) {
|
||
return (
|
||
e === BufferUsage.STREAM_DRAW ||
|
||
e === BufferUsage.STATIC_DRAW ||
|
||
e === BufferUsage.DYNAMIC_DRAW
|
||
);
|
||
},
|
||
},
|
||
BufferUsage$1 = Object.freeze(BufferUsage);
|
||
|
||
function Buffer$1(e) {
|
||
var t = (e = defaultValue(e, defaultValue.EMPTY_OBJECT)).context._gl,
|
||
i = e.bufferTarget,
|
||
r = e.typedArray,
|
||
n = e.sizeInBytes,
|
||
a = e.usage,
|
||
o = defined(r);
|
||
o && (n = r.byteLength);
|
||
var s = t.createBuffer();
|
||
t.bindBuffer(i, s),
|
||
t.bufferData(i, o ? r : n, a),
|
||
t.bindBuffer(i, null),
|
||
(this._gl = t),
|
||
(this._webgl2 = e.context._webgl2),
|
||
(this._bufferTarget = i),
|
||
(this._sizeInBytes = n),
|
||
(this._usage = a),
|
||
(this._buffer = s),
|
||
(this.vertexArrayDestroyable = !0);
|
||
}
|
||
|
||
Buffer$1.createVertexBuffer = function (e) {
|
||
return new Buffer$1({
|
||
context: e.context,
|
||
bufferTarget: WebGLConstants$1.ARRAY_BUFFER,
|
||
typedArray: e.typedArray,
|
||
sizeInBytes: e.sizeInBytes,
|
||
usage: e.usage,
|
||
});
|
||
};
|
||
|
||
var IndexDatatype = {
|
||
UNSIGNED_BYTE: WebGLConstants$1.UNSIGNED_BYTE,
|
||
UNSIGNED_SHORT: WebGLConstants$1.UNSIGNED_SHORT,
|
||
UNSIGNED_INT: WebGLConstants$1.UNSIGNED_INT,
|
||
getSizeInBytes: function (e) {
|
||
switch (e) {
|
||
case IndexDatatype.UNSIGNED_BYTE:
|
||
return Uint8Array.BYTES_PER_ELEMENT;
|
||
case IndexDatatype.UNSIGNED_SHORT:
|
||
return Uint16Array.BYTES_PER_ELEMENT;
|
||
case IndexDatatype.UNSIGNED_INT:
|
||
return Uint32Array.BYTES_PER_ELEMENT;
|
||
}
|
||
},
|
||
fromSizeInBytes: function (e) {
|
||
switch (e) {
|
||
case 2:
|
||
return IndexDatatype.UNSIGNED_SHORT;
|
||
case 4:
|
||
return IndexDatatype.UNSIGNED_INT;
|
||
case 1:
|
||
return IndexDatatype.UNSIGNED_BYTE;
|
||
}
|
||
},
|
||
validate: function (e) {
|
||
return (
|
||
defined(e) &&
|
||
(e === IndexDatatype.UNSIGNED_BYTE ||
|
||
e === IndexDatatype.UNSIGNED_SHORT ||
|
||
e === IndexDatatype.UNSIGNED_INT)
|
||
);
|
||
},
|
||
createTypedArray: function (e, t) {
|
||
return e >= CesiumMath.SIXTY_FOUR_KILOBYTES
|
||
? new Uint32Array(t)
|
||
: new Uint16Array(t);
|
||
},
|
||
createTypedArrayFromArrayBuffer: function (e, t, i, r) {
|
||
return e >= CesiumMath.SIXTY_FOUR_KILOBYTES
|
||
? new Uint32Array(t, i, r)
|
||
: new Uint16Array(t, i, r);
|
||
},
|
||
},
|
||
IndexDatatype$1 = Object.freeze(IndexDatatype);
|
||
|
||
Buffer$1.createIndexBuffer = function (e) {
|
||
var t = e.context,
|
||
i = e.indexDatatype,
|
||
r = IndexDatatype$1.getSizeInBytes(i),
|
||
n = new Buffer$1({
|
||
context: t,
|
||
bufferTarget: WebGLConstants$1.ELEMENT_ARRAY_BUFFER,
|
||
typedArray: e.typedArray,
|
||
sizeInBytes: e.sizeInBytes,
|
||
usage: e.usage,
|
||
}),
|
||
a = n.sizeInBytes / r;
|
||
return (
|
||
Object.defineProperties(n, {
|
||
indexDatatype: {
|
||
get: function () {
|
||
return i;
|
||
},
|
||
},
|
||
bytesPerIndex: {
|
||
get: function () {
|
||
return r;
|
||
},
|
||
},
|
||
numberOfIndices: {
|
||
get: function () {
|
||
return a;
|
||
},
|
||
},
|
||
}),
|
||
n
|
||
);
|
||
};
|
||
|
||
var ComponentDatatype = {
|
||
BYTE: WebGLConstants$1.BYTE,
|
||
UNSIGNED_BYTE: WebGLConstants$1.UNSIGNED_BYTE,
|
||
SHORT: WebGLConstants$1.SHORT,
|
||
UNSIGNED_SHORT: WebGLConstants$1.UNSIGNED_SHORT,
|
||
INT: WebGLConstants$1.INT,
|
||
UNSIGNED_INT: WebGLConstants$1.UNSIGNED_INT,
|
||
FLOAT: WebGLConstants$1.FLOAT,
|
||
DOUBLE: WebGLConstants$1.DOUBLE,
|
||
getSizeInBytes: function (e) {
|
||
switch (e) {
|
||
case ComponentDatatype.BYTE:
|
||
return Int8Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.UNSIGNED_BYTE:
|
||
return Uint8Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.SHORT:
|
||
return Int16Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.UNSIGNED_SHORT:
|
||
return Uint16Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.INT:
|
||
return Int32Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.UNSIGNED_INT:
|
||
return Uint32Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.FLOAT:
|
||
return Float32Array.BYTES_PER_ELEMENT;
|
||
case ComponentDatatype.DOUBLE:
|
||
return Float64Array.BYTES_PER_ELEMENT;
|
||
}
|
||
},
|
||
fromTypedArray: function (e) {
|
||
return e instanceof Int8Array
|
||
? ComponentDatatype.BYTE
|
||
: e instanceof Uint8Array
|
||
? ComponentDatatype.UNSIGNED_BYTE
|
||
: e instanceof Int16Array
|
||
? ComponentDatatype.SHORT
|
||
: e instanceof Uint16Array
|
||
? ComponentDatatype.UNSIGNED_SHORT
|
||
: e instanceof Int32Array
|
||
? ComponentDatatype.INT
|
||
: e instanceof Uint32Array
|
||
? ComponentDatatype.UNSIGNED_INT
|
||
: e instanceof Float32Array
|
||
? ComponentDatatype.FLOAT
|
||
: e instanceof Float64Array
|
||
? ComponentDatatype.DOUBLE
|
||
: void 0;
|
||
},
|
||
validate: function (e) {
|
||
return (
|
||
defined(e) &&
|
||
(e === ComponentDatatype.BYTE ||
|
||
e === ComponentDatatype.UNSIGNED_BYTE ||
|
||
e === ComponentDatatype.SHORT ||
|
||
e === ComponentDatatype.UNSIGNED_SHORT ||
|
||
e === ComponentDatatype.INT ||
|
||
e === ComponentDatatype.UNSIGNED_INT ||
|
||
e === ComponentDatatype.FLOAT ||
|
||
e === ComponentDatatype.DOUBLE)
|
||
);
|
||
},
|
||
createTypedArray: function (e, t) {
|
||
switch (e) {
|
||
case ComponentDatatype.BYTE:
|
||
return new Int8Array(t);
|
||
case ComponentDatatype.UNSIGNED_BYTE:
|
||
return new Uint8Array(t);
|
||
case ComponentDatatype.SHORT:
|
||
return new Int16Array(t);
|
||
case ComponentDatatype.UNSIGNED_SHORT:
|
||
return new Uint16Array(t);
|
||
case ComponentDatatype.INT:
|
||
return new Int32Array(t);
|
||
case ComponentDatatype.UNSIGNED_INT:
|
||
return new Uint32Array(t);
|
||
case ComponentDatatype.FLOAT:
|
||
return new Float32Array(t);
|
||
case ComponentDatatype.DOUBLE:
|
||
return new Float64Array(t);
|
||
}
|
||
},
|
||
createArrayBufferView: function (e, t, i, r) {
|
||
switch (
|
||
((i = defaultValue(i, 0)),
|
||
(r = defaultValue(r, (t.byteLength - i) / ComponentDatatype.getSizeInBytes(e))),
|
||
e)
|
||
) {
|
||
case ComponentDatatype.BYTE:
|
||
return new Int8Array(t, i, r);
|
||
case ComponentDatatype.UNSIGNED_BYTE:
|
||
return new Uint8Array(t, i, r);
|
||
case ComponentDatatype.SHORT:
|
||
return new Int16Array(t, i, r);
|
||
case ComponentDatatype.UNSIGNED_SHORT:
|
||
return new Uint16Array(t, i, r);
|
||
case ComponentDatatype.INT:
|
||
return new Int32Array(t, i, r);
|
||
case ComponentDatatype.UNSIGNED_INT:
|
||
return new Uint32Array(t, i, r);
|
||
case ComponentDatatype.FLOAT:
|
||
return new Float32Array(t, i, r);
|
||
case ComponentDatatype.DOUBLE:
|
||
return new Float64Array(t, i, r);
|
||
}
|
||
},
|
||
fromName: function (e) {
|
||
switch (e) {
|
||
case "BYTE":
|
||
return ComponentDatatype.BYTE;
|
||
case "UNSIGNED_BYTE":
|
||
return ComponentDatatype.UNSIGNED_BYTE;
|
||
case "SHORT":
|
||
return ComponentDatatype.SHORT;
|
||
case "UNSIGNED_SHORT":
|
||
return ComponentDatatype.UNSIGNED_SHORT;
|
||
case "INT":
|
||
return ComponentDatatype.INT;
|
||
case "UNSIGNED_INT":
|
||
return ComponentDatatype.UNSIGNED_INT;
|
||
case "FLOAT":
|
||
return ComponentDatatype.FLOAT;
|
||
case "DOUBLE":
|
||
return ComponentDatatype.DOUBLE;
|
||
}
|
||
},
|
||
},
|
||
ComponentDatatype$1 = Object.freeze(ComponentDatatype);
|
||
|
||
var emptyVertexBuffer = [0, 0, 0];
|
||
|
||
Buffer$1.prototype._getBuffer = function () {
|
||
return this._buffer;
|
||
};
|
||
|
||
function addAttribute(e, t, i, r) {
|
||
var n = defined(t.vertexBuffer),
|
||
a = defined(t.value),
|
||
o = t.value ? t.value.length : t.componentsPerAttribute,
|
||
s = {
|
||
index: defaultValue(t.index, i),
|
||
enabled: defaultValue(t.enabled, !0),
|
||
vertexBuffer: t.vertexBuffer,
|
||
value: a ? t.value.slice(0) : void 0,
|
||
componentsPerAttribute: o,
|
||
componentDatatype: defaultValue(t.componentDatatype, ComponentDatatype$1.FLOAT),
|
||
normalize: defaultValue(t.normalize, !1),
|
||
offsetInBytes: defaultValue(t.offsetInBytes, 0),
|
||
strideInBytes: defaultValue(t.strideInBytes, 0),
|
||
instanceDivisor: defaultValue(t.instanceDivisor, 0),
|
||
};
|
||
if (n)
|
||
(s.vertexAttrib = function (e) {
|
||
var t = this.index;
|
||
e.bindBuffer(e.ARRAY_BUFFER, this.vertexBuffer._getBuffer()),
|
||
e.vertexAttribPointer(
|
||
t,
|
||
this.componentsPerAttribute,
|
||
this.componentDatatype,
|
||
this.normalize,
|
||
this.strideInBytes,
|
||
this.offsetInBytes
|
||
),
|
||
e.enableVertexAttribArray(t),
|
||
this.instanceDivisor > 0 &&
|
||
(r.glVertexAttribDivisor(t, this.instanceDivisor),
|
||
(r._vertexAttribDivisors[t] = this.instanceDivisor),
|
||
(r._previousDrawInstanced = !0));
|
||
}),
|
||
(s.disableVertexAttribArray = function (e) {
|
||
e.disableVertexAttribArray(this.index),
|
||
this.instanceDivisor > 0 && r.glVertexAttribDivisor(i, 0);
|
||
});
|
||
else {
|
||
switch (s.componentsPerAttribute) {
|
||
case 1:
|
||
s.vertexAttrib = function (e) {
|
||
e.vertexAttrib1fv(this.index, this.value);
|
||
};
|
||
break;
|
||
case 2:
|
||
s.vertexAttrib = function (e) {
|
||
e.vertexAttrib2fv(this.index, this.value);
|
||
};
|
||
break;
|
||
case 3:
|
||
s.vertexAttrib = function (e) {
|
||
e.vertexAttrib3fv(this.index, this.value);
|
||
};
|
||
break;
|
||
case 4:
|
||
s.vertexAttrib = function (e) {
|
||
e.vertexAttrib4fv(this.index, this.value);
|
||
};
|
||
}
|
||
s.disableVertexAttribArray = function (e) {};
|
||
}
|
||
e.push(s);
|
||
}
|
||
|
||
function bind(e, t, i) {
|
||
for (var r = 0; r < t.length; ++r) {
|
||
var n = t[r];
|
||
n.enabled && n.vertexAttrib(e);
|
||
}
|
||
defined(i) && e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, i._getBuffer());
|
||
}
|
||
|
||
function VertexArray(e) {
|
||
var t,
|
||
i,
|
||
r = (e = defaultValue(e, defaultValue.EMPTY_OBJECT)).context,
|
||
n = r._gl,
|
||
a = e.attributes,
|
||
o = e.indexBuffer,
|
||
s = [],
|
||
l = 1,
|
||
c = !1,
|
||
u = !1,
|
||
d = a.length;
|
||
for (t = 0; t < d; ++t) addAttribute(s, a[t], t, r);
|
||
for (d = s.length, t = 0; t < d; ++t) {
|
||
var h = s[t];
|
||
if (defined(h.vertexBuffer) && 0 === h.instanceDivisor) {
|
||
var p =
|
||
h.strideInBytes ||
|
||
h.componentsPerAttribute *
|
||
ComponentDatatype$1.getSizeInBytes(h.componentDatatype);
|
||
l = h.vertexBuffer.sizeInBytes / p;
|
||
break;
|
||
}
|
||
}
|
||
for (t = 0; t < d; ++t)
|
||
s[t].instanceDivisor > 0 && (c = !0), defined(s[t].value) && (u = !0);
|
||
r.vertexArrayObject &&
|
||
((i = r.glCreateVertexArray()),
|
||
r.glBindVertexArray(i),
|
||
bind(n, s, o),
|
||
r.glBindVertexArray(null)),
|
||
(this._numberOfVertices = l),
|
||
(this._hasInstancedAttributes = c),
|
||
(this._hasConstantAttributes = u),
|
||
(this._context = r),
|
||
(this._gl = n),
|
||
(this._vao = i),
|
||
(this._attributes = s),
|
||
(this._indexBuffer = o);
|
||
}
|
||
|
||
function setVertexAttribDivisor(e) {
|
||
var t = e._context,
|
||
i = e._hasInstancedAttributes;
|
||
if (i || t._previousDrawInstanced) {
|
||
t._previousDrawInstanced = i;
|
||
var r,
|
||
n = t._vertexAttribDivisors,
|
||
a = e._attributes,
|
||
o = Cesium.ContextLimits.maximumVertexAttributes;
|
||
if (i) {
|
||
var s = a.length;
|
||
for (r = 0; r < s; ++r) {
|
||
var l = a[r];
|
||
if (l.enabled) {
|
||
var c = l.instanceDivisor,
|
||
u = l.index;
|
||
c !== n[u] && (t.glVertexAttribDivisor(u, c), (n[u] = c));
|
||
}
|
||
}
|
||
} else
|
||
for (r = 0; r < o; ++r) n[r] > 0 && (t.glVertexAttribDivisor(r, 0), (n[r] = 0));
|
||
}
|
||
}
|
||
|
||
function setConstantAttributes(e, t) {
|
||
for (var i = e._attributes, r = i.length, n = 0; n < r; ++n) {
|
||
var a = i[n];
|
||
a.enabled && defined(a.value) && a.vertexAttrib(t);
|
||
}
|
||
}
|
||
|
||
VertexArray.prototype._bind = function () {
|
||
defined(this._vao)
|
||
? (this._context.glBindVertexArray(this._vao),
|
||
this._context.instancedArrays && setVertexAttribDivisor(this),
|
||
this._hasConstantAttributes && setConstantAttributes(this, this._gl))
|
||
: bind(this._gl, this._attributes, this._indexBuffer);
|
||
};
|
||
|
||
VertexArray.prototype._unBind = function () {
|
||
if (defined(this._vao)) this._context.glBindVertexArray(null);
|
||
else {
|
||
for (var e = this._attributes, t = this._gl, i = 0; i < e.length; ++i) {
|
||
var r = e[i];
|
||
r.enabled && r.disableVertexAttribArray(t);
|
||
}
|
||
this._indexBuffer && t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, null);
|
||
}
|
||
};
|
||
|
||
VertexArray.prototype.isDestroyed = function () {
|
||
return !1;
|
||
};
|
||
|
||
Buffer$1.prototype.isDestroyed = function () {
|
||
return !1;
|
||
};
|
||
|
||
function returnTrue() {
|
||
return !0;
|
||
}
|
||
|
||
function destroyObject(e, t) {
|
||
function i() {}
|
||
for (var r in e) "function" == typeof e[r] && (e[r] = i);
|
||
e.isDestroyed = returnTrue;
|
||
}
|
||
|
||
Buffer$1.prototype.destroy = function () {
|
||
return this._gl.deleteBuffer(this._buffer), destroyObject(this);
|
||
};
|
||
|
||
VertexArray.prototype.destroy = function () {
|
||
for (var e = this._attributes, t = 0; t < e.length; ++t) {
|
||
var i = e[t].vertexBuffer;
|
||
defined(i) && !i.isDestroyed() && i.vertexArrayDestroyable && i.destroy();
|
||
}
|
||
var r = this._indexBuffer;
|
||
return (
|
||
defined(r) && !r.isDestroyed() && r.vertexArrayDestroyable && r.destroy(),
|
||
defined(this._vao) && this._context.glDeleteVertexArray(this._vao),
|
||
destroyObject(this)
|
||
);
|
||
};
|
||
|
||
const createVertexArrays = (e, t, i) => {
|
||
(e._createVertexArray = !1),
|
||
releaseShaders(e),
|
||
destroyVertexArrays(e),
|
||
sortPolylinesIntoBuckets(e);
|
||
var r,
|
||
n,
|
||
a = [[]],
|
||
o = a[0],
|
||
s = e._batchTable,
|
||
l = e._useHighlightColor,
|
||
c = [0],
|
||
u = 0,
|
||
d = [[]],
|
||
h = 0,
|
||
p = e._polylineBuckets;
|
||
for (r in p)
|
||
p.hasOwnProperty(r) &&
|
||
((n = p[r]).updateShader(t, s, l), (h += n.lengthOfPositions));
|
||
if (h > 0) {
|
||
var f,
|
||
m = e._mode,
|
||
g = new Float32Array(18 * h),
|
||
_ = new Float32Array(4 * h),
|
||
y = 0,
|
||
v = 0,
|
||
C = 0;
|
||
for (r in p)
|
||
if (p.hasOwnProperty(r)) {
|
||
(n = p[r]).write(g, _, y, v, C, s, t, i),
|
||
m === SceneMode$1.MORPHING &&
|
||
(defined(f) || (f = new Float32Array(18 * h)), n.writeForMorph(f, y));
|
||
var T = n.lengthOfPositions;
|
||
var fourt = 4 * T;
|
||
(y += 18 * T), (v += fourt), (C += fourt), (u = n.updateIndices(a, c, d, u));
|
||
}
|
||
var S,
|
||
A = e._positionBufferUsage.bufferUsage,
|
||
x = BufferUsage$1.STATIC_DRAW;
|
||
(e._positionBuffer = Buffer$1.createVertexBuffer({
|
||
context: t,
|
||
typedArray: g,
|
||
usage: A,
|
||
})),
|
||
defined(f) &&
|
||
(S = Buffer$1.createVertexBuffer({ context: t, typedArray: f, usage: A })),
|
||
(e._texCoordExpandAndBatchIndexBuffer = Buffer$1.createVertexBuffer({
|
||
context: t,
|
||
typedArray: _,
|
||
usage: x,
|
||
}));
|
||
for (var E = 12, b = 16, P = 0, D = a.length, w = 0; w < D; ++w)
|
||
if ((o = a[w]).length > 0) {
|
||
var M = new Uint16Array(o),
|
||
I = Buffer$1.createIndexBuffer({
|
||
context: t,
|
||
typedArray: M,
|
||
usage: BufferUsage$1.STATIC_DRAW,
|
||
indexDatatype: IndexDatatype$1.UNSIGNED_SHORT,
|
||
});
|
||
P += c[w];
|
||
var R,
|
||
O,
|
||
B,
|
||
L,
|
||
F = 6 * (E * (w * 65536 - P)),
|
||
N = E + F,
|
||
V = E + N,
|
||
k = E + V,
|
||
U = E + k,
|
||
G = E + U,
|
||
$ = b * (w * 65536 - P),
|
||
z = [
|
||
{
|
||
index: attributeLocations$5.position3DHigh,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: F,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.position3DLow,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: N,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.position2DHigh,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: F,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.position2DLow,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: N,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.prevPosition3DHigh,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: V,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.prevPosition3DLow,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: k,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.prevPosition2DHigh,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: V,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.prevPosition2DLow,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: k,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.nextPosition3DHigh,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: U,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.nextPosition3DLow,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: G,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.nextPosition2DHigh,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: U,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.nextPosition2DLow,
|
||
componentsPerAttribute: 3,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
offsetInBytes: G,
|
||
strideInBytes: 72,
|
||
},
|
||
{
|
||
index: attributeLocations$5.texCoordExpandAndBatchIndex,
|
||
componentsPerAttribute: 4,
|
||
componentDatatype: ComponentDatatype$1.FLOAT,
|
||
vertexBuffer: e._texCoordExpandAndBatchIndexBuffer,
|
||
offsetInBytes: $,
|
||
},
|
||
];
|
||
m === SceneMode$1.SCENE3D
|
||
? ((R = e._positionBuffer),
|
||
(O = "vertexBuffer"),
|
||
(B = emptyVertexBuffer),
|
||
(L = "value"))
|
||
: m === SceneMode$1.SCENE2D || m === SceneMode$1.COLUMBUS_VIEW
|
||
? ((R = emptyVertexBuffer),
|
||
(O = "value"),
|
||
(B = e._positionBuffer),
|
||
(L = "vertexBuffer"))
|
||
: ((R = S),
|
||
(O = "vertexBuffer"),
|
||
(B = e._positionBuffer),
|
||
(L = "vertexBuffer")),
|
||
(z[0][O] = R),
|
||
(z[1][O] = R),
|
||
(z[2][L] = B),
|
||
(z[3][L] = B),
|
||
(z[4][O] = R),
|
||
(z[5][O] = R),
|
||
(z[6][L] = B),
|
||
(z[7][L] = B),
|
||
(z[8][O] = R),
|
||
(z[9][O] = R),
|
||
(z[10][L] = B),
|
||
(z[11][L] = B);
|
||
var H = new Cesium.VertexArray({ context: t, attributes: z, indexBuffer: I });
|
||
e._vertexArrays.push({ va: H, buckets: d[w] });
|
||
}
|
||
}
|
||
};
|
||
|
||
var NUMBER_OF_PROPERTIES$2 = Cesium.Polyline.NUMBER_OF_PROPERTIES;
|
||
|
||
function Material$3(e) {
|
||
(this.type = void 0),
|
||
(this.shaderSource = void 0),
|
||
(this.materials = void 0),
|
||
(this.uniforms = void 0),
|
||
(this._uniforms = void 0),
|
||
(this.translucent = void 0),
|
||
(this._minificationFilter = defaultValue(
|
||
e.minificationFilter,
|
||
TextureMinificationFilter$1.LINEAR
|
||
)),
|
||
(this._magnificationFilter = defaultValue(
|
||
e.magnificationFilter,
|
||
TextureMagnificationFilter$1.LINEAR
|
||
)),
|
||
(this._strict = void 0),
|
||
(this._template = void 0),
|
||
(this._count = void 0),
|
||
(this._texturePaths = {}),
|
||
(this._loadedImages = []),
|
||
(this._loadedCubeMaps = []),
|
||
(this._textures = {}),
|
||
(this._updateFunctions = []),
|
||
(this._defaultTexture = void 0),
|
||
initializeMaterial(e, this),
|
||
Object.defineProperties(this, { type: { value: this.type, writable: !1 } }),
|
||
defined(Material$3._uniformList[this.type]) ||
|
||
(Material$3._uniformList[this.type] = Object.keys(this._uniforms));
|
||
}
|
||
|
||
var scratchUniformArray = [];
|
||
|
||
Material$3.fromType = function (e, t) {
|
||
var i = new Material$3({ fabric: { type: e } });
|
||
if (defined(t)) for (var r in t) t.hasOwnProperty(r) && (i.uniforms[r] = t[r]);
|
||
return i;
|
||
};
|
||
Material$3.ColorType = "Color";
|
||
|
||
function replacer(e, t) {
|
||
return t instanceof Cesium.Texture ? t.id : t;
|
||
}
|
||
|
||
function replaceToken(e, t, i, r) {
|
||
r = defaultValue(r, !0);
|
||
var n = 0,
|
||
a = new RegExp("([\\w" + (r ? "." : "") + "])?" + t + "([\\w])?", "g");
|
||
return (
|
||
(e.shaderSource = e.shaderSource.replace(a, function (e, t, r) {
|
||
return t || r ? e : ((n += 1), i);
|
||
})),
|
||
n
|
||
);
|
||
}
|
||
|
||
function Resource(e) {
|
||
"string" == typeof (e = defaultValue(e, defaultValue.EMPTY_OBJECT)) &&
|
||
(e = { url: e }),
|
||
(this._url = void 0),
|
||
(this._templateValues = defaultClone(e.templateValues, {})),
|
||
(this._queryParameters = defaultClone(e.queryParameters, {})),
|
||
(this.headers = defaultClone(e.headers, {})),
|
||
(this.request = defaultValue(e.request, new Request())),
|
||
(this.proxy = e.proxy),
|
||
(this.retryCallback = e.retryCallback),
|
||
(this.retryAttempts = defaultValue(e.retryAttempts, 0)),
|
||
(this._retryCount = 0);
|
||
var t = new URI(e.url);
|
||
parseQuery(t, this, !0, !0), t.fragment(""), (this._url = t.toString());
|
||
}
|
||
|
||
function getUniformType(e) {
|
||
var t = e.type;
|
||
if (!defined(t)) {
|
||
var i = typeof e;
|
||
if ("number" === i) t = "float";
|
||
else if ("boolean" === i) t = "bool";
|
||
else if (
|
||
"string" === i ||
|
||
e instanceof Resource ||
|
||
e instanceof HTMLCanvasElement ||
|
||
e instanceof HTMLImageElement
|
||
)
|
||
t = /^([rgba]){1,4}$/i.test(e)
|
||
? "channels"
|
||
: e === Material$3.DefaultCubeMapId
|
||
? "samplerCube"
|
||
: "sampler2D";
|
||
else if ("object" === i)
|
||
if (Array.isArray(e))
|
||
(4 !== e.length && 9 !== e.length && 16 !== e.length) ||
|
||
(t = "mat" + Math.sqrt(e.length));
|
||
else {
|
||
var r = 0;
|
||
for (var n in e) e.hasOwnProperty(n) && (r += 1);
|
||
r >= 2 && r <= 4 ? (t = "vec" + r) : 6 === r && (t = "samplerCube");
|
||
}
|
||
}
|
||
return t;
|
||
}
|
||
|
||
function getNumberOfTokens(e, t, i) {
|
||
return replaceToken(e, t, t, i);
|
||
}
|
||
|
||
function createUniform$1(e, t) {
|
||
e._strict;
|
||
var i = e._template.uniforms,
|
||
r = i[t],
|
||
n = getUniformType(r);
|
||
if ("channels" === n) replaceToken(e, t, r, !1);
|
||
else {
|
||
if ("sampler2D" === n) {
|
||
var a = t + "Dimensions";
|
||
getNumberOfTokens(e, a) > 0 &&
|
||
((i[a] = { type: "ivec3", x: 1, y: 1 }), createUniform$1(e, a));
|
||
}
|
||
if (!new RegExp("uniform\\s+" + n + "\\s+" + t + "\\s*;").test(e.shaderSource)) {
|
||
var o = "uniform " + n + " " + t + ";";
|
||
e.shaderSource = o + e.shaderSource;
|
||
}
|
||
var s = t + "_" + e._count++;
|
||
if ((replaceToken(e, t, s), (e.uniforms[t] = r), "sampler2D" === n))
|
||
(e._uniforms[s] = function () {
|
||
return e._textures[t];
|
||
}),
|
||
e._updateFunctions.push(createTexture2DUpdateFunction(t));
|
||
else if ("samplerCube" === n)
|
||
(e._uniforms[s] = function () {
|
||
return e._textures[t];
|
||
}),
|
||
e._updateFunctions.push(createCubeMapUpdateFunction(t));
|
||
else if (-1 !== n.indexOf("mat")) {
|
||
var l = new matrixMap[n]();
|
||
e._uniforms[s] = function () {
|
||
return matrixMap[n].fromColumnMajorArray(e.uniforms[t], l);
|
||
};
|
||
} else
|
||
e._uniforms[s] = function () {
|
||
return e.uniforms[t];
|
||
};
|
||
}
|
||
}
|
||
|
||
function createUniforms(e) {
|
||
var t = e._template.uniforms;
|
||
for (var i in t) t.hasOwnProperty(i) && createUniform$1(e, i);
|
||
}
|
||
|
||
function createMaterialId(e) {
|
||
Material$3._uniformList = {};
|
||
Material$3._uniformList[e.type] = [];
|
||
// 对帧率影响较大
|
||
// createUniforms(e)
|
||
var t = Material$3._uniformList[e.type],
|
||
i = t.length;
|
||
scratchUniformArray.length = 2 * i;
|
||
var r = 0;
|
||
t.forEach((telement) => {
|
||
var a = telement;
|
||
(scratchUniformArray[r] = a),
|
||
(scratchUniformArray[r + 1] = e._uniforms[a]()),
|
||
(r += 2);
|
||
});
|
||
return e.type + ":" + JSON.stringify(scratchUniformArray, replacer);
|
||
}
|
||
|
||
var boundingSphereScratch$2 = new Cesium.BoundingSphere();
|
||
|
||
function combine$2(e, t, i) {
|
||
i = defaultValue(i, !1);
|
||
var r,
|
||
n,
|
||
a,
|
||
o = {},
|
||
s = defined(e),
|
||
l = defined(t);
|
||
if (s)
|
||
for (r in e)
|
||
e.hasOwnProperty(r) &&
|
||
((n = e[r]),
|
||
l && i && "object" == typeof n && t.hasOwnProperty(r)
|
||
? ((a = t[r]), (o[r] = "object" == typeof a ? combine$2(n, a, i) : n))
|
||
: (o[r] = n));
|
||
if (l)
|
||
for (r in t)
|
||
t.hasOwnProperty(r) && !o.hasOwnProperty(r) && ((a = t[r]), (o[r] = a));
|
||
return o;
|
||
}
|
||
|
||
var Pass = {
|
||
ENVIRONMENT: 0,
|
||
COMPUTE: 1,
|
||
GLOBE: 2,
|
||
TERRAIN_CLASSIFICATION: 3,
|
||
CESIUM_3D_TILE: 4,
|
||
CESIUM_3D_TILE_CLASSIFICATION: 5,
|
||
CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW: 6,
|
||
OPAQUE: 7,
|
||
TRANSLUCENT: 8,
|
||
OVERLAY: 9,
|
||
NUMBER_OF_PASSES: 10,
|
||
},
|
||
Pass$1 = Object.freeze(Pass);
|
||
|
||
var boundingSphereScratch2 = new Cesium.BoundingSphere();
|
||
|
||
function createCommandLists(e, t, i, r) {
|
||
var n = t.context,
|
||
a = t.commandList,
|
||
o = i.length,
|
||
s = 0,
|
||
l = !0,
|
||
c = e._vertexArrays,
|
||
u = e.debugShowBoundingVolume,
|
||
d = e._batchTable.getUniformMapCallback();
|
||
c.forEach((celement) => {
|
||
var f = celement,
|
||
m = f.buckets;
|
||
m.forEach((melement) => {
|
||
var y,
|
||
v,
|
||
C,
|
||
T,
|
||
S = melement,
|
||
A = S.offset,
|
||
x = S.bucket.shaderProgram,
|
||
E = S.bucket.polylines,
|
||
P = 0;
|
||
E.forEach((eelement) => {
|
||
var w = eelement,
|
||
M = createMaterialId(w._material);
|
||
if (M !== y) {
|
||
if (defined(y) && P > 0) {
|
||
var I = v.isTranslucent();
|
||
s >= o
|
||
? ((C = new Cesium.DrawCommand({ owner: e })), i.push(C))
|
||
: (C = i[s]),
|
||
++s,
|
||
(T = combine$2(d(v._uniforms), e._uniformMap)),
|
||
(C.boundingVolume = Cesium.BoundingSphere.clone(
|
||
boundingSphereScratch$2,
|
||
C.boundingVolume
|
||
)),
|
||
(C.modelMatrix = r),
|
||
(C.shaderProgram = x),
|
||
(C.vertexArray = f.va),
|
||
(C.renderState = I ? e._translucentRS : e._opaqueRS),
|
||
(C.pass = I ? Pass$1.TRANSLUCENT : Pass$1.OPAQUE),
|
||
(C.debugShowBoundingVolume = u),
|
||
(C.pickId = "v_pickColor"),
|
||
(C.uniformMap = T),
|
||
(C.count = P),
|
||
(C.offset = A),
|
||
(A += P),
|
||
(P = 0),
|
||
(l = !0),
|
||
a.push(C);
|
||
}
|
||
(v = w._material).update(n), (y = M);
|
||
}
|
||
var R,
|
||
O = w._locatorBuckets;
|
||
O.forEach((oelement) => {
|
||
var F = oelement;
|
||
F.locator === S && (P += F.count);
|
||
});
|
||
t.mode === SceneMode$1.SCENE3D
|
||
? (R = w._boundingVolumeWC)
|
||
: t.mode === SceneMode$1.COLUMBUS_VIEW
|
||
? (R = w._boundingVolume2D)
|
||
: t.mode === SceneMode$1.SCENE2D
|
||
? defined(w._boundingVolume2D) &&
|
||
(((R = Cesium.BoundingSphere.clone(
|
||
w._boundingVolume2D,
|
||
boundingSphereScratch2
|
||
)).center.x = 0),
|
||
((R = Cesium.BoundingSphere.clone(
|
||
w._boundingVolume2D,
|
||
boundingSphereScratch2
|
||
)).center.y = 0),
|
||
((R = Cesium.BoundingSphere.clone(
|
||
w._boundingVolume2D,
|
||
boundingSphereScratch2
|
||
)).center.z = 0))
|
||
: defined(w._boundingVolumeWC) &&
|
||
defined(w._boundingVolume2D) &&
|
||
(R = Cesium.BoundingSphere.union(
|
||
w._boundingVolumeWC,
|
||
w._boundingVolume2D,
|
||
boundingSphereScratch2
|
||
)),
|
||
l
|
||
? ((l = !1), Cesium.BoundingSphere.clone(R, boundingSphereScratch$2))
|
||
: Cesium.BoundingSphere.union(
|
||
R,
|
||
boundingSphereScratch$2,
|
||
boundingSphereScratch$2
|
||
);
|
||
});
|
||
defined(y) &&
|
||
P > 0 &&
|
||
(s >= o ? ((C = new Cesium.DrawCommand({ owner: e })), i.push(C)) : (C = i[s]),
|
||
++s,
|
||
(T = combine$2(d(v._uniforms), e._uniformMap)),
|
||
(C.boundingVolume = Cesium.BoundingSphere.clone(
|
||
boundingSphereScratch$2,
|
||
C.boundingVolume
|
||
)),
|
||
(C.modelMatrix = r),
|
||
(C.shaderProgram = x),
|
||
(C.vertexArray = f.va),
|
||
(C.renderState = v.isTranslucent() ? e._translucentRS : e._opaqueRS),
|
||
(C.pass = v.isTranslucent() ? Pass$1.TRANSLUCENT : Pass$1.OPAQUE),
|
||
(C.debugShowBoundingVolume = u),
|
||
(C.pickId = "v_pickColor"),
|
||
(C.uniformMap = T),
|
||
(C.count = P),
|
||
(C.offset = A),
|
||
(l = !0),
|
||
a.push(C)),
|
||
(y = void 0);
|
||
});
|
||
});
|
||
i.length = s;
|
||
}
|
||
|
||
// 视锥剔除
|
||
const isPointInViewport = (point) => {
|
||
const { planes: planceVec4 }= viewer.scene.frameState.cullingVolume;
|
||
// 获取视锥体的四个平面
|
||
const planes =[];
|
||
for (let i=0;i<planceVec4.length; i++){
|
||
const tempPlane = new Cesium.Plane(new Cesium.Cartesian3(1.0,0.0, 0.0), 0.0);
|
||
planes.push(Cesium.Plane.fromCartesian4(planceVec4[i], tempPlane));
|
||
}
|
||
// 检查点是否在每个平面内部
|
||
for(let i=0;i<planes.length; i++){
|
||
const plane = planes[i];
|
||
if(Cesium.Plane.getPointDistance(plane,point)<0){
|
||
// 点在某个平面外
|
||
return false;
|
||
}
|
||
}
|
||
//点在视口内
|
||
return true;
|
||
};
|
||
|
||
// 调整 Polyline 密度
|
||
const adjustPolylineDensity = (polyline) => {
|
||
const minSegmentLength=20000; //最小段长度设置
|
||
let positions =polyline._positions;
|
||
let newPositions=[];
|
||
for(let i=0;i<positions.length-1;i++){
|
||
let distance = Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||
if(distance>minSegmentLength){
|
||
if(isPointInViewport(positions[i])) {
|
||
newPositions.push(positions[i]);
|
||
}
|
||
// 如果当前段太长,可以考虑添加额外的位置点
|
||
if(distance>minSegmentLength*3){
|
||
let midPoint = Cesium.Cartesian3.lerp(positions[i], positions[i + 1], 0.5, new Cesium.Cartesian3());
|
||
if(isPointInViewport(midPoint)){
|
||
newPositions.push(midPoint);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(positions[positions.length-1]){
|
||
if(isPointInViewport(positions[positions.length-1])){
|
||
newPositions.push(positions[positions.length-1]);
|
||
}
|
||
}
|
||
return newPositions;
|
||
};
|
||
|
||
var POSITION_SIZE_INDEX = Cesium.Polyline.POSITION_SIZE_INDEX,
|
||
MATERIAL_INDEX = Cesium.Polyline.MATERIAL_INDEX,
|
||
MATERIAL_INDEX = Cesium.Polyline.MATERIAL_INDEX,
|
||
SHOW_INDEX$4 = Cesium.Polyline.SHOW_INDEX,
|
||
WIDTH_INDEX = Cesium.Polyline.WIDTH_INDEX,
|
||
DISTANCE_DISPLAY_CONDITION = 5;
|
||
|
||
class CustomPolyline {
|
||
constructor(options) {
|
||
this.show = options.show;
|
||
this._polylines = options._polylines;
|
||
this.modelMatrix = options.modelMatrix;
|
||
this._batchTable = options._batchTable;
|
||
this._createBatchTable = options._createBatchTable;
|
||
this._createVertexArray = options._createVertexArray;
|
||
this._external = options._external;
|
||
this._highlightColor = options._highlightColor;
|
||
this._mode = options._mode;
|
||
this._modelMatrix = options._modelMatrix;
|
||
this._opaqueRS = options._opaqueRS;
|
||
this._polylineBuckets = options._polylineBuckets;
|
||
this._polylinesRemoved = options._polylinesRemoved;
|
||
this._polylinesToUpdate = options._polylinesToUpdate;
|
||
this._polylinesUpdated = options._polylinesUpdated;
|
||
this._positionBuffer = options._positionBuffer;
|
||
this._positionBufferUsage = options._positionBufferUsage;
|
||
this._propertiesChanged = options._propertiesChanged;
|
||
this._texCoordExpandAndBatchIndexBuffer =
|
||
options._texCoordExpandAndBatchIndexBuffer;
|
||
this._translucentRS = options._translucentRS;
|
||
this._uniformMap = options._uniformMap;
|
||
this._useHighlightColor = options._useHighlightColor;
|
||
this._vertexArrays = options._vertexArrays;
|
||
this.mymark = true;
|
||
this.myinterver = 0;
|
||
this._colorCommands = [];
|
||
options._colorCommands.forEach((element) => {
|
||
this._colorCommands.push(element);
|
||
});
|
||
}
|
||
|
||
update(e) {
|
||
if (!window.allowUpdate) {
|
||
if (!this.show) {
|
||
return;
|
||
}
|
||
this._colorCommands.forEach((item) => {
|
||
e.commandList.push(item);
|
||
});
|
||
this.myinterver += 1;
|
||
var allowindex = 1000;
|
||
// if (viewer._clockViewModel.multiplier >= 100000) {
|
||
// allowindex = 3;
|
||
// } else if (50000 <= viewer._clockViewModel.multiplier < 100000) {
|
||
// allowindex = 6;
|
||
// } else if (25000 <= viewer._clockViewModel.multiplier < 50000) {
|
||
// allowindex = 12;
|
||
// } else if (12000 <= viewer._clockViewModel.multiplier < 25000) {
|
||
// allowindex = 24;
|
||
// } else if (6000 <= viewer._clockViewModel.multiplier < 12000) {
|
||
// allowindex = 48;
|
||
// } else if (3000 <= viewer._clockViewModel.multiplier < 6000) {
|
||
// allowindex = 64;
|
||
// } else if (1000 <= viewer._clockViewModel.multiplier < 3000) {
|
||
// allowindex = 84;
|
||
// }
|
||
if (this.myinterver == allowindex) {
|
||
this.myinterver = 0;
|
||
window.allowUpdate = true;
|
||
}
|
||
} else {
|
||
if ((removePolylines(this), 0 !== this._polylines.length && this.show)) {
|
||
updateMode$1(this, e);
|
||
var t,
|
||
i = e.context,
|
||
r = e.mapProjection,
|
||
n = this._propertiesChanged;
|
||
if (this._createBatchTable) {
|
||
if (0 === Cesium.ContextLimits.maximumVertexTextureImageUnits)
|
||
throw new RuntimeError(
|
||
"Vertex texture fetch support is required to render polylines. The maximum number of vertex texture image units must be greater than zero."
|
||
);
|
||
createBatchTable(this, i), (this._createBatchTable = !1);
|
||
}
|
||
if (this._createVertexArray || computeNewBuffersUsage(this))
|
||
createVertexArrays(this, i, r);
|
||
else if (this._polylinesUpdated) {
|
||
var a = this._polylinesToUpdate;
|
||
if (this._mode !== SceneMode$1.SCENE3D)
|
||
a.forEach((element) => {
|
||
element.update();
|
||
});
|
||
if (n[POSITION_SIZE_INDEX] || n[MATERIAL_INDEX])
|
||
createVertexArrays(this, i, r);
|
||
else var c = this._polylineBuckets;
|
||
a.forEach((element) => {
|
||
t = element;
|
||
n = t._propertiesChanged;
|
||
var d = t._bucket,
|
||
h = 0;
|
||
|
||
for (var p in c)
|
||
if (c.hasOwnProperty(p)) {
|
||
if (c[p] === d) {
|
||
n[POSITION_INDEX$4] && d.writeUpdate(h, t, this._positionBuffer, r);
|
||
break;
|
||
}
|
||
h += c[p].lengthOfPositions;
|
||
}
|
||
if (
|
||
((n[SHOW_INDEX$4] || n[WIDTH_INDEX]) &&
|
||
this._batchTable.setBatchedAttribute(
|
||
t._index,
|
||
0,
|
||
new Cesium.Cartesian2(t._width, t._show)
|
||
),
|
||
this._batchTable.attributes.length > 2)
|
||
) {
|
||
if (n[POSITION_INDEX$4] || n[POSITION_SIZE_INDEX]) {
|
||
var f =
|
||
e.mode === SceneMode$1.SCENE2D
|
||
? t._boundingVolume2D
|
||
: t._boundingVolumeWC,
|
||
m = EncodedCartesian3.fromCartesian(
|
||
f.center,
|
||
scratchUpdatePolylineEncodedCartesian
|
||
),
|
||
g = Cesium.Cartesian4.fromElements(
|
||
m.low.x,
|
||
m.low.y,
|
||
m.low.z,
|
||
f.radius,
|
||
scratchUpdatePolylineCartesian4
|
||
);
|
||
this._batchTable.setBatchedAttribute(t._index, 2, m.high),
|
||
this._batchTable.setBatchedAttribute(t._index, 3, g);
|
||
}
|
||
if (n[DISTANCE_DISPLAY_CONDITION]) {
|
||
var _ = scratchNearFarCartesian2;
|
||
(_.x = 0), (_.y = Number.MAX_VALUE);
|
||
var y = t.distanceDisplayCondition;
|
||
defined(y) && ((_.x = y.near), (_.y = y.far)),
|
||
this._batchTable.setBatchedAttribute(t._index, 4, _);
|
||
}
|
||
}
|
||
t._clean();
|
||
});
|
||
(a.length = 0), (this._polylinesUpdated = !1);
|
||
}
|
||
n = this._propertiesChanged;
|
||
n.forEach((element) => {
|
||
element = 0;
|
||
});
|
||
var C = Cesium.Matrix4.IDENTITY;
|
||
e.mode === SceneMode$1.SCENE3D && (C = this.modelMatrix);
|
||
var BlendingState$1 = Object.freeze(Cesium.BlendingState);
|
||
var T = e.passes,
|
||
S = 0 !== e.morphTime;
|
||
if (
|
||
((defined(this._opaqueRS) && this._opaqueRS.depthTest.enabled === S) ||
|
||
(this._opaqueRS = Cesium.RenderState.fromCache({
|
||
depthMask: S,
|
||
depthTest: { enabled: S },
|
||
})),
|
||
(defined(this._translucentRS) &&
|
||
this._translucentRS.depthTest.enabled === S) ||
|
||
(this._translucentRS = Cesium.RenderState.fromCache({
|
||
blending: BlendingState$1.ALPHA_BLEND,
|
||
depthMask: !S,
|
||
depthTest: { enabled: S },
|
||
})),
|
||
this._batchTable.update(e),
|
||
T.render || T.pick)
|
||
)
|
||
createCommandLists(this, e, this._colorCommands, C);
|
||
}
|
||
window.allowUpdate = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 使用宏任务等待 _primitives 数组内容更新后再操作内容
|
||
setTimeout(() => {
|
||
let mypolylines;
|
||
viewer.scene.primitives._primitives.forEach((element, index) => {
|
||
if (element.constructor.name == "CustomPolyline") {
|
||
viewer.scene.primitives._primitives.splice(index, 2);
|
||
mypolylines = element;
|
||
}
|
||
if (element.constructor.name == "PolylineCollection") {
|
||
// 4K适配版本后将造成列表第一颗卫星模型不显示的bug,故注释掉
|
||
// viewer.scene.primitives._primitives.splice(index, 1);
|
||
mypolylines = element;
|
||
}
|
||
// 打包后进行系统切换以及先进行视图切换后进行系统切换时对象名称可能会发生改变,具体名称需要在重装或更新打包依赖库后重新获取
|
||
// 2025/12/30 打包后直接进行系统切换时对象名称发生改变 CustomPolyline --> jn
|
||
// 2025/12/30 打包后先进行视图切换(3D -> 2D)后进行系统切换时对象名称发生改变 CustomPolyline --> jn
|
||
// 2025/12/30 打包后先进行视图切换(3D -> 哥伦布图)后进行系统切换时对象名称发生改变 CustomPolyline --> le
|
||
// console.log(element.constructor.name);
|
||
if (element.constructor.name == "jn" || element.constructor.name == "le") {
|
||
viewer.scene.primitives._primitives.splice(index, 2);
|
||
mypolylines = element;
|
||
}
|
||
// 打包后进行系统切换以及先进行视图切换后进行系统切换时对象名称可能会发生改变,具体名称需要在重装或更新打包依赖库后重新获取
|
||
// 2025/12/30 打包后直接进行系统切换时对象名称未发生改变 PolylineCollection --> fn
|
||
// 2025/12/30 打包后先进行视图切换(3D -> 2D)后进行系统切换时对象名称未发生改变 PolylineCollection --> S
|
||
// 2025/12/30 打包后先进行视图切换(3D -> 哥伦布图)后进行系统切换时对象名称未发生改变 PolylineCollection --> S
|
||
if (element.constructor.name == "fn" || element.constructor.name == "S") {
|
||
// 4K适配版本后将造成列表第一颗卫星模型不显示的bug,故注释掉
|
||
// viewer.scene.primitives._primitives.splice(index, 1);
|
||
mypolylines = element;
|
||
}
|
||
});
|
||
viewer.scene.primitives.show = false;
|
||
let polylineowner = new CustomPolyline(mypolylines);
|
||
let newprimitive = new CustomPrimitive(viewer.scene.primitives._primitives[10]);
|
||
viewer.scene.primitives._primitives[10] = newprimitive;
|
||
viewer.scene.primitives._primitives.pop();
|
||
viewer.scene.primitives._primitives.push(polylineowner);
|
||
viewer.scene.primitives.show = true;
|
||
}, 0);
|
||
|
||
cesiumObject.entities.values.forEach((element, index) => {
|
||
if (element.model !== undefined) {
|
||
// 调整卫星名称显示位置
|
||
element.label.pixelOffset._value = new Cesium.Cartesian2(12, 21);
|
||
// 根据卫星系统名称为其替换不同的卫星模型
|
||
if (element.properties.satelliteType._value == "Beidou") {
|
||
if (element.description._value.indexOf("GEO") !== -1) {
|
||
element.model.uri._value = GEOModel.model._resource;
|
||
} else if (element.description._value.indexOf("MEO") !== -1) {
|
||
element.model.uri._value = MEOModel.model._resource;
|
||
} else if (element.description._value.indexOf("IGSO") !== -1) {
|
||
element.model.uri._value = IGSOModel.model._resource;
|
||
}
|
||
} else if (element.properties.satelliteType._value == "GPS") {
|
||
// 指定基于漫反射和镜面反射图像的照明的贡献,调整模型亮度
|
||
element.model.imageBasedLightingFactor = new Cesium.Cartesian2(20, 1);
|
||
if (element.description._value.indexOf("II-F") !== -1) {
|
||
element.model.uri._value = GPSIIFModel.model._resource;
|
||
} else if (element.description._value.indexOf("II-R") !== -1) {
|
||
element.model.uri._value = GPSIIRModel.model._resource;
|
||
} else if (element.description._value.indexOf("III-A") !== -1) {
|
||
element.model.uri._value = GPSIIIAModel.model._resource;
|
||
} else if (element.description._value.indexOf("IIR-M") !== -1) {
|
||
element.model.uri._value = GPSIIRMModel.model._resource;
|
||
}
|
||
} else if (element.properties.satelliteType._value == "GLONASS") {
|
||
// 指定基于漫反射和镜面反射图像的照明的贡献,调整模型亮度
|
||
element.model.imageBasedLightingFactor = new Cesium.Cartesian2(10, 1);
|
||
if (element.description._value.indexOf("GLO-K") !== -1) {
|
||
element.model.uri._value = GLONASSGLOKModel.model._resource;
|
||
} else if (element.description._value.indexOf("GLO-M") !== -1) {
|
||
element.model.uri._value = GLONASSGLOMModel.model._resource;
|
||
}
|
||
} else if (element.properties.satelliteType._value == "Galileo") {
|
||
// 指定基于漫反射和镜面反射图像的照明的贡献,调整模型亮度
|
||
element.model.imageBasedLightingFactor = new Cesium.Cartesian2(20, 1);
|
||
if (element.description._value.indexOf("MEO") !== -1) {
|
||
element.model.uri._value = GalileoMEOModel.model._resource;
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
entity.load(cesiumObject.entities.values);
|
||
|
||
// 显示卫星导航系统的科普信息
|
||
viewer.selectedEntity = entity.find("Constellation");
|
||
|
||
// 当用户操作或者相机移动时调用调整 Polyline 密度的函数
|
||
viewer.camera.moveEnd.addEventListener(() => {
|
||
let entities=viewer.entities.values;
|
||
for(let i=0;i<entities.length; i++) {
|
||
if (entities[i].polyline) {
|
||
entities[i].polyline._positions = adjustPolylineDensity(entities[i]);
|
||
}
|
||
}
|
||
});
|
||
|
||
// 设置相机初始位置
|
||
const allfly = (x, y, z, h, p, r) => {
|
||
viewer.camera.flyTo({
|
||
destination: Cesium.Cartesian3.fromDegrees(x, y, z),
|
||
orientation: {
|
||
heading: Cesium.Math.toRadians(h), // 方向,以弧度为单位的航向角。
|
||
pitch: Cesium.Math.toRadians(p), // 倾斜角度,以弧度为单位的俯仰角。
|
||
roll: r,
|
||
},
|
||
});
|
||
};
|
||
|
||
if (
|
||
window.document.getElementsByClassName("cesium-toolbar-button")[1].classList[2] ==
|
||
"cesium-sceneModePicker-button3D"
|
||
) {
|
||
allfly(108.55, 34.32, 100000000, 0, -90, 0);
|
||
}
|
||
if (
|
||
window.document.getElementsByClassName("cesium-toolbar-button")[1].classList[2] ==
|
||
"cesium-sceneModePicker-button2D"
|
||
) {
|
||
allfly(0, 0, 40000000, 0, -90, 0);
|
||
viewer.scene.camera.position.z = 63781370;
|
||
}
|
||
if (
|
||
window.document.getElementsByClassName("cesium-toolbar-button")[1].classList[2] ==
|
||
"cesium-sceneModePicker-buttonColumbusView"
|
||
) {
|
||
allfly(0, -90, 40000000, 0, -45, 0);
|
||
}
|
||
};
|
||
|
||
// 显示/隐藏、跟踪卫星等交互操作
|
||
store.subscribeAction(({ type, payload }) => {
|
||
// 显示/隐藏卫星
|
||
if (type === "satelliteSystem/toggleShow") {
|
||
const satellite = entity.get(payload);
|
||
if (!satellite) return;
|
||
|
||
satellite.show = !satellite.show;
|
||
}
|
||
|
||
// 跟踪卫星
|
||
if (type === "satelliteSystem/track") {
|
||
const satellite = entity.get(payload);
|
||
if (!satellite || !vcViewerInstance) return;
|
||
|
||
vcViewerInstance.selectedEntity = satellite;
|
||
vcViewerInstance.trackedEntity = satellite;
|
||
}
|
||
});
|
||
</script> |