Skip to content

Instantly share code, notes, and snippets.

@thimenesup
Created April 26, 2019 17:27
Show Gist options
  • Save thimenesup/0f039e86a2e50661cb054b4f068e1f1c to your computer and use it in GitHub Desktop.
Save thimenesup/0f039e86a2e50661cb054b4f068e1f1c to your computer and use it in GitHub Desktop.
extends MeshInstance
export var lod_distance = 15
export(Array,Mesh) var meshes
func _notification(what):
if what == NOTIFICATION_VISIBILITY_CHANGED:
set_process(is_visible_in_tree())
func _process(delta):
var camera = get_viewport().get_camera()
var i = translation.distance_to(camera.translation) / lod_distance
i = int(clamp(i,0,meshes.size()-1))
mesh = meshes[i]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment