Selaa lähdekoodia

Editor: Import geometry parameter panels dynamically.

Mr.doob 4 vuotta sitten
vanhempi
commit
e25449c2e3

+ 2 - 2
editor/js/Sidebar.Geometry.BoxGeometry.js → editor/js/Sidebar.Geometry.BoxBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UINumber, UIInteger } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryBoxGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -92,4 +92,4 @@ function SidebarGeometryBoxGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryBoxGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.CircleGeometry.js → editor/js/Sidebar.Geometry.CircleBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryCircleGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -70,4 +70,4 @@ function SidebarGeometryCircleGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryCircleGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.CylinderGeometry.js → editor/js/Sidebar.Geometry.CylinderBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UICheckbox, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryCylinderGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -92,4 +92,4 @@ function SidebarGeometryCylinderGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryCylinderGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.DodecahedronGeometry.js → editor/js/Sidebar.Geometry.DodecahedronBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryDodecahedronGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -48,4 +48,4 @@ function SidebarGeometryDodecahedronGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryDodecahedronGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.ExtrudeGeometry.js → editor/js/Sidebar.Geometry.ExtrudeBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UICheckbox, UIButton, UINumber } from './libs
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryExtrudeGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -142,4 +142,4 @@ function SidebarGeometryExtrudeGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryExtrudeGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.IcosahedronGeometry.js → editor/js/Sidebar.Geometry.IcosahedronBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryIcosahedronGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -52,4 +52,4 @@ function SidebarGeometryIcosahedronGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryIcosahedronGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.LatheGeometry.js → editor/js/Sidebar.Geometry.LatheBufferGeometry.js

@@ -5,7 +5,7 @@ import { UIPoints2 } from './libs/ui.three.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryLatheGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -69,4 +69,4 @@ function SidebarGeometryLatheGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryLatheGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.OctahedronGeometry.js → editor/js/Sidebar.Geometry.OctahedronBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryOctahedronGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -53,4 +53,4 @@ function SidebarGeometryOctahedronGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryOctahedronGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.PlaneGeometry.js → editor/js/Sidebar.Geometry.PlaneBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryPlaneGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -71,4 +71,4 @@ function SidebarGeometryPlaneGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryPlaneGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.RingGeometry.js → editor/js/Sidebar.Geometry.RingBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryRingGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -92,4 +92,4 @@ function SidebarGeometryRingGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryRingGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.ShapeGeometry.js → editor/js/Sidebar.Geometry.ShapeBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UIButton } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryShapeGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -52,4 +52,4 @@ function SidebarGeometryShapeGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryShapeGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.SphereGeometry.js → editor/js/Sidebar.Geometry.SphereBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometrySphereGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -104,4 +104,4 @@ function SidebarGeometrySphereGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometrySphereGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.TeapotBufferGeometry.js

@@ -2,7 +2,7 @@ import { UIRow, UIText, UIInteger, UICheckbox, UINumber } from './libs/ui.js';
 
 import { TeapotBufferGeometry } from '../../examples/jsm/geometries/TeapotBufferGeometry.js';
 
