let tuopanInishengji = true let storeyHeight = { 1: 0, 2: 261.9, 3: 411.4, 4: 561.1, 5: 710.8 } let storeyWidth = { 1: -100, 2: -100, 3: -100, 4: -130, 5: -60 } let tishengjiLocation = { floor: 0, x: 0, y: 0, z: 0 } let tuopanLocation = { floor: 0, x: 0, y: 0, z: 0 } const tishengjiAnimation = (model, floor, newLocation = 0, time = 2000) => { return new Promise((resolve, reject) => { tishengjiLocation.floor = floor if (!model || tishengjiLocation.y === newLocation) { resolve() } let distance = newLocation - tishengjiLocation.y let time1 = setInterval(() => { if ((distance > 0 && model.position.y >= newLocation) || (distance < 0 && model.position.y <= newLocation)) { model.position.y = newLocation tishengjiLocation.y = newLocation resolve() clearInterval(time1) clearTimeout(time3) } else { model.position.y += distance / (time / 16) tishengjiLocation.y = model.position.y } }, 16) let time3 = setTimeout(() => { resolve() clearInterval(time1) clearTimeout(time3) }, time + 1000) }) } const tuopanXAnimation = (model, newLocation = 0, time = 2000) => { return new Promise((resolve, reject) => { if (!model || newLocation === tuopanLocation.x || tishengjiLocation.floor !== tuopanLocation.floor) { resolve() }else{ tuopanInishengji = newLocation === 0; let distance = newLocation - tuopanLocation.x let time1 = setInterval(() => { if ((distance > 0 && model.position.x >= newLocation) || (distance < 0 && model.position.x <= newLocation)) { model.position.x = newLocation tuopanLocation.x = newLocation resolve() clearInterval(time1) clearTimeout(time3) } else { model.position.x += distance / (time / 16) tuopanLocation.x = model.position.x } }, 16) let time3 = setTimeout(() => { resolve(0) clearInterval(time1) clearTimeout(time3) }, time + 1000) } }) } const tuopanYAnimation = (model, floor, newLocation = 0, time = 2000) => { return new Promise((resolve, reject) => { tuopanLocation.floor = floor if (!model || tuopanLocation.y === newLocation) { resolve() } let distance = newLocation - tuopanLocation.y let time1 = setInterval(() => { if ((distance > 0 && model.position.y >= newLocation) || (distance < 0 && model.position.y <= newLocation)) { model.position.y = newLocation tuopanLocation.y = newLocation resolve() clearInterval(time1) clearTimeout(time3) } else { model.position.y += distance / (time / 16) tuopanLocation.y = model.position.y } }, 16) let time3 = setTimeout(() => { resolve() clearInterval(time1) clearTimeout(time3) }, time + 1000) }) } export { tuopanInishengji, storeyHeight, storeyWidth, tishengjiAnimation, tuopanXAnimation, tuopanYAnimation, tuopanLocation }