未验证 提交 38814cb2 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16319 from linbingquan/dev1

Editor: Sorting objects for Menubar.Add.js
...@@ -37,135 +37,180 @@ Menubar.Add = function ( editor ) { ...@@ -37,135 +37,180 @@ Menubar.Add = function ( editor ) {
options.add( new UI.HorizontalRule() ); options.add( new UI.HorizontalRule() );
// Plane // Box
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/plane' ) ); option.setTextContent( strings.getKey( 'menubar/add/box' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.PlaneBufferGeometry( 1, 1, 1, 1 ); var geometry = new THREE.BoxBufferGeometry( 1, 1, 1, 1, 1, 1 );
var material = new THREE.MeshStandardMaterial(); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
var mesh = new THREE.Mesh( geometry, material ); mesh.name = 'Box';
mesh.name = 'Plane';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Box // Circle
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/box' ) ); option.setTextContent( strings.getKey( 'menubar/add/circle' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.BoxBufferGeometry( 1, 1, 1, 1, 1, 1 ); var geometry = new THREE.CircleBufferGeometry( 1, 8, 0, Math.PI * 2 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Box'; mesh.name = 'Circle';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Circle // Cylinder
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/circle' ) ); option.setTextContent( strings.getKey( 'menubar/add/cylinder' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.CircleBufferGeometry( 1, 8, 0, Math.PI * 2 ); var geometry = new THREE.CylinderBufferGeometry( 1, 1, 1, 8, 1, false, 0, Math.PI * 2 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Circle'; mesh.name = 'Cylinder';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Ring // Icosahedron
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/ring' ) ); option.setTextContent( strings.getKey( 'menubar/add/icosahedron' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.RingBufferGeometry( 0.5, 1, 8, 1, 0, Math.PI * 2 ); var geometry = new THREE.IcosahedronBufferGeometry( 1, 0 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Ring'; mesh.name = 'Icosahedron';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Cylinder // Lathe
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/cylinder' ) ); option.setTextContent( strings.getKey( 'menubar/add/lathe' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.CylinderBufferGeometry( 1, 1, 1, 8, 1, false, 0, Math.PI * 2 ); var points = [
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); new THREE.Vector2( 0, 0 ),
mesh.name = 'Cylinder'; new THREE.Vector2( 0.4, 0 ),
new THREE.Vector2( 0.35, 0.05 ),
new THREE.Vector2( 0.1, 0.075 ),
new THREE.Vector2( 0.08, 0.1 ),
new THREE.Vector2( 0.08, 0.4 ),
new THREE.Vector2( 0.1, 0.42 ),
new THREE.Vector2( 0.14, 0.48 ),
new THREE.Vector2( 0.2, 0.5 ),
new THREE.Vector2( 0.25, 0.54 ),
new THREE.Vector2( 0.3, 1.2 )
];
var geometry = new THREE.LatheBufferGeometry( points, 12, 0, Math.PI * 2 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial( { side: THREE.DoubleSide } ) );
mesh.name = 'Lathe';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Sphere // Octahedron
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/sphere' ) ); option.setTextContent( strings.getKey( 'menubar/add/octahedron' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.SphereBufferGeometry( 1, 8, 6, 0, Math.PI * 2, 0, Math.PI ); var geometry = new THREE.OctahedronBufferGeometry( 1, 0 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Sphere'; mesh.name = 'Octahedron';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Icosahedron // Plane
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/icosahedron' ) ); option.setTextContent( strings.getKey( 'menubar/add/plane' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.IcosahedronBufferGeometry( 1, 0 ); var geometry = new THREE.PlaneBufferGeometry( 1, 1, 1, 1 );
var material = new THREE.MeshStandardMaterial();
var mesh = new THREE.Mesh( geometry, material );
mesh.name = 'Plane';
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option )
// Ring
var option = new UI.Row();
option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/ring' ) );
option.onClick( function () {
var geometry = new THREE.RingBufferGeometry( 0.5, 1, 8, 1, 0, Math.PI * 2 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Icosahedron'; mesh.name = 'Ring';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Octahedron // Sphere
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/octahedron' ) ); option.setTextContent( strings.getKey( 'menubar/add/sphere' ) );
option.onClick( function () { option.onClick( function () {
var geometry = new THREE.OctahedronBufferGeometry( 1, 0 ); var geometry = new THREE.SphereBufferGeometry( 1, 8, 6, 0, Math.PI * 2, 0, Math.PI );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() ); var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Octahedron'; mesh.name = 'Sphere';
editor.execute( new AddObjectCommand( mesh ) ); editor.execute( new AddObjectCommand( mesh ) );
} ); } );
options.add( option ); options.add( option );
// Sprite
var option = new UI.Row();
option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/sprite' ) );
option.onClick( function () {
var sprite = new THREE.Sprite( new THREE.SpriteMaterial() );
sprite.name = 'Sprite';
editor.execute( new AddObjectCommand( sprite ) );
} );
options.add( option );
// Tetrahedron // Tetrahedron
var option = new UI.Row(); var option = new UI.Row();
...@@ -266,90 +311,40 @@ Menubar.Add = function ( editor ) { ...@@ -266,90 +311,40 @@ Menubar.Add = function ( editor ) {
options.add( option ); options.add( option );
*/ */
// Lathe
var option = new UI.Row();
option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/lathe' ) );
option.onClick( function () {
var points = [
new THREE.Vector2( 0, 0 ),
new THREE.Vector2( 0.4, 0 ),
new THREE.Vector2( 0.35, 0.05 ),
new THREE.Vector2( 0.1, 0.075 ),
new THREE.Vector2( 0.08, 0.1 ),
new THREE.Vector2( 0.08, 0.4 ),
new THREE.Vector2( 0.1, 0.42 ),
new THREE.Vector2( 0.14, 0.48 ),
new THREE.Vector2( 0.2, 0.5 ),
new THREE.Vector2( 0.25, 0.54 ),
new THREE.Vector2( 0.3, 1.2 )
];
var geometry = new THREE.LatheBufferGeometry( points, 12, 0, Math.PI * 2 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial( { side: THREE.DoubleSide } ) );
mesh.name = 'Lathe';
editor.execute( new AddObjectCommand( mesh ) );
} );
options.add( option );
// Sprite
var option = new UI.Row();
option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/sprite' ) );
option.onClick( function () {
var sprite = new THREE.Sprite( new THREE.SpriteMaterial() );
sprite.name = 'Sprite';
editor.execute( new AddObjectCommand( sprite ) );
} );
options.add( option );
// //
options.add( new UI.HorizontalRule() ); options.add( new UI.HorizontalRule() );
// PointLight // AmbientLight
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/pointlight' ) ); option.setTextContent( strings.getKey( 'menubar/add/ambientlight' ) );
option.onClick( function () { option.onClick( function () {
var color = 0xffffff; var color = 0x222222;
var intensity = 1;
var distance = 0;
var light = new THREE.PointLight( color, intensity, distance ); var light = new THREE.AmbientLight( color );
light.name = 'PointLight'; light.name = 'AmbientLight';
editor.execute( new AddObjectCommand( light ) ); editor.execute( new AddObjectCommand( light ) );
} ); } );
options.add( option ); options.add( option );
// SpotLight // DirectionalLight
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/spotlight' ) ); option.setTextContent( strings.getKey( 'menubar/add/directionallight' ) );
option.onClick( function () { option.onClick( function () {
var color = 0xffffff; var color = 0xffffff;
var intensity = 1; var intensity = 1;
var distance = 0;
var angle = Math.PI * 0.1;
var penumbra = 0;
var light = new THREE.SpotLight( color, intensity, distance, angle, penumbra ); var light = new THREE.DirectionalLight( color, intensity );
light.name = 'SpotLight'; light.name = 'DirectionalLight';
light.target.name = 'SpotLight Target'; light.target.name = 'DirectionalLight Target';
light.position.set( 5, 10, 7.5 ); light.position.set( 5, 10, 7.5 );
...@@ -358,59 +353,64 @@ Menubar.Add = function ( editor ) { ...@@ -358,59 +353,64 @@ Menubar.Add = function ( editor ) {
} ); } );
options.add( option ); options.add( option );
// DirectionalLight // HemisphereLight
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/directionallight' ) ); option.setTextContent( strings.getKey( 'menubar/add/hemispherelight' ) );
option.onClick( function () { option.onClick( function () {
var color = 0xffffff; var skyColor = 0x00aaff;
var groundColor = 0xffaa00;
var intensity = 1; var intensity = 1;
var light = new THREE.DirectionalLight( color, intensity ); var light = new THREE.HemisphereLight( skyColor, groundColor, intensity );
light.name = 'DirectionalLight'; light.name = 'HemisphereLight';
light.target.name = 'DirectionalLight Target';
light.position.set( 5, 10, 7.5 ); light.position.set( 0, 10, 0 );
editor.execute( new AddObjectCommand( light ) ); editor.execute( new AddObjectCommand( light ) );
} ); } );
options.add( option ); options.add( option );
// HemisphereLight // PointLight
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/hemispherelight' ) ); option.setTextContent( strings.getKey( 'menubar/add/pointlight' ) );
option.onClick( function () { option.onClick( function () {
var skyColor = 0x00aaff; var color = 0xffffff;
var groundColor = 0xffaa00;
var intensity = 1; var intensity = 1;
var distance = 0;
var light = new THREE.HemisphereLight( skyColor, groundColor, intensity ); var light = new THREE.PointLight( color, intensity, distance );
light.name = 'HemisphereLight'; light.name = 'PointLight';
light.position.set( 0, 10, 0 );
editor.execute( new AddObjectCommand( light ) ); editor.execute( new AddObjectCommand( light ) );
} ); } );
options.add( option ); options.add( option );
// AmbientLight // SpotLight
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/ambientlight' ) ); option.setTextContent( strings.getKey( 'menubar/add/spotlight' ) );
option.onClick( function () { option.onClick( function () {
var color = 0x222222; var color = 0xffffff;
var intensity = 1;
var distance = 0;
var angle = Math.PI * 0.1;
var penumbra = 0;
var light = new THREE.AmbientLight( color ); var light = new THREE.SpotLight( color, intensity, distance, angle, penumbra );
light.name = 'AmbientLight'; light.name = 'SpotLight';
light.target.name = 'SpotLight Target';
light.position.set( 5, 10, 7.5 );
editor.execute( new AddObjectCommand( light ) ); editor.execute( new AddObjectCommand( light ) );
...@@ -421,30 +421,30 @@ Menubar.Add = function ( editor ) { ...@@ -421,30 +421,30 @@ Menubar.Add = function ( editor ) {
options.add( new UI.HorizontalRule() ); options.add( new UI.HorizontalRule() );
// PerspectiveCamera // OrthographicCamera
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/perspectivecamera' ) ); option.setTextContent( strings.getKey( 'menubar/add/orthographiccamera' ) );
option.onClick( function () { option.onClick( function () {
var camera = new THREE.PerspectiveCamera(); var camera = new THREE.OrthographicCamera();
camera.name = 'PerspectiveCamera'; camera.name = 'OrthographicCamera';
editor.execute( new AddObjectCommand( camera ) ); editor.execute( new AddObjectCommand( camera ) );
} ); } );
options.add( option ); options.add( option );
// OrthographicCamera // PerspectiveCamera
var option = new UI.Row(); var option = new UI.Row();
option.setClass( 'option' ); option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/orthographiccamera' ) ); option.setTextContent( strings.getKey( 'menubar/add/perspectivecamera' ) );
option.onClick( function () { option.onClick( function () {
var camera = new THREE.OrthographicCamera(); var camera = new THREE.PerspectiveCamera();
camera.name = 'OrthographicCamera'; camera.name = 'PerspectiveCamera';
editor.execute( new AddObjectCommand( camera ) ); editor.execute( new AddObjectCommand( camera ) );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册