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

update camera so it has mode and startingPos && update orbital so it has mode and targetPos #622

Merged
merged 13 commits into from
May 11, 2024

Conversation

hanbollar
Copy link
Contributor

@hanbollar hanbollar commented May 9, 2024

Linking

...

Problem

Want a way to change the starting camera's position. also updating orbital to allow for user to note target position

Solution

updating camera from an attribute to data-camera and updating orbital as well

Breaking Change

updates both camera and orbital from one value to 'mode, pos' pairings

Notes

there's two main options for this fix:
- keep camera as is where it's mode and add a starting position: camera:blah; startPos:"x y z"
- change camera to have camera="mode:blah; startPos:'x y z'"

i'm implementing the former to not have to deal with ' vs " inline. Additionally, using userPos instead of startPos since it's more about the user (ie to follow the main convention we're setting up in other cases already)

see comments in pr body for rest of conversation ~

ended up implementing orbital="mode:true/false; targetPos:x y z" camera="mode:blah; startPos:x y z"

Since this is adding a new example - when testing just directly head to https://localhost:8080/examples/camera.html or https://examples-mrjs-pr-622.onrender.com/examples/camera.html


Required to Merge

  • PASS - all necessary actions must pass (excluding the auto-skipped ones)
  • TEST IN HEADSET - main dev-testing-example and any of the other examples still work as expected
  • VIDEO - if this pr changes something visually - post a video here of it in headset-MR and/or on desktop (depending on what it affects) for the reviewer to reference.
d.mov

hanbollar added 3 commits May 8, 2024 20:45
Signed-off-by: hanbollar <github@hannahbollar.com>
Signed-off-by: hanbollar <github@hannahbollar.com>
Signed-off-by: hanbollar <github@hannahbollar.com>
Copy link

render bot commented May 9, 2024

Signed-off-by: hanbollar <github@hannahbollar.com>
@@ -389,7 +389,23 @@ export class MRApp extends MRElement {
}

this.camera.matrixWorldAutoUpdate = false;
this.camera.position.set(0, 0, 1);

const startPosString = this.getAttribute('userPos');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i went with the userPos="x y z" approach since it's the user's starting position

@michaelthatsit
Copy link
Member

i'm implementing the former to not have to deal with ' vs " inline. Additionally, using userPos instead of startPos since it's more about the user (ie to follow the main convention we're setting up in other cases already)

you actually don't need to do this! you can do camera="mode: blah; startPos: x y z;" let cameraSettings = mrjsUtils.string.stringToJson(this.getAttribute('camera')) and it would output:

{
  mode: 'blah', // String
  startPos: [x, y, z] // Array
}

We use it for all the components.

I would also switch camera to data-camera so you can do this.dataset.camera instead of this.getAttribute('camera')

@hanbollar
Copy link
Contributor Author

i'm implementing the former to not have to deal with ' vs " inline. Additionally, using userPos instead of startPos since it's more about the user (ie to follow the main convention we're setting up in other cases already)

you actually don't need to do this! you can do camera="mode: blah; startPos: x y z;" let cameraSettings = mrjsUtils.string.stringToJson(this.getAttribute('camera')) and it would output:

{
  mode: 'blah', // String
  startPos: [x, y, z] // Array
}

We use it for all the components.

I would also switch camera to data-camera so you can do this.dataset.camera instead of this.getAttribute('camera')

good to know on that for future - and sounds good - update incoming for actual data-comp for camera 🫡

hanbollar added 2 commits May 9, 2024 12:38
Signed-off-by: hanbollar <github@hannahbollar.com>
Signed-off-by: hanbollar <github@hannahbollar.com>
@hanbollar
Copy link
Contributor Author

current progress - cam position works 👍 , working on orbital

weird thing happening with orbital where it stays at original location until connectedCallback happens (ie until we call init() in that function) - because of this we get a reload at the default loc and then it doesnt update to what we want until we click and drag around - still digging into 🤔

Untitled.mov

Signed-off-by: hanbollar <github@hannahbollar.com>
@hanbollar
Copy link
Contributor Author

current progress - cam position works 👍 , working on orbital

weird thing happening with orbital where it stays at original location until connectedCallback happens (ie until we call init() in that function) - because of this we get a reload at the default loc and then it doesnt update to what we want until we click and drag around - still digging into 🤔

Untitled.mov

was missing a update call for controls, all good ~

@hanbollar hanbollar changed the title WIP - cam with starting pos update camera so it has mode and startingPos && update orbital so it has mode and targetPos May 9, 2024
@hanbollar hanbollar changed the title update camera so it has mode and startingPos && update orbital so it has mode and targetPos update camera so it has mode and startingPos && update orbital so it has mode and targetPos May 9, 2024
Signed-off-by: hanbollar <github@hannahbollar.com>
hanbollar added 4 commits May 9, 2024 13:46
Signed-off-by: hanbollar <github@hannahbollar.com>
Signed-off-by: hanbollar <github@hannahbollar.com>
Signed-off-by: hanbollar <github@hannahbollar.com>
Signed-off-by: hanbollar <github@hannahbollar.com>
@hanbollar hanbollar requested a review from michaelthatsit May 9, 2024 21:03
@michaelthatsit
Copy link
Member

This looks good. In the future we should chance all the attributes on mr-app to start with data- (not data-comp-) as we discussed.

@hanbollar hanbollar merged commit e35feb4 into main May 11, 2024
6 checks passed
@hanbollar hanbollar deleted the hb-cam branch May 11, 2024 01:17
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