eyeToWindowCoordinates.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Transforms a position from eye to window coordinates. The transformation\n\
  4. * from eye to clip coordinates is done using {@link czm_projection}.\n\
  5. * The transform from normalized device coordinates to window coordinates is\n\
  6. * done using {@link czm_viewportTransformation}, which assumes a depth range\n\
  7. * of <code>near = 0</code> and <code>far = 1</code>.\n\
  8. * <br /><br />\n\
  9. * This transform is useful when there is a need to manipulate window coordinates\n\
  10. * in a vertex shader as done by {@link BillboardCollection}.\n\
  11. *\n\
  12. * @name czm_eyeToWindowCoordinates\n\
  13. * @glslFunction\n\
  14. *\n\
  15. * @param {vec4} position The position in eye coordinates to transform.\n\
  16. *\n\
  17. * @returns {vec4} The transformed position in window coordinates.\n\
  18. *\n\
  19. * @see czm_modelToWindowCoordinates\n\
  20. * @see czm_projection\n\
  21. * @see czm_viewportTransformation\n\
  22. * @see BillboardCollection\n\
  23. *\n\
  24. * @example\n\
  25. * vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);\n\
  26. */\n\
  27. vec4 czm_eyeToWindowCoordinates(vec4 positionEC)\n\
  28. {\n\
  29. vec4 q = czm_projection * positionEC; // clip coordinates\n\
  30. q.xyz /= q.w; // normalized device coordinates\n\
  31. q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates\n\
  32. return q;\n\
  33. }\n\
  34. ";