提交 314dcf02 编写于 作者: A alteredq

Editor: plugged in adding of SpotLight, HemisphereLight and AmbientLight to menubar.

Also nicer whitespace formatting for lights and cameras in strings generated by SceneExporter.
上级 3e4339f3
......@@ -132,10 +132,69 @@ Menubar.Add = function ( signals ) {
// add spot light
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Spot light' );
option.onClick( function () {
var color = 0xffffff;
var intensity = 1;
var distance = 0;
var angle = Math.PI * 0.1;
var exponent = 10;
var light = new THREE.SpotLight( color, intensity, distance, angle, exponent );
light.name = 'Light ' + light.id;
light.target.name = 'Light ' + light.id + ' target';
light.target.properties.targetInverse = light;
light.position.set( 0, 1, 0 ).multiplyScalar( 200 );
signals.objectAdded.dispatch( light );
} );
options.add( option );
// add hemisphere light
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Hemisphere light' );
option.onClick( function () {
var skyColor = 0x00aaff;
var groundColor = 0xffaa00;
var intensity = 1;
var light = new THREE.HemisphereLight( skyColor, groundColor, intensity );
light.name = 'Light ' + light.id;
light.position.set( 1, 1, 1 ).multiplyScalar( 200 );
signals.objectAdded.dispatch( light );
} );
options.add( option );
// add ambient light
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 'Ambient light' );
option.onClick( function () {
var color = 0x222222;
var light = new THREE.AmbientLight( color );
light.name = 'Light ' + light.id;
signals.objectAdded.dispatch( light );
} );
options.add( option );
//
function createDummyMaterial() {
......
......@@ -217,8 +217,8 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "AmbientLight",',
' "color" : ' + o.color.getHex() + ( o.children.length ? ',' : '' )
' "type" : "AmbientLight",',
' "color" : ' + o.color.getHex() + ( o.children.length ? ',' : '' )
];
......@@ -227,9 +227,9 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "DirectionalLight",',
' "color" : ' + o.color.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "type" : "DirectionalLight",',
' "color" : ' + o.color.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "direction" : ' + Vector3String( o.position ) + ',',
' "target" : ' + LabelString( getObjectName( o.target ) ) + ( o.children.length ? ',' : '' )
......@@ -240,10 +240,10 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "PointLight",',
' "color" : ' + o.color.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "position" : ' + Vector3String( o.position ) + ',',
' "type" : "PointLight",',
' "color" : ' + o.color.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "position" : ' + Vector3String( o.position ) + ',',
' "distance" : ' + o.distance + ( o.children.length ? ',' : '' )
];
......@@ -253,12 +253,12 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "SpotLight",',
' "color" : ' + o.color.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "position" : ' + Vector3String( o.position ) + ',',
' "type" : "SpotLight",',
' "color" : ' + o.color.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "position" : ' + Vector3String( o.position ) + ',',
' "distance" : ' + o.distance + ',',
' "angle" : ' + o.angle + ',',
' "angle" : ' + o.angle + ',',
' "exponent" : ' + o.exponent + ',',
' "target" : ' + LabelString( getObjectName( o.target ) ) + ( o.children.length ? ',' : '' )
......@@ -269,11 +269,11 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "HemisphereLight",',
' "skyColor" : ' + o.color.getHex() + ',',
' "groundColor" : ' + o.groundColor.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "position" : ' + Vector3String( o.position ) + ( o.children.length ? ',' : '' )
' "type" : "HemisphereLight",',
' "skyColor" : ' + o.color.getHex() + ',',
' "groundColor" : ' + o.groundColor.getHex() + ',',
' "intensity" : ' + o.intensity + ',',
' "position" : ' + Vector3String( o.position ) + ( o.children.length ? ',' : '' )
];
......@@ -294,11 +294,11 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "PerspectiveCamera",',
' "fov": ' + o.fov + ',',
' "aspect": ' + o.aspect + ',',
' "near": ' + o.near + ',',
' "far": ' + o.far + ',',
' "type" : "PerspectiveCamera",',
' "fov" : ' + o.fov + ',',
' "aspect" : ' + o.aspect + ',',
' "near" : ' + o.near + ',',
' "far" : ' + o.far + ',',
' "position" : ' + Vector3String( o.position ) + ( o.children.length ? ',' : '' )
];
......@@ -308,13 +308,13 @@ THREE.SceneExporter.prototype = {
var output = [
'\t\t' + LabelString( getObjectName( o ) ) + ' : {',
' "type" : "OrthographicCamera",',
' "left": ' + o.left + ',',
' "right": ' + o.right + ',',
' "top": ' + o.top + ',',
' "bottom": ' + o.bottom + ',',
' "near": ' + o.near + ',',
' "far": ' + o.far + ',',
' "type" : "OrthographicCamera",',
' "left" : ' + o.left + ',',
' "right" : ' + o.right + ',',
' "top" : ' + o.top + ',',
' "bottom" : ' + o.bottom + ',',
' "near" : ' + o.near + ',',
' "far" : ' + o.far + ',',
' "position" : ' + Vector3String( o.position ) + ( o.children.length ? ',' : '' )
];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册