Browse Source

Merge branch 'dev' into sheen

Daniel Sturk 6 năm trước cách đây
mục cha
commit
4466b48ef5
100 tập tin đã thay đổi với 995 bổ sung82 xóa
  1. 17 0
      docs/api/en/objects/Points.html
  2. 3 3
      docs/api/en/renderers/WebGLRenderer.html
  3. 16 0
      docs/api/zh/objects/Points.html
  4. 2 2
      docs/manual/en/introduction/How-to-use-WebGL2.html
  5. 1 1
      docs/manual/en/introduction/WebGL-compatibility-check.html
  6. 2 2
      docs/manual/zh/introduction/How-to-use-WebGL2.html
  7. 1 1
      docs/manual/zh/introduction/WebGL-compatibility-check.html
  8. 1 1
      examples/js/WebGL.js
  9. 19 1
      examples/js/controls/OrthographicTrackballControls.js
  10. 2 2
      examples/js/controls/TransformControls.js
  11. 12 0
      examples/js/libs/dat.gui.min.js
  12. 5 0
      examples/js/libs/stats.min.js
  13. 9 1
      examples/js/loaders/EXRLoader.js
  14. 12 4
      examples/js/loaders/HDRCubeTextureLoader.js
  15. 9 1
      examples/js/loaders/RGBELoader.js
  16. 9 0
      examples/jsm/WebGL.d.ts
  17. 98 0
      examples/jsm/WebGL.js
  18. 19 1
      examples/jsm/controls/OrthographicTrackballControls.js
  19. 2 2
      examples/jsm/controls/TransformControls.js
  20. 1 1
      examples/jsm/loaders/EXRLoader.d.ts
  21. 9 1
      examples/jsm/loaders/EXRLoader.js
  22. 1 1
      examples/jsm/loaders/HDRCubeTextureLoader.d.ts
  23. 12 4
      examples/jsm/loaders/HDRCubeTextureLoader.js
  24. 1 1
      examples/jsm/loaders/MMDLoader.d.ts
  25. 45 0
      examples/jsm/loaders/OBJLoader2.d.ts
  26. 48 2
      examples/jsm/loaders/OBJLoader2.js
  27. 19 0
      examples/jsm/loaders/OBJLoader2Parallel.d.ts
  28. 28 4
      examples/jsm/loaders/OBJLoader2Parallel.js
  29. 1 1
      examples/jsm/loaders/RGBELoader.d.ts
  30. 9 1
      examples/jsm/loaders/RGBELoader.js
  31. 4 0
      examples/jsm/loaders/obj2/bridge/MtlObjBridge.d.ts
  32. 6 2
      examples/jsm/loaders/obj2/bridge/MtlObjBridge.js
  33. 22 0
      examples/jsm/loaders/obj2/shared/MaterialHandler.d.ts
  34. 23 2
      examples/jsm/loaders/obj2/shared/MaterialHandler.js
  35. 22 0
      examples/jsm/loaders/obj2/shared/MeshReceiver.d.ts
  36. 23 6
      examples/jsm/loaders/obj2/shared/MeshReceiver.js
  37. 4 0
      examples/jsm/loaders/obj2/utils/CodeSerializer.d.ts
  38. 8 3
      examples/jsm/loaders/obj2/utils/CodeSerializer.js
  39. 3 0
      examples/jsm/loaders/obj2/utils/ObjectManipulator.d.ts
  40. 5 1
      examples/jsm/loaders/obj2/utils/ObjectManipulator.js
  41. 59 0
      examples/jsm/loaders/obj2/worker/main/WorkerExecutionSupport.d.ts
  42. 78 5
      examples/jsm/loaders/obj2/worker/main/WorkerExecutionSupport.js
  43. 81 0
      examples/jsm/loaders/obj2/worker/parallel/OBJLoader2Parser.d.ts
  44. 94 20
      examples/jsm/loaders/obj2/worker/parallel/OBJLoader2Parser.js
  45. 24 0
      examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.d.ts
  46. 19 4
      examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.js
  47. 2 0
      examples/jsm/nodes/accessors/CameraNode.js
  48. 2 0
      examples/jsm/nodes/accessors/ColorsNode.js
  49. 2 0
      examples/jsm/nodes/accessors/LightNode.js
  50. 2 0
      examples/jsm/nodes/accessors/NormalNode.js
  51. 2 0
      examples/jsm/nodes/accessors/PositionNode.js
  52. 2 0
      examples/jsm/nodes/accessors/ResolutionNode.js
  53. 2 0
      examples/jsm/nodes/accessors/ScreenUVNode.js
  54. 2 0
      examples/jsm/nodes/accessors/UVNode.js
  55. 2 0
      examples/jsm/nodes/bsdfs/BlinnExponentToRoughnessNode.js
  56. 2 0
      examples/jsm/nodes/bsdfs/RoughnessToBlinnExponentNode.js
  57. 2 0
      examples/jsm/nodes/core/AttributeNode.js
  58. 2 0
      examples/jsm/nodes/core/ConstNode.js
  59. 2 0
      examples/jsm/nodes/core/FunctionCallNode.js
  60. 2 0
      examples/jsm/nodes/core/FunctionNode.js
  61. 2 0
      examples/jsm/nodes/core/InputNode.js
  62. 2 0
      examples/jsm/nodes/core/Node.js
  63. 2 0
      examples/jsm/nodes/core/VarNode.js
  64. 2 0
      examples/jsm/nodes/effects/BlurNode.js
  65. 2 0
      examples/jsm/nodes/effects/ColorAdjustmentNode.js
  66. 2 0
      examples/jsm/nodes/effects/LuminanceNode.js
  67. 2 0
      examples/jsm/nodes/inputs/BoolNode.js
  68. 2 0
      examples/jsm/nodes/inputs/ColorNode.js
  69. 2 0
      examples/jsm/nodes/inputs/CubeTextureNode.js
  70. 2 0
      examples/jsm/nodes/inputs/FloatNode.js
  71. 2 0
      examples/jsm/nodes/inputs/IntNode.js
  72. 2 0
      examples/jsm/nodes/inputs/Matrix3Node.js
  73. 2 0
      examples/jsm/nodes/inputs/Matrix4Node.js
  74. 2 0
      examples/jsm/nodes/inputs/RTTNode.js
  75. 2 0
      examples/jsm/nodes/inputs/ReflectorNode.js
  76. 2 0
      examples/jsm/nodes/inputs/TextureNode.js
  77. 2 0
      examples/jsm/nodes/inputs/Vector2Node.js
  78. 2 0
      examples/jsm/nodes/inputs/Vector3Node.js
  79. 2 0
      examples/jsm/nodes/inputs/Vector4Node.js
  80. 2 0
      examples/jsm/nodes/materials/NodeMaterial.js
  81. 2 0
      examples/jsm/nodes/materials/nodes/PhongNode.js
  82. 2 0
      examples/jsm/nodes/materials/nodes/RawNode.js
  83. 2 0
      examples/jsm/nodes/materials/nodes/SpriteNode.js
  84. 2 0
      examples/jsm/nodes/math/CondNode.js
  85. 2 0
      examples/jsm/nodes/math/MathNode.js
  86. 2 0
      examples/jsm/nodes/math/OperatorNode.js
  87. 2 0
      examples/jsm/nodes/misc/BumpMapNode.js
  88. 2 0
      examples/jsm/nodes/misc/NormalMapNode.js
  89. 2 0
      examples/jsm/nodes/postprocessing/NodePass.js
  90. 2 0
      examples/jsm/nodes/postprocessing/NodePostProcessing.js
  91. 2 0
      examples/jsm/nodes/procedural/CheckerNode.js
  92. 2 0
      examples/jsm/nodes/procedural/NoiseNode.js
  93. 2 0
      examples/jsm/nodes/utils/BypassNode.js
  94. 2 0
      examples/jsm/nodes/utils/ColorSpaceNode.js
  95. 2 0
      examples/jsm/nodes/utils/JoinNode.js
  96. 2 0
      examples/jsm/nodes/utils/SwitchNode.js
  97. 2 0
      examples/jsm/nodes/utils/TimerNode.js
  98. 2 0
      examples/jsm/nodes/utils/UVTransformNode.js
  99. 2 0
      examples/jsm/nodes/utils/VelocityNode.js
  100. 1 1
      examples/webgl2_materials_texture2darray.html

+ 17 - 0
docs/api/en/objects/Points.html

@@ -54,6 +54,17 @@
 			Default is a [page:PointsMaterial] with a random color.
 		</p>
 
+		<h3>[property:Array morphTargetInfluences]</h3>
+		<p>
+		An array of weights typically from 0-1 that specify how much of the morph is applied.
+		Undefined by default, but reset to a blank array by [page:Points.updateMorphTargets updateMorphTargets].
+		</p>
+
+		<h3>[property:Object morphTargetDictionary]</h3>
+		<p>
+		A dictionary of morphTargets based on the morphTarget.name property.
+		Undefined by default, but rebuilt [page:Points.updateMorphTargets updateMorphTargets].
+		</p>
 
 		<h2>Methods</h2>
 		<p>See the base [page:Object3D] class for common methods.</p>
@@ -69,6 +80,12 @@
 		Returns a clone of this Points object and its descendants.
 		</p>
 
+		<h3>[method:null updateMorphTargets]()</h3>
+		<p>
+		Updates the morphTargets to have no influence on the object. Resets the
+		[page:Points.morphTargetInfluences morphTargetInfluences] and
+		[page:Points.morphTargetDictionary morphTargetDictionary] properties.
+		</p>
 
 		<h2>Source</h2>
 

+ 3 - 3
docs/api/en/renderers/WebGLRenderer.html

@@ -354,7 +354,7 @@
 		<h3>[method:Integer getActiveCubeFace]()</h3>
 		<p>Returns the current active cube face.</p>
 
-		<h3>[method:Integer getActiveMipMapLevel]()</h3>
+		<h3>[method:Integer getActiveMipmapLevel]()</h3>
 		<p>Returns the current active mipmap level.</p>
 
 		<h3>[method:RenderTarget getRenderTarget]()</h3>
@@ -446,11 +446,11 @@
 		<h3>[method:null setPixelRatio]( [param:number value] )</h3>
 		<p>Sets device pixel ratio. This is usually used for HiDPI device to prevent bluring output canvas.</p>
 
-		<h3>[method:null setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipMapLevel] )</h3>
+		<h3>[method:null setRenderTarget]( [param:WebGLRenderTarget renderTarget], [param:Integer activeCubeFace], [param:Integer activeMipmapLevel] )</h3>
 		<p>
 		renderTarget -- The [page:WebGLRenderTarget renderTarget] that needs to be activated. When *null* is given, the canvas is set as the active render target instead.<br />
 		activeCubeFace -- Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of [page:WebGLRenderTargetCube] (optional).<br />
-		activeMipMapLevel -- Specifies the active mipmap level (optional).<br /><br />
+		activeMipmapLevel -- Specifies the active mipmap level (optional).<br /><br />
 		This method sets the active rendertarget.
 		</p>
 

+ 16 - 0
docs/api/zh/objects/Points.html

@@ -50,6 +50,17 @@
 		[page:Material]的实例。定义了物体的外观。默认值是一个具有随机颜色的[page:PointsMaterial]。
 	</p>
 
+	<h3>[property:Array morphTargetInfluences]</h3>
+	<p>
+		一个包含有权重(值一般在0-1范围内)的数组,指定应用了多少变形。
+		默认情况下是未定义的,但是会被[page:Points.updateMorphTargets updateMorphTargets]重置为一个空数组。
+	</p>
+
+	<h3>[property:Object morphTargetDictionary]</h3>
+	<p>
+		基于morphTarget.name属性的morphTargets字典。
+		默认情况下是未定义的,但是会被[page:Points.updateMorphTargets updateMorphTargets]重建。
+	</p>
 
 	<h2>方法</h2>
 	<p>请参阅其基类[page:Object3D]来查看共有方法。</p>
@@ -65,6 +76,11 @@
 		返回这个点及其子集的一个克隆对象。
 	</p>
 
+	<h3>[method:null updateMorphTargets]()</h3>
+	<p>
+		更新morphTargets,使其不对对象产生影响,重置[page:Points.morphTargetInfluences morphTargetInfluences] and
+		[page:Points.morphTargetDictionary morphTargetDictionary]属性。
+	</p>
 
 	<h2>源代码</h2>
 

+ 2 - 2
docs/manual/en/introduction/How-to-use-WebGL2.html

@@ -22,11 +22,11 @@
 
 	<p>
 		Since WebGL 2 is not supported by all devices that support WebGL 1, it's important to check the respective availability.
-		To do so, please include [link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js WebGL.js] into your project.
+		To do so, please include [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js WebGL.js] into your project.
 	</p>
 
 	<code>
-&lt;script src="/path/to/WebGL.js"&gt;&lt;/script&gt;
+import { WEBGL } from 'three/examples/jsm/WebGL.js';
 	</code>
 
 	<p>

+ 1 - 1
docs/manual/en/introduction/WebGL-compatibility-check.html

@@ -15,7 +15,7 @@
 		</p>
 
 		<p>
-			Add	[link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js]
+			Add	[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js]
 			to your javascript and run the following before attempting to render anything.
 		</p>
 

+ 2 - 2
docs/manual/zh/introduction/How-to-use-WebGL2.html

@@ -21,11 +21,11 @@
 
 	<p>
 		由于WebGL 2并不被所有支持WebGL 1的设备所支持,因此检查各种设备上WebGL 2的可用性是非常重要的。
-		要对其可用性进行检查,请将[link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js WebGL.js]包含到你的项目中。
+		要对其可用性进行检查,请将[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js WebGL.js]包含到你的项目中。
 	</p>
 
 	<code>
-&lt;script src="/path/to/WebGL.js"&gt;&lt;/script&gt;
+import { WEBGL } from 'three/examples/jsm/WebGL.js';
 	</code>
 
 	<p>

+ 1 - 1
docs/manual/zh/introduction/WebGL-compatibility-check.html

@@ -14,7 +14,7 @@
 		</p>
 
 		<p>
