chunk.gd 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. extends Spatial
  2. # Declare member variables here. Examples:
  3. # var a = 2
  4. # var b = "text"
  5. var latMin:float = 0
  6. var latMax:float = 1
  7. var lonMin:float = 0.0
  8. var lonMax:float = 1.0
  9. var resolution:int = 512
  10. var radius:float = 10
  11. var scaleFact:int = 1
  12. var origin:Vector3
  13. var center:Vector3
  14. func setParams(latMinIN, latMaxIN, lonMinIN, lonMaxIN, resolutionIN, radiusIN:float, scaleFactIN):
  15. latMin = latMinIN
  16. latMax = latMaxIN
  17. lonMin = lonMinIN
  18. lonMax = lonMaxIN
  19. resolution = resolutionIN
  20. radius = radiusIN
  21. scaleFact = scaleFactIN
  22. # Called when the node enters the scene tree for the first time.
  23. func _ready():
  24. print("chunk %s,%s initializing" %[latMin, lonMin])
  25. var initialized = .get_node("Mesh").initialize(latMin, latMax, lonMin, lonMax, resolution, radius, scaleFact)
  26. if not initialized:
  27. var download = Downloader.Download.new()
  28. while not download._file_name == .get_node("Mesh").tl.getFilepath():
  29. print("awaiting file download for %s" %.get_node("Mesh").tl.getFilepath())
  30. download = yield(Messenger, "fileDownloaded")
  31. print(download)
  32. .get_node("Mesh").genMesh()
  33. .get_node("Origin").transform.origin = .get_node("Mesh").origin
  34. .get_node("Center").transform.origin = .get_node("Mesh").center
  35. print("chunk %s,%s ready" %[latMin, lonMin])
  36. #.translate(.get_node("Mesh").origin)
  37. # Called every frame. 'delta' is the elapsed time since the previous frame.
  38. #func _process(delta):
  39. # pass