Hello guys,
I actually working on a personal project that I would like to share. I think maybe this project can help people. So, d2k.js is a javascript micro-layer based on three.js and babylon.js that will help you to create the webgl in a intuitive an functional way. This project also implement an experimental mode to use three.js and babylon.js in a single canvas. It can be cool if you want to use the a Xbox 360 pad to move objects 3D from babylon and three also. D2k do not replace babylon’s or threejs, it is dependent on them, you need to include them in your project
npm: https://www.npmjs.com/package/d2k
github: https://github.com/monsieurbadia/d2k.js
With d2k.js you will be able to :
- automate the creation of primitive
- automate the scene composition
- create several scene from a json config file
- switch between babylon and three with one line of code
- render scene from babylon and three in one canvas
to do a hello world
window.addEventListener( "DOMContentLoaded", _ => {
const THREEstarter = d2k
.onstarter( { canvas: 'myCanvasId' } )
.use( THREE )
.withCamera( { name: 'myCameraName' } )
.withLight( { name: 'myLightName' } ) // optional
.withMesh( { name: 'myMeshName' } )
.withScene( { name: 'mySceneName' } )
.withRenderer( { name: 'myRendererName' } )
.composify( {
config: {
start: true,
scene: {
main: 'mySceneName',
others: [ { name: 'mySceneBackgroundName' } ]
},
mesh: [ { name: 'myMeshName', parent: 'main' } ],
light: [ { name: 'myLightName', parent: 'main' } ],
camera: {
main: 'myCameraName',
others: [ { name: 'another' } ]
},
renderer: 'myRendererName'
}
} )
.value();
THREEstarter.mesh.myMeshName.onrender( time => {
THREEstarter.mesh.myMeshName.rotation.x += time;
THREEstarter.mesh.myMeshName.rotation.y += time;
} );
}, false );
If you need more information check the readme file.
This project is just the skeleton of an idea. It’s harsh to understand two complexes libraries in so I know that I still have a lot stuff to do before supporting all primitives correctly from both libraries. Keep in mind that I’m an artist not an engineer so my mindset it’s quite different, this can have an impact in my code. But I will try to do my best each day, to improve this project, I need feedback, so if you are curious or you have a few time to use it, go ahead. Don’t forget to send me a message or contact me on twitter. That will help me!
Sorry for my bad English… Stay at home and be safe.
Cheers,
monsieurbadia