Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Three.TSL.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ export const objectRadius = TSL.objectRadius;
export const objectScale = TSL.objectScale;
export const objectViewPosition = TSL.objectViewPosition;
export const objectWorldMatrix = TSL.objectWorldMatrix;
export const OnBeforeObjectUpdate = TSL.OnBeforeObjectUpdate;
export const OnBeforeMaterialUpdate = TSL.OnBeforeMaterialUpdate;
export const OnObjectUpdate = TSL.OnObjectUpdate;
export const OnMaterialUpdate = TSL.OnMaterialUpdate;
export const oneMinus = TSL.oneMinus;
Expand Down
35 changes: 35 additions & 0 deletions src/nodes/utils/EventNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

}
Expand All @@ -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;

Expand Down Expand Up @@ -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 );