mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-07-03 06:51:16 +00:00
3D Cameras with sweep and animation
This commit is contained in:
parent
4cc7a0c004
commit
7e76edc153
48 changed files with 3211 additions and 1511 deletions
50
addons/tattomoosa.vision_cone_3d/src/ConeShape3D.gd
Normal file
50
addons/tattomoosa.vision_cone_3d/src/ConeShape3D.gd
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
@tool
|
||||
class_name ConeShape3D
|
||||
extends ConvexPolygonShape3D
|
||||
|
||||
## The height of the cone
|
||||
@export var height : float = 2.0:
|
||||
set(value):
|
||||
height = value
|
||||
_request_resize()
|
||||
## The radius of the bottom of the cone
|
||||
@export var radius : float = 0.5:
|
||||
set(value):
|
||||
radius = value
|
||||
_request_resize()
|
||||
## The number of radial segments of the cone
|
||||
@export var resolution : int = 8:
|
||||
set(value):
|
||||
resolution = value
|
||||
_request_resize()
|
||||
|
||||
# Resize requested
|
||||
var pending_resize := false
|
||||
|
||||
# Update size to initial state
|
||||
func _init() -> void:
|
||||
_request_resize()
|
||||
|
||||
# Will only resize once per frame, during idle time
|
||||
func _request_resize() -> void:
|
||||
if !pending_resize:
|
||||
_update_size.call_deferred()
|
||||
pending_resize = true
|
||||
|
||||
# Updates shape size
|
||||
func _update_size() -> void:
|
||||
points = _make_cone_polygon_points()
|
||||
pending_resize = false
|
||||
|
||||
# Makes a cone polygon
|
||||
@warning_ignore("return_value_discarded")
|
||||
func _make_cone_polygon_points() -> PackedVector3Array:
|
||||
var pts : PackedVector3Array = []
|
||||
var top : Vector3 = Vector3(0, height / 2, 0)
|
||||
for i in resolution:
|
||||
var angle := float(i) * TAU / resolution
|
||||
var x := cos(angle) * radius
|
||||
var y := sin(angle) * radius
|
||||
pts.push_back(Vector3(x, -height/2, y))
|
||||
pts.push_back(top)
|
||||
return pts
|
||||
Loading…
Add table
Add a link
Reference in a new issue