Skip to content

Camera: Prevent setting non-uniform scale#33440

Draft
WestLangley wants to merge 1 commit intomrdoob:devfrom
WestLangley:dev-camera_uniform_scale
Draft

Camera: Prevent setting non-uniform scale#33440
WestLangley wants to merge 1 commit intomrdoob:devfrom
WestLangley:dev-camera_uniform_scale

Conversation

@WestLangley
Copy link
Copy Markdown
Collaborator

This PR prevents setting non-uniform scale in cameras.

Currently, this is just a draft for discussion.

@github-actions
Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 365.31
86.78
365.31
86.78
+0 B
+0 B
WebGPU 639.21
177.47
639.21
177.47
+0 B
+0 B
WebGPU Nodes 637.33
177.18
637.33
177.18
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 497.82
121.45
497.94
121.48
+117 B
+34 B
WebGPU 711.06
192.41
711.18
192.44
+117 B
+32 B
WebGPU Nodes 660.28
179.65
660.39
179.68
+117 B
+32 B

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Apr 21, 2026

Related issue: #26659

Is this change required although #32805 is in place?

@WestLangley
Copy link
Copy Markdown
Collaborator Author

Is this change required although #32805 is in place?

TBH, since cameraMatrixWorldInverse is no longer guaranteed to be the inverse of cameraMatrixWorld, I am not sure.

For what use case is setting camera scale now required?

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Apr 22, 2026

I can't think of a use case right now since normally if a camera is influenced by scaling, it's the scale from the world transform.

Could the PR updated so no (local) scaling is allowed?

@WestLangley
Copy link
Copy Markdown
Collaborator Author

Could the PR updated so no (local) scaling is allowed?

It can be, but I was thinking that would be overly-restrictive.

/ping @hybridherbst

@WestLangley
Copy link
Copy Markdown
Collaborator Author

@Mugen87 As you suggested, I could modify the PR like so, and optionally warn once. Your choice.

updateMatrix() {

	if ( this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) {

		// console.warnOnce( 'THREE.Camera: .scale is not supported. Use a parent Group (dolly) instead.' );

		this.scale.set( 1, 1, 1 );

	}

	super.updateMatrix();

}

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented May 3, 2026

Still thinking about potential side effects of this change. I know from VR that cameras might be part of the scene graph, I think this is also true for react-three-fiber apps.

Sorry for asking again but what is the motivation behind this change? Is it to get the camera's world matrix back in sync with its inverse?

@WestLangley
Copy link
Copy Markdown
Collaborator Author

Sorry for asking again but what is the motivation behind this change? Is it to get the camera's world matrix back in sync with its inverse?

No, that will not happen here, since the user can add the camera to a scaled parent.

The original motivation was to prevent the user from setting non-uniform scale, since it is officially "not supported."

I thought uniform scale was still required in WebXR, but perhaps that is typically handled with a parent camera rig, so this PR could be modified so uniform scaling of the camera is also prevented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants