2017-08-17 22:00:37 +05:30
|
|
|
import Renderer from './3d_viewer';
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
export default () => {
|
2017-08-17 22:00:37 +05:30
|
|
|
const viewer = new Renderer(document.getElementById('js-stl-viewer'));
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
[].slice.call(document.querySelectorAll('.js-material-changer')).forEach((el) => {
|
|
|
|
el.addEventListener('click', (e) => {
|
2022-08-13 15:12:31 +05:30
|
|
|
const { currentTarget } = e;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
document.querySelector('.js-material-changer.selected').classList.remove('selected');
|
2022-08-13 15:12:31 +05:30
|
|
|
currentTarget.classList.add('selected');
|
|
|
|
currentTarget.blur();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-13 15:12:31 +05:30
|
|
|
viewer.changeObjectMaterials(currentTarget.dataset.material);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|
2018-03-27 19:54:05 +05:30
|
|
|
};
|