Vector3DTileClampedPolylinesVS.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "attribute vec3 startEllipsoidNormal;\n\
  3. attribute vec3 endEllipsoidNormal;\n\
  4. attribute vec4 startPositionAndHeight;\n\
  5. attribute vec4 endPositionAndHeight;\n\
  6. attribute vec4 startFaceNormalAndVertexCorner;\n\
  7. attribute vec4 endFaceNormalAndHalfWidth;\n\
  8. attribute float a_batchId;\n\
  9. \n\
  10. uniform mat4 u_modifiedModelView;\n\
  11. uniform vec2 u_minimumMaximumVectorHeights;\n\
  12. \n\
  13. varying vec4 v_startPlaneEC;\n\
  14. varying vec4 v_endPlaneEC;\n\
  15. varying vec4 v_rightPlaneEC;\n\
  16. varying float v_halfWidth;\n\
  17. varying vec3 v_volumeUpEC;\n\
  18. \n\
  19. void main()\n\
  20. {\n\
  21. // vertex corner IDs\n\
  22. // 3-----------7\n\
  23. // /| left /|\n\
  24. // / | 1 / |\n\
  25. // 2-----------6 5 end\n\
  26. // | / | /\n\
  27. // start |/ right |/\n\
  28. // 0-----------4\n\
  29. //\n\
  30. float isEnd = floor(startFaceNormalAndVertexCorner.w * 0.251); // 0 for front, 1 for end\n\
  31. float isTop = floor(startFaceNormalAndVertexCorner.w * mix(0.51, 0.19, isEnd)); // 0 for bottom, 1 for top\n\
  32. \n\
  33. vec3 forward = endPositionAndHeight.xyz - startPositionAndHeight.xyz;\n\
  34. vec3 right = normalize(cross(forward, startEllipsoidNormal));\n\
  35. \n\
  36. vec4 position = vec4(startPositionAndHeight.xyz, 1.0);\n\
  37. position.xyz += forward * isEnd;\n\
  38. \n\
  39. v_volumeUpEC = czm_normal * normalize(cross(right, forward));\n\
  40. \n\
  41. // Push for volume height\n\
  42. float offset;\n\
  43. vec3 ellipsoidNormal = mix(startEllipsoidNormal, endEllipsoidNormal, isEnd);\n\
  44. \n\
  45. // offset height to create volume\n\
  46. offset = mix(startPositionAndHeight.w, endPositionAndHeight.w, isEnd);\n\
  47. offset = mix(u_minimumMaximumVectorHeights.y, u_minimumMaximumVectorHeights.x, isTop) - offset;\n\
  48. position.xyz += offset * ellipsoidNormal;\n\
  49. \n\
  50. // move from RTC to EC\n\
  51. position = u_modifiedModelView * position;\n\
  52. right = czm_normal * right;\n\
  53. \n\
  54. // Push for width in a direction that is in the start or end plane and in a plane with right\n\
  55. // N = normalEC (\"right-facing\" direction for push)\n\
  56. // R = right\n\
  57. // p = angle between N and R\n\
  58. // w = distance to push along R if R == N\n\
  59. // d = distance to push along N\n\
  60. //\n\
  61. // N R\n\
  62. // { \ p| } * cos(p) = dot(N, R) = w / d\n\
  63. // d\ \ | |w * d = w / dot(N, R)\n\
  64. // { \| }\n\
  65. // o---------- polyline segment ---->\n\
  66. //\n\
  67. vec3 scratchNormal = mix(-startFaceNormalAndVertexCorner.xyz, endFaceNormalAndHalfWidth.xyz, isEnd);\n\
  68. scratchNormal = cross(scratchNormal, mix(startEllipsoidNormal, endEllipsoidNormal, isEnd));\n\
  69. vec3 miterPushNormal = czm_normal * normalize(scratchNormal);\n\
  70. \n\
  71. offset = 2.0 * endFaceNormalAndHalfWidth.w * max(0.0, czm_metersPerPixel(position)); // offset = widthEC\n\
  72. offset = offset / dot(miterPushNormal, right);\n\
  73. position.xyz += miterPushNormal * (offset * sign(0.5 - mod(startFaceNormalAndVertexCorner.w, 2.0)));\n\
  74. \n\
  75. gl_Position = czm_depthClamp(czm_projection * position);\n\
  76. \n\
  77. position = u_modifiedModelView * vec4(startPositionAndHeight.xyz, 1.0);\n\
  78. vec3 startNormalEC = czm_normal * startFaceNormalAndVertexCorner.xyz;\n\
  79. v_startPlaneEC = vec4(startNormalEC, -dot(startNormalEC, position.xyz));\n\
  80. v_rightPlaneEC = vec4(right, -dot(right, position.xyz));\n\
  81. \n\
  82. position = u_modifiedModelView * vec4(endPositionAndHeight.xyz, 1.0);\n\
  83. vec3 endNormalEC = czm_normal * endFaceNormalAndHalfWidth.xyz;\n\
  84. v_endPlaneEC = vec4(endNormalEC, -dot(endNormalEC, position.xyz));\n\
  85. v_halfWidth = endFaceNormalAndHalfWidth.w;\n\
  86. }\n\
  87. ";