TextureLoader.gd 710 B

123456789101112131415161718192021222324252627282930313233
  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+180)%360
  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