supereggbert / glge Goto Github PK
View Code? Open in Web Editor NEWA javascript webGL graphics library
Home Page: http://glge.org
License: Other
A javascript webGL graphics library
Home Page: http://glge.org
License: Other
If I include a COLLADA model in my XML, say the rubber duckie sample:
<collada document="duck.dae" />
There doesn't seem to be a way of adding an arbitrary number of ducks to the scene graph.
I've tried creating a new GLGE.Object
and setting its mesh and materials, but calling doc.getElement
on the document's onLoad
handler results in a GLGE.Collada
object that is uninitialized -- it's missing the xml
property and its children
array is empty.
In GLGE.BoundingVolume.prototype.applyMatrix function this.limits[6] is used but there are only 6 elements in the array.
In my web application it is necessary to remove the WebGL view and create it again without reloading the page inbetween. I discovered that I can't reuse the mesh or material instances, I have to create them again.
I'm building some objects manually, and there it works fine that way. However, Collada objects don't work on the second try (no error, but nothing is displayed).
This is caused by local caches in GLGE.Collada which store old meshes and materials that aren't valid any more when creating a new rendering context. I implemented a temporary workaround:
GLGE.resetColladaCaches = function() {
meshCache = {};
MaterialCache = {};
actionCache = {};
};
This has to be somewhere at the bottom of glge_collada.js. I just have to call this function after removing the old WebGL canvas, and I can load the Collada file successfully once more after the new context has been created.
However, that's only a workaround, there has to be some cleaner method of fixing this.
An Opera 12 users reports that other WebGL demos have worked for him but ourbricks fails.
http://www.gamedev.net/blog/23/entry-2251140-checking-out-ourbricks/
Have you tested GLGE on Opera 12?
Using glge_xmlparser.js in SceneJS online DAE converter - a user reports that his Sketchup file breaks the parser due to Sketchup's extraneous spaces in closing tag.
Full details here:
http://groups.google.co.nz/group/scenejs/browse_thread/thread/3820f4796407e074
When calling the method removeChild( object ), following error occurs:
Uncaught TypeError: Cannot call method 'indexOf' of undefined
GLGE.Events.removeEventListenerglge-compiled.js:1869
GLGE.Group.removeChildglge-compiled.js:3
The exception is thrown inside of the function removeEventListener.
this.events[event] is undefiend in the line:
var idx=this.events[event].indexOf(fn);
Did a fast check whether math library was fast.
Few changes:
Looks like the vector math is still most unoptimized.
diff --git a/glge_math.js b/glge_math.js
index f002d57..ac3f4b9 100644
--- a/glge_math.js
+++ b/glge_math.js
@@ -41,7 +41,7 @@ if(!GLGE){
d=this.data
ret += this.data[i]*v[i]
ret += d[i]*v[i]
this.data[1]_v[2]-this.data[2]_v[1],
this.data[2]_v[0]-this.data[0]_v[2],
this.data[0]_v[1]-this.data[1]_v[0] ];
var d = this.data;
d[1]_v[2]-d[2]_v[1],
d[2]_v[0]-d[0]_v[2],
d[0]_v[1]-d[1]_v[0] ]);
var d = this.data;
if (this.data.length != v.length) GLGE.error("GLGE.Vec.add -- unmatched vector length")
if (d.length != v.length) GLGE.error("GLGE.Vec.add -- unmatched vector length")
retvec[i]=this.data[i]+v[i]
retvec[i]=d[i]+v[i]
retvec[i]=this.data[i]+v
retvec[i]=d[i]+v
var d = this.data;
if (this.data.length != v.length) GLGE.error("GLGE.Vec.subtract -- unmatched vector length")
if (d.length != v.length) GLGE.error("GLGE.Vec.subtract -- unmatched vector length")
retvec[i]=this.data[i]-v[i]
retvec[i]=d[i]-v[i]
retvec[i]=this.data[i]-v
retvec[i]=d[i]-v
var d = this.data;
for(var i in this.data) {
retvec[i]=this.data[i]*value
for(var i in d) {
retvec[i]=d[i]*value
sq += this.data[i] \* this.data[i]
var d = this.data;
sq += d[i] \* d[i]
retval.push(this.data[i]*f)
retval.push(d[i]*f)
this.data=[array[0],array[1],array[2],0,array[3],array[4],array[5],0,array[6],array[7],array[8],0,0,0,0,1];
this.data=new WebGLFloatArray([array[0],array[1],array[2],0,array[3],array[4],array[5],0,array[6],array[7],array[8],0,0,0,0,1]);
this.data=[array[0],array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15]];
this.data=new WebGLFloatArray([array[0],array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15]]);
if(mat2.length==16){
var mat=[
mat2[0] \* mat1[0]+mat2[4] \* mat1[1]+mat2[8] \* mat1[2]+mat2[12] \* mat1[3],
mat2[1] \* mat1[0]+mat2[5] \* mat1[1]+mat2[9] \* mat1[2]+mat2[13] \* mat1[3],
mat2[2] \* mat1[0]+mat2[6] \* mat1[1]+mat2[10] \* mat1[2]+mat2[14] \* mat1[3],
mat2[3] \* mat1[0]+mat2[7] \* mat1[1]+mat2[11] \* mat1[2]+mat2[15] \* mat1[3],
if(mat2.length==16){
var m0 = mat2[0], m4 = mat2[4], m8 = mat2[8], m12 = mat2[12],
m1 = mat2[1], m5 = mat2[5], m9 = mat2[9], m13 = mat2[13],
m2 = mat2[2], m6 = mat2[6], m10 = mat2[10], m14 = mat2[14],
m3 = mat2[3], m7 = mat2[7], m11 = mat2[11], m15 = mat2[15];
var n0 = mat1[0], n4 = mat1[4], n8 = mat1[8], n12 = mat1[12],
n1 = mat1[1], n5 = mat1[5], n9 = mat1[9], n13 = mat1[13],
n2 = mat1[2], n6 = mat1[6], n10 = mat1[10], n14 = mat1[14],
n3 = mat1[3], n7 = mat1[7], n11 = mat1[11], n15 = mat1[15];
return new GLGE.Mat([
m0 \* n0+m4 \* n1+m8 \* n2+m12 \* n3,
m1 \* n0+m5 \* n1+m9 \* n2+m13 \* n3,
m2 \* n0+m6 \* n1+m10 \* n2+m14 \* n3,
m3 \* n0+m7 \* n1+m11 \* n2+m15 \* n3,
mat2[0] \* mat1[4]+mat2[4] \* mat1[5]+mat2[8] \* mat1[6]+mat2[12] \* mat1[7],
mat2[1] \* mat1[4]+mat2[5] \* mat1[5]+mat2[9] \* mat1[6]+mat2[13] \* mat1[7],
mat2[2] \* mat1[4]+mat2[6] \* mat1[5]+mat2[10] \* mat1[6]+mat2[14] \* mat1[7],
mat2[3] \* mat1[4]+mat2[7] \* mat1[5]+mat2[11] \* mat1[6]+mat2[15] \* mat1[7],
m0 \* n4+m4 \* n5+m8 \* n6+m12 \* n7,
m1 \* n4+m5 \* n5+m9 \* n6+m13 \* n7,
m2 \* n4+m6 \* n5+m10 \* n6+m14 \* n7,
m3 * n4+m7 * n5+m11 * n6+m15 * n7,
mat2[0] * mat1[8]+mat2[4] * mat1[9]+mat2[8] * mat1[10]+mat2[12] * mat1[11],
mat2[1] \* mat1[8]+mat2[5] \* mat1[9]+mat2[9] \* mat1[10]+mat2[13] \* mat1[11],
mat2[2] \* mat1[8]+mat2[6] \* mat1[9]+mat2[10] \* mat1[10]+mat2[14] \* mat1[11],
mat2[3] \* mat1[8]+mat2[7] \* mat1[9]+mat2[11] \* mat1[10]+mat2[15] \* mat1[11],
m0 \* n8+m4 \* n9+m8 \* n10+m12 \* n11,
m1 \* n8+m5 \* n9+m9 \* n10+m13 \* n11,
m2 \* n8+m6 \* n9+m10 \* n10+m14 \* n11,
m3 * n8+m7 * n9+m11 * n10+m15 * n11,
mat2[0] * mat1[12]+mat2[4] * mat1[13]+mat2[8] * mat1[14]+mat2[12] * mat1[15],
mat2[1] \* mat1[12]+mat2[5] \* mat1[13]+mat2[9] \* mat1[14]+mat2[13] \* mat1[15],
mat2[2] \* mat1[12]+mat2[6] \* mat1[13]+mat2[10] \* mat1[14]+mat2[14] \* mat1[15],
return new GLGE.Mat(mat);
m0 \* n12+m4 \* n13+m8 \* n14+m12 \* n15,
m1 \* n12+m5 \* n13+m9 \* n14+m13 \* n15,
m2 \* n12+m6 \* n13+m10 \* n14+m14 \* n15,
m3 \* n12+m7 \* n13+m11 \* n14+m15 \* n15]);
}else if(mat2.length==4){
var vec=[
mat1[0]_mat2[0]+mat1[1]_mat2[1]+mat1[2]_mat2[2]+mat1[3]_mat2[3],
mat1[4]_mat2[0]+mat1[5]_mat2[1]+mat1[6]_mat2[2]+mat1[7]_mat2[3],
mat1[8]_mat2[0]+mat1[9]_mat2[1]+mat1[10]_mat2[2]+mat1[11]_mat2[3],
mat1[12]_mat2[0]+mat1[13]_mat2[1]+mat1[14]_mat2[2]+mat1[15]_mat2[3]];
return new GLGE.Vec(vec);
var m0 = mat2[0], m1 = mat2[1], m2 = mat2[2], m3 = mat2[3];
return new GLGE.Vec([
mat1[0]_m0+mat1[1]_m1+mat1[2]_m2+mat1[3]_m3,
mat1[4]_m0+mat1[5]_m1+mat1[6]_m2+mat1[7]_m3,
mat1[8]_m0+mat1[9]_m1+mat1[10]_m2+mat1[11]_m3,
mat1[12]_m0+mat1[13]_m1+mat1[14]_m2+mat1[15]_m3]);
}else if(mat2.length==3){
var vec=[
mat1[0]_mat2[0]+mat1[1]_mat2[1]+mat1[2]*mat2[2]+mat1[3],
mat1[4]_mat2[0]+mat1[5]_mat2[1]+mat1[6]*mat2[2]+mat1[7],
mat1[8]_mat2[0]+mat1[9]_mat2[1]+mat1[10]*mat2[2]+mat1[11],
mat1[12]_mat2[0]+mat1[13]_mat2[1]+mat1[14]*mat2[2]+mat1[15]];
return new GLGE.Vec(vec);
var m0 = mat2[0], m1 = mat2[1], m2 = mat2[2]
return new GLGE.Vec([
mat1[0]_m0+mat1[1]_m1+mat1[2]*m2+mat1[3],
mat1[4]_m0+mat1[5]_m1+mat1[6]*m2+mat1[7],
mat1[8]_m0+mat1[9]_m1+mat1[10]*m2+mat1[11],
mat1[12]_m0+mat1[13]_m1+mat1[14]*m2+mat1[15]]);
} else {
GLGE.error("Unsupported matrix length in cross(): must be 3-4");
throw "invalid matrix length";
}
var mat=[
return new GLGE.Mat([
mat1[0]_value,mat1[1]_value,mat1[2]_value,mat1[3]_value,
mat1[4]_value,mat1[5]_value,mat1[6]_value,mat1[7]_value,
mat1[8]_value,mat1[9]_value,mat1[10]_value,mat1[11]_value,
mat1[12]_value,mat1[13]_value,mat1[14]_value,mat1[15]_value];
return new GLGE.Mat(mat);
mat1[12]_value,mat1[13]_value,mat1[14]_value,mat1[15]_value]);
return m[12] \* m[9] \* m[6] \* m[3] - m[8] \* m[13] \* m[6] \* m[3] - m[12] \* m[5] \* m[10] \* m[3] + m[4] \* m[13] \* m[10] \* m[3] + m[8] \* m[5] \* m[14] \* m[3] - m[4] \* m[9] \* m[14] \* m[3] - m[12] \* m[9] \* m[2] \* m[7] + m[8] \* m[13] \* m[2] \* m[7] + m[12] \* m[1] \* m[10] \* m[7] - m[0] \* m[13] \* m[10] \* m[7] - m[8] \* m[1] \* m[14] \* m[7] + m[0] \* m[9] \* m[14] \* m[7] + m[12] \* m[5] \* m[2] \* m[11] - m[4] \* m[13] \* m[2] \* m[11] - m[12] \* m[1] \* m[6] \* m[11] + m[0] \* m[13] \* m[6] \* m[11] + m[4] \* m[1] \* m[14] \* m[11] - m[0] \* m[5] \* m[14] \* m[11] - m[8] \* m[5] \* m[2] \* m[15] + m[4] \* m[9] \* m[2] \* m[15] + m[8] \* m[1] \* m[6] \* m[15] - m[0] \* m[9] \* m[6] \* m[15] - m[4] \* m[1] \* m[10] \* m[15] + m[0] \* m[5] \* m[10] \* m[15];
var m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12],
m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13],
m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14],
m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
return m12 \* m9 \* m6 \* m3 - m8 \* m13 \* m6 \* m3 - m12 \* m5 \* m10 \* m3 + m4 \* m13 \* m10 \* m3 + m8 \* m5 \* m14 \* m3 - m4 \* m9 \* m14 \* m3 - m12 \* m9 \* m2 \* m7 + m8 \* m13 \* m2 \* m7 + m12 \* m1 \* m10 \* m7 - m0 \* m13 \* m10 \* m7 - m8 \* m1 \* m14 \* m7 + m0 \* m9 \* m14 \* m7 + m12 \* m5 \* m2 \* m11 - m4 \* m13 \* m2 \* m11 - m12 \* m1 \* m6 \* m11 + m0 \* m13 \* m6 \* m11 + m4 \* m1 \* m14 \* m11 - m0 \* m5 \* m14 \* m11 - m8 \* m5 \* m2 \* m15 + m4 \* m9 \* m2 \* m15 + m8 \* m1 \* m6 \* m15 - m0 \* m9 \* m6 \* m15 - m4 \* m1 \* m10 \* m15 + m0 \* m5 \* m10 \* m15;
var mat=[
(m[9] \* m[14] \* m[7] - m[13] \* m[10] \* m[7] + m[13] \* m[6] \* m[11] - m[5] \* m[14] \* m[11] - m[9] \* m[6] \* m[15] + m[5] \* m[10] \* m[15])/det,
(m[12] \* m[10] \* m[7] - m[8] \* m[14] \* m[7] - m[12] \* m[6] \* m[11] + m[4] \* m[14] \* m[11] + m[8] \* m[6] \* m[15] - m[4] \* m[10] \* m[15])/det,
(m[8] \* m[13] \* m[7] - m[12] \* m[9] \* m[7] + m[12] \* m[5] \* m[11] - m[4] \* m[13] \* m[11] - m[8] \* m[5] \* m[15] + m[4] \* m[9] \* m[15])/det,
(m[12] \* m[9] \* m[6] - m[8] \* m[13] \* m[6] - m[12] \* m[5] \* m[10] + m[4] \* m[13] \* m[10] + m[8] \* m[5] \* m[14] - m[4] \* m[9] \* m[14])/det,
(m[13] \* m[10] \* m[3] - m[9] \* m[14] \* m[3] - m[13] \* m[2] \* m[11] + m[1] \* m[14] \* m[11] + m[9] \* m[2] \* m[15] - m[1] \* m[10] \* m[15])/det,
(m[8] \* m[14] \* m[3] - m[12] \* m[10] \* m[3] + m[12] \* m[2] \* m[11] - m[0] \* m[14] \* m[11] - m[8] \* m[2] \* m[15] + m[0] \* m[10] \* m[15])/det,
(m[12] \* m[9] \* m[3] - m[8] \* m[13] \* m[3] - m[12] \* m[1] \* m[11] + m[0] \* m[13] \* m[11] + m[8] \* m[1] \* m[15] - m[0] \* m[9] \* m[15])/det,
(m[8] \* m[13] \* m[2] - m[12] \* m[9] \* m[2] + m[12] \* m[1] \* m[10] - m[0] \* m[13] \* m[10] - m[8] \* m[1] \* m[14] + m[0] \* m[9] \* m[14])/det,
(m[5] \* m[14] \* m[3] - m[13] \* m[6] \* m[3] + m[13] \* m[2] \* m[7] - m[1] \* m[14] \* m[7] - m[5] \* m[2] \* m[15] + m[1] \* m[6] \* m[15])/det,
(m[12] \* m[6] \* m[3] - m[4] \* m[14] \* m[3] - m[12] \* m[2] \* m[7] + m[0] \* m[14] \* m[7] + m[4] \* m[2] \* m[15] - m[0] \* m[6] \* m[15])/det,
(m[4] \* m[13] \* m[3] - m[12] \* m[5] \* m[3] + m[12] \* m[1] \* m[7] - m[0] \* m[13] \* m[7] - m[4] \* m[1] \* m[15] + m[0] \* m[5] \* m[15])/det,
(m[12] \* m[5] \* m[2] - m[4] \* m[13] \* m[2] - m[12] \* m[1] \* m[6] + m[0] \* m[13] \* m[6] + m[4] \* m[1] \* m[14] - m[0] \* m[5] \* m[14])/det,
(m[9] \* m[6] \* m[3] - m[5] \* m[10] \* m[3] - m[9] \* m[2] \* m[7] + m[1] \* m[10] \* m[7] + m[5] \* m[2] \* m[11] - m[1] \* m[6] \* m[11])/det,
(m[4] \* m[10] \* m[3] - m[8] \* m[6] \* m[3] + m[8] \* m[2] \* m[7] - m[0] \* m[10] \* m[7] - m[4] \* m[2] \* m[11] + m[0] \* m[6] \* m[11])/det,
(m[8] \* m[5] \* m[3] - m[4] \* m[9] \* m[3] - m[8] \* m[1] \* m[7] + m[0] \* m[9] \* m[7] + m[4] \* m[1] \* m[11] - m[0] \* m[5] \* m[11])/det,
(m[4] \* m[9] \* m[2] - m[8] \* m[5] \* m[2] + m[8] \* m[1] \* m[6] - m[0] \* m[9] \* m[6] - m[4] \* m[1] \* m[10] + m[0] \* m[5] \* m[10])/det];
var m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12],
m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13],
m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14],
m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
this.inverseMat=new GLGE.Mat(mat);
this.inverseMat=new GLGE.Mat([
(m9 \* m14 \* m7 - m13 \* m10 \* m7 + m13 \* m6 \* m11 - m5 \* m14 \* m11 - m9 \* m6 \* m15 + m5 \* m10 \* m15)/det,
(m12 \* m10 \* m7 - m8 \* m14 \* m7 - m12 \* m6 \* m11 + m4 \* m14 \* m11 + m8 \* m6 \* m15 - m4 \* m10 \* m15)/det,
(m8 \* m13 \* m7 - m12 \* m9 \* m7 + m12 \* m5 \* m11 - m4 \* m13 \* m11 - m8 \* m5 \* m15 + m4 \* m9 \* m15)/det,
(m12 \* m9 \* m6 - m8 \* m13 \* m6 - m12 \* m5 \* m10 + m4 \* m13 \* m10 + m8 \* m5 \* m14 - m4 \* m9 \* m14)/det,
(m13 \* m10 \* m3 - m9 \* m14 \* m3 - m13 \* m2 \* m11 + m1 \* m14 \* m11 + m9 \* m2 \* m15 - m1 \* m10 \* m15)/det,
(m8 \* m14 \* m3 - m12 \* m10 \* m3 + m12 \* m2 \* m11 - m0 \* m14 \* m11 - m8 \* m2 \* m15 + m0 \* m10 \* m15)/det,
(m12 \* m9 \* m3 - m8 \* m13 \* m3 - m12 \* m1 \* m11 + m0 \* m13 \* m11 + m8 \* m1 \* m15 - m0 \* m9 \* m15)/det,
(m8 \* m13 \* m2 - m12 \* m9 \* m2 + m12 \* m1 \* m10 - m0 \* m13 \* m10 - m8 \* m1 \* m14 + m0 \* m9 \* m14)/det,
(m5 \* m14 \* m3 - m13 \* m6 \* m3 + m13 \* m2 \* m7 - m1 \* m14 \* m7 - m5 \* m2 \* m15 + m1 \* m6 \* m15)/det,
(m12 \* m6 \* m3 - m4 \* m14 \* m3 - m12 \* m2 \* m7 + m0 \* m14 \* m7 + m4 \* m2 \* m15 - m0 \* m6 \* m15)/det,
(m4 \* m13 \* m3 - m12 \* m5 \* m3 + m12 \* m1 \* m7 - m0 \* m13 \* m7 - m4 \* m1 \* m15 + m0 \* m5 \* m15)/det,
(m12 \* m5 \* m2 - m4 \* m13 \* m2 - m12 \* m1 \* m6 + m0 \* m13 \* m6 + m4 \* m1 \* m14 - m0 \* m5 \* m14)/det,
(m9 \* m6 \* m3 - m5 \* m10 \* m3 - m9 \* m2 \* m7 + m1 \* m10 \* m7 + m5 \* m2 \* m11 - m1 \* m6 \* m11)/det,
(m4 \* m10 \* m3 - m8 \* m6 \* m3 + m8 \* m2 \* m7 - m0 \* m10 \* m7 - m4 \* m2 \* m11 + m0 \* m6 \* m11)/det,
(m8 \* m5 \* m3 - m4 \* m9 \* m3 - m8 \* m1 \* m7 + m0 \* m9 \* m7 + m4 \* m1 \* m11 - m0 \* m5 \* m11)/det,
(m4 \* m9 \* m2 - m8 \* m5 \* m2 + m8 \* m1 \* m6 - m0 \* m9 \* m6 - m4 \* m1 \* m10 + m0 \* m5 \* m10)/det]);
var m2=value.data;
var mat=[
var m2=value.data;;
return new GLGE.Mat([
m[0]+m2[0],m[1]+m2[1],m[2]+m2[2],m[3]+m2[3],
m[4]+m2[4],m[5]+m2[5],m[6]+m2[6],m[7]+m2[7],
m[8]+m2[8],m[9]+m2[9],m[10]+m2[10],m[11]+m2[11],
m[12]+m2[12],m[13]+m2[13],m[14]+m2[14],m[15]+m2[15]];
return new GLGE.Mat(mat);
var mat=[
m[12]+m2[12],m[13]+m2[13],m[14]+m2[14],m[15]+m2[15]]);
return new GLGE.Mat([
m[0]+value,m[1]+value,m[2]+value,m[3]+value,
m[4]+value,m[5]+value,m[6]+value,m[7]+value,
m[8]+value,m[9]+value,m[10]+value,m[11]+value,
m[12]+value,m[13]+value,m[14]+value,m[15]+value];
return new GLGE.Mat(mat);
m[12]+value,m[13]+value,m[14]+value,m[15]+value]);
var mat=[
return new GLGE.Mat([
m[0]-m2[0],m[1]-m2[1],m[2]-m2[2],m[3]-m2[3],
m[4]-m2[4],m[5]-m2[5],m[6]-m2[6],m[7]-m2[7],
m[8]-m2[8],m[9]-m2[9],m[10]-m2[10],m[11]-m2[11],
m[12]-m2[12],m[13]-m2[13],m[14]-m2[14],m[15]-m2[15]];
return new GLGE.Mat(mat);
m[12]-m2[12],m[13]-m2[13],m[14]-m2[14],m[15]-m2[15]]);
var mat=[
return new GLGE.Mat([
m[0]-value,m[1]-value,m[2]-value,m[3]-value,
m[4]-value,m[5]-value,m[6]-value,m[7]-value,
m[8]-value,m[9]-value,m[10]-value,m[11]-value,
m[12]-value,m[13]-value,m[14]-value,m[15]-value];
return new GLGE.Mat(mat);
m[12]-value,m[13]-value,m[14]-value,m[15]-value]);
var mat=[
this.data[0],this.data[4],this.data[8],this.data[12],
this.data[1],this.data[5],this.data[9],this.data[13],
this.data[2],this.data[6],this.data[10],this.data[14],
this.data[3],this.data[7],this.data[11],this.data[15]];
this.transposeMat=new GLGE.Mat(mat);
var d = this.data;
this.transposeMat=new GLGE.Mat([
d[0],d[4],d[8],d[12],
d[1],d[5],d[9],d[13],
d[2],d[6],d[10],d[14],
d[3],d[7],d[11],d[15]]);
var mat=[
return new GLGE.Mat([
m[0]_value,m[1]_value,m[2]_value,m[3]_value,
m[4]_value,m[5]_value,m[6]_value,m[7]_value,
m[8]_value,m[9]_value,m[10]_value,m[11]_value,
m[12]_value,m[13]_value,m[14]_value,m[15]_value];
return new GLGE.Mat(mat);
m[12]_value,m[13]_value,m[14]_value,m[15]_value]);
Move the document to load out of the GLGE.Document constructor, else the onload event may not fire correctly!
It appears that all of the examples in the current version of GLGE that use the tag (2dfilterdemo, demoscene, and shadowdemo) are broken in the current releases of Chrome and Firefox4 (on Win7). The scene
isn’t drawn correctly (sometimes all white or all black)
and you can’t interact with it. Is there a fix or workaround for this?
Using latest WebKit[Version 5.0 (6533.16, r61173)] or Chromium[6.0.433.0 (49597)] will face following
error: "Uncaught TypeError: Cannot read property 'data' of undefined glge.js:4646".
var data=gl.readPixels(0, 0, 4, 1, gl.RGBA, gl.UNSIGNED_BYTE);
//TODO: firefox hack :-( remove when fixed!
if(data.data) data = data.data;
One solution could be:
"Compensating for WebGL readPixels() Spec Changes(http://asalga.wordpress.com/2010/07/14/compensating-for-webgl-readpixels-spec-changes/)"
Works great in Minefield. I get frame rates around 50
In Chrome it just loads up the 2D interface but all the 3D stuff is just white
In Webkit nightly I also get the white but it flickers between the white and the 3D space where I can see a buggy version of the particles
sorry for my inexperience but for mesh animations, I can create animations with blender(I prefer this one ) and then implements them in glge code (how I implement them in glegle code ?), or I have to create animations from zero with code glge ...tanks
GLGE.Group has no default 'pickable' property, as opposed to GLGE.Object. Because of this, Group need to have setPickable(true) called, even if child objects already are pickable by default.
I downloaded the project zip file and unzip it to local Apache web server. I run the linedemo in /examples folder but it displays nothing. I am surprised because this demo in http://www.glge.org/demos/linedemo/ still OK.
In the code, I found that local linedemo includes glge-compiled.js but the online one uses glge_math.js and glge.js.
Is this a bug? Or I missed something to run?
Thanks.
introduce config file to allow defaults to be altered
I’ve downloaded Minefield, Google Chrome 10 and others latest browsers, but the GLGE’s examples don’t work… The browser find webGL but the objects don’t appear in the scene. I don’t understand why… I only have this problem on Windows, it works on Mac OS…
If somebody can help me… It’s pretty urgent !
I'm trying to load a wavefront model, model/steve.obj
that references an mtl file in the same directory. When I try to load the model with steve.setSrc('model/steve.obj', location.href)
, I get this strange error that seems to point to a problem in the path munging.
Error loading Document: model//undefined/steve.mtl status 404
The obj file references it as simply steve.mtl
, and I've traced the origin of the extra /undefined/
to GLGE.Wavefront.prototype.getAbsolutePath
—I'm just not sure what to make of it. It might be worth the effort to refactor it to use a preexisting path parsing library that knows how to handle some of the edge cases that can come up.
The sphere loads, but it won't show the texture properly. All I get is a black shape.
First I give the sphere code, then I give the code that will load the sphere but won't load the texture...
THE SPHERE
function createSphere( heightDivisions, pieSlices, invertNormals )
{
var normalDirection = 1 ;
if( invertNormals == undefined )
{
invertNormals = false ;
}
if( invertNormals ) normalDirection *= -1 ;
var mesh = new GLGE.Mesh() ;
var x ;
var y ;
var z ;
var radius ;
var pointCount = 0 ;
var points = Array() ;
var uv = Array() ;
for( var i = 0 ; i <= Math.PI ; i += Math.PI / heightDivisions )
{
z = 1 - Math.cos( i ) ;
radius = Math.sin( i ) ;
for( var j = 0 ; j < 2 * Math.PI ; j += 2 * Math.PI / pieSlices )
{
x = radius * Math.cos( j ) ;
y = radius * Math.sin( j ) ;
uv.push( j / ( 2 * Math.PI ) ) ;
uv.push( z ) ;
points.push( x / 2 ) ;
points.push( y / 2 ) ;
points.push( z / 2 ) ;
pointCount++ ;
}
}
mesh.setPositions( points ) ;
mesh.setUV( uv ) ;
normals = Array() ;
for( var q in points )
{
if( q % 3 == 2 )
normals.push( normalDirection * ( points[ q ] * 2 - 1 ) ) ;
else
normals.push( normalDirection * ( points[ q ] * 2 ) ) ;
}
mesh.setNormals( normals ) ;
var faces= Array() ;
var m ;
for( var l = 0 ; l < heightDivisions ; l += 1 )
{
var low = l * pieSlices ;
var high = ( l + 1 ) * pieSlices ;
for( m = 0 ; m < pieSlices - 1 ; m += 1 )
{
var lowLeft = low + m ;
var lowRight = low + m + 1 ;
var highLeft = high + m ;
var highRight = high + m + 1 ;
faces.push( lowLeft ) ;
faces.push( lowRight ) ;
faces.push( highLeft ) ;
faces.push( highLeft ) ;
faces.push( highRight ) ;
faces.push( lowRight ) ;
}
faces.push( low ) ;
faces.push( high ) ;
faces.push( high + pieSlices - 1 ) ;
faces.push( low + pieSlices - 1 ) ;
faces.push( low ) ;
faces.push( high + pieSlices - 1 ) ;
}
mesh.setFaces( faces ) ;
// alert( mesh.faces.data ) ;
return mesh ;
}
THE INVOKING CODE
var spaceTexture = new GLGE.Texture( "space" ) ;
spaceTexture.setSrc( "spaceSmall.png" ) ;
var materialLayer = new GLGE.MaterialLayer() ;
materialLayer.setTexture( spaceTexture ) ;
materialLayer.setMapinput( GLGE.UV1 ) ;
materialLayer.setMapto( GLGE.M_COLOR ) ;
var mat = new GLGE.Material() ;
mat.addTexture( spaceTexture ) ;
mat.addMaterialLayer( materialLayer ) ;
var sphereMesh = createSphere( 20, 20 ) ;
var sphereMaterial = new GLGE.Material() ;
var sphereObject = new GLGE.Object() ;
sphereObject.setMesh( sphereMesh ) ;
sphereObject.setMaterial( mat ) ;
Hey,
I just realized, that this kind of transparent materials aren't working anymore:
<material id="B_transparent" specular="0" alpha="0.5">
<texture id="b_tex" src="images/B_color.jpg"/>
<material_layer texture="#b_tex" mapto="M_COLOR" mapinput="UV1"/>
</material>
Any ideas?
There are several places in code where for..in loop is used without var keyword. Creating global variables may cause problems:
http://stackoverflow.com/questions/5717126/var-or-no-var-in-javascripts-for-in-loop
I'm trying to use point rendering, and, yes, the points are displayed. The problem is that they are 1px dots, and setting myObject.setPointSize(10), or any other number, does not change how it's displayed.
Here's how I try to use it:
myObject = doc.getElement('box');
myObject.setDrawType(GLGE.DRAW_POINTS);
myObject.setPointSize(10);
Is this a bug in GLGE, or is there something here I have missed?
I used the most recent GLGE from Github.
If you want the doc checked into the repo It would be great to have a git post-commit hook check to see if the doc needs to be re-built and if so build and commit the changes.
I'm suggesting a post-commit hook because then whatever commit you make stays whole and the commit narrative for the changes you just made aren't muddied-up by the commit changes in the doc files.
I'm looking at the glge code and considering working on i it and after cloning, changing the first line of build.js to look for node in all standard locations (my node is in /usr/local/bin);
#!/usr/bin/env node
and then after building successfully -- when I run git status it shows a long list of changes to doc files that are checked in and also a bunch that are not checked in. Unless I commit these into a branch they will show up whenever I am checking what need's to be committed.
But if I have a change and I develop it into a branch and push it to github for you to consider I don't want to include the doc changes (unless they're changes that occur because of my changes) those are your responsibility to decide when to include.
Here's what git status shows after a successful clone and build:
[glge-git (master)]$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: build.js
# modified: docs/files.html
# modified: docs/index.html
# modified: docs/symbols/GLGE.Action.html
# modified: docs/symbols/GLGE.ActionChannel.html
# modified: docs/symbols/GLGE.Animatable.html
# modified: docs/symbols/GLGE.AnimationCurve.html
# modified: docs/symbols/GLGE.AnimationVector.html
# modified: docs/symbols/GLGE.Assets.html
# modified: docs/symbols/GLGE.BezTriple.html
# modified: docs/symbols/GLGE.Camera.html
# modified: docs/symbols/GLGE.Collada.html
# modified: docs/symbols/GLGE.Document.html
# modified: docs/symbols/GLGE.Events.html
# modified: docs/symbols/GLGE.Group.html
# modified: docs/symbols/GLGE.HeightMap.html
# modified: docs/symbols/GLGE.JSONLoader.html
# modified: docs/symbols/GLGE.KeyInput.html
# modified: docs/symbols/GLGE.Light.html
# modified: docs/symbols/GLGE.LinearPoint.html
# modified: docs/symbols/GLGE.Material.html
# modified: docs/symbols/GLGE.MaterialLayer.html
# modified: docs/symbols/GLGE.Mesh.html
# modified: docs/symbols/GLGE.Message.html
# modified: docs/symbols/GLGE.MouseInput.html
# modified: docs/symbols/GLGE.MultiMaterial.html
# modified: docs/symbols/GLGE.Object.html
# modified: docs/symbols/GLGE.ObjectLod.html
# modified: docs/symbols/GLGE.ParticleSystem.html
# modified: docs/symbols/GLGE.Placeable.html
# modified: docs/symbols/GLGE.QuickNotation.html
# modified: docs/symbols/GLGE.Renderer.html
# modified: docs/symbols/GLGE.Scene.html
# modified: docs/symbols/GLGE.StepPoint.html
# modified: docs/symbols/GLGE.Text.html
# modified: docs/symbols/GLGE.Texture.html
# modified: docs/symbols/GLGE.TextureCamera.html
# modified: docs/symbols/GLGE.TextureCanvas.html
# modified: docs/symbols/GLGE.TextureCube.html
# modified: docs/symbols/GLGE.TextureVideo.html
# modified: docs/symbols/GLGE.Wavefront.html
# modified: docs/symbols/GLGE.html
# modified: docs/symbols/_global_.html
# modified: docs/symbols/src/src_core_glge.js.html
# modified: docs/symbols/src/src_core_glge_math.js.html
# modified: docs/symbols/src/src_extra_glge_collada.js.html
# modified: docs/symbols/src/src_extra_glge_filter2d.js.html
# modified: docs/symbols/src/src_extra_glge_wavefront.js.html
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# devtemplate.html
# docs/symbols/GLGE.FilterGlow.html
# docs/symbols/src/src_animation_glge_action.js.html
# docs/symbols/src/src_animation_glge_actionchannel.js.html
# docs/symbols/src/src_animation_glge_animationcurve.js.html
# docs/symbols/src/src_animation_glge_animationpoints.js.html
# docs/symbols/src/src_animation_glge_animationvector.js.html
# docs/symbols/src/src_core_glge_animatable.js.html
# docs/symbols/src/src_core_glge_document.js.html
# docs/symbols/src/src_core_glge_event.js.html
# docs/symbols/src/src_core_glge_group.js.html
# docs/symbols/src/src_core_glge_jsonloader.js.html
# docs/symbols/src/src_core_glge_messages.js.html
# docs/symbols/src/src_core_glge_placeable.js.html
# docs/symbols/src/src_core_glge_quicknote.js.html
# docs/symbols/src/src_extra_filters_glge_filter_glow.js.html
# docs/symbols/src/src_geometry_glge_mesh.js.html
# docs/symbols/src/src_material_glge_material.js.html
# docs/symbols/src/src_material_glge_materiallayer.js.html
# docs/symbols/src/src_material_glge_multimaterial.js.html
# docs/symbols/src/src_material_glge_texture.js.html
# docs/symbols/src/src_material_glge_texturecamera.js.html
# docs/symbols/src/src_material_glge_texturecanvas.js.html
# docs/symbols/src/src_material_glge_texturecube.js.html
# docs/symbols/src/src_material_glge_texturevideo.js.html
# docs/symbols/src/src_renderable_glge_lod.js.html
# docs/symbols/src/src_renderable_glge_object.js.html
# docs/symbols/src/src_renderable_glge_text.js.html
# docs/symbols/src/src_renders_glge_renderer.js.html
# docs/symbols/src/src_scene_glge_camera.js.html
# docs/symbols/src/src_scene_glge_light.js.html
# docs/symbols/src/src_scene_glge_scene.js.html
no changes added to commit (use "git add" and/or "git commit -a")
the preload gui's layout is wrong
some times
anim_gal2 -- I have to rotate by half of what makes sense -- ie, a rotation of 1.57 is 180 degrees (instead of 90)
also, as I move her around, the center of rotation changes
Hello,
the latest rtt_cubemap demo won't run as stats.js changed a bit. Below you can find the patch that updates it to the latest version.
https://raw.github.com/gist/2653814/6dd363d0db07434ed40aaa9f62789a4d906f70e6/stats.patch
Steps to reproduce:
Error: uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http://localhost:8026/files/glge/glge-compiled.js :: <TOP_LEVEL> :: line 8988" data: no]
8987 try{gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);}
8988 catch(e){gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE,canvas,null);}
Does not happen in Chrome.
Congratulations and thanks for version 0.8
This is sort of important
POINT lights seem not to work at all in google-chrome, starting with checkin 5b73.
I ran into this problem when trying to load a model from another domain. The .dae came in fine, but a security error happened when trying to render the texture. Last year, CORS for webgl textures was briefly disabled because it actually was a security risk, but now Chrome and FF currently support the crossorigin
attribute on Image
to circumvent the problem.
I was able to bypass this issue by modifying GLGE.Texture.prototype.setSrc
as following:
// ... snip ...
this.image=new Image();
this.image.crossOrigin = "anonymous"; // Allow cross-domain resource sharing for image
// ..rest of code ...
I'm not sure if this is by design or an oversight; however, any clarification would greatly be appreciated. Thanks!
People in this forum are reporting that animated models "flickers when I move about and doesn't display otherwise" in the latest version of Firefox.
http://www.gamedev.net/topic/615504-embedding-3d-content-in-the-forums/#entry4886459
Hello,
I'm having an issue where when picking a collada object, getId() won't return its #id, but the name of the instance geometry of the model. I was wondering if that's intentional or a bug. Meshes, MD2 models pick the right ID.
Thank you in advance,
John
When using GLGE.Group.prototype.getBoundingVolume() the applyMatrixScale gets applied multiple times causing the end boundingVolume scale to be incorrect.
For instance a call to getBoundingVolume() on a regular Collada object that has a depth of 5 (this->child->child->child->child) yielded this bounding volume:
center: Array[3]
0: 0.06825499999999998
1: 0
2: 0.8567349999999996
dims: Array[3]
0: 0.43662999999999996
1: 6.64572
2: 5.8684899999999995
Then setting the Scale of that Collada object to 2x if you call getBoundingVolume() on that Collada object it can be scaled more than 2x.
Prop Scale 2x
center: Array[3]
0: 2.1841599999999994
1: 0
2: 27.415519999999987
dims: Array[3]
0: 13.972159999999999
1: 212.66304
2: 187.79167999999999
If we take dims[2] we can see exactly how much scaling was done.
5.8684899999999995 * 2 * 2 * 2 * 2 * 2 = 187.79167999999999
I have node installed at: /usr/local/bin/node
This change to ./build.js should make the build script work if node is installed anywhere reasonable.
[glge-git (master)]$ git diff build.js
diff --git a/build.js b/build.js
index e8ec88b..ce32d28 100755
--- a/build.js
+++ b/build.js
@@ -1,4 +1,4 @@
-#!/usr/bin/node
+#!/usr/bin/env node
/*
GLGE WebGL Graphics Engine
Copyright (c) 2010, Paul Brunt
Apparently when there are many objects using the same material or texture, the texture display can flicker: sometimes the texture shows, sometimes drops to black, depending on the point of view.
This happens at least when the texture has alpha transparency.
A demo of the bug: http://www.realxtend.org/webnaali/flickerbug.html
I think I got it without alpha texture transparency too but that is unconfirmed, may try to make another test case about that. But would be great to get this fixed also when alpha transparency is used.
Oh: I got this with Chrome 16.0.912.77 on Linux (with nvidia proprietary drivers) but apparently it does not happen with Firefox 9.0.1 on the same machine
Objects that have zTransparent(true) and that are closer to the camera than particle system disappears from the view when I call reset(). I try figure out whats wrong and probably gl.useProgram() in GLGE.ParticleSystem.prototype.GLRender() overrides shader program, and then GLGE.Object.prototype.GLRender() doesn't change it.
When I click the https://github.com/downloads/supereggbert/GLGE/GLGEv0.9.zip link it keeps saying that the file does not exist. I tried on a few different computers. All the other downloads work just fine.
On most recent Webkit and Chrome dev but it works in Firefox 4b
Shows up like normal but when I click the cube everything inside the Webgl frame turns grey
Results from bisect:
279a130 is first bad commit
commit 279a130
Author: Paul Brunt [email protected]
Date: Mon May 3 11:45:05 2010 +0100
added soft shadows
:100755 100755 1923dc41d157ba386b1daaf817e8372feed2f53d c06e7996a4d7105954c0c4bd68fa3250b1a67f2b M glge.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.