Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var canvas = document.getElementById("renderCanvas");
- var engine = new BABYLON.Engine(canvas, true);
- var createScene = function () {
- // This creates a basic Babylon Scene object (non-mesh)
- var scene = new BABYLON.Scene(engine);
- // This creates and positions a free camera (non-mesh)
- var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 7, 17), scene);
- // This targets the camera to scene origin
- camera.setTarget(BABYLON.Vector3.Zero());
- // This attaches the camera to the canvas
- camera.attachControl(canvas, true);
- // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
- var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
- // Default intensity is 1. Let's dim the light a small amount
- light.intensity = 0.7;
- return scene;
- };
- var scene = createScene();
- //Import human mesh
- BABYLON.SceneLoader.ImportMesh("him", "models/Dude/", "dude.babylon", scene, function(newMeshes, particleSystems, skeletons){
- scene.cameras[0].setTarget(newMeshes[0].position);
- scene.getMeshByName("him").scaling = new BABYLON.Vector3(0.07, 0.07, 0.07);
- });
- engine.runRenderLoop(function () {
- if(scene.getMeshByName("him") != null){
- //my attempt
- var bone = scene.getSkeletonByName("Skeleton0").bones[20];
- var boneMat = bone.getWorldMatrix();
- BABYLON.Matrix.RotationZToRef(0.1, boneMat);
- bone.updateMatrix(boneMat);
- scene.render();
- }
- });
- // Resize
- window.addEventListener("resize", function () {
- engine.resize();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement