NOTE: These models are somewhat untested. Please report problems to me.
The file format is as follows:
butterflyModel_Vertex is a list of vertexes
butterflyModel_Vertex=[[[0.33, 0.46, 0.29],[0.0, 0.0, 1.0, 1.0],[3.2e-06, 0.82, -0.58]],[[0.48, 0.46, 0.29],[0.0, 0.0, 1.0, 1.0],[3.2e-06, 0.63, -0.78]],
butterflyModel_INDEX is a list of edges
butterflyModel_INDEX = [3, 2, 1, 5, 4, 2,
function DeepFlatten(struct) {
let size = 0;
for (let item of struct[0]) {
size += item.length;
}
size *= struct.length
let i = 0;
let rv = new Float32Array(size);
for(let data of struct) {
for (let item of data) {
for(let num of item) {
rv[i] = num;
++i;
}
}
}
return rv;
}
An example application of this is
vbuf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vbuf);
gl.bufferData(gl.ARRAY_BUFFER,DeepFlatten(verts), gl.STATIC_DRAW);
Typical use includes the following in your .html file:
<script type="text/javascript" src="https://mirkwood.cs.edinboro.edu/~bennett/GraphicsCode/Common/webgl-utils.js"></script>
<script type="text/javascript" src="https://mirkwood.cs.edinboro.edu/~bennett/GraphicsCode/Common/initShaders.js"></script>
<script type="text/javascript" src="https://mirkwood.cs.edinboro.edu/~bennett/GraphicsCode/Common/MV.js"></script>
<script type="text/javascript" src="https://mirkwood.cs.edinboro.edu/~bennett/GraphicsCode/NewShapes/teapot.js"></script>
<script type="text/javascript" src="https://mirkwood.cs.edinboro.edu/~bennett/GraphicsCode/NewShapes/cheetah.js"></script>
<script type="text/javascript" src="https://mirkwood.cs.edinboro.edu/~bennett/GraphicsCode/NewShapes/DeepFlatten.js"></script>