Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 3D models Media Frame scaling issues and add support for 3D preview #4655

Merged
merged 2 commits into from
Sep 28, 2021

Conversation

keianhzo
Copy link
Contributor

@keianhzo keianhzo commented Sep 20, 2021

Fixes #4089

This PR fixes a couple of issues with media frames and 3D object:

  • Fixes the scale issues when the object is captured
  • Adds full support for 3D object preview

@keianhzo keianhzo changed the title Fix 3D model scale issues and add support for 3D preview Fix 3D models MEdia Frame scaling issues and add support for 3D preview Sep 20, 2021
@keianhzo keianhzo changed the title Fix 3D models MEdia Frame scaling issues and add support for 3D preview Fix 3D models Media Frame scaling issues and add support for 3D preview Sep 20, 2021
Copy link
Contributor

@netpro2k netpro2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Thanks for getting this fixed up! If I had implemented this I would have been too lazy to support animated previews, but that's a nice touch :) - Made a few comments, mostly around the matrix world update contract. I think most of my comments are noop changes so no strong opinions on if you bother changing them if you have already done a bunch of testing.

src/systems/media-frames.js Outdated Show resolved Hide resolved
}

const DEBUG = qsTruthy("debug");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for this PR but we keep inventing this adhoc all over, we should unify on a good debug system

clonedMesh.traverse(node => {
if (node.isMesh) {
if (node.material) {
node.material = node.material.clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was going to suggest cloning materials should be an option for cloneObject3D but you have to traverse again anyway to set the transparency...

src/systems/media-frames.js Outdated Show resolved Hide resolved
clonedMesh.position.set(0, 0, 0);
clonedMesh.quaternion.identity();
clonedMesh.matrixNeedsUpdate = true;
clonedMesh.updateMatrixWorld(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Been a long time since I looked at the world update patch but it looks like we prefer directly calling updateMatricies in our own code https://github.com/mozilla/hubs/blob/env-settings-fixes/src/utils/threejs-world-update.js#L119

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though in this case it looks like setFromObject on Box3 ends up already updating matricies anyway... https://github.com/mrdoob/three.js/blob/master/src/math/Box3.js#L196 . Mostly just ends up being noops anyway since most things respect the dirty flags, but just trying to trace through.

src/systems/media-frames.js Outdated Show resolved Hide resolved
src/systems/media-frames.js Outdated Show resolved Hide resolved
src/systems/media-frames.js Show resolved Hide resolved
@keianhzo keianhzo merged commit c3f7999 into master Sep 28, 2021
@keianhzo keianhzo deleted the media-frames-scale-fix branch September 28, 2021 13:35
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.

Media zones will sometimes make the object inserted enormous
2 participants