d2k
Version:
rendering engine from the Dark side of the Force - wip
79 lines (63 loc) • 2.05 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 - cube texture (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" touch-action="none"></canvas>
<script src="https://threejs.org/build/three.js"></script>
<script src="../../src/3d-object-builder/index.js"></script>
<script>
window.addEventListener( 'DOMContentLoaded', function () {
var starter = fetch( 'http://localhost:5007/api/scene/three' )
.then( function ( response ) { return response.json(); } )
.then( function ( data ) {
var scene = data.scene;
var starter = d2k
.onstarter( { canvas: 'viewRendering' } )
.use( THREE )
.withLoader( scene.loader )
.withCamera( scene.camera )
.withRenderer( scene.renderer )
.withMesh( scene.mesh )
.withLight( scene.light )
.withScene( scene.scene )
.composify( scene.composify )
.value();
starter.mesh.myMeshName.onloader( function ( textures ) {
starter.mesh.myMeshName.material.map = textures.find( function ( texture ) { return texture.name === 'img-1'; } );
starter.mesh.myMeshName.material.needsUpdate = true;
} );
starter.mesh.myMeshName.onrender( function ( time ) {
starter.mesh.myMeshName.rotation.x += time;
starter.mesh.myMeshName.rotation.y += time;
} );
} );
}, false );
</script>
</body>
</html>