3D Library Adventure


  • Posts: 1654
Last Ludum Dare I got a taste of 3D.

Since that time I was looking into other libraries then ThreeJS (html5 only) which I used first.
I couldn't stand that there was no cross-platform solution.

I've finally found one that does half what I want : Away3D.

With a little help from Justin I was able to draw stuff on all the publication methods of Stencyl.
Since I was using the 3.5 beta version, and didn't want to upgrade my old macbook, I was only able to test using the simulator and didn't have the opportunity to do a device test.

So : iOS Simulator, Android, Linux, Mac, Windows, Flash and HTML5 all work just fine.

Here are some of the screenshots:

  HTML5 Demos

Unfortunately there is no HaXe port of the AwayPhysics library, so for now I'm trying to do stuff with simple physics/collision bounding boxes.

I've started a new journal to investigate how to make an extension out of this.

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • *
  • Posts: 2720
The screenshots look great. An extension for 3D cross-platform will be fantastic.
Despite its limitations, let's hope it was viable enough to make commercial games.
Thank you very much for your excellent work.

I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.


  • *
  • Posts: 2726
Nice screenshots so far! Please do keep us posted; this looks really interesting. I'd be particularly interested in learning how you integrated the Away3D library into Stencyl.


  • Posts: 1654
For Merrak (and for those of you who like to read a lot of stuff)

Log July-August

* BabylonHx
* OmniHx3D
* HaxeBullet (might revisit)
* Away3D (see for all the steps to actually make something work : next post)


This works with haxelib run lime but with an older haxe.
I would have liked to get this to work since it has collision detection / physics and much
more features than Away3D.

Trying to convert the library to Stencyl 3.4 and/or 3.5
     Loads of 'Float32' Type conversion. Comparing stuff to null.
   To even get some small demo to work it took me 2 days to correct all those errors.
   When I started with the next small demo it gave another huge list of errors to correct.
   That was with demos using a scene, camera and 1 object; not even fancy stuff or collision detection

Windows 7 64bit (profesional) [ Windows XP does not work (32bit) ]  in Virtual Box on Mac

Environment variables:

HAXEPATH c:\haxe
Download : Haxe 3.2.0rc
    download haxe 3.2.0rc

