Browse Source

Merge remote-tracking branch 'mrdoob-origin/dev' into gltf-webp-bug

Garrett Johnson 4 years ago
parent
commit
020fbdb379
51 changed files with 63 additions and 54 deletions
  1. 6 2
      editor/js/Menubar.File.js
  2. 2 0
      examples/js/loaders/GLTFLoader.js
  3. 4 2
      examples/jsm/exporters/USDZExporter.js
  4. 2 0
      examples/jsm/loaders/GLTFLoader.js
  5. 1 1
      src/extras/core/Font.js
  6. 1 1
      src/extras/curves/ArcCurve.js
  7. 1 1
      src/extras/curves/CatmullRomCurve3.js
  8. 1 1
      src/extras/curves/CubicBezierCurve.js
  9. 1 1
      src/extras/curves/CubicBezierCurve3.js
  10. 1 1
      src/extras/curves/EllipseCurve.js
  11. 1 1
      src/extras/curves/LineCurve.js
  12. 1 1
      src/extras/curves/LineCurve3.js
  13. 1 1
      src/extras/curves/QuadraticBezierCurve.js
  14. 1 1
      src/extras/curves/QuadraticBezierCurve3.js
  15. 1 1
      src/extras/curves/SplineCurve.js
  16. 1 1
      src/lights/AmbientLight.js
  17. 1 1
      src/lights/AmbientLightProbe.js
  18. 1 1
      src/lights/DirectionalLight.js
  19. 1 1
      src/lights/DirectionalLightShadow.js
  20. 1 1
      src/lights/HemisphereLight.js
  21. 1 1
      src/lights/HemisphereLightProbe.js
  22. 1 1
      src/lights/Light.js
  23. 1 1
      src/lights/LightProbe.js
  24. 1 1
      src/lights/PointLight.js
  25. 1 1
      src/lights/PointLightShadow.js
  26. 1 1
      src/lights/RectAreaLight.js
  27. 1 1
      src/lights/SpotLight.js
  28. 1 1
      src/lights/SpotLightShadow.js
  29. 1 0
      src/loaders/ImageBitmapLoader.js
  30. 1 1
      src/math/Box2.js
  31. 1 1
      src/math/Box3.js
  32. 1 1
      src/math/Color.js
  33. 1 1
      src/math/Euler.js
  34. 1 1
      src/math/Matrix3.js
  35. 1 1
      src/math/Matrix4.js
  36. 1 1
      src/math/Plane.js
  37. 1 1
      src/math/Quaternion.js
  38. 1 1
      src/math/SphericalHarmonics3.js
  39. 1 1
      src/math/Vector2.js
  40. 1 1
      src/math/Vector3.js
  41. 1 1
      src/math/Vector4.js
  42. 1 1
      src/objects/Group.js
  43. 1 1
      src/objects/LineLoop.js
  44. 1 1
      src/objects/Sprite.js
  45. 1 1
      src/renderers/WebGLCubeRenderTarget.js
  46. 1 1
      src/renderers/WebGLMultisampleRenderTarget.js
  47. 1 1
      src/renderers/WebGLRenderTarget.js
  48. 1 1
      src/scenes/Fog.js
  49. 1 1
      src/scenes/FogExp2.js
  50. 1 1
      src/scenes/Scene.js
  51. 3 5
      test/unit/src/core/Object3D.tests.js

+ 6 - 2
editor/js/Menubar.File.js

