1234567891011121314151617181920212223242526272829303132 |
- /**
- * Transforms a position from eye to window coordinates. The transformation
- * from eye to clip coordinates is done using {@link czm_projection}.
- * The transform from normalized device coordinates to window coordinates is
- * done using {@link czm_viewportTransformation}, which assumes a depth range
- * of <code>near = 0</code> and <code>far = 1</code>.
- * <br /><br />
- * This transform is useful when there is a need to manipulate window coordinates
- * in a vertex shader as done by {@link BillboardCollection}.
- *
- * @name czm_eyeToWindowCoordinates
- * @glslFunction
- *
- * @param {vec4} position The position in eye coordinates to transform.
- *
- * @returns {vec4} The transformed position in window coordinates.
- *
- * @see czm_modelToWindowCoordinates
- * @see czm_projection
- * @see czm_viewportTransformation
- * @see BillboardCollection
- *
- * @example
- * vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
- */
- vec4 czm_eyeToWindowCoordinates(vec4 positionEC)
- {
- vec4 q = czm_projection * positionEC; // clip coordinates
- q.xyz /= q.w; // normalized device coordinates
- q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
- return q;
- }
|