.. role:: ts-api-decorator

####
Vec3
####

.. js:module:: cee
   :noindex:

.. container:: ts-api-section

   .. js:class:: Vec3

      An immutable 3d vector with x, y and z values. 

      Used for positions, normals and other 3d entities.



.. container:: api-index-section

   .. rubric:: Constructors

   .. rst-class:: api-index-list-item api-kind-constructor api-parent-kind-class

   * :js:meth:`~cee.Vec3.constructor`



.. container:: api-index-section

   .. rubric:: Properties

   .. rst-class:: api-index-list-item api-kind-property api-parent-kind-class

   * :js:attr:`~cee.Vec3.x`
   * :js:attr:`~cee.Vec3.y`
   * :js:attr:`~cee.Vec3.z`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.Vec3.equals`
   * :js:meth:`~cee.Vec3.getLength`
   * :js:meth:`~cee.Vec3.getLengthSquared`
   * :js:meth:`~cee.Vec3.getNegated`
   * :js:meth:`~cee.Vec3.getNormalized`
   * :js:meth:`~cee.Vec3.getPointDistance`
   * :js:meth:`~cee.Vec3.getPointDistanceSquared`
   * :js:meth:`~cee.Vec3.add`
   * :js:meth:`~cee.Vec3.cross`
   * :js:meth:`~cee.Vec3.dot`
   * :js:meth:`~cee.Vec3.from`
   * :js:meth:`~cee.Vec3.fromArray`
   * :js:meth:`~cee.Vec3.negate`
   * :js:meth:`~cee.Vec3.scale`
   * :js:meth:`~cee.Vec3.sub`
   * :js:meth:`~cee.Vec3.transformPoint`
   * :js:meth:`~cee.Vec3.transformVector`





------------

Constructors
============

.. container:: ts-api-section

   .. js:function:: Vec3.constructor( x, y, z)

      :param x: None
      :type x: number
      :param y: None
      :type y: number
      :param z: None
      :type z: number


      Constructor


      :rtype: Vec3



Properties
==========

.. container:: ts-api-section

   .. js:attribute:: Vec3.x

      :type: number

      The x coordinate of the vector



.. container:: ts-api-section

   .. js:attribute:: Vec3.y

      :type: number

      The y coordinate of the vector



.. container:: ts-api-section

   .. js:attribute:: Vec3.z

      :type: number

      The z coordinate of the vector



Methods
=======

.. rst-class:: ts-api-section

equals
------

.. js:method:: Vec3.equals( other)

   :param other: None
   :type other: Vec3Like


   Returns true if the vectors are equal


   :rtype: boolean

.. rst-class:: ts-api-section

getLength
---------

.. js:method:: Vec3.getLength()



   Returns the length of the vector (sqrt(x^2 + y^2 + z^2)).


   :rtype: number

.. rst-class:: ts-api-section

getLengthSquared
----------------

.. js:method:: Vec3.getLengthSquared()



   Returns the squared length of the vector


   :rtype: number

.. rst-class:: ts-api-section

getNegated
----------

.. js:method:: Vec3.getNegated()



   Returns a negated version of the vector.


   :rtype: Vec3

.. rst-class:: ts-api-section

getNormalized
-------------

.. js:method:: Vec3.getNormalized()



   Returns a normalized version of the vector.


   :rtype: Vec3

.. rst-class:: ts-api-section

getPointDistance
----------------

.. js:method:: Vec3.getPointDistance( otherPoint)

   :param otherPoint: None
   :type otherPoint: Vec3


   Returns the distance between this point and otherPoint


   :rtype: number

.. rst-class:: ts-api-section

getPointDistanceSquared
-----------------------

.. js:method:: Vec3.getPointDistanceSquared( otherPoint)

   :param otherPoint: None
   :type otherPoint: Vec3Like


   Returns the squared distance between this point and otherPoint


   :rtype: number

.. rst-class:: ts-api-section

:ts-api-decorator:`static` add
------------------------------

.. js:method:: Vec3.add( a, b)

   :param a: None
   :type a: Vec3Like
   :param b: None
   :type b: Vec3Like


   Returns the result of adding the two vectors


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` cross
--------------------------------

.. js:method:: Vec3.cross( a, b)

   :param a: None
   :type a: Vec3Like
   :param b: None
   :type b: Vec3Like


   Returns the cross product of the 2 vectors


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` dot
------------------------------

.. js:method:: Vec3.dot( a, b)

   :param a: None
   :type a: Vec3Like
   :param b: None
   :type b: Vec3Like


   Returns the dot product of the 2 vectors


   :rtype: number

.. rst-class:: ts-api-section

:ts-api-decorator:`static` from
-------------------------------

.. js:method:: Vec3.from( vec)

   :param vec: None
   :type vec: Vec3Like


   Creates a new Vec3 instance from any object with x, y and z properties.


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` fromArray
------------------------------------

.. js:method:: Vec3.fromArray( arr)

   :param arr: None
   :type arr: ArrayLike <number>


   Creates a new Vec3 instance from the first 3 elements of the given array.


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` negate
---------------------------------

.. js:method:: Vec3.negate( vec)

   :param vec: None
   :type vec: Vec3Like


   Returns the negation of the given vector


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` scale
--------------------------------

.. js:method:: Vec3.scale( vec, factor)

   :param vec: None
   :type vec: Vec3Like
   :param factor: None
   :type factor: number


   Returns the result of scaling the given vector by the given factor


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` sub
------------------------------

.. js:method:: Vec3.sub( a, b)

   :param a: None
   :type a: Vec3Like
   :param b: None
   :type b: Vec3Like


   Returns the result of subtracting vector b from vector a


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` transformPoint
-----------------------------------------

.. js:method:: Vec3.transformPoint( p, matrix)

   :param p: None
   :type p: Vec3Like
   :param matrix: None
   :type matrix: Mat4


   Returns a new vector with the given vector transforms as a point.

   Transforms the vector as a point by multiplying it with the given matrix.
   This will both rotate and translate the vector p.
   Assumes the matrix m doesn't contain any perspective projection.


   :rtype: Vec3

.. rst-class:: ts-api-section

:ts-api-decorator:`static` transformVector
------------------------------------------

.. js:method:: Vec3.transformVector( p, matrix)

   :param p: None
   :type p: Vec3Like
   :param matrix: None
   :type matrix: Mat4


   Returns a new vector with the given vector transforms as a vector.

   Transforms the vector as a vector by multiplying it with the given matrix. 
   This will only rotate the vector. The translation part of the matrix will be ignored.
   Assumes the matrix m doesn't contain any perspective projection.


   :rtype: Vec3

