Moving threeJs Object by BUTTON (Click) #2689
Replies: 1 comment 1 reply
-
Hello! This won't be the complete answer, but gives you a way to move forward. Your room components take properties and applies it to their parent group - this is great and will allow you to pass additional properties from their parent, Your rooms seem to be 3.6 wide on the x-axis and 2.7 high on the y-axis, so to set Your next step is to use React.useState to keep track of all your positions, in an array for example: and then pass the position data to your room: To update the positions, write function that then iterates through the positions and sets a new value to them. Your rooms follow a pattern so you could apply a formula/function to compute the new positions:
and then call this function depending on the event you want it to trigger on (a HTML button with an Best of luck" |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm a beginner at Three JS and need some help with my code. Please, Could you help me for a second?
1| Button1 "increase + 1". After Clicking Button 1, ROOM1 will move to ROOM2 Location and so forth. Room8 will move to ROOM1 position.
2| Button2 "increase + 2". After Clicking Button 2, ROOM1 will move to ROOM3 Location and so forth. Room8 will move to ROOM2 position.
This is my Code in Sandbox.
https://codesandbox.io/s/threejs-code-3rlk8b?file=/src/components/PartOne.js
Please help me.
Thank You So much for Your Precious Time
Beta Was this translation helpful? Give feedback.
All reactions