Skip to content

Conversation

Myrmod
Copy link

@Myrmod Myrmod commented Dec 6, 2021

This is my first pull request ever, so sorry if I did something wrong here.

I created a basic implementation of the PointerLockControls and a corresponding example. It's not exciting, but it works.
If time permits I will try to add a function which translates pressed keys to movement of the camera (eg. arrow keys), like in this example

I wasn't sure how to create a proper image for the example, would be happy to be enlightened :D

@vercel
Copy link

vercel bot commented Dec 6, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/svelte/svelte-cubed/3AcXAtpURvg1qvKVPtQKRAexU8QW
✅ Preview: https://svelte-cubed-git-fork-myrmod-pointerlocks-svelte.vercel.app

@JackDra
Copy link

JackDra commented Dec 6, 2021

I wasn't sure how to create a proper image for the example, would be happy to be enlightened :D

I just took a screenshot of the example and added it to static/example-thumbnails/points.jpg.
It just needs the correct name to be picked up by the template thingy.
I think for yours its first-person-camera.jpg

@Myrmod
Copy link
Author

Myrmod commented Dec 7, 2021

Thank you for the hint. I added an image the way you described it. Do I have to recreate the pull request or is it fine this way?

@JackDra
Copy link

JackDra commented Dec 7, 2021

Thank you for the hint. I added an image the way you described it. Do I have to recreate the pull request or is it fine this way?

Nope, the vercel link will redeploy the branch any time you make a commit to this branch. You can check it out by clicking the preview!

root.invalidate();
});

canvas.addEventListener('click', () => {

Choose a reason for hiding this comment

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

I think we should remove all event listeners onDestroy https://svelte.dev/docs#onDestroy and also reset camera properties if needed

Copy link
Author

Choose a reason for hiding this comment

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

I thought it's not necessary, because the event listenders should get removed automatically as soon as the component is unmounted, because the object, on which the event listenters have been added to, doesn't exist any more.
If they really stay there I totally agree, that they should be removed.

In what case would you reset the camera properties? Either I am too sleepy or I haven't changed any camera properties in the current pull request?

@Myrmod
Copy link
Author

Myrmod commented Dec 12, 2021

If you add enableMovement to your SC.PointerLockControls the camera will now be moving accordingly. Pressing Shift increases the movement speed, however sometimes the pressedKeys wont be reset, the keyup event seems not to always trigger correctly. So I do have some questions and would like to have some feedback.

  • What might be the reason for a pressed key to become "locked" and not get removed on keyup here?
  • For the position of the code inside the SC.PointerLockControls, do you think it's the proper position? How would you guys use this?

I am happy for any other suggestions :)

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.

3 participants