Samuel Girardin Posted February 5, 2014 Share Posted February 5, 2014 Hi, I've just passed a long time to understand how using BABYLON.SceneLoader.ImportMesh in Typescript without using the classic inline function. The inline function works fine with Typescript but after it was quite difficult to deal with, you must declare your scene a static var, etc, use static method etc... not efficient or elegant for me. Here is my solution (it works like a charm, perhaps there is an other way to deal with ? Let me know. If this solution can help). So here is my typescript class. /// <reference path="Tdef/babylon.d.ts" />class skin { public scene: BABYLON.Scene; constructor(engine : BABYLON.Engine) { this.scene = new BABYLON.Scene(engine); // add here light, camera, what ever you want.. // BABYLON.SceneLoader deal with arrow function (a,b,c)=>{ calback function} BABYLON.SceneLoader.ImportMesh("him", "Scenes/Dude/", "Dude.babylon", this.scene, (newMeshes2, particleSystems2, skeletons2) => { this.onloading(newMeshes2, particleSystems2, skeletons2) }); } private onloading(newMeshes2:BABYLON.Mesh[], particleSystems2:BABYLON.ParticleSystem, skeletons2:BABYLON.Skeleton[]): void { var dude = newMeshes2[0]; dude.rotation.y = Math.PI; dude.position = new BABYLON.Vector3(0, 0, -80); this.scene.beginAnimation(skeletons2[0], 0, 100, true, 1.0); } public getScene(): BABYLON.Scene { return this.scene; }}Sam Samuel Girardin and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Alex_on_the_web Posted February 24, 2014 Share Posted February 24, 2014 Hey, this might be off the topic, but do you use a hand crafted babylon.d.ts file, or the one provided (as outdated as it might be) on github? The thing is I've been tinkering with Sublime + T3S and I just cannot get Sublime to recognise a BABYLON namespace. Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted February 24, 2014 Author Share Posted February 24, 2014 Hi, Yes I use typescript def provided by babylonjs's github, and I update and correct them when it's needed. I use Visual Studio 2013 web express. Sam Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.