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

Update color instantly #275

Merged
merged 19 commits into from
Jan 14, 2025
Merged

Update color instantly #275

merged 19 commits into from
Jan 14, 2025

Conversation

remcoder
Copy link
Member

@remcoder remcoder commented Jan 13, 2025

This is an improvement to change the color of the model instantly, without having to rebuild the mesh.

It uses a simple ShaderMaterial which has an updatable uniform property for the color. Updating this doesn't require rebuilding the mesh, it only requires a renderer.render call.

It actually works better than expected so I promoted this from poc to pr.

TODO

I needed a good model to test shader with so I included Marlin (by cipis)
image
It looks great with this shader!

@remcoder remcoder mentioned this pull request Jan 13, 2025
Copy link

github-actions bot commented Jan 13, 2025

Visit the preview URL for this PR (updated for commit ff62254):

https://gcode-preview--pr275-poc-instant-color-ch-6qh01fy5.web.app

(expires Thu, 13 Feb 2025 21:43:45 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 59bd114ae4847b32c2bba0b68620b9069a3e3531

remcoder and others added 10 commits January 13, 2025 17:53
- Added y-axis clipping support to shaders
- Simplified clipping implementation using y values
- Removed old Plane-based clipping system
- Fixed material initialization and uniform access
- Cleaned up all references to old implementation
- Added y-axis clipping for ShaderMaterial (tubes)
- Restored plane-based clipping for LineMaterial (travel lines)
- Added updateLineClipping method to sync both systems
- Cleaned up imports and removed duplicates
# Conflicts:
#	src/dev-gui.ts
#	src/webgl-preview.ts
render.add(this.watchedObject.renderer.info.memory, 'geometries').listen();
render.add(this.watchedObject.renderer.info.memory, 'textures').listen();
render.add(this.watchedObject, '_lastRenderTime').listen();
render.add(this.webglPreview.renderer.info.render, 'triangles').listen();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Be careful with changing watchedObject. I had issues with this referencing some old objects when they are replaced.

We have many this.an_object = new ObjectClass() that made it a challenge to watch on the GUI.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the heads-up. I doublechecked and I don't think this changes breaks anything. The watchedObject is still the same instance but now it is typed to make the compiler happy.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you checked with the other places where watchedObject is changed too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll check it again! Will try tomorrow.

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked all the dev helpers. Nothing is broken by this PR.

The Job info and _lastRenderTime don't update but I checked that was already the case be for this PR.

Only the types have changed and the namei of the instance but there shouldn't be even a change in the javascript code that is being generated.

btw, did you see you can now change the lighting through the dev helper?

@remcoder remcoder changed the title POC: Update color instantly Update color instantly Jan 14, 2025
@remcoder remcoder marked this pull request as ready for review January 14, 2025 21:11
@remcoder remcoder merged commit c485237 into develop Jan 14, 2025
3 checks passed
@remcoder remcoder deleted the poc/instant-color-change branch January 14, 2025 21:44
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