Quellcode durchsuchen

fixed delay in Envmap loading + added Context.setCurrent

Nicolas Cannasse vor 5 Jahren
Ursprung
Commit
5bdae454d7
2 geänderte Dateien mit 18 neuen und 2 gelöschten Zeilen
  1. 6 0
      hrt/prefab/Context.hx
  2. 12 2
      hrt/prefab/l3d/Environment.hx

+ 6 - 0
hrt/prefab/Context.hx

@@ -83,4 +83,10 @@ package hrt.prefab;
 		return root;
 	}
 
+	#if editor
+	public function setCurrent() {
+		cast(shared, hide.prefab.ContextShared).scene.setCurrent();
+	}
+	#end
+
 }

+ 12 - 2
hrt/prefab/l3d/Environment.hx

@@ -132,7 +132,7 @@ class Environment extends Object3D {
 
 		if( bakedDiffSize != diffSize || bakedSpecSize != specSize || bakedIgnoredSpecLevels != ignoredSpecLevels || bakedSampleBits != sampleBits || bakedThreshold != threshold || bakedScale != scale )
 			return false;
-		
+
 		var lutSize = hxd.Pixels.calcStride(env.lut.width, env.lut.format) * env.lut.height;
 		if( curPos + lutSize > bytes.length ) return false;
 		var lutBytes = bytes.sub(curPos, lutSize);
@@ -191,6 +191,16 @@ class Environment extends Object3D {
 		if( sourceMap == null )
 			return;
 
+		#if editor
+		if( sourceMap.flags.has(Loading) ) {
+			haxe.Timer.delay(function() {
+				ctx.setCurrent();
+				updateInstance(ctx,propName);
+			},100);
+			return;
+		}
+		#end
+
 		var needCompute = false;
 
 		if( env == null ) {
@@ -245,7 +255,7 @@ class Environment extends Object3D {
 
 	public function applyToRenderer( r : h3d.scene.Renderer) {
 		var r = Std.downcast(r, h3d.scene.pbr.Renderer);
-		if( r != null ) 
+		if( r != null )
 			r.env = env;
 	}