first examples
This commit is contained in:
parent
a01a7a7acc
commit
2219e943da
33 changed files with 785 additions and 6 deletions
29
entities/plinth/plinth.gd
Normal file
29
entities/plinth/plinth.gd
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
@tool
|
||||
extends StaticBody3D
|
||||
|
||||
@onready var exhibit_title: Label3D = $ExhibitTitle
|
||||
@onready var exhibit_number: Label3D = $ExhibitNumber
|
||||
|
||||
@export var prefix: String:
|
||||
get:
|
||||
return prefix
|
||||
set(value):
|
||||
prefix = value
|
||||
set_label3d()
|
||||
|
||||
@export var title: String:
|
||||
get:
|
||||
return title
|
||||
set(value):
|
||||
title = value
|
||||
set_label3d()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
set_label3d()
|
||||
|
||||
func set_label3d():
|
||||
if exhibit_title and exhibit_number:
|
||||
if not prefix.is_empty() and not title.is_empty():
|
||||
exhibit_title.text = title
|
||||
exhibit_number.text = prefix
|
||||
42
entities/plinth/plinth.tscn
Normal file
42
entities/plinth/plinth.tscn
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://bn6vxev7totc8"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://rtbkmc0lc26v" path="res://assets/models/kenney.nl/column.glb" id="1_4464o"]
|
||||
[ext_resource type="Script" path="res://entities/plinth/plinth.gd" id="1_c0mgr"]
|
||||
[ext_resource type="FontFile" uid="uid://d268g1dy6fv6t" path="res://assets/fonts/FrederickatheGreat-Regular.ttf" id="2_kx7w3"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_aq2yi"]
|
||||
size = Vector3(0.91626, 1.34576, 0.744141)
|
||||
|
||||
[node name="Plinth" type="StaticBody3D"]
|
||||
script = ExtResource("1_c0mgr")
|
||||
prefix = "000"
|
||||
title = "Title"
|
||||
|
||||
[node name="PlinthModel" parent="." instance=ExtResource("1_4464o")]
|
||||
transform = Transform3D(1.5, 0, 0, 0, 1, 0, 0, 0, 1.2, 0, 0, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.672333, 0)
|
||||
shape = SubResource("BoxShape3D_aq2yi")
|
||||
|
||||
[node name="ExhibitTitle" type="Label3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.965926, 0.258819, 0, -0.258819, 0.965926, 0, 1.21637, 0.378944)
|
||||
pixel_size = 0.0006
|
||||
modulate = Color(0.5475, 0.6015, 0.75, 1)
|
||||
outline_modulate = Color(0.152941, 0.176471, 0.25098, 1)
|
||||
text = "Title"
|
||||
font = ExtResource("2_kx7w3")
|
||||
font_size = 128
|
||||
autowrap_mode = 2
|
||||
width = 1200.0
|
||||
|
||||
[node name="ExhibitNumber" type="Label3D" parent="."]
|
||||
transform = Transform3D(0.777146, 0, -0.62932, 0, 1, 0, 0.62932, 0, 0.777146, -0.403741, 1.28391, 0.32542)
|
||||
pixel_size = 0.0004
|
||||
modulate = Color(0.5475, 0.6015, 0.75, 1)
|
||||
outline_modulate = Color(0.152941, 0.176471, 0.25098, 1)
|
||||
text = "000"
|
||||
font = ExtResource("2_kx7w3")
|
||||
font_size = 128
|
||||
autowrap_mode = 2
|
||||
width = 1200.0
|
||||
52
entities/viewer/viewer.gd
Normal file
52
entities/viewer/viewer.gd
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
@export var rotation_speed: float = 0.002
|
||||
|
||||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if Input.is_action_pressed("ui_cancel"):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
if event is InputEventMouseButton and event.button_index == 1 and event.is_pressed():
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
handle_motion(event)
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# Add the gravity.
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
var input_dir := Input.get_vector("left", "right", "front", "back")
|
||||
var direction := (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func handle_motion(event: InputEventMouseMotion) -> void:
|
||||
if not Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
|
||||
return
|
||||
|
||||
$Camera3D.rotation.x -= event.relative.y * rotation_speed
|
||||
$Camera3D.rotation.x = clamp($Camera3D.rotation.x, deg_to_rad(-89), deg_to_rad(89))
|
||||
rotation.y -= event.relative.x * rotation_speed
|
||||
17
entities/viewer/viewer.tscn
Normal file
17
entities/viewer/viewer.tscn
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dcv8xw0aeturp"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/viewer/viewer.gd" id="1_8hs0o"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_bf5le"]
|
||||
height = 1.7
|
||||
|
||||
[node name="Viewer" type="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5)
|
||||
script = ExtResource("1_8hs0o")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.7, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.85, 0)
|
||||
shape = SubResource("CapsuleShape3D_bf5le")
|
||||
Loading…
Add table
Add a link
Reference in a new issue