瀏覽代碼

PG new content fix

GijsSchenk 5 年之前
父節點
當前提交
25abc19af7
共有 1 個文件被更改,包括 24 次插入7 次删除
  1. 24 7
      Playground/src/tools/monacoManager.ts

+ 24 - 7
Playground/src/tools/monacoManager.ts

@@ -120,18 +120,35 @@ export class MonacoManager {
 
     private _setNewContent() {
         this._createEditor();
-        this._editor?.setValue(`// You have to create a function called createScene. This function must return a BABYLON.Scene object
-    // You can reference the following variables: scene, canvas
-    // You must at least define a camera
 
-    var createScene = function() {
+        if(this.globalState.language === "JS"){
+            this._editor?.setValue(`// You have to create a function called createScene. This function must return a BABYLON.Scene object
+// You can reference the following variables: scene, canvas
+// You must at least define a camera
+
+var createScene = function() {
+    var scene = new BABYLON.Scene(engine);
+    var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
+    camera.attachControl(canvas, true);
+
+    return scene;
+};`);
+        } else {
+            this._editor?.setValue(`// You have to create a class called Playground. This class must provide a static function named CreateScene(engine, canvas) which must return a Scene object
+// You must at least define a camera inside the CreateScene function
+
+class Playground {
+    public static CreateScene(engine: BABYLON.Engine, canvas: HTMLCanvasElement): BABYLON.Scene {
         var scene = new BABYLON.Scene(engine);
-        var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
+
+        var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
+        camera.setTarget(BABYLON.Vector3.Zero());
         camera.attachControl(canvas, true);
 
         return scene;
-    };
-        `);
+    }
+}`);
+        }
 
         this.globalState.onRunRequiredObservable.notifyObservers();