import axios from 'axios'; import { storeToRefs } from 'pinia'; import { DEMO_BUCKET_URL } from '@/constants'; import { stlResolution } from '@/models/scanState'; import { useViewerStore } from '@/stores/viewer.store'; const ax = axios.create(); export function mockDemoViewerStlDecimator() { const { options } = storeToRefs(useViewerStore()); options.value.onResolveKeys = async (keys: string[]) => { return await Promise.all( keys.map(async (key) => { if (key.includes('.stl')) { try { const x = await ax.post( 'https://qz7o5n708h.execute-api.ap-southeast-2.amazonaws.com/test/decimate-stl-demo', { S3KeySub: `stl/${key}`, DecimationValue: stlResolution.value / 100, }, ); return x.data.data.Url; } catch (err) { console.error(err); } } return `${DEMO_BUCKET_URL}/stl/${key}`; }), ); }; }