Jump to content

BABYLON.SceneLoader deal with arrow function vs inline function


Samuel Girardin
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • 3 weeks later...

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...