-function SidebarGeometryTeapotBufferGeometry( signals, object ) {
+function GeometryParametersPanel( signals, object ) {
 
 	var container = new UIRow();
 
@@ -102,4 +102,4 @@ function SidebarGeometryTeapotBufferGeometry( signals, object ) {
 
 }
 
-export { SidebarGeometryTeapotBufferGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.TetrahedronGeometry.js → editor/js/Sidebar.Geometry.TetrahedronBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryTetrahedronGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -53,4 +53,4 @@ function SidebarGeometryTetrahedronGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryTetrahedronGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.TorusGeometry.js → editor/js/Sidebar.Geometry.TorusBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryTorusGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -82,4 +82,4 @@ function SidebarGeometryTorusGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryTorusGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.TorusKnotGeometry.js → editor/js/Sidebar.Geometry.TorusKnotBufferGeometry.js

@@ -4,7 +4,7 @@ import { UIRow, UIText, UIInteger, UINumber } from './libs/ui.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryTorusKnotGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -93,4 +93,4 @@ function SidebarGeometryTorusKnotGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryTorusKnotGeometry };
+export { GeometryParametersPanel };

+ 2 - 2
editor/js/Sidebar.Geometry.TubeGeometry.js → editor/js/Sidebar.Geometry.TubeBufferGeometry.js

@@ -5,7 +5,7 @@ import { UIPoints3 } from './libs/ui.three.js';
 
 import { SetGeometryCommand } from './commands/SetGeometryCommand.js';
 
-function SidebarGeometryTubeGeometry( editor, object ) {
+function GeometryParametersPanel( editor, object ) {
 
 	var strings = editor.strings;
 
@@ -102,4 +102,4 @@ function SidebarGeometryTubeGeometry( editor, object ) {
 
 }
 
-export { SidebarGeometryTubeGeometry };
+export { GeometryParametersPanel };

+ 5 - 41
editor/js/Sidebar.Geometry.js

@@ -8,46 +8,8 @@ import { SidebarGeometryGeometry } from './Sidebar.Geometry.Geometry.js';
 import { SidebarGeometryBufferGeometry } from './Sidebar.Geometry.BufferGeometry.js';
 import { SidebarGeometryModifiers } from './Sidebar.Geometry.Modifiers.js';
 
-import { SidebarGeometryBoxGeometry } from './Sidebar.Geometry.BoxGeometry.js';
-import { SidebarGeometryCircleGeometry } from './Sidebar.Geometry.CircleGeometry.js';
-import { SidebarGeometryCylinderGeometry } from './Sidebar.Geometry.CylinderGeometry.js';
-import { SidebarGeometryDodecahedronGeometry } from './Sidebar.Geometry.DodecahedronGeometry.js';
-import { SidebarGeometryExtrudeGeometry } from './Sidebar.Geometry.ExtrudeGeometry.js';
-import { SidebarGeometryIcosahedronGeometry } from './Sidebar.Geometry.IcosahedronGeometry.js';
-import { SidebarGeometryLatheGeometry } from './Sidebar.Geometry.LatheGeometry.js';
-import { SidebarGeometryOctahedronGeometry } from './Sidebar.Geometry.OctahedronGeometry.js';
-import { SidebarGeometryPlaneGeometry } from './Sidebar.Geometry.PlaneGeometry.js';
-import { SidebarGeometryRingGeometry } from './Sidebar.Geometry.RingGeometry.js';
-import { SidebarGeometryShapeGeometry } from './Sidebar.Geometry.ShapeGeometry.js';
-import { SidebarGeometrySphereGeometry } from './Sidebar.Geometry.SphereGeometry.js';
-import { SidebarGeometryTeapotBufferGeometry } from './Sidebar.Geometry.TeapotBufferGeometry.js';
-import { SidebarGeometryTetrahedronGeometry } from './Sidebar.Geometry.TetrahedronGeometry.js';
-import { SidebarGeometryTorusGeometry } from './Sidebar.Geometry.TorusGeometry.js';
-import { SidebarGeometryTorusKnotGeometry } from './Sidebar.Geometry.TorusKnotGeometry.js';
-import { SidebarGeometryTubeGeometry } from './Sidebar.Geometry.TubeGeometry.js';
-
 import { VertexNormalsHelper } from '../../examples/jsm/helpers/VertexNormalsHelper.js';
 
-var geometryUIClasses = {
-	'BoxBufferGeometry': SidebarGeometryBoxGeometry,
-	'CircleBufferGeometry': SidebarGeometryCircleGeometry,
-	'CylinderBufferGeometry': SidebarGeometryCylinderGeometry,
-	'DodecahedronBufferGeometry': SidebarGeometryDodecahedronGeometry,
-	'ExtrudeBufferGeometry': SidebarGeometryExtrudeGeometry,
-	'IcosahedronBufferGeometry': SidebarGeometryIcosahedronGeometry,
-	'LatheBufferGeometry': SidebarGeometryLatheGeometry,
-	'OctahedronBufferGeometry': SidebarGeometryOctahedronGeometry,
-	'PlaneBufferGeometry': SidebarGeometryPlaneGeometry,
-	'RingBufferGeometry': SidebarGeometryRingGeometry,
-	'ShapeBufferGeometry': SidebarGeometryShapeGeometry,
-	'SphereBufferGeometry': SidebarGeometrySphereGeometry,
-	'TeapotBufferGeometry': SidebarGeometryTeapotBufferGeometry,
-	'TetrahedronBufferGeometry': SidebarGeometryTetrahedronGeometry,
-	'TorusBufferGeometry': SidebarGeometryTorusGeometry,
-	'TorusKnotBufferGeometry': SidebarGeometryTorusKnotGeometry,
-	'TubeBufferGeometry': SidebarGeometryTubeGeometry
-};
-
 function SidebarGeometry( editor ) {
 
 	var strings = editor.strings;
@@ -222,7 +184,7 @@ function SidebarGeometry( editor ) {
 	} );
 	helpersRow.add( vertexNormalsButton );
 
-	function build() {
+	async function build() {
 
 		var object = editor.selected;
 
@@ -247,9 +209,11 @@ function SidebarGeometry( editor ) {
 
 					parameters.add( new SidebarGeometryModifiers( editor, object ) );
 
-				} else if ( geometryUIClasses[ geometry.type ] !== undefined ) {
+				} else {
+
+					var { GeometryParametersPanel } = await import( `./Sidebar.Geometry.${ geometry.type }.js` );
 
-					parameters.add( new geometryUIClasses[ geometry.type ]( editor, object ) );
+					parameters.add( new GeometryParametersPanel( editor, object ) );
 
 				}
 

+ 16 - 16
editor/sw.js

@@ -139,23 +139,23 @@ const assets = [
 	'./js/Sidebar.Geometry.Geometry.js',
 	'./js/Sidebar.Geometry.BufferGeometry.js',
 	'./js/Sidebar.Geometry.Modifiers.js',
-	'./js/Sidebar.Geometry.BoxGeometry.js',
-	'./js/Sidebar.Geometry.CircleGeometry.js',
-	'./js/Sidebar.Geometry.CylinderGeometry.js',
-	'./js/Sidebar.Geometry.DodecahedronGeometry.js',
-	'./js/Sidebar.Geometry.ExtrudeGeometry.js',
-	'./js/Sidebar.Geometry.IcosahedronGeometry.js',
-	'./js/Sidebar.Geometry.OctahedronGeometry.js',
-	'./js/Sidebar.Geometry.PlaneGeometry.js',
-	'./js/Sidebar.Geometry.RingGeometry.js',
-	'./js/Sidebar.Geometry.SphereGeometry.js',
-	'./js/Sidebar.Geometry.ShapeGeometry.js',
-	'./js/Sidebar.Geometry.TetrahedronGeometry.js',
-	'./js/Sidebar.Geometry.TorusGeometry.js',
-	'./js/Sidebar.Geometry.TorusKnotGeometry.js',
-	'./js/Sidebar.Geometry.TubeGeometry.js',
+	'./js/Sidebar.Geometry.BoxBufferGeometry.js',
+	'./js/Sidebar.Geometry.CircleBufferGeometry.js',
+	'./js/Sidebar.Geometry.CylinderBufferGeometry.js',
+	'./js/Sidebar.Geometry.DodecahedronBufferGeometry.js',
+	'./js/Sidebar.Geometry.ExtrudeBufferGeometry.js',
+	'./js/Sidebar.Geometry.IcosahedronBufferGeometry.js',
+	'./js/Sidebar.Geometry.LatheBufferGeometry.js',
+	'./js/Sidebar.Geometry.OctahedronBufferGeometry.js',
+	'./js/Sidebar.Geometry.PlaneBufferGeometry.js',
+	'./js/Sidebar.Geometry.RingBufferGeometry.js',
+	'./js/Sidebar.Geometry.SphereBufferGeometry.js',
+	'./js/Sidebar.Geometry.ShapeBufferGeometry.js',
+	'./js/Sidebar.Geometry.TetrahedronBufferGeometry.js',
+	'./js/Sidebar.Geometry.TorusBufferGeometry.js',
+	'./js/Sidebar.Geometry.TorusKnotBufferGeometry.js',
+	'./js/Sidebar.Geometry.TubeBufferGeometry.js',
 	'./js/Sidebar.Geometry.TeapotBufferGeometry.js',
-	'./js/Sidebar.Geometry.LatheGeometry.js',
 	'./js/Sidebar.Material.js',
 	'./js/Sidebar.Animation.js',
 	'./js/Sidebar.Script.js',