(postProcess, context, viewport)
| 143 | const postProcessMatrix4Scratch = new Matrix4(); |
| 144 | |
| 145 | function updateSunPosition(postProcess, context, viewport) { |
| 146 | const us = context.uniformState; |
| 147 | const sunPosition = us.sunPositionWC; |
| 148 | const viewMatrix = us.view; |
| 149 | const viewProjectionMatrix = us.viewProjection; |
| 150 | const projectionMatrix = us.projection; |
| 151 | |
| 152 | // create up sampled render state |
| 153 | let viewportTransformation = Matrix4.computeViewportTransformation( |
| 154 | viewport, |
| 155 | 0.0, |
| 156 | 1.0, |
| 157 | postProcessMatrix4Scratch, |
| 158 | ); |
| 159 | const sunPositionEC = Matrix4.multiplyByPoint( |
| 160 | viewMatrix, |
| 161 | sunPosition, |
| 162 | sunPositionECScratch, |
| 163 | ); |
| 164 | let sunPositionWC = Transforms.pointToGLWindowCoordinates( |
| 165 | viewProjectionMatrix, |
| 166 | viewportTransformation, |
| 167 | sunPosition, |
| 168 | sunPositionWCScratch, |
| 169 | ); |
| 170 | |
| 171 | sunPositionEC.x += CesiumMath.SOLAR_RADIUS; |
| 172 | const limbWC = Transforms.pointToGLWindowCoordinates( |
| 173 | projectionMatrix, |
| 174 | viewportTransformation, |
| 175 | sunPositionEC, |
| 176 | sunPositionEC, |
| 177 | ); |
| 178 | const sunSize = |
| 179 | Cartesian2.magnitude(Cartesian2.subtract(limbWC, sunPositionWC, limbWC)) * |
| 180 | 30.0 * |
| 181 | 2.0; |
| 182 | |
| 183 | const size = sizeScratch; |
| 184 | size.x = sunSize; |
| 185 | size.y = sunSize; |
| 186 | |
| 187 | postProcess._uCenter = Cartesian2.clone(sunPositionWC, postProcess._uCenter); |
| 188 | postProcess._uRadius = Math.max(size.x, size.y) * 0.15; |
| 189 | |
| 190 | const width = context.drawingBufferWidth; |
| 191 | const height = context.drawingBufferHeight; |
| 192 | |
| 193 | const stages = postProcess._stages; |
| 194 | const firstStage = stages.get(0); |
| 195 | |
| 196 | const downSampleWidth = firstStage.outputTexture.width; |
| 197 | const downSampleHeight = firstStage.outputTexture.height; |
| 198 | |
| 199 | const downSampleViewport = new BoundingRectangle(); |
| 200 | downSampleViewport.width = downSampleWidth; |
| 201 | downSampleViewport.height = downSampleHeight; |
| 202 |
no test coverage detected
searching dependent graphs…