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

[WIP] feat: add expand/compress buttons #29

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zhixiangteoh
Copy link
Collaborator

@zhixiangteoh zhixiangteoh commented Mar 31, 2021

Description

This PR modifies the toolbar to expand and compress quad video layers by a fixed amount (factor of 1.25).

Note: Although the C/E buttons have no effect on equirect background layer (because equirect layer makes no sense of width or height attributes), the toolbar for equirect layer video is the same one as for quad layer videos, which is not an ideal UI. Functionality-wise it does not affect any of the existing features nor introduce any new bugs.

@zhixiangteoh zhixiangteoh added type.Enhancement An enhancement to an existing function or feature, or a new feature priority.High Must do labels Mar 31, 2021
@zhixiangteoh zhixiangteoh requested a review from sovoid March 31, 2021 06:41
@sovoid sovoid changed the title Add basic expand/compress buttons to Toolbar [WIP] feat: add expand/compress buttons Mar 31, 2021
Add resize handle to toolbar
The idea is to attach the handle to the controller and then calculate
the euclidean distance between the original handle position and the
position of the handle (attached to the controller); some way to
determine the sign of resizing (increase/decrease) has yet to be found.

Some additional changes to driver `multiple-layers.js` particularly in
that `handleToolbarIntersections` now handles engaging the move and
resize interactions. `handleSelectEnd` is still where move and resize
are disengaged.
util/webxr/MediaLayerManager/GlassLayer.js Outdated Show resolved Hide resolved
util/webxr/MediaLayerManager/GlassLayer.js Outdated Show resolved Hide resolved
util/webxr/MediaLayerManager/GlassLayer.js Outdated Show resolved Hide resolved
util/webxr/Toolbar.js Show resolved Hide resolved
util/webxr/Toolbar.js Show resolved Hide resolved
@sovoid
Copy link
Owner

sovoid commented Apr 8, 2021

you might need to rebase this branch with master

Two points `handleLeftPoint` and `handleRightPoint` are created every time
the resize handle is engaged. Then these points are used to determine
whether to expand or compress.

This way of doing it seems to be pretty buggy—3D euclidean distance between
`currPosition` (position that the controller is pointing at) and the left
and right points are not always reflected properly; you can be pointing to
the right but the distance to the right point is somehow longer than the
distance to the left.

Open to new ways to determine the sign of resizing.

'#' will be ignored, and an empty message aborts the commit.  # # On branch
feat-resizing # Your branch is up to date with 'origin/feat-resizing'.  # #
Changes to be committed: #	modified:
apps/simple-video-layers/multiple-layers.js #	modified:
util/webxr/MediaLayerManager/GlassLayer.js #	modified:
util/webxr/Toolbar.js #
if (
layerObj.glassLayer &&
controller.userData.engagedResize &&
layerObj
Copy link
Owner

Choose a reason for hiding this comment

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

add this check before layerObj.glassLayer

layerObj
) {
layerObj.toolbar.disengageResize(controller);
controller.userData.engagedResize = false;
Copy link
Owner

Choose a reason for hiding this comment

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

since we are passing controller here, let us modify this env variable inside the disengageResize

Copy link
Owner

Choose a reason for hiding this comment

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

@cabanier do you have any suggestions on this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it seems that this logic should move to disengageResize.
Maybe have an engaged attribute on controller.userdata?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm my idea was that since in handleSelectEnd we access controller.userData.engagedResize directly, as in:

if (layerObj.glassLayer && controller.userData.engagedResize && layerObj) {
                            // ^^^^^^^^^^^^^^^^^^^^^^^
    layerObj.toolbar.disengageResize(controller);
    controller.userData.engagedResize = false;
}

we should explicitly modify this field in the driver itself.

}
if (controller.userData.engagedResize && layerObj) {
layerObj.toolbar.disengageResize(controller);
controller.userData.engagedResize = false;
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like this condition is duplicated

fluidResize() {
if (
!this.resizeHandleClone ||
!this.resizeHandleClone.userData.engageResizePosition
Copy link
Owner

Choose a reason for hiding this comment

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

this condition is a bit weird. We can just combine them into one condition using optional chaining

// console.log("dist to left", distanceLtoCurr);
// console.log("dist to right", distanceRtoCurr);
// console.log(distanceRtoCurr < distanceLtoCurr ? "expand" : "compress");
const sign = distanceRtoCurr < distanceLtoCurr ? 1 : -1;
Copy link
Owner

Choose a reason for hiding this comment

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

Lets use better variable names here since it is not explicit what these variables mean just by the name? Can you explain what they are doing here in a comment?

this.handleRightPoint.getWorldPosition(handleRightPosition);

// console.log("handle left", handleLeftPosition);
// console.log("handle right", handleRightPosition);
Copy link
Owner

Choose a reason for hiding this comment

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

remove these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority.High Must do type.Enhancement An enhancement to an existing function or feature, or a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants