-
Notifications
You must be signed in to change notification settings - Fork 303
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
refactor(pointsmaterial) : shared potree material among point tiles (no cloning) #760
Conversation
You could use this PR to work towards one important aspect needed for #695: unifying parser output. So instead of adding a new possibility for parser output (we already have meshes and Features), I'd prefer that you use the same output as the geojson parser - improved if needed (maybe using a |
Here, I was more targetting the "Move symbolizing code out of formatters" facet of #695. Concerning my question on the need to clone the material, I figured out that the issue was triggered by the pointcloud process that was setting
It might be that both per-layer and per-tile materials make sense depending on the context and that we might end up supporting both (eg by accepting layer.material as a material instance to be shared or as a material creator function called for each tile) |
If you want to use your own material, this PR is not needed, you can already do it: layer.onPointsCreated = (layer, pts) => {
pts.material = mymaterial;
}; That's why I'm suggesting to do something more useful for the long term. I don't request that you modify all parsers; you can simply improve the ones you're interested in (
Great, then open another PR to fix this as well :) |
unfortunately, it is. Your snippet is likely not working, due to the current handling of the visibility in the pointcloud process (see fa5f613)...
I can open an issue to start the discussion. Whenever someone has time to work on that, he will then have some material to base its work on... |
Can you elaborate (I don't understand the problem)?
|
If you use a single material shared by all objects and the process modifies material.visible, then either all or no objects of the layer will be displayed (depending on the status of the last updated object)
indeed, that is lod-culling ! |
#761 shows the shared material bug in action |
IMHO you need to clone the So, with this error fixed in my snippet, you can do: layer.onPointsCreated = (layer, pts) => {
pts.material = mymaterial.clone();
}; |
what do you mean by "need" ? this PR achieves its goal of a shared material decoupled from the parsers without cloning the material...
...which does not matter here as all nodes are added to a flat group (no hierarchy), as far as I can tell. :) |
You need because of the meaning of the 2
Yes, but you're only looking at itowns code. You don't know how it'll be used and you can't assume that users of itowns will never add children to points objects. |
I do not know what they are doing, but if user add children to points objects, which is not a documented behavior (and might interfere with pointcloudprocess logic), they might be happy to see that these objects get invisible whenever the points get invisible. That's actually a very good idea to simplify the box helper code, isn't it ? :) If we cannot agree on the second commit for now, what do you think of the first one ? |
This is fully documented: it's the core behavior of three.js.
Sorry but this is wrong as well. We mark invisible points as invisible (here). But we also hide visible points when they are not needed. So not cloning the material would be handy for a few things but I don't think it's possible. |
I think I already answered to the first one here: #760 (comment) |
I understand that you prefer to close this PR unmerged.
|
a701b17
to
04a9607
Compare
732b076
to
58914de
Compare
Could you rebase this PR please? |
done! I added a second commit to fix some issues in the debug helper. I am not satisfied on the call to updatestats in the helper as this function is defined in the example. do you have a better proposition for fixing the display of the stats ? |
Thanks. I'm still not convinced that this is good idea because that goes against the logic exposed by threejs, so IMHO this shouldn't be merged. |
Not sure about what the 'logic of threejs' is, about sharing materials across objects. Do you have a pointer ? Both approaches (master and this PR) work and offer different tradeoffs, depending if you want more or less to hide to the user that the layer is managing internally a collection of objects by exposing a single
let us keep this around for a while, until we settle on a common approach for all itowns materials :) |
See #760 (comment), and #760 (comment) and #760 (comment) In threejs, a material has per object properties (at the very least the Feel free to prove me wrong, but I don't want to merge something that breaks threejs semantics (again, especially for the .visible property). |
I meant pointers to comments not written by you ;). For reference, there are at least 2 I found the pointcloud debug helper a little buggy (eg: sync issues for the stats and the visibility of boxes) and lacked the option to show only the sticky node. Would you be interested in writing a PR for the second commit only ? |
untick "display parent" and "display children". It'll display only this node.
But that's a flaw to the particular solution chosen in #764 . In short, we (I included) have complicated our life on current master (properties are in layer.foo, then layer.material.foo, then layer.material.uniforms.foo, leading indeed to painful and difficult synchronization process). This can be a lot simpler, without requiring to keep the same material. |
I am for removing this one, and keep all stylization to
This one sounds good and should be kept. The good thing is that it does not impose anything on the material (it is free to use or not this new property).
The issue here is that materials may not have a uniforms property. Updating them should be a internal concern of the material You are missing the syncing of the
I agree, but it is only the downside of garanteeing the sync of the layer options with the object materials (I consider the previous behavior of only copying layer properties at tile creation time a bug). This PR is an alternative approach with the same sync garantee, there are surely other way to achieve this goal. |
this PR is rebased in #1589 |
Description
Potree parsers used a hardcoded itowns.PointsMaterial material
This PR tackles some part of #695 to decouple the parsing and the styling of potree pointclouds.
Change
Screenshots
No visible change
Question
I am not sure I understand why I need to clone the material. Ideally, I would like to use the same material for all pointcloud tiles.
@peppsac : any clue ?