@@ -488,12 +488,16 @@ function MenubarFile( editor ) {
 	var link = document.createElement( 'a' );
 	function save( blob, filename ) {
 
+		if ( link.href ) {
+
+			URL.revokeObjectURL( link.href );
+
+		}
+
 		link.href = URL.createObjectURL( blob );
 		link.download = filename || 'data.json';
 		link.dispatchEvent( new MouseEvent( 'click' ) );
 
-		// URL.revokeObjectURL( url ); breaks Firefox...
-
 	}
 
 	function saveArrayBuffer( buffer, filename ) {

+ 2 - 0
examples/js/loaders/GLTFLoader.js

@@ -228,6 +228,7 @@ THREE.GLTFLoader = ( function () {
 
 				path: path || this.resourcePath || '',
 				crossOrigin: this.crossOrigin,
+				requestHeader: this.requestHeader,
 				manager: this.manager,
 				ktx2Loader: this.ktx2Loader,
 				meshoptDecoder: this.meshoptDecoder
@@ -1843,6 +1844,7 @@ THREE.GLTFLoader = ( function () {
 		}
 
 		this.textureLoader.setCrossOrigin( this.options.crossOrigin );
+		this.textureLoader.setRequestHeader( this.options.requestHeader );
 
 		this.fileLoader = new THREE.FileLoader( this.options.manager );
 		this.fileLoader.setResponseType( 'arraybuffer' );

+ 4 - 2
examples/jsm/exporters/USDZExporter.js

@@ -83,9 +83,11 @@ async function imgToU8( image ) {
 		( typeof OffscreenCanvas !== 'undefined' && image instanceof OffscreenCanvas ) ||
 		( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {
 
+		const scale = 1024 / Math.max( image.width, image.height );
+
 		const canvas = document.createElement( 'canvas' );
-		canvas.width = Math.min( 1024, image.width );
-		canvas.height = Math.min( 1024, image.height );
+		canvas.width = image.width * Math.min( 1, scale );
+		canvas.height = image.height * Math.min( 1, scale );
 
 		const context = canvas.getContext( '2d' );
 		context.drawImage( image, 0, 0, canvas.width, canvas.height );

+ 2 - 0
examples/jsm/loaders/GLTFLoader.js

@@ -293,6 +293,7 @@ var GLTFLoader = ( function () {
 
 				path: path || this.resourcePath || '',
 				crossOrigin: this.crossOrigin,
+				requestHeader: this.requestHeader,
 				manager: this.manager,
 				ktx2Loader: this.ktx2Loader,
 				meshoptDecoder: this.meshoptDecoder
@@ -1908,6 +1909,7 @@ var GLTFLoader = ( function () {
 		}
 
 		this.textureLoader.setCrossOrigin( this.options.crossOrigin );
+		this.textureLoader.setRequestHeader( this.options.requestHeader );
 
 		this.fileLoader = new FileLoader( this.options.manager );
 		this.fileLoader.setResponseType( 'arraybuffer' );

+ 1 - 1
src/extras/core/Font.js

@@ -4,7 +4,7 @@ class Font {
 
 	constructor( data ) {
 
-		Object.defineProperty( this, 'isFont', { value: true } );
+		this.isFont = true;
 
 		this.type = 'Font';
 

+ 1 - 1
src/extras/curves/ArcCurve.js

@@ -7,7 +7,7 @@ class ArcCurve extends EllipseCurve {
 		super( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
 
 		this.type = 'ArcCurve';
-		Object.defineProperty( this, 'isArcCurve', { value: true } );
+		this.isArcCurve = true;
 
 	}
 

+ 1 - 1
src/extras/curves/CatmullRomCurve3.js

@@ -88,7 +88,7 @@ class CatmullRomCurve3 extends Curve {
 		super();
 
 		this.type = 'CatmullRomCurve3';
-		Object.defineProperty( this, 'isCatmullRomCurve3', { value: true } );
+		this.isCatmullRomCurve3 = true;
 		this.points = points;
 		this.closed = closed;
 		this.curveType = curveType;

+ 1 - 1
src/extras/curves/CubicBezierCurve.js

@@ -9,7 +9,7 @@ class CubicBezierCurve extends Curve {
 		super();
 
 		this.type = 'CubicBezierCurve';
-		Object.defineProperty( this, 'isCubicBezierCurve', { value: true } );
+		this.isCubicBezierCurve = true;
 
 		this.v0 = v0;
 		this.v1 = v1;

+ 1 - 1
src/extras/curves/CubicBezierCurve3.js

@@ -9,7 +9,7 @@ class CubicBezierCurve3 extends Curve {
 		super();
 
 		this.type = 'CubicBezierCurve3';
-		Object.defineProperty( this, 'isCubicBezierCurve3', { value: true } );
+		this.isCubicBezierCurve3 = true;
 
 		this.v0 = v0;
 		this.v1 = v1;

+ 1 - 1
src/extras/curves/EllipseCurve.js

@@ -8,7 +8,7 @@ class EllipseCurve extends Curve {
 		super();
 
 		this.type = 'EllipseCurve';
-		Object.defineProperty( this, 'isEllipseCurve', { value: true } );
+		this.isEllipseCurve = true;
 
 		this.aX = aX || 0;
 		this.aY = aY || 0;

+ 1 - 1
src/extras/curves/LineCurve.js

@@ -8,7 +8,7 @@ class LineCurve extends Curve {
 		super();
 
 		this.type = 'LineCurve';
-		Object.defineProperty( this, 'isLineCurve', { value: true } );
+		this.isLineCurve = true;
 
 		this.v1 = v1;
 		this.v2 = v2;

+ 1 - 1
src/extras/curves/LineCurve3.js

@@ -8,7 +8,7 @@ class LineCurve3 extends Curve {
 		super();
 
 		this.type = 'LineCurve3';
-		Object.defineProperty( this, 'isLineCurve3', { value: true } );
+		this.isLineCurve3 = true;
 
 		this.v1 = v1;
 		this.v2 = v2;

+ 1 - 1
src/extras/curves/QuadraticBezierCurve.js

@@ -9,7 +9,7 @@ class QuadraticBezierCurve extends Curve {
 		super();
 
 		this.type = 'QuadraticBezierCurve';
-		Object.defineProperty( this, 'isQuadraticBezierCurve', { value: true } );
+		this.isQuadraticBezierCurve = true;
 
 		this.v0 = v0;
 		this.v1 = v1;

+ 1 - 1
src/extras/curves/QuadraticBezierCurve3.js

@@ -9,7 +9,7 @@ class QuadraticBezierCurve3 extends Curve {
 		super();
 
 		this.type = 'QuadraticBezierCurve3';
-		Object.defineProperty( this, 'isQuadraticBezierCurve3', { value: true } );
+		this.isQuadraticBezierCurve3 = true;
 
 		this.v0 = v0;
 		this.v1 = v1;

+ 1 - 1
src/extras/curves/SplineCurve.js

@@ -9,7 +9,7 @@ class SplineCurve extends Curve {
 		super();
 
 		this.type = 'SplineCurve';
-		Object.defineProperty( this, 'isSplineCurve', { value: true } );
+		this.isSplineCurve = true;
 
 		this.points = points;
 

+ 1 - 1
src/lights/AmbientLight.js

@@ -7,7 +7,7 @@ class AmbientLight extends Light {
 		super( color, intensity );
 
 		this.type = 'AmbientLight';
-		Object.defineProperty( this, 'isAmbientLight', { value: true } );
+		this.isAmbientLight = true;
 
 	}
 

+ 1 - 1
src/lights/AmbientLightProbe.js

@@ -7,7 +7,7 @@ class AmbientLightProbe extends LightProbe {
 
 		super( undefined, intensity );
 
-		Object.defineProperty( this, 'isAmbientLightProbe', { value: true } );
+		this.isAmbientLightProbe = true;
 
 		const color1 = new Color().set( color );
 

+ 1 - 1
src/lights/DirectionalLight.js

@@ -8,7 +8,7 @@ class DirectionalLight extends Light {
 
 		super( color, intensity );
 
-		Object.defineProperty( this, 'isDirectionalLight', { value: true } );
+		this.isDirectionalLight = true;
 
 		this.type = 'DirectionalLight';
 

+ 1 - 1
src/lights/DirectionalLightShadow.js

@@ -7,7 +7,7 @@ class DirectionalLightShadow extends LightShadow {
 
 		super( new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );
 
-		Object.defineProperty( this, 'isDirectionalLightShadow', { value: true } );
+		this.isDirectionalLightShadow = true;
 
 	}
 

+ 1 - 1
src/lights/HemisphereLight.js

@@ -8,7 +8,7 @@ class HemisphereLight extends Light {
 
 		super( skyColor, intensity );
 
-		Object.defineProperty( this, 'isHemisphereLight', { value: true } );
+		this.isHemisphereLight = true;
 
 		this.type = 'HemisphereLight';
 

+ 1 - 1
src/lights/HemisphereLightProbe.js

@@ -8,7 +8,7 @@ class HemisphereLightProbe extends LightProbe {
 
 		super( undefined, intensity );
 
-		Object.defineProperty( this, 'isHemisphereLightProbe', { value: true } );
+		this.isHemisphereLightProbe = true;
 
 		const color1 = new Color().set( skyColor );
 		const color2 = new Color().set( groundColor );

+ 1 - 1
src/lights/Light.js

@@ -7,7 +7,7 @@ class Light extends Object3D {
 
 		super();
 
-		Object.defineProperty( this, 'isLight', { value: true } );
+		this.isLight = true;
 
 		this.type = 'Light';
 

+ 1 - 1
src/lights/LightProbe.js

@@ -7,7 +7,7 @@ class LightProbe extends Light {
 
 		super( undefined, intensity );
 
-		Object.defineProperty( this, 'isLightProbe', { value: true } );
+		this.isLightProbe = true;
 
 		this.sh = sh;
 

+ 1 - 1
src/lights/PointLight.js

@@ -7,7 +7,7 @@ class PointLight extends Light {
 
 		super( color, intensity );
 
-		Object.defineProperty( this, 'isPointLight', { value: true } );
+		this.isPointLight = true;
 
 		this.type = 'PointLight';
 

+ 1 - 1
src/lights/PointLightShadow.js

@@ -15,7 +15,7 @@ class PointLightShadow extends LightShadow {
 
 		super( new PerspectiveCamera( 90, 1, 0.5, 500 ) );
 
-		Object.defineProperty( this, 'isPointLightShadow', { value: true } );
+		this.isPointLightShadow = true;
 
 		this._frameExtents = new Vector2( 4, 2 );
 

+ 1 - 1
src/lights/RectAreaLight.js

@@ -6,7 +6,7 @@ class RectAreaLight extends Light {
 
 		super( color, intensity );
 
-		Object.defineProperty( this, 'isRectAreaLight', { value: true } );
+		this.isRectAreaLight = true;
 
 		this.type = 'RectAreaLight';
 

+ 1 - 1
src/lights/SpotLight.js

@@ -8,7 +8,7 @@ class SpotLight extends Light {
 
 		super( color, intensity );
 
-		Object.defineProperty( this, 'isSpotLight', { value: true } );
+		this.isSpotLight = true;
 
 		this.type = 'SpotLight';
 

+ 1 - 1
src/lights/SpotLightShadow.js

@@ -8,7 +8,7 @@ class SpotLightShadow extends LightShadow {
 
 		super( new PerspectiveCamera( 50, 1, 0.5, 500 ) );
 
-		Object.defineProperty( this, 'isSpotLightShadow', { value: true } );
+		this.isSpotLightShadow = true;
 
 		this.focus = 1;
 

+ 1 - 0
src/loaders/ImageBitmapLoader.js

@@ -65,6 +65,7 @@ ImageBitmapLoader.prototype = Object.assign( Object.create( Loader.prototype ),
 
 		const fetchOptions = {};
 		fetchOptions.credentials = ( this.crossOrigin === 'anonymous' ) ? 'same-origin' : 'include';
+		fetchOptions.headers = this.requestHeader;
 
 		fetch( url, fetchOptions ).then( function ( res ) {
 

+ 1 - 1
src/math/Box2.js

@@ -6,7 +6,7 @@ class Box2 {
 
 	constructor( min, max ) {
 
-		Object.defineProperty( this, 'isBox2', { value: true } );
+		this.isBox2 = true;
 
 		this.min = ( min !== undefined ) ? min : new Vector2( + Infinity, + Infinity );
 		this.max = ( max !== undefined ) ? max : new Vector2( - Infinity, - Infinity );

+ 1 - 1
src/math/Box3.js

@@ -4,7 +4,7 @@ class Box3 {
 
 	constructor( min, max ) {
 
-		Object.defineProperty( this, 'isBox3', { value: true } );
+		this.isBox3 = true;
 
 		this.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );
 		this.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );

+ 1 - 1
src/math/Color.js

@@ -55,7 +55,7 @@ class Color {
 
 	constructor( r, g, b ) {
 
-		Object.defineProperty( this, 'isColor', { value: true } );
+		this.isColor = true;
 
 		if ( g === undefined && b === undefined ) {
 

+ 1 - 1
src/math/Euler.js

@@ -7,7 +7,7 @@ class Euler {
 
 	constructor( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {
 
-		Object.defineProperty( this, 'isEuler', { value: true } );
+		this.isEuler = true;
 
 		this._x = x;
 		this._y = y;

+ 1 - 1
src/math/Matrix3.js

@@ -2,7 +2,7 @@ class Matrix3 {
 
 	constructor() {
 
-		Object.defineProperty( this, 'isMatrix3', { value: true } );
+		this.isMatrix3 = true;
 
 		this.elements = [
 

+ 1 - 1
src/math/Matrix4.js

@@ -4,7 +4,7 @@ class Matrix4 {
 
 	constructor() {
 
-		Object.defineProperty( this, 'isMatrix4', { value: true } );
+		this.isMatrix4 = true;
 
 		this.elements = [
 

+ 1 - 1
src/math/Plane.js

@@ -9,7 +9,7 @@ class Plane {
 
 	constructor( normal, constant ) {
 
-		Object.defineProperty( this, 'isPlane', { value: true } );
+		this.isPlane = true;
 
 		// normal is assumed to be normalized
 

+ 1 - 1
src/math/Quaternion.js

@@ -4,7 +4,7 @@ class Quaternion {
 
 	constructor( x = 0, y = 0, z = 0, w = 1 ) {
 
-		Object.defineProperty( this, 'isQuaternion', { value: true } );
+		this.isQuaternion = true;
 
 		this._x = x;
 		this._y = y;

+ 1 - 1
src/math/SphericalHarmonics3.js

@@ -14,7 +14,7 @@ class SphericalHarmonics3 {
 
 	constructor() {
 
-		Object.defineProperty( this, 'isSphericalHarmonics3', { value: true } );
+		this.isSphericalHarmonics3 = true;
 
 		this.coefficients = [];
 

+ 1 - 1
src/math/Vector2.js

@@ -2,7 +2,7 @@ class Vector2 {
 
 	constructor( x = 0, y = 0 ) {
 
-		Object.defineProperty( this, 'isVector2', { value: true } );
+		this.isVector2 = true;
 
 		this.x = x;
 		this.y = y;

+ 1 - 1
src/math/Vector3.js

@@ -5,7 +5,7 @@ class Vector3 {
 
 	constructor( x = 0, y = 0, z = 0 ) {
 
-		Object.defineProperty( this, 'isVector3', { value: true } );
+		this.isVector3 = true;
 
 		this.x = x;
 		this.y = y;

+ 1 - 1
src/math/Vector4.js

@@ -2,7 +2,7 @@ class Vector4 {
 
 	constructor( x = 0, y = 0, z = 0, w = 1 ) {
 
-		Object.defineProperty( this, 'isVector4', { value: true } );
+		this.isVector4 = true;
 
 		this.x = x;
 		this.y = y;

+ 1 - 1
src/objects/Group.js

@@ -6,7 +6,7 @@ class Group extends Object3D {
 
 		super();
 		this.type = 'Group';
-		Object.defineProperty( this, 'isGroup', { value: true } );
+		this.isGroup = true;
 
 	}
 

+ 1 - 1
src/objects/LineLoop.js

@@ -6,7 +6,7 @@ class LineLoop extends Line {
 
 		super( geometry, material );
 		this.type = 'LineLoop';
-		Object.defineProperty( this, 'isLineLoop', { value: true } );
+		this.isLineLoop = true;
 
 	}
 

+ 1 - 1
src/objects/Sprite.js

@@ -57,7 +57,7 @@ class Sprite extends Object3D {
 
 		this.center = new Vector2( 0.5, 0.5 );
 
-		Object.defineProperty( this, 'isSprite', { value: true } );
+		this.isSprite = true;
 
 	}
 

+ 1 - 1
src/renderers/WebGLCubeRenderTarget.js

@@ -21,7 +21,7 @@ class WebGLCubeRenderTarget extends WebGLRenderTarget {
 
 		super( size, size, options );
 
-		Object.defineProperty( this, 'isWebGLCubeRenderTarget', { value: true } );
+		this.isWebGLCubeRenderTarget = true;
 
 		options = options || {};
 

+ 1 - 1
src/renderers/WebGLMultisampleRenderTarget.js

@@ -6,7 +6,7 @@ class WebGLMultisampleRenderTarget extends WebGLRenderTarget {
 
 		super( width, height, options );
 
-		Object.defineProperty( this, 'isWebGLMultisampleRenderTarget', { value: true } );
+		this.isWebGLMultisampleRenderTarget = true;
 
 		this.samples = 4;
 

+ 1 - 1
src/renderers/WebGLRenderTarget.js

@@ -14,7 +14,7 @@ class WebGLRenderTarget extends EventDispatcher {
 
 		super();
 
-		Object.defineProperty( this, 'isWebGLRenderTarget', { value: true } );
+		this.isWebGLRenderTarget = true;
 
 		this.width = width;
 		this.height = height;

+ 1 - 1
src/scenes/Fog.js

@@ -4,7 +4,7 @@ class Fog {
 
 	constructor( color, near, far ) {
 
-		Object.defineProperty( this, 'isFog', { value: true } );
+		this.isFog = true;
 
 		this.name = '';
 

+ 1 - 1
src/scenes/FogExp2.js

@@ -4,7 +4,7 @@ class FogExp2 {
 
 	constructor( color, density ) {
 
-		Object.defineProperty( this, 'isFogExp2', { value: true } );
+		this.isFogExp2 = true;
 
 		this.name = '';
 

+ 1 - 1
src/scenes/Scene.js

@@ -6,7 +6,7 @@ class Scene extends Object3D {
 
 		super();
 
-		Object.defineProperty( this, 'isScene', { value: true } );
+		this.isScene = true;
 
 		this.type = 'Scene';
 

+ 3 - 5
test/unit/src/core/Object3D.tests.js

@@ -297,11 +297,9 @@ export default QUnit.module( 'Core', () => {
 			obj.translateOnAxis( new Vector3( 0, 1, 0 ), 1.23 );
 			obj.translateOnAxis( new Vector3( 0, 0, 1 ), - 4.56 );
 
-			assert.propEqual( obj.position, {
-				x: 1,
-				y: 1.23,
-				z: - 4.56
-			} );
+			assert.numEqual( obj.position.x, 1, 'x is equal' );
+			assert.numEqual( obj.position.y, 1.23, 'y is equal' );
+			assert.numEqual( obj.position.z, - 4.56, 'z is equal' );
 
 		} );