kentpham88

Using typescript in playground

Recommended Posts

On 7/6/2018 at 5:03 AM, brianzinn said:

if you wanted some help 

that is solved 

this is js we need  

*  notice that too
 * Copyright (c) Microsoft Corporation. All rights reserved.
 * monaco-typescript version: 2.0.1(076cc15ec707b6c7a820ae7a16c982af01a35127)
 * Released under the MIT license
 * https://github.com/Microsoft/monaco-typescript/blob/master/LICENSE.md

that is fully client side

and this method compile that 

      triggerCompile(`
        class Greeter {
               greeting: string;
               constructor(message: string) {
                   this.greeting = message;
                  }
               greet() {
                 return "Hello, " + this.greeting;
                   }
         }

         let greeter = new Greeter("world");
 
        `);

    }

and new problem : we need a simple design pattern for make BABYLON Scene from this sample

https://www.babylonjs-playground.com/#8AWDVG#11

 

module:              ts.ModuleKind.AMD,
target:                 ts.ScriptTarget.ES5,
noLib:                 true,
noResolve:          true,
suppressOutputPathCheck:           true

Share this post


Link to post
Share on other sites

https://github.com/BabylonJS/Babylon.js/pull/4706

PR is created

actually it is so cool and so great idea :D thanks @kentpham88

class SceneBase {
    scene : any;
    constructor() { 
        this.scene = new BABYLON.Scene(engine); 
    }
}

class CameraBase {
    camera : any; 
    constructor() { 
        this.camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); 
        this.camera.setTarget(BABYLON.Vector3.Zero());
        this.camera.attachControl(canvas, true);
    } 
}

class SceneTheme {
    lights : any[]; 
    constructor() {
       var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
       light.intensity = 0.7;
       this.lights = new Array();
       this.lights.push(light);       
    } 
}

class Objects{
    meshes : any[]; 
    constructor(){

        this.meshes = new Array();

       var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
              sphere.position.y = 1;
        this.meshes.push(sphere);
              
      var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
       this.meshes.push(ground);
         
    }

}

class MainScene { 
    constructor() { 
    }
    CreateScene() {

        var scene = new SceneBase().scene;
        
        var camera = new CameraBase().camera;

        var theme = new SceneTheme();

        var objGroup1 = new Objects();
         
        return scene;
    }
}

one of best benefits is created usable class can import in main code  with live online debug 

we never had it before  this is like new generation life of babylonjs

Share this post


Link to post
Share on other sites
On 7/8/2018 at 3:11 AM, NasimiAsl said:

https://github.com/BabylonJS/Babylon.js/pull/4706

PR is created

actually it is so cool and so great idea :D thanks @kentpham88


class SceneBase {
    scene : any;
    constructor() { 
        this.scene = new BABYLON.Scene(engine); 
    }
}

class CameraBase {
    camera : any; 
    constructor() { 
        this.camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); 
        this.camera.setTarget(BABYLON.Vector3.Zero());
        this.camera.attachControl(canvas, true);
    } 
}

class SceneTheme {
    lights : any[]; 
    constructor() {
       var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
       light.intensity = 0.7;
       this.lights = new Array();
       this.lights.push(light);       
    } 
}

class Objects{
    meshes : any[]; 
    constructor(){

        this.meshes = new Array();

       var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
              sphere.position.y = 1;
        this.meshes.push(sphere);
              
      var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
       this.meshes.push(ground);
         
    }

}

class MainScene { 
    constructor() { 
    }
    CreateScene() {

        var scene = new SceneBase().scene;
        
        var camera = new CameraBase().camera;

        var theme = new SceneTheme();

        var objGroup1 = new Objects();
         
        return scene;
    }
}

one of best benefits is created usable class can import in main code  with live online debug 

we never had it before  this is like new generation life of babylonjs

Wow great job, so much progress!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.