CustomImageService.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import VectorType from '../enum/VectorType.js'
  2. import CustomImage from '../Geometry/CustomImage.js'
  3. import { mathUtil } from '../MathUtil.js'
  4. import { floorplanService } from './FloorplanService'
  5. import Constant from '../Constant'
  6. export default class CustomImageService {
  7. constructor() {
  8. this.url = null;
  9. }
  10. setCustomImageUrl(url){
  11. this.url = url;
  12. }
  13. async createCustomImage(center,vectorId) {
  14. const customImage = new CustomImage(this.url, center,vectorId)
  15. if(this.url){
  16. const imageData = await floorplanService.loadImageData(this.url)
  17. customImage.setImageData(imageData)
  18. customImage.width = imageData.width;
  19. customImage.height = imageData.height;
  20. }
  21. floorplanService.addCustomImage(customImage)
  22. this.url = null;
  23. return customImage
  24. }
  25. deleteCustomImage(customImageId, floorNum) {
  26. floorplanService.deleteCustomImage(customImageId, floorNum)
  27. }
  28. }
  29. const customImageService = new CustomImageService()
  30. export { customImageService }