(target: gdjs.EffectsTarget)
| 124 | return true; |
| 125 | } |
| 126 | updatePreRender(target: gdjs.EffectsTarget): any { |
| 127 | // Apply any update to the camera or shadow map size. |
| 128 | this._updateShadowCamera(); |
| 129 | this._updateShadowMapSize(); |
| 130 | |
| 131 | // Avoid shadow acne due to depth buffer precision. |
| 132 | const biasMultiplier = |
| 133 | this._shadowMapSize < 1024 |
| 134 | ? 2 |
| 135 | : this._shadowMapSize < 2048 |
| 136 | ? 1.25 |
| 137 | : 1; |
| 138 | this._light.shadow.bias = -this._minimumShadowBias * biasMultiplier; |
| 139 | |
| 140 | // Apply update to the light position and its target. |
| 141 | // By doing this, the shadows are "following" the GDevelop camera. |
| 142 | if (!target.getRuntimeLayer) { |
| 143 | return; |
| 144 | } |
| 145 | const layer = target.getRuntimeLayer(); |
| 146 | const x = layer.getCameraX(); |
| 147 | const y = layer.getCameraY(); |
| 148 | const z = layer.getCameraZ(layer.getInitialCamera3DFieldOfView()); |
| 149 | |
| 150 | const roundedX = Math.floor(x / 100) * 100; |
| 151 | const roundedY = Math.floor(y / 100) * 100; |
| 152 | const roundedZ = Math.floor(z / 100) * 100; |
| 153 | if (this._top === 'Y-') { |
| 154 | const posLightX = |
| 155 | roundedX + |
| 156 | this._distanceFromCamera * |
| 157 | Math.cos(gdjs.toRad(-this._rotation + 90)) * |
| 158 | Math.cos(gdjs.toRad(this._elevation)); |
| 159 | const posLightY = |
| 160 | roundedY - |
| 161 | this._distanceFromCamera * |
| 162 | Math.sin(gdjs.toRad(this._elevation)); |
| 163 | const posLightZ = |
| 164 | roundedZ + |
| 165 | this._distanceFromCamera * |
| 166 | Math.sin(gdjs.toRad(-this._rotation + 90)) * |
| 167 | Math.cos(gdjs.toRad(this._elevation)); |
| 168 | this._light.position.set(posLightX, posLightY, posLightZ); |
| 169 | this._light.target.position.set(roundedX, roundedY, roundedZ); |
| 170 | } else { |
| 171 | const posLightX = |
| 172 | roundedX + |
| 173 | this._distanceFromCamera * |
| 174 | Math.cos(gdjs.toRad(this._rotation)) * |
| 175 | Math.cos(gdjs.toRad(this._elevation)); |
| 176 | const posLightY = |
| 177 | roundedY + |
| 178 | this._distanceFromCamera * |
| 179 | Math.sin(gdjs.toRad(this._rotation)) * |
| 180 | Math.cos(gdjs.toRad(this._elevation)); |
| 181 | const posLightZ = |
| 182 | roundedZ + |
| 183 | this._distanceFromCamera * |
nothing calls this directly
no test coverage detected