mirror of
https://github.com/wahyd4/three.js.git
synced 2026-08-19 01:45:57 +10:00
Some fixes to GUI Codegen + Preview
This commit is contained in:
@@ -126,7 +126,7 @@ THREE.MeshBasicMaterial.prototype.gui = {
|
||||
|
||||
return 'new THREE.MeshBasicMaterial( { ' + [
|
||||
|
||||
'color: ' + material.color.getHex()
|
||||
'color: 0x' + material.color.getHex().toString(16)
|
||||
|
||||
].join( ', ' ) + ' } )';
|
||||
|
||||
|
||||
+46
-6
@@ -14,6 +14,40 @@ var Code = function () {
|
||||
_checkbox.style.margin = '20px 6px 0px 20px';
|
||||
_checkbox.addEventListener( 'click', function () { _html = !_html; _update(); }, false );
|
||||
_domElement.appendChild( _checkbox );
|
||||
|
||||
var _preview = document.createElement( 'a' );
|
||||
_preview.href = '#';
|
||||
_preview.innerHTML = 'preview';
|
||||
_preview.style.margin = '20px 6px 0px 20px';
|
||||
_preview.addEventListener( 'click',
|
||||
function () {
|
||||
|
||||
|
||||
// Get unescaped code gen
|
||||
var temp=document.createElement("pre");
|
||||
temp.innerHTML = _codegen( true );
|
||||
temp = temp.firstChild.nodeValue;
|
||||
temp = temp.replace("js/Three.js", "../build/Three.js");
|
||||
temp = temp.replace("js/RequestAnimationFrame.js", "../examples/js/RequestAnimationFrame.js");
|
||||
aaa = temp;
|
||||
console.log('test', temp);
|
||||
|
||||
var opener = window.open('','myconsole',
|
||||
'width=800,height=400'
|
||||
+',menubar=1'
|
||||
+',toolbar=0'
|
||||
+',status=1'
|
||||
+',scrollbars=1'
|
||||
+',resizable=1');
|
||||
|
||||
|
||||
opener.document.writeln( temp );
|
||||
opener.document.close();
|
||||
|
||||
}, false
|
||||
);
|
||||
_domElement.appendChild( _preview );
|
||||
|
||||
|
||||
/*
|
||||
var _checkboxText = document.createElement( 'span' );
|
||||
@@ -34,9 +68,8 @@ var Code = function () {
|
||||
//
|
||||
|
||||
var _list = [];
|
||||
|
||||
var _update = function () {
|
||||
|
||||
|
||||
var _codegen = function (html) {
|
||||
var string = '';
|
||||
|
||||
string += [
|
||||
@@ -48,7 +81,8 @@ var Code = function () {
|
||||
'',
|
||||
'function init() {',
|
||||
'',
|
||||
'\tcamera = new THREE.Camera();',
|
||||
'\tcamera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );',
|
||||
'\tcamera.position.z = 500;',
|
||||
'',
|
||||
'\tscene = new THREE.Scene();',
|
||||
''
|
||||
@@ -79,18 +113,24 @@ var Code = function () {
|
||||
'function render() {',
|
||||
'',
|
||||
'\trenderer.render( scene, camera );',
|
||||
'\trenderer.setSize( window.innerWidth, window.innerHeight );',
|
||||
'',
|
||||
'}'
|
||||
|
||||
].join( '\n' );
|
||||
|
||||
if ( _html ) {
|
||||
if ( html ) {
|
||||
|
||||
string = '<!doctype html>\n<html>\n\t<body>\n\t\t<script src=\"js/Three.js\"></script>\n\t\t<script src=\"js/RequestAnimationFrame.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>';
|
||||
|
||||
}
|
||||
|
||||
_code.innerHTML = string;
|
||||
return string;
|
||||
}
|
||||
|
||||
var _update = function () {
|
||||
|
||||
_code.innerHTML = _codegen( _html );
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user