BabylonJS - spaces
by kolar
HTML
<script src="https://dl.dropboxusercontent.com/u/12395133/babylon.1.11.js"></script>
<textarea id="log"></textarea>
<div id="rootDiv">
<canvas id="canvas"></canvas>
</div>
CSS
html, body, div, canvas {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: hidden;
}
#log {
position:fixed;
color:#555;
font-size:11px;
font-family:courier;
width:180px;
height:300px;
}
JavaScript
var canvas = document.getElementById("canvas");
var engine = new BABYLON.Engine(canvas, false);
var scene = new BABYLON.Scene(engine);
var camera = new BABYLON.ArcRotateCamera("Camera", 1, 0.8, 10, new BABYLON.Vector3(0, 0, 0), scene);
camera.setPosition(new BABYLON.Vector3(0, 10, -10));
var light0 = new BABYLON.HemisphericLight("Omni", new BABYLON.Vector3(0, 0, 10), scene);
scene.activeCamera.attachControl(canvas);
engine.runRenderLoop(function () {
scene.render();
});
function importMesh() {
BABYLON.SceneLoader.ImportMesh(null, "https://dl.dropboxusercontent.com/u/12395133/", "bieber.babylon", scene, function (newMeshes, particleSystems, skeletons) {
var chlop = newMeshes[0];
scene.beginAnimation(skeletons[0], 11, 30, true, 1.0);
});
}
importMesh();
$('#canvas').click(function(e) {
var offset = $(this).offset();
var x = e.clientX - offset.left;
var y = e.clientY - offset.top;
var p = scene.pick(x,y);
var ix=scene.meshes.indexOf(p.pickedMesh);
if(ix>=0) {
scene.meshes.splice(ix, 1);
}
importMesh();
});
function log(txt){
$("#log").val( $("#log").val() + txt + "\n" );
}
setInterval(function(){
log("num of tex: "+scene.textures.length);
log("num of skel: "+scene.skeletons.length);
}, 1000);