David Catuhe 6 роки тому
батько
коміт
4ba55152f3

+ 12 - 2
nodeEditor/public/index-local.html

@@ -2,10 +2,13 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 
 <head>
-    <title>Node Material Editor - Local Development</title>
+    <title>Node Material Editor - Local Development</title>    
+    <meta name="viewport" content="width=device-width, user-scalable=no">
+    <link rel="shortcut icon" href="https://www.babylonjs.com/favicon.ico">
 
     <script src="https://code.jquery.com/pep/0.4.2/pep.min.js"></script>
     <script src="../../Tools/DevLoader/BabylonLoader.js"></script>
+    <link rel="stylesheet" href="https://use.typekit.net/cta4xsb.css"></style>
 
     <style>
         html,
@@ -16,14 +19,21 @@
             margin: 0;
             overflow: hidden;
         }
+
+        #host-element {
+            width: 100%;
+            height: 100%;            
+        }
     </style>
 </head>
 
 <body>
+    <div id="host-element">
+    </div>
     <script>
         // Load the scripts + map file to allow vscode debug.
         BABYLONDEVTOOLS.Loader
-            .require("index")
+            .require("index.js")
             .load();
     </script>
 </body>

+ 6 - 0
nodeEditor/public/index.html

@@ -4,7 +4,11 @@
 <head>
     <title>Babylon.js Node Material Editor</title>
 
+    <meta name="viewport" content="width=device-width, user-scalable=no">
+    <link rel="shortcut icon" href="https://www.babylonjs.com/favicon.ico">
+
     <script src="https://code.jquery.com/pep/0.4.2/pep.min.js"></script>
+    <link rel="stylesheet" href="https://use.typekit.net/cta4xsb.css"></style>
     <script src="https://preview.babylonjs.com/babylon.js"></script>
     <script src="https://preview.babylonjs.com/nodeEditor/babylon.nodeEditor.js"></script>
     
@@ -21,6 +25,8 @@
 </head>
 
 <body>    
+    <div id="host-element">
+    </div>
     <script src="index.js"></script>
 </body>
 

+ 4 - 1
nodeEditor/public/index.js

@@ -1,4 +1,5 @@
 if (BABYLON.Engine.isSupported()) {
+    var canvas = document.createElement("canvas");
     var engine = new BABYLON.Engine(canvas, false);
 
     BABYLONDEVTOOLS.Loader.debugShortcut(engine);
@@ -9,7 +10,9 @@ if (BABYLON.Engine.isSupported()) {
     nodeMaterial.setToDefault();
     nodeMaterial.build(true);
 
-    BABYLON.NodeEditor.Show({nodeMaterial: nodeMaterial});
+    var hostElement = document.getElementById("host-element");
+
+    BABYLON.NodeEditor.Show({nodeMaterial: nodeMaterial, hostElement: hostElement});
 }
 else {
     alert('Babylon.js is not supported.')

+ 8 - 2
nodeEditor/src/nodeEditor.ts

@@ -8,7 +8,8 @@ import { Popup } from "../src/sharedComponents/popup"
  * Interface used to specify creation options for the node editor
  */
 export interface INodeEditorOptions {
-    nodeMaterial: NodeMaterial
+    nodeMaterial: NodeMaterial,
+    hostElement?: HTMLElement
 }
 
 /**
@@ -29,7 +30,12 @@ export class NodeEditor {
             }
         }
 
-        let hostElement = Popup.CreatePopup("BABYLON.JS NODE EDITOR", "node-editor", 1000, 800)!;
+        let hostElement = options.hostElement;
+        
+        if (!hostElement) {
+            hostElement = Popup.CreatePopup("BABYLON.JS NODE EDITOR", "node-editor", 1000, 800)!;
+        }
+        
         let globalState = new GlobalState();
         globalState.nodeMaterial = options.nodeMaterial
         globalState.hostElement = hostElement;