Skip to content
Merged
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
35 changes: 30 additions & 5 deletions src/nodes/accessors/UniformArrayNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,38 @@ class UniformArrayNode extends BufferNode {

}

update( /*frame*/ ) {

this.updateBuffer();

}

/**
* The update makes sure to correctly transfer the data from the (complex) objects
* in the array to the internal, correctly padded value buffer.
* Composes a user-defined update with the buffer transfer.
*
* @param {NodeFrame} frame - A reference to the current node frame.
* @param {Function} callback - The update function.
* @param {string} updateType - The update type.
* @return {UniformArrayNode} A reference to this node.
*/
update( /*frame*/ ) {
onUpdate( callback, updateType ) {

callback = callback.bind( this );

return super.onUpdate( ( frame, self ) => {

callback( frame, self );

this.updateBuffer();

}, updateType );

}

/**
* The method makes sure to correctly transfer the data from the (complex) objects
* in the array to the internal, correctly padded value buffer.
*/
updateBuffer() {

const { array, value } = this;

Expand Down Expand Up @@ -315,7 +340,7 @@ class UniformArrayNode extends BufferNode {
this.bufferCount = length;
this.bufferType = paddedType;

this.update(); // initialize the buffer values
this.updateBuffer(); // initialize the buffer values

return super.setup( builder );

Expand Down
Loading