Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 1x 5x 5x 5x 5x 5x 5x 2x 2x 2x 2x 4x 4x 1x 4x 8x 8x | <template>
<div>
<span class="text-caption">{{ t('labels.opacity') }}</span>
<v-slider
:model-value="opacity"
@update:model-value="setOpacity"
hide-details
min="0"
max="100"
thumb-color="primary"
:thumb-label="label"
thumb-size="16"
step="1"
>
<template #prepend>
<v-btn
variant="text"
icon="remove"
density="compact"
@click="decrement"
/>
</template>
<template #append>
<v-btn
variant="text"
icon="add"
density="compact"
@click="increment"
/>
</template>
</v-slider>
</div>
</template>
<script setup lang="ts">
import { useViewer3cr } from '@/composables/useViewer3cr';
import { clamp } from '@/functions/clamp';
import { ObjectColour } from '@3cr/types-ts';
import { DataOverlayMcad } from '@3cr/viewer-types-ts';
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
interface Props {
mcad: DataOverlayMcad;
}
const props = defineProps<Props>();
const { t } = useI18n();
const viewer3cr = useViewer3cr();
const label = ref<boolean | 'always'>(true);
const timeout = ref<number>();
const opacity = computed(() => Math.round(props.mcad.Colour.A * 100));
async function increment(): Promise<void> {
await setOpacity(opacity.value + 1);
showLabel();
}
async function decrement(): Promise<void> {
await setOpacity(opacity.value - 1);
showLabel();
}
function showLabel(): void {
label.value = 'always';
if (timeout.value) {
clearTimeout(timeout.value);
}
timeout.value = setTimeout(() => (label.value = true), 1000);
}
async function setOpacity(value: number): Promise<void> {
const message: ObjectColour = {
Version: '0.0.0',
Id: props.mcad.Id,
Colour: {
Version: '0.0.0',
R: props.mcad.Colour.R,
G: props.mcad.Colour.G,
B: props.mcad.Colour.B,
A: clamp(value, 0, 100) / 100,
},
};
await viewer3cr.setMcadObjectColour({ message });
}
</script>
|