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

vector3 param type #477

Open
wants to merge 9 commits into
base: alpha
Choose a base branch
from
Open

vector3 param type #477

wants to merge 9 commits into from

Conversation

funwithtriangles
Copy link
Member

@funwithtriangles funwithtriangles commented Dec 18, 2024

This introduces a new type of param to the core, vector3. It has a childNodeIds property which points to three more param nodes with the number value type. It feels like a nicer way to do it so we can still link inputs to these child nodes as if they were any other number node, rather than dealing with actual array values.

At the last step of the engine, the array gets created from the three child nodes and passed as a param to the sketch. I think we can merge this sooner rather than later, in future PRs, I plan to:

  • Improve the component, so the three sliders popout. This will allow for individual inputs to be linked.
  • Add vector2, rgb, hsl types, each with their own special component (e.g. color picker)

@funwithtriangles
Copy link
Member Author

@cale-bradbury what do ya think? Does this approach make sense to you? We'll have special slider components for each type (e.g. a color picker, XY field) but always with a "popout" option which exposes the underlying number nodes where users can assign inputs as always.

if (valueType === 'vector3') {
// Return an array of values for vector3
const childNodeIds = nodes[id].childNodeIds
value = childNodeIds.map((childNodeId) => nodeValues[childNodeId])
Copy link
Member Author

Choose a reason for hiding this comment

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

We're getting all child nodes and creating an array to be handed to the sketch. Is that how users will want it? We could also hand it back as an object with x, y and z properties (or r, g, b for colors...). Part of me thinks an array is simplest and the user can deal with it how they please.

@@ -39,6 +40,8 @@ export default class Solid {
this.root.rotation.y += params.rotSpeedY * baseSpeed * deltaFrame
this.root.rotation.z += params.rotSpeedZ * baseSpeed * deltaFrame

this.root.position.set(...params.position)
Copy link
Member Author

Choose a reason for hiding this comment

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

Here the array format works perfectly for three js, having it as object with x, y and z properties would just be more work, but I can imagine other times it would be nicer to have it the other way around. However for most cases, including color, three.js plays nicely with plain array so maybe we stick with the simplest approach.

@funwithtriangles funwithtriangles mentioned this pull request Dec 18, 2024
5 tasks
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.

1 participant