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

How to access methods? #26

Open
davidfitzgibbon opened this issue Nov 26, 2021 · 4 comments
Open

How to access methods? #26

davidfitzgibbon opened this issue Nov 26, 2021 · 4 comments

Comments

@davidfitzgibbon
Copy link

I'm so excited for this project! Thanks so much for all the hard work Rich! Cant wait to see what comes out of this community.

I've been jumping straight in, and have an issue.

I'm trying to recreate this little demo where the is a movingBox who's position is changing, and a watchingBox that's looking at it.

Is it possible to use an Object3D .lookAt() method here? Is this something that needs to be built into SC that I could try to help with? Am I just not getting the declarative way of doing this?

I've made a best (not working) attempt here with the logic I would have expected.

@DefinitelyMaybe
Copy link

DefinitelyMaybe commented Nov 26, 2021

This one is about what gets attached to bind:this={cube1/2}. It's not the three.js object as you might expect but rather the svelte object. I'm sure this will come up a lot. Something we could try would be exporting the three object as a property but I don't know whether that's a good solution/avenue to go down.

Edit: in the mean time, a quick hack is to look into the movingCube variable.

@davidfitzgibbon
Copy link
Author

@DefinitelyMaybe thanks so much for the feedback.

I've tried accessing the data within the movingCube, but dont seem to be able to access that data?

I did get it working though, by creating two empty Object3Ds. That feels a little hacky though. But it works!

I'm very new to working with Three declaratively, I havent tried React Three Fiber or anything. Definitely a learning curve here, but it feels strange not being able to reach for the methods that you get on objects in Three.

You're right though, it's important not to take on anything we shouldnt into the project.

@rrcook
Copy link

rrcook commented Mar 13, 2022

@davidfitzgibbon In your comments, the "best (not working) attempt" and the "by creating two empty Object3Ds" links point to the same stackblitz. If you did get something working I'd like to see the code snippet, I have need of getting to the underlying three objects to get properties.

@davidfitzgibbon
Copy link
Author

@rrcook I never got to the actual ThreeJS functions, and apologies for the bad linking!

My initial attempt was something like this, trying to bind to the 'element' and use the underlying .lookAt() from there, which doesnt work.

This is surprising still to me, that we cant access the ThreeJS functions, BUT, as above I was able to mimic it by running the ThreeJS in the script with two empty Object3Ds, and copying their positions and rotations to the SvelteCubed objects.

Hopefully that's more clear!

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

No branches or pull requests

3 participants