d2k
Version:
rendering engine from the Dark side of the Force - wip
114 lines (102 loc) • 2.93 kB
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 (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 () {
var THREEstarter = d2k
.onstarter( { canvas: 'viewRendering' } )
.use( THREE )
.withCamera( {
name: 'myCameraName',
config: {
args: [ 75, window.innerWidth / window.innerHeight, 0.1, 1000 ],
position: [ 0, 0, 100 ],
type: 'perspective'
}
} )
.withMesh( {
name: 'myMeshName',
config: [ {
visible: true,
position: [ -20, 0, 0 ],
geometry: {
args: [ 20, 20, 20 ],
type: 'box-buffer'
},
material: {
type: 'mesh-normal'
}
},
{
visible: true,
position: [ 20, 0, 0 ],
geometry: {
args: [ 20, 20, 20 ],
type: 'box'
},
material: {
type: 'mesh-normal'
}
} ]
} )
.withScene( {
name: 'mySceneName'
} )
.withRenderer( {
name: 'myRendererName',
config: {
autoClear: true,
pixelRatio: window.devicePixelRatio,
size: [ window.innerWidth, window.innerHeight ]
}
} )
.composify( {
config: {
start: true,
scene: { main: 'mySceneName' },
mesh: [ { name: 'myMeshName', sceneParent: 'main' } ],
camera: { main: 'myCameraName' },
renderer: 'myRendererName'
}
} )
.value();
THREEstarter.mesh.myMeshName.onrender( function ( time ) {
THREEstarter.mesh.myMeshName.children[ 0 ].rotation.x += time;
THREEstarter.mesh.myMeshName.children[ 0 ].rotation.y += time;
THREEstarter.mesh.myMeshName.children[ 1 ].rotation.x += time;
THREEstarter.mesh.myMeshName.children[ 1 ].rotation.y += time;
} );
}, false );
</script>
</body>
</html>