Skip to content

Commit

Permalink
Fix menus scale
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jan 25, 2024
1 parent 35eb38e commit cba5e2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/bit-systems/media-loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ function resizeAndRecenter(world: HubsWorld, mediaLoaderEid: EntityID, box: Box3
const moveParentNotObject = MediaLoader.flags[mediaLoaderEid] & MEDIA_LOADER_FLAGS.MOVE_PARENT_NOT_OBJECT;

const mediaLoaderObj = world.eid2obj.get(mediaLoaderEid)!;
const mediaEid = findChildWithComponent(world, LoadedByMediaLoader, mediaLoaderEid)!;
const mediaObj = world.eid2obj.get(mediaEid)!;
const offsetEid = findChildWithComponent(world, MediaLoaderOffset, mediaLoaderEid)!;
const offsetObj = world.eid2obj.get(offsetEid)!;

let scalar = 1;
if (recenter) {
Expand Down Expand Up @@ -110,9 +110,9 @@ function resizeAndRecenter(world: HubsWorld, mediaLoaderEid: EntityID, box: Box3
diff.multiplyScalar(scalar);
transformPosition.addVectors(rootPosition, diff);

// Set the new media world matrix and restore the media loader original matrix
// Set the new offset world matrix and restore the media loader original matrix
tmpMat.compose(transformPosition, rootRotation.identity(), rootScale);
setMatrixWorld(mediaObj, tmpMat);
setMatrixWorld(offsetObj, tmpMat);
setMatrixWorld(mediaLoaderObj, origMat);
} else if (moveParentNotObject) {
mediaLoaderObj.updateMatrices();
Expand All @@ -134,7 +134,7 @@ function resizeAndRecenter(world: HubsWorld, mediaLoaderEid: EntityID, box: Box3

tmpMat.compose(transformPosition, rootRotation, rootScale);
setMatrixWorld(mediaLoaderObj, tmpMat);
setMatrixWorld(mediaObj, origMat);
setMatrixWorld(offsetObj, origMat);
}

addComponent(world, MediaContentBounds, mediaLoaderEid);
Expand Down
4 changes: 2 additions & 2 deletions src/bit-systems/object-menu-transform-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const tmpMat42 = new Matrix4();
const aabb = new Box3();
const sphere = new Sphere();
const yVector = new Vector3(0, 1, 0);
const UNIT_V3 = new Vector3(1, 1, 1);

// Calculate the AABB without accounting for the root object rotation
function getAABB(obj: Object3D, box: Box3, onlyVisible: boolean = false) {
Expand Down Expand Up @@ -85,7 +84,8 @@ function transformMenu(world: HubsWorld, menu: EntityID) {
} else {
targetObj.updateMatrices(true, true);
targetObj.matrixWorld.decompose(tmpVec1, tmpQuat1, tmpVec2);
tmpMat42.compose(tmpVec1, tmpQuat1, UNIT_V3);
targetObj.getWorldScale(tmpVec2);
tmpMat42.compose(tmpVec1, tmpQuat1, tmpVec2);
tmpMat4.copy(tmpMat42);

const isFacing = isFacingCamera(targetObj);
Expand Down

0 comments on commit cba5e2b

Please sign in to comment.