unpackUint.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type,\n\
  4. * so the return value is an int.\n\
  5. * <p>\n\
  6. * There are also precision limitations in WebGL 1. highp int is still limited\n\
  7. * to 24 bits. Above the value of 2^24 = 16777216, precision loss may occur.\n\
  8. * </p>\n\
  9. *\n\
  10. * @param {float|vec2|vec3|vec4} packed The packed value. For vectors, the components are listed in little-endian order.\n\
  11. *\n\
  12. * @return {int} The unpacked value.\n\
  13. */\n\
  14. int czm_unpackUint(float packedValue) {\n\
  15. float rounded = czm_round(packedValue * 255.0);\n\
  16. return int(rounded);\n\
  17. }\n\
  18. \n\
  19. int czm_unpackUint(vec2 packedValue) {\n\
  20. vec2 rounded = czm_round(packedValue * 255.0);\n\
  21. return int(dot(rounded, vec2(1.0, 256.0)));\n\
  22. }\n\
  23. \n\
  24. int czm_unpackUint(vec3 packedValue) {\n\
  25. vec3 rounded = czm_round(packedValue * 255.0);\n\
  26. return int(dot(rounded, vec3(1.0, 256.0, 65536.0)));\n\
  27. }\n\
  28. \n\
  29. int czm_unpackUint(vec4 packedValue) {\n\
  30. vec4 rounded = czm_round(packedValue * 255.0);\n\
  31. return int(dot(rounded, vec4(1.0, 256.0, 65536.0, 16777216.0)));\n\
  32. }\n\
  33. ";