d2k
Version:
rendering engine from the Dark side of the Force - wip
70 lines (56 loc) • 1.73 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 (glsl)</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" touch-action="none"></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/glsl' )
.then( function ( response ) { return response.json(); } )
.then( function ( data ) {
var scene = data.scene;
var starter = d2k
.onstarter( scene.init )
.use( THREE )
.withShader( scene.shader )
.value();
starter.shader.myShaderName.onrender( function ( time ) {
starter.shader.myShaderName.material.uniforms.time.value += time;
} );
starter.shader.myShaderName.onresize( function ( size ) {
starter.shader.myShaderName.material.uniforms.resolution.value.x = size.width;
starter.shader.myShaderName.material.uniforms.resolution.value.y = size.height;
} );
} );
}, false );
</script>
</body>
</html>