Browse Source

fix when meshspray not at origin

Nicolas Cannasse 4 years ago
parent
commit
55d50c8e77
1 changed files with 6 additions and 2 deletions
  1. 6 2
      hrt/prefab/l3d/MeshSpray.hx

+ 6 - 2
hrt/prefab/l3d/MeshSpray.hx

@@ -39,13 +39,17 @@ class MeshSpray extends Object3D {
 			return ctx;
 		ctx = super.make(ctx);
 		var mspray = Std.downcast(ctx.local3d, MeshSprayObject);
-		for( b in mspray.batches )
+		var pos = mspray.getAbsPos();
+		var tmp = new h3d.Matrix();
+		for( b in mspray.batches ) {
 			b.begin();
+			b.worldPosition = tmp;
+		}
 		for( c in children ) {
 			if( !c.enabled || c.type != "model" )
 				continue;
 			var batch = mspray.batchesMap.get(c.source);
-			batch.worldPosition = c.to(Object3D).getTransform();
+			tmp.multiply3x4(c.to(Object3D).getTransform(), pos);
 			batch.emitInstance();
 		}
 		for( b in mspray.batches )