Bonjour,

Je travaille actuellement en Web GL ( biblioteque gwt-g3d) et j'affiche actuellement plusieurs cubes. Mais l'affichage de ces cubes est très lent (14 fps pour 5 cube) et avec 1 cube je tombe déjà à 40 fps. J'utilise un Lambertian Shader. la métode qui semble faire ramer est :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
shader.setProjectionMatrix(MODELVIEW.get());
voici le Main (non complet juste le code qui correspond à la 3D):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
public class Test implements EntryPoint{
	private GL2 gl;
	private Surface3D surface;
	private LambertianShader shader;
	private float posX =0, posY=0, posZ = 10;
	private float yaw, yawRate;
	private float pitch, pitchRate;
	private float speed;
	private ArrayList<Objet3D> listeObjet= new ArrayList<Objet3D>();
	private final KeyboardManager keyboardManager = new KeyboardManager();
	//private boolean MouseLeftClicked = false;
 
 
 
	/**
         * This is the entry point method.
         */	public void onModuleLoad() {
		  // Adds a canvas to the document.
		  surface = new Surface3D(500, 500);
		  surface.setPixelSize(surface.getWidth(), surface.getHeight());
 
		  RootPanel.get("section").add(surface);
 
		  keyboardManager.manage(surface);
		  keyboardManager.setPreventDefault(true);
		  gl = surface.getGL();
 
		  if (gl == null) {
		    Window.alert("No WebGL context found. Exiting.");
		    return;
		  }
		  // Sets up the GL context.
		  gl.clearColor(0.7f, 0.9f, 1.0f,1.0f);
		  gl.clearDepth(1);
		  gl.viewport(0, 0, surface.getWidth(), surface.getHeight());
		  gl.enable(EnableCap.DEPTH_TEST);
		  gl.depthFunc(DepthFunction.LEQUAL);
		  gl.clear(ClearBufferMask.COLOR_BUFFER_BIT, ClearBufferMask.DEPTH_BUFFER_BIT);
		  // Creates a lambertian shader.
		  shader = new LambertianShader();
		  try {
		      shader.init(gl);
		    } catch (ShaderException e) {
		      Window.alert(e.getMessage());
		      return;
		    }
		    shader.bind();
 
		   listeObjet.add(new Cube(gl, shader, new Vector3f(0, 0, 0), 2, 2, 2, new Vector4f(.9f, .2f, .2f, 1f)));
		   listeObjet.add(new Cube(gl, shader, new Vector3f(0, -5, 0), 2, 2, 2, new Vector4f(.2f, .8f, .2f, 1f)));
		   listeObjet.add(new Cube(gl, shader, new Vector3f(0, 5, 0), 2, 2, 2, new Vector4f(0.7f, .1f, 0.7f, 1f)));
	       listeObjet.add(new Cube(gl, shader, new Vector3f(5, 0, 0), 2, 2, 2, new Vector4f(0.7f, .1f, 0.7f, 1f)));
		   listeObjet.add(new Cube(gl, shader, new Vector3f(-5, 0, 0), 2, 2, 2, new Vector4f(0.7f, .1f, 0.7f, 1f)));
 
 
		    shader.setDiffuseColor(.9f, .2f, .2f, 1f);
		    shader.setLightPosition(0, 0, 5);
 
		    PROJECTION.pushIdentity();
		    PROJECTION.perspective(30, 1, 1, 10000);
		    shader.setProjectionMatrix(PROJECTION.get());
		    PROJECTION.pop();    
 
		    update();
		    FpsTimer timer = new FpsTimer(60)
			{
				@Override
				public void update()
				{
					System.out.println(""+getFps());
					Test.this.update();
				}
			};
			timer.start();
 
 
		}
 
	public void update() {
		handleKeys();
	    gl.clear(ClearBufferMask.COLOR_BUFFER_BIT, ClearBufferMask.DEPTH_BUFFER_BIT);
	   // System.out.println("X = "+posX+" Y = "+posY+" Z = "+posZ+"  AngleX = "+pitch+" AngleY = "+yaw);
	    MODELVIEW.push();
	    MODELVIEW.rotateX((float) Math.toRadians(-pitch));
	    MODELVIEW.rotateY((float) Math.toRadians(-yaw));
	    MODELVIEW.translate(-posX, -posY, -posZ);
	    shader.setModelViewMatrix(MODELVIEW.get());
	    for(Objet3D myObjet3d:listeObjet)
	    {
	    	myObjet3d.draw();
	    }
 
	    MODELVIEW.pop();
 
 
 
	    float elapsed = 60f;
	    if (speed != 0) {
	        posX -= (float) (Math.sin(Math.toRadians(yaw)) * speed * elapsed);
	        posZ -= (float) (Math.cos(Math.toRadians(yaw)) * speed * elapsed);
	    }
Et la classe cube qui creer un Static mesh box et s'occupe de l'affichage de celle-ci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
public class Cube extends Formes3D {
 
		private float hauteur, largeur, profondeur;
 
 
		protected Cube(GL2 gl, LambertianShader shader,Vector3f pos, float _hauteur, float _largeur, float _profondeur, Vector4f color) 
		{
			super(gl, shader, color, pos);
			hauteur = _hauteur;
			largeur = _largeur;
			profondeur = _profondeur;
			mesh = new StaticMesh(gl, PrimitiveFactory.makeBox());
			mesh.setPositionIndex(shader.getAttributePosition());
			mesh.setNormalIndex(shader.getAttributeNormal());
 
		}
 
		@Override
		protected void draw() {
			shader.setDiffuseColor(color);
			MODELVIEW.push();
			MODELVIEW.translate(position.x, position.y, position.z);
			MODELVIEW.scale(largeur, hauteur, profondeur);
			gl.uniformMatrix(shader.getUniformLocation("uModelViewMatrix"), MODELVIEW.get());
			MODELVIEW.pop();
			mesh.draw();
 
 
 
 
		}
 
}
Es-que quelqu’un à une idée d'où le problème peut venir ?

Merci d'avance.