typescript

This commit is contained in:
Kseninia Mikhaylova 2024-06-13 10:55:29 +03:00
parent 12f7048806
commit 6cdb8290f1
2 changed files with 47 additions and 36 deletions

View File

@ -17,6 +17,7 @@ const parametric = {
},
total_length: {
min: 1,
max: undefined,
step: 0.1,
},
height: {
@ -52,14 +53,17 @@ const changeParametres = () => {
fence_section.value = form_state.length * 0.001
for (const key in form_state) {
if (parametric.hasOwnProperty(key) && parametric[key].max) {
if (form_state[key] > parametric[key].max) {
form_state[key] = parametric[key].max
if (parametric.hasOwnProperty(key)) {
const key_p = key as keyof typeof parametric
const key_s = key as keyof typeof form_state
if (parametric[key_p].max) {
if (form_state[key_s] > parametric[key_p].max) {
form_state[key_s] = parametric[key_p].max
}
}
if (parametric.hasOwnProperty(key) && parametric[key].min) {
if (form_state[key] < parametric[key].min) {
form_state[key] = parametric[key].min
if (parametric[key_p].min) {
if (form_state[key_s] < parametric[key_p].min) {
form_state[key_s] = parametric[key_p].min
}
}
}
@ -90,6 +94,7 @@ const changeParametres = () => {
if (form_state.extra_section && form_state.extra_section < parametric.length.min) {
form_refs.total_length.value.setCustomValidity('Расчет невозможен')
}
}
}
const setLamelleColor = (color: ralTypes) => {
@ -100,13 +105,18 @@ const setPillarColor = (color: ralTypes) => {
}
const increment = (field: keyof typeof form_state, value: number) => {
if (form_state.hasOwnProperty(field)) {
let v = (form_state[field] + value * parametric[field].step ?? 1)
const key_p = field as keyof typeof parametric
let v = (form_state[field] + value * parametric[key_p].step ?? 1)
if (parametric.hasOwnProperty(field)) {
if (v > parametric[field].max) {
v = parametric[field].max
if (parametric[key_p].max) {
if (v > parametric[key_p].max) {
v = parametric[key_p].max
}
}
if (parametric[key_p].min) {
if (v < parametric[key_p].min) {
v = parametric[key_p].min
}
if (v < parametric[field].min) {
v = parametric[field].min
}
}
form_state[field] = parseFloat(v.toFixed(2))

View File

@ -23,7 +23,8 @@ const pbrTexture = await useTexture({
const repeat = 5
for (const key in pbrTexture) {
if (Object.prototype.hasOwnProperty.call(pbrTexture, key)) {
const element = pbrTexture[key];
const key_p = key as keyof typeof pbrTexture
const element = pbrTexture[key_p]
if (element && element.wrapS) {
element.wrapS = RepeatWrapping
element.wrapT = RepeatWrapping