瀏覽代碼

managed to get only a slight glimpse of preview working in gui

zz85 13 年之前
父節點
當前提交
38c5643d70
共有 3 個文件被更改,包括 34 次插入9 次删除
  1. 5 4
      gui/js/Code.Templates.js
  2. 27 5
      gui/js/Code.js
  3. 2 0
      gui/js/UI.Viewport.js

+ 5 - 4
gui/js/Code.Templates.js

@@ -30,10 +30,11 @@ THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHei
 					geometry.gui.parameters.depth,
 					geometry.gui.parameters.segmentsWidth,
 					geometry.gui.parameters.segmentsHeight,
-					geometry.gui.parameters.segmentsDepth,
-					geometry.gui.parameters.materials,
-					geometry.gui.parameters.flipped,
-					geometry.gui.parameters.sides
+					geometry.gui.parameters.segmentsDepth
+					// ,
+					// geometry.gui.parameters.materials,
+					// geometry.gui.parameters.flipped,
+					// geometry.gui.parameters.sides
 
 				].join( ', ' ) + ' )';
 

+ 27 - 5
gui/js/Code.js

@@ -28,8 +28,6 @@ var Code = function () {
 			temp = temp.firstChild.nodeValue;
 			temp = temp.replace("js/Three.js", "../build/Three.js");
 
-			console.log('test', temp);
-
 			var opener = window.open('','myconsole',
 			  'width=800,height=400'
 			   +',menubar=1'
@@ -69,6 +67,7 @@ var Code = function () {
 	var _codegen = function (html) {
 		var string = '';
 
+		console.log(_list);
 		string += [
 
 			'var camera, scene, renderer;',
@@ -118,8 +117,12 @@ var Code = function () {
 
 		if ( html ) {
 
-			string = '<!doctype html>\n<html>\n\t<body>\n\t\t<script src=\"js/Three.js\"></script>\n\t\t<script>\n' + ( '\n' + string ).replace( /\n/gi, '\n\t\t\t' ) + '\n\n\t\t</script>\n\t</body>\n</html>';
-
+			string = '<!doctype html>\n<html>\n\t<body>\
+			\n\t\t<style> body {background-color: #f0f0f0;} </style>\
+			\n\t\t<script src=\"js/Three.js\"></script>\
+			\n\t\t<script>\n' 
+			+ ( '\n' + string ).replace( /\n/gi, '\n\t\t\t' ) + 
+			'\n\n\t\t</script>\n\t</body>\n</html>';
 		}
 
 		return string;
@@ -131,6 +134,16 @@ var Code = function () {
 
 	}
 
+	var _strfor = function(str) {
+	    for (var i=1; i<arguments.length; i++) {
+	    	if (arguments[i].toFixed) {
+	    		arguments[i] = arguments[i].toFixed(2);
+	    	}
+	        str = str.replace('{'+(i-1)+'}', arguments[i]);
+	    }
+	    return str;
+	}
+
 	// signals
 
 	signals.updated.add( function ( scene ) {
@@ -143,7 +156,16 @@ var Code = function () {
 
 			if ( object.geometry == undefined || object.geometry.gui == undefined ) {
 
-				_list.push( 'TODO' );
+				if (object instanceof THREE.Camera) {
+					var string = '';
+					string += _strfor( '\n\tcamera.position.set({0},{1},{2});', object.position.x, object.position.y, object.position.z);
+					string += _strfor( '\n\tcamera.rotation.set({0},{1},{2});', object.rotation.x, object.rotation.y, object.rotation.z);
+
+					_list.push( string );
+
+				} else {
+					_list.push( 'TODO' );
+				}
 				continue;
 
 			}

+ 2 - 0
gui/js/UI.Viewport.js

@@ -41,6 +41,8 @@ UI.Viewport = function () {
 
 	var _scene = new THREE.Scene();
 
+	_scene.add(_camera);
+
 	/*
 	var light = new THREE.AmbientLight( 0x404040 );
 	_scene.add( light );