Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 53d16cd0ae3c6269c89aa36e242e6318efeb7002
      
https://github.com/WebKit/WebKit/commit/53d16cd0ae3c6269c89aa36e242e6318efeb7002
  Author: Mike Wyrzykowski <[email protected]>
  Date:   2026-02-19 (Thu, 19 Feb 2026)

  Changed paths:
    M Source/WebKit/GPUProcess/graphics/Model/USDModel.swift
    M Source/WebKit/WebProcess/GPU/graphics/Model/RemoteMeshProxy.cpp
    M Source/WebKit/WebProcess/GPU/graphics/Model/RemoteMeshProxy.h
    M Source/WebKit/WebProcess/Model/WebModelPlayer.mm

  Log Message:
  -----------
  Correct <model> entity transform calculations
https://bugs.webkit.org/show_bug.cgi?id=307575
rdar://170160478

Reviewed by Etienne Segonzac.

Correct some bounding box math during rotations which was
resulting in some inconsistencies between macOS/iOS and visionOS.

* Source/WebKit/GPUProcess/graphics/Model/USDModel.swift:
(Material.render(with:)):
Remove temporary 90 degree rotation which was added for testing purposes.

* Source/WebKit/WebProcess/GPU/graphics/Model/RemoteMeshProxy.cpp:
(WebKit::computeMinAndMaxCorners):
In order to correctly compute a tight fitting AABB, it is necessary to
rotate the 8 points which define the AABB instead of rotating the center + 
extents
which is effectively the representation of the bounding sphere.

(WebKit::RemoteMeshProxy::update):
The bounding box only changes if its corners change. Also instead of calling
setEntityTransform directly, go through setStageMode which correctly handles
any scale needed for orbiting.

(WebKit::RemoteMeshProxy::getCenterAndExtents const):
2.f * (m_maxCorner - center) is equivalent to  m_maxCorner - m_minCorner, there
is no function change here but the latter is more readable.

(WebKit::RemoteMeshProxy::setEntityTransform):
The entity transform is not necessarily the transform we use to render on screen
due to scaling or potential precision issues, so call setStageMode similar to
RemoteMeshProxy::update

(WebKit::RemoteMeshProxy::setEntityTransformInternal):
Refactor out of a member function which calls the actual IPC message

(WebKit::RemoteMeshProxy::setScale):
Setting the scale is equivalent to setting a transform, call setTransform
to simplify logic

(WebKit::RemoteMeshProxy::setStageMode):
For stage mode == none, we want to center the mesh in its center and moved
backward by half its extent. The extent is the entire lengh of the bounding box,
so half is half the length.

To tightly fit the model in the viewport during rotations, take the max extent
of its transform to scale the model up or down during orbit mode.

(WebKit::RemoteMeshProxy::setRotation):
Set rotation should be allowed before the entity has a transform set, in case
it is set before the model is loaded.

* Source/WebKit/WebProcess/GPU/graphics/Model/RemoteMeshProxy.h:
Add member function declaration.

* Source/WebKit/WebProcess/Model/WebModelPlayer.mm:
(WebKit::WebModelPlayer::simulate):
Only update the rotation when it actually changes.

(WebKit::WebModelPlayer::setStageMode):
If set don't call setStageMode when it is == none then after setting to orbit
and back to none, orbit will persist in RemoteMeshProxy which is wrong.

Canonical link: https://commits.webkit.org/307847@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to