- This topic has 7 replies, 2 voices, and was last updated 3 months, 3 weeks ago by xeon.
-
AuthorPosts
-
2024-08-24 at 7:10 pm #76955masjParticipant
Hi!
I’m using puzzles to rotate an object when the user drags their pointer left to right.
Works fine, except when the pointer leaves the container/window – if I re-enter the container/window, the rotation “pops” to reflect the entry position of my pointerThis is an issue since I will be having the scene in an iframe in another page, and when the cursor exits the iframe element in a mouse/pointerdown state, the rotation stops, but when the cursor re-enters the iframe element, the rotation not only pops, but acts as if I’;m still in a mouse/pointerdown state, as if I’m dragging even though no buttons are pressed.
Please help! I’ve been trying to use various HTML event puzzles to address the issues, and would be super-grateful any insights/suggestions.
Attachments:
You must be logged in to view attached files.2024-08-24 at 8:12 pm #76958xeonCustomerThe code is correct..the problem is the “All objects”. This is a non itterable object selector and for this to work the way you want it needs to be an itterable object like an object, group, collection.
Xeon
Route 66 Digital
Interactive Solutions - https://www.r66d.com
Tutorials - https://www.xeons3dlab.com2024-08-24 at 9:42 pm #76959masjParticipantThanks for your insight, Xeon.
I tried switching the selector to a single (non-inerrable) object, but unfortunately, the same issue persists, if I am still click-dragging on the object when my cursor leaves the container.
In reality, I just need the user to click and drag horizontally, with the click originating in the v3d-container element (not even necessarily on an object, if it means we can stop the popping rotation and sticky drag if the pointer leaves/re-enters the container), through puzzles, JS, or a combination of the two.
2024-08-24 at 11:28 pm #76960xeonCustomerOk…I have been trying to recreate the problem you are having and I just cant make it happen.
To test the theory out I created a scene with just a cube. I took the Camera and set it so that it does not have any controls. It can’t orbit, cant pan and cant zoom. This was important because often if you drag on the canvas the orbit Camera will take over and that will rotate while outside the canvas and that was a bit confusing.. when I was testing the drag over on a object.When using this setup dragging over an object stops for me as soon as the mouse leaves the canvas… however…. i created something else to ensure it stops….give it a shot.
basically added the width of the canvas container to be the limiter of the drag.
Attachments:
You must be logged in to view attached files.Xeon
Route 66 Digital
Interactive Solutions - https://www.r66d.com
Tutorials - https://www.xeons3dlab.com2024-08-25 at 1:34 am #76967masjParticipantThanks again Xeon, esp for going through the trouble of attempting to recreate the issue.
Tried it with a clean scene and simple cube just in case, but same issue when the cursor would leave the container in pressed state (made a gif, but unable to attach it so here’s a link link to gif maybe it’s a browser “feature” or a v3d bug? not sure).
That said though, testing for container dimensions in the logic as a work around is brilliant!
I’ll give that an attempt when I get the chance to do so and report back. Thank you for your great insights and ideas!2024-08-25 at 3:40 am #76968xeonCustomerOk…after watching your GIF…I think I miss understood the problem you were having.
In situation you are showing the mouse leaves the canvas at X and then renters the canvas a X+n and upon re-entry the object snaps to the mouse due to the new “current location” of x.The code I provided will not fix this particular issue. I had thought that you were dragging on the x… then returned from the same X starting point…so if you exit with X=0, you returned at X=0 but what you are doing is exiting the drag ie. X=10 and then returning from out of canvas to immediately appear at X = 400 and the cube rotates to face the new location making it “jump” for lack of a better phrase. Its not that the mouse is not rotation is not stopping…when the mouse leaves the canvas….its your re-entry point.
If the requirement is really that a person rotates the object leaves at X=0 and can return at X=500 and the object has to assume the entry point is the new x=0 so that the cube resumes the same rotation point regardless of where the mouse enters….??? I am sure it can be done….I know I haven’t tried to solve for that one…but I will think on it.
Xeon
Route 66 Digital
Interactive Solutions - https://www.r66d.com
Tutorials - https://www.xeons3dlab.com2024-08-25 at 4:26 am #76969xeonCustomerOk… so there is some algebra and geometery involved.
Overview – we have to determine the angle we need to rotate the object to based on the new X-entry point.
Basically you have to determine the (x, y) of where the mouse left the screen, and where its re-enter. These two points will be the base of a triangle with the apex of the triangle being the origin/center point of the object be rotated.
Two key formulas….
distance between two points =√((x2-x1)^2 – (y2-y1)^2 this will give us the lenght of the two sides from where they exit the screen to the objects center as well as the distance between the two exist points. You will have to do this calculation for all three points.Then you can use the law of cosines : cos(C) = (a^2+b^2+c^2)/2ac….solve for C and then you have the angle you have to animate the object to.
The problem— the time it takes for it to determine the new angle may be slower than the update X-values. So you would have to create some sort of delay on initial re-entry to prevent further rotation until the object is in the new orientation. This too might look like a stutter or at least sluggish…perhaps…have to try it out.
I also tested the standard drag move puzzle and it behaves the same way…so we are fighting that which is sort of a known condition of drag move…. My only thought is at this point is to put sort of a lag/delay on all the move…so on re-entry it just seems normal.
Xeon
Route 66 Digital
Interactive Solutions - https://www.r66d.com
Tutorials - https://www.xeons3dlab.com -
AuthorPosts
- You must be logged in to reply to this topic.