Last modified: 2025-03-25 21:31:17
< 2025-03-24 2025-03-26 >I think make makePeptide()
return null
if the node is disabled.
And whenever a node tries to use a child node, it needs to check
whether the child node returned null
, and if a null
child implies
a null
parent then it also has to return null
.
This is working, good, fixes the glitch where the distance field gets broken when a node is disabled.
ChatGPT pointed me at:
For sources of free icons.
I am wondering if I should embrace the JS ecosystem a bit more and maybe use React? It would make making UI components easier, but introduces a build step which is an enormous annoyance.
I'll let Claude have a go at refactoring it to use React, and if it looks too annoying I'll just stop.
Meh, looks too annoying.
We can now open/save files by serialising as JSON. Pretty hacky but works for now.
To do this we basically want to change:
P.const(this.blendRadius);
into
P.var("u_MyNodeName_blendRadius");
and then set the uniforms at render time.
And instead of constructing the uniform name by hand, we probably want that abstracted. So maybe:
this.uniform("blendRadius");
And this.uniform("blendRadius")
will firstly pick a uniform name,
and secondly set some state so that the uniform can get set based on
the node properties at render time. And we'll also want a vuniform()
or something for Vec3
values.
And then I guess we see if the generated code is exactly identical to what it was before, and if so don't bother recompiling the shader? Can probably do even better than that if we know which properties can safely be changed without needing to mark the document dirty.
Whoa this is working!
The CubicLattice
seems broken, need to look at that in a bit. I think
it's not a cubic lattice but it may be interesting anyway. Actually
it might be a cubic lattice. Not sure.
One thing that is really cool about this is I don't need to write any special code to work out whether the shader needs recompiling. I just work out if the generated code is equivalent to the last one (which takes less than 1 ms with my default object, even for a shader that takes 300 ms to compile). And if it's equivalent I don't bother recompiling it.
Firefox seems to cache the compiled shaders anyway, so compiling duplicate shaders isn't the end of the world, but it unnecessarily flashes up the "loading" spinner on the UI.
Also we need to set the uniforms when evaluating in JS for working out coordinates under the cursor, and for meshing.
I added a tan()
function to Peptide, currently failing tests because
I didn't make an interval version.
Great, was quite easy to set uniform values in the SDF for coordinates under cursor and for meshing. This is a good improvement. The next thing is probably defining a way to set draggable points on the 3d view, and then those draggable points can go straight into setting uniforms, which means you can directly edit the shape in realtime.
Being able to just straightforwardly write the code and have it
automatically work out when it needs to recompile the shader is great.
This is exactly the kind of experience I want with domain repetition,
I want to be able to just write my SDFs and have it work out when to use
domain repetition and when to use explicit union, without having to also
write a boundingSphere()
calculator for every node.
I got Cursor to add Copy/Paste options to the menu. It looks like:
"Cut" was broken because I had edited it to delete the node from the tree at the time you "Cut", instead of at the time you "Paste".
Cool, I've now made it disable & collapse the "cut" node to make it clear what is happening. You can manually cancel the cut by just not pasting it anywhere, and re-expanding and re-enabling. And even after that you can paste it anyway if you want, and then it will move.
And fixed the other bugs. Great, I now have a working cut/copy/paste.
https://en.wikipedia.org/wiki/Command_pattern is a good way to do undo/redo. Every edit to the document is a "command" and they all go through a "command runner", which adds an undo point?
It has the potential risk that if you do multiple "commands" as part of one user-visible operation then it could turn into multiple half-broken undo states.
Another option would be to store an undo point every time document.dirty()
in the render loop! That way we would always catch every user-visible operation, and no need for command pattern stuff. I think the only downside is if the user manages to do multiple things before we re-render then they'll still only get one undo point, but I think I don't care about that? If you only see the contents of the screen change once I think it's fine to consider that the object only changed once.
Oh! But most of your property edits no longer cause document.dirty()
because they only change uniforms.
Oh, disregard, it all works out! They still cause document.dirty()
but
they generate identical shader code so we don't recompile the shader.
Good, I think that's the way to do it: store an undo point every time we think we might have to regenerate the main shader.
OK, this seems to be working, but it feels like it is probably buggy.
Bugs:
OK, fixed those. Great, we have undo/redo now! Claude didn't spot any bugs that I thought sounded like they mattered, and I couldn't think of any either. But I do still vaguely have a feeling that it's not rigorous.
I want to be able to drag grab handles in the 3d view to set rough positions and sizes.
I want the surface normals to not get more vague as you get more zoomed-out. (The issue is we need a large step size to make edge detection work, maybe we ditch edge detection if we're not going to do anything useful with it?).
I want a better sketch editor, including arcs, circles, and a constraint solver.
I want to be able to use computed values in property fields (like =Box1.size.x
), and also maybe make a "parameter sheet" that just has a bunch of cells with names that you can edit.
I want a measuring tool to let me click on some points on the surface and have it show me the distance/angle between them.
I want decent keyboard shortcuts, I ought to be able to manipulate the tree and edit properties without touching the mouse.
I want to click on the surface and pick out datum axes/planes, and use them in nodes that take axes, or map sketches on to them.
I want to be able to make gears and text and helical extrusions.
I want to load in a photograph of what I'm trying to make and position/scale it for reference.
I want to be able to put "links" in the tree, to kind of make a DAG.
I want to be able to set the precision for STL export, and also have it automatically discover the bounding box, and probably do some sparse voxel thing to cut down on how long it takes.
I want to be able to type my own custom SDFs in some sort of Peptide DSL.
I want to be able to import meshes and interact with them with my own SDFs (sample a SDF for the mesh as voxels and load as a 3d texture, with distance interpolation?).
I want a better chamfering smooth-min, the current one basically sucks.
And I want to be able to target fillets/chamfers at specific edges.
< 2025-03-24 2025-03-26 >