API | Uses canvas | Graphics libraries | AB framework | Worlds using this API | Starter Worlds |
Physics (r2) | Yes | Three.js, Ammo | No | 6 Worlds | Starter Worlds |
This API is for Three.js Worlds with physics using ammo.js.
It has no Ancient Brain framework.
Anything written for Three.js with ammo.js should be easily ported to this API.
This API has the following features:
AB.mind.getAction ( state );
ABWorld; // instance of class ABWorldClass // Data and methods of ABWorld: ABWorld.canvas; // to point to the canvas // useful functions for creating/resizing canvas: ABWorld.fullwidth(); // return full width of window on desktop / screen on mobile ABWorld.fullheight(); // return full height of window on desktop / screen on mobileThe AB system will find the canvas automatically (e.g. when it needs to do a screenshot). If the AB system fails to find the canvas, you can help it out by assigning the canvas to ABWorld.canvas.
If you are concerned about performance, you can set preserveDrawingBuffer to be false:
renderer = new THREE.WebGLRenderer ( { preserveDrawingBuffer: false } );But then your World cannot have a screenshot. So a better approach is to set it to true for "generate image" runs and false for normal runs, which can be done as follows:
if ( AB.isScreenshotRun() ) renderer = new THREE.WebGLRenderer ( { preserveDrawingBuffer : true } ); else renderer = new THREE.WebGLRenderer ( { preserveDrawingBuffer : false } );