useModelInfoStore.js 990 Bytes
import { defineStore } from 'pinia';
import { reactive, ref } from 'vue';

export const useModelInfoStore = defineStore('model-info', () => {
    const isBoundingBoxVisible = ref(true);

    const modelInfo = reactive({
        length: 0,
        width: 0,
        height: 0,
        volume: 0,
        triangles: 0
    });

    const setModelInfo = ({ length, width, height, volume, triangles }) => {
        modelInfo.length = length === 0 ? null : length.toFixed(2);
        modelInfo.width = width === 0 ? null : width.toFixed(2);
        modelInfo.height = height === 0 ? null : height.toFixed(2);
        modelInfo.volume = volume === 0 ? null : (volume / 1000).toFixed(2);
        modelInfo.triangles = triangles === 0 ? null : Math.round(triangles / 3);
    };

    const setBoundingBoxVisible = (val) => {
        isBoundingBoxVisible.value = val;
    };

    return {
        modelInfo,
        isBoundingBoxVisible,
        setModelInfo,
        setBoundingBoxVisible
    };
});