瀏覽代碼

Add null check for ctx.camera.

borisrp 2 月之前
父節點
當前提交
54a60a89cb
共有 1 個文件被更改,包括 5 次插入3 次删除
  1. 5 3
      h3d/scene/pbr/Renderer.hx

+ 5 - 3
h3d/scene/pbr/Renderer.hx

@@ -474,9 +474,11 @@ class Renderer extends h3d.scene.Renderer {
 		ctx.setGlobal("ldrMap", textures.ldr);
 		ctx.setGlobal("velocity", textures.velocity);
 		ctx.setGlobal("global.time", ctx.time);
-		ctx.setGlobal("camera.position", ctx.camera.pos);
-		ctx.setGlobal("camera.inverseViewProj", ctx.camera.getInverseViewProj());
-		ctx.setGlobal("camera.inverseView", ctx.camera.getInverseView());
+		if(ctx.camera != null){
+			ctx.setGlobal("camera.position", ctx.camera.pos);
+			ctx.setGlobal("camera.inverseViewProj", ctx.camera.getInverseViewProj());
+			ctx.setGlobal("camera.inverseView", ctx.camera.getInverseView());
+		}
 	}
 
 	function beginPbr() {