d2k
Version:
rendering engine from the Dark side of the Force - wip
71 lines (58 loc) • 1.68 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>d2k.js - tips - fetch hello world (three.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;
z-index: 100;
position: absolute;
}
</style>
</head>
<body>
<canvas id="viewRendering"></canvas>
<script src="https://threejs.org/build/three.min.js"></script>
<script src="./../../src/3d-object-builder/index.js"></script>
<script>
window.addEventListener( 'DOMContentLoaded', function () {
fetch( 'http://localhost:5007/api/scene/three' )
.then( function ( response ) { return response.json(); } )
.then( function ( data ) {
var scene = data.scene;
var starter = d2k
.onstarter( scene.init )
.use( THREE )
.withCamera( scene.camera )
.withRenderer( scene.renderer )
.withMesh( scene.mesh )
.withLight( scene.light )
.withScene( scene.scene )
.composify( scene.composify )
.value();
starter.mesh.myMeshName.onrender( time => {
starter.mesh.myMeshName.rotation.x += time;
starter.mesh.myMeshName.rotation.y += time;
} );
} );
}, false );
</script>
</body>
</html>