mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 19:43:48 +01:00
134 lines
2.8 KiB
HTML
Executable File
134 lines
2.8 KiB
HTML
Executable File
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>three.js webgl - collada - skinning</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
|
|
<style>
|
|
body {
|
|
color: #000;
|
|
font-family:Monospace;
|
|
font-size:13px;
|
|
text-align:center;
|
|
|
|
background-color: #000;
|
|
margin: 0px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#info {
|
|
position: absolute;
|
|
top: 0px; width: 100%;
|
|
padding: 5px;
|
|
}
|
|
|
|
a {
|
|
|
|
color: #f00;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="container"></div>
|
|
|
|
<div id="info">
|
|
<a href="http://threejs.org" target="_blank">three.js</a> webgl - collada - skinning
|
|
</div>
|
|
|
|
<script src="../build/three.min.js"></script>
|
|
<script src="js/loaders/ColladaLoader.js"></script>
|
|
<script src="js/Detector.js"></script>
|
|
<script src="js/libs/stats.min.js"></script>
|
|
|
|
<script>
|
|
|
|
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
|
|
|
|
var container, stats;
|
|
var camera, scene, renderer;
|
|
var clock = new THREE.Clock();
|
|
|
|
init();
|
|
|
|
function init() {
|
|
|
|
container = document.getElementById( 'container' );
|
|
|
|
camera = new THREE.PerspectiveCamera( 25, window.innerWidth / window.innerHeight, 1, 10000 );
|
|
camera.position.set( -5, -5, 5 );
|
|
camera.up.set( 0, 0, 1 );
|
|
|
|
scene = new THREE.Scene();
|
|
|
|
var light = new THREE.DirectionalLight( 0xffffff, 1.5 );
|
|
light.position.set( 0, -4, -4 ).normalize();
|
|
scene.add( light );
|
|
|
|
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
|
renderer.setClearColor( 0xfff4e5 );
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
|
renderer.sortObjects = false;
|
|
container.appendChild( renderer.domElement );
|
|
|
|
stats = new Stats();
|
|
stats.domElement.style.position = 'absolute';
|
|
stats.domElement.style.top = '0px';
|
|
container.appendChild( stats.domElement );
|
|
|
|
|
|
var loader = new THREE.ColladaLoader();
|
|
loader.load( "./models/collada/avatar.dae", function ( collada ) {
|
|
|
|
collada.scene.traverse( function ( child ) {
|
|
|
|
if ( child instanceof THREE.SkinnedMesh ) {
|
|
|
|
var animation = new THREE.Animation( child, child.geometry.animation );
|
|
animation.play();
|
|
|
|
camera.lookAt( child.position );
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
scene.add( collada.scene );
|
|
|
|
} );
|
|
|
|
window.addEventListener( 'resize', onWindowResize, false );
|
|
|
|
animate();
|
|
|
|
}
|
|
|
|
function onWindowResize() {
|
|
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
camera.updateProjectionMatrix();
|
|
|
|
renderer.setSize( window.innerWidth, window.innerHeight );
|
|
|
|
}
|
|
|
|
function animate() {
|
|
|
|
requestAnimationFrame( animate, renderer.domElement );
|
|
|
|
THREE.AnimationHandler.update( clock.getDelta() );
|
|
|
|
renderer.render( scene, camera );
|
|
|
|
stats.update();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|
|
|