addition to standard

let WebGLFloatArray.set() return itself.
Becuase that would spare a few lines of code while it now returns undefined (which is useless).

http://ewgl.wordpress.com/2009/12/20/new-webglfloatarray-overhead/

btw this is still not implemented in minefield.

PS this should also account for the other objects in Webgl that have a set method.

In my GoogleWebToolkit-Module for WebGL (I’m calling it WebGLToolkit) the WebGLFloatArray overlay does currently look like this:

package com.delphigl.wgt.overlay;

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.core.client.JsArrayNumber;
import com.delphigl.wgt.math.*;

public class WebGLFloatArray extends WebGLArrayBuffer {
	protected WebGLFloatArray() { }

	public static WebGLFloatArray create(JSONArray array) {
		return create((JsArrayNumber)array.getJavaScriptObject());
	}

	public static native WebGLFloatArray create(int size) /*-{
		return new WebGLFloatArray(size);
	}-*/;

	public static native WebGLFloatArray create(JsArrayNumber array) /*-{
		return new WebGLFloatArray(array);
	}-*/;

	public final native double get(int index) /*-{
		return this.get(index);
	}-*/;

	public final native void set(int index, double value) /*-{
		this.set(index, value);
	}-*/;

	public final native void set(int offset, Vector2d value) /*-{
		this.set(offset  , value.@com.delphigl.wgt.math.Vector2d::x);
		this.set(offset+1, value.@com.delphigl.wgt.math.Vector2d::y);
	}-*/;

	public final native void set(int offset, Vector3d value) /*-{
		this.set(offset  , value.@com.delphigl.wgt.math.Vector3d::x);
		this.set(offset+1, value.@com.delphigl.wgt.math.Vector3d::y);
		this.set(offset+2, value.@com.delphigl.wgt.math.Vector3d::z);
	}-*/;

	public final native void set(int offset, Vector4d value) /*-{
		this.set(offset  , value.@com.delphigl.wgt.math.Vector4d::x);
		this.set(offset+1, value.@com.delphigl.wgt.math.Vector4d::y);
		this.set(offset+2, value.@com.delphigl.wgt.math.Vector4d::z);
		this.set(offset+3, value.@com.delphigl.wgt.math.Vector4d::w);
	}-*/;

	public final native WebGLFloatArray slice(int offset, int length) /*-{
		return this.slice(offset, length);
	}-*/;
}

The vector extensions have already proven very helpful. E.g. something like this:

		int lineCount = 0;
		WebGLFloatArray coords = lineRenderer.getCoordArray();
		WebGLUnsignedByteArray colors = lineRenderer.getColorArray();
		Vector4i color = new Vector4i(255, 0, 0, 255);

		// set course projection lines
		if (semiMajorAxis != 0.0 || parent != null) {
			for (int i=0; i<positions.length-1; ++i) {
				coords.set(lineCount*6+0, positions[i]); 
				coords.set(lineCount*6+3, positions[i+1]); 				
				colors.set(lineCount*8+0, color);
				color.w = 255 - (255*(i+1)) / positions.length;
				colors.set(lineCount*8+4, color);
				lineCount++;
			}
		}

I could also add your idea.

However, would need to use GoogleWebToolkit and my framework/module. I haven’t released the source yet, but I can send you an the current version, if you wish.

(I’m using my framework for my “UltimateConquest”)

Sorry, I forgot to mention: The above code is Java code, not JavaScript. The GoogleWebToolkit does compile Java-Code to JavaScript.

I don’t like editing native objects,
so this is a bit out of question,
I’ll probably just use a container function to fix this.