2017-04-06 06:02:24 -04:00
|
|
|
import Renderer from './3d_viewer';
|
|
|
|
|
2018-03-01 03:21:08 -05:00
|
|
|
export default () => {
|
2017-04-06 06:02:24 -04:00
|
|
|
const viewer = new Renderer(document.getElementById('js-stl-viewer'));
|
|
|
|
|
2020-12-23 16:10:24 -05:00
|
|
|
[].slice.call(document.querySelectorAll('.js-material-changer')).forEach((el) => {
|
|
|
|
el.addEventListener('click', (e) => {
|
2022-06-30 11:09:03 -04:00
|
|
|
const { currentTarget } = e;
|
2017-04-06 06:02:24 -04:00
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
2021-04-09 23:09:09 -04:00
|
|
|
document.querySelector('.js-material-changer.selected').classList.remove('selected');
|
2022-06-30 11:09:03 -04:00
|
|
|
currentTarget.classList.add('selected');
|
|
|
|
currentTarget.blur();
|
2017-04-06 06:02:24 -04:00
|
|
|
|
2022-06-30 11:09:03 -04:00
|
|
|
viewer.changeObjectMaterials(currentTarget.dataset.material);
|
2017-04-06 06:02:24 -04:00
|
|
|
});
|
|
|
|
});
|
2018-03-01 03:21:08 -05:00
|
|
|
};
|