Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

PackedVector3Array

A packed array of Vector3s.

Description

An array specifically designed to hold Vector3. Packs data tightly, so it saves memory for large array sizes.

Note

There are notable differences when using this API with C#. See C# API differences to GDScript for more information.

Constructors

PackedVector3Array

PackedVector3Array ( )

PackedVector3Array

PackedVector3Array ( PackedVector3Array from )

PackedVector3Array

PackedVector3Array ( Array from )

Methods

bool

append ( Vector3 value )

void

append_array ( PackedVector3Array array )

int

bsearch ( Vector3 value, bool before=true )

void

clear ( )

int

count ( Vector3 value ) const

PackedVector3Array

duplicate ( )

void

fill ( Vector3 value )

int

find ( Vector3 value, int from=0 ) const

bool

has ( Vector3 value ) const

int

insert ( int at_index, Vector3 value )

bool

is_empty ( ) const

bool

push_back ( Vector3 value )

void

remove_at ( int index )

int

resize ( int new_size )

void

reverse ( )

int

rfind ( Vector3 value, int from=-1 ) const

void

set ( int index, Vector3 value )

int

size ( ) const

PackedVector3Array

slice ( int begin, int end=2147483647 ) const

void

sort ( )

PackedByteArray

to_byte_array ( ) const

Operators

bool

operator != ( PackedVector3Array right )

PackedVector3Array

operator * ( Transform3D right )

PackedVector3Array

operator + ( PackedVector3Array right )

bool

operator == ( PackedVector3Array right )

Vector3

operator [] ( int index )


Constructor Descriptions

PackedVector3Array PackedVector3Array ( )

Constructs an empty PackedVector3Array.


PackedVector3Array PackedVector3Array ( PackedVector3Array from )

Constructs a PackedVector3Array as a copy of the given PackedVector3Array.


PackedVector3Array PackedVector3Array ( Array from )

Constructs a new PackedVector3Array. Optionally, you can pass in a generic Array that will be converted.

Note: When initializing a PackedVector3Array with elements, it must be initialized with an Array of Vector3 values:

var array = PackedVector3Array([Vector3(12, 34, 56), Vector3(78, 90, 12)])

Method Descriptions

bool append ( Vector3 value )

Appends an element at the end of the array (alias of push_back).


void append_array ( PackedVector3Array array )

Appends a PackedVector3Array at the end of this array.


int bsearch ( Vector3 value, bool before=true )

Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a before specifier can be passed. If false, the returned index comes after all existing entries of the value in the array.

Note: Calling bsearch on an unsorted array results in unexpected behavior.

Note: Vectors with @GDScript.NAN elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.


void clear ( )

Clears the array. This is equivalent to using resize with a size of 0.


int count ( Vector3 value ) const

Returns the number of times an element is in the array.

Note: Vectors with @GDScript.NAN elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.


PackedVector3Array duplicate ( )

Creates a copy of the array, and returns it.


void fill ( Vector3 value )

Assigns the given value to all elements in the array. This can typically be used together with resize to create an array with a given size and initialized elements.


int find ( Vector3 value, int from=0 ) const

Searches the array for a value and returns its index or -1 if not found. Optionally, the initial search index can be passed.

Note: Vectors with @GDScript.NAN elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.


bool has ( Vector3 value ) const

Returns true if the array contains value.

Note: Vectors with @GDScript.NAN elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.


int insert ( int at_index, Vector3 value )

Inserts a new element at a given position in the array. The position must be valid, or at the end of the array (idx == size()).


bool is_empty ( ) const

Returns true if the array is empty.


bool push_back ( Vector3 value )

Inserts a Vector3 at the end.


void remove_at ( int index )

Removes an element from the array by index.


int resize ( int new_size )

Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling resize once and assigning the new values is faster than adding new elements one by one.


void reverse ( )

Reverses the order of the elements in the array.


int rfind ( Vector3 value, int from=-1 ) const

Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array.

Note: Vectors with @GDScript.NAN elements don't behave the same as other vectors. Therefore, the results from this method may not be accurate if NaNs are included.