How to bind haxe function to js and get js native this?

how to bind haxe function to js and get js native this?


three_Mesh.prototype.raycast = Main_raycast;



function raycast(raycaster:Raycaster, intersects:Dynamic) {

	trace('ok this'+this);//will throw **Cannot access this from a static function**
	
}

and try putinto class

Mesh.prototype.raycast = cast three2.objects.Mesh.prototype.raycast;//is this right bind get native this?

//Mesh.hx

override function raycast(raycaster:Raycaster, intersects:Array<Intersection<Object3D>>):Void {

       trace(this);//this isn't native this. this is global ,how to get native this?
}

Hej,

Maybe you’re looking for that ? js.Lib.nativeThis js.Lib - Haxe 4.2.1 API

2 Likes