modelToWindowCoordinates.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Transforms a position from model to window coordinates. The transformation\n\
  4. * from model to clip coordinates is done using {@link czm_modelViewProjection}.\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. * <br /><br />\n\
  12. * This function should not be confused with {@link czm_viewportOrthographic},\n\
  13. * which is an orthographic projection matrix that transforms from window \n\
  14. * coordinates to clip coordinates.\n\
  15. *\n\
  16. * @name czm_modelToWindowCoordinates\n\
  17. * @glslFunction\n\
  18. *\n\
  19. * @param {vec4} position The position in model coordinates to transform.\n\
  20. *\n\
  21. * @returns {vec4} The transformed position in window coordinates.\n\
  22. *\n\
  23. * @see czm_eyeToWindowCoordinates\n\
  24. * @see czm_modelViewProjection\n\
  25. * @see czm_viewportTransformation\n\
  26. * @see czm_viewportOrthographic\n\
  27. * @see BillboardCollection\n\
  28. *\n\
  29. * @example\n\
  30. * vec4 positionWC = czm_modelToWindowCoordinates(positionMC);\n\
  31. */\n\
  32. vec4 czm_modelToWindowCoordinates(vec4 position)\n\
  33. {\n\
  34. vec4 q = czm_modelViewProjection * position; // clip coordinates\n\
  35. q.xyz /= q.w; // normalized device coordinates\n\
  36. q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates\n\
  37. return q;\n\
  38. }\n\
  39. ";