API | Uses canvas | Graphics libraries | AB framework | Worlds using this API | Starter Worlds |
Three (r2) | Yes | Three.js | No | 34 Worlds | Starter Worlds |
This API is for Three.js Worlds.
It has no Ancient Brain framework.
Anything written in Three.js should run using this API without change.
This API has the following features:
AB.mind.getAction ( state );
ABWorld; // instance of class ABWorldClass ABWorld.canvas; // a variable to point to the canvas // When making a screenshot, Ancient Brain will search for the canvas. // If it cannot find the canvas, set this variable to point to it. ABWorld.fullwidth(); // return full width of window on desktop / screen on mobile ABWorld.fullheight(); // return full height of window on desktop / screen on mobile
We need to allow runs to generate a
World image screenshot from the canvas.
To allow this, the API sets the
THREE.WebGLRenderer
property "preserveDrawingBuffer" to true by default.
The API takes care of this for you.
When you make your own renderer, you need to consider "preserveDrawingBuffer".
If you create the renderer like the following, then your World cannot have a screenshot:
renderer = new THREE.WebGLRenderer ( { preserveDrawingBuffer: false } );To solve this, you can make preserveDrawingBuffer always true, or make it true only on screenshot runs:
if ( AB.isScreenshotRun() ) renderer = new THREE.WebGLRenderer ( { preserveDrawingBuffer : true } ); else renderer = new THREE.WebGLRenderer ( { preserveDrawingBuffer : false } );