diff --git a/src/App.vue b/src/App.vue index 23476ac..59e46e9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,17 +11,17 @@ import Demo1 from './components/demos/Demo1.vue'; import Demo2 from './components/demos/Demo2.vue'; import Demo3 from './components/demos/Demo3.vue'; -import Demo4 from './components/demos/Demo4.vue'; +import Slider1 from './components/demos/Slider1.vue'; import DemoGLTF from './components/demos/DemoGLTF.vue'; export default { name: 'App', components: { - Demo1, Demo2, Demo3, Demo4, DemoGLTF, + Demo1, Demo2, Demo3, Slider1, DemoGLTF, }, data() { return { - tests: ['Demo1', 'Demo2', 'Demo3', 'Demo4', 'DemoGLTF'], + tests: ['Demo1', 'Demo2', 'Demo3', 'Slider1', 'DemoGLTF'], test: 'Demo1', }; }, diff --git a/src/components/demos/Slider1.vue b/src/components/demos/Slider1.vue new file mode 100644 index 0000000..d01e8e0 --- /dev/null +++ b/src/components/demos/Slider1.vue @@ -0,0 +1,23 @@ + + + diff --git a/src/components/sliders/Slider1.vue b/src/components/sliders/Slider1.vue new file mode 100644 index 0000000..581a7a2 --- /dev/null +++ b/src/components/sliders/Slider1.vue @@ -0,0 +1,151 @@ + + + diff --git a/src/components/sliders/useTextures.js b/src/components/sliders/useTextures.js new file mode 100644 index 0000000..26d0ad5 --- /dev/null +++ b/src/components/sliders/useTextures.js @@ -0,0 +1,28 @@ +import { TextureLoader } from 'three'; + +export default function useTextures() { + const loader = new TextureLoader(); + const textures = []; + + const loadTexture = (img, index) => { + return new Promise(resolve => { + loader.load( + img.src, + texture => { + textures[index] = texture; + resolve(texture); + } + ); + }); + }; + + const loadTextures = (images, cb) => { + textures.splice(0); + Promise.all(images.map(loadTexture)).then(cb); + }; + + return { + textures, + loadTextures, + }; +}; diff --git a/src/tools.js b/src/tools.js index 23efd52..450c3fc 100644 --- a/src/tools.js +++ b/src/tools.js @@ -17,3 +17,7 @@ export function lerpv3(v1, v2, amount) { v1.y = lerp(v1.y, v2.y, amount); v1.z = lerp(v1.z, v2.z, amount); }; + +export function limit(val, min, max) { + return val < min ? min : (val > max ? max : val); +};