Conversation
- give geometry() extrusionDistance a default so existing callers still type-check - guard against null result before destructuring in renderPathsAsTubes - prettier formatting for WIP files
|
Visit the preview URL for this PR (updated for commit e946a7e): https://gcode-preview--pr358-feature-rainbow-fila-b1v3ppjg.web.app (expires Sun, 20 Sep 2026 21:19:57 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 59bd114ae4847b32c2bba0b68620b9069a3e3531 |
|
That looks like a cool feature to visualize gradient filament! If the goal is to just have something pretty, gradient by layer may be simpler. But the case above is cool, but it can also help visualize what layers uses more filament and not ruin the effect (for example, a container with a flat bottom will have the colours to shift rapidly on the flat bottom and then have more of a stretched shift on the rest). |
|
yeah this was an old experiment. The idea was to have some sort of simulation bc it's always hard to predict how such prints come out. It would need a length after which the color change is 360 degrees and repeats.. assuming that this is a constant factor 🤷🏻 . Your example of a container or base is a great example. But even just different sizes or number of instances of the same model change the coloring a lot. And then there is the effect that 2 consecutive prints never look the same because they most probably never start at the same color. Let's say you print a rainbow Axolotl for a kid. Then a second kid wants a rainbow Axolotl too. However, the second Axolotl then becomes its own unique color variation, at which point the first kid now also wants a copy of the second version, and so on.... (ask me how I know 😄 ) |
|
actually doing this by layer might make it a lot easier! Thank for that idea! |
Per-layer draw calls vs. per-vertex data + shaderFollowing the "doing this by layer might be a lot easier" thread — the by-layer idea is easier in one implementation and not easier in another, so it's worth separating the two. This came up while looking at Numbers below are measured on Option A — a material and draw call per layerGroup geometry by layer, give each layer its own material, set its color directly. For:
Against:
Option B — per-vertex attribute, shader does the mappingWhat this WIP already does: For:
Against:
Option C —
|
Intent
Color filament by cumulative extrusion distance, computed per path and passed to the shader as a vertex attribute (
extrusionDistance). Each geometry gets a per-vertex extrusion-distance attribute, and the material's fragment shader maps that value onto a rainbow hue.Current state (WIP)
Path.geometry()now accepts anextrusionDistanceparameter and returns{ geometry, extrusionDistance }, setting a per-vertexextrusionDistanceattribute.createColorMaterialshader receivesvExtrusionand maps it viamod(vExtrusion, 100.0) / 100.0into a rainbow. The actualrainbow()mapping is stubbed — it returns red fort in (0,1)and white otherwise, so no real color gradient yet.renderPathsAsTubesthreads a runningtotalExtrusionDistancethrough each path and uses the returned geometry.side: 2).Fixes applied to make it compile
src/path.ts: gavegeometry()a default value for the newextrusionDistanceparam and defaultoptsso existing callers still type-check.src/scene-manager.ts: guarded against thenullresult frompath.geometry()before destructuring.npm run lintpasses.npm run typeCheckandnpm run lintboth pass.