mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 16:00:08 +01:00
Update several 3D demos to Godot 4
This commit is contained in:
@@ -18,7 +18,7 @@ func _input(event):
|
||||
rot.y -= event.relative.x * MOUSE_SENSITIVITY
|
||||
# Vertical mouse look.
|
||||
rot.x = clamp(rot.x - event.relative.y * MOUSE_SENSITIVITY, -1.57, 1.57)
|
||||
transform.basis = Basis(rot)
|
||||
transform.basis = Basis.from_euler(rot)
|
||||
|
||||
if event.is_action_pressed("toggle_mouse_capture"):
|
||||
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cepadwp0eni7g"
|
||||
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,26 +11,23 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
|
||||
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
process/hdr_as_srgb=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
||||
@@ -1,139 +1,128 @@
|
||||
[gd_scene load_steps=17 format=2]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://rj7yrj3c672g"]
|
||||
|
||||
[ext_resource path="res://camera.gd" type="Script" id=1]
|
||||
[ext_resource path="res://waypoint.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://noto_sans_regular.ttf" type="FontData" id=3]
|
||||
[ext_resource type="Script" path="res://camera.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://deqpan4silm2n" path="res://waypoint.tscn" id="2"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id=1]
|
||||
albedo_color = Color(0.6, 0.564706, 0.423529, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id=2]
|
||||
material = SubResource( 1 )
|
||||
size = Vector3(16, 2, 16)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id=3]
|
||||
albedo_color = Color(0.788235, 0.788235, 0.788235, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id=4]
|
||||
material = SubResource( 3 )
|
||||
size = Vector3(4, 1.5, 4)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id=5]
|
||||
[sub_resource type="StandardMaterial3D" id="5"]
|
||||
albedo_color = Color(0.25098, 0.470588, 0.996078, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id=6]
|
||||
material = SubResource( 5 )
|
||||
size = Vector3(1, 1, 1)
|
||||
[sub_resource type="BoxMesh" id="6"]
|
||||
material = SubResource( "5" )
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id=7]
|
||||
[sub_resource type="StandardMaterial3D" id="7"]
|
||||
albedo_color = Color(0.435294, 0.917647, 0.380392, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id=8]
|
||||
material = SubResource( 7 )
|
||||
size = Vector3(1, 1, 1)
|
||||
[sub_resource type="BoxMesh" id="8"]
|
||||
material = SubResource( "7" )
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id=9]
|
||||
[sub_resource type="StandardMaterial3D" id="9"]
|
||||
albedo_color = Color(0.862745, 0.764706, 0.12549, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id=10]
|
||||
material = SubResource( 9 )
|
||||
size = Vector3(1, 1, 1)
|
||||
[sub_resource type="BoxMesh" id="10"]
|
||||
material = SubResource( "9" )
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id=11]
|
||||
[sub_resource type="StandardMaterial3D" id="11"]
|
||||
albedo_color = Color(0.996078, 0.266667, 0.25098, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id=12]
|
||||
material = SubResource( 11 )
|
||||
size = Vector3(1, 1, 1)
|
||||
[sub_resource type="BoxMesh" id="12"]
|
||||
material = SubResource( "11" )
|
||||
|
||||
[sub_resource type="Font" id=13]
|
||||
font_data = ExtResource( 3 )
|
||||
[sub_resource type="StandardMaterial3D" id="1"]
|
||||
albedo_color = Color(0.6, 0.564706, 0.423529, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id="2"]
|
||||
material = SubResource( "1" )
|
||||
size = Vector3(16, 2, 16)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="3"]
|
||||
albedo_color = Color(0.788235, 0.788235, 0.788235, 1)
|
||||
|
||||
[sub_resource type="BoxMesh" id="4"]
|
||||
material = SubResource( "3" )
|
||||
size = Vector3(4, 1.5, 4)
|
||||
|
||||
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_1hqbf"]
|
||||
sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
||||
ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1)
|
||||
|
||||
[sub_resource type="Sky" id="Sky_47fsp"]
|
||||
sky_material = SubResource( "ProceduralSkyMaterial_1hqbf" )
|
||||
|
||||
[sub_resource type="Environment" id="Environment_ob0ys"]
|
||||
background_mode = 2
|
||||
sky = SubResource( "Sky_47fsp" )
|
||||
tonemap_mode = 2
|
||||
glow_enabled = true
|
||||
|
||||
[node name="Main" type="Node3D"]
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 8)
|
||||
fov = 75.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Ground" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.5, 0)
|
||||
mesh = SubResource( 2 )
|
||||
surface_material_override/0 = null
|
||||
|
||||
[node name="WhiteCube" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource( 4 )
|
||||
surface_material_override/0 = null
|
||||
|
||||
[node name="BlueCube" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0, -5)
|
||||
mesh = SubResource( 6 )
|
||||
surface_material_override/0 = null
|
||||
mesh = SubResource( "6" )
|
||||
|
||||
[node name="WaypointAnchor" type="Position3D" parent="BlueCube"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
||||
[node name="Waypoint" parent="BlueCube/WaypointAnchor" instance=ExtResource( 2 )]
|
||||
[node name="Waypoint" parent="BlueCube/WaypointAnchor" instance=ExtResource( "2" )]
|
||||
modulate = Color(0.501961, 0.764706, 1, 1)
|
||||
text = "Blue Waypoint"
|
||||
|
||||
[node name="GreenCube" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 0, 5)
|
||||
mesh = SubResource( 8 )
|
||||
surface_material_override/0 = null
|
||||
mesh = SubResource( "8" )
|
||||
|
||||
[node name="WaypointAnchor" type="Position3D" parent="GreenCube"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
||||
[node name="Waypoint" parent="GreenCube/WaypointAnchor" instance=ExtResource( 2 )]
|
||||
[node name="Waypoint" parent="GreenCube/WaypointAnchor" instance=ExtResource( "2" )]
|
||||
modulate = Color(0.419608, 1, 0.427451, 1)
|
||||
text = "Green Waypoint"
|
||||
|
||||
[node name="YellowCube" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 0, 5)
|
||||
mesh = SubResource( 10 )
|
||||
surface_material_override/0 = null
|
||||
mesh = SubResource( "10" )
|
||||
|
||||
[node name="WaypointAnchor" type="Position3D" parent="YellowCube"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
||||
[node name="Waypoint" parent="YellowCube/WaypointAnchor" instance=ExtResource( 2 )]
|
||||
[node name="Waypoint" parent="YellowCube/WaypointAnchor" instance=ExtResource( "2" )]
|
||||
modulate = Color(1, 0.992157, 0.419608, 1)
|
||||
text = "Yellow Waypoint (non-sticky)"
|
||||
sticky = false
|
||||
|
||||
[node name="RedCube" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5, 0, -5)
|
||||
mesh = SubResource( 12 )
|
||||
surface_material_override/0 = null
|
||||
mesh = SubResource( "12" )
|
||||
|
||||
[node name="WaypointAnchor" type="Position3D" parent="RedCube"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||
|
||||
[node name="Waypoint" parent="RedCube/WaypointAnchor" instance=ExtResource( 2 )]
|
||||
[node name="Waypoint" parent="RedCube/WaypointAnchor" instance=ExtResource( "2" )]
|
||||
modulate = Color(1, 0.466667, 0.427451, 1)
|
||||
text = "Red Waypoint"
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(-0.642788, -0.383022, 0.663414, 0, 0.866025, 0.5, -0.766044, 0.321394, -0.556671, 0, 6, -9)
|
||||
light_energy = 0.9
|
||||
shadow_enabled = true
|
||||
shadow_bias = 0.06
|
||||
directional_shadow_blend_splits = true
|
||||
directional_shadow_normal_bias = 0.0
|
||||
directional_shadow_bias_split_scale = 0.7
|
||||
directional_shadow_max_distance = 60.0
|
||||
[node name="Camera3D" type="Camera3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 8)
|
||||
script = ExtResource( "1" )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_left = 10.0
|
||||
offset_top = 10.0
|
||||
offset_right = 50.0
|
||||
offset_bottom = 24.0
|
||||
custom_colors/font_color_shadow = Color(0, 0, 0, 0.501961)
|
||||
custom_constants/shadow_offset_x = 1
|
||||
custom_constants/shadow_offset_y = 1
|
||||
custom_fonts/font = SubResource( 13 )
|
||||
offset_right = 325.0
|
||||
offset_bottom = 36.0
|
||||
text = "Press Esc or F10 to toggle mouse capture"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Ground" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.5, 0)
|
||||
mesh = SubResource( "2" )
|
||||
|
||||
[node name="WhiteCube" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource( "4" )
|
||||
|
||||
[node name="Environment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource( "Environment_ob0ys" )
|
||||
|
||||
[node name="Sun" type="DirectionalLight3D" parent="Environment"]
|
||||
transform = Transform3D(-0.866025, -0.433013, 0.25, 0, 0.5, 0.866026, -0.5, 0.75, -0.433013, 0, 0, 0)
|
||||
shadow_enabled = true
|
||||
directional_shadow_max_distance = 250.0
|
||||
|
||||
33
3d/waypoints/noto_sans_regular.ttf.import
Normal file
33
3d/waypoints/noto_sans_regular.ttf.import
Normal file
@@ -0,0 +1,33 @@
|
||||
[remap]
|
||||
|
||||
importer="font_data_dynamic"
|
||||
type="FontData"
|
||||
uid="uid://bvthc4p0nqt1r"
|
||||
path="res://.godot/imported/noto_sans_regular.ttf-e8bec33260ad1aa067149f43e3e4ab21.fontdata"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://noto_sans_regular.ttf"
|
||||
dest_files=["res://.godot/imported/noto_sans_regular.ttf-e8bec33260ad1aa067149f43e3e4ab21.fontdata"]
|
||||
|
||||
[params]
|
||||
|
||||
antialiased=true
|
||||
multichannel_signed_distance_field=false
|
||||
msdf_pixel_range=8
|
||||
msdf_size=48
|
||||
force_autohinter=false
|
||||
hinting=1
|
||||
subpixel_positioning=1
|
||||
embolden=0.0
|
||||
transform=Transform2D(1, 0, 0, 1, 0, 0)
|
||||
oversampling=0.0
|
||||
compress=true
|
||||
opentype_feature_overrides={}
|
||||
preload/char_ranges=PackedStringArray()
|
||||
preload/glyph_ranges=PackedStringArray()
|
||||
preload/configurations=PackedStringArray()
|
||||
support_overrides/language_enabled=PackedStringArray()
|
||||
support_overrides/language_disabled=PackedStringArray()
|
||||
support_overrides/script_enabled=PackedStringArray()
|
||||
support_overrides/script_disabled=PackedStringArray()
|
||||
@@ -6,7 +6,7 @@
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
@@ -14,6 +14,7 @@ config/name="3D Waypoints"
|
||||
config/description="This is an example of displaying GUI elements such as Labels in a 3D world, without relying on viewports. This results in better readability and performance for use cases such as showing player names."
|
||||
run/main_scene="res://main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/features=PackedStringArray("4.0")
|
||||
|
||||
[display]
|
||||
|
||||
|
||||
@@ -11,8 +11,10 @@ const MARGIN = 8
|
||||
# The waypoint's text.
|
||||
@export var text = "Waypoint":
|
||||
set(value):
|
||||
# TODO: Manually copy the code from this method.
|
||||
set_text(value)
|
||||
text = value
|
||||
# The label's text can only be set once the node is ready.
|
||||
if is_inside_tree():
|
||||
label.text = value
|
||||
|
||||
# If `true`, the waypoint sticks to the viewport's edges when moving off-screen.
|
||||
@export var sticky = true
|
||||
@@ -45,7 +47,7 @@ func _process(_delta):
|
||||
# `get_size_override()` will return a valid size only if the stretch mode is `2d`.
|
||||
# Otherwise, the viewport size is used directly.
|
||||
var viewport_base_size = (
|
||||
get_viewport().get_size_override() if get_viewport().get_size_override() > Vector2(0, 0)
|
||||
get_viewport().content_scale_size if get_viewport().content_scale_size > Vector2i(0, 0)
|
||||
else get_viewport().size
|
||||
)
|
||||
|
||||
@@ -83,38 +85,30 @@ func _process(_delta):
|
||||
)
|
||||
|
||||
label.visible = true
|
||||
rect_rotation = 0
|
||||
rotation = 0
|
||||
# Used to display a diagonal arrow when the waypoint is displayed in
|
||||
# one of the screen corners.
|
||||
var overflow = 0
|
||||
|
||||
if position.x <= MARGIN:
|
||||
# Left overflow.
|
||||
overflow = -45
|
||||
overflow = -TAU / 8.0
|
||||
label.visible = false
|
||||
rect_rotation = 90
|
||||
rotation = TAU / 4.0
|
||||
elif position.x >= viewport_base_size.x - MARGIN:
|
||||
# Right overflow.
|
||||
overflow = 45
|
||||
overflow = TAU / 8.0
|
||||
label.visible = false
|
||||
rect_rotation = 270
|
||||
rotation = TAU * 3.0 / 4.0
|
||||
|
||||
if position.y <= MARGIN:
|
||||
# Top overflow.
|
||||
label.visible = false
|
||||
rect_rotation = 180 + overflow
|
||||
rotation = TAU / 2.0 + overflow
|
||||
elif position.y >= viewport_base_size.y - MARGIN:
|
||||
# Bottom overflow.
|
||||
label.visible = false
|
||||
rect_rotation = -overflow
|
||||
|
||||
|
||||
func set_text(p_text):
|
||||
text = p_text
|
||||
|
||||
# The label's text can only be set once the node is ready.
|
||||
if is_inside_tree():
|
||||
label.text = p_text
|
||||
rotation = -overflow
|
||||
|
||||
|
||||
static func angle_diff(from, to):
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture2D"
|
||||
path="res://.godot/imported/waypoint.svg-de0ee5a99654d0ef48e907a9ea3ae741.stex"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cgow8dqpnhb4h"
|
||||
path="res://.godot/imported/waypoint.svg-de0ee5a99654d0ef48e907a9ea3ae741.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
@@ -10,26 +11,24 @@ metadata={
|
||||
[deps]
|
||||
|
||||
source_file="res://waypoint.svg"
|
||||
dest_files=["res://.godot/imported/waypoint.svg-de0ee5a99654d0ef48e907a9ea3ae741.stex"]
|
||||
dest_files=["res://.godot/imported/waypoint.svg-de0ee5a99654d0ef48e907a9ea3ae741.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/hdr_compression=1
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=true
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
process/hdr_as_srgb=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
|
||||
@@ -1,29 +1,19 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://deqpan4silm2n"]
|
||||
|
||||
[ext_resource path="res://waypoint.gd" type="Script" id=1]
|
||||
[ext_resource path="res://waypoint.svg" type="Texture2D" id=2]
|
||||
[ext_resource path="res://noto_sans_regular.ttf" type="FontData" id=3]
|
||||
|
||||
[sub_resource type="Font" id=1]
|
||||
font_data = ExtResource( 3 )
|
||||
[ext_resource type="Script" path="res://waypoint.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://cgow8dqpnhb4h" path="res://waypoint.svg" id="2"]
|
||||
|
||||
[node name="Waypoint" type="Control"]
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
script = ExtResource( "1" )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_left = -200.0
|
||||
offset_top = -40.0
|
||||
offset_right = 200.0
|
||||
offset_bottom = -17.0
|
||||
custom_colors/font_color_shadow = Color(0, 0, 0, 0.501961)
|
||||
custom_constants/shadow_offset_x = 1
|
||||
custom_constants/shadow_offset_y = 1
|
||||
custom_fonts/font = SubResource( 1 )
|
||||
text = "Waypoint"
|
||||
align = 1
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
@@ -31,11 +21,12 @@ __meta__ = {
|
||||
[node name="Marker" type="TextureRect" parent="."]
|
||||
offset_left = -8.0
|
||||
offset_top = -16.0
|
||||
offset_right = 120.0
|
||||
offset_bottom = 112.0
|
||||
rect_scale = Vector2(0.125, 0.125)
|
||||
texture = ExtResource( 2 )
|
||||
offset_right = 8.0
|
||||
texture = ExtResource( "2" )
|
||||
ignore_texture_size = true
|
||||
__meta__ = {
|
||||
"_edit_layout_mode": 0,
|
||||
"_edit_use_anchors_": false,
|
||||
"_edit_use_custom_anchors": false,
|
||||
"_editor_description_": "An high-resolution texture is used and scaled down so the demo looks good at higher resolutions."
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user