eastNorthUpToEyeCoordinates.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Computes a 3x3 rotation matrix that transforms vectors from an ellipsoid's east-north-up coordinate system \n\
  4. * to eye coordinates. In east-north-up coordinates, x points east, y points north, and z points along the \n\
  5. * surface normal. East-north-up can be used as an ellipsoid's tangent space for operations such as bump mapping.\n\
  6. * <br /><br />\n\
  7. * The ellipsoid is assumed to be centered at the model coordinate's origin.\n\
  8. *\n\
  9. * @name czm_eastNorthUpToEyeCoordinates\n\
  10. * @glslFunction\n\
  11. *\n\
  12. * @param {vec3} positionMC The position on the ellipsoid in model coordinates.\n\
  13. * @param {vec3} normalEC The normalized ellipsoid surface normal, at <code>positionMC</code>, in eye coordinates.\n\
  14. *\n\
  15. * @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.\n\
  16. *\n\
  17. * @example\n\
  18. * // Transform a vector defined in the east-north-up coordinate \n\
  19. * // system, (0, 0, 1) which is the surface normal, to eye \n\
  20. * // coordinates.\n\
  21. * mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);\n\
  22. * vec3 normalEC = m * vec3(0.0, 0.0, 1.0);\n\
  23. */\n\
  24. mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)\n\
  25. {\n\
  26. vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates\n\
  27. vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordiantes\n\
  28. vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates\n\
  29. \n\
  30. return mat3(\n\
  31. tangentEC.x, tangentEC.y, tangentEC.z,\n\
  32. bitangentEC.x, bitangentEC.y, bitangentEC.z,\n\
  33. normalEC.x, normalEC.y, normalEC.z);\n\
  34. }\n\
  35. ";