Code Monkey home page Code Monkey logo

3d's Introduction

3d

ThreeApp

This repo is an experiment used as a demo for the talks @gdl_js. It proposes a Three.js app structure using NanoWidget implementation of the Widget pattern.

Video

https://youtu.be/MZQmJr0FmZs?t=1h9m39s

##Slides https://docs.google.com/presentation/d/1bwAGiKeEwiZ82vfW7Bg5P9K5kQfDEWOa-xA_EmEYuYc/edit?usp=sharing

NanoWidget based THREEjs Framework

The experiment lies on the way the framework is buit, we have a simple koa server to serve the js app located at localhost:3000

npm install
npm start

The index.js is the one that kickstarts the app, this will create a window.Dispatcher singleton and also instanciate, setup() and render the main app element.

Our main app.js will instanciate an ThreeEngine which by itself instanciates a THREE.Camera, THREE.Scene and a THREE.Renderer which offers a domElement as the rendering api. The main app will take this element and render it to the DOM. It will handle the requestAnimationFrame loop and 'update' using a broadcast event using the global Dispatcher.

NanoThreeWidget

The main experiment is to check if this API makes sense for simple component based apps, the Widget pattern in theory can be applied to any rendereable components, this experiment tries to prove thats possible and keep being as easy to use as Widget.

API

class NanoThreejsWidget extends includes(NanoCustomEventSupport, NanoNodeSupport) {
  //.element An empty 3DObject as a holder of Widget elements

  //Adds the inner element to the caller element
  render (element) {}

  //Removes and element from the caller element
  take (element) {}

  //Adds a custom UserData.active prop in the 3D object and sets it to true
  activate () {}
  
  //Adds a custom UserData.active prop in the 3D object and sets it to false
  deactivate() {}
  
  //Adds a custom UserData.disabled prop in the 3D object and sets it to false
  enable() {}
  
  //Adds a custom UserData.disabled prop in the 3D object and sets it to true
  disable() {}
  
  //Calls for element removal, and nullification
  destroy () {}
  
  //Remove element
  destroyElement () {}

  //Overideables private methods
  _getElement () {} //it should return an ".add eable" THREE object element
  _render (element) {}
  _take (element) {}
  _activate() {}
  _deactivate() {}
  _enable() {}
  _disable() {}
  _destroy () {}
  _destroyElement () {}
}

And has the NanoNodeSupport and NanoEventSupport Api ready to use for hierarchy and event handling.

Finally it instanciates the main "3D" app,

3d's People

Contributors

escusado avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.