diff --git a/src/datastructures/index.js b/src/datastructures/index.js index 8fb4c371..3672a4c4 100644 --- a/src/datastructures/index.js +++ b/src/datastructures/index.js @@ -4,4 +4,5 @@ export * from './view.js' export * from './graph.js' export * from './graphlist.js' export * from './indexallocator.js' -export * from './denselist.js' \ No newline at end of file +export * from './denselist.js' +export * from './range.js' \ No newline at end of file diff --git a/src/datastructures/range.js b/src/datastructures/range.js new file mode 100644 index 00000000..a342b2f3 --- /dev/null +++ b/src/datastructures/range.js @@ -0,0 +1,32 @@ +import { lerp } from '../math/index.js' + +export class Range { + + /** + * @type {number} + */ + start + + /** + * @type {number} + */ + end + constructor(start = 0, end = 1) { + this.start = start + this.end = end + } + + /** + * @returns {boolean} + */ + valid() { + return this.start <= this.end + } + + /** + * @param {number} t + */ + lerp(t) { + return lerp(this.start, this.end, t) + } +} \ No newline at end of file