8#ifndef META_OCEAN_INTERACTION_JS_EXTERNAL_H
9#define META_OCEAN_INTERACTION_JS_EXTERNAL_H
109 inline Type type()
const;
116 template <
typename TNative>
117 inline TNative& value();
124 template <
typename TNative>
125 static inline Type type();
147 template <
typename TNative>
148 static inline void setValue(v8::Local<v8::Object>&
object, TNative&& value);
156 template <
typename TNative>
157 static inline void setValue(v8::Local<v8::Object>&
object,
const TNative& value);
166 template <
typename TNative>
167 static JSExternal* create(TNative* data, v8::Local<v8::Object>& owner, v8::Isolate* isolate);
178 JSExternal(
void* data,
const Type type, v8::Local<v8::Object>& owner, v8::Isolate* isolate);
209template <
typename TNative>
212 return new JSExternal((
void*)(data), type<TNative>(), owner, isolate);
223 ocean_assert(
data_ !=
nullptr);
232 ocean_assert(
data_ !=
nullptr);
241 ocean_assert(
data_ !=
nullptr);
250 ocean_assert(
data_ !=
nullptr);
259 ocean_assert(
data_ !=
nullptr);
268 ocean_assert(
data_ !=
nullptr);
277 ocean_assert(
data_ !=
nullptr);
286 ocean_assert(
data_ !=
nullptr);
295 ocean_assert(
data_ !=
nullptr);
304 ocean_assert(
data_ !=
nullptr);
313 ocean_assert(
data_ !=
nullptr);
322 ocean_assert(
data_ !=
nullptr);
331 ocean_assert(
data_ !=
nullptr);
340 ocean_assert(
data_ !=
nullptr);
349 ocean_assert(
data_ !=
nullptr);
358 ocean_assert(
data_ !=
nullptr);
367 ocean_assert(
data_ !=
nullptr);
376 ocean_assert(
data_ !=
nullptr);
382template <
typename TNative>
385 static_assert(oceanFalse<TNative>(),
"This function is not defined for the data type");
391 return TYPE_DEVICE_SAMPLE;
427 return TYPE_RENDERING_ENGINE;
433 return TYPE_RENDERING_OBJECT;
440 return TYPE_MEDIA_OBJECT;
446 return TYPE_SCENE_DESCRIPTION_NODE;
497template <
typename TNative>
500 static_assert(oceanFalse<TNative>(),
"This function is not defined for the data type");
504template <
typename TNative>
508 ocean_assert(externalObject !=
nullptr);
510 externalObject->
value<TNative>() = std::move(
value);
513template <
typename TNative>
517 ocean_assert(externalObject !=
nullptr);
This class implements an euler rotation with angles: yaw, pitch and roll.
Definition Euler.h:80
This class is a lightweight helper class for device objects to allow event callback handling.
Definition JSDevice.h:35
This class implements a type-safe object wrapper for non-JavaScript objects.
Definition JSExternal.h:50
Type type() const
Returns the type of the wrapped C++ object.
Definition JSExternal.h:215
static void destructorCallback(const v8::WeakCallbackInfo< JSExternal > &info)
The callback function which will be called from v8 once the wrapped object is not used anymore.
JSExternal & operator=(JSExternal &)=delete
Disabled assign operator.
~JSExternal()
Destructs this object.
v8::Persistent< v8::Object > persistent_
The v8 Persistent object ensuring that we get informed when the JS object is not needed anymore.
Definition JSExternal.h:206
static JSExternal * create(TNative *data, v8::Local< v8::Object > &owner, v8::Isolate *isolate)
Creates a new type-safe wrapper object for a specific native C++ object.
Definition JSExternal.h:210
TNative & value()
Returns the wrapped C++ object.
Definition JSExternal.h:383
static void setValue(v8::Local< v8::Object > &object, TNative &&value)
Sets or changes the native C++ object of an external JavaScript object.
Definition JSExternal.h:505
void * data_
The pointer to the actual native object.
Definition JSExternal.h:200
static JSExternal * external(const v8::Local< v8::Object > &object)
Returns the external object from a given JavaScript object.
Type type_
The type of the native object.
Definition JSExternal.h:203
JSExternal(const JSExternal &)=delete
Disabled copy constructor.
JSExternal(void *data, const Type type, v8::Local< v8::Object > &owner, v8::Isolate *isolate)
Creates a new type-safe wrapper object for a specific native C++ object.
Type
Definition of different external object types.
Definition JSExternal.h:57
@ TYPE_RENDERING_OBJECT
Rendering object object.
Definition JSExternal.h:81
@ TYPE_SQUARE_MATRIX_3
SquareMatrix3 object.
Definition JSExternal.h:87
@ TYPE_ROTATION
Rotation object.
Definition JSExternal.h:83
@ TYPE_DEVICE_SAMPLE
Device sample object.
Definition JSExternal.h:65
@ TYPE_VECTOR_2
Vector2 object.
Definition JSExternal.h:91
@ TYPE_SQUARE_MATRIX_4
SquareMatrix4 object.
Definition JSExternal.h:89
@ TYPE_SCENE_DESCRIPTION_NODE
Scene description node.
Definition JSExternal.h:85
@ TYPE_VECTOR_4
Vector4 object.
Definition JSExternal.h:95
@ TYPE_EULER
Euler object.
Definition JSExternal.h:67
@ TYPE_VECTOR_3
Vector3 object.
Definition JSExternal.h:93
@ TYPE_DEVICE_OBJECT
Device object object.
Definition JSExternal.h:63
@ TYPE_QUATERNION
Quaternion object.
Definition JSExternal.h:77
@ TYPE_RENDERING_ENGINE
Rendering engine object.
Definition JSExternal.h:79
@ TYPE_UNDEFINED
Undefined object.
Definition JSExternal.h:59
@ TYPE_PLANE_3
Plane3 object.
Definition JSExternal.h:75
@ TYPE_COLOR
Color object.
Definition JSExternal.h:61
@ TYPE_MEDIA_OBJECT
Media object object.
Definition JSExternal.h:73
@ TYPE_LINE_3
Line3 object.
Definition JSExternal.h:71
@ TYPE_HOMOGENOUS_MATRIX_4
HomogenousMatrix4 object.
Definition JSExternal.h:69
static JSExternal * external(const v8::Local< v8::Value > &value)
Returns the external object from a given JavaScript object.
This class implements an infinite line in 3D space.
Definition Line3.h:68
This template class implements a object reference with an internal reference counter.
Definition base/ObjectRef.h:58
This class implements a color defined by red, green, blue and alpha parameters.
Definition RGBAColor.h:41
This class implements a axis-angle rotation using floating point values.
Definition Rotation.h:79
This class implements a vector with four elements.
Definition Vector4.h:97
The namespace covering the entire Ocean framework.
Definition Accessor.h:15