Extrac into c:\haxe (so copy paste files from the 3.2.0rc directory

For neko version refer to this list:


2.*   1.*

3.0.0   2.0.0

3.1.3   2.0.0

3.2.0   2.0.0

3.3.0   2.1.0

3.4.0   2.1.0

So Neko 2.0.0 it is. Download from package.chocolatey.org/packages/neko/2.0.0 > neko.2.0.0.nupkg

 7-zip unarchive

* haxelib selfupdate

current version is now 3.2.0-rc.3

* haxelib install lime


* haxelib run lime setup windows

(Vc++ Express  installation)

* haxelib install lime 2.7.0

* haxelib install hxcpp 3.2.193

* haxelib install openfl 3.4.0

* haxelib install actuate 1.8.6

* haxelib install format 3.2.1

* haxelib install poly2trihx 0.1.4

* Download & install git : https://git-scm.com/download/win

* haxelib git BabylonHx https://github.com/vujadin/BabylonHx

* haxelib git BabylonHxSimpleTest https://github.com/jfroco/BabylonHxSimpleTest
 haxelib_client 3.2.0rc3
 actuate 1.8.7
 hxcpp 3.4.64
 openfl 3.4.0
 lime : 2.7.0
haxelib run lime setup (will install windows)

If you want to install Visual C++ 2015 you need to select language:
*        Custom -> Next
*         Programming Languages (collapse)
*        Visual C++ languages
*         Next
*          Signing with your microsoft account (create one if needed)
*      Team : click on not now link next to button
*   Start Visual Studio so that it goes through the project phase.


* haxelib run lime build project.xml windows
This takes some time as it creates afile:

This works!

Attempt with Stencyl (installed into c:\abc)

* haxelib setup c:\abc\plaf\haxe\lib

* haxelib list

Should list stencyl among others

If you want to make another version active use:
* haxelib set lime 3.2.1
* haxelib run lime setup (installs bunch of stuff)

* haxelib install hxcpp
* haxelib install lime
* haxelib run lime setup windows
* haxelib run lime build project.xml windows

Failed due to type mismatches.

After moving back and forth between different stencyl versions (3.2 upwards)
and not getting good compilation and with the week re-coding to not get much done
I gave up on BabylonHX


After installation it immediately gave huge lists of type errors.
Not wanting to go the same route as with Babylon: I gave up



Finally a library that didn't reported an error when using just a 3d View.

The next post has the steps to get a sample working on haxe AND in Stencyl

« Last Edit: August 17, 2017, 05:57:28 am by mdotedot »
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • Posts: 1654
I've made the following test case:

* Oracle Linux
* Stencyl Beta 3.5 9480
* Copy-Pasted the native example to a Away3D folder and modified the info.txt, blocks.xml and renamed the .hx to Away3D.hx
* Modify the blocks.xml and info.txt to reflect the Away3D references.
* Download the Away3D github haxe library and put it the away3d folder in the engine-extension

To test outside Stencyl I used these steps:
* haxelib setup <your plaf/haxe/lib path>

Code: [Select]

# to set the environment in Stencyl : haxelib setup $HOME/Downloads/plaf/haxe/lib
rm -rf Export/flash/release/bin/Away3D.swf # remove Example
haxelib run openfl build project.xml flash # build example
/root/Downloads/ext-tools/players/flash-10-linux Export/flash/release/bin/Away3D.swf

Code: [Select]
import openfl.display3D.*;

import openfl.display.StageScaleMode;
import openfl.display.StageAlign;
import openfl.display.Sprite;
import openfl.display.BitmapData;
import openfl.display.Bitmap;
import openfl.events.Event;
import openfl.geom.Vector3D;
import openfl.Lib;

import openfl.display3D.*;
import openfl.display.Stage3D;

import openfl.display.Shape;

// Away3D
import away3d.containers.View3D;
import away3d.debug.*;
import away3d.entities.Mesh;
import away3d.materials.*; // colorMaterial
import away3d.primitives.*; // CubeGeometry
import away3d.utils.Cast;
import away3d.events.*;
import away3d.core.managers.*;

import away3d.events.*;

class Away3D extends Sprite{

        // Stencyl will use pass root stage
        private var stg:openfl.display.Stage;

        private  var _view:View3D;

        //scene objects
        private var _plane:Mesh;
        private  var _cube:Mesh;
        private var _player:Mesh;

        public var context:openfl.display3D.Context3D;
        private var cubeMaterial:ColorMaterial;
        private var collidedMaterial:ColorMaterial;

        #if stencyl
                private var engine:com.stencyl.Engine;

        // render loop
        private  function _onEnterFrame(e:Event):Void

                #if stencyl
                        engine.setGameAttribute('Debug', 'PlayerX:'+_player.x);


                // Collision Detection
                if (_cube.worldBounds.overlaps(_player.worldBounds)){
                        _cube.material = collidedMaterial;
                        _cube.material = cubeMaterial;
                } // collision


        } // onEnterFrame

        private function init(){
 trace('in init');
                // Context
                context = stg.stage3Ds[0].context3D;

                // away3D view
                _view = new View3D();

                _view.camera.z = -1200;
                _view.camera.y = 200;
                _view.camera.lookAt(new Vector3D());

                cubeMaterial=new ColorMaterial(0xff0000);
                collidedMaterial=new ColorMaterial(0xff00ff);

                _cube = new Mesh(new CubeGeometry(200, 200, 200, 1, 1, 1, false),  new ColorMaterial(0xff0000));

                _cube.x = 300;
                _cube.y = 160;
                _cube.z = -250;

                _player = new Mesh(new CubeGeometry(130, 130, 130,1,1,1, false),  new ColorMaterial(0xffff00));
trace(' the cube is : '+_cube);


                // render listener
                stg.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
        } // init

#if stencyl
        public  function stencyl(_engine:com.stencyl.Engine){


                // for android/iOS : force opaqueBackground : Stencyl overwrite
                #if mobile
                        // You still need 'no color' on scene property

        // haxelib run will call this (project.xml Main '')
        public function new() {
                #if !stencyl
                        // Stage

} // Away3D class

// eof haxe file

Code: [Select]
<?xml version=”1.0" encoding=”utf-8"?>

 <meta title="Away3DTest" package="" version="1.0.0" company="MyCompany" />
 <app main="Away3D" path="Export" file="Away3D" />
 <source path="." />

 <haxelib name="openfl" />


You can now do the run.sh on the system to get a swf file.


Create a scene with background properties set to NO COLOR !!!!!!!!!

Add Away3D extension using the Settings : Extension tab.

To call the code from Stencyl this is all it takes:
Code: [Select]
var a=new Away3D();

Since this code works we now can make more examples and investigate all the Away3D possibilities.

Thanks to Justin to get the engine.root.stage from the Stencyl Engine since without this it
would not show antyhing.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • Posts: 1654
First Person Terrain Walking Demo

A lot of animated Knights

Mouse Pointing at Objects

« Last Edit: August 17, 2017, 07:09:07 am by mdotedot »
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • Posts: 1654
Thanks Squeeb.

Hopefully I can create an actual game with it.

This last demo looks promising to pull it off. Use the numbers to do an animation:

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • *
  • Posts: 1228
Wow, this is really cool!!!!! :D Interested to see what you make with it.

I'm sure I'm not smart enough to use it as is but if it ever gets integrated with easy design mode blocks to let people add 3d models to their otherwise 2d games then that would be incredibly wild. Could be neat for backgrounds, special bosses, cutscenes, etc. (I have no expectations of this btw, just dreaming)


  • Posts: 2262
This is incredible. Can't wait to see where this goes.


  • *
  • Posts: 2726
An interesting read!

Earlier in the summer I had bookmarked BabylonHX as something to look into, but I decided to write my own renderer for my purposes. It's nice to know this can be done, though... especially if I ever get stuck. I just recently started digging into OpenFL, learning what stages are and how rendering is done at a lower level. I think I see what you're doing now, if my understanding of how Stencyl is built over OpenFL is right.

Anyway.. looking forward to what you come up with in the next phase :) Great work so far!


  • Posts: 131
Hi Guys.

Wow. This is really awesome!  :o  :o  :o If this becomes a success, I will not hesitate to pay for it's further development. Looking forward to this. Great Job. Let's see what Chief has to say about this.



  • Posts: 1654
Thanks for all the feedback.

This weeks investigation (Next Post = actual part of pipeline)

I had a look at some tools to create 3D assets. Previously I used examples from Away3D and things I found on the internet.
But I want to get a grasp on the tools needed to actually make these assets.

My personal preferences:
* Free to use : I have no problem paying for stuff but I should need that tool daily or really often to make it worth my money.
* Somewhat user-friendly. Although I do realise it is a new skill that needs to be learned.
* Preferably one tool

If anybody know of a good (free) 3D tool that can export OBJ and MD5(anim/mesh) please let me know!!

Away Builder
URL: http://awaytools.com/awaybuilder/live-tool/

This gives a taste of what you can do to create scenes. This looks very promising to get into the pipeline.
Especially for non-animated objects.

It is free. It is from the same makers as the library so a good integration as far as I can now tell with my tests.

You can download the tool to your computer rather than using the online version (if it ever gets to be pulled offline)

Download URL: https://github.com/awaytools/AwayBuilder

Downside: it cannot do animations ( although it looked it would do it   >:(   )

Magica Voxel

A really nice tool and it can do OBJect animations. Unfortunately this is not automatically interpreted by the Away3D code.
But I might give it a shot when exporting single frames to the engine and make an in-engine-animation.


Houdini Apprentice 16.0.671 (non-commercial version) 

Could not get animation to work.



This can export to DAE but from what I’ve seen it is only human animation

What bothers me the most is that it is from Adobe. Now free but probably will be the same as photoshop and other things from Adobe: subscription based.

URL: https://www.daz3d.com/
register to download. (supposedly free, so no trial period)

Result : too large DAE file 60MB (!)
But what the main issue is:  Too much emphasis on human animation.

Not free in the long run and it is too expensive for my taste


Lots of reports that it doesn’t work.
Let us see what does and does not work !

(See Next Post)
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • Posts: 1654
So for the next phase I'm looking to create some assets with Blender.

I have found a way to get animations to export. It is a very delicate process.
I hope to get a better, steady workflow since currently I'm struggling a lot to get my head around 3D tools like Blender.
It probably can do amazing stuff and it would likely be the free tool that I want that can do both animation and object generation.

As always I like programming more than creating assets/levels so I kind of lack the spirit to really investigate and learn Blender the way I kind of should.

But at least I have now a process that allows m.e. to create something myself and use it in the Away3D engine!

  Blender Exporting Animations
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.


  • Posts: 1654
After a long weekend of investigations, Blender, AwayBuilder  I have decided to alter the Away3D engine a bit for future use.

The issue was that loading MD5Mesh and/or OBJ files the materials are either not loaded with the objects or are referenced in such a manner that the Away3D engine would re-map the (color)textures again.

For our future extension we need a way to map / bind a color or mapped texture to a (sub)mesh.

So I changed some part of the parsers.  I will document this for future reference:

* away3d/loaders/parsers/OBJParser.hx
Change parseLine function to:
Code: [Select]
private function parseLine(trunk:Array<String>):Void
switch (trunk[0]) {
case "mtllib":
_mtlLib = true;
//_mtlLibLoaded = false; // M.E. mtl file doesn't get found in the extras folder .. only base-folder :(
//loadMtl(trunk[1]);     // M.E.Don't try to load otherwise other code is not executed
case "g":
case "o":
case "usemtl":
if (_mtlLib) {
// if (trunk[1] != "")      // M.E. don't change trunk
// trunk[1] = "def000"; //M.E. keep the original name

_activeMaterialID = trunk[1];
if (_currentGroup != null)
_currentGroup.materialID = _activeMaterialID;

case "v":
case "vt":
case "vn":
case "f":

Make the loader set a default material when subMesh contains a material name
Code: [Select]
for (i in 0..._meshData.length){
_geometry.addSubGeometry(translateGeom(_meshData[i].vertexData, _meshData[i].weightData, _meshData[i].indices));

// M.E. : Make a default material and give it the material name from the MD5Mesh file
for(j in 0 ... _mesh.subMeshes.length){
_mesh.subMeshes[j].material=new ColorMaterial(0x00); // Default to a material
//_geometry.animation = _animation;
// _mesh.animationController = _animationController;
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.