chunk.gd 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. var initialized = false
  15. func setParams(latMinIN, latMaxIN, lonMinIN, lonMaxIN, resolutionIN, radiusIN:float, scaleFactIN):
  16. latMin = latMinIN
  17. latMax = latMaxIN
  18. lonMin = lonMinIN
  19. lonMax = lonMaxIN
  20. resolution = resolutionIN
  21. radius = radiusIN
  22. scaleFact = scaleFactIN
  23. # Called when the node enters the scene tree for the first time.
  24. func _ready():
  25. initialize()
  26. #.translate(.get_node("Mesh").origin)
  27. func initialize():
  28. print("chunk %s,%s initializing" %[latMin, lonMin])
  29. var initialized = .get_node("Mesh").initialize(latMin, latMax, lonMin, lonMax, resolution, radius, scaleFact)
  30. if not initialized:
  31. var download = Downloader.Download.new()
  32. while not download._file_name == .get_node("Mesh").tl.getFilepath():
  33. print("awaiting file download for %s" %.get_node("Mesh").tl.getFilepath())
  34. download = yield(Messenger, "fileDownloaded")
  35. var texInitialized = .get_node("Mesh").initTexture()
  36. if not texInitialized:
  37. var dl = Downloader.Download.new()
  38. while not dl._file_name == .get_node("Mesh").texl.getTexName():
  39. print("awaiting file download for %s" %.get_node("Mesh").texl.getTexName())
  40. dl = yield(Messenger, "fileDownloaded")
  41. .get_node("Mesh").genMesh()
  42. .get_node("Origin").transform.origin = .get_node("Mesh").origin
  43. .get_node("Center").transform.origin = .get_node("Mesh").center
  44. print("chunk %s,%s ready" %[latMin, lonMin])
  45. # Called every frame. 'delta' is the elapsed time since the previous frame.
  46. #func _process(delta):
  47. # pass