Skip to main content

Unfinished! Development in progress.

← Back to blog

Hello World!

This is a sample blog post.

4/26/2025 — 2 minutes read


Introduction

This is a sample post for testing purposes.

Test Heading

Test!

extends Node3D

signal camera_rotated(rotation: Vector3)

@onready var player_node: Node3D = self.get_parent()

var is_camera_rotating := false
var zoom := 1.0
var camera_distance := 0.2;
var camera_yaw := 0.0
var camera_pitch := 0.0

func _ready() -> void:
    pass ;
func _toggle_mouse_capture():
    if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
        Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
    else:
        Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _rotate_camera(delta: float) -> void:
    var mouse_delta := Input.get_last_mouse_velocity() * delta
    camera_yaw = self.global_rotation.y;
    camera_yaw -= mouse_delta.x * 0.01
    var rot_y := lerp_angle(self.global_rotation.y, camera_yaw, 1.1)

    camera_pitch = self.global_rotation.x;
    camera_pitch -= mouse_delta.y * 0.01
    camera_pitch = clamp(camera_pitch, -1.0, 1.0)
    var rot_x := lerp_angle(self.global_rotation.x, camera_pitch, 1.1)

    player_node.global_rotation.y = rot_y


    self.global_rotation.x = rot_x
    self.global_rotation.y = rot_y

func _input(event: InputEvent) -> void:
    if event is InputEventMouseButton:
        if event.button_index == MOUSE_BUTTON_RIGHT:
            is_camera_rotating = true
            _toggle_mouse_capture()
        if event.button_index == MOUSE_BUTTON_RIGHT and not event.pressed:
            is_camera_rotating = false


func _handle_zoom(delta: float):
    if Input.is_action_just_pressed("zoom_in"):
        camera_distance = clampf(camera_distance - 0.25, 0.1, 5.0)
    elif Input.is_action_just_pressed("zoom_out"):
        camera_distance = clampf(camera_distance + 0.25, 0.1, 5.0)

    camera_distance = clampf(camera_distance, 0.1, 5.0)

    var rot_y := camera_yaw
    var rot_x := camera_pitch

    var camera_offset := Vector3(0, 0, -camera_distance)
    camera_offset = camera_offset.rotated(Vector3.UP, rot_y)
    camera_offset = camera_offset.rotated(Vector3.RIGHT, rot_x)
    var camera_position := player_node.global_position + camera_offset
    camera_position.y = player_node.global_position.y + camera_distance * 0.5
    self.global_position = self.global_position.lerp(camera_position, delta * 4.0)

func _process(delta: float) -> void:
    _handle_zoom(delta)
    if is_camera_rotating:
        _rotate_camera(delta)

Testing Level 3

More code snippets

Testing Svelte

<script lang="ts">
	import LucideChevronUp from '~icons/lucide/chevron-up';
	import Button from '$lib/components/Button.svelte';
	const scrollYThreshold = 100;
	let scrollY = $state(0);
	let showBackToTop = $state(false);

	$effect(() => {
		showBackToTop = scrollY > scrollYThreshold;
	});
</script>

<svelte:window bind:scrollY />

{#if showBackToTop}
	<Button
		class="fixed right-6 bottom-[4.5rem] z-50 h-12 w-12 justify-center sm:right-4 sm:bottom-4"
		onclick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
		circle
		transition={{
			fn: 'fade',
			params: { duration: 100 }
		}}
		title="Back to top"
	>
		<LucideChevronUp class="h-6 w-6" />
		<span class="sr-only">Back to top</span>
	</Button>
{/if}