API | Uses canvas | Graphics libraries | AB framework | Worlds using this API | Starter Worlds |
Three (Module) (r1) | Yes | Three.js | No | 121 Worlds | None |
This API is for Three.js Worlds.
It has no Ancient Brain framework.
Anything written in Three.js
using three.module.js
should run using this API without change.
This API has the following features:
AB.mind.getAction ( state );
You can load Three.js using something like this:
import * as THREE from '/api/threemodule/libs/three.module.js';
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 } );