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