|
|
@@ -36,6 +36,14 @@ class EventNode extends Node {
|
|
|
|
|
|
this.updateType = NodeUpdateType.RENDER;
|
|
|
|
|
|
+ } else if ( eventType === EventNode.BEFORE_OBJECT ) {
|
|
|
+
|
|
|
+ this.updateBeforeType = NodeUpdateType.OBJECT;
|
|
|
+
|
|
|
+ } else if ( eventType === EventNode.BEFORE_MATERIAL ) {
|
|
|
+
|
|
|
+ this.updateBeforeType = NodeUpdateType.RENDER;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -46,10 +54,17 @@ class EventNode extends Node {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ updateBefore( frame ) {
|
|
|
+
|
|
|
+ this.callback( frame );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
EventNode.OBJECT = 'object';
|
|
|
EventNode.MATERIAL = 'material';
|
|
|
+EventNode.BEFORE_MATERIAL = 'beforeMaterial';
|
|
|
|
|
|
export default EventNode;
|
|
|
|
|
|
@@ -81,3 +96,23 @@ export const OnObjectUpdate = ( callback ) => createEvent( EventNode.OBJECT, cal
|
|
|
* @returns {EventNode}
|
|
|
*/
|
|
|
export const OnMaterialUpdate = ( callback ) => createEvent( EventNode.MATERIAL, callback );
|
|
|
+
|
|
|
+/**
|
|
|
+ * Creates an event that triggers a function before an object (Mesh|Sprite) is updated.
|
|
|
+ *
|
|
|
+ * The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
|
|
|
+ *
|
|
|
+ * @param {Function} callback - The callback function.
|
|
|
+ * @returns {EventNode}
|
|
|
+ */
|
|
|
+export const OnBeforeObjectUpdate = ( callback ) => createEvent( EventNode.BEFORE_OBJECT, callback );
|
|
|
+
|
|
|
+/**
|
|
|
+ * Creates an event that triggers a function before the material is updated.
|
|
|
+ *
|
|
|
+ * The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
|
|
|
+ *
|
|
|
+ * @param {Function} callback - The callback function.
|
|
|
+ * @returns {EventNode}
|
|
|
+ */
|
|
|
+export const OnBeforeMaterialUpdate = ( callback ) => createEvent( EventNode.BEFORE_MATERIAL, callback );
|