-			请将[link:https://github.com/mrdoob/three.js/blob/master/examples/js/WebGL.js]引入到你的文件,并在尝试开始渲染之前先运行该文件。
+			请将[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/WebGL.js]引入到你的文件,并在尝试开始渲染之前先运行该文件。
         	</p>
 
 <code>

+ 1 - 1
examples/js/WebGL.js

@@ -3,7 +3,7 @@
  * @author mr.doob / http://mrdoob.com/
  */
 
-var WEBGL = {
+THREE.WEBGL = {
 
 	isWebGLAvailable: function () {
 

+ 19 - 1
examples/js/controls/OrthographicTrackballControls.js

@@ -485,7 +485,25 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) {
 		event.preventDefault();
 		event.stopPropagation();
 
-		_zoomStart.y += event.deltaY * 0.01;
+		switch ( event.deltaMode ) {
+
+			case 2:
+				// Zoom in pages
+				_zoomStart.y -= event.deltaY * 0.025;
+				break;
+
+			case 1:
+				// Zoom in lines
+				_zoomStart.y -= event.deltaY * 0.01;
+				break;
+
+			default:
+				// undefined, 0, assume pixels
+				_zoomStart.y -= event.deltaY * 0.00025;
+				break;
+
+		}
+
 		_this.dispatchEvent( startEvent );
 		_this.dispatchEvent( endEvent );
 

+ 2 - 2
examples/js/controls/TransformControls.js

@@ -598,7 +598,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 
 	}
 
-	// TODO: depricate
+	// TODO: deprecate
 
 	this.getMode = function () {
 
@@ -638,7 +638,7 @@ THREE.TransformControls = function ( camera, domElement ) {
 
 	this.update = function () {
 
-		console.warn( 'THREE.TransformControls: update function has been depricated.' );
+		console.warn( 'THREE.TransformControls: update function has no more functionality and therefore has been deprecated.' );
 
 	};
 

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 12 - 0
examples/js/libs/dat.gui.min.js


+ 5 - 0
examples/js/libs/stats.min.js

@@ -0,0 +1,5 @@
+// stats.js - http://github.com/mrdoob/stats.js
+var Stats=function(){function h(a){c.appendChild(a.dom);return a}function k(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?"block":"none";l=a}var l=0,c=document.createElement("div");c.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";c.addEventListener("click",function(a){a.preventDefault();k(++l%c.children.length)},!1);var g=(performance||Date).now(),e=g,a=0,r=h(new Stats.Panel("FPS","#0ff","#002")),f=h(new Stats.Panel("MS","#0f0","#020"));
+if(self.performance&&self.performance.memory)var t=h(new Stats.Panel("MB","#f08","#201"));k(0);return{REVISION:16,dom:c,addPanel:h,showPanel:k,begin:function(){g=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();f.update(c-g,200);if(c>e+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}};
+Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f,
+v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats);

+ 9 - 1
examples/js/loaders/EXRLoader.js

@@ -82,13 +82,21 @@ THREE.EXRLoader = function ( manager ) {
 
 THREE.EXRLoader.prototype = Object.create( THREE.DataTextureLoader.prototype );
 
-THREE.EXRLoader.prototype.setType = function ( value ) {
+THREE.EXRLoader.prototype.setDataType = function ( value ) {
 
 	this.type = value;
 	return this;
 
 };
 
+THREE.EXRLoader.prototype.setType = function ( value ) {
+
+	console.warn( 'THREE.EXRLoader: .setType() has been renamed to .setDataType().' );
+
+	return this.setDataType( value );
+
+};
+
 THREE.EXRLoader.prototype._parser = function ( buffer ) {
 
 	const USHORT_RANGE = ( 1 << 16 );

+ 12 - 4
examples/js/loaders/HDRCubeTextureLoader.js

@@ -15,9 +15,9 @@ THREE.HDRCubeTextureLoader.prototype.load = function ( urls, onLoad, onProgress,
 
 	if ( ! Array.isArray( urls ) ) {
 
-		console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setType() instead.' );
+		console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
 
-		this.setType( urls );
+		this.setDataType( urls );
 
 		urls = onLoad;
 		onLoad = onProgress;
@@ -121,10 +121,18 @@ THREE.HDRCubeTextureLoader.prototype.setPath = function ( value ) {
 
 };
 
-THREE.HDRCubeTextureLoader.prototype.setType = function ( value ) {
+THREE.HDRCubeTextureLoader.prototype.setDataType = function ( value ) {
 
 	this.type = value;
-	this.hdrLoader.setType( value );
+	this.hdrLoader.setDataType( value );
 	return this;
 
 };
+
+THREE.HDRCubeTextureLoader.prototype.setType = function ( value ) {
+
+	console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
+
+	return this.setDataType( value );
+
+};

+ 9 - 1
examples/js/loaders/RGBELoader.js

@@ -470,13 +470,21 @@ THREE.RGBELoader.prototype._parser = function ( buffer ) {
 
 };
 
-THREE.RGBELoader.prototype.setType = function ( value ) {
+THREE.RGBELoader.prototype.setDataType = function ( value ) {
 
 	this.type = value;
 	return this;
 
 };
 
+THREE.RGBELoader.prototype.setType = function ( value ) {
+
+	console.warn( 'THREE.RGBELoader: .setType() has been renamed to .setDataType().' );
+
+	return this.setDataType( value );
+
+};
+
 THREE.RGBELoader.prototype.load = function ( url, onLoad, onProgress, onError ) {
 
 	function onLoadCallback( texture, texData ) {

+ 9 - 0
examples/jsm/WebGL.d.ts

@@ -0,0 +1,9 @@
+export namespace WEBGL {
+
+  export function isWebGLAvailable(): boolean;
+  export function isWebGL2Available(): boolean;
+  export function getWebGLErrorMessage(): HTMLElement;
+  export function getWebGL2ErrorMessage(): HTMLElement;
+  export function getErrorMessage(version: number): HTMLElement;
+
+}

+ 98 - 0
examples/jsm/WebGL.js

@@ -0,0 +1,98 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ * @author mr.doob / http://mrdoob.com/
+ */
+
+
+
+var WEBGL = {
+
+	isWebGLAvailable: function () {
+
+		try {
+
+			var canvas = document.createElement( 'canvas' );
+			return !! ( window.WebGLRenderingContext && ( canvas.getContext( 'webgl' ) || canvas.getContext( 'experimental-webgl' ) ) );
+
+		} catch ( e ) {
+
+			return false;
+
+		}
+
+	},
+
+	isWebGL2Available: function () {
+
+		try {
+
+			var canvas = document.createElement( 'canvas' );
+			return !! ( window.WebGL2RenderingContext && canvas.getContext( 'webgl2' ) );
+
+		} catch ( e ) {
+
+			return false;
+
+		}
+
+	},
+
+	getWebGLErrorMessage: function () {
+
+		return this.getErrorMessage( 1 );
+
+	},
+
+	getWebGL2ErrorMessage: function () {
+
+		return this.getErrorMessage( 2 );
+
+	},
+
+	getErrorMessage: function ( version ) {
+
+		var names = {
+			1: 'WebGL',
+			2: 'WebGL 2'
+		};
+
+		var contexts = {
+			1: window.WebGLRenderingContext,
+			2: window.WebGL2RenderingContext
+		};
+
+		var message = 'Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';
+
+		var element = document.createElement( 'div' );
+		element.id = 'webglmessage';
+		element.style.fontFamily = 'monospace';
+		element.style.fontSize = '13px';
+		element.style.fontWeight = 'normal';
+		element.style.textAlign = 'center';
+		element.style.background = '#fff';
+		element.style.color = '#000';
+		element.style.padding = '1.5em';
+		element.style.width = '400px';
+		element.style.margin = '5em auto 0';
+
+		if ( contexts[ version ] ) {
+
+			message = message.replace( '$0', 'graphics card' );
+
+		} else {
+
+			message = message.replace( '$0', 'browser' );
+
+		}
+
+		message = message.replace( '$1', names[ version ] );
+
+		element.innerHTML = message;
+
+		return element;
+
+	}
+
+};
+
+export { WEBGL };

+ 19 - 1
examples/jsm/controls/OrthographicTrackballControls.js

@@ -492,7 +492,25 @@ var OrthographicTrackballControls = function ( object, domElement ) {
 		event.preventDefault();
 		event.stopPropagation();
 
-		_zoomStart.y += event.deltaY * 0.01;
+		switch ( event.deltaMode ) {
+
+			case 2:
+				// Zoom in pages
+				_zoomStart.y -= event.deltaY * 0.025;
+				break;
+
+			case 1:
+				// Zoom in lines
+				_zoomStart.y -= event.deltaY * 0.01;
+				break;
+
+			default:
+				// undefined, 0, assume pixels
+				_zoomStart.y -= event.deltaY * 0.00025;
+				break;
+
+		}
+
 		_this.dispatchEvent( startEvent );
 		_this.dispatchEvent( endEvent );
 

+ 2 - 2
examples/jsm/controls/TransformControls.js

@@ -623,7 +623,7 @@ var TransformControls = function ( camera, domElement ) {
 
 	}
 
-	// TODO: depricate
+	// TODO: deprecate
 
 	this.getMode = function () {
 
@@ -663,7 +663,7 @@ var TransformControls = function ( camera, domElement ) {
 
 	this.update = function () {
 
-		console.warn( 'THREE.TransformControls: update function has been depricated.' );
+		console.warn( 'THREE.TransformControls: update function has no more functionality and therefore has been deprecated.' );
 
 	};
 

+ 1 - 1
examples/jsm/loaders/EXRLoader.d.ts

@@ -19,5 +19,5 @@ export class EXRLoader extends DataTextureLoader {
   type: TextureDataType;
 
   _parser(buffer: ArrayBuffer) : EXR;
-  setType(type: TextureDataType): this;
+  setDataType(type: TextureDataType): this;
 }

+ 9 - 1
examples/jsm/loaders/EXRLoader.js

@@ -91,13 +91,21 @@ var EXRLoader = function ( manager ) {
 
 EXRLoader.prototype = Object.create( DataTextureLoader.prototype );
 
-EXRLoader.prototype.setType = function ( value ) {
+EXRLoader.prototype.setDataType = function ( value ) {
 
 	this.type = value;
 	return this;
 
 };
 
+EXRLoader.prototype.setType = function ( value ) {
+
+	console.warn( 'THREE.EXRLoader: .setType() has been renamed to .setDataType().' );
+
+	return this.setDataType( value );
+
+};
+
 EXRLoader.prototype._parser = function ( buffer ) {
 
 	const USHORT_RANGE = ( 1 << 16 );

+ 1 - 1
examples/jsm/loaders/HDRCubeTextureLoader.d.ts

@@ -15,5 +15,5 @@ export class HDRCubeTextureLoader {
 
   load(url: string, onLoad: (texture: CubeTexture) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   setPath(value: string): this;
-  setType(type: TextureDataType): this;
+  setDataType(type: TextureDataType): this;
 }

+ 12 - 4
examples/jsm/loaders/HDRCubeTextureLoader.js

@@ -32,9 +32,9 @@ HDRCubeTextureLoader.prototype.load = function ( urls, onLoad, onProgress, onErr
 
 	if ( ! Array.isArray( urls ) ) {
 
-		console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setType() instead.' );
+		console.warn( 'THREE.HDRCubeTextureLoader signature has changed. Use .setDataType() instead.' );
 
-		this.setType( urls );
+		this.setDataType( urls );
 
 		urls = onLoad;
 		onLoad = onProgress;
@@ -138,12 +138,20 @@ HDRCubeTextureLoader.prototype.setPath = function ( value ) {
 
 };
 
-HDRCubeTextureLoader.prototype.setType = function ( value ) {
+HDRCubeTextureLoader.prototype.setDataType = function ( value ) {
 
 	this.type = value;
-	this.hdrLoader.setType( value );
+	this.hdrLoader.setDataType( value );
 	return this;
 
 };
 
+HDRCubeTextureLoader.prototype.setType = function ( value ) {
+
+	console.warn( 'THREE.HDRCubeTextureLoader: .setType() has been renamed to .setDataType().' );
+
+	return this.setDataType( value );
+
+};
+
 export { HDRCubeTextureLoader };

+ 1 - 1
examples/jsm/loaders/MMDLoader.d.ts

@@ -28,7 +28,7 @@ export class MMDLoader {
   loadPMX(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   loadVMD(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   loadVPD(url: string, onLoad: (object: object) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
-  loadWithAnimation(url: string, onLoad: (object: MMDLoaderAnimationObject) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
+  loadWithAnimation(url: string, vmdUrl: string | string[], onLoad: (object: MMDLoaderAnimationObject) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void): void;
   setAnimationPath(animationPath: string): this;
   setCrossOrigin(crossOrigin: string): this;
   setPath(path: string): this;

+ 45 - 0
examples/jsm/loaders/OBJLoader2.d.ts

@@ -0,0 +1,45 @@
+import {
+  LoadingManager,
+  Group
+} from '../../../src/Three';
+
+import { MaterialHandler } from './obj2/shared/MaterialHandler';
+import { MeshReceiver} from './obj2/shared/MeshReceiver';
+
+export class OBJLoader2 {
+  constructor(manager?: LoadingManager);
+  manager: LoadingManager;
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+  modelName: string;
+  instanceNo: number;
+  path: string;
+  resourcePath: string;
+  useIndices: boolean;
+  disregardNormals: boolean;
+  materialPerSmoothingGroup: boolean;
+  useOAsMesh: boolean;
+  baseObject3d: Group;
+  callbacks: {
+    onParseProgress: Function;
+    genericErrorHandler: Function;
+  };
+  materialHandler: MaterialHandler;
+  meshReceiver: MeshReceiver;
+
+  addMaterials(materials: object): void;
+  load(url: string, onLoad: (group: Group) => void, onProgress?: (event: ProgressEvent) => void, onError?: (event: ErrorEvent) => void, onMeshAlter?: (meshData: object) => void): void;
+  parse(content: ArrayBuffer | string): void;
+  setLogging(enabled: boolean, debug: boolean): this;
+  setModelName(modelName: string): this;
+  setPath(path: string): this;
+  setResourcePath(path: string): this;
+  setBaseObject3d(baseObject3d: Object3D): this;
+  setUseIndices(useIndices: boolean): this;
+  setDisregardNormals(disregardNormals: boolean): this;
+  setMaterialPerSmoothingGroup(materialPerSmoothingGroup: boolean): this;
+  setUseOAsMesh(useOAsMesh: boolean): this;
+  setGenericErrorHandler(genericErrorHandler: Function): void;
+}

+ 48 - 2
examples/jsm/loaders/OBJLoader2.js

@@ -20,6 +20,7 @@ import { MaterialHandler } from "./obj2/shared/MaterialHandler.js";
  * @param {DefaultLoadingManager} [manager] The loadingManager for the loader to use. Default is {@link DefaultLoadingManager}
  */
 const OBJLoader2 = function ( manager ) {
+
 	this.manager = ( manager !== undefined && manager !== null ) ? manager : DefaultLoadingManager;
 	this.logging = {
 		enabled: true,
@@ -43,6 +44,7 @@ const OBJLoader2 = function ( manager ) {
 
 	this.materialHandler = new MaterialHandler();
 	this.meshReceiver = new MeshReceiver( this.materialHandler );
+
 };
 OBJLoader2.OBJLOADER2_VERSION = '3.0.0-beta2';
 console.info( 'Using OBJLoader2 version: ' + OBJLoader2.OBJLOADER2_VERSION );
@@ -58,9 +60,11 @@ OBJLoader2.prototype = {
 	 * @param {boolean} debug True or false.
 	 */
 	setLogging: function ( enabled, debug ) {
+
 		this.logging.enabled = enabled === true;
 		this.logging.debug = debug === true;
 		return this;
+
 	},
 
 	/**
@@ -69,8 +73,10 @@ OBJLoader2.prototype = {
 	 * @param {string} modelName
 	 */
 	setModelName: function ( modelName ) {
+
 		this.modelName = modelName ? modelName : this.modelName;
 		return this;
+
 	},
 
 	/**
@@ -79,8 +85,10 @@ OBJLoader2.prototype = {
 	 * @param {string} path URL
 	 */
 	setPath: function ( path ) {
+
 		this.path = path ? path : this.path;
 		return this;
+
 	},
 
 
@@ -89,7 +97,9 @@ OBJLoader2.prototype = {
 	 * @param {string} resourcePath
 	 */
 	setResourcePath: function ( resourcePath ) {
+
 		this.resourcePath = resourcePath ? resourcePath : this.resourcePath;
+
 	},
 
 	/**
@@ -98,8 +108,10 @@ OBJLoader2.prototype = {
 	 * @param {Object3D} baseObject3d Object already attached to scenegraph where new meshes will be attached to
 	 */
 	setBaseObject3d: function ( baseObject3d ) {
+
 		this.baseObject3d = ( baseObject3d === undefined || baseObject3d === null ) ? this.baseObject3d : baseObject3d;
 		return this;
+
 	},
 
 	/**
@@ -108,7 +120,9 @@ OBJLoader2.prototype = {
 	 * @param materials Object with named {@link Material}
 	 */
 	addMaterials: function ( materials ) {
+
 		this.materialHandler.addMaterials( materials );
+
 	},
 
 	/**
@@ -117,8 +131,10 @@ OBJLoader2.prototype = {
 	 * @param {boolean} useIndices=false
 	 */
 	setUseIndices: function ( useIndices ) {
+
 		this.useIndices = useIndices === true;
 		return this;
+
 	},
 
 	/**
@@ -127,8 +143,10 @@ OBJLoader2.prototype = {
 	 * @param {boolean} disregardNormals=false
 	 */
 	setDisregardNormals: function ( disregardNormals ) {
+
 		this.disregardNormals = disregardNormals === true;
 		return this;
+
 	},
 
 	/**
@@ -137,8 +155,10 @@ OBJLoader2.prototype = {
 	 * @param {boolean} materialPerSmoothingGroup=false
 	 */
 	setMaterialPerSmoothingGroup: function ( materialPerSmoothingGroup ) {
+
 		this.materialPerSmoothingGroup = materialPerSmoothingGroup === true;
 		return this;
+
 	},
 
 	/**
@@ -147,8 +167,10 @@ OBJLoader2.prototype = {
 	 * @param {boolean} useOAsMesh=false
 	 */
 	setUseOAsMesh: function ( useOAsMesh ) {
+
 		this.useOAsMesh = useOAsMesh === true;
 		return this;
+
 	},
 
 	/**
@@ -156,11 +178,13 @@ OBJLoader2.prototype = {
 	 * @param {Function} genericErrorHandler
 	 */
 	setGenericErrorHandler: function ( genericErrorHandler ) {
+
 		if ( genericErrorHandler !== undefined && genericErrorHandler !== null ) {
 
 			this.callbacks.genericErrorHandler = genericErrorHandler;
 
 		}
+
 	},
 
 	/**
@@ -173,6 +197,7 @@ OBJLoader2.prototype = {
 	 * @private
 	 */
 	_setCallbacks: function ( onParseProgress, onMeshAlter, onLoadMaterials ) {
+
 		if ( onParseProgress !== undefined && onParseProgress !== null ) {
 
 			this.callbacks.onParseProgress = onParseProgress;
@@ -180,6 +205,7 @@ OBJLoader2.prototype = {
 		}
 		this.meshReceiver._setCallbacks( onParseProgress, onMeshAlter );
 		this.materialHandler._setCallbacks( onLoadMaterials );
+
 	},
 
 	/**
@@ -191,6 +217,7 @@ OBJLoader2.prototype = {
 	 * @param {number} numericalValue Numerical value describing the progress
 	 */
 	_onProgress: function ( type, text, numericalValue ) {
+
 		let message = text ? text : '';
 		let event = {
 			detail: {
@@ -211,6 +238,7 @@ OBJLoader2.prototype = {
 			console.log( message );
 
 		}
+
 	},
 
 	/**
@@ -220,6 +248,7 @@ OBJLoader2.prototype = {
 	 * @param {String} errorMessage The event containing the error
 	 */
 	_onError: function ( errorMessage ) {
+
 		if ( this.callbacks.genericErrorHandler ) {
 
 			this.callbacks.genericErrorHandler( errorMessage );
@@ -243,6 +272,7 @@ OBJLoader2.prototype = {
 	 * @param {function} [onMeshAlter] Called after worker successfully delivered a single mesh
 	 */
 	load: function ( url, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
+
 		let scope = this;
 		if ( onError === null || onError === undefined ) {
 
@@ -279,27 +309,32 @@ OBJLoader2.prototype = {
 			let numericalValueRef = 0;
 			let numericalValue = 0;
 			onFileLoadProgress = function ( event ) {
+
 				if ( ! event.lengthComputable ) return;
 
 				numericalValue = event.loaded / event.total;
 				if ( numericalValue > numericalValueRef ) {
 
 					numericalValueRef = numericalValue;
-					let output = 'Download of "' + url + '": ' + (numericalValue * 100).toFixed( 2 ) + '%';
+					let output = 'Download of "' + url + '": ' + ( numericalValue * 100 ).toFixed( 2 ) + '%';
 					scope._onProgress( 'progressLoad', output, numericalValue );
 
 				}
+
 			};
 
 		}
 		this._setCallbacks( null, onMeshAlter, null );
 		let fileLoaderOnLoad = function ( content ) {
+
 			onLoad( scope.parse( content ) );
+
 		};
 		let fileLoader = new FileLoader( this.manager );
 		fileLoader.setPath( this.path || this.resourcePath );
 		fileLoader.setResponseType( 'arraybuffer' );
 		fileLoader.load( filename, fileLoaderOnLoad, onFileLoadProgress, onError );
+
 	},
 
 	/**
@@ -308,6 +343,7 @@ OBJLoader2.prototype = {
 	 * @param {arraybuffer|string} content OBJ data as Uint8Array or String
 	 */
 	parse: function ( content ) {
+
 		// fast-fail in case of illegal data
 		if ( content === null || content === undefined ) {
 
@@ -330,13 +366,19 @@ OBJLoader2.prototype = {
 
 		let scope = this;
 		let scopedOnAssetAvailable = function ( payload ) {
+
 			scope._onAssetAvailable( payload );
+
 		};
 		let onProgressScoped = function ( text, numericalValue ) {
+
 			scope._onProgress( 'progressParse', text, numericalValue );
+
 		};
 		let onErrorScoped = function ( message ) {
+
 			scope._onError( message );
+
 		};
 		parser.setCallbackOnAssetAvailable( scopedOnAssetAvailable );
 		parser.setCallbackOnProgress( onProgressScoped );
@@ -346,7 +388,7 @@ OBJLoader2.prototype = {
 			if ( this.logging.enabled ) console.info( 'Parsing arrayBuffer...' );
 			parser.parse( content );
 
-		} else if ( typeof( content ) === 'string' || content instanceof String ) {
+		} else if ( typeof ( content ) === 'string' || content instanceof String ) {
 
 			if ( this.logging.enabled ) console.info( 'Parsing text...' );
 			parser.parseText( content );
@@ -362,6 +404,7 @@ OBJLoader2.prototype = {
 
 		}
 		return this.baseObject3d;
+
 	},
 
 	_onAssetAvailable: function ( payload ) {
@@ -372,7 +415,9 @@ OBJLoader2.prototype = {
 
 			let meshes = this.meshReceiver.buildMeshes( payload );
 			for ( let mesh of meshes ) {
+
 				this.baseObject3d.add( mesh );
+
 			}
 
 		} else if ( payload.type === 'material' ) {
@@ -380,6 +425,7 @@ OBJLoader2.prototype = {
 			this.materialHandler.addPayloadMaterials( payload );
 
 		}
+
 	}
 };
 

+ 19 - 0
examples/jsm/loaders/OBJLoader2Parallel.d.ts

@@ -0,0 +1,19 @@
+import {
+  LoadingManager
+} from '../../../src/Three';
+import { OBJLoader2 } from './OBJLoader2.js';
+
+import { WorkerExecutionSupport} from './obj2/worker/main/WorkerExecutionSupport';
+
+export class OBJLoader2Parallel extends OBJLoader2 {
+  constructor(manager?: LoadingManager);
+  preferJsmWorker: boolean;
+	executeParallel: boolean;
+	workerExecutionSupport: WorkerExecutionSupport;
+
+  setPreferJsmWorker(preferJsmWorker: boolean): this;
+  setCallbackOnParseComplete(onParseComplete: Function): this;
+  setExecuteParallel(executeParallel: boolean): this;
+  getWorkerExecutionSupport(): object;
+  buildWorkerCode(): object;
+}

+ 28 - 4
examples/jsm/loaders/OBJLoader2Parallel.js

@@ -27,12 +27,14 @@ import {
  * @constructor
  */
 const OBJLoader2Parallel = function ( manager ) {
+
 	OBJLoader2.call( this, manager );
 	this.preferJsmWorker = false;
 
 	this.callbacks.onParseComplete = null;
 	this.executeParallel = true;
 	this.workerExecutionSupport = new WorkerExecutionSupport();
+
 };
 OBJLoader2Parallel.prototype = Object.create( OBJLoader2.prototype );
 OBJLoader2Parallel.prototype.constructor = OBJLoader2Parallel;
@@ -42,8 +44,10 @@ console.info( 'Using OBJLoader2Parallel version: ' + OBJLoader2.OBJLOADER2_PARAL
 
 
 OBJLoader2Parallel.prototype.setPreferJsmWorker = function ( preferJsmWorker ) {
+
 	this.preferJsmWorker = preferJsmWorker === true;
 	return this;
+
 };
 
 /**
@@ -53,10 +57,14 @@ OBJLoader2Parallel.prototype.setPreferJsmWorker = function ( preferJsmWorker ) {
  * @return {OBJLoader2Parallel}
  */
 OBJLoader2Parallel.prototype.setCallbackOnParseComplete = function ( onParseComplete ) {
+
 	if ( onParseComplete !== undefined && onParseComplete !== null ) {
+
 		this.callbacks.onParseComplete = onParseComplete;
+
 	}
 	return this;
+
 };
 
 /**
@@ -66,8 +74,10 @@ OBJLoader2Parallel.prototype.setCallbackOnParseComplete = function ( onParseComp
  * @return {OBJLoader2Parallel}
  */
 OBJLoader2Parallel.prototype.setExecuteParallel = function ( executeParallel ) {
+
 	this.executeParallel = executeParallel === true;
 	return this;
+
 };
 
 /**
@@ -76,7 +86,9 @@ OBJLoader2Parallel.prototype.setExecuteParallel = function ( executeParallel ) {
  * @return {WorkerExecutionSupport|WorkerExecutionSupport}
  */
 OBJLoader2Parallel.prototype.getWorkerExecutionSupport = function () {
+
 	return this.workerExecutionSupport;
+
 };
 
 /**
@@ -85,6 +97,7 @@ OBJLoader2Parallel.prototype.getWorkerExecutionSupport = function () {
  * @return {CodeBuilderInstructions}
  */
 OBJLoader2Parallel.prototype.buildWorkerCode = function () {
+
 	let codeBuilderInstructions = new CodeBuilderInstructions( true, true, this.preferJsmWorker );
 	if ( codeBuilderInstructions.isSupportsJsmWorker() ) {
 
@@ -104,19 +117,23 @@ OBJLoader2Parallel.prototype.buildWorkerCode = function () {
 		codeBuilderInstructions.addCodeFragment( codeWorkerRunner );
 
 		// allows to include full libraries as importScripts
-//		codeBuilderInstructions.addLibraryImport( '../../node_modules/three/build/three.js' );
+		//		codeBuilderInstructions.addLibraryImport( '../../node_modules/three/build/three.js' );
 		codeBuilderInstructions.addStartCode( 'new WorkerRunner( new DefaultWorkerPayloadHandler( new OBJLoader2Parser() ) );' );
 
 	}
 	return codeBuilderInstructions;
+
 };
 
 /**
  * @private
  */
 OBJLoader2Parallel.prototype._configure = function () {
+
 	if ( this.callbacks.onParseComplete === null ) {
+
 		throw "No callbackOnLoad was provided! Aborting!";
+
 	}
 	// check if worker is already available and if so, then fast-fail
 	if ( this.workerExecutionSupport.isWorkerLoaded( this.preferJsmWorker ) ) return;
@@ -125,10 +142,13 @@ OBJLoader2Parallel.prototype._configure = function () {
 
 	let scope = this;
 	let scopedOnAssetAvailable = function ( payload ) {
+
 		scope._onAssetAvailable( payload );
+
 	};
 
 	this.workerExecutionSupport.updateCallbacks( scopedOnAssetAvailable, this.callbacks.onParseComplete );
+
 };
 
 /**
@@ -141,10 +161,12 @@ OBJLoader2Parallel.prototype._configure = function () {
  * @param {function} [onError] A function to be called if an error occurs during loading. The function receives the error as an argument.
  * @param {function} [onMeshAlter] Called after worker successfully delivered a single mesh
  */
-OBJLoader2Parallel.prototype.load = function( content, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
+OBJLoader2Parallel.prototype.load = function ( content, onLoad, onFileLoadProgress, onError, onMeshAlter ) {
+
 	this.setCallbackOnParseComplete( onLoad );
 
 	OBJLoader2.prototype.load.call( this, content, function () {}, onFileLoadProgress, onError, onMeshAlter );
+
 };
 
 /**
@@ -152,7 +174,8 @@ OBJLoader2Parallel.prototype.load = function( content, onLoad, onFileLoadProgres
  *
  * @param {arraybuffer} content OBJ data as Uint8Array or String
  */
-OBJLoader2Parallel.prototype.parse = function( content ) {
+OBJLoader2Parallel.prototype.parse = function ( content ) {
+
 	if ( this.executeParallel ) {
 
 		this._configure();
@@ -183,6 +206,7 @@ OBJLoader2Parallel.prototype.parse = function( content ) {
 		this.callbacks.onParseComplete( OBJLoader2.prototype.parse.call( this, content ) );
 
 	}
+
 };
 
-export { OBJLoader2Parallel }
+export { OBJLoader2Parallel };

+ 1 - 1
examples/jsm/loaders/RGBELoader.d.ts

@@ -21,5 +21,5 @@ export class RGBELoader extends DataTextureLoader {
   type: TextureDataType;
 
   _parser(buffer: ArrayBuffer): RGBE;
-  setType(type: TextureDataType): this;
+  setDataType(type: TextureDataType): this;
 }

+ 9 - 1
examples/jsm/loaders/RGBELoader.js

@@ -484,13 +484,21 @@ RGBELoader.prototype._parser = function ( buffer ) {
 
 };
 
-RGBELoader.prototype.setType = function ( value ) {
+RGBELoader.prototype.setDataType = function ( value ) {
 
 	this.type = value;
 	return this;
 
 };
 
+RGBELoader.prototype.setType = function ( value ) {
+
+	console.warn( 'THREE.RGBELoader: .setType() has been renamed to .setDataType().' );
+
+	return this.setDataType( value );
+
+};
+
 RGBELoader.prototype.load = function ( url, onLoad, onProgress, onError ) {
 
 	function onLoadCallback( texture, texData ) {

+ 4 - 0
examples/jsm/loaders/obj2/bridge/MtlObjBridge.d.ts

@@ -0,0 +1,4 @@
+export namespace MtlObjBridge {
+  export function link(processResult: object, assetLoader: object): void;
+  export function addMaterialsFromMtlLoader(materialCreator: object): void;
+}

+ 6 - 2
examples/jsm/loaders/obj2/bridge/MtlObjBridge.js

@@ -13,12 +13,14 @@ const MtlObjBridge = {
 	 * @param processResult
 	 * @param assetLoader
 	 */
-	link: function( processResult, assetLoader ) {
+	link: function ( processResult, assetLoader ) {
+
 		if ( typeof assetLoader.addMaterials === 'function' ) {
 
 			assetLoader.addMaterials( this.addMaterialsFromMtlLoader( processResult ) );
 
 		}
+
 	},
 
 	/**
@@ -27,6 +29,7 @@ const MtlObjBridge = {
 	 * @param Instance of {@link MTLLoader.MaterialCreator}
 	 */
 	addMaterialsFromMtlLoader: function ( materialCreator ) {
+
 		let newMaterials = {};
 		if ( materialCreator instanceof MTLLoader.MaterialCreator ) {
 
@@ -35,7 +38,8 @@ const MtlObjBridge = {
 
 		}
 		return newMaterials;
+
 	}
 };
 
-export { MtlObjBridge }
+export { MtlObjBridge };

+ 22 - 0
examples/jsm/loaders/obj2/shared/MaterialHandler.d.ts

@@ -0,0 +1,22 @@
+import {
+  Material
+} from '../../../../../src/Three';
+
+export class MaterialHandler {
+  constructor();
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+  callbacks: {
+    onLoadMaterials: Function;
+  };
+  materials: object;
+
+  addMaterials(materials: object, newMaterials: object): object;
+  addPayloadMaterials(materialPayload: object): object;
+  setLogging(enabled: boolean, debug: boolean): void;
+  getMaterials(): object;
+  getMaterial(materialName: string): Material;
+  getMaterialsJSON(): object;
+}

+ 23 - 2
examples/jsm/loaders/obj2/shared/MaterialHandler.js

@@ -13,6 +13,7 @@ import {
 
 
 const MaterialHandler = function () {
+
 	this.logging = {
 		enabled: true,
 		debug: false
@@ -23,6 +24,7 @@ const MaterialHandler = function () {
 	};
 	this.materials = {};
 	this._createDefaultMaterials();
+
 };
 
 MaterialHandler.prototype = {
@@ -36,19 +38,24 @@ MaterialHandler.prototype = {
 	 * @param {boolean} debug True or false.
 	 */
 	setLogging:	function ( enabled, debug ) {
+
 		this.logging.enabled = enabled === true;
 		this.logging.debug = debug === true;
+
 	},
 
 	_setCallbacks: function ( onLoadMaterials ) {
+
 		if ( onLoadMaterials !== undefined && onLoadMaterials !== null ) {
 
 			this.callbacks.onLoadMaterials = onLoadMaterials;
 
 		}
+
 	},
 
 	_createDefaultMaterials: function () {
+
 		let defaultMaterial = new MeshStandardMaterial( { color: 0xDCF1FF } );
 		defaultMaterial.name = 'defaultMaterial';
 
@@ -69,6 +76,7 @@ MaterialHandler.prototype = {
 		runtimeMaterials[ defaultPointMaterial.name ] = defaultPointMaterial;
 
 		this.addMaterials( runtimeMaterials );
+
 	},
 
 	/**
@@ -78,6 +86,7 @@ MaterialHandler.prototype = {
 	 * @returns {Object} Map of {@link Material}
 	 */
 	addPayloadMaterials: function ( materialPayload ) {
+
 		let material, materialName;
 		let materialCloneInstructions = materialPayload.materials.materialCloneInstructions;
 		let newMaterials = {};
@@ -85,9 +94,10 @@ MaterialHandler.prototype = {
 		if ( materialCloneInstructions !== undefined && materialCloneInstructions !== null ) {
 
 			let materialNameOrg = materialCloneInstructions.materialNameOrg;
-			materialNameOrg = (materialNameOrg !== undefined && materialNameOrg !== null) ? materialNameOrg : "";
+			materialNameOrg = ( materialNameOrg !== undefined && materialNameOrg !== null ) ? materialNameOrg : "";
 			let materialOrg = this.materials[ materialNameOrg ];
 			if ( materialOrg ) {
+
 				material = materialOrg.clone();
 
 				materialName = materialCloneInstructions.materialName;
@@ -111,6 +121,7 @@ MaterialHandler.prototype = {
 				console.info( 'Requested material "' + materialNameOrg + '" is not available!' );
 
 			}
+
 		}
 
 		let materials = materialPayload.materials.serializedMaterials;
@@ -137,6 +148,7 @@ MaterialHandler.prototype = {
 		newMaterials = this.addMaterials( materials, newMaterials );
 
 		return newMaterials;
+
 	},
 
 	/**
@@ -146,6 +158,7 @@ MaterialHandler.prototype = {
 	 * @param newMaterials [Object] with named {@link Material}
 	 */
 	addMaterials: function ( materials, newMaterials ) {
+
 		if ( newMaterials === undefined || newMaterials === null ) {
 
 			newMaterials = {};
@@ -165,6 +178,7 @@ MaterialHandler.prototype = {
 
 		}
 		return newMaterials;
+
 	},
 
 	/**
@@ -173,7 +187,9 @@ MaterialHandler.prototype = {
 	 * @returns {Object} Map of {@link Material}
 	 */
 	getMaterials: function () {
+
 		return this.materials;
+
 	},
 
 	/**
@@ -182,7 +198,9 @@ MaterialHandler.prototype = {
 	 * @returns {Material}
 	 */
 	getMaterial: function ( materialName ) {
+
 		return this.materials[ materialName ];
+
 	},
 
 	/**
@@ -191,17 +209,20 @@ MaterialHandler.prototype = {
 	 * @returns {Object} Map of Materials in JSON representation
 	 */
 	getMaterialsJSON: function () {
+
 		let materialsJSON = {};
 		let material;
 		for ( let materialName in this.materials ) {
 
 			material = this.materials[ materialName ];
 			materialsJSON[ materialName ] = material.toJSON();
+
 		}
 
 		return materialsJSON;
+
 	}
 
 };
 
-export { MaterialHandler }
+export { MaterialHandler };

+ 22 - 0
examples/jsm/loaders/obj2/shared/MeshReceiver.d.ts

@@ -0,0 +1,22 @@
+import {
+  Mesh
+} from '../../../../../src/Three';
+
+import { MaterialHandler } from './MaterialHandler'
+
+export class MeshReceiver {
+  constructor(materialHandler: MaterialHandler);
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+  callbacks: {
+    onParseProgress: Function;
+    onMeshAlter: Function;
+  };
+  materialHandler: MaterialHandler;
+
+  buildMeshes(meshPayload: object): Mesh[];
+  setLogging(enabled: boolean, debug: boolean): void;
+
+}

+ 23 - 6
examples/jsm/loaders/obj2/shared/MeshReceiver.js

@@ -17,7 +17,8 @@ import {
  * @param {MaterialHandler} materialHandler
  * @constructor
  */
-const MeshReceiver = function( materialHandler ) {
+const MeshReceiver = function ( materialHandler ) {
+
 	this.logging = {
 		enabled: true,
 		debug: false
@@ -28,6 +29,7 @@ const MeshReceiver = function( materialHandler ) {
 		onMeshAlter: null
 	};
 	this.materialHandler = materialHandler;
+
 };
 
 MeshReceiver.prototype = {
@@ -41,8 +43,10 @@ MeshReceiver.prototype = {
 	 * @param {boolean} debug True or false.
 	 */
 	setLogging:	function ( enabled, debug ) {
+
 		this.logging.enabled = enabled === true;
 		this.logging.debug = debug === true;
+
 	},
 
 	/**
@@ -52,6 +56,7 @@ MeshReceiver.prototype = {
 	 * @private
 	 */
 	_setCallbacks: function ( onParseProgress, onMeshAlter ) {
+
 		if ( onParseProgress !== undefined && onParseProgress !== null ) {
 
 			this.callbacks.onParseProgress = onParseProgress;
@@ -62,6 +67,7 @@ MeshReceiver.prototype = {
 			this.callbacks.onMeshAlter = onMeshAlter;
 
 		}
+
 	},
 
 	/**
@@ -71,6 +77,7 @@ MeshReceiver.prototype = {
 	 * @returns {Mesh[]} mesh Array of {@link Mesh}
 	 */
 	buildMeshes: function ( meshPayload ) {
+
 		let meshName = meshPayload.params.meshName;
 
 		let bufferGeometry = new BufferGeometry();
@@ -80,7 +87,7 @@ MeshReceiver.prototype = {
 			bufferGeometry.setIndex( new BufferAttribute( new Uint32Array( meshPayload.buffers.indices ), 1 ) );
 
 		}
-		let haveVertexColors = meshPayload.buffers.colors  !== null;
+		let haveVertexColors = meshPayload.buffers.colors !== null;
 		if ( haveVertexColors ) {
 
 			bufferGeometry.addAttribute( 'color', new BufferAttribute( new Float32Array( meshPayload.buffers.colors ), 3 ) );
@@ -95,7 +102,7 @@ MeshReceiver.prototype = {
 			bufferGeometry.computeVertexNormals();
 
 		}
-		if ( meshPayload.buffers.uvs  !== null ) {
+		if ( meshPayload.buffers.uvs !== null ) {
 
 			bufferGeometry.addAttribute( 'uv', new BufferAttribute( new Float32Array( meshPayload.buffers.uvs ), 2 ) );
 
@@ -155,6 +162,7 @@ MeshReceiver.prototype = {
 					}
 				}
 			);
+
 		}
 
 		// here LoadedMeshUserOverride is required to be provided by the callback used to alter the results
@@ -208,12 +216,12 @@ MeshReceiver.prototype = {
 
 			}
 			progressMessage += ': Adding mesh(es) (' + meshNames.length + ': ' + meshNames + ') from input mesh: ' + meshName;
-			progressMessage += ' (' + ( meshPayload.progress.numericalValue * 100).toFixed( 2 ) + '%)';
+			progressMessage += ' (' + ( meshPayload.progress.numericalValue * 100 ).toFixed( 2 ) + '%)';
 
 		} else {
 
 			progressMessage += ': Not adding mesh: ' + meshName;
-			progressMessage += ' (' + ( meshPayload.progress.numericalValue * 100).toFixed( 2 ) + '%)';
+			progressMessage += ' (' + ( meshPayload.progress.numericalValue * 100 ).toFixed( 2 ) + '%)';
 
 		}
 		let callbackOnParseProgress = this.callbacks.onParseProgress;
@@ -224,6 +232,7 @@ MeshReceiver.prototype = {
 		}
 
 		return meshes;
+
 	}
 
 };
@@ -235,10 +244,12 @@ MeshReceiver.prototype = {
  * @param {boolean} disregardMesh=false Tell implementation to completely disregard this mesh
  * @param {boolean} disregardMesh=false Tell implementation that mesh(es) have been altered or added
  */
-const LoadedMeshUserOverride = function( disregardMesh, alteredMesh ) {
+const LoadedMeshUserOverride = function ( disregardMesh, alteredMesh ) {
+
 	this.disregardMesh = disregardMesh === true;
 	this.alteredMesh = alteredMesh === true;
 	this.meshes = [];
+
 };
 
 
@@ -252,8 +263,10 @@ LoadedMeshUserOverride.prototype = {
 	 * @param {Mesh} mesh
 	 */
 	addMesh: function ( mesh ) {
+
 		this.meshes.push( mesh );
 		this.alteredMesh = true;
+
 	},
 
 	/**
@@ -262,7 +275,9 @@ LoadedMeshUserOverride.prototype = {
 	 * @returns {boolean}
 	 */
 	isDisregardMesh: function () {
+
 		return this.disregardMesh;
+
 	},
 
 	/**
@@ -271,7 +286,9 @@ LoadedMeshUserOverride.prototype = {
 	 * @returns {boolean}
 	 */
 	providesAlteredMeshes: function () {
+
 		return this.alteredMesh;
+
 	}
 };
 

+ 4 - 0
examples/jsm/loaders/obj2/utils/CodeSerializer.d.ts

@@ -0,0 +1,4 @@
+export namespace CodeSerializer {
+  export function serializeObject(fullName: string, object: object): string;
+  export function serializeClass(fullName: string, object: object, constructorName?: string, basePrototypeName?: string, ignoreFunctions?: string[], includeFunctions?: string[], overrideFunctions?: string[]): string;
+}

+ 8 - 3
examples/jsm/loaders/obj2/utils/CodeSerializer.js

@@ -12,12 +12,13 @@ const CodeSerializer = {
 	 * @returns {string}
 	 */
 	serializeObject: function ( fullName, object ) {
+
 		let objectString = fullName + ' = {\n\n';
 		let part;
 		for ( let name in object ) {
 
 			part = object[ name ];
-			if ( typeof( part ) === 'string' || part instanceof String ) {
+			if ( typeof ( part ) === 'string' || part instanceof String ) {
 
 				part = part.replace( '\n', '\\n' );
 				part = part.replace( '\r', '\\r' );
@@ -42,6 +43,7 @@ const CodeSerializer = {
 		objectString += '}\n\n';
 
 		return objectString;
+
 	},
 
 	/**
@@ -53,6 +55,7 @@ const CodeSerializer = {
 	 * @returns {string}
 	 */
 	serializeClass: function ( fullName, object, constructorName, basePrototypeName, ignoreFunctions, includeFunctions, overrideFunctions ) {
+
 		let valueString, objectPart, constructorString, i, funcOverride;
 		let prototypeFunctions = [];
 		let objectProperties = [];
@@ -90,6 +93,7 @@ const CodeSerializer = {
 						prototypeFunctions.push( '\t' + name + ': ' + valueString + ',\n\n' );
 
 					}
+
 				}
 
 			}
@@ -119,7 +123,7 @@ const CodeSerializer = {
 
 			} else {
 
-				if ( typeof( objectPart ) === 'string' || objectPart instanceof String) {
+				if ( typeof ( objectPart ) === 'string' || objectPart instanceof String ) {
 
 					valueString = '\"' + objectPart.toString() + '\"';
 
@@ -172,7 +176,8 @@ const CodeSerializer = {
 		objectString += '\n\n';
 
 		return objectString;
+
 	},
 };
 
-export { CodeSerializer }
+export { CodeSerializer };

+ 3 - 0
examples/jsm/loaders/obj2/utils/ObjectManipulator.d.ts

@@ -0,0 +1,3 @@
+export namespace ObjectManipulator {
+  export function applyProperties(objToAlter: object, params: object, forceCreation: boolean): void;
+}

+ 5 - 1
examples/jsm/loaders/obj2/utils/ObjectManipulator.js

@@ -12,11 +12,13 @@ const ObjectManipulator = {
 	 * @param {Object} params The parameter object
 	 */
 	applyProperties: function ( objToAlter, params, forceCreation ) {
+
 		// fast-fail
 		if ( objToAlter === undefined || objToAlter === null || params === undefined || params === null ) return;
 
 		var property, funcName, values;
 		for ( property in params ) {
+
 			funcName = 'set' + property.substring( 0, 1 ).toLocaleUpperCase() + property.substring( 1 );
 			values = params[ property ];
 
@@ -29,8 +31,10 @@ const ObjectManipulator = {
 				objToAlter[ property ] = values;
 
 			}
+
 		}
+
 	}
 };
 
-export { ObjectManipulator }
+export { ObjectManipulator };

+ 59 - 0
examples/jsm/loaders/obj2/worker/main/WorkerExecutionSupport.d.ts

@@ -0,0 +1,59 @@
+export class CodeBuilderInstructions {
+  constructor(supportsStandardWorker: boolean, supportsJsmWorker: boolean, preferJsmWorker: boolean);
+  supportsStandardWorker: boolean;
+  supportsJsmWorker: boolean;
+  preferJsmWorker: boolean;
+  startCode: string;
+  codeFragments: string[];
+  importStatements: string[];
+  jsmWorkerFile: string;
+  defaultGeometryType: number;
+
+  isSupportsStandardWorker(): boolean;
+  isSupportsJsmWorker(): boolean;
+  isPreferJsmWorker(): boolean;
+  setJsmWorkerFile(jsmWorkerFile: string): void;
+  addStartCode(startCode: string): void;
+  addCodeFragment(code: string): void;
+  addLibraryImport(libraryPath: string): void;
+  getImportStatements(): string[];
+  getCodeFragments(): string[];
+  getStartCode(): string;
+}
+
+export class WorkerExecutionSupport {
+  constructor();
+
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+
+  worker: {
+    native: null;
+    jsmWorker: boolean;
+    logging: boolean;
+    workerRunner: {
+      name: string;
+      usesMeshDisassembler: boolean;
+      defaultGeometryType: number;
+    };
+    terminateWorkerOnLoad: boolean;
+    forceWorkerDataCopy: boolean;
+    started: boolean;
+    queuedMessage: null;
+    callbacks: {
+      onAssetAvailable: Function;
+      onLoad: Function;
+      terminate: Function;
+    };
+  }
+
+  setLogging(enabled: boolean, debug: boolean): this;
+  setForceWorkerDataCopy(forceWorkerDataCopy: boolean): this;
+  setTerminateWorkerOnLoad(terminateWorkerOnLoad: boolean): this;
+  updateCallbacks(onAssetAvailable: Function, onLoad: Function): void;
+  buildWorker(codeBuilderInstructions: CodeBuilderInstructions): void;
+  isWorkerLoaded(requireJsmWorker: boolean): boolean;
+  executeParallel(payload:object, transferables?: object[]);
+}

+ 78 - 5
examples/jsm/loaders/obj2/worker/main/WorkerExecutionSupport.js

@@ -11,6 +11,7 @@
  * @constructor
  */
 const CodeBuilderInstructions = function ( supportsStandardWorker, supportsJsmWorker, preferJsmWorker ) {
+
 	this.supportsStandardWorker = supportsStandardWorker;
 	this.supportsJsmWorker = supportsJsmWorker;
 	this.preferJsmWorker = preferJsmWorker;
@@ -20,6 +21,7 @@ const CodeBuilderInstructions = function ( supportsStandardWorker, supportsJsmWo
 
 	this.jsmWorkerFile = null;
 	this.defaultGeometryType = 0;
+
 };
 
 CodeBuilderInstructions.prototype = {
@@ -27,15 +29,21 @@ CodeBuilderInstructions.prototype = {
 	constructor: CodeBuilderInstructions,
 
 	isSupportsStandardWorker: function () {
+
 		return this.supportsStandardWorker;
+
 	},
 
 	isSupportsJsmWorker: function () {
+
 		return this.supportsJsmWorker;
+
 	},
 
 	isPreferJsmWorker: function () {
+
 		return this.preferJsmWorker;
+
 	},
 
 	/**
@@ -44,9 +52,13 @@ CodeBuilderInstructions.prototype = {
 	 * @param {String} jsmWorkerFile
 	 */
 	setJsmWorkerFile: function ( jsmWorkerFile ) {
+
 		if ( jsmWorkerFile !== undefined && jsmWorkerFile !== null ) {
+
 			this.jsmWorkerFile = jsmWorkerFile;
+
 		}
+
 	},
 
 	/**
@@ -54,7 +66,9 @@ CodeBuilderInstructions.prototype = {
 	 * @param {String} startCode
 	 */
 	addStartCode: function ( startCode ) {
+
 		this.startCode = startCode;
+
 	},
 
 	/**
@@ -62,7 +76,9 @@ CodeBuilderInstructions.prototype = {
 	 * @param {String} code
 	 */
 	addCodeFragment: function ( code ) {
+
 		this.codeFragments.push( code );
+
 	},
 
 	/**
@@ -70,21 +86,29 @@ CodeBuilderInstructions.prototype = {
 	 * @param {String} libraryPath
 	 */
 	addLibraryImport: function ( libraryPath ) {
+
 		let libraryUrl = new URL( libraryPath, window.location.href ).href;
 		let code = 'importScripts( "' + libraryUrl + '" );';
 		this.importStatements.push(	code );
+
 	},
 
 	getImportStatements: function () {
+
 		return this.importStatements;
+
 	},
 
 	getCodeFragments: function () {
+
 		return this.codeFragments;
+
 	},
 
 	getStartCode: function () {
+
 		return this.startCode;
+
 	}
 
 };
@@ -94,12 +118,14 @@ CodeBuilderInstructions.prototype = {
  * @class
  */
 const WorkerExecutionSupport = function () {
+
 	// check worker support first
 	if ( window.Worker === undefined ) throw "This browser does not support web workers!";
 	if ( window.Blob === undefined ) throw "This browser does not support Blob!";
 	if ( typeof window.URL.createObjectURL !== 'function' ) throw "This browser does not support Object creation from URL!";
 
 	this._reset();
+
 };
 WorkerExecutionSupport.WORKER_SUPPORT_VERSION = '3.0.0-beta2';
 console.info( 'Using WorkerSupport version: ' + WorkerExecutionSupport.WORKER_SUPPORT_VERSION );
@@ -110,14 +136,17 @@ WorkerExecutionSupport.prototype = {
 	constructor: WorkerExecutionSupport,
 
 	_reset: function () {
+
 		this.logging = {
 			enabled: true,
 			debug: false
 		};
 
 		let scope = this;
-		let scopeTerminate = function (  ) {
+		let scopeTerminate = function ( ) {
+
 			scope._terminate();
+
 		};
 		this.worker = {
 			native: null,
@@ -138,6 +167,7 @@ WorkerExecutionSupport.prototype = {
 				terminate: scopeTerminate
 			}
 		};
+
 	},
 
 	/**
@@ -147,10 +177,12 @@ WorkerExecutionSupport.prototype = {
 	 * @param {boolean} debug True or false.
 	 */
 	setLogging: function ( enabled, debug ) {
+
 		this.logging.enabled = enabled === true;
 		this.logging.debug = debug === true;
 		this.worker.logging = enabled === true;
 		return this;
+
 	},
 
 	/**
@@ -159,8 +191,10 @@ WorkerExecutionSupport.prototype = {
 	 * @param {boolean} forceWorkerDataCopy True or false.
 	 */
 	setForceWorkerDataCopy: function ( forceWorkerDataCopy ) {
+
 		this.worker.forceWorkerDataCopy = forceWorkerDataCopy === true;
 		return this;
+
 	},
 
 	/**
@@ -169,6 +203,7 @@ WorkerExecutionSupport.prototype = {
 	 * @param {boolean} terminateWorkerOnLoad True or false.
 	 */
 	setTerminateWorkerOnLoad: function ( terminateWorkerOnLoad ) {
+
 		this.worker.terminateWorkerOnLoad = terminateWorkerOnLoad === true;
 		if ( this.worker.terminateWorkerOnLoad && this.isWorkerLoaded( this.worker.jsmWorker ) &&
 				this.worker.queuedMessage === null && this.worker.started ) {
@@ -182,6 +217,7 @@ WorkerExecutionSupport.prototype = {
 
 		}
 		return this;
+
 	},
 
 	/**
@@ -191,6 +227,7 @@ WorkerExecutionSupport.prototype = {
 	 * @param {Function} [onLoad] The function that is called when parsing is complete.
 	 */
 	updateCallbacks: function ( onAssetAvailable, onLoad ) {
+
 		if ( onAssetAvailable !== undefined && onAssetAvailable !== null ) {
 
 			this.worker.callbacks.onAssetAvailable = onAssetAvailable;
@@ -202,14 +239,17 @@ WorkerExecutionSupport.prototype = {
 
 		}
 		this._verifyCallbacks();
+
 	},
 
 	_verifyCallbacks: function () {
+
 		if ( this.worker.callbacks.onAssetAvailable === undefined || this.worker.callbacks.onAssetAvailable === null ) {
 
 			throw 'Unable to run as no "onAssetAvailable" callback is set.';
 
 		}
+
 	},
 
 	/**
@@ -219,10 +259,13 @@ WorkerExecutionSupport.prototype = {
  	 * @param {CodeBuilderInstructions} codeBuilderInstructions
 	 */
 	buildWorker: function ( codeBuilderInstructions ) {
+
 		let jsmSuccess = false;
 
 		if ( codeBuilderInstructions.isSupportsJsmWorker() && codeBuilderInstructions.isPreferJsmWorker() ) {
+
 			jsmSuccess = this._buildWorkerJsm( codeBuilderInstructions );
+
 		}
 
 		if ( ! jsmSuccess && codeBuilderInstructions.isSupportsStandardWorker() ) {
@@ -230,6 +273,7 @@ WorkerExecutionSupport.prototype = {
 			this._buildWorkerStandard( codeBuilderInstructions );
 
 		}
+
 	},
 
 	/**
@@ -239,6 +283,7 @@ WorkerExecutionSupport.prototype = {
 	 * @private
 	 */
 	_buildWorkerJsm: function ( codeBuilderInstructions ) {
+
 		let jsmSuccess = true;
 		let timeLabel = 'buildWorkerJsm';
 		let workerAvailable = this._buildWorkerCheckPreconditions( true, timeLabel );
@@ -250,8 +295,7 @@ WorkerExecutionSupport.prototype = {
 				let worker = new Worker( workerFileUrl, { type: "module" } );
 				this._configureWorkerCommunication( worker, true, codeBuilderInstructions.defaultGeometryType, timeLabel );
 
-			}
-			catch ( e ) {
+			} catch ( e ) {
 
 				jsmSuccess = false;
 				// Chrome throws this exception, but Firefox currently does not complain, but can't execute the worker afterwards
@@ -260,11 +304,13 @@ WorkerExecutionSupport.prototype = {
 					console.error( "Modules are not supported in workers." );
 
 				}
+
 			}
 
 		}
 
 		return jsmSuccess;
+
 	},
 
 	/**
@@ -279,17 +325,22 @@ WorkerExecutionSupport.prototype = {
 	 * @private
 	 */
 	_buildWorkerStandard: function ( codeBuilderInstructions ) {
+
 		let timeLabel = 'buildWorkerStandard';
 		let workerAvailable = this._buildWorkerCheckPreconditions( false, timeLabel );
 		if ( ! workerAvailable ) {
 
 			let concatenateCode = '';
 			codeBuilderInstructions.getImportStatements().forEach( function ( element ) {
+
 				concatenateCode += element + '\n';
+
 			} );
 			concatenateCode += '\n';
 			codeBuilderInstructions.getCodeFragments().forEach( function ( element ) {
+
 				concatenateCode += element + '\n';
+
 			} );
 			concatenateCode += '\n';
 			concatenateCode += codeBuilderInstructions.getStartCode();
@@ -300,15 +351,18 @@ WorkerExecutionSupport.prototype = {
 			this._configureWorkerCommunication( worker, false, codeBuilderInstructions.defaultGeometryType, timeLabel );
 
 		}
+
 	},
 
 	_buildWorkerCheckPreconditions: function ( requireJsmWorker, timeLabel ) {
+
 		let workerAvailable = false;
 		if ( this.isWorkerLoaded( requireJsmWorker ) ) {
 
 			workerAvailable = true;
 
 		} else {
+
 			if ( this.logging.enabled ) {
 
 				console.info( 'WorkerExecutionSupport: Building ' + ( requireJsmWorker ? 'jsm' : 'standard' ) + ' worker code...' );
@@ -318,20 +372,25 @@ WorkerExecutionSupport.prototype = {
 
 		}
 		return workerAvailable;
+
 	},
 
 	_configureWorkerCommunication: function ( worker, haveJsmWorker, defaultGeometryType, timeLabel ) {
+
 		this.worker.native = worker;
 		this.worker.jsmWorker = haveJsmWorker;
 
 		let scope = this;
 		let scopedReceiveWorkerMessage = function ( event ) {
+
 			scope._receiveWorkerMessage( event );
+
 		};
 		this.worker.native.onmessage = scopedReceiveWorkerMessage;
 		if ( defaultGeometryType !== undefined && defaultGeometryType !== null ) {
 
 			this.worker.workerRunner.defaultGeometryType = defaultGeometryType;
+
 		}
 
 		if ( this.logging.enabled ) {
@@ -339,6 +398,7 @@ WorkerExecutionSupport.prototype = {
 			console.timeEnd( timeLabel );
 
 		}
+
 	},
 
 	/**
@@ -347,18 +407,22 @@ WorkerExecutionSupport.prototype = {
 	 * @return {boolean|*}
 	 */
 	isWorkerLoaded: function ( requireJsmWorker ) {
+
 		return this.worker.native !== null &&
 			( ( requireJsmWorker && this.worker.jsmWorker ) || ( ! requireJsmWorker && ! this.worker.jsmWorker ) );
+
 	},
 
 	/**
 	 * Executed in worker scope
 	 */
 	_receiveWorkerMessage: function ( event ) {
+
 		let payload = event.data;
 		let workerRunnerName = this.worker.workerRunner.name;
 
 		switch ( payload.cmd ) {
+
 			case 'assetAvailable':
 				this.worker.callbacks.onAssetAvailable( payload );
 				break;
@@ -401,6 +465,7 @@ WorkerExecutionSupport.prototype = {
 				break;
 
 		}
+
 	},
 
 	/**
@@ -408,16 +473,19 @@ WorkerExecutionSupport.prototype = {
 	 *
 	 * @param {Object} payload Raw mesh description (buffers, params, materials) used to build one to many meshes.
 	 */
-	executeParallel: function( payload, transferables ) {
+	executeParallel: function ( payload, transferables ) {
+
 		payload.cmd = 'parse';
 		payload.usesMeshDisassembler = this.worker.workerRunner.usesMeshDisassembler;
 		payload.defaultGeometryType = this.worker.workerRunner.defaultGeometryType;
 		if ( ! this._verifyWorkerIsAvailable( payload, transferables ) ) return;
 
 		this._postMessage();
+
 	},
 
 	_verifyWorkerIsAvailable: function ( payload, transferables ) {
+
 		this._verifyCallbacks();
 		let ready = true;
 		if ( this.worker.queuedMessage !== null ) {
@@ -435,9 +503,11 @@ WorkerExecutionSupport.prototype = {
 
 		}
 		return ready;
+
 	},
 
 	_postMessage: function () {
+
 		if ( this.worker.queuedMessage !== null ) {
 
 			if ( this.worker.queuedMessage.payload.data.input instanceof ArrayBuffer ) {
@@ -466,15 +536,18 @@ WorkerExecutionSupport.prototype = {
 			}
 
 		}
+
 	},
 
 	_terminate: function () {
+
 		this.worker.native.terminate();
 		this._reset();
+
 	}
 };
 
 export {
 	CodeBuilderInstructions,
 	WorkerExecutionSupport
-}
+};

+ 81 - 0
examples/jsm/loaders/obj2/worker/parallel/OBJLoader2Parser.d.ts

@@ -0,0 +1,81 @@
+export class OBJLoader2Parser {
+  constructor();
+  callbacks: {
+    onProgress: Function;
+    onAssetAvailable: Function;
+    onError: Function;
+  };
+  contentRef: Uint8Array;
+  legacyMode: boolean;
+  materials: object;
+  materialPerSmoothingGroup: boolean;
+  useOAsMesh: boolean;
+  useIndices: boolean;
+  disregardNormals: boolean;
+
+  vertices: number[];
+  colors: number[];
+  normals: number[];
+  uvs: number[];
+
+  rawMesh: {
+    objectName: string;
+    groupName: string;
+    activeMtlName: string;
+    mtllibName: string;
+    faceType: number;
+    subGroups: object[];
+    subGroupInUse: object;
+    smoothingGroup: {
+      splitMaterials: boolean;
+      normalized: boolean;
+      real: boolean;
+    };
+    counts: {
+      doubleIndicesCount: number;
+      faceCount: number;
+      mtlCount: number;
+      smoothingGroupCount: number;
+    }
+  };
+
+  inputObjectCount: number;
+  outputObjectCount: number;
+  globalCounts: {
+    vertices: number;
+    faces: number;
+    doubleIndicesCount: number;
+    lineByte: number;
+    currentByte: number;
+    totalBytes: number;
+  };
+
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+
+  resetRawMesh(): void;
+  setMaterialPerSmoothingGroup(materialPerSmoothingGroup: boolean): void;
+  setUseOAsMesh(useOAsMesh: boolean): void;
+  setUseIndices(useIndices: boolean): void;
+  setDisregardNormals(disregardNormals: boolean): void;
+  setMaterials(materials: object): void;
+  setCallbackOnAssetAvailable(onAssetAvailable: Function): void;
+  setCallbackOnProgress(onProgress: Function): void;
+  setCallbackOnError(onError: Function): void;
+  setLogging(enabled: boolean, debug: boolean): void;
+  configure(): void;
+  parse(arrayBuffer: Uint8Array): void;
+  parseText(text: string): void;
+  processLine(buffer: string[], bufferPointer: number, slashesCount: number): void;
+  pushSmoothingGroup(smoothingGroup: object): void;
+  checkFaceType(faceType: number): void;
+  checkSubGroup(): void;
+  buildFace(faceIndexV: string, faceIndexU: string, faceIndexN: string): void;
+  createRawMeshReport(inputObjectCount: number): void;
+  finalizeRawMesh(): object;
+  processCompletedMesh(): boolean;
+  buildMesh(result: object): void;
+  finalizeParsing(): void;
+}

+ 94 - 20
examples/jsm/loaders/obj2/worker/parallel/OBJLoader2Parser.js

@@ -6,7 +6,8 @@
  * Parse OBJ data either from ArrayBuffer or string
  * @class
  */
-const OBJLoader2Parser = function() {
+const OBJLoader2Parser = function () {
+
 	this.callbacks = {
 		onProgress: null,
 		onAssetAvailable: null,
@@ -64,6 +65,7 @@ const OBJLoader2Parser = function() {
 		enabled: true,
 		debug: false
 	};
+
 };
 
 OBJLoader2Parser.prototype = {
@@ -71,6 +73,7 @@ OBJLoader2Parser.prototype = {
 	constructor: OBJLoader2Parser,
 
 	resetRawMesh: function () {
+
 		// faces are stored according combined index of group, material and smoothingGroup (0 or not)
 		this.rawMesh.subGroups = [];
 		this.rawMesh.subGroupInUse = null;
@@ -84,66 +87,88 @@ OBJLoader2Parser.prototype = {
 		this.rawMesh.counts.faceCount = 0;
 		this.rawMesh.counts.mtlCount = 0;
 		this.rawMesh.counts.smoothingGroupCount = 0;
+
 	},
 
 	setMaterialPerSmoothingGroup: function ( materialPerSmoothingGroup ) {
+
 		this.materialPerSmoothingGroup = materialPerSmoothingGroup;
+
 	},
 
 	setUseOAsMesh: function ( useOAsMesh ) {
+
 		this.useOAsMesh = useOAsMesh;
+
 	},
 
 	setUseIndices: function ( useIndices ) {
+
 		this.useIndices = useIndices;
+
 	},
 
 	setDisregardNormals: function ( disregardNormals ) {
+
 		this.disregardNormals = disregardNormals;
+
 	},
 
 	setMaterials: function ( materials ) {
+
 		if ( materials === undefined || materials === null ) return;
 
 		for ( let materialName in materials ) {
+
 			if ( materials.hasOwnProperty( materialName ) ) {
 
 				this.materials[ materialName ] = materials[ materialName ];
 
 			}
+
 		}
+
 	},
 
 	setCallbackOnAssetAvailable: function ( onAssetAvailable ) {
+
 		if ( onAssetAvailable !== null && onAssetAvailable !== undefined ) {
 
 			this.callbacks.onAssetAvailable = onAssetAvailable;
 
 		}
+
 	},
 
 	setCallbackOnProgress: function ( onProgress ) {
+
 		if ( onProgress !== null && onProgress !== undefined ) {
 
 			this.callbacks.onProgress = onProgress;
 
 		}
+
 	},
 
 	setCallbackOnError: function ( onError ) {
+
 		if ( onError !== null && onError !== undefined ) {
 
 			this.callbacks.onError = onError;
 
 		}
+
 	},
 
 	setLogging: function ( enabled, debug ) {
+
 		this.logging.enabled = enabled === true;
 		this.logging.debug = debug === true;
+
 	},
 
 	configure: function () {
+
 		if ( this.callbacks.onAssetAvailable === null ) {
 
 			let errorMessage = 'Unable to run as no callback for building meshes is set.';
@@ -154,6 +179,7 @@ OBJLoader2Parser.prototype = {
 			} else {
 
 				throw errorMessage;
+
 			}
 
 		}
@@ -161,7 +187,7 @@ OBJLoader2Parser.prototype = {
 		if ( this.logging.enabled ) {
 
 			let matKeys = Object.keys( this.materials );
-			let matNames = (matKeys.length > 0) ? '\n\tmaterialNames:\n\t\t- ' + matKeys.join( '\n\t\t- ' ) : '\n\tmaterialNames: None';
+			let matNames = ( matKeys.length > 0 ) ? '\n\tmaterialNames:\n\t\t- ' + matKeys.join( '\n\t\t- ' ) : '\n\tmaterialNames: None';
 			let printedConfig = 'OBJLoader.Parser configuration:'
 				+ matNames
 				+ '\n\tmaterialPerSmoothingGroup: ' + this.materialPerSmoothingGroup
@@ -169,17 +195,24 @@ OBJLoader2Parser.prototype = {
 				+ '\n\tuseIndices: ' + this.useIndices
 				+ '\n\tdisregardNormals: ' + this.disregardNormals;
 			if ( this.callbacks.onProgress !== null ) {
+
 				printedConfig += '\n\tcallbacks.onProgress: ' + this.callbacks.onProgress.name;
+
 			}
 			if ( this.callbacks.onAssetAvailable !== null ) {
+
 				printedConfig += '\n\tcallbacks.onAssetAvailable: ' + this.callbacks.onAssetAvailable.name;
+
 			}
 			if ( this.callbacks.onError !== null ) {
+
 				printedConfig += '\n\tcallbacks.onError: ' + this.callbacks.onError.name;
+
 			}
 			console.info( printedConfig );
 
 		}
+
 	},
 
 	/**
@@ -188,6 +221,7 @@ OBJLoader2Parser.prototype = {
 	 * @param {Uint8Array} arrayBuffer OBJ data as Uint8Array
 	 */
 	parse: function ( arrayBuffer ) {
+
 		if ( this.logging.enabled ) console.time( 'OBJLoader.Parser.parse' );
 		this.configure();
 
@@ -201,6 +235,7 @@ OBJLoader2Parser.prototype = {
 
 			code = arrayBufferView[ i ];
 			switch ( code ) {
+
 				// space
 				case 32:
 					if ( word.length > 0 ) buffer[ bufferPointer ++ ] = word;
@@ -231,10 +266,13 @@ OBJLoader2Parser.prototype = {
 				default:
 					word += String.fromCharCode( code );
 					break;
+
 			}
+
 		}
 		this.finalizeParsing();
 		if ( this.logging.enabled ) console.timeEnd( 'OBJLoader.Parser.parse' );
+
 	},
 
 	/**
@@ -243,6 +281,7 @@ OBJLoader2Parser.prototype = {
 	 * @param {string} text OBJ data as string
 	 */
 	parseText: function ( text ) {
+
 		if ( this.logging.enabled ) console.time( 'OBJLoader.Parser.parseText' );
 		this.configure();
 		this.legacyMode = true;
@@ -255,6 +294,7 @@ OBJLoader2Parser.prototype = {
 
 			char = text[ i ];
 			switch ( char ) {
+
 				case ' ':
 					if ( word.length > 0 ) buffer[ bufferPointer ++ ] = word;
 					word = '';
@@ -281,16 +321,21 @@ OBJLoader2Parser.prototype = {
 
 				default:
 					word += char;
+
 			}
+
 		}
 		this.finalizeParsing();
 		if ( this.logging.enabled ) console.timeEnd( 'OBJLoader.Parser.parseText' );
+
 	},
 
 	processLine: function ( buffer, bufferPointer, slashesCount ) {
+
 		if ( bufferPointer < 1 ) return;
 
 		let reconstructString = function ( content, legacyMode, start, stop ) {
+
 			let line = '';
 			if ( stop > start ) {
 
@@ -309,11 +354,13 @@ OBJLoader2Parser.prototype = {
 
 			}
 			return line;
+
 		};
 
 		let bufferLength, length, i, lineDesignation;
-		lineDesignation = buffer [ 0 ];
+		lineDesignation = buffer[ 0 ];
 		switch ( lineDesignation ) {
+
 			case 'v':
 				this.vertices.push( parseFloat( buffer[ 1 ] ) );
 				this.vertices.push( parseFloat( buffer[ 2 ] ) );
@@ -354,6 +401,7 @@ OBJLoader2Parser.prototype = {
 					}
 
 					// "f vertex/uv ..."
+
 				} else if ( bufferLength === slashesCount * 2 ) {
 
 					this.checkFaceType( 1 );
@@ -366,6 +414,7 @@ OBJLoader2Parser.prototype = {
 					}
 
 					// "f vertex/uv/normal ..."
+
 				} else if ( bufferLength * 2 === slashesCount * 3 ) {
 
 					this.checkFaceType( 2 );
@@ -378,6 +427,7 @@ OBJLoader2Parser.prototype = {
 					}
 
 					// "f vertex//normal ..."
+
 				} else {
 
 					this.checkFaceType( 3 );
@@ -402,7 +452,7 @@ OBJLoader2Parser.prototype = {
 
 				} else {
 
-					this.checkFaceType( (lineDesignation === 'l') ? 5 : 6 );
+					this.checkFaceType( ( lineDesignation === 'l' ) ? 5 : 6 );
 					for ( i = 1, length = bufferLength + 1; i < length; i ++ ) this.buildFace( buffer[ i ] );
 
 				}
@@ -441,17 +491,22 @@ OBJLoader2Parser.prototype = {
 
 			default:
 				break;
+
 		}
+
 	},
 
 	pushSmoothingGroup: function ( smoothingGroup ) {
+
 		let smoothingGroupInt = parseInt( smoothingGroup );
 		if ( isNaN( smoothingGroupInt ) ) {
+
 			smoothingGroupInt = smoothingGroup === "off" ? 0 : 1;
+
 		}
 
 		let smoothCheck = this.rawMesh.smoothingGroup.normalized;
-		this.rawMesh.smoothingGroup.normalized = this.rawMesh.smoothingGroup.splitMaterials ? smoothingGroupInt : (smoothingGroupInt === 0) ? 0 : 1;
+		this.rawMesh.smoothingGroup.normalized = this.rawMesh.smoothingGroup.splitMaterials ? smoothingGroupInt : ( smoothingGroupInt === 0 ) ? 0 : 1;
 		this.rawMesh.smoothingGroup.real = smoothingGroupInt;
 
 		if ( smoothCheck !== smoothingGroupInt ) {
@@ -460,6 +515,7 @@ OBJLoader2Parser.prototype = {
 			this.checkSubGroup();
 
 		}
+
 	},
 
 	/**
@@ -473,6 +529,7 @@ OBJLoader2Parser.prototype = {
 	 * faceType = 6: "p vertex ..."
 	 */
 	checkFaceType: function ( faceType ) {
+
 		if ( this.rawMesh.faceType !== faceType ) {
 
 			this.processCompletedMesh();
@@ -480,9 +537,11 @@ OBJLoader2Parser.prototype = {
 			this.checkSubGroup();
 
 		}
+
 	},
 
 	checkSubGroup: function () {
+
 		let index = this.rawMesh.activeMtlName + '|' + this.rawMesh.smoothingGroup.normalized;
 		this.rawMesh.subGroupInUse = this.rawMesh.subGroups[ index ];
 
@@ -505,15 +564,17 @@ OBJLoader2Parser.prototype = {
 			this.rawMesh.subGroups[ index ] = this.rawMesh.subGroupInUse;
 
 		}
+
 	},
 
 	buildFace: function ( faceIndexV, faceIndexU, faceIndexN ) {
+
 		let subGroupInUse = this.rawMesh.subGroupInUse;
 		let scope = this;
 		let updateSubGroupInUse = function () {
 
 			let faceIndexVi = parseInt( faceIndexV );
-			let indexPointerV = 3 * (faceIndexVi > 0 ? faceIndexVi - 1 : faceIndexVi + scope.vertices.length / 3);
+			let indexPointerV = 3 * ( faceIndexVi > 0 ? faceIndexVi - 1 : faceIndexVi + scope.vertices.length / 3 );
 			let indexPointerC = scope.colors.length > 0 ? indexPointerV : null;
 
 			let vertices = subGroupInUse.vertices;
@@ -532,7 +593,7 @@ OBJLoader2Parser.prototype = {
 			if ( faceIndexU ) {
 
 				let faceIndexUi = parseInt( faceIndexU );
-				let indexPointerU = 2 * (faceIndexUi > 0 ? faceIndexUi - 1 : faceIndexUi + scope.uvs.length / 2);
+				let indexPointerU = 2 * ( faceIndexUi > 0 ? faceIndexUi - 1 : faceIndexUi + scope.uvs.length / 2 );
 				let uvs = subGroupInUse.uvs;
 				uvs.push( scope.uvs[ indexPointerU ++ ] );
 				uvs.push( scope.uvs[ indexPointerU ] );
@@ -541,13 +602,14 @@ OBJLoader2Parser.prototype = {
 			if ( faceIndexN && ! scope.disregardNormals ) {
 
 				let faceIndexNi = parseInt( faceIndexN );
-				let indexPointerN = 3 * (faceIndexNi > 0 ? faceIndexNi - 1 : faceIndexNi + scope.normals.length / 3);
+				let indexPointerN = 3 * ( faceIndexNi > 0 ? faceIndexNi - 1 : faceIndexNi + scope.normals.length / 3 );
 				let normals = subGroupInUse.normals;
 				normals.push( scope.normals[ indexPointerN ++ ] );
 				normals.push( scope.normals[ indexPointerN ++ ] );
 				normals.push( scope.normals[ indexPointerN ] );
 
 			}
+
 		};
 
 		if ( this.useIndices ) {
@@ -560,11 +622,11 @@ OBJLoader2Parser.prototype = {
 				indicesPointer = this.rawMesh.subGroupInUse.vertices.length / 3;
 				updateSubGroupInUse();
 				subGroupInUse.indexMappings[ mappingName ] = indicesPointer;
-				subGroupInUse.indexMappingsCount++;
+				subGroupInUse.indexMappingsCount ++;
 
 			} else {
 
-				this.rawMesh.counts.doubleIndicesCount++;
+				this.rawMesh.counts.doubleIndicesCount ++;
 
 			}
 			subGroupInUse.indices.push( indicesPointer );
@@ -575,9 +637,11 @@ OBJLoader2Parser.prototype = {
 
 		}
 		this.rawMesh.counts.faceCount ++;
+
 	},
 
 	createRawMeshReport: function ( inputObjectCount ) {
+
 		return 'Input Object number: ' + inputObjectCount +
 			'\n\tObject name: ' + this.rawMesh.objectName +
 			'\n\tGroup name: ' + this.rawMesh.groupName +
@@ -588,12 +652,14 @@ OBJLoader2Parser.prototype = {
 			'\n\tSmoothingGroup count: ' + this.rawMesh.counts.smoothingGroupCount +
 			'\n\tMaterial count: ' + this.rawMesh.counts.mtlCount +
 			'\n\tReal MeshOutputGroup count: ' + this.rawMesh.subGroups.length;
+
 	},
 
 	/**
 	 * Clear any empty subGroup and calculate absolute vertex, normal and uv counts
 	 */
 	finalizeRawMesh: function () {
+
 		let meshOutputGroupTemp = [];
 		let meshOutputGroup;
 		let absoluteVertexCount = 0;
@@ -611,7 +677,7 @@ OBJLoader2Parser.prototype = {
 				indices = meshOutputGroup.indices;
 				if ( indices.length > 0 && absoluteIndexMappingsCount > 0 ) {
 
-					for ( let i = 0; i < indices.length; i++ ) {
+					for ( let i = 0; i < indices.length; i ++ ) {
 
 						indices[ i ] = indices[ i ] + absoluteIndexMappingsCount;
 
@@ -627,6 +693,7 @@ OBJLoader2Parser.prototype = {
 				absoluteNormalCount += meshOutputGroup.normals.length;
 
 			}
+
 		}
 
 		// do not continue if no result
@@ -647,9 +714,11 @@ OBJLoader2Parser.prototype = {
 
 		}
 		return result;
+
 	},
 
 	processCompletedMesh: function () {
+
 		let result = this.finalizeRawMesh();
 		let haveMesh = result !== null;
 		if ( haveMesh ) {
@@ -671,13 +740,14 @@ OBJLoader2Parser.prototype = {
 			if ( this.callbacks.onProgress !== null ) {
 
 				this.callbacks.onProgress( 'Completed [o: ' + this.rawMesh.objectName + ' g:' + this.rawMesh.groupName + '' +
-					'] Total progress: ' + (progressBytesPercent * 100).toFixed( 2 ) + '%', progressBytesPercent );
+					'] Total progress: ' + ( progressBytesPercent * 100 ).toFixed( 2 ) + '%', progressBytesPercent );
 
 			}
 			this.resetRawMesh();
 
 		}
 		return haveMesh;
+
 	},
 
 	/**
@@ -687,22 +757,23 @@ OBJLoader2Parser.prototype = {
 	 * @param result
 	 */
 	buildMesh: function ( result ) {
+
 		let meshOutputGroups = result.subGroups;
 
 		let vertexFA = new Float32Array( result.absoluteVertexCount );
 		this.globalCounts.vertices += result.absoluteVertexCount / 3;
 		this.globalCounts.faces += result.faceCount;
 		this.globalCounts.doubleIndicesCount += result.doubleIndicesCount;
-		let indexUA = (result.absoluteIndexCount > 0) ? new Uint32Array( result.absoluteIndexCount ) : null;
-		let colorFA = (result.absoluteColorCount > 0) ? new Float32Array( result.absoluteColorCount ) : null;
-		let normalFA = (result.absoluteNormalCount > 0) ? new Float32Array( result.absoluteNormalCount ) : null;
-		let uvFA = (result.absoluteUvCount > 0) ? new Float32Array( result.absoluteUvCount ) : null;
+		let indexUA = ( result.absoluteIndexCount > 0 ) ? new Uint32Array( result.absoluteIndexCount ) : null;
+		let colorFA = ( result.absoluteColorCount > 0 ) ? new Float32Array( result.absoluteColorCount ) : null;
+		let normalFA = ( result.absoluteNormalCount > 0 ) ? new Float32Array( result.absoluteNormalCount ) : null;
+		let uvFA = ( result.absoluteUvCount > 0 ) ? new Float32Array( result.absoluteUvCount ) : null;
 		let haveVertexColors = colorFA !== null;
 
 		let meshOutputGroup;
 		let materialNames = [];
 
-		let createMultiMaterial = (meshOutputGroups.length > 1);
+		let createMultiMaterial = ( meshOutputGroups.length > 1 );
 		let materialIndex = 0;
 		let materialIndexMapping = [];
 		let selectedMaterialIndex;
@@ -727,7 +798,7 @@ OBJLoader2Parser.prototype = {
 			materialNameOrg = meshOutputGroup.materialName;
 			if ( this.rawMesh.faceType < 4 ) {
 
-				materialName = materialNameOrg + (haveVertexColors ? '_vertexColor' : '') + (meshOutputGroup.smoothingGroup === 0 ? '_flat' : '');
+				materialName = materialNameOrg + ( haveVertexColors ? '_vertexColor' : '' ) + ( meshOutputGroup.smoothingGroup === 0 ? '_flat' : '' );
 
 
 			} else {
@@ -883,17 +954,19 @@ OBJLoader2Parser.prototype = {
 					uvs: uvFA
 				},
 				// 0: mesh, 1: line, 2: point
-				geometryType: this.rawMesh.faceType < 4 ? 0 : (this.rawMesh.faceType === 6) ? 2 : 1
+				geometryType: this.rawMesh.faceType < 4 ? 0 : ( this.rawMesh.faceType === 6 ) ? 2 : 1
 			},
 			[ vertexFA.buffer ],
-			indexUA !== null ?  [ indexUA.buffer ] : null,
+			indexUA !== null ? [ indexUA.buffer ] : null,
 			colorFA !== null ? [ colorFA.buffer ] : null,
 			normalFA !== null ? [ normalFA.buffer ] : null,
 			uvFA !== null ? [ uvFA.buffer ] : null
 		);
+
 	},
 
 	finalizeParsing: function () {
+
 		if ( this.logging.enabled ) console.info( 'Global output object count: ' + this.outputObjectCount );
 		if ( this.processCompletedMesh() && this.logging.enabled ) {
 
@@ -904,6 +977,7 @@ OBJLoader2Parser.prototype = {
 			console.info( parserFinalReport );
 
 		}
+
 	}
 };
 

+ 24 - 0
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.d.ts

@@ -0,0 +1,24 @@
+import { OBJLoader2Parser } from './OBJLoader2Parser';
+
+export class DefaultWorkerPayloadHandler {
+  constructor(parser: OBJLoader2Parser);
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+  parser: OBJLoader2Parser;
+
+  handlePayload(payload: object): void;
+}
+
+export class WorkerRunner {
+  constructor(payloadHandler: object);
+  logging: {
+    enabled: boolean;
+    debug: boolean;
+  };
+  resourceDescriptors: OBJLoader2Parser;
+  payloadHandler: object;
+
+  processMessage(payload: object): void;
+}

+ 19 - 4
examples/jsm/loaders/obj2/worker/parallel/WorkerRunner.js

@@ -5,11 +5,13 @@
 import { ObjectManipulator } from "../../utils/ObjectManipulator.js";
 
 const DefaultWorkerPayloadHandler = function ( parser ) {
+
 	this.parser = parser;
 	this.logging = {
 		enabled: false,
 		debug: false
 	};
+
 };
 
 DefaultWorkerPayloadHandler.prototype = {
@@ -17,19 +19,26 @@ DefaultWorkerPayloadHandler.prototype = {
 	constructor: DefaultWorkerPayloadHandler,
 
 	handlePayload: function ( payload ) {
+
 		if ( payload.logging ) {
+
 			this.logging.enabled = payload.logging.enabled === true;
 			this.logging.debug = payload.logging.debug === true;
+
 		}
 		if ( payload.cmd === 'parse' ) {
 
 			let scope = this;
 			let callbacks = {
 				callbackOnAssetAvailable: function ( payload ) {
+
 					self.postMessage( payload );
+
 				},
 				callbackOnProgress: function ( text ) {
+
 					if ( scope.logging.enabled && scope.logging.debug ) console.debug( 'WorkerRunner: progress: ' + text );
+
 				}
 			};
 
@@ -44,7 +53,7 @@ DefaultWorkerPayloadHandler.prototype = {
 			ObjectManipulator.applyProperties( parser, callbacks );
 
 			let arraybuffer;
-			if ( payload.params && payload.params.index !== undefined && payload.params.index !== null) {
+			if ( payload.params && payload.params.index !== undefined && payload.params.index !== null ) {
 
 				arraybuffer = this.resourceDescriptors[ payload.params.index ].content;
 
@@ -62,7 +71,7 @@ DefaultWorkerPayloadHandler.prototype = {
 
 			} else {
 
-				parser[ parseFunctionName ] ( arraybuffer, payload.data.options );
+				parser[ parseFunctionName ]( arraybuffer, payload.data.options );
 
 			}
 			if ( this.logging.enabled ) console.log( 'WorkerRunner: Run complete!' );
@@ -87,14 +96,18 @@ DefaultWorkerPayloadHandler.prototype = {
  * @constructor
  */
 const WorkerRunner = function ( payloadHandler ) {
+
 	this.resourceDescriptors = [];
 	this.payloadHandler = payloadHandler;
 
 	let scope = this;
-	let scopedRunner = function( event ) {
+	let scopedRunner = function ( event ) {
+
 		scope.processMessage( event.data );
+
 	};
 	self.addEventListener( 'message', scopedRunner, false );
+
 };
 
 WorkerRunner.prototype = {
@@ -107,6 +120,7 @@ WorkerRunner.prototype = {
 	 * @param {Object} payload Raw mesh description (buffers, params, materials) used to build one to many meshes.
 	 */
 	processMessage: function ( payload ) {
+
 		if ( payload.data.resourceDescriptors && this.resourceDescriptors.length === 0 ) {
 
 			for ( let name in payload.data.resourceDescriptors ) {
@@ -118,6 +132,7 @@ WorkerRunner.prototype = {
 		}
 
 		this.payloadHandler.handlePayload( payload );
+
 	}
 
 };
@@ -125,4 +140,4 @@ WorkerRunner.prototype = {
 export {
 	WorkerRunner,
 	DefaultWorkerPayloadHandler
-}
+};

+ 2 - 0
examples/jsm/nodes/accessors/CameraNode.js

@@ -202,6 +202,8 @@ CameraNode.prototype.copy = function ( source ) {
 
 	}
 
+	return this;
+
 };
 
 CameraNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/ColorsNode.js

@@ -34,6 +34,8 @@ ColorsNode.prototype.copy = function ( source ) {
 
 	this.index = source.index;
 
+	return this;
+
 };
 
 ColorsNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/LightNode.js

@@ -40,6 +40,8 @@ LightNode.prototype.copy = function ( source ) {
 
 	this.scope = source.scope;
 
+	return this;
+
 };
 
 LightNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/NormalNode.js

@@ -84,6 +84,8 @@ NormalNode.prototype.copy = function ( source ) {
 
 	this.scope = source.scope;
 
+	return this;
+
 };
 
 NormalNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/PositionNode.js

@@ -114,6 +114,8 @@ PositionNode.prototype.copy = function ( source ) {
 
 	this.scope = source.scope;
 
+	return this;
+
 };
 
 PositionNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/ResolutionNode.js

@@ -43,6 +43,8 @@ ResolutionNode.prototype.copy = function ( source ) {
 
 	this.renderer = source.renderer;
 
+	return this;
+
 };
 
 ResolutionNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/ScreenUVNode.js

@@ -43,6 +43,8 @@ ScreenUVNode.prototype.copy = function ( source ) {
 
 	this.resolution = source.resolution;
 
+	return this;
+
 };
 
 ScreenUVNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/accessors/UVNode.js

@@ -36,6 +36,8 @@ UVNode.prototype.copy = function ( source ) {
 
 	this.index = source.index;
 
+	return this;
+
 };
 
 UVNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/bsdfs/BlinnExponentToRoughnessNode.js

@@ -29,6 +29,8 @@ BlinnExponentToRoughnessNode.prototype.copy = function ( source ) {
 
 	this.blinnExponent = source.blinnExponent;
 
+	return this;
+
 };
 
 BlinnExponentToRoughnessNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/bsdfs/RoughnessToBlinnExponentNode.js

@@ -71,6 +71,8 @@ RoughnessToBlinnExponentNode.prototype.copy = function ( source ) {
 
 	this.texture = source.texture;
 
+	return this;
+
 };
 
 RoughnessToBlinnExponentNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/AttributeNode.js

@@ -47,6 +47,8 @@ AttributeNode.prototype.copy = function ( source ) {
 
 	this.type = source.type;
 
+	return this;
+
 };
 
 AttributeNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/ConstNode.js

@@ -102,6 +102,8 @@ ConstNode.prototype.copy = function ( source ) {
 
 	this.parse( source.src, source.useDefine );
 
+	return this;
+
 };
 
 ConstNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/FunctionCallNode.js

@@ -70,6 +70,8 @@ FunctionCallNode.prototype.copy = function ( source ) {
 
 	this.value = source.value;
 
+	return this;
+
 };
 
 FunctionCallNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/FunctionNode.js

@@ -226,6 +226,8 @@ FunctionNode.prototype.copy = function ( source ) {
 
 	if ( source.type !== undefined ) this.type = source.type;
 
+	return this;
+
 };
 
 FunctionNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/InputNode.js

@@ -38,6 +38,8 @@ InputNode.prototype.copy = function ( source ) {
 
 	if ( source.readonly !== undefined ) this.readonly = source.readonly;
 
+	return this;
+
 };
 
 InputNode.prototype.createJSONNode = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/Node.js

@@ -147,6 +147,8 @@ Node.prototype = {
 
 		if ( source.userData !== undefined ) this.userData = JSON.parse( JSON.stringify( source.userData ) );
 
+		return this;
+
 	},
 
 	createJSONNode: function ( meta ) {

+ 2 - 0
examples/jsm/nodes/core/VarNode.js

@@ -43,6 +43,8 @@ VarNode.prototype.copy = function ( source ) {
 	this.type = source.type;
 	this.value = source.value;
 
+	return this;
+
 };
 
 VarNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/effects/BlurNode.js

@@ -142,6 +142,8 @@ BlurNode.prototype.copy = function ( source ) {
 	this.blurX = source.blurX;
 	this.blurY = source.blurY;
 
+	return this;
+
 };
 
 BlurNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/effects/ColorAdjustmentNode.js

@@ -113,6 +113,8 @@ ColorAdjustmentNode.prototype.copy = function ( source ) {
 	this.adjustment = source.adjustment;
 	this.method = source.method;
 
+	return this;
+
 };
 
 ColorAdjustmentNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/effects/LuminanceNode.js

@@ -52,6 +52,8 @@ LuminanceNode.prototype.copy = function ( source ) {
 
 	this.rgb = source.rgb;
 
+	return this;
+
 };
 
 LuminanceNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/BoolNode.js

@@ -28,6 +28,8 @@ BoolNode.prototype.copy = function ( source ) {
 
 	this.value = source.value;
 
+	return this;
+
 };
 
 BoolNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/ColorNode.js

@@ -33,6 +33,8 @@ ColorNode.prototype.copy = function ( source ) {
 
 	this.value.copy( source );
 
+	return this;
+
 };
 
 ColorNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/CubeTextureNode.js

@@ -84,6 +84,8 @@ CubeTextureNode.prototype.copy = function ( source ) {
 
 	if ( source.bias ) this.bias = source.bias;
 
+	return this;
+
 };
 
 CubeTextureNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/FloatNode.js

@@ -28,6 +28,8 @@ FloatNode.prototype.copy = function ( source ) {
 
 	this.value = source.value;
 
+	return this;
+
 };
 
 FloatNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/IntNode.js

@@ -28,6 +28,8 @@ IntNode.prototype.copy = function ( source ) {
 
 	this.value = source.value;
 
+	return this;
+
 };
 
 IntNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/Matrix3Node.js

@@ -51,6 +51,8 @@ Matrix3Node.prototype.copy = function ( source ) {
 
 	this.value.fromArray( source.elements );
 
+	return this;
+
 };
 
 Matrix3Node.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/Matrix4Node.js

@@ -50,6 +50,8 @@ Matrix4Node.prototype.copy = function ( source ) {
 
 	this.scope.value.fromArray( source.elements );
 
+	return this;
+
 };
 
 Matrix4Node.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/RTTNode.js

@@ -135,6 +135,8 @@ RTTNode.prototype.copy = function ( source ) {
 
 	this.saveTo = source.saveTo;
 
+	return this;
+
 };
 
 RTTNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/ReflectorNode.js

@@ -67,6 +67,8 @@ ReflectorNode.prototype.copy = function ( source ) {
 
 	this.scope.mirror = source.mirror;
 
+	return this;
+
 };
 
 ReflectorNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/TextureNode.js

@@ -89,6 +89,8 @@ TextureNode.prototype.copy = function ( source ) {
 	if ( source.bias ) this.bias = source.bias;
 	if ( source.project !== undefined ) this.project = source.project;
 
+	return this;
+
 };
 
 TextureNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/Vector2Node.js

@@ -33,6 +33,8 @@ Vector2Node.prototype.copy = function ( source ) {
 
 	this.value.copy( source );
 
+	return this;
+
 };
 
 Vector2Node.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/Vector3Node.js

@@ -33,6 +33,8 @@ Vector3Node.prototype.copy = function ( source ) {
 
 	this.value.copy( source );
 
+	return this;
+
 };
 
 Vector3Node.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/inputs/Vector4Node.js

@@ -33,6 +33,8 @@ Vector4Node.prototype.copy = function ( source ) {
 
 	this.value.copy( source );
 
+	return this;
+
 };
 
 Vector4Node.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/materials/NodeMaterial.js

@@ -144,6 +144,8 @@ NodeMaterial.prototype.copy = function ( source ) {
 
 	}
 
+	return this;
+
 };
 
 NodeMaterial.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/materials/nodes/PhongNode.js

@@ -372,6 +372,8 @@ PhongNode.prototype.copy = function ( source ) {
 	if ( source.environment ) this.environment = source.environment;
 	if ( source.environmentAlpha ) this.environmentAlpha = source.environmentAlpha;
 
+	return this;
+
 };
 
 PhongNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/materials/nodes/RawNode.js

@@ -41,6 +41,8 @@ RawNode.prototype.copy = function ( source ) {
 
 	this.value = source.value;
 
+	return this;
+
 };
 
 RawNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/materials/nodes/SpriteNode.js

@@ -202,6 +202,8 @@ SpriteNode.prototype.copy = function ( source ) {
 
 	if ( source.alpha ) this.alpha = source.alpha;
 
+	return this;
+
 };
 
 SpriteNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/math/CondNode.js

@@ -99,6 +99,8 @@ CondNode.prototype.copy = function ( source ) {
 	this.ifNode = source.ifNode;
 	this.elseNode = source.elseNode;
 
+	return this;
+
 };
 
 CondNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/math/MathNode.js

@@ -243,6 +243,8 @@ MathNode.prototype.copy = function ( source ) {
 	this.c = source.c;
 	this.method = source.method;
 
+	return this;
+
 };
 
 MathNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/math/OperatorNode.js

@@ -63,6 +63,8 @@ OperatorNode.prototype.copy = function ( source ) {
 	this.b = source.b;
 	this.op = source.op;
 
+	return this;
+
 };
 
 OperatorNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/misc/BumpMapNode.js

@@ -144,6 +144,8 @@ BumpMapNode.prototype.copy = function ( source ) {
 	this.value = source.value;
 	this.scale = source.scale;
 
+	return this;
+
 };
 
 BumpMapNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/misc/NormalMapNode.js

@@ -95,6 +95,8 @@ NormalMapNode.prototype.copy = function ( source ) {
 	this.value = source.value;
 	this.scale = source.scale;
 
+	return this;
+
 };
 
 NormalMapNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/postprocessing/NodePass.js

@@ -52,6 +52,8 @@ NodePass.prototype.copy = function ( source ) {
 
 	this.input = source.input;
 
+	return this;
+
 };
 
 NodePass.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/postprocessing/NodePostProcessing.js

@@ -97,6 +97,8 @@ NodePostProcessing.prototype = {
 
 		this.output = source.output;
 
+		return this;
+
 	},
 
 	toJSON: function ( meta ) {

+ 2 - 0
examples/jsm/nodes/procedural/CheckerNode.js

@@ -54,6 +54,8 @@ CheckerNode.prototype.copy = function ( source ) {
 
 	this.uv = source.uv;
 
+	return this;
+
 };
 
 CheckerNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/procedural/NoiseNode.js

@@ -48,6 +48,8 @@ NoiseNode.prototype.copy = function ( source ) {
 
 	this.uv = source.uv;
 
+	return this;
+
 };
 
 NoiseNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/BypassNode.js

@@ -62,6 +62,8 @@ BypassNode.prototype.copy = function ( source ) {
 	this.code = source.code;
 	this.value = source.value;
 
+	return this;
+
 };
 
 BypassNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/ColorSpaceNode.js

@@ -295,6 +295,8 @@ ColorSpaceNode.prototype.copy = function ( source ) {
 	this.input = source.input;
 	this.method = source.method;
 
+	return this;
+
 };
 
 ColorSpaceNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/JoinNode.js

@@ -78,6 +78,8 @@ JoinNode.prototype.copy = function ( source ) {
 
 	}
 
+	return this;
+
 };
 
 JoinNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/SwitchNode.js

@@ -80,6 +80,8 @@ SwitchNode.prototype.copy = function ( source ) {
 	this.node = source.node;
 	this.components = source.components;
 
+	return this;
+
 };
 
 SwitchNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/TimerNode.js

@@ -75,6 +75,8 @@ TimerNode.prototype.copy = function ( source ) {
 
 	this.timeScale = source.timeScale;
 
+	return this;
+
 };
 
 TimerNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/UVTransformNode.js

@@ -44,6 +44,8 @@ UVTransformNode.prototype.copy = function ( source ) {
 	this.uv = source.uv;
 	this.position = source.position;
 
+	return this;
+
 };
 
 UVTransformNode.prototype.toJSON = function ( meta ) {

+ 2 - 0
examples/jsm/nodes/utils/VelocityNode.js

@@ -152,6 +152,8 @@ VelocityNode.prototype.copy = function ( source ) {
 
 	this.setParams( source.params );
 
+	return this;
+
 };
 
 VelocityNode.prototype.toJSON = function ( meta ) {

+ 1 - 1
examples/webgl2_materials_texture2darray.html

@@ -55,13 +55,13 @@
 		</div>
 
 		<script src="js/libs/jszip.min.js"></script>
-		<script src="js/WebGL.js"></script>
 
 		<script type="module">
 
 			import * as THREE from '../build/three.module.js';
 
 			import Stats from './jsm/libs/stats.module.js';
+			import { WEBGL } from './jsm/WebGL.js';
 
 			if ( WEBGL.isWebGL2Available() === false ) {
 

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác