feat: stream chunks in-game, render 3D catalog props, and ground chunk coordinates
checkpoint / checkpoint (push) Successful in 5m54s
checkpoint / checkpoint (push) Successful in 5m54s
This commit is contained in:
+14
-17
@@ -54,20 +54,16 @@ var is_dirty: bool = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
# Position this chunk scene at its world-space origin
|
||||
global_position = bounds.position
|
||||
# Set up collision shape for the chunk bounds
|
||||
_setup_collision()
|
||||
# Position this chunk scene at its 3D world ground coordinates
|
||||
global_position = Vector3(
|
||||
float(coord.x * Chunk.CHUNK_SIZE_X),
|
||||
float(coord.z * Chunk.CHUNK_SIZE_Z),
|
||||
float(coord.y * Chunk.CHUNK_SIZE_Y)
|
||||
)
|
||||
|
||||
|
||||
func _setup_collision() -> void:
|
||||
# Add a collision shape for the chunk's bounding box
|
||||
var collision := CollisionShape3D.new()
|
||||
var shape := BoxShape3D.new()
|
||||
shape.size = bounds.size
|
||||
collision.shape = shape
|
||||
collision.name = "ChunkBounds"
|
||||
add_child(collision)
|
||||
pass
|
||||
|
||||
|
||||
## Add a tile layer to this chunk scene.
|
||||
@@ -91,9 +87,10 @@ func add_object(obj: WorldObject) -> void:
|
||||
func _add_static_object(obj: WorldObject) -> void:
|
||||
var static_obj := StaticObjectNode.new()
|
||||
static_obj.world_object = obj
|
||||
static_obj.position = obj.position
|
||||
static_obj.quaternion = Quaternion(obj.rotation.x, obj.rotation.y, obj.rotation.z, obj.rotation.w)
|
||||
static_obj.scale = obj.scale
|
||||
# Map chunk coordinates (X_ground, Y_ground, Z_height) to Godot 3D (X, Y_height, Z_ground)
|
||||
static_obj.position = Vector3(obj.position.x, obj.position.z, obj.position.y)
|
||||
static_obj.quaternion = Quaternion(obj.rotation.x, obj.rotation.z, obj.rotation.y, obj.rotation.w)
|
||||
static_obj.scale = Vector3(obj.scale.x, obj.scale.z, obj.scale.y)
|
||||
static_obj.name = "static_%s" % obj.id
|
||||
add_child(static_obj)
|
||||
|
||||
@@ -101,9 +98,9 @@ func _add_static_object(obj: WorldObject) -> void:
|
||||
func _add_dynamic_object(obj: WorldObject) -> void:
|
||||
var dynamic_obj := DynamicObjectNode.new()
|
||||
dynamic_obj.world_object = obj
|
||||
dynamic_obj.position = obj.position
|
||||
dynamic_obj.quaternion = Quaternion(obj.rotation.x, obj.rotation.y, obj.rotation.z, obj.rotation.w)
|
||||
dynamic_obj.scale = obj.scale
|
||||
dynamic_obj.position = Vector3(obj.position.x, obj.position.z, obj.position.y)
|
||||
dynamic_obj.quaternion = Quaternion(obj.rotation.x, obj.rotation.z, obj.rotation.y, obj.rotation.w)
|
||||
dynamic_obj.scale = Vector3(obj.scale.x, obj.scale.z, obj.scale.y)
|
||||
dynamic_obj.name = "dynamic_%s" % obj.id
|
||||
add_child(dynamic_obj)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user