Giter VIP home page Giter VIP logo

away3d's Introduction

MIT License Haxelib Version Build Status Community Discord Server


Introduction

The OpenFL project is an open-source answer to the needs of game and application developers everywhere, looking for a fast, simple approach to delivering creative masterpieces without relying on a specific implementation, such as a browser plugin.

Using the innovative Haxe programming language, OpenFL supports wildly different platforms using one codebase. Transitioning from one target type to another is simple, and keeps the strengths of the target environment. OpenFL builds to native C++, Neko or Flash bytecode, or JavaScript, enabling maximum compatibility and runtime performance.

OpenFL depends on Lime, which has easy-to-use command-line tools, and provides backend support.

Platforms

Currently, OpenFL supports the following platforms:

  • iOS
  • Android
  • HTML5
  • Windows
  • macOS
  • Linux
  • Flash
  • AIR

There is also a community effort to bring OpenFL to consoles, OpenFL is running on:

  • Switch
  • Wii U
  • PlayStation 4
  • PlayStation 3
  • PlayStation Vita
  • Xbox One

Additional details on console support will be available in the future.

OpenFL is also being used in additional environments:

  • TiVo boxes
  • Raspberry Pi
  • Node.js

Libraries

OpenFL is compatible with many libraries, ported from ActionScript or written originally in Haxe, including:

OpenFL also powers other platforms, such as Stencyl.

Code Editors

Plugins have been written for many code editors, but the most popular editors used for Haxe and OpenFL development are:

Easy Deployment

OpenFL includes the tools you need to build, package, install and run on each target platform.

For example, openfl test html5 will generate an HTML5 project, create a local web server and open your default browser.

Some platforms will require a standard SDK to build (such as Visual Studio C++ or Xcode). OpenFL includes "setup" commands to even help the install of these standard tools.

3D Support

OpenFL is designed primarily for 2D development, but you can use the OpenGLRenderer API to write your own WebGL-style code, and mix it with the OpenFL display architecture.

OpenFL also has support for the Stage3D API. If you like you can use this directly, or you can also use libraries such as Away3D or Starling.

Native Extensions

When you target a native platform, the output is true native C++, enabling deep integration with platform features and third-party SDKs. There is a standard Haxe "CFFI" API for connecting Haxe classes directly to C++ libraries.

We have also developed a straight-forward Android library project API for adding Java-based extensions, too. Native extensions can also use the standard Lime project format, for flexible control over dependencies, adding additional assets or tuning the output of your project.

The result are native extensions that can be made to interchangeably drop into projects, without breaking one another. We have made no attempt to emulate the system for AIR native extensions, which are much more difficult to create and less flexible.

Core Components

OpenFL relies upon Lime, a foundation for cross-platform project development.

hxcpp is used automatically by the Lime tools to manage the C++ compilation process for each platform, and to provide the Haxe standard library for C++ support.

License

OpenFL is free, open-source software under the MIT license.

Installing OpenFL

Follow the directions at openfl.org.

Development Builds

When there are changes, OpenFL is built nightly. Builds are available for download here.

To install a development build, use the "haxelib local" command:

haxelib local openfl-haxelib.zip

Building from Source

Clone the OpenFL repository:

git clone https://github.com/openfl/openfl

Tell haxelib where your development copy of OpenFL is installed:

haxelib dev openfl openfl

To return to release builds:

haxelib dev openfl

You may also need a development build of Lime installed.

away3d's People

Contributors

arlez80 avatar aw4kening avatar greg209 avatar hoothin avatar jasonsturges avatar jgranick avatar joshtynjala avatar longde123 avatar modjke avatar player-03 avatar rainyt avatar rakuten avatar rob-bateman avatar sleep2death avatar tbyrne-imag avatar tesract avatar type1j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

away3d's Issues

Basic_SkyBox example is crashing

