UNPKG

d2k

Version:

rendering engine from the Dark side of the Force - wip

116 lines (103 loc) 2.84 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>d2k.js - hello world (babylon.js)</title> <style> * { box-sizing: border-box; } html, body { width: 100%; height: 100%; } body { margin: 0; overflow: hidden; } canvas { left: 0; right: 0; top: 0; bottom: 0; width: 100%; height: 100%; z-index: 100; position: absolute; } </style> </head> <body> <canvas id="viewRendering"></canvas> <script src="https://cdn.babylonjs.com/babylon.js"></script> <script src="../../src/3d-object-builder/index.js"></script> <script> window.addEventListener( 'DOMContentLoaded', function () { var BABYLONstarter = d2k .onstarter( { canvas: 'viewRendering' } ) .use( BABYLON ) .withEngine( { name: 'myEngineName' } ) .withScene( { name: 'mySceneName', config: { autoClear: true, clearColor: [ 0.6, 0.6, 0.6 ] } } ) .withCamera( { name: 'myCameraName', config: { args: [ Math.PI / 2, Math.PI / 2, 2, [ 0, 0, 0 ] ], type: 'arc-rotate' } } ) .withLight( { name: 'myLightName', config: { args: [ 0, 1, 0 ], type: 'point' } } ) .withMesh( { name: 'myMeshName', config: [ { args: { size: 0.20 }, position: [ -0.20, 0, 0 ], type: 'box', material: { name: 'material', type: 'standard' } }, { args: { size: 0.20 }, position: [ 0.20, 0, 0 ], type: 'box', material: { name: 'material', type: 'standard' } } ] } ) .value(); var meshes = BABYLONstarter.mesh.myMeshName.getChildren(); BABYLONstarter.mesh.myMeshName.onrender( function ( time ) { meshes[ 0 ].rotation.x -= time; meshes[ 0 ].rotation.y -= time; meshes[ 1 ].rotation.x -= time; meshes[ 1 ].rotation.y -= time; } ); BABYLONstarter.engine.myEngineName.onrender( { engine: BABYLONstarter.engine.myEngineName, scene: BABYLONstarter.scene.mySceneName } ); }, false ); </script> </body> </html>