1
0
mirror of https://github.com/troisjs/trois.git synced 2024-11-24 12:22:03 +08:00
trois/src/tools.js

14 lines
330 B
JavaScript
Raw Normal View History

2020-09-14 22:57:11 +08:00
export function setFromProp(o, prop) {
if (prop instanceof Object) {
for (const [key, value] of Object.entries(prop)) {
o[key] = value;
}
}
};
2020-09-16 21:30:39 +08:00
export function lerp(value1, value2, amount) {
amount = amount < 0 ? 0 : amount;
amount = amount > 1 ? 1 : amount;
return value1 + (value2 - value1) * amount;
};