TextureLoader.gd 703 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. var texName = getTexName(lat, lon)
  8. print("opening texture "+texName)
  9. var image = Image.new()
  10. var err = image.load(texName)
  11. if err != OK:
  12. print("error opening tex ", err)
  13. var tex = ImageTexture.new()
  14. tex.create_from_image(image, 0)
  15. return tex
  16. func getTexName(lat, lon):
  17. return "%s/m-%s-%s.png" % [filePrexif, (int(lat)+90)%180, (int(lon)+180)%360]
  18. #return "res://tex/grid.png"
  19. # Called every frame. 'delta' is the elapsed time since the previous frame.
  20. #func _process(delta):
  21. # pass