(First up, can I just say that I'm really excited to see Away3D getting some updates recently?!)

Just letting you know that environment mapping crashes right now. You can see this happening by trying to compile and run the Basic_SkyBox example. It produces this error:

Error: Error #3653: AGAL validation failed: Destination writemask is zero for destination operand at token 2 of fragment program.
	at flash.display3D::Program3D/upload()
	at away3d.core.managers::AGALProgram3DCache/setProgram3D()
	at away3d.materials.passes::MaterialPassBase/updateProgram()
	at away3d.materials.passes::CompiledPass/updateProgram()
	at away3d.materials.passes::MaterialPassBase/activate()
	at away3d.materials.passes::CompiledPass/activate()
	at away3d.materials.passes::SuperShaderPass/activate()
	at away3d.materials::MaterialBase/activatePass()
	at away3d.core.render::DefaultRenderer/drawRenderables()
	at away3d.core.render::DefaultRenderer/draw()

(I've actually gotten this error with a few different things I've tried in this version of away3d, but this example is the easiest way to replicate it. I'm fully updated as of this post, using openfl 4.7.3 and lime 3.7.2.)

`ParticleGeometryHelper` creates one particle per subgeometry.

Away3D was never particularly well-documented, so perhaps this shouldn't be a surprise. Documentation on particles seems to be limited to one article that doesn't even mention subgeometries.

The first thing we need for particles is a set of geometries. Each element of this set will represent a particle. You can use any geometry in the set; a built-in geometry primitive provided by Away3D or an external geometry loaded from a file.

This seems to indicate that each Geometry corresponds to a single particle, but ParticleGeometryHelper instead creates a new particle per subgeometry. This isn't intuitive as a user, and it also makes ParticleGeometryHelper that much more complicated.

Different rendering for Neko and HTML5

Hello Joshua,
Thank you for the previous fix. Now Neko is working well with the correct animation (like in flash). But unfortunately in html5 mesh is still "floating" (It looks like rubber bear with water inside). Maybe the last video didn't show it well, so I recorded another one (left bear is running on Neko and looks good, the right one is on html5 and looks wrong).
Two bears.zip
If you don't have such effect can you tell me what version of Lime and Openfl are in use? Which version of a browser are you running this example on (I tried the latest version of Lime and OpenFL, Chrome and Firefox)? This will be very helpful.
Thank you in advance.

Add Missing MouseEvent3D Events

I have modified Mouse3Dmanager.hx & MouseEvent3D.hx based on the as code here to incorporate the missing MouseEvent3D events...

MouseEvent.MIDDLE_CLICK, onMouseMiddleClick
MouseEvent.MIDDLE_MOUSE_UP, onMouseMiddleUp
MouseEvent.MIDDLE_MOUSE_DOWN, onMouseMiddleDown
MouseEvent.RIGHT_CLICK, onMouseRightClick
MouseEvent.RIGHT_MOUSE_UP, onMouseRightUp
MouseEvent.RIGHT_MOUSE_DOWN, onMouseRightDown

Mouse3DManager.hx

package away3d.core.managers;

import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.core.pick.IPicker;
import away3d.core.pick.PickingCollisionVO;
import away3d.core.pick.PickingType;
import away3d.events.MouseEvent3D;

import openfl.display.DisplayObject;
import openfl.display.DisplayObjectContainer;
import openfl.display.Stage;
import openfl.events.MouseEvent;
import openfl.geom.Vector3D;
import openfl.Vector;

/**
 * Mouse3DManager enforces a singleton pattern and is not intended to be instanced.
 * it provides a manager class for detecting 3D mouse hits on View3D objects and sending out 3D mouse events.
 */
class Mouse3DManager
{
	public var forceMouseMove(get, set):Bool;
	public var mousePicker(get, set):IPicker;
	
	private static var _view3Ds:Map<View3D, Int>;
	private static var _view3DLookup:Vector<View3D>;
	private static var _viewCount:Int = 0;
	
	private var _activeView:View3D;
	private var _updateDirty:Bool = true;
	private var _nullVector:Vector3D = new Vector3D();
	private static var _collidingObject:PickingCollisionVO;
	private static var _previousCollidingObject:PickingCollisionVO;
	private static var _collidingViewObjects:Vector<PickingCollisionVO>;
	private static var _queuedEvents:Vector<MouseEvent3D> = new Vector<MouseEvent3D>();
	
	private var _mouseMoveEvent:MouseEvent = new MouseEvent(MouseEvent.MOUSE_MOVE);
	
	private static var _mouseUp:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MOUSE_UP);
	private static var _mouseClick:MouseEvent3D = new MouseEvent3D(MouseEvent3D.CLICK);
	private static var _mouseOut:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MOUSE_OUT);
	private static var _mouseDown:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MOUSE_DOWN);
	private static var _mouseMove:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MOUSE_MOVE);
	private static var _mouseOver:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MOUSE_OVER);
	private static var _mouseWheel:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MOUSE_WHEEL);
	private static var _mouseDoubleClick:MouseEvent3D = new MouseEvent3D(MouseEvent3D.DOUBLE_CLICK);
	
	private static var _mouseMiddleClick:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MIDDLE_CLICK);
	private static var _mouseMiddleUp:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MIDDLE_MOUSE_UP);
	private static var _mouseMiddleDown:MouseEvent3D = new MouseEvent3D(MouseEvent3D.MIDDLE_MOUSE_DOWN);
	private static var _mouseRightClick:MouseEvent3D = new MouseEvent3D(MouseEvent3D.RIGHT_CLICK);
	private static var _mouseRightUp:MouseEvent3D = new MouseEvent3D(MouseEvent3D.RIGHT_MOUSE_UP);
	private static var _mouseRightDown:MouseEvent3D = new MouseEvent3D(MouseEvent3D.RIGHT_MOUSE_DOWN);
	
	private var _forceMouseMove:Bool;
	private var _mousePicker:IPicker = PickingType.RAYCAST_FIRST_ENCOUNTERED;
	private var _childDepth:Int = 0;
	private static var _previousCollidingView:Int = -1;
	private static var _collidingView:Int = -1;
	private var _collidingDownObject:PickingCollisionVO;
	private var _collidingUpObject:PickingCollisionVO;
	
	/**
	 * Creates a new <code>Mouse3DManager</code> object.
	 */
	public function new()
	{
		if (_view3Ds == null) {
			_view3Ds = new Map<View3D, Int>();
			_view3DLookup = new Vector<View3D>();
		}
	}
	
	// ---------------------------------------------------------------------
	// Interface.
	// ---------------------------------------------------------------------
	
	public function updateCollider(view:View3D):Void
	{
		_previousCollidingView = _collidingView;
		
		if (view != null) {
			// Clear the current colliding objects for multiple views if backBuffer just cleared
			if (view.stage3DProxy.bufferClear)
				_collidingViewObjects = new Vector<PickingCollisionVO>(_viewCount);
			
			if (!view.shareContext) {
				if (view == _activeView && (_forceMouseMove || _updateDirty)) { // If forceMouseMove is off, and no 2D mouse events dirtied the update, don't update either.
					_collidingObject = _mousePicker.getViewCollision(view.mouseX, view.mouseY, view);
				}
			} else {
				if (view.getBounds(view.parent).contains(view.mouseX + view.x, view.mouseY + view.y)) {
					if (_collidingViewObjects == null) 
						_collidingViewObjects = new Vector<PickingCollisionVO>(_viewCount);
					_collidingObject = _collidingViewObjects[_view3Ds[view]] = _mousePicker.getViewCollision(view.mouseX, view.mouseY, view);
				}
			}
		}
	}
	
	public function fireMouseEvents():Void
	{
		var i:Int = 0;
		var len:Int;
		var event:MouseEvent3D;
		var dispatcher:ObjectContainer3D;
		
		// If multiple view are used, determine the best hit based on the depth intersection.
		if (_collidingViewObjects != null) {
			_collidingObject = null;
			// Get the top-most view colliding object
			var distance:Float = Math.POSITIVE_INFINITY;
			var view:View3D;
			var v:Int = _viewCount - 1;
			while (v >= 0) {
				view = _view3DLookup[v];
				if (_collidingViewObjects[v] != null && (view.layeredView || _collidingViewObjects[v].rayEntryDistance < distance)) {
					distance = _collidingViewObjects[v].rayEntryDistance;
					_collidingObject = _collidingViewObjects[v];
					if (view.layeredView)
						break;
				}
				v--;
			}
		}
		
		// If colliding object has changed, queue over/out events.
		if (_collidingObject != _previousCollidingObject) {
			if (_previousCollidingObject != null)
				queueDispatch(_mouseOut, _mouseMoveEvent, _previousCollidingObject);
			if (_collidingObject != null)
				queueDispatch(_mouseOver, _mouseMoveEvent, _collidingObject);
		}
		
		// Fire mouse move events here if forceMouseMove is on.
		if (_forceMouseMove && _collidingObject != null)
			queueDispatch(_mouseMove, _mouseMoveEvent, _collidingObject);
		
		// Dispatch all queued events.
		len = _queuedEvents.length;
		for (i in 0...len) {
			// Only dispatch from first implicitly enabled object ( one that is not a child of a mouseChildren = false hierarchy ).
			event = _queuedEvents[i];
			dispatcher = event.object;
			
			while (dispatcher != null && !dispatcher._ancestorsAllowMouseEnabled)
				dispatcher = dispatcher.parent;
			
			if (dispatcher != null)
				dispatcher.dispatchEvent(event);
		}
		_queuedEvents.length = 0;
		
		_updateDirty = false;
		_previousCollidingObject = _collidingObject;
	}
	
	public function addViewLayer(view:View3D):Void
	{
		var stg:Stage = view.stage;
		
		// Add instance to mouse3dmanager to fire mouse events for multiple views
		if (view.stage3DProxy.mouse3DManager == null)
			view.stage3DProxy.mouse3DManager = this;
		
		if (!hasKey(view))
			_view3Ds.set(view, 0);
		
		_childDepth = 0;
		traverseDisplayObjects(stg);
		_viewCount = _childDepth;
	}
	
	public function enableMouseListeners(view:View3D):Void
	{
		view.addEventListener(MouseEvent.CLICK, onClick);
		view.addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
		view.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
		view.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		view.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
		view.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
		view.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
		view.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		
		view.addEventListener(MouseEvent.MIDDLE_CLICK, onMouseMiddleClick);
		view.addEventListener(MouseEvent.MIDDLE_MOUSE_UP, onMouseMiddleUp);
		view.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, onMouseMiddleDown);		
		view.addEventListener(MouseEvent.RIGHT_CLICK, onMouseRightClick);
		view.addEventListener(MouseEvent.RIGHT_MOUSE_UP, onMouseRightUp);
		view.addEventListener(MouseEvent.RIGHT_MOUSE_DOWN, onMouseRightDown);
	}
	
	public function disableMouseListeners(view:View3D):Void
	{
		view.removeEventListener(MouseEvent.CLICK, onClick);
		view.removeEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
		view.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
		view.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
		view.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
		view.removeEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
		view.removeEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
		view.removeEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
		
		view.removeEventListener(MouseEvent.MIDDLE_CLICK, onMouseMiddleClick);
		view.removeEventListener(MouseEvent.MIDDLE_MOUSE_UP, onMouseMiddleUp);
		view.removeEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, onMouseMiddleDown);		
		view.removeEventListener(MouseEvent.RIGHT_CLICK, onMouseRightClick);
		view.removeEventListener(MouseEvent.RIGHT_MOUSE_UP, onMouseRightUp);
		view.removeEventListener(MouseEvent.RIGHT_MOUSE_DOWN, onMouseRightDown);
	}
	
	public function dispose():Void
	{
		_mousePicker.dispose();
	}
	
	// ---------------------------------------------------------------------
	// Private.
	// ---------------------------------------------------------------------
	
	private function queueDispatch(event:MouseEvent3D, sourceEvent:MouseEvent, collider:PickingCollisionVO = null):Void
	{
		
		// 2D properties.
		event.ctrlKey = sourceEvent.ctrlKey;
		event.altKey = sourceEvent.altKey;
		event.shiftKey = sourceEvent.shiftKey;
		event.delta = sourceEvent.delta;
		event.screenX = sourceEvent.localX;
		event.screenY = sourceEvent.localY;
		
		if (collider == null)
			collider = _collidingObject;
		
		// 3D properties.
		if (collider != null) {
			// Object.
			event.object = collider.entity;
			event.renderable = collider.renderable;
			// UV.
			event.uv = collider.uv;
			// Position.
			event.localPosition = (collider.localPosition != null) ? collider.localPosition.clone() : null;
			// Normal.
			event.localNormal = (collider.localNormal != null) ? collider.localNormal.clone() : null;
			// Face index.
			event.index = collider.index;
			// SubGeometryIndex.
			event.subGeometryIndex = collider.subGeometryIndex;
			
		} else {
			// Set all to null.
			event.uv = null;
			event.object = null;
			event.localPosition = _nullVector;
			event.localNormal = _nullVector;
			event.index = 0;
			event.subGeometryIndex = 0;
		}
		
		// Store event to be dispatched later.
		_queuedEvents.push(event);
	}
	
	private function reThrowEvent(event:MouseEvent):Void
	{
		if (_activeView == null || (_activeView != null && !_activeView.shareContext))
			return;
		
		var keys:Iterator<View3D> = _view3Ds.keys();
		for (v in keys) {
			if (v != _activeView && _view3Ds.get(v) == _view3Ds.get(_activeView) - 1) {
				if (event.bubbles == true)
					v.dispatchEvent(new MouseEvent(event.type, false, event.cancelable, event.localX, event.localY, event.relatedObject, event.ctrlKey, event.altKey, event.shiftKey, event.buttonDown, event.delta, event.commandKey, event.clickCount));
				else v.dispatchEvent(event);
			}
		}
	}
	
	private function hasKey(view:View3D):Bool
	{
		return _view3Ds.exists(view);
	}
	
	private function traverseDisplayObjects(container:DisplayObjectContainer):Void
	{
		var childCount:Int = container.numChildren;
		var c:Int = 0;
		var child:DisplayObject;
		for (c in 0...childCount) {
			child = container.getChildAt(c);
			if (Std.is(child, View3D) && _view3Ds.exists(cast child)) {
				_view3Ds[cast child] = _childDepth;
				_view3DLookup[_childDepth] = cast child;
				_childDepth++;
			}
			if (Std.is(child, DisplayObjectContainer)){
				traverseDisplayObjects(cast(child, DisplayObjectContainer));
			}
		}
	}
	
	// ---------------------------------------------------------------------
	// Listeners.
	// ---------------------------------------------------------------------
	
	private function onMouseMove(event:MouseEvent):Void
	{
		if (_collidingObject != null) {
			queueDispatch(_mouseMove, _mouseMoveEvent = event);
		} else {
			reThrowEvent(event);
		}	
		_updateDirty = true;
	}
	
	private function onMouseOut(event:MouseEvent):Void
	{
		_activeView = null;
		if (_collidingObject != null) {
			queueDispatch(_mouseOut, event, _collidingObject);
		}
		_updateDirty = true;
	}
	
	private function onMouseOver(event:MouseEvent):Void
	{
		_activeView = cast(event.currentTarget, View3D);
		if (_collidingObject != null && _previousCollidingObject != _collidingObject) {
			queueDispatch(_mouseOver, event, _collidingObject);
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onClick(event:MouseEvent):Void
	{
		if (_collidingObject != null) {
			queueDispatch(_mouseClick, event);
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onDoubleClick(event:MouseEvent):Void
	{
		if (_collidingObject != null) {
			queueDispatch(_mouseDoubleClick, event);
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onMouseDown(event:MouseEvent):Void
	{
		_activeView = cast(event.currentTarget, View3D);
		updateCollider(_activeView); // ensures collision check is done with correct mouse coordinates on mobile
		if (_collidingObject != null) {
			queueDispatch(_mouseDown, event);
			_previousCollidingObject = _collidingObject;
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onMouseUp(event:MouseEvent):Void
	{
		if (_collidingObject != null) {
			queueDispatch(_mouseUp, event);
			_previousCollidingObject = _collidingObject;
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onMouseWheel(event:MouseEvent):Void
	{
		if (_collidingObject != null){
			queueDispatch(_mouseWheel, event);
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	
	
	private function onMouseMiddleClick(event:MouseEvent ):Void
	{
		if (_collidingObject != null){
			queueDispatch(_mouseMiddleClick, event );
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onMouseMiddleUp(event:MouseEvent ):Void
	{
		if (_collidingObject != null){
			queueDispatch( _mouseMiddleUp, event );
			_previousCollidingObject = _collidingObject;
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}

	private function onMouseMiddleDown(event:MouseEvent ):Void
	{
		_activeView = cast(event.currentTarget, View3D);
		updateCollider(_activeView); // ensures collision check is done with correct mouse coordinates on mobile
		if (_collidingObject != null) {
			queueDispatch( _mouseMiddleDown, event );
			_previousCollidingObject = _collidingObject;
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}

	private function onMouseRightClick( event:MouseEvent ):Void
	{
		if (_collidingObject != null){
			queueDispatch( _mouseRightClick, event );
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onMouseRightUp( event:MouseEvent ):Void
	{
		if (_collidingObject != null){
			queueDispatch( _mouseRightUp, event );
			_previousCollidingObject = _collidingObject;
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	private function onMouseRightDown( event:MouseEvent ):Void
	{
		_activeView = cast(event.currentTarget, View3D);
		updateCollider(_activeView); // ensures collision check is done with correct mouse coordinates on mobile
		if (_collidingObject != null) {
			queueDispatch( _mouseRightDown, event );
			_previousCollidingObject = _collidingObject;
		} else {
			reThrowEvent(event);
		}
		_updateDirty = true;
	}
	
	// ---------------------------------------------------------------------
	// Getters & setters.
	// ---------------------------------------------------------------------
	
	private function get_forceMouseMove():Bool
	{
		return _forceMouseMove;
	}
	
	private function set_forceMouseMove(value:Bool):Bool
	{
		_forceMouseMove = value;
		return value;
	}
	
	private function get_mousePicker():IPicker
	{
		return _mousePicker;
	}
	
	private function set_mousePicker(value:IPicker):IPicker
	{
		_mousePicker = value;
		return value;
	}
}

MouseEvent3D.hx

package away3d.events;

import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.core.base.IRenderable;
import away3d.core.math.Matrix3DUtils;
import away3d.materials.MaterialBase;

import openfl.events.Event;
import openfl.geom.Point;
import openfl.geom.Vector3D;

/**
 * A MouseEvent3D is dispatched when a mouse event occurs over a mouseEnabled object in View3D.
 * todo: we don't have screenZ data, tho this should be easy to implement
 */
class MouseEvent3D extends Event
{
	public var scenePosition(get, never):Vector3D;
	public var sceneNormal(get, never):Vector3D;

	// Private.
	@:allow(away3d) private var _allowedToPropagate:Bool = true;
	@:allow(away3d) private var _parentEvent:MouseEvent3D;
	
	/**
	 * Defines the value of the type property of a mouseOver3d event object.
	 */
	public static inline var MOUSE_OVER:String = "mouseOver3d";
	
	/**
	 * Defines the value of the type property of a mouseOut3d event object.
	 */
	public static inline var MOUSE_OUT:String = "mouseOut3d";
	
	/**
	 * Defines the value of the type property of a mouseUp3d event object.
	 */
	public static inline var MOUSE_UP:String = "mouseUp3d";
	
	/**
	 * Defines the value of the type property of a mouseDown3d event object.
	 */
	public static inline var MOUSE_DOWN:String = "mouseDown3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var MOUSE_MOVE:String = "mouseMove3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var  MIDDLE_CLICK:String = "middleMouseClick3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var  MIDDLE_MOUSE_UP:String = "middleMouseUp3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var  MIDDLE_MOUSE_DOWN:String = "middleMouseDown3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var  RIGHT_CLICK:String = "mouseRightClick3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var  RIGHT_MOUSE_UP:String = "mouseRightUp3d";
	
	/**
	 * Defines the value of the type property of a mouseMove3d event object.
	 */
	public static inline var  RIGHT_MOUSE_DOWN:String = "mouseRightDown3d";
	
	/**
	 * Defines the value of the type property of a rollOver3d event object.
	 */
	//		public static const ROLL_OVER : String = "rollOver3d";
	
	/**
	 * Defines the value of the type property of a rollOut3d event object.
	 */
	//		public static const ROLL_OUT : String = "rollOut3d";
	
	/**
	 * Defines the value of the type property of a click3d event object.
	 */
	public static inline var CLICK:String = "click3d";
	
	/**
	 * Defines the value of the type property of a doubleClick3d event object.
	 */
	public static inline var DOUBLE_CLICK:String = "doubleClick3d";
	
	/**
	 * Defines the value of the type property of a mouseWheel3d event object.
	 */
	public static inline var MOUSE_WHEEL:String = "mouseWheel3d";
	
	/**
	 * The horizontal coordinate at which the event occurred in view coordinates.
	 */
	public var screenX:Float;
	
	/**
	 * The vertical coordinate at which the event occurred in view coordinates.
	 */
	public var screenY:Float;
	
	/**
	 * The view object inside which the event took place.
	 */
	public var view:View3D;
	
	/**
	 * The 3d object inside which the event took place.
	 */
	public var object:ObjectContainer3D;
	
	/**
	 * The renderable inside which the event took place.
	 */
	public var renderable:IRenderable;
	
	/**
	 * The material of the 3d element inside which the event took place.
	 */
	public var material:MaterialBase;
	
	/**
	 * The uv coordinate inside the draw primitive where the event took place.
	 */
	public var uv:Point;
	
	/**
	 * The index of the face where the event took place.
	 */
	public var index:Int;
	
	/**
	 * The index of the subGeometry where the event took place.
	 */
	public var subGeometryIndex:Int;
	
	/**
	 * The position in object space where the event took place
	 */
	public var localPosition:Vector3D;
	
	/**
	 * The normal in object space where the event took place
	 */
	public var localNormal:Vector3D;
	
	/**
	 * Indicates whether the Control key is active (true) or inactive (false).
	 */
	public var ctrlKey:Bool;
	
	/**
	 * Indicates whether the Alt key is active (true) or inactive (false).
	 */
	public var altKey:Bool;
	
	/**
	 * Indicates whether the Shift key is active (true) or inactive (false).
	 */
	public var shiftKey:Bool;
	
	/**
	 * Indicates how many lines should be scrolled for each unit the user rotates the mouse wheel.
	 */
	public var delta:Int;
	
	/**
	 * Create a new MouseEvent3D object.
	 * @param type The type of the MouseEvent3D.
	 */
	public function new(type:String)
	{
		super(type, true, true);
	}
	
	/**
	 * @inheritDoc
	 */
	#if flash
	@:getter(bubbles) function get_bubbles():Bool
	{
		var doesBubble:Bool = super.bubbles && _allowedToPropagate;
		_allowedToPropagate = true;
		// Don't bubble if propagation has been stopped.
		return doesBubble;
	}
	#end
	/**
	 * @inheritDoc
	 */
	override public function stopPropagation():Void
	{
		super.stopPropagation();
		_allowedToPropagate = false;
		if (_parentEvent != null)
			_parentEvent.stopPropagation();
	}
	
	/**
	 * @inheritDoc
	 */
	override public function stopImmediatePropagation():Void
	{
		super.stopImmediatePropagation();
		_allowedToPropagate = false;
		if (_parentEvent != null)
			_parentEvent.stopImmediatePropagation();
	}
	
	/**
	 * Creates a copy of the MouseEvent3D object and sets the value of each property to match that of the original.
	 */
	override public function clone():Event
	{
		var result:MouseEvent3D = new MouseEvent3D(type);
		
		#if flash
		if (isDefaultPrevented())
			result.preventDefault();
		#end
		
		result.screenX = screenX;
		result.screenY = screenY;
		
		result.view = view;
		result.object = object;
		result.renderable = renderable;
		result.material = material;
		result.uv = uv;
		result.localPosition = localPosition;
		result.localNormal = localNormal;
		result.index = index;
		result.subGeometryIndex = subGeometryIndex;
		result.delta = delta;
		
		result.ctrlKey = ctrlKey;
		result.shiftKey = shiftKey;
		
		result._parentEvent = this;
		result._allowedToPropagate = _allowedToPropagate;
		
		return result;
	}
	
	/**
	 * The position in scene space where the event took place
	 */
	private function get_scenePosition():Vector3D
	{
		if (Std.is(object, ObjectContainer3D))
			return Matrix3DUtils.transformVector(cast(object, ObjectContainer3D).sceneTransform,localPosition);
		else
			return localPosition;
	}

	/**
	 * The position in scene space where the event took place
	 * @param v destination Vector3D
	 * @return
	 */
	public function getScenePosition(v:Vector3D = null):Vector3D {
		if(v == null) v = new Vector3D();
		if (Std.is(object, ObjectContainer3D)) {
			Matrix3DUtils.transformVector(cast(object, ObjectContainer3D).sceneTransform,localPosition,v);
		}else{
			v.x = localPosition.x;
			v.y = localPosition.y;
			v.z = localPosition.z;
		}
		return v;
	}
	
	/**
	 * The normal in scene space where the event took place
	 */
	private function get_sceneNormal():Vector3D
	{
		if (Std.is(object, ObjectContainer3D)) {
			var sceneNormal:Vector3D = Matrix3DUtils.deltaTransformVector(cast(object, ObjectContainer3D).sceneTransform,localNormal);
			sceneNormal.normalize();
			return sceneNormal;
		} else
			return localNormal;
	}

	/**
	 * The normal in scene space where the event took place
	 * @param v destination Vector3D
	 * @return
	 */
	public function getSceneNormal(v:Vector3D = null):Vector3D {
		if(v == null) v = new Vector3D();
		if (Std.is(object, ObjectContainer3D)) {
			Matrix3DUtils.deltaTransformVector(cast(object, ObjectContainer3D).sceneTransform,localNormal, v);
			v.normalize();
		} else {
			v.x = localNormal.x;
			v.y = localNormal.y;
			v.z = localNormal.z;
		}
		return v;
	}
}

DAEParser throws exception on Std::parseFloat on Neko target

I'm trying to load a DAE file but it's throwing an exception on the Neko target trying to parse a value that is already a float.

Called from sys.io.FileOutput::$statics line 1
Called from ApplicationMain::main line 79
Called from ApplicationMain::create line 111
Called from lime.app.Application::exec line 225
Called from lime._backend.native.NativeApplication::exec line 154
Called from a C function
Called from lime._backend.native.NativeApplication::handleApplicationEvent line 194
Called from lime._backend.native.NativeApplication::updateTimer line 689
Called from openfl.utils.Timer::timer_onTimer line 168
Called from openfl.events.EventDispatcher::dispatchEvent line 97
Called from openfl.events.EventDispatcher::__dispatchEvent line 218
Called from away3d.loaders.parsers.ParserBase::onInterval line 385
Called from away3d.loaders.parsers.DAEParser::proceedParsing line 204
Called from away3d.loaders.parsers.DAEParser::setupMaterials line 837
Called from away3d.loaders.parsers.DAEParser::setupMaterial line 779
Called from Std::parseFloat line 55
Uncaught exception - Invalid field access : __s

traverseChildHandler() handles getting the float XML element and parsing the value to a float. When entering setupMaterial() on ActionScript, the value is passed into Number() while the Haxe version uses Std.parseFloat() again. This fails on Neko target while C++ and HTML5 appear to accept this mistake and return the float as is.

While I do plan to use C++ and HTML5 later, I would like to keep using Neko during development because of its fast start up time. I would remove the extra parseFloat calls and make a PR but I'm not sure if that breaks any special cases or diverge from the ActionScript sources.

Versions:

  • OS: Ubuntu 17.04 64-bit
  • Haxe: 3.4.2
  • Haxelib: 3.3.0
  • away3d-samples: 5.0.1
  • away3d: 5.0.2
  • hxcpp: 3.4.64
  • lime-samples: 4.0.1
  • lime: 5.0.3
  • openfl-samples: 4.9.0
  • openfl: 5.1.2
  • swf: 2.3.1

If _billboardAxis is not null in ParticleBillboardState, the display object will disappear.

override public function setRenderState(stage3DProxy:Stage3DProxy, renderable:IRenderable, animationSubGeometry:AnimationSubGeometry, animationRegisterCache:AnimationRegisterCache, camera:Camera3D):Void
	{
		// TODO: not used

		var comps:Vector<Vector3D>;
		if (_billboardAxis != null) {
			var pos:Vector3D = renderable.getRenderSceneTransform(camera).position;
			var look:Vector3D = camera.sceneTransform.position.subtract(pos);
			var right:Vector3D = look.crossProduct(_billboardAxis);
			right.normalize();
			look = _billboardAxis.crossProduct(right);
			look.normalize();
			
			//create a quick inverse projection matrix
			_matrix.copyFrom(renderable.getRenderSceneTransform(camera));
			comps = Matrix3DUtils.decompose(_matrix, Orientation3D.AXIS_ANGLE);
			_matrix.copyColumnFrom(0, right);
			_matrix.copyColumnFrom(1, _billboardAxis);
			_matrix.copyColumnFrom(2, look);
			_matrix.copyColumnFrom(3, pos);
			_matrix.appendRotation(-comps[1].w*MathConsts.RADIANS_TO_DEGREES, comps[1]);
		} else {
			//create a quick inverse projection matrix
			_matrix.copyFrom(renderable.getRenderSceneTransform(camera));
			_matrix.append(camera.inverseSceneTransform);
			
			//decompose using axis angle rotations
			comps = Matrix3DUtils.decompose(_matrix, Orientation3D.AXIS_ANGLE);
			
			//recreate the matrix with just the rotation data
			_matrix.identity();
			_matrix.appendRotation(-comps[1].w*MathConsts.RADIANS_TO_DEGREES, comps[1]);
		}
		
		//set a new matrix transform constant
		animationRegisterCache.setVertexConstFromMatrix(animationRegisterCache.getRegisterIndex(_animationNode, ParticleBillboardNode.MATRIX_INDEX), _matrix);
	}

If _billboardAxis is not null in ParticleBillboardState, the display object will disappear.

AWD files broken on HTML5 (distinct from native platform bug) (Bounty 100EUR)

related issues: #13 #4

Looks like AWD models don't load at all in away3d for html5 builds. This seems to be true both for the latest version of openfl/lime (6.1.0 and 5.4.0 at time of writing), and also the old versions I've been using for development (5.1.5 and 5.2.1).

In away3d.loaders.parsers.AWD2Parser.hx, if I set debug=true; on line 47, I get the following output in HTML5:

AWD2Parser.hx:339: Import AWDFile of version = 2 - 1
AWD2Parser.hx:340: Global Settings = Compression = 189 | Streaming = true | Matrix-Precision = true | Geometry-Precision = true | Properties-Precision = true

It's reading a compression value of 189, which is well out of bounds and clearly wrong. For comparison, here is the same debug output in flash, where the test model loads correctly:

AWD2Parser.hx:339: Import AWDFile of version = 2 - 1
AWD2Parser.hx:340: Global Settings = Compression = 1 | Streaming = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:404: AWDBlock:  ID = 1 | TypeID = 255 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:1998: Parsed a MetaDataBlock: TimeStamp         = 958575047
AWD2Parser.hx:1999:                         EncoderName       = AwayBuilder
AWD2Parser.hx:2000:                         EncoderVersion    = 1.0.0
AWD2Parser.hx:2001:                         GeneratorName     = AwayBuilder
AWD2Parser.hx:2002:                         GeneratorVersion  = 1.0.0
AWD2Parser.hx:497: 

AWD2Parser.hx:404: AWDBlock:  ID = 2 | TypeID = 254 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:1990: Parsed a NameSpaceBlock: ID = 1 | String = http://example.com/myawdns
AWD2Parser.hx:497: 

AWD2Parser.hx:404: AWDBlock:  ID = 3 | TypeID = 1 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:628: Parsed a TriangleGeometry: Name = geometry| SubGeometries = 1
AWD2Parser.hx:497: 

AWD2Parser.hx:404: AWDBlock:  ID = 4 | TypeID = 82 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:1398: Start parsing a embed Bitmap for Texture
AWD2Parser.hx:497: 

AWD2Parser.hx:192: Successfully loadet Bitmap for texture
AWD2Parser.hx:193: Parsed CubeTexture: Name = file:///C:/Users/terry/Desktop/cat.jpg
AWD2Parser.hx:404: AWDBlock:  ID = 5 | TypeID = 81 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:1364: Parsed a TextureMaterial(SinglePass): Name = 'Material1' | Texture-Name = file:///C:/Users/terry/Desktop/cat.jpg
AWD2Parser.hx:497: 

AWD2Parser.hx:404: AWDBlock:  ID = 6 | TypeID = 23 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:796: Parsed a Mesh: Name = 'Cube_Cube.001' | Parent-Name = Root (TopLevel)| Geometry-Name = geometry | SubMeshes = 1 | Mat-Names = Material1
AWD2Parser.hx:497: 

AWD2Parser.hx:404: AWDBlock:  ID = 7 | TypeID = 1 | Compression = false | Matrix-Precision = false | Geometry-Precision = false | Properties-Precision = false
AWD2Parser.hx:628: Parsed a TriangleGeometry: Name = geometry| SubGeometries = 1
AWD2Parser.hx:497: 

(I'm using cat.awd from this issue as the test model: #13)

I'm really interested in getting these three interconnected bugs fixed (this one, #13 and #4) so that I can release a project I've been working on! Therefore, I'm going to try offering a bounty, which I've never done before. (inspired by a recent openfl issue)

I offer a bounty of 100 EUR for a pull request to this project that fixes AWD parsing for both native and html5, for the most recent builds of openfl and lime. I consider AWD parsing sufficiently fixed for me if the demo cat model in this issue (#13) can be loaded successfully in both native and html5.

error on view3D.dispose() (i now provided my code)

Error occurs when trying to dispose a View3D.

Thread 0 (critical error: Null Object Reference):
*    27 : openfl.display3D.Program3D.__deleteShaders() at openfl/display3D/Program3D.hx:597
     26 : openfl.display3D.Program3D.dispose() at openfl/display3D/Program3D.hx:113
     25 : away3d.core.managers.AGALProgram3DCache.destroyProgram() at away3d/core/managers/AGALProgram3DCache.hx:126
     24 : away3d.core.managers.AGALProgram3DCache.dispose() at away3d/core/managers/AGALProgram3DCache.hx:76
     23 : away3d.core.managers.AGALProgram3DCache.onContext3DDisposed() at away3d/core/managers/AGALProgram3DCache.hx:65
     22 : openfl.events.EventDispatcher.__dispatchEvent() at openfl/events/EventDispatcher.hx:402
     21 : openfl.events.EventDispatcher.dispatchEvent() at openfl/events/EventDispatcher.hx:246
     20 : away3d.core.managers.Stage3DProxy.freeContext3D() at away3d/core/managers/Stage3DProxy.hx:557
     19 : away3d.core.managers.Stage3DProxy.dispose() at away3d/core/managers/Stage3DProxy.hx:177
     18 : away3d.containers.View3D.dispose() at away3d/containers/View3D.hx:937
     17 : object3d.VeView3D.destroy() at object3d/VeView3D.hx:66
     16 : flixel.group.FlxTypedGroup.destroy() at flixel/group/FlxGroup.hx:154
     15 : flixel.FlxState.destroy() at flixel/FlxState.hx:165
     14 : flixel.FlxGame.switchState() at flixel/FlxGame.hx:624
     13 : flixel.FlxGame.update() at flixel/FlxGame.hx:724
     12 : flixel.FlxGame.step() at flixel/FlxGame.hx:677
     11 : flixel.FlxGame.onEnterFrame() at flixel/FlxGame.hx:545
     10 : openfl.events.EventDispatcher.__dispatchEvent() at openfl/events/EventDispatcher.hx:402
      9 : openfl.display.DisplayObject.__dispatch() at openfl/display/DisplayObject.hx:1399
      8 : openfl.display.Stage.__broadcastEvent() at openfl/display/Stage.hx:1181
      7 : openfl.display.Stage.__onLimeRender() at openfl/display/Stage.hx:2046
      6 : lime.app._Event_lime_graphics_RenderContext_Void.dispatch() at lime/_internal/macros/EventMacro.hx:91
      5 : lime._internal.backend.native.NativeApplication.handleRenderEvent() at lime/_internal/backend/native/NativeApplication.hx:371
      4 : lime._internal.backend.native.NativeApplication.exec() at lime/_internal/backend/native/NativeApplication.hx:146
      3 : lime.app.Application.exec() at lime/app/Application.hx:150
      2 : ApplicationMain.create() at ApplicationMain.hx:135
      1 : ApplicationMain.main() at ApplicationMain.hx:26
      0 : hxcpp.__hxcpp_main() at ?:1

Original issue (possibly outdated) in 2015 by ramsestom from away3d/away3d-core-openfl

I have an ObjectContainer3D OC1 that contains 2 other ObjectContainer3D OC2 and OC3 (containing each one a mesh).
If I add only OC1 as child to my view3D, calling the view3D.dispose() function make the program to crash with this error:

Null Object Reference
Called from openfl._legacy.display.Stage.__pollTimers (openfl/_legacy/display/Stage.hx line 1084)
Called from openfl._legacy.display.Stage.__checkRender (openfl/_legacy/display/Stage.hx line 351)
Called from openfl._legacy.display.Stage.__render (openfl/_legacy/display/Stage.hx line 1103)
Called from openfl._legacy.display.DisplayObjectContainer.__broadcast (openfl/_legacy/display/DisplayObjectContainer.hx line 286)
Called from openfl._legacy.display.DisplayObject.__broadcast (openfl/_legacy/display/DisplayObject.hx line 161)
Called from openfl._legacy.display.DisplayObject.__dispatchEvent (openfl/_legacy/display/DisplayObject.hx line 182)
Called from openfl._legacy.events.EventDispatcher.dispatchEvent (openfl/_legacy/events/EventDispatcher.hx line 98)
Called from flixel.FlxGame.onEnterFrame (flixel/FlxGame.hx line 523)
Called from flixel.FlxGame.step (flixel/FlxGame.hx line 681)
Called from flixel.FlxGame.update (flixel/FlxGame.hx line 701)
Called from flixel.FlxGame.switchState (flixel/FlxGame.hx line 608)
Called from gui.states.PlayState3D.destroy (gui/states/PlayState3D.hx line 289)
Called from away3d.containers.View3D.dispose (away3d/containers/View3D.hx line 1003)
Called from away3d.core.managers.Stage3DProxy.dispose (away3d/core/managers/Stage3DProxy.hx line 151)
Called from away3d.core.managers.Stage3DProxy.freeContext3D (away3d/core/managers/Stage3DProxy.hx line 492)
Called from openfl._legacy.events.EventDispatcher.dispatchEvent (openfl/_legacy/events/EventDispatcher.hx line 98)
Called from away3d.core.managers.AGALProgram3DCache.onContext3DDisposed (away3d/core/managers/AGALProgram3DCache.hx line 58)
Called from away3d.core.managers.AGALProgram3DCache.dispose (away3d/core/managers/AGALProgram3DCache.hx line 68)
Called from away3d.core.managers.AGALProgram3DCache.destroyProgram (away3d/core/managers/AGALProgram3DCache.hx line 115)
Called from openfl.display3D.Program3D.dispose (openfl/display3D/Program3D.hx line 25)
Called from openfl.display3D.Context3D.__deleteProgram (openfl/display3D/Context3D.hx line 229)

Now, If my ObjectContainer3D OC1 only contains 1 Mesh (instead of OC2 and OC3), there is no error. view3D.dispose() succed. The same thing if I I only put OC2 (with 1 mesh) as child of OC1 (so whithout OC3) and then put OC1 as single child of view3D (everything is fine in that case). The issue only appear if I have in my view3D an ObjectContainer3D with more than 1 child in it...

Problem with MD2Parser

Encountering an issue trying to compile with Away3D 5.0.8, in Openfl 8.8.0, Lime 7.2.1 when import away3d.loaders.parsers.Parsers; is called

C:\HaxeToolkit\haxe\lib\away3d\5,0,8\away3d\loaders\parsers\MD2Parser.hx:415: chars 4-24 : Error: This kind of operation is not supported

This refers to the line _byteData.position++;

If I comment our the reference to MD2Parser.hx it compiles OK

AWD files are broken on native platforms

Heya,

Recently updated to the latest OpenFL and Away3D versions. Previously, I had been able to load .awd files without any problems in native builds. As of the current versions (away3d 5.0.3, openfl 6.1.0, lime 5.4.0), textures are no longer being loaded for awd files.

Here's a simple example which demonstrates the problem. It's a modified version of the Basic LoadAWD example without lighting and using a simple textured model: away3d_awdbug.zip

If I build this project in flash, I get the expected result, which is:

flash

However, on windows, I get an untextured version, like this:

cversion

Use of undeclared identifier 'va0' in fragment shader

When I add a depth of field filter, c++, neko, and html5 targets throw an error compiling the fragment shader. Only Flash target works.

There's an example project to replicate this error at: openfl-away3d-filter3d

In that project, a depth of field filter is added:

import away3d.filters.DepthOfFieldFilter3D;

dofFilter = new DepthOfFieldFilter3D(32, 32);

Mac

When the fragment shader is compiled, it throws error:

Program3D.hx:332: fragment: ERROR: 0:18: Incompatible types (float and vec4) in assignment (and no available implicit conversion)
ERROR: 0:18: Use of undeclared identifier 'va0'

Error : Error compiling fragment shader: ERROR: 0:18: Incompatible types (float and vec4) in assignment (and no available implicit conversion)
ERROR: 0:18: Use of undeclared identifier 'va0'

In openfl.display3D.Program3D:

[openfl.display3D.Program3D] // AGAL fragment shader
#version 120
uniform vec4 fc0;
uniform vec4 fc1;
uniform vec4 fc2;
uniform vec4 fc3;
varying vec4 v0;
uniform sampler2D sampler0;
uniform sampler2D sampler1;
void main() {
    vec4 ft0;
    vec4 ft1;
    vec4 ft2;
    vec4 ft6;
    ft0 = texture2D(sampler1, v0.xy); // tex
    ft1.z = vec4(dot(vec4(ft0), vec4(fc3))).z; // dp4
    ft1.z = ft1.z - fc1.z; // sub
    ft1.z = vec4(1) / ft1.z, va0.x; // rcp (untested)

Call stack:

Called from openfl.display.Stage::__broadcastEvent openfl/display/Stage.hx line 1068
Called from openfl.display.DisplayObject::__dispatch openfl/display/DisplayObject.hx line 337
Called from openfl.events.EventDispatcher::__dispatchEvent openfl/events/EventDispatcher.hx line 218
Called from Away3dViewport::render Away3dViewport.hx line 124
Called from away3d.containers.View3D::render away3d/containers/View3D.hx line 771
Called from away3d.core.render.Filter3DRenderer::render away3d/core/render/Filter3DRenderer.hx line 150
Called from away3d.filters.tasks.Filter3DTaskBase::getProgram3D away3d/filters/tasks/Filter3DTaskBase.hx line 172
Called from away3d.filters.tasks.Filter3DTaskBase::updateProgram3D away3d/filters/tasks/Filter3DTaskBase.hx line 138
Called from openfl.display3D.Program3D::upload openfl/display3D/Program3D.hx line 80
Called from openfl.display3D.Program3D::__uploadFromGLSL openfl/display3D/Program3D.hx line 336

Neko

Uncaught exception - Error compiling fragment shader: ERROR: 0:18: Incompatible types (float and vec4) in assignment (and no available implicit conversion)
ERROR: 0:18: Use of undeclared identifier 'va0'

html5

Program3D.hx:365: program: WARNING: Could not find vertex shader attribute 'va0' to match BindAttributeLocation request.

OpenFlAway3dFilter3d.js:28250
Program3D.hx:365: program: WARNING: Could not find vertex shader attribute 'va0' to match BindAttributeLocation request.
WARNING: Could not find vertex shader attribute 'va1' to match BindAttributeLocation request.

OpenFlAway3dFilter3d.js:28250
Program3D.hx:365: program: WARNING: Could not find vertex shader attribute 'va0' to match BindAttributeLocation request.

OpenFlAway3dFilter3d.js:28250
Program3D.hx:332: fragment: ERROR: 0:19: 'assign' : cannot convert from 'highp 4-component vector of float' to 'highp float'
ERROR: 0:19: 'va0' : undeclared identifier
ERROR: 0:19: 'x' : field selection requires structure or vector on left hand side

OpenFlAway3dFilter3d.js:70318
Uncaught openfl_errors_Error
errorID: 0
message: "Error compiling fragment shader: ERROR: 0:19: 'assign' : cannot convert from 'highp 4-component vector of float' to 'highp float'↵ERROR: 0:19: 'va0' : undeclared identifier ↵ERROR: 0:19: 'x' : field selection requires structure or vector on left hand side

Object3D.pivotPoint (bug)

Could 'pivotPoint' for Object3D be investigated, under the impression they have no effect (tested on a mesh).

Different animation rendering for flash and html5 targets

Hi guys,
There is an issue with animation rendering if you try to compile for html5 target.
I checked the example of 'PolarBearAWDAnimation' -
https://github.com/openfl/away3d-samples/tree/master/intermediate/PolarBearAWDAnimation

(Original AS3 version was checked and there everything is ok)

I'm using Away3d 5.0.4, OpenFL 7.0.0 and Lime 6.0.1.
The following target platforms were checked:

  • FLASH target (animation looks the same as in original as3 version (correct));
  • HTML5 target (animation looks incorrect - Bear model is "floating");
  • NEKO (Bear didn't load and some exception was thrown).

I've recorded a video where you can see the difference (from left to right):
-- original AS3 version -- haxe version target to FLASH -- haxe version target to HTML5
BearsTest.zip

Maybe you can help to fix this (for html5) or at least give a hint where to look for a solution.

Thank you in advance

Native Build fails on MacOS Sierra

All most all the examples fail in Native MAC Builds.
While running

openfl test neko

it runs fine. But making a native build by

openfl test mac

fails with errors. The following errors I found on PolarBearAWDAnimation

Error: ./src/away3d/materials/compilation/RegisterPool.cpp:146:21: error: redefinition of 'index1'
HXDLIN(  90)                            Int index1 = _hx_register->_component;
                                            ^
./src/away3d/materials/compilation/RegisterPool.cpp:144:21: note: previous definition is here
HXLINE(  90)                            Int index1 = _hx_register->_component;
                                            ^
./src/away3d/materials/compilation/RegisterPool.cpp:173:20: error: redefinition of 'index1'
HXDLIN( 102)                    Int index1 = _hx_register->_component;
                                    ^
./src/away3d/materials/compilation/RegisterPool.cpp:171:20: note: previous definition is here
HXDLIN( 102)                    Int index1 = _hx_register->_component;
                                    ^
2 errors generated.

Invalid GLSL

I tried some methods like DepthOfField, CelDiffuseMethod and CelSpecularMethod. And it only works on the Flash target. It seems the GLSL has a bug.

Program3D.hx:332: fragment: ERROR: 0:49: '=' : dimension mismatch
ERROR: 0:49: 'assign' : cannot convert from 'highp 4-component vector of float' to 'highp float'
ERROR: 0:80: '=' : dimension mismatch
ERROR: 0:80: 'assign' : cannot convert from 'highp 4-component vector of float' to 'highp float'

Other Methods like OutlineMethod works fine.

Away3D 5.0.2
openfl 5.1.5
lime 5.2.1

DAEParser.supportsData assumes ByteArrayData.position is 0

I found that if I enabled the default parsers and include my own custom subclassed parsers, it will throw an EOF error:

Called from away3d.library.Asset3DLibrary::loadData line 123
Called from away3d.library.Asset3DLibraryBundle::loadData line 182
Called from away3d.library.Asset3DLibraryBundle::parseResource line 449
Called from away3d.loaders.AssetLoader::loadData line 135
Called from away3d.loaders.AssetLoader::retrieveDependency line 204
Called from away3d.loaders.misc.SingleFileLoader::parseData line 149
Called from away3d.loaders.misc.SingleFileLoader::parse line 273
Called from away3d.loaders.misc.SingleFileLoader::getParserFromData line 218
Called from a C function
Called from away3d.loaders.parsers.DAEParser::supportsData line 127
Called from openfl.utils.ByteArrayData::readUTFBytes line 565
Uncaught exception - End of file was encountered

The custom classes I used ParserUtil.toString(data) to convert it to a string similar to the existing parsers like OBJParser. However, DAEParser diverges from the Flash code and uses readUTFBytes() directly which makes an assumption that the byte array position is 0. Since the parsers ahead of it mutated the byte array, this becomes not true.

I guess the best fix is to use existing helper function ParserUtil.toString within supportsData() that sets the position before reading the byte array.

  • OS: Ubuntu 17.04 64-bit
  • Haxe: 3.4.2
  • Haxelib: 3.3.0
  • away3d: 5.0.2
  • openfl: 5.1.3

lime test flash fails

C:/HaxeToolkit/haxe/lib/away3d/git/away3d/textures/Anisotropy.hx:3: characters 1-7 : Warning : (WDeprecated) `@:enum abstract` is deprecated in favor of `enum abstract`
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/core/managers/RTTBufferManager.hx:215: characters 4-60 : error: Int should be UInt
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/core/managers/RTTBufferManager.hx:215: characters 4-60 : ... have: openfl.Vector<Int>
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/core/managers/RTTBufferManager.hx:215: characters 4-60 : ... want: openfl.Vector<UInt>
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:525: characters 44-53 : Field set_width should be declared with 'override' since it is inherited from superclass flash.display.Sprite
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:525: characters 44-53 : Field set_width overrides parent class with different or incomplete type
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/display/DisplayObject.hx:196: characters 19-28 : ... Base field is defined here
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:525: characters 44-53 : ... error: Void should be Float
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:525: characters 44-53 : ... have: (...) -> Void
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:525: characters 44-53 : ... want: (...) -> Float
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:576: characters 44-54 : Field set_height should be declared with 'override' since it is inherited from superclass flash.display.Sprite
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:576: characters 44-54 : Field set_height overrides parent class with different or incomplete type
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/display/DisplayObject.hx:180: characters 19-29 : ... Base field is defined here
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:576: characters 44-54 : ... error: Void should be Float
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:576: characters 44-54 : ... have: (...) -> Void
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:576: characters 44-54 : ... want: (...) -> Float
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/core/render/BackgroundImageRenderer.hx:119: characters 3-61 : error: Int should be UInt
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/core/render/BackgroundImageRenderer.hx:119: characters 3-61 : ... have: openfl.Vector<Int>
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/core/render/BackgroundImageRenderer.hx:119: characters 3-61 : ... want: openfl.Vector<UInt>
Export/flash/haxe/ApplicationMain.hx:147: characters 3-34 : ... Called from macro here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/Scene3DEvent.hx:17: characters 19-29 : Field get_target should be declared with 'override' since it is inherited from superclass flash.events.Event
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/Scene3DEvent.hx:17: characters 19-29 : Field get_target overrides parent class with different or incomplete type
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/events/Event.hx:114: characters 19-29 : ... Base field is defined here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/Scene3DEvent.hx:17: characters 19-29 : ... error: Dynamic should be openfl.utils.Object
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/Scene3DEvent.hx:17: characters 19-29 : ... have: (...) -> Dynamic
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/Scene3DEvent.hx:17: characters 19-29 : ... want: (...) -> openfl.utils.Object
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:515: characters 44-53 : Field get_width should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:566: characters 44-54 : Field get_height should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/TouchEvent3D.hx:115: characters 15-22 : This field cannot be accessed because it is not a real variable
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/events/Event.hx:92: characters 19-48 : Add @:isVar here to enable it
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/TouchEvent3D.hx:112: characters 29-40 : Field get_bubbles should be declared with 'override' since it is inherited from superclass flash.events.Event
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/events/MouseEvent3D.hx:164: characters 29-40 : Field get_bubbles should be declared with 'override' since it is inherited from superclass flash.events.Event
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:486: characters 44-55 : Field get_filters should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:500: characters 44-55 : Field set_filters should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:500: characters 44-55 : Field set_filters overrides parent class with different or incomplete type
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/display/DisplayObject.hx:179: characters 19-30 : ... Base field is defined here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:500: characters 44-55 : ... error: Void should be Array<openfl.filters.BitmapFilter>
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:500: characters 44-55 : ... have: (...) -> Void
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:500: characters 44-55 : ... want: (...) -> Array<...>
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:613: characters 44-49 : Field set_x should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:613: characters 44-49 : Field set_x overrides parent class with different or incomplete type
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/display/DisplayObject.hx:197: characters 19-24 : ... Base field is defined here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:613: characters 44-49 : ... error: Void should be Float
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:613: characters 44-49 : ... have: (...) -> Void
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:613: characters 44-49 : ... want: (...) -> Float
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:632: characters 44-49 : Field set_y should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:632: characters 44-49 : Field set_y overrides parent class with different or incomplete type
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/display/DisplayObject.hx:198: characters 19-24 : ... Base field is defined here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:632: characters 44-49 : ... error: Void should be Float
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:632: characters 44-49 : ... have: (...) -> Void
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:632: characters 44-49 : ... want: (...) -> Float
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:651: characters 44-55 : Field set_visible should be declared with 'override' since it is inherited from superclass flash.display.Sprite
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:651: characters 44-55 : Field set_visible overrides parent class with different or incomplete type
C:/HaxeToolkit/haxe/lib/openfl/git/lib/flash-externs/src/flash/display/DisplayObject.hx:195: characters 19-30 : ... Base field is defined here
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:651: characters 44-55 : ... error: Void should be Bool
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:651: characters 44-55 : ... have: (...) -> Void
C:/HaxeToolkit/haxe/lib/away3d/git/away3d/containers/View3D.hx:651: characters 44-55 : ... want: (...) -> Bool

Starling/Away3D interoperability is broken

I think Starling and Away3D interoperability is currently broken. When I try making a simple demo project with a starling layer and an Away3D layer, it just renders a black screen. Here's an example:

radiosilence_hx.zip
(or on github here: TerryCavanagh/radio-silence-hx@d398652)

This example is basically just following this old Away3D tutorial written with AS3 - http://away3d.com/tutorials/Away3D_and_Starling_Interoperation

In addition, this unrelated issue #39 contains an example Away3D + Starling project, and it just renders a black screen for me too.

(Tested on Haxe 4.3.1, OpenFL 9.2.2, Lime 8.0.2, and Away3D and Starling up to date from github. Apologies if I'm just doing something dumb, as usual)

Stage3D proxy is null in Filter3DRenderer when setting filters3d property

When I add 3d filters to a view, I'm receiving a runtime exception.

Adding filters to my view:

dofFilter = new DepthOfFieldFilter3D(32, 32);
view.filters3d = [ dofFilter ];

In View3D, the set_filters3d() property creates a new Filter3DRenderer

private function set_filters3d(value:Array<Filter3DBase>):Array<Filter3DBase>
{
    ...
    } else if (_filter3DRenderer==null && value!=null) {
        _filter3DRenderer = new Filter3DRenderer(stage3DProxy);  // <-- line 326

In the Filter3DRenderer constructor, stage3DProxy is null.

This errors in Filter3DRenderer at line 35 when adding the event listener.

public function new(stage3DProxy:Stage3DProxy)
{
    _stage3DProxy = stage3DProxy;
    _stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_RECREATED, onContext3DRecreated);

Null object reference at _stage3DProxy.addEventListener()

screen-capture

Apologies if I'm missing something, but I believe the proxy is in error.

I'll put together a small project to isolate this error and help debug this error here.

[HTML5] Stage resizing issues with shared context

If we start application with small browser window at first, then maximize it, stage will be cutted
I've just modified basic/Particles sample Main class, so you can easily reproduce it.
How in can be fixed? Or are there any work arounds?

Just copy this code to basic/Particles/Main.hx and add <haxelib name="starling" /> to project.xml

/*

Basic GPU-based particle animation example in Away3d

Demonstrates:

How to use the ParticleAnimationSet to define static particle behaviour.
How to create particle geometry using the ParticleGeometryHelper class.
How to apply a particle animation to a particle geometry set using ParticleAnimator.
How to create a random spray of particles eminating from a central point.

Code by Rob Bateman & Liao Cheng
[email protected]
http://www.infiniteturtles.co.uk
[email protected]


This code is distributed under the MIT License

Copyright (c) The Away Foundation http://www.theawayfoundation.org

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

*/

package;

import starling.display.Quad;
import openfl.display3D.Context3DRenderMode;
import starling.core.Starling;
import away3d.events.Stage3DEvent;
import away3d.core.managers.Stage3DProxy;
import away3d.core.managers.Stage3DManager;
import away3d.animators.*;
import away3d.animators.data.*;
import away3d.animators.nodes.*;
import away3d.containers.*;
import away3d.controllers.*;
import away3d.core.base.*;
import away3d.debug.*;
import away3d.entities.*;
import away3d.materials.*;
import away3d.primitives.*;
import away3d.tools.helpers.*;
import away3d.utils.*;

import openfl.display.*;
import openfl.events.*;
import openfl.geom.*;
import openfl.Vector;

class Main extends Sprite
{		
	//engine variables
	private var _view:View3D;
	private var _cameraController:HoverController;
	
	//particle variables
	private var _particleAnimationSet:ParticleAnimationSet;
	private var _particleMesh:Mesh;
	private var _particleAnimator:ParticleAnimator;
	
	//navigation variables
	private var _move:Bool = false;
	private var _lastPanAngle:Float;
	private var _lastTiltAngle:Float;
	private var _lastMouseX:Float;
	private var _lastMouseY:Float;
	
	/**
	 * Constructor
	 */
	public function new()
	{
		super();
		
		initProxies();
	}

	private function onContextCreated(event:Stage3DEvent):Void
	{
		initStarling();
		initAway3D();
	}

	var _starling:Starling;

	private function initStarling():Void
	{
		_starling = new Starling(AppDisplay, stage, stage3DProxy.viewPort, stage3DProxy.stage3D, Context3DRenderMode.AUTO);
		_starling.showStats = true;

		stage.addEventListener(openfl.events.Event.ENTER_FRAME, e -> {
			stage3DProxy.clear();

			_starling.nextFrame();
			_view.render();

			stage3DProxy.present();
		});

		_starling.start();
	}

	private function initAway3D():Void
	{
		stage.scaleMode = StageScaleMode.NO_SCALE;
		stage.align = StageAlign.TOP_LEFT;

		_view = new View3D();
		_view.stage3DProxy = stage3DProxy;
		_view.shareContext = true;
		addChild(_view);

		_cameraController = new HoverController(_view.camera, null, 45, 20, 1000);

//		addChild(new AwayStats(_view));

		//setup the particle geometry
		var plane:Geometry = new PlaneGeometry(10, 10, 1, 1, false);
		var geometrySet:Vector<Geometry> = new Vector<Geometry>();
		for (i in 0...20000)
			geometrySet.push(plane);

		//setup the particle animation set
		_particleAnimationSet = new ParticleAnimationSet(true, true);
		_particleAnimationSet.addAnimation(new ParticleBillboardNode());
		_particleAnimationSet.addAnimation(new ParticleVelocityNode(ParticlePropertiesMode.LOCAL_STATIC));
		_particleAnimationSet.initParticleFunc = initParticleFunc;

		//setup the particle material
		var material:TextureMaterial = new TextureMaterial(Cast.bitmapTexture("assets/blue.png"));
		material.blendMode = BlendMode.ADD;

		//setup the particle animator and mesh
		_particleAnimator = new ParticleAnimator(_particleAnimationSet);
		_particleMesh = new Mesh(ParticleGeometryHelper.generateGeometry(geometrySet), material);
		_particleMesh.animator = _particleAnimator;
		_view.scene.addChild(_particleMesh);

		//start the animation
//		_particleAnimator.start();

		//add listeners
		addEventListener(Event.ENTER_FRAME, onEnterFrame);
		stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
		stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
		stage.addEventListener(Event.RESIZE, onResize);
		onResize();
	}

	private var stage3DManager:Stage3DManager;
	private var stage3DProxy:Stage3DProxy;

	private function initProxies():Void
	{
		// Define a new Stage3DManager for the Stage3D objects
		stage3DManager = Stage3DManager.getInstance(stage);

		// Create a new Stage3D proxy to contain the separate views
		stage3DProxy = stage3DManager.getFreeStage3DProxy(false, "enhanced");
		stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATED, onContextCreated);
	}

	/**
	 * Initialiser function for particle properties
	 */
	private function initParticleFunc(prop:ParticleProperties):Void
	{
		prop.startTime = Math.random()*5 - 5;
		prop.duration = 5;
		var degree1:Float = Math.random() * Math.PI ;
		var degree2:Float = Math.random() * Math.PI * 2;
		var r:Float = Math.random() * 50 + 400;
		prop.nodes[ParticleVelocityNode.VELOCITY_VECTOR3D] = new Vector3D(r * Math.sin(degree1) * Math.cos(degree2), r * Math.cos(degree1) * Math.cos(degree2), r * Math.sin(degree2));
	}
	
	/**
	 * Navigation and render loop
	 */		
	private function onEnterFrame(event:Event):Void
	{
		if (_move)
		{
			_cameraController.panAngle = 0.3*(stage.mouseX - _lastMouseX) + _lastPanAngle;
			_cameraController.tiltAngle = 0.3*(stage.mouseY - _lastMouseY) + _lastTiltAngle;
		}
//		_view.render();
	}
	
	/**
	 * Mouse down listener for navigation
	 */		
	private function onMouseDown(event:MouseEvent):Void
	{
		_lastPanAngle = _cameraController.panAngle;
		_lastTiltAngle = _cameraController.tiltAngle;
		_lastMouseX = stage.mouseX;
		_lastMouseY = stage.mouseY;
		_move = true;
		stage.addEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
	}
	
	/**
	 * Mouse up listener for navigation
	 */		
	private function onMouseUp(event:MouseEvent):Void
	{
		_move = false;
		stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
	}
	
	/**
	 * Mouse stage leave listener for navigation
	 */
	private function onStageMouseLeave(event:Event):Void
	{
		_move = false;
		stage.removeEventListener(Event.MOUSE_LEAVE, onStageMouseLeave);
	}
	
	/**
	 * stage listener for resize events
	 */
	private function onResize(event:Event = null):Void
	{
		_view.width = stage.stageWidth;
		_view.height = stage.stageHeight;
	}
}

class AppDisplay extends starling.display.Sprite
{
	public function new()
	{
		super();

		var q:Quad = new Quad(500, 500, 0xFF0000);

		addChild(q);
	}
}

Bug in OrthographicLens.hx

As per bug in Away3D forum post relating to the unproject function in OrthographicLens.hx...

Away3D Forum Post

Can this be implemented in openfl Away3D...

var translation:Vector3D = Matrix3DUtils.CALCULATION_VECTOR3D;
matrix.copyColumnTo(3, translation);
v.x = nX + translation.x;
//v.y = nX + translation.y;
v.y = -nY + translation.y;
v.z = sZ;
v.w = 1;

Broken on native targets

Current version of the library is broken on windows target, as of openfl 4.6.0!

Error: RegisterPool.cpp
./src/away3d/materials/compilation/RegisterPool.cpp(146): error C2374: 'index1': redefinition; multiple initialization
./src/away3d/materials/compilation/RegisterPool.cpp(144): note: see declaration of 'index1'
./src/away3d/materials/compilation/RegisterPool.cpp(147): error C2228: left of '.StaticCast' must have class/struct/union
./src/away3d/materials/compilation/RegisterPool.cpp(147): error C2059: syntax error: ')'
./src/away3d/materials/compilation/RegisterPool.cpp(173): error C2374: 'index1': redefinition; multiple initialization
./src/away3d/materials/compilation/RegisterPool.cpp(171): note: see declaration of 'index1'
./src/away3d/materials/compilation/RegisterPool.cpp(174): error C2228: left of '.StaticCast' must have class/struct/union
./src/away3d/materials/compilation/RegisterPool.cpp(174): error C2059: syntax error: ')'

(hoping it's an easy fix!)

problem with shadow effects

away3d example load3DS doesn't show if I use openfl test windows than it doesn't show like black screen

Can you fix it?

I'm using OpenFL 4.9.1, Lime 4.0.2, HXCPP 3.4.64 and Haxe 3.4.2
And I am using with Visual Studio 2015 Community
where_is_load3ds

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.