WhitestormJS / whs.js

:rocket: 🌪 Super-fast 3D framework for Web Applications 🥇 & Games 🎮. Based on Three.js
MIT License
6.13k stars 391 forks source link

Core API #216

Open sasha240100 opened 7 years ago

sasha240100 commented 7 years ago

API

This issue exists for v2.x.x API discussion. Please, add your API suggestions in comments below

App

This class is used to prepare a world scene, setup physics, camera, renderer and all other things that you usually do before making meshes.

components

Component is a main class which is commonly used in core parts of WhitestormJS framework. Component is used in MeshComponent and almost all known classes of framework.

modules

Modules provide easy integration with components. They can make a lot of complex things much simpler to other developers (such as adding 3D physics).

Version:
Issue type:

Tested on: ###### Desktop - [ ] Chrome - [ ] Chrome Canary - [ ] Chrome dev-channel - [ ] Firefox - [ ] Opera - [ ] Microsoft IE - [ ] Microsoft Edge ###### Android - [ ] Chrome - [ ] Firefox - [ ] Opera ###### IOS - [ ] Chrome - [ ] Firefox - [ ] Opera
sasha240100 commented 7 years ago

/ping @thejmazz

ide commented 6 years ago

One suggestion for the module API: swap this and self in integrate(self). Currently:

class Module {
  integrate(self) {
    // `this` is the app instance
    // `self` is the module instance
  }
}

let app = new WHS.App([new Module()]);

A new API would look like:

class Module {
  version = 2;  // Tell WHS to use a new module API. This way existing modules don't break.
  integrate(component) {
    // `this` is the module instance
    // `component` is the app instance
  }
}