-
Notifications
You must be signed in to change notification settings - Fork 294
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
Adding in a Networked World Transform Option and Example #223
Adding in a Networked World Transform Option and Example #223
Conversation
Have updated to only update worldMatrices once per update now. |
} | ||
else { | ||
//pick-up | ||
self.player.object3D.attach(self.el.object3D); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you attach it the the camera in the first place? The whole PR exists only because of it.
You shouldn't need to detach and attach the object when it's grabbed.
You should look at the https://github.com/wmurphyrd/aframe-super-hands-component library instead.
euler_w = new THREE.Euler(); | ||
pos_w = new THREE.Vector3(); | ||
quat_w = new THREE.Quaternion(); | ||
scale_w = new THREE.Vector3(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are creating those objects each time gatherComponentsData
is called, not cool for the garbage collector. You may lose some fps when the garbage collector is triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and the added example, but I really think this is not the proper way to do.
See https://github.com/wmurphyrd/aframe-super-hands-component a great library to grab objects.
Unfortunate. Super-hands is a huge dependency to put into a project If all you need is a way to adjust adjust scene hierarchy while still maintaining appropriate transform synchs on other client. Attaching/detaching appears to be a valid form to do so in three.js without relying on a physics-based constraint. Being able to pick up and release an object just seemed the simplest and most intuitive way to demonstrate this. Thanks for checking it out anyhow. |
Do you really need physics with super-hands? I thought you could use some components without physics. |
Ok I understand now that your pickable component is using the camera position, not the cursor position, this is why I found it was weird in your video. |
Just a note that I am continuing to use an updated version of this fork as it is so handy to be able to create networked entities that appear to obey the scene graph when synched i.e., below having an empty parent entity holding a bunch of locally transformed spheres that will all show up on the remote side with the correct placement. So can be useful beyond just having a simple "carrying" mechanic ... |
I guess you have a networked component only on the children? Is that right? |
My previous comment may be wrong, it depends when and how often the children updates their position. If the children update their world position because the parent position changed, so in the same frame, instead of the 9 |
Yeah, I am pretty sure this solution could probably be better optimized, so I only set the ‘syncWorldTranforms’ to try where needed :/ But it is just a strange case where I need to control color/visibility of each target/sphere but I need the entire group to move together. I think I would need to create another NAF template otherwise which I guess is a possibility also. I’ll keep poking thanks. |
If the spheres doesn't move, I'll write a schema for the parent with position/rotation, and schema with material.color/visible for the spheres. I don't see anything wrong with it. :) |
I have been playing with being able to pick up and release other elements for a few months and always wrestled with how networked-aframe currently only syncs via local space so that if you are trying to sync a nested component (e.g. one parented to the camera) the expected transforms will not be reflected in other users' views.
In this PR I am proposing and showing an example of a new networked property called "synchWorldTransforms" in networked.js
This property defaults to false so that most use-cases that do not require world transforms do not incur the overhead of calculating them, defaulting to traditional methods of copying each property over.
An example of what this would look on an element that can be picked up below
*new* world-space.html in examples
Note that the added code in networked.js is not necessarily the most performant as it will likely calculate the object3D's world matrices more than once per frame; but it felt a fair trade-off so that the code was not too violently inserted into the existing foundation. Maybe I have overlooked an easier way to do this with greater performance :)networked.js
Here is a video of the example here in action: https://twitter.com/PlumCantaloupe/status/1286145807784321027?s=20