TextureLoader.gd 700 B

12345678910111213141516171819202122232425262728293031
  1. extends Reference
  2. var filePrexif = "user://colorTiles"
  3. # Called when the node enters the scene tree for the first time.
  4. func _ready():
  5. pass # Replace with function body.
  6. func loadTexture(lat, lon):
  7. lat =int(lat)
  8. lon = int(lon)
  9. var texName = getTexName(lat, lon)
  10. print(texName)
  11. var image = Image.new()
  12. var err = image.load(texName)
  13. if err != OK:
  14. print("error opening tex ", err)
  15. var tex = ImageTexture.new()
  16. tex.create_from_image(image, 0)
  17. return tex
  18. func getTexName(lat, lon):
  19. return "%s/m-%s-%s.png" % [filePrexif, (lat+90)%180, (lon+180)%360]
  20. #return "user://grid.png"
  21. # Called every frame. 'delta' is the elapsed time since the previous frame.
  22. #func _process(delta):
  23. # pass