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

"Translation" animation with step=0 #30

Closed
kperry42 opened this issue Sep 26, 2022 · 1 comment
Closed

"Translation" animation with step=0 #30

kperry42 opened this issue Sep 26, 2022 · 1 comment

Comments

@kperry42
Copy link
Contributor

I like the new the "translation" animation feature, it's very nice. One detail, though - it doesn't allow for setting a translation with "step" = 0. This would be helpful if one wants to build several items with computed properties. For instance in this simple example of an expanding row of boxes, where the middle one should stay at the origin:

data = [];
for (let j = -2, j <= 2; j++) {
    data.push(box(1, 1, 1, {translation: {path:'[t, 0, 0]', step: j/10}}));
}

... you don't want to have to write special-case code to remove the translation with step=0.

Currently, threejs-template.js line 421 has:

var step = s.options.translation.step ? s.options.translation.step : .05;

This causes "s.options.translation.step = 0" to map to "step = .05". Using Number.isFinite() here instead would be an improvement:

var step = Number.isFinite(s.options.translation.step) ? s.options.translation.step : .05;

This will map undefined, null, false, and invalid values to the default, but allow 0 as a possible value.

@paulmasson
Copy link
Owner

@kperry42 I don't have a problem with this change. Would you like to submit a pull request to get credit for the enhancement?

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

No branches or pull requests

2 participants