Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
Elisée Maurer edited this page Jan 27, 2016 · 2 revisions

Superpowers Game

This is the documentation wiki for Superpowers Game, a Superpowers system for 2D and 3D game development with TypeScript, powered by Three.js under the hood.

This wiki's purpose is to explain how Superpowers Game is designed and how it works.
You can find tutorials at http://docs.superpowers-html5.com/

Scripting API and underlying engine

In Superpowers Game, you work with actors. An actor is an object with a 3D transform and a list of components. There are several levels of abstraction though.

To your scripts, actors are exposed as the Sup.Actor class (declaration, implementation).

The Sup.Actor class has a hidden property called __inner that references the underlying SupEngine.Actor class.

SupEngine.Actor objects themselves store a THREE.Object3D instance in their threeObject property. This is the actual Three.js object that is added to the main THREE.Scene and where your various renderer components will attach their meshes.

Sup.Actor — The public API for scripting with actors
(myActor as any).__inner — The underlying `SupEngine.Actor` object for an actor
(myActor as any).__inner.threeObject — The underlying THREE.Object3D for an actor
(myActor as any).__inner.components — The list of underlying components for an actor

Components expose a public API too. For instance, the Sup.ModelRenderer class (declaration, implementation).

Components have an __inner property too, that references their underlying SupEngine.ActorComponent-derived class. In our case, that's the ModelRenderer class.

If the component is a renderer, its underlying engine class will probably have a threeMesh property which holds a THREE.Mesh.

someActor.modelRenderer — The public API for scripting model renderers
(someActor.modelRenderer as any).__inner — The underlying `ModelRenderer` class that inherits from `SupEngine.ActorComponent`
(someActor.modelRenderer as any).__inner.threeMesh — The `THREE.Mesh` parented to `someActor.__inner.threeObject`
Clone this wiki locally