瀏覽代碼

correctly init camera screen ratio before entering render()

ncannasse 9 年之前
父節點
當前提交
f32e5de90a
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      h3d/scene/Scene.hx

+ 4 - 0
h3d/scene/Scene.hx

@@ -18,6 +18,10 @@ class Scene extends Object implements h3d.IDrawable implements hxd.SceneEvents.I
 		hitInteractives = [];
 		hitInteractives = [];
 		interactives = [];
 		interactives = [];
 		camera = new h3d.Camera();
 		camera = new h3d.Camera();
+		// update ratio before render (prevent first-frame difference)
+		var engine = h3d.Engine.getCurrent();
+		if( engine != null )
+			camera.screenRatio = engine.width / engine.height;
 		ctx = new RenderContext();
 		ctx = new RenderContext();
 		renderer = new Renderer();
 		renderer = new Renderer();
 		lightSystem = new h3d.pass.LightSystem();
 		lightSystem = new h3d.pass.LightSystem();