Browse Source

Merge pull request #10944 from gero3/editor-electron

Initial electron version of the editor
Mr.doob 8 years ago
parent
commit
e639ebd91e
2 changed files with 59 additions and 2 deletions
  1. 55 0
      editor/main.js
  2. 4 2
      package.json

+ 55 - 0
editor/main.js

@@ -0,0 +1,55 @@
+const electron = require( 'electron' );
+const app = electron.app;
+const BrowserWindow = electron.BrowserWindow;
+
+const path = require( 'path' );
+const url = require( 'url' );
+
+// Keep a global reference of the window object, if you don't, the window will
+// be closed automatically when the JavaScript object is garbage collected.
+let mainWindow;
+
+function createWindow() {
+
+	mainWindow = new BrowserWindow( { webPreferences: {
+		nodeIntegration: false
+	} } );
+
+	mainWindow.maximize();
+	mainWindow.setMenu( null );
+
+	mainWindow.loadURL( url.format( {
+		pathname: path.join( __dirname, 'index.html' ),
+		protocol: 'file:',
+		slashes: true
+	} ) );
+
+	mainWindow.on( 'closed', function () {
+
+		mainWindow = null;
+
+	} );
+
+}
+
+app.on( 'ready', createWindow );
+
+app.on( 'window-all-closed', function () {
+
+	if ( process.platform !== 'darwin' ) {
+
+		app.quit();
+
+	}
+
+} );
+
+app.on( 'activate', function () {
+
+	if ( mainWindow === null ) {
+
+		createWindow();
+
+	}
+
+} );

+ 4 - 2
package.json

@@ -33,7 +33,8 @@
     "build-closure": "rollup -c && java -jar utils/build/compiler/closure-compiler-v20160713.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --externs utils/build/externs.js --language_in=ECMASCRIPT5_STRICT --js build/three.js --js_output_file build/three.min.js",
     "dev": "rollup -c -w",
     "lint": "eslint src",
-    "test": "rollup -c test/rollup.unit.config.js -w"
+    "test": "rollup -c test/rollup.unit.config.js -w",
+    "editor-start": "electron ./editor/main.js"
   },
   "keywords": [
     "three",
@@ -53,6 +54,7 @@
     "qunitjs": "^2.1.1",
     "rollup": "^0.41.4",
     "rollup-watch": "^3.2.2",
-    "uglify-js": "^2.6.0"
+    "uglify-js": "^2.6.0",
+    "electron": "^1.6.1"
   }
 }