metafizzy / metafizzy/zdog

addToPoint option for easier point-to-point modeling

Open
#5 0 comments 6 reactions 0 assignees View on GitHub
feature request
Dominant language
JavaScript
Stars
10.7k
Forks
407
PR merge metrics
No merged PRs in 30d

Description

**Add a 👍 reaction** to this issue if you would like to see this feature added. Do not add +1 comments — [They will be deleted](https://metafizzy.co/blog/use-github-reactions-delete-plus-1-comments/).

---

Proposal: add `addToPoint` option for items, and named `path` points for easier point-to-point modeling. Currently you have to copy `translate` values. Consider this model for an arm

``` js
let chest = new Zdog.Shape({
path: [
{ x: -4 },
{ x: 4 }
],
// ...
});

let upperArm = new Zdog.Shape({
addTo: chest,
path: [
{ y: 0 },
{ y: 3 },
],
// connect to shoulder
translate: { x: -4 },
// ...
});

let foreArm = new Zdog.Shape({
addTo: upperArm,
path: [
{ y: 0 },
{ y: 3 },
],
// connect to elbow
translate: { y: 3 },
// ...
});
// hand
new Zdog.Shape({
addTo: foreArm,
// connect to wrist
translate: { y: 3 },
// ...
});
```

The `translate` values for `upperArm`, `foreArm` and hand are all taken from a point of the item's parent. With an `addToPoint` option and named path point, you could directly set that value without have to copy over the values.

``` js
let chest = new Zdog.Shape({
path: [
{ x: -4, name: 'rightShoulder' },
{ x: 4 }
],
// ...
});

let upperArm = new Zdog.Shape({
addTo: chest,
addToPoint: 'rightShoulder',
path: [
{ y: 0 },
{ y: 3, name: 'elbow' },
],
// ...
});

let foreArm = new Zdog.Shape({
addTo: upperArm,
addToPoint: 'elbow',
path: [
{ y: 0 },
{ y: 3, name: 'wrist' },
],
// ...
});
// hand
new Zdog.Shape({
addTo: foreArm,
addToPoint: 'wrist',
// ...
});
```

Contributor guide

Open the contributing guide

Research direction

Start at the Zdog.Shape entry point and trace how addTo, translate, and path points are handled. Compare the existing arm example with the proposed named-point model. Done means items can attach through addToPoint and named path points without manually copying parent translate values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.