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

Path class #26

Open
1 task
vorg opened this issue Jan 26, 2024 · 1 comment
Open
1 task

Path class #26

vorg opened this issue Jan 26, 2024 · 1 comment
Labels
type/feat A new feature

Comments

@vorg
Copy link
Member

vorg commented Jan 26, 2024

There is need for class / utils for handling 2d/3d paths (lists of points)

It wish it could be geom with .positions but then it needs .primitive id to distinguish paths/holes like we did with houdini branches. Or it could be just path: array of arrays type (definitely not array of typedarrays too much PITA) but then i need path.* nodes e.g. path.Subdivide path.Resample and most path.CenterAndNormalize.

Some more questions from @dmnsgn:

  1. first, what is the primitive definition ie. "what is a path": is it an array of point in cartesian coordinates?
  2. Are we interested in defining points for curves too (associating bezier control points for instance) and so that suggest the same citi data structures (keeping holes or informations about point in separate arrays)
  3. is there both 2d path and 3d path? Is that something we could again define with .primitive id.
  4. do we lean towards a data structure optimised for webgl/webgpu and just build conversion helpers when we need to convert path to svg?
  5. are we re-inventing a non-typescript @thing/geom and should it be in pex-geom

@vorg answers:
to keep it simple

  1. Path is list of points so technically a PolyLine. Shape would be an array of Paths (array of arrays of points)
  2. That would be Curve or Shape2d or SVG. Too complicated. Nobody will generate bezier curves or hard corners in code -> Out of scope
  3. Happy to assume it's always 3d and z can be just = 0
  4. Nope. PITA. Kills DX, unproductive, it's not a rendering primitive (that would be geometry with typed array attributes)
  5. TODO: worth checking

Tasks

  • research @thing/geom
@dmnsgn dmnsgn added type/feat A new feature and removed enhancement labels Jan 29, 2024
@dmnsgn
Copy link
Member

dmnsgn commented Feb 16, 2024

Path is just a construct. For me the most flexible is still using buckets of data. We could use type properties to identify objects other than 3D geometries:

// Simplicial complex (default type)
{
  positions: new Float32Array([x, y, z, x, y, z, ...]),
  normals?: new Float32Array([x, y, z, x, y, z, ...]),
  uvs?: new Float32Array([u, v, u, v, ...]),
  cells: new Uint32Array([a, b, c, a, b, c, ...])
  // + any other attribute
}

// Path
{
  type: PexGeomEnumTypes.Path,
  positions: new Float32Array([x, y, z, x, y, z, ...]),
  normals?: new Float32Array([x, y, z, x, y, z, ...]),
  tangents?: new Float32Array([x, y, z, x, y, z, ...]),
  binormals?: new Float32Array([x, y, z, x, y, z, ...]),
  // + any other attribute
}

// Shape (similar to earcut(vertices[, holes, dimensions = 2]) )
{
  type: PexGeomEnumTypes.Shape,
  positions: new Float32Array([x, y, z, x, y, z, ...]),
  holes: [5, 8],
  // + any other attribute
}

// Bezier curve (for the sake of example)
{
  type: PexGeomEnumTypes.BezierCurve,
  positions: new Float32Array([cp1x, cp1y, cp2x, cp2y, x, y,  cp1x, cp1y, cp2x, cp2y, x, y]),
  holes: [5, 8],
  // + any other attribute
}

// Hierarchy
{
  type: "hierarchy,
  positions: new Float32Array([x, y, z, x, y, z, ...]),
  nodes: [0, 5],
  weight: [10, 7.5]
}
{
  type: "node",
  id: 0,
  parent: undefined
}
{
  type: "node",
  id: 5,
  parent: 0,
  children: [6, 7]
}

that allows for

  • variable number of attributes
  • assuming attributes have meaning on their own (positions means 3D positions in space, not vertices for 3D rendering)
  • the possibility of adding new features via attributes
  • identifying the data types easily to transform them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feat A new feature
Projects
None yet
Development

No branches or pull requests

2 participants