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

edit 3d tiles opacity and blending mode #1012

Merged
merged 15 commits into from
Jan 18, 2025
Merged

edit 3d tiles opacity and blending mode #1012

merged 15 commits into from
Jan 18, 2025

Conversation

kfarr
Copy link
Collaborator

@kfarr kfarr commented Jan 8, 2025

No description provided.

Base automatically changed from epic-street-editing to main January 13, 2025 22:25
@kfarr kfarr marked this pull request as ready for review January 16, 2025 05:19
@kfarr kfarr changed the title mvp opacity and blending mode edit 3d tiles opacity and blending mode Jan 16, 2025
// this.updateMaterials();
// this.el.getAttribute('tiles-material-change').needsUpdate = false;
// }
this.updateMaterials();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's expensive to keep doing a traverse on each tick, also it's creating an array each time [node.material].

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, in obb-clipping this is throttled, I can do that again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately the result looks very bad if throttled, materials appear to "flicker" as they wait for the throttle to be adjusted to a different blending.

For now I'll keep it, but there are 2 options to fix:

  1. hook into the material post processing event in the existing 3d tiles library
  2. consider switching to better maintained library instead of optimizing this one, hook into its material post processing event https://github.com/NASA-AMMOS/3DTilesRendererJS?tab=readme-ov-file#custom-material (blocked by a-frame / three.js upgrade -- needs v166)

@kfarr
Copy link
Collaborator Author

kfarr commented Jan 16, 2025

the default should not apply this unless a user selects it. an idea:

  • add new boolean to street-geo, blendingEnabled default false
  • if false, don't add or modify any blending-opacity component values
  • if set to true and was previously false, add blending-opacity component, allow modify of blending-opacity component values
  • if set to false and was previously true, delete and re-add the google tiles without the component?

@vincentfretin
Copy link
Collaborator

Wait, for the array allocation, I just thought that you will fix it like this:

applyPolygonOffsetToObject: function (object3D) {
if (!object3D) return;
object3D.traverse((obj) => {
if (obj.isMesh) {
if (Array.isArray(obj.material)) {
obj.material.forEach((material) => {
this.updateMaterial(material);
});
} else {
this.updateMaterial(obj.material);
}
}
});
},
updateMaterial: function (material) {
if (!material) return;
material.polygonOffset = true;
material.polygonOffsetFactor = this.data.factor;
material.polygonOffsetUnits = this.data.units;
// Ensure material updates
material.needsUpdate = true;
},

Not a complex cache with a WeakMap.

For traversing of each tick, it probably doesn't matter much, you can do a Chrome profiling eventually with cpu throttling with and without the component to be sure.
You can revisit the code once we update aframe and use the proper hook/event the 3d tiles library provides.

src/components/street-geo.js Outdated Show resolved Hide resolved
src/components/street-geo.js Show resolved Hide resolved
@kfarr kfarr merged commit 0e9a4b3 into main Jan 18, 2025
1 check passed
@kfarr kfarr deleted the tiles-blending-experiment branch January 18, 2025 19:51
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

Successfully merging this pull request may close these issues.

2 participants