Skip to content

Commit

Permalink
Haxe 4.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Nov 10, 2023
1 parent e070e3e commit be7c926
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 43 deletions.
101 changes: 64 additions & 37 deletions away3d/containers/View3D.hx
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,10 @@ class View3D extends Sprite
/**
* Not supported. Use filters3d instead.
*/
@:getter(filters)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function get_filters():Array<BitmapFilter>
@:getter(filters) private #if (!flash && !display) override #end function get_filters():Array<BitmapFilter>
#else
private #if !flash override #end function get_filters():Array<BitmapFilter>
#if (flash && haxe_ver < 4.3) @:getter(filters) #else override #end private function get_filters():Array<BitmapFilter>
#end
{
throw new Error("filters is not supported in View3D. Use filters3d instead.");
Expand All @@ -493,44 +492,49 @@ class View3D extends Sprite
/**
* Not supported. Use filters3d instead.
*/
@:setter(filters)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function set_filters(value:Array<BitmapFilter>)
@:setter(filters) private #if (!flash && !display) override #end function set_filters(value:Array<BitmapFilter>)
#else
private #if !flash override #end function set_filters(value:Array<BitmapFilter>)
#if (flash && haxe_ver < 4.3) @:setter(filters) #else override #end private function set_filters(value:Array<BitmapFilter>):#if (!flash || haxe_ver >= 4.3) Array<BitmapFilter> #else Void #end
#end
{
throw new Error("filters is not supported in View3D. Use filters3d instead.");
#if !flash return value; #end
#if (!flash || haxe_ver >= 4.3)
return value;
#end
}

/**
* The width of the viewport. When software rendering is used, this is limited by the
* platform to 2048 pixels.
*/
@:getter(width)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function get_width():Float
@:getter(width) private #if (!flash && !display) override #end function get_width():Float
#else
private #if !flash override #end function get_width():Float
#if (flash && haxe_ver < 4.3) @:getter(width) #else override #end private function get_width():Float
#end
{
return _width;
}

@:setter(width)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function set_width(value:Float)
@:setter(width) private #if (!flash && !display) override #end function set_width(value:Float)
#else
private #if !flash override #end function set_width(value:Float)
#if (flash && haxe_ver < 4.3) @:setter(width) #else override #end private function set_width(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end
#end
{
// Backbuffer limitation in software mode. See comment in updateBackBuffer()
if (_stage3DProxy != null && _stage3DProxy.usesSoftwareRendering && value > 2048)
value = 2048;

if (_width == value)
#if flash return #else return value #end;
{
#if (!flash || haxe_ver >= 4.3)
return value;
#else
return;
#end
}

_hitField.width = value;
_width = value;
Expand All @@ -552,36 +556,42 @@ class View3D extends Sprite
_backBufferInvalid = true;
_scissorRectDirty = true;

#if !flash return value; #end
#if (!flash || haxe_ver >= 4.3)
return value;
#end
}

/**
* The height of the viewport. When software rendering is used, this is limited by the
* platform to 2048 pixels.
*/
@:getter(height)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function get_height():Float
@:getter(height) private #if (!flash && !display) override #end function get_height():Float
#else
private #if !flash override #end function get_height():Float
#if (flash && haxe_ver < 4.3) @:getter(height) #else override #end private function get_height():Float
#end
{
return _height;
}

@:setter(height)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function set_height(value:Float)
@:setter(height) private #if (!flash && !display) override #end function set_height(value:Float)
#else
private #if !flash override #end function set_height(value:Float)
#if (flash && haxe_ver < 4.3) @:setter(height) #else override #end private function set_height(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end
#end
{
// Backbuffer limitation in software mode. See comment in updateBackBuffer()
if (_stage3DProxy != null && _stage3DProxy.usesSoftwareRendering && value > 2048)
value = 2048;

if (_height == value)
#if flash return #else return value #end;
{
#if (!flash || haxe_ver >= 4.3)
return value;
#else
return;
#end
}

_hitField.height = value;
_height = value;
Expand All @@ -603,60 +613,77 @@ class View3D extends Sprite
_backBufferInvalid = true;
_scissorRectDirty = true;

#if !flash return value; #end
#if (!flash || haxe_ver >= 4.3)
return value;
#end
}

@:setter(x)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function set_x(value:Float)
@:setter(x) private #if (!flash && !display) override #end function set_x(value:Float)
#else
private #if !flash override #end function set_x(value:Float)
#if (flash && haxe_ver < 4.3) @:setter(x) #else override #end private function set_x(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end
#end
{
if (x == value)
#if flash return #else return value #end;
{
#if (!flash || haxe_ver >= 4.3)
return value;
#else
return;
#end
}

super.x = value;
_localTLPos.x = value;

_globalPos.x = parent != null ? parent.localToGlobal(_localTLPos).x : value;
_globalPosDirty = true;

#if !flash return value; #end
#if (!flash || haxe_ver >= 4.3)
return value;
#end
}

@:setter(y)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function set_y(value:Float)
@:setter(y) private #if (!flash && !display) override #end function set_y(value:Float)
#else
private #if !flash override #end function set_y(value:Float)
#if (flash && haxe_ver < 4.3) @:setter(y) #else override #end private function set_y(value:Float):#if (!flash || haxe_ver >= 4.3) Float #else Void #end
#end
{
if (y == value)
#if flash return #else return value #end;
{
#if (!flash || haxe_ver >= 4.3)
return value;
#else
return;
#end
}

super.y = value;
_localTLPos.y = value;

_globalPos.y = parent != null ? parent.localToGlobal(_localTLPos).y : value;
_globalPosDirty = true;

#if !flash return value; #end
#if (!flash || haxe_ver >= 4.3)
return value;
#end
}

@:setter(visible)
#if (openfl < "8.0.0")
private #if (!flash && !display) override #end function set_visible(value:Bool)
@:setter(visible) private #if (!flash && !display) override #end function set_visible(value:Bool)
#else
private #if !flash override #end function set_visible(value:Bool)
#if (flash && haxe_ver < 4.3) @:setter(visible) #else override #end private function set_visible(value:Bool):#if (!flash || haxe_ver >= 4.3) Bool #else Void #end
#end
{
super.visible = value;

if (_stage3DProxy!=null && !_shareContext)
_stage3DProxy.visible = value;

#if !flash return value; #end
#if (!flash || haxe_ver >= 4.3)
return value;
#end
}

/**
Expand Down
2 changes: 1 addition & 1 deletion away3d/events/MouseEvent3D.hx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class MouseEvent3D extends Event
* @inheritDoc
*/
#if flash
@:getter(bubbles) function get_bubbles():Bool
#if (haxe_ver < 4.3) @:getter(bubbles) #else override #end private function get_bubbles():Bool
{
var doesBubble:Bool = super.bubbles && _allowedToPropagate;
_allowedToPropagate = true;
Expand Down
4 changes: 2 additions & 2 deletions away3d/events/Scene3DEvent.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package away3d.events;
import away3d.containers.ObjectContainer3D;

import openfl.events.Event;
import openfl.utils.Object;

class Scene3DEvent extends Event
{
Expand All @@ -12,9 +13,8 @@ class Scene3DEvent extends Event

public var objectContainer3D:ObjectContainer3D;

//@:getter(target)
#if flash
private function get_target():Dynamic {
#if (haxe_ver < 4.3) @:getter(target) #else override #end private function get_target(): #if (openfl >= "9.2.0") Object #else Dynamic #end {
return objectContainer3D;
}
#end
Expand Down
4 changes: 2 additions & 2 deletions away3d/events/TouchEvent3D.hx
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class TouchEvent3D extends Event
* @inheritDoc
*/
#if flash
@:getter(bubbles) function get_bubbles():Bool
#if (haxe_ver < 4.3) @:getter(bubbles) #else override #end private function get_bubbles():Bool
{
// Don't bubble if propagation has been stopped.
return this.bubbles && _allowedToPropagate;
return super.bubbles && _allowedToPropagate;
}
#end

Expand Down
2 changes: 1 addition & 1 deletion away3d/textures/Anisotropy.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package away3d.textures;

@:enum abstract Anisotropy(Null<Int>)
#if (haxe_ver >= 4.0) enum #else @:enum #end abstract Anisotropy(Null<Int>)
{
public var NONE = 0;
public var ANISOTROPIC2X = 1;
Expand Down

1 comment on commit be7c926

@ConfidantCommunications

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please sign in to comment.