Camera: Exclude scale from view matrix.#32805
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
|
||
| this.matrixWorld.decompose( _position, _quaternion, _scale ); | ||
|
|
||
| if ( _scale.x === 1 && _scale.y === 1 && _scale.z === 1 ) { |
There was a problem hiding this comment.
Small optimization: If the scale is already 1, the method does not use a compose() to produce the view matrix.
|
@hybridherbst With a glTF complaint view matrix, the uniform scale use case from #26659 (comment) works now. However, with a non-uniform scale as well with negative scales, we can't use |
|
Hi! That's great to hear. I think non-uniform camera scales are fortunately relatively rare but can still happen (e.g. when parenting a camera to something; another usecase that is not quite supported by three.js at the moment – see our older PRs for improving OrbitControls). |
Three.js r183 strips parent scale from camera view matrix (mrdoob/three.js#32805). ContactShadows relied on shadowGroup scale to expand the camera frustum. Fix sets camera frustum to world-space (scaled) dimensions directly and calls updateProjectionMatrix() after changing frustum params. Closes #1392 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Related issue: #26659
Description
The PR makes the computation of the view matrix glTF conform by excluding the scale. From the spec:
That fixes the lighting issues reported in #26659 when a uniform scale is applied to the camera. When taking the code from the fiddle and testing with the PR, it renders now as expected meaning the lighting does not change anymore.