<commit_before>package h2d;

/**
	Allows a 2D object position to follow a 3D object using the current camera.
**/
@:uiNoComponent
class ObjectFollower extends Object {

	public var follow : h3d.scene.Object;
	public var pixelSnap = true;
	public var followVisibility = false;
	public var offsetX = 0.;
	public var offsetY = 0.;
	public var offsetZ = 0.;

	public var horizontalAlign : h2d.Flow.FlowAlign = Left;
	public var verticalAlign : h2d.Flow.FlowAlign = Top;

	public function new( obj, ?parent ) {
		super(parent);
		this.follow = obj;
	}

	function followObject() {
		if( follow == null )
			return;
		var scene = @:privateAccess follow.getScene();
		if( scene == null )
			return;
		var s2d = getScene();
		var width = s2d == null ? h3d.Engine.getCurrent().width : s2d.width;
		var height = s2d == null ? h3d.Engine.getCurrent().height : s2d.height;
		var absPos = follow.getAbsPos();
		var p = scene.camera.project(absPos._41 + offsetX, absPos._42 + offsetY, absPos._43 + offsetZ, width, height);
		visible = p.z > 0;

		if( horizontalAlign != Left || verticalAlign != Top ) {
			var prev = follow;
			follow = null;
			var b = getBounds(this); // prevent recursive
			follow = prev;

			var w = b.width, h = b.height;<commit_msg>use getSize() instead of getBounds() for alignment<commit_after>package h2d;

/**
	Allows a 2D object position to follow a 3D object using the current camera.
**/
@:uiNoComponent
class ObjectFollower extends Object {

	public var follow : h3d.scene.Object;
	public var pixelSnap = true;
	public var followVisibility = false;
	public var offsetX = 0.;
	public var offsetY = 0.;
	public var offsetZ = 0.;

	public var horizontalAlign : h2d.Flow.FlowAlign = Left;
	public var verticalAlign : h2d.Flow.FlowAlign = Top;

	public function new( obj, ?parent ) {
		super(parent);
		this.follow = obj;
	}

	function followObject() {
		if( follow == null )
			return;
		var scene = @:privateAccess follow.getScene();
		if( scene == null )
			return;
		var s2d = getScene();
		var width = s2d == null ? h3d.Engine.getCurrent().width : s2d.width;
		var height = s2d == null ? h3d.Engine.getCurrent().height : s2d.height;
		var absPos = follow.getAbsPos();
		var p = scene.camera.project(absPos._41 + offsetX, absPos._42 + offsetY, absPos._43 + offsetZ, width, height);
		visible = p.z > 0;

		if( horizontalAlign != Left || verticalAlign != Top ) {
			var prev = follow;
			follow = null;
			var b = getSize(); // prevent recursive
			follow = prev;

			var w = b.width, h = b.height;
{'fraction_non_alphanumeric': 0.12335853561480302, 'fraction_numerical': 0.01830481496219658, 'mean_word_length': 3.481283422459893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5409446', 'n_tokens_mistral': 913, 'n_tokens_neox': 831, 'n_words': 265}