Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
<!DOCTYPE HTML>
<html>
<head>
<title>Bone Hands - Leap</title>
<script type="text/javascript" src="../javascripts/three.r67.js"></script>
<script type="text/javascript" src="../javascripts/lib/physi.js"></script>
<script type="text/javascript" src="../javascripts/leap-0.6.2.min.js"></script>
<script type="text/javascript" src="../javascripts/leap-plugins-0.1.6.min.js"></script>
<script type="text/javascript" src="../javascripts/lib/TrackballControls.js"></script>
<script type="text/javascript" src="../javascripts/leap.widgets.js"></script>
<style type="text/css">#connect-leap{zoom: 0.4;}</style>
</head>
<body>
<script type="text/javascript">
var initScene = function () {
Physijs.scripts.worker = '../javascripts/lib/physijs_worker.js';
window.scene = new Physijs.Scene();
window.scene.addEventListener('update', function() {
scene.simulate( undefined, 2 );
});
// window.scene.setGravity({x:0,y:-100,z:0});
window.scene.setGravity({x:0,y:0,z:0});
window.renderer = new THREE.WebGLRenderer({
alpha: true
});
window.renderer.shadowMapEnabled = true;
window.renderer.shadowMapType = THREE.BasicShadowMap;
window.renderer.setClearColor(0x000000, 0);
window.renderer.setSize(window.innerWidth, window.innerHeight);
window.renderer.domElement.style.position = 'fixed';
window.renderer.domElement.style.top = 0;
window.renderer.domElement.style.left = 0;
window.renderer.domElement.style.width = '100%';
window.renderer.domElement.style.height = '100%';
document.body.appendChild(window.renderer.domElement);
window.widgets = new LeapWidgets(window.scene);
widgets.initLeapHand({sampleRecording: '../recordings/knob.lz'});
var wall = widgets.createWall(new THREE.Vector3(0, 0, -200), new THREE.Vector3(500, 300, 100));
var base = widgets.createWall(new THREE.Vector3(0, -50, -100), new THREE.Vector3(200, 50, 300));
var text = widgets.createLabel("LeapJS Widgets - Knob", new THREE.Vector3(0, wall.position.y+wall.geometry.parameters.height/2-16, wall.position.z+wall.geometry.parameters.depth/2+1), 16, 0xffffff);
var knob = widgets.createSwitch("Knob", new THREE.Vector3(base.position.x, base.position.y+base.geometry.parameters.height/2 + 50, base.position.z+80), 10, 100);
var angleLabel = widgets.createLabel("Up", new THREE.Vector3(-60, base.position.y, base.position.z+base.geometry.parameters.depth/2+1), 16, 0xffffff);
var impactLabel = widgets.createLabel("0", new THREE.Vector3(60, base.position.y, base.position.z+base.geometry.parameters.depth/2+1), 16, 0xffffff);
knob.addEventListener('control', function(evt) {
angleLabel.setText(Math.round(evt.angle*180/Math.PI) + '°');
impactLabel.setText(Math.round(evt.impact));
});
knob.addEventListener('reset', function(evt) {
angleLabel.setText('Up');
impactLabel.setText('0');
});
//knob.addEventListener('collision', function(other_object, relative_velocity, relative_rotation, contact_normal) {
// console.log(knob._physijs.touches);
// knob.setLinearVelocity(new THREE.Vector3().copy(other_object.position));
// if (other_object.sticky && !other_object.point && other_object instanceof Physijs.SphereMesh) {
// other_object.material.color.setHex(0x00000e);
// other_object.point = new Physijs.PointConstraint(
// knob,
// other_object,
// new THREE.Vector3().copy(knob.position)
// );
// window.scene.addConstraint(other_object.point);
// }
//});
var spotLight = new THREE.SpotLight(0xffffff, 1);
spotLight.shadowCameraVisible = true;
spotLight.castShadow = true;
spotLight.shadowMapWidth = 6048;
spotLight.shadowMapHeight = 6048;
spotLight.shadowCameraFar = 1000;
spotLight.shadowDarkness = 0.5;
spotLight.position.fromArray([wall.position.x, knob.position.y, wall.position.z + 1000]);
spotLight.target.position.copy(wall.position);
scene.add(spotLight);
window.camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
window.camera.position.fromArray([0, wall.position.y+wall.geometry.parameters.height/3, 350]);
window.camera.lookAt(new THREE.Vector3(0, wall.position.y, wall.position.z));
window.addEventListener('resize', function () {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.render(scene, camera);
}, false);
scene.add(camera);
};
initScene();
</script>
</body>
</html>