Kaynağa Gözat

Updated examples builds.

Mr.doob 4 yıl önce
ebeveyn
işleme
1da6f21e7e
2 değiştirilmiş dosya ile 39 ekleme ve 14 silme
  1. 26 2
      examples/js/exporters/ColladaExporter.js
  2. 13 12
      examples/js/math/Lut.js

+ 26 - 2
examples/js/exporters/ColladaExporter.js

@@ -19,9 +19,33 @@
 			options = Object.assign( {
 				version: '1.4.1',
 				author: null,
-				textureDirectory: ''
+				textureDirectory: '',
+				upAxis: 'Y_UP',
+				unitName: null,
+				unitMeter: null
 			}, options );
 
+			if ( options.upAxis.match( /^[XYZ]_UP$/ ) === null ) {
+
+				console.error( 'ColladaExporter: Invalid upAxis: valid values are X_UP, Y_UP or Z_UP.' );
+				return null;
+
+			}
+
+			if ( options.unitName !== null && options.unitMeter === null ) {
+
+				console.error( 'ColladaExporter: unitMeter needs to be specified if unitName is specified.' );
+				return null;
+
+			}
+
+			if ( options.unitMeter !== null && options.unitName === null ) {
+
+				console.error( 'ColladaExporter: unitName needs to be specified if unitMeter is specified.' );
+				return null;
+
+			}
+
 			if ( options.textureDirectory !== '' ) {
 
 				options.textureDirectory = `${options.textureDirectory}/`.replace( /\\/g, '/' ).replace( /\/+/g, '/' );
@@ -437,7 +461,7 @@
 			const libraryMaterials = [];
 			const libraryVisualScenes = processObject( object );
 			const specLink = version === '1.4.1' ? 'http://www.collada.org/2005/11/COLLADASchema' : 'https://www.khronos.org/collada/';
-			let dae = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' + `<COLLADA xmlns="${specLink}" version="${version}">` + '<asset>' + ( '<contributor>' + '<authoring_tool>three.js Collada Exporter</authoring_tool>' + ( options.author !== null ? `<author>${options.author}</author>` : '' ) + '</contributor>' + `<created>${new Date().toISOString()}</created>` + `<modified>${new Date().toISOString()}</modified>` + '<up_axis>Y_UP</up_axis>' ) + '</asset>';
+			let dae = '<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' + `<COLLADA xmlns="${specLink}" version="${version}">` + '<asset>' + ( '<contributor>' + '<authoring_tool>three.js Collada Exporter</authoring_tool>' + ( options.author !== null ? `<author>${options.author}</author>` : '' ) + '</contributor>' + `<created>${new Date().toISOString()}</created>` + `<modified>${new Date().toISOString()}</modified>` + ( options.unitName !== null ? `<unit name="${options.unitName}" meter="${options.unitMeter}" />` : '' ) + `<up_axis>${options.upAxis}</up_axis>` ) + '</asset>';
 			dae += `<library_images>${libraryImages.join( '' )}</library_images>`;
 			dae += `<library_effects>${libraryEffects.join( '' )}</library_effects>`;
 			dae += `<library_materials>${libraryMaterials.join( '' )}</library_materials>`;

+ 13 - 12
examples/js/math/Lut.js

@@ -2,16 +2,20 @@
 
 	class Lut {
 
-		constructor( colormap, numberofcolors ) {
+		constructor( colormap, count = 32 ) {
 
 			this.lut = [];
-			this.setColorMap( colormap, numberofcolors );
+			this.map = [];
+			this.n = 0;
+			this.minV = 0;
+			this.maxV = 1;
+			this.setColorMap( colormap, count );
 
 		}
 
 		set( value ) {
 
-			if ( value instanceof Lut ) {
+			if ( value.isLut === true ) {
 
 				this.copy( value );
 
@@ -35,10 +39,10 @@
 
 		}
 
-		setColorMap( colormap, numberofcolors = 32 ) {
+		setColorMap( colormap, count = 32 ) {
 
 			this.map = ColorMapKeywords[ colormap ] || ColorMapKeywords.rainbow;
-			this.n = numberofcolors;
+			this.n = count;
 			const step = 1.0 / this.n;
 			this.lut.length = 0;
 
@@ -95,9 +99,10 @@
 
 		}
 
-		addColorMap( colormapName, arrayOfColors ) {
+		addColorMap( name, arrayOfColors ) {
 
-			ColorMapKeywords[ colormapName ] = arrayOfColors;
+			ColorMapKeywords[ name ] = arrayOfColors;
+			return this;
 
 		}
 
@@ -151,11 +156,7 @@
 
 	}
 
-	Lut.prototype.lut = [];
-	Lut.prototype.map = [];
-	Lut.prototype.n = 256;
-	Lut.prototype.minV = 0;
-	Lut.prototype.maxV = 1;
+	Lut.prototype.isLut = true;
 	const ColorMapKeywords = {
 		'rainbow': [[ 0.0, 0x0000FF ], [ 0.2, 0x00FFFF ], [ 0.5, 0x00FF00 ], [ 0.8, 0xFFFF00 ], [ 1.0, 0xFF0000 ]],
 		'cooltowarm': [[ 0.0, 0x3C4EC2 ], [ 0.2, 0x9BBCFF ], [ 0.5, 0xDCDCDC ], [ 0.8, 0xF6A385 ], [ 1.0, 0xB40426 ]],