Ocean
JSVector3.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_INTERACTION_JS_VECTOR_3_H
9 #define META_OCEAN_INTERACTION_JS_VECTOR_3_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Interaction
18 {
19 
20 namespace JavaScript
21 {
22 
23 /**
24  * This class implements a wrapper for a JavaScript Vector3 object.
25  * @ingroup interactionjs
26  */
27 class OCEAN_INTERACTION_JS_EXPORT JSVector3 : public JSObject<JSVector3, Vector3>
28 {
29  friend class JSObject<JSVector3, Vector3>;
30  friend class JSLibrary;
31 
32  public:
33 
34  /**
35  * Definition of ids for individual accessors.
36  */
37  enum AccessorId : unsigned int
38  {
39  /// The accessor for the x property, a number value.
41  /// The accessor for the y property, a number value.
43  /// The accessor for the z property, a number value.
44  AI_Z
45  };
46 
47  /**
48  * Definition of ids for individual functions.
49  */
50  enum FunctionId : unsigned int
51  {
52  /**
53  * Adds two vectors or adds a scalar value to this vector.
54  * <pre>
55  * Vector3 = Vector3.add(Vector3)
56  * Vector3 = Vector3.add(Number)
57  * </pre>
58  */
60 
61  /**
62  * Determines the angle between two vectors in radian.
63  * <pre>
64  * Number = Vector3.angle(Vector3)
65  * </pre>
66  */
68 
69  /**
70  * Determines the cross product between two vectors.
71  * <pre>
72  * Vector3 = Vector3.cross(Vector3)
73  * </pre>
74  */
76 
77  /**
78  * Inverts this vector.
79  * <pre>
80  * Vector3.invert()
81  * </pre>
82  */
84 
85  /**
86  * Returns the inverted vector of this vector.
87  * <pre>
88  * Vector3 = Vector3.inverted()
89  * </pre>
90  */
92 
93  /**
94  * Returns whether two vectors are equal up to some epsilon.
95  * <pre>
96  * Boolean = Vector3.isEqual(Vector3)
97  * </pre>
98  */
100 
101  /**
102  * Returns the length of this vector.
103  * <pre>
104  * Number = Vector3.length()
105  * </pre>
106  */
108 
109  /**
110  * Returns the distance between this vector and another vector.
111  * <pre>
112  * Number = Vector3.distance(Vector3)
113  * </pre>
114  */
116 
117  /**
118  * Multiplies two vectors to determine the scalar product or multiplies this vector with a scalar.
119  * <pre>
120  * Number = Vector3.multiply(Vector3)
121  * Vector3 = Vector3.multiply(Number)
122  * </pre>
123  */
125 
126  /**
127  * Normalizes this vector so that the vector has unit length afterwards.
128  * <pre>
129  * Vector3.normalize()
130  * </pre>
131  */
133 
134  /**
135  * Returns the normalized vector of this vector, so that the new vector has unit length.
136  * <pre>
137  * Vector3 = Vector3.normalized()
138  * </pre>
139  */
141 
142  /**
143  * Returns a string with the values of this vector.
144  * <pre>
145  * String = Vector3.string()
146  * </pre>
147  */
149 
150  /**
151  * Subtracts two vectors or subtracts a scalar value from this vector.
152  * <pre>
153  * Vector3 = Vector3.subtract(Vector3)
154  * Vector3 = Veccto3.subtract(Number)
155  * </pre>
156  */
157  FI_SUBTRACT
158  };
159 
160  public:
161 
162  /**
163  * Returns the JavaScript name of this object.
164  * @return The object's JavaScript name
165  */
166  static inline const char* objectName();
167 
168  protected:
169 
170  /**
171  * Creates the function template and object template for this object.
172  */
173  static void createFunctionTemplate();
174 };
175 
176 inline const char* JSVector3::objectName()
177 {
178  return "Vector3";
179 }
180 
181 }
182 
183 }
184 
185 }
186 
187 #endif // META_OCEAN_INTERACTION_JS_VECTOR_3_H
This class implements the java script interaction library object.
Definition: JSLibrary.h:32
This class implements the base class for all native wrapper of JavaScript objects.
Definition: JSObject.h:31
This class implements a wrapper for a JavaScript Vector3 object.
Definition: JSVector3.h:28
AccessorId
Definition of ids for individual accessors.
Definition: JSVector3.h:38
@ AI_X
The accessor for the x property, a number value.
Definition: JSVector3.h:40
@ AI_Y
The accessor for the y property, a number value.
Definition: JSVector3.h:42
static void createFunctionTemplate()
Creates the function template and object template for this object.
static const char * objectName()
Returns the JavaScript name of this object.
Definition: JSVector3.h:176
FunctionId
Definition of ids for individual functions.
Definition: JSVector3.h:51
@ FI_INVERT
Inverts this vector.
Definition: JSVector3.h:83
@ FI_LENGTH
Returns the length of this vector.
Definition: JSVector3.h:107
@ FI_ADD
Adds two vectors or adds a scalar value to this vector.
Definition: JSVector3.h:59
@ FI_STRING
Returns a string with the values of this vector.
Definition: JSVector3.h:148
@ FI_MULTIPLY
Multiplies two vectors to determine the scalar product or multiplies this vector with a scalar.
Definition: JSVector3.h:124
@ FI_NORMALIZE
Normalizes this vector so that the vector has unit length afterwards.
Definition: JSVector3.h:132
@ FI_INVERTED
Returns the inverted vector of this vector.
Definition: JSVector3.h:91
@ FI_NORMALIZED
Returns the normalized vector of this vector, so that the new vector has unit length.
Definition: JSVector3.h:140
@ FI_DISTANCE
Returns the distance between this vector and another vector.
Definition: JSVector3.h:115
@ FI_ANGLE
Determines the angle between two vectors in radian.
Definition: JSVector3.h:67
@ FI_CROSS
Determines the cross product between two vectors.
Definition: JSVector3.h:75
@ FI_IS_EQUAL
Returns whether two vectors are equal up to some epsilon.
Definition: JSVector3.h:99
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15