I made a function that if a mesh is big, it is splitting it into peaces of 65535 vertices, and takes 65535/3 of the index coordinates, from the x3d file. works fine, I don't understand why every triangle has to have 3 vertices though, as you say, some vertices are shared by more then one triangle, no point in writing them twice, I really don't understand why the exporter of x3d from 3d max is writing the file this way, maybe it is part of the xd3 file format, and maybe it is a limitation of the exporter, don't know.
Anyway I have another problem. when you rotate the object, you have to rotate the light direction you use in the Fragment shader, otherwise the light will rotate with the object as if it is a spot of color on the object, so I did rotate it, but then if I use a very small object the light spot is not steady while you rotate the object, it dances around, I guess when the calculation is done with very small numbers, with many numbers over the floating point, that makes the output very inaccurate.
maybe this is not the reason, but I can't think of anything else.
here is the code I use to rotate and move the light source to it's correct position, maybe someone can show me a better way to do it.
first I get the rotation and position changes stored in the object, and the groups it belongs to, in a Matrix3D called "drawMatrix":
var tmp:Object3D = obj;
tmp = tmp.Parent;
now I use this matrix to rotate and move the light:
var m:Vector.<Number> = obj.modelToWorld.rawData;
//I begin by setting the light position it it's original place I have to
//change the position in accordance of the object, don't know exactly why but
//this is the only way it works.
obj.LightPos = new Vector3D();
obj.LightPos.x = -(sceneLight.Position.x - m);
obj.LightPos.y = -(sceneLight.Position.y - m);
obj.LightPos.z = sceneLight.Position.z - m;
obj.LightPos.w = sceneLight.Position.w;
//now I do the adjustment
obj.LightDir = new Matrix3D();
obj.LightPos = obj.LightDir.transformVector(obj.LightPos);
any help would be appreciated