Plugin Documentation

Enable 3D rendering with by using Three.js.

For maximum performance, use this plugin together with PixiJS plugin.

Models

Three.js plugin can load OBJ and FBX models. If the model contains any material files, they will be automatically loaded.

game.addAsset('model.obj');
game.addAsset('model2.fbx');

game.createScene('Main', {
    init: function() {
        var model = game.getOBJ('model.obj');
        var model2 = game.getFBX('model2.fbx');
    }
});

Helper

You can use THREE.Texture.fromAsset helper function to create THREE.Texture from asset.

game.addAsset('panda.png');

game.createScene('Main', {
    init: function() {
        var threeTexture = THREE.Texture.fromAsset('panda.png');
    }
});

Config

You can set THREE.WebGLRenderer parameters from game.config module:

game.config = {
    three: {
        preserveDrawingBuffer: true
    }
}

Debugging

View Three.js render and memory info on debug panel by setting these values in game.config module:

game.config = {
    three: {
        debugRender: true,
        debugMemory: true
    }
}

Releases

1.6.0

  • Added autoDispose attribute to Container3D
  • Added dispose parameter to remove method in Object3D
  • Added error message when MTL loading fails
  • Added usage of game.Texture as texture in Object3D
  • Added openEnded parameter to Cylinder3D
  • Fixed scene cleaning
  • Fixed dynamic loading of game.Texture

1.5.1

  • Fixed loading error to show error on console
  • Fixed loading FBX without animation
  • Fixed memory leaking, when setting new scene

1.5.0

  • Added support for FBX files
  • Updated Three.js to revision 99

1.4.0

  • Added support for multiple materials in Object3D
  • Added more examples

1.3.0

  • Added game classes Container3D, Object3D, Box3D, Sphere3D, Plane3D and Cylinder3D
  • Added more examples