Jump to content

Using typescript in playground


kentpham88
 Share

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
Link to comment
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

Link to comment
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!

Link to comment
Share on other sites

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...