Просмотр исходного кода

UniformArrayNode: Fix `update()` overwrite. (#33962)

Michael Herzog 2 недель назад
Родитель
Сommit
ec832f1cad
1 измененных файлов с 30 добавлено и 5 удалено
  1. 30 5
      src/nodes/accessors/UniformArrayNode.js

+ 30 - 5
src/nodes/accessors/UniformArrayNode.js

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

粤ICP备19079148号