|
|
@@ -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;
|
|
|
|
|
|
@@ -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 );
|
|
|
|