瀏覽代碼

Editor: Reimplementing Editor class as proposed by @arodic in #3493.

Mr.doob 12 年之前
父節點
當前提交
c184fec335
共有 7 個文件被更改,包括 124 次插入45 次删除
  1. 9 38
      editor/index.html
  2. 100 0
      editor/js/Editor.js
  3. 3 3
      editor/js/Loader.js
  4. 3 1
      editor/js/Menubar.js
  5. 3 1
      editor/js/Sidebar.js
  6. 3 1
      editor/js/Toolbar.js
  7. 3 1
      editor/js/Viewport.js

+ 9 - 38
editor/index.html

@@ -110,6 +110,7 @@
 		<script src="js/libs/ui.js"></script>
 		<script src="js/libs/ui.three.js"></script>
 
+		<script src="js/Editor.js"></script>
 		<script src="js/Loader.js"></script>
 		<script src="js/Menubar.js"></script>
 		<script src="js/Menubar.File.js"></script>
@@ -138,60 +139,30 @@
 			window.URL = window.URL || window.webkitURL;
 			window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
 
-			var SIGNALS = signals;
+			var editor = new Editor();
 
-			var signals = {
+			var loader = new Loader( editor );
 
-				// actions
-
-				flattenSelectedObject: new SIGNALS.Signal(),
-				cloneSelectedObject: new SIGNALS.Signal(),
-				removeSelectedObject: new SIGNALS.Signal(),
-				playAnimations: new SIGNALS.Signal(),
-
-				// notifications
-
-				transformModeChanged: new SIGNALS.Signal(),
-				snapChanged: new SIGNALS.Signal(),
-				rendererChanged: new SIGNALS.Signal(),
-				sceneAdded: new SIGNALS.Signal(),
-				sceneChanged: new SIGNALS.Signal(),
-				objectAdded: new SIGNALS.Signal(),
-				objectSelected: new SIGNALS.Signal(),
-				objectChanged: new SIGNALS.Signal(),
-				materialChanged: new SIGNALS.Signal(),
-				clearColorChanged: new SIGNALS.Signal(),
-				fogTypeChanged: new SIGNALS.Signal(),
-				fogColorChanged: new SIGNALS.Signal(),
-				fogParametersChanged: new SIGNALS.Signal(),
-				windowResize: new SIGNALS.Signal()
-
-			};
-
-			//
-
-			var loader = new Loader( signals );
-
-			var viewport = new Viewport( signals );
+			var viewport = new Viewport( editor );
 			viewport.setTop( '32px' );
 			viewport.setLeft( '0px' );
 			viewport.setRight( '300px' );
 			viewport.setBottom( '32px' );
 			document.body.appendChild( viewport.dom );
 
-			var toolbar = new Toolbar( signals );
+			var toolbar = new Toolbar( editor );
 			toolbar.setBottom( '0px' );
 			toolbar.setLeft( '0px' );
 			toolbar.setRight( '300px' );
 			toolbar.setHeight( '32px' );
 			document.body.appendChild( toolbar.dom );
 
-			var menubar = new Menubar( signals );
+			var menubar = new Menubar( editor );
 			menubar.setWidth( '100%' );
 			menubar.setHeight( '32px' );
 			document.body.appendChild( menubar.dom );
 
-			var sidebar = new Sidebar( signals );
+			var sidebar = new Sidebar( editor );
 			sidebar.setRight( '0px' );
 			sidebar.setTop( '32px' );
 			sidebar.setBottom( '0px' );
@@ -205,7 +176,7 @@
 
 					case 46: // delete
 
-						signals.removeSelectedObject.dispatch();
+						editor.signals.removeSelectedObject.dispatch();
 
 						break;
 
@@ -215,7 +186,7 @@
 
 			var onWindowResize = function ( event ) {
 
-				signals.windowResize.dispatch();
+				editor.signals.windowResize.dispatch();
 
 			};
 

+ 100 - 0
editor/js/Editor.js

@@ -0,0 +1,100 @@
+var Editor = function () {
+
+	var SIGNALS = signals;
+
+	this.signals = {
+
+		// actions
+
+		flattenSelectedObject: new SIGNALS.Signal(),
+		cloneSelectedObject: new SIGNALS.Signal(),
+		removeSelectedObject: new SIGNALS.Signal(),
+		playAnimations: new SIGNALS.Signal(),
+
+		// notifications
+
+		transformModeChanged: new SIGNALS.Signal(),
+		snapChanged: new SIGNALS.Signal(),
+		rendererChanged: new SIGNALS.Signal(),
+		sceneAdded: new SIGNALS.Signal(),
+		sceneChanged: new SIGNALS.Signal(),
+		objectAdded: new SIGNALS.Signal(),
+		objectSelected: new SIGNALS.Signal(),
+		objectChanged: new SIGNALS.Signal(),
+		materialChanged: new SIGNALS.Signal(),
+		clearColorChanged: new SIGNALS.Signal(),
+		fogTypeChanged: new SIGNALS.Signal(),
+		fogColorChanged: new SIGNALS.Signal(),
+		fogParametersChanged: new SIGNALS.Signal(),
+		windowResize: new SIGNALS.Signal()
+
+	};
+
+	this.scene = new THREE.Scene();
+
+	this.object = {};
+	this.geometries = {};
+	this.materials = {};
+	this.textures = {};
+
+};
+
+Editor.prototype = {
+
+	setScene: function ( scene ) {
+
+	},
+
+	//
+
+	addObject: function ( object, parent ) {
+
+	},
+
+	addGeometry: function ( geometry  ) {
+
+	},
+
+	addMaterial: function ( material ) {
+
+	},
+
+	addTexture: function ( texture ) {
+
+	},
+
+	//
+
+	addHelper: function ( object ) {
+
+	},
+
+	removeHelper: function ( object ) {
+
+	},
+
+	//
+
+	select: function ( object ) {
+
+	},
+
+	deselect: function ( object ) {
+
+	},
+
+	//
+
+	cloneObject: function ( object ) {
+
+	},
+
+	flattenObject: function ( object ) {
+
+	},
+
+	deleteObject: function ( object ) {
+
+	}
+
+}

+ 3 - 3
editor/js/Loader.js

@@ -1,7 +1,7 @@
+var Loader = function ( editor ) {
 
-var Loader = function ( signals ) {
-
-	scope = this;
+	var scope = this;
+	var signals = editor.signals;
 
 	var sceneExporter = new THREE.ObjectExporter();
 

+ 3 - 1
editor/js/Menubar.js

@@ -1,4 +1,6 @@
-var Menubar = function ( signals ) {
+var Menubar = function ( editor ) {
+
+	var signals = editor.signals;
 
 	var container = new UI.Panel();
 	container.setPosition( 'absolute' );

+ 3 - 1
editor/js/Sidebar.js

@@ -1,4 +1,6 @@
-var Sidebar = function ( signals ) {
+var Sidebar = function ( editor ) {
+
+	var signals = editor.signals;
 
 	var container = new UI.Panel();
 	container.setPosition( 'absolute' );

+ 3 - 1
editor/js/Toolbar.js

@@ -1,4 +1,6 @@
-var Toolbar = function ( signals ) {
+var Toolbar = function ( editor ) {
+
+	var signals = editor.signals;
 
 	var container = new UI.Panel();
 	container.setPosition( 'absolute' );

+ 3 - 1
editor/js/Viewport.js

@@ -1,4 +1,6 @@
-var Viewport = function ( signals ) {
+var Viewport = function ( editor ) {
+
+	var signals = editor.signals;
 
 	var container = new UI.Panel();
 	container.setPosition( 'absolute' );