Mr.doob 1 tahun lalu
induk
melakukan
904a6eaa32
100 mengubah file dengan 77429 tambahan dan 7236 penghapusan
  1. 39 27
      build/three.cjs
  2. 39 27
      build/three.module.js
  3. 0 0
      build/three.module.min.js
  4. 76070 0
      build/three.webgpu.js
  5. 5 0
      build/three.webgpu.min.js
  6. 0 3
      docs/api/ar/objects/LOD.html
  7. 0 3
      docs/api/ar/objects/Line.html
  8. 0 3
      docs/api/ar/objects/Mesh.html
  9. 0 3
      docs/api/ar/objects/Points.html
  10. 1 4
      docs/api/ar/objects/Sprite.html
  11. 4 2
      docs/api/en/materials/MeshBasicMaterial.html
  12. 4 2
      docs/api/en/materials/MeshLambertMaterial.html
  13. 4 2
      docs/api/en/materials/MeshPhongMaterial.html
  14. 4 2
      docs/api/en/materials/MeshStandardMaterial.html
  15. 4 2
      docs/api/en/materials/MeshToonMaterial.html
  16. 132 0
      docs/api/en/math/Matrix2.html
  17. 0 3
      docs/api/en/objects/LOD.html
  18. 0 3
      docs/api/en/objects/Line.html
  19. 0 3
      docs/api/en/objects/Mesh.html
  20. 0 3
      docs/api/en/objects/Points.html
  21. 0 3
      docs/api/en/objects/Sprite.html
  22. 0 6
      docs/api/it/objects/LOD.html
  23. 0 5
      docs/api/it/objects/Line.html
  24. 0 3
      docs/api/it/objects/Mesh.html
  25. 0 5
      docs/api/it/objects/Points.html
  26. 0 5
      docs/api/it/objects/Sprite.html
  27. 0 5
      docs/api/zh/objects/LOD.html
  28. 0 5
      docs/api/zh/objects/Line.html
  29. 0 3
      docs/api/zh/objects/Mesh.html
  30. 0 5
      docs/api/zh/objects/Points.html
  31. 0 5
      docs/api/zh/objects/Sprite.html
  32. 1 0
      docs/list.json
  33. 1 1
      editor/js/Menubar.Add.js
  34. 0 1
      editor/js/Menubar.File.js
  35. 15 1
      examples/files.json
  36. 2 1
      examples/jsm/Addons.js
  37. 7 3
      examples/jsm/exporters/GLTFExporter.js
  38. 0 25
      examples/jsm/lights/IESSpotLight.js
  39. 35 0
      examples/jsm/lights/RectAreaLightTexturesLib.js
  40. 3 30
      examples/jsm/lights/RectAreaLightUniformsLib.js
  41. 20 0
      examples/jsm/lines/webgpu/Line2.js
  42. 376 0
      examples/jsm/lines/webgpu/LineSegments2.js
  43. 2 9
      examples/jsm/loaders/MaterialXLoader.js
  44. 583 0
      examples/jsm/loaders/UltraHDRLoader.js
  45. 76 3
      examples/jsm/loaders/VTKLoader.js
  46. 2 2
      examples/jsm/misc/GPUComputationRenderer.js
  47. 0 208
      examples/jsm/nodes/Nodes.js
  48. 0 25
      examples/jsm/nodes/accessors/AccessorsUtils.js
  49. 0 100
      examples/jsm/nodes/accessors/BatchNode.js
  50. 0 13
      examples/jsm/nodes/accessors/BitangentNode.js
  51. 0 159
      examples/jsm/nodes/accessors/BufferAttributeNode.js
  52. 0 36
      examples/jsm/nodes/accessors/BufferNode.js
  53. 0 19
      examples/jsm/nodes/accessors/CameraNode.js
  54. 0 145
      examples/jsm/nodes/accessors/ClippingNode.js
  55. 0 61
      examples/jsm/nodes/accessors/CubeTextureNode.js
  56. 0 118
      examples/jsm/nodes/accessors/InstanceNode.js
  57. 0 21
      examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js
  58. 0 420
      examples/jsm/nodes/accessors/MaterialNode.js
  59. 0 41
      examples/jsm/nodes/accessors/MaterialReferenceNode.js
  60. 0 36
      examples/jsm/nodes/accessors/ModelNode.js
  61. 0 39
      examples/jsm/nodes/accessors/ModelViewProjectionNode.js
  62. 0 255
      examples/jsm/nodes/accessors/MorphNode.js
  63. 0 14
      examples/jsm/nodes/accessors/NormalNode.js
  64. 0 150
      examples/jsm/nodes/accessors/Object3DNode.js
  65. 0 26
      examples/jsm/nodes/accessors/PointUVNode.js
  66. 0 10
      examples/jsm/nodes/accessors/PositionNode.js
  67. 0 166
      examples/jsm/nodes/accessors/ReferenceNode.js
  68. 0 6
      examples/jsm/nodes/accessors/ReflectVectorNode.js
  69. 0 29
      examples/jsm/nodes/accessors/RendererReferenceNode.js
  70. 0 52
      examples/jsm/nodes/accessors/SceneNode.js
  71. 0 124
      examples/jsm/nodes/accessors/SkinningNode.js
  72. 0 130
      examples/jsm/nodes/accessors/StorageBufferNode.js
  73. 0 104
      examples/jsm/nodes/accessors/StorageTextureNode.js
  74. 0 23
      examples/jsm/nodes/accessors/TangentNode.js
  75. 0 100
      examples/jsm/nodes/accessors/Texture3DNode.js
  76. 0 94
      examples/jsm/nodes/accessors/TextureBicubicNode.js
  77. 0 415
      examples/jsm/nodes/accessors/TextureNode.js
  78. 0 35
      examples/jsm/nodes/accessors/TextureSizeNode.js
  79. 0 3
      examples/jsm/nodes/accessors/UVNode.js
  80. 0 146
      examples/jsm/nodes/accessors/UniformsNode.js
  81. 0 29
      examples/jsm/nodes/accessors/UserDataNode.js
  82. 0 70
      examples/jsm/nodes/accessors/VertexColorNode.js
  83. 0 84
      examples/jsm/nodes/code/CodeNode.js
  84. 0 37
      examples/jsm/nodes/code/ExpressionNode.js
  85. 0 96
      examples/jsm/nodes/code/FunctionCallNode.js
  86. 0 130
      examples/jsm/nodes/code/FunctionNode.js
  87. 0 488
      examples/jsm/nodes/code/ScriptableNode.js
  88. 0 167
      examples/jsm/nodes/code/ScriptableValueNode.js
  89. 0 128
      examples/jsm/nodes/core/AssignNode.js
  90. 0 116
      examples/jsm/nodes/core/AttributeNode.js
  91. 0 45
      examples/jsm/nodes/core/BypassNode.js
  92. 0 46
      examples/jsm/nodes/core/CacheNode.js
  93. 0 32
      examples/jsm/nodes/core/ConstNode.js
  94. 0 67
      examples/jsm/nodes/core/ContextNode.js
  95. 0 72
      examples/jsm/nodes/core/IndexNode.js
  96. 0 83
      examples/jsm/nodes/core/InputNode.js
  97. 0 19
      examples/jsm/nodes/core/LightingModel.js
  98. 0 578
      examples/jsm/nodes/core/Node.js
  99. 0 15
      examples/jsm/nodes/core/NodeAttribute.js
  100. 0 1393
      examples/jsm/nodes/core/NodeBuilder.js

File diff ditekan karena terlalu besar
+ 39 - 27
build/three.cjs


File diff ditekan karena terlalu besar
+ 39 - 27
build/three.module.js


File diff ditekan karena terlalu besar
+ 0 - 0
build/three.module.min.js


File diff ditekan karena terlalu besar
+ 76070 - 0
build/three.webgpu.js


File diff ditekan karena terlalu besar
+ 5 - 0
build/three.webgpu.min.js


+ 0 - 3
docs/api/ar/objects/LOD.html

@@ -80,9 +80,6 @@
 		إضافة شبكة ستعرض عند مسافة معينة وأكبر. عادةً ما تكون المسافة أبعد، كلما كان التفصيل أقل في الشبكة.
 		</p>
 		
-		<h3>[method:LOD clone]()</h3>
-		<p>إرجاع نسخة من هذا كائن LOD مع مستوياته المرتبطة.</p>
-		
 		<h3>[method:Integer getCurrentLevel]()</h3>
 		<p>الحصول على مستوى LOD النشط حاليًا. كفهرس لمصفوفة المستويات.</p>
 		

+ 0 - 3
docs/api/ar/objects/Line.html

@@ -95,9 +95,6 @@
 		ستستدعي [page:Raycaster.intersectObject] هذه الطريقة.
 		</p>
 		 
-		<h3>[method:Line clone]()</h3>
-		<p>يعود بنسخة من هذا كائن Line وأحفاده.</p>
-		 
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 		يحدث morphTargets ليكون لها تأثير على الكائن. يعيد تعيين

+ 0 - 3
docs/api/ar/objects/Mesh.html

@@ -72,9 +72,6 @@
 		<h2>الطرق (Methods)</h2>
 		<p>انظر إلى الفئة الأساسية [page:Object3D] للحصول على الطرق المشتركة.</p>
 		
-		<h3>[method:Mesh clone]()</h3>
-		<p>إرجاع نسخة من هذا كائن [name] وأحفاده.</p>
-		
 		<h3>
 		[method:Vector3 getVertexPosition]( [param:Integer index], [param:Vector3 target] )
 		</h3>

+ 0 - 3
docs/api/ar/objects/Points.html

@@ -71,9 +71,6 @@
 		سيتم استدعاء هذه الطريقة بواسطة [page:Raycaster.intersectObject].
 		</p>
 		
-		<h3>[method:Points clone]()</h3>
-		<p>إرجاع نسخة من هذا كائن Points وأحفاده.</p>
-		
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 		تحديث التحولات لعدم التأثير على الكائن. يعيد تعيين خصائص

+ 1 - 4
docs/api/ar/objects/Sprite.html

@@ -61,10 +61,7 @@
 			
 		<h2>الطرق (Methods)</h2>
 		<p>انظر إلى الفئة الأساسية [page:Object3D] للحصول على الطرق المشتركة.</p>
-			
-		<h3>[method:Sprite clone]()</h3>
-		<p>إرجاع نسخة من هذا كائن Sprite وأحفاده.</p>
-			
+
 		<h3>[method:this copy]( [param:Sprite sprite] )</h3>
 		<p>نسخ خصائص رذاذ المارة إلى هذه واحدة.</p>
 			

+ 4 - 2
docs/api/en/materials/MeshBasicMaterial.html

@@ -78,8 +78,10 @@
 
 		<h3>[property:Float aoMapIntensity]</h3>
 		<p>
-			Intensity of the ambient occlusion effect. Default is `1`. Zero is no
-			occlusion effect.
+			Intensity of the ambient occlusion effect. Range is 0-1, where `0`
+			disables ambient occlusion. Where intensity is `1` and the [page:.aoMap]
+			red channel is also `1`, ambient light is fully occluded on a surface.
+			Default is `1`.
 		</p>
 
 		<h3>[property:Color color]</h3>

+ 4 - 2
docs/api/en/materials/MeshLambertMaterial.html

@@ -87,8 +87,10 @@
 
 		<h3>[property:Float aoMapIntensity]</h3>
 		<p>
-			Intensity of the ambient occlusion effect. Default is `1`. Zero is no
-			occlusion effect.
+			Intensity of the ambient occlusion effect. Range is 0-1, where `0`
+			disables ambient occlusion. Where intensity is `1` and the [page:.aoMap]
+			red channel is also `1`, ambient light is fully occluded on a surface.
+			Default is `1`.
 		</p>
 
 		<h3>[property:Texture bumpMap]</h3>

+ 4 - 2
docs/api/en/materials/MeshPhongMaterial.html

@@ -85,8 +85,10 @@
 
 		<h3>[property:Float aoMapIntensity]</h3>
 		<p>
-			Intensity of the ambient occlusion effect. Default is `1`. Zero is no
-			occlusion effect.
+			Intensity of the ambient occlusion effect. Range is 0-1, where `0`
+			disables ambient occlusion. Where intensity is `1` and the [page:.aoMap]
+			red channel is also `1`, ambient light is fully occluded on a surface.
+			Default is `1`.
 		</p>
 
 		<h3>[property:Texture bumpMap]</h3>

+ 4 - 2
docs/api/en/materials/MeshStandardMaterial.html

@@ -114,8 +114,10 @@
 
 		<h3>[property:Float aoMapIntensity]</h3>
 		<p>
-			Intensity of the ambient occlusion effect. Default is `1`. Zero is no
-			occlusion effect.
+			Intensity of the ambient occlusion effect. Range is 0-1, where `0`
+			disables ambient occlusion. Where intensity is `1` and the [page:.aoMap]
+			red channel is also `1`, ambient light is fully occluded on a surface.
+			Default is `1`.
 		</p>
 
 		<h3>[property:Texture bumpMap]</h3>

+ 4 - 2
docs/api/en/materials/MeshToonMaterial.html

@@ -78,8 +78,10 @@
 
 		<h3>[property:Float aoMapIntensity]</h3>
 		<p>
-			Intensity of the ambient occlusion effect. Default is `1`. Zero is no
-			occlusion effect.
+			Intensity of the ambient occlusion effect. Range is 0-1, where `0`
+			disables ambient occlusion. Where intensity is `1` and the [page:.aoMap]
+			red channel is also `1`, ambient light is fully occluded on a surface.
+			Default is `1`.
 		</p>
 
 		<h3>[property:Texture bumpMap]</h3>

+ 132 - 0
docs/api/en/math/Matrix2.html

@@ -0,0 +1,132 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8" />
+		<base href="../../../" />
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+		<h1>[name]</h1>
+
+		<p class="desc">
+			A class representing a 2x2
+			[link:https://en.wikipedia.org/wiki/Matrix_(mathematics) matrix].
+		</p>
+
+		<h2>Code Example</h2>
+		<code>
+const m = new Matrix2(); 
+		</code>
+
+		<h2>A Note on Row-Major and Column-Major Ordering</h2>
+		<p>
+			The constructor and [page:set]() method take arguments in
+			[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order row-major] 
+			order, while internally they are stored in the [page:.elements elements] 
+			array in column-major order.<br /><br />
+
+			This means that calling
+			<code>
+m.set( 11, 12,
+       21, 22 );
+		</code>
+			will result in the [page:.elements elements] array containing:
+			<code> 
+m.elements = [ 11, 21,
+			   12, 22 ];
+			</code>
+			and internally all calculations are performed using column-major ordering.
+			However, as the actual ordering makes no difference mathematically and
+			most people are used to thinking about matrices in row-major order, the
+			three.js documentation shows matrices in row-major order. Just bear in
+			mind that if you are reading the source code, you'll have to take the
+			[link:https://en.wikipedia.org/wiki/Transpose transpose] of any matrices
+			outlined here to make sense of the calculations.
+		</p>
+
+		<h2>Constructor</h2>
+
+		<h3>[name]( [param:Number n11], [param:Number n12],
+			[param:Number n21], [param:Number n22] )</h3>
+		<p>
+			Creates a 2x2 matrix with the given arguments in row-major order. If no arguments are provided, the constructor initializes
+			the [name] to the 3x3 [link:https://en.wikipedia.org/wiki/Identity_matrix identity matrix].
+		</p>
+
+		<h2>Properties</h2>
+
+		<h3>[property:Array elements]</h3>
+		<p>
+			A [link:https://en.wikipedia.org/wiki/Row-_and_column-major_order column-major] list of matrix values.
+		</p>
+
+		<h2>Methods</h2>
+
+		<h3>
+			[method:this fromArray]( [param:Array array], [param:Integer offset] )
+		</h3>
+		<p>
+			[page:Array array] - the array to read the elements from.<br />
+			[page:Integer offset] - (optional) index of first element in the array.
+			Default is `0`.<br /><br />
+
+			Sets the elements of this matrix based on an array in
+			[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major] format.
+		</p>
+
+		<h3>[method:this identity]()</h3>
+		<p>
+			Resets this matrix to the 2x2 identity matrix:
+		</p>
+
+		<math display="block">
+			<mrow>
+				<mo>[</mo>
+				<mtable>
+					<mtr>
+						<mtd><mn>1</mn></mtd>
+						<mtd><mn>0</mn></mtd>
+					</mtr>
+					<mtr>
+						<mtd><mn>0</mn></mtd>
+						<mtd><mn>1</mn></mtd>
+					</mtr>
+				</mtable>
+				<mo>]</mo>
+			</mrow>
+		</math>
+
+		<h3>
+			[method:this set]( [param:Float n11], [param:Float n12], [param:Float n21], [param:Float n22] )
+		</h3>
+		<p>
+			Sets the 2x2 matrix values to the given
+			[link:https://en.wikipedia.org/wiki/Row-_and_column-major_order row-major]
+			sequence of values:
+		</p>
+
+		<math display="block">
+			<mrow>
+				<mo>[</mo>
+				<mtable>
+					<mtr>
+						<mtd><mi>n11</mi></mtd>
+						<mtd><mi>n12</mi></mtd>
+					</mtr>
+					<mtr>
+						<mtd><mi>n21</mi></mtd>
+						<mtd><mi>n22</mi></mtd>
+					</mtr>
+				</mtable>
+				<mo>]</mo>
+			</mrow>
+		</math>
+
+		<h2>Source</h2>
+
+		<p>
+			[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+		</p>
+	</body>
+</html>

+ 0 - 3
docs/api/en/objects/LOD.html

@@ -86,9 +86,6 @@
 			the further away the distance, the lower the detail on the mesh.
 		</p>
 
-		<h3>[method:LOD clone]()</h3>
-		<p>Returns a clone of this LOD object with its associated levels.</p>
-
 		<h3>[method:Integer getCurrentLevel]()</h3>
 		<p>Get the currently active LOD level. As index of the levels array.</p>
 

+ 0 - 3
docs/api/en/objects/Line.html

@@ -95,9 +95,6 @@
 			[page:Raycaster.intersectObject] will call this method.
 		</p>
 
-		<h3>[method:Line clone]()</h3>
-		<p>Returns a clone of this Line object and its descendants.</p>
-
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 			Updates the morphTargets to have no influence on the object. Resets the

+ 0 - 3
docs/api/en/objects/Mesh.html

@@ -74,9 +74,6 @@
 		<h2>Methods</h2>
 		<p>See the base [page:Object3D] class for common methods.</p>
 
-		<h3>[method:Mesh clone]()</h3>
-		<p>Returns a clone of this [name] object and its descendants.</p>
-
 		<h3>
 			[method:Vector3 getVertexPosition]( [param:Integer index], [param:Vector3 target] )
 		</h3>

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

@@ -71,9 +71,6 @@
 			[page:Raycaster.intersectObject] will call this method.
 		</p>
 
-		<h3>[method:Points clone]()</h3>
-		<p>Returns a clone of this Points object and its descendants.</p>
-
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 			Updates the morphTargets to have no influence on the object. Resets the

+ 0 - 3
docs/api/en/objects/Sprite.html

@@ -62,9 +62,6 @@
 		<h2>Methods</h2>
 		<p>See the base [page:Object3D] class for common methods.</p>
 
-		<h3>[method:Sprite clone]()</h3>
-		<p>Returns a clone of this Sprite object and any descendants.</p>
-
 		<h3>[method:this copy]( [param:Sprite sprite] )</h3>
 		<p>Copies the properties of the passed sprite to this one.</p>
 

+ 0 - 6
docs/api/it/objects/LOD.html

@@ -88,12 +88,6 @@
 		la distanza, minore è il dettaglio sulla mesh.
 		</p>
 
-		<h3>[method:LOD clone]()</h3>
-		<p>
-			Restituisce un clone di questo oggetto LOD e degli oggetti specifici della distanza ad esso associati.
-		</p>
-
-
 		<h3>[method:Integer getCurrentLevel]()</h3>
 		<p>
 			Ottiene il livello LOD attivo attualmente. Come indice dell'array dei livelli.

+ 0 - 5
docs/api/it/objects/Line.html

@@ -90,11 +90,6 @@
 			[page:Raycaster.intersectObject] chiamerà questo metodo.
 		</p>
 
-		<h3>[method:Line clone]()</h3>
-		<p>
-			Restituisce un clone di questo oggetto Line e i suoi discendenti.
-		</p>
-
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 			Aggiorna i morphTargets in modo che non abbiano alcuna influenza sull'oggetto. 

+ 0 - 3
docs/api/it/objects/Mesh.html

@@ -67,9 +67,6 @@
 		<h2>Metodi</h2>
 		<p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
 
-		<h3>[method:Mesh clone]()</h3>
-		<p>Restituisce un clone di questo oggetto [name] e i suoi discendenti.</p>
-
 		<h3>[method:undefined raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
 		<p>
 			Ottiene le intersezioni tra un raggio lanciato e questa mesh.

+ 0 - 5
docs/api/it/objects/Points.html

@@ -66,11 +66,6 @@
 			[page:Raycaster.intersectObject] chiamerà questo metodo, ma i risultati non saranno ordinati.
 		</p>
 
-		<h3>[method:Points clone]()</h3>
-		<p>
-			Restituisce un clone di questo oggetto [name] e i suoi discendenti.</p>
-		</p>
-
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 			Aggiorna i morphTargets in modo che non abbiano influenza sull'oggetto. Reimposta le proprietà

+ 0 - 5
docs/api/it/objects/Sprite.html

@@ -63,11 +63,6 @@
 		<h2>Metodi</h2>
 		<p>Vedi la classe base [page:Object3D] per i metodi comuni.</p>
 
-		<h3>[method:Sprite clone]()</h3>
-		<p>
-			Restituisce un clone di questo oggetto Sprite e i suoi discendenti.
-		</p>
-
 		<h3>[method:this copy]( [param:Sprite sprite] )</h3>
 		<p>
 			Copia le proprietà della sprite passata in questa.

+ 0 - 5
docs/api/zh/objects/LOD.html

@@ -86,11 +86,6 @@
 		添加在一定距离和更大范围内显示的网格。通常来说,距离越远,网格中的细节就越少。
 		</p>
 
-		<h3>[method:LOD clone]()</h3>
-		<p>
-			返回一个LOD对象及其所关联的在特定距离中的物体。
-		</p>
-
 		<h3>[method:Integer getCurrentLevel]()</h3>
 		<p>
 		Get the currently active LOD level. As index of the levels array.

+ 0 - 5
docs/api/zh/objects/Line.html

@@ -88,11 +88,6 @@
 			[page:Raycaster.intersectObject]将会调用这个方法。
 		</p>
 
-		<h3>[method:Line clone]()</h3>
-		<p>
-			返回这条线及其子集的一个克隆对象。
-		</p>
-
 		<h3>[method:undefined updateMorphTargets]()</h3>
 		<p>
 		Updates the morphTargets to have no influence on the object. Resets the

+ 0 - 3
docs/api/zh/objects/Mesh.html

@@ -70,9 +70,6 @@
 		<h2>方法</h2>
 		<p>共有方法请参见其基类[page:Object3D]。</p>
 
-		<h3>[method:Mesh clone]()</h3>
-		<p>返回这个[name]对象及其子级的克隆。</p>
-
 		<h3>
 			[method:Vector3 getVertexPosition]( [param:Integer index], [param:Vector3 target] )
 		</h3>

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

@@ -69,11 +69,6 @@
 		[page:Raycaster.intersectObject]将会调用这个方法。
 	</p>
 
-	<h3>[method:Points clone]()</h3>
-	<p>
-		返回这个点及其子集的一个克隆对象。
-	</p>
-
 	<h3>[method:undefined updateMorphTargets]()</h3>
 	<p>
 		更新morphTargets,使其不对对象产生影响,重置[page:Points.morphTargetInfluences morphTargetInfluences] 和

+ 0 - 5
docs/api/zh/objects/Sprite.html

@@ -61,11 +61,6 @@
 		<h2>方法</h2>
 		<p>共有方法请参见其基类[page:Object3D]。</p>
 
-		<h3>[method:Sprite clone]()</h3>
-		<p>
-			返回当前Sprite对象的一个克隆及其任何后代。
-		</p>
-
 		<h3>[method:this copy]( [param:Sprite sprite] )</h3>
 		<p>
 			将前一个Sprite对象的属性复制给当前的这个对象。

+ 1 - 0
docs/list.json

@@ -241,6 +241,7 @@
 				"Interpolant": "api/en/math/Interpolant",
 				"Line3": "api/en/math/Line3",
 				"MathUtils": "api/en/math/MathUtils",
+				"Matrix2": "api/en/math/Matrix2",
 				"Matrix3": "api/en/math/Matrix3",
 				"Matrix4": "api/en/math/Matrix4",
 				"Plane": "api/en/math/Plane",

+ 1 - 1
editor/js/Menubar.Add.js

@@ -1,6 +1,6 @@
 import * as THREE from 'three';
 
-import { UIPanel, UIRow, UIHorizontalRule } from './libs/ui.js';
+import { UIPanel, UIRow } from './libs/ui.js';
 
 import { AddObjectCommand } from './commands/AddObjectCommand.js';
 

+ 0 - 1
editor/js/Menubar.File.js

@@ -1,5 +1,4 @@
 import { UIPanel, UIRow, UIHorizontalRule } from './libs/ui.js';
-import { Loader } from './Loader.js';
 
 function MenubarFile( editor ) {
 

+ 15 - 1
examples/files.json

@@ -118,8 +118,8 @@
 		"webgl_loader_tilt",
 		"webgl_loader_texture_dds",
 		"webgl_loader_texture_exr",
+		"webgl_loader_texture_ultrahdr",
 		"webgl_loader_texture_hdr",
-		"webgl_loader_texture_hdrjpg",
 		"webgl_loader_texture_ktx",
 		"webgl_loader_texture_ktx2",
 		"webgl_loader_texture_logluv",
@@ -344,6 +344,7 @@
 		"webgpu_loader_gltf_transmission",
 		"webgpu_loader_materialx",
 		"webgpu_materials",
+		"webgpu_materials_basic",
 		"webgpu_materials_displacementmap",
 		"webgpu_materials_lightmap",
 		"webgpu_materials_matcap",
@@ -356,6 +357,8 @@
 		"webgpu_mirror",
 		"webgpu_morphtargets",
 		"webgpu_morphtargets_face",
+		"webgpu_mrt",
+		"webgpu_mrt_mask",
 		"webgpu_multiple_rendertargets",
 		"webgpu_multiple_rendertargets_readback",
 		"webgpu_multisampled_renderbuffers",
@@ -367,12 +370,22 @@
 		"webgpu_pmrem_equirectangular",
 		"webgpu_pmrem_scene",
 		"webgpu_portal",
+		"webgpu_postprocessing_3dlut",
 		"webgpu_postprocessing_afterimage",
 		"webgpu_postprocessing_anamorphic",
+		"webgpu_postprocessing_ao",
+		"webgpu_postprocessing_bloom",
+		"webgpu_postprocessing_bloom_emissive",
+		"webgpu_postprocessing_bloom_selective",
 		"webgpu_postprocessing_dof",
+		"webgpu_postprocessing_pixel",
+		"webgpu_postprocessing_fxaa",
 		"webgpu_postprocessing_sobel",
+		"webgpu_postprocessing_transition",
 		"webgpu_postprocessing",
+		"webgpu_procedural_texture",
 		"webgpu_reflection",
+		"webgpu_refraction",
 		"webgpu_rtt",
 		"webgpu_sandbox",
 		"webgpu_shadertoy",
@@ -388,6 +401,7 @@
 		"webgpu_textures_anisotropy",
 		"webgpu_textures_partialupdate",
 		"webgpu_tsl_editor",
+		"webgpu_tsl_galaxy",
 		"webgpu_tsl_transpiler",
 		"webgpu_video_panorama",
 		"webgpu_volume_cloud",

+ 2 - 1
examples/jsm/Addons.js

@@ -71,8 +71,8 @@ export * from './interactive/InteractiveGroup.js';
 export * from './interactive/SelectionBox.js';
 export * from './interactive/SelectionHelper.js';
 
-export { default as IESSpotLight } from './lights/IESSpotLight.js';
 export * from './lights/LightProbeGenerator.js';
+export * from './lights/RectAreaLightTexturesLib.js';
 export * from './lights/RectAreaLightUniformsLib.js';
 
 export * from './lines/Line2.js';
@@ -117,6 +117,7 @@ export * from './loaders/PDBLoader.js';
 export * from './loaders/PLYLoader.js';
 export * from './loaders/PVRLoader.js';
 export * from './loaders/RGBELoader.js';
+export * from './loaders/UltraHDRLoader.js';
 export * from './loaders/RGBMLoader.js';
 export * from './loaders/STLLoader.js';
 export * from './loaders/SVGLoader.js';

+ 7 - 3
examples/jsm/exporters/GLTFExporter.js

@@ -871,7 +871,9 @@ class GLTFWriter {
 		canvas.width = width;
 		canvas.height = height;
 
-		const context = canvas.getContext( '2d' );
+		const context = canvas.getContext( '2d', {
+			willReadFrequently: true,
+		} );
 		context.fillStyle = '#00ffff';
 		context.fillRect( 0, 0, width, height );
 
@@ -1273,7 +1275,9 @@ class GLTFWriter {
 			canvas.width = Math.min( image.width, options.maxTextureSize );
 			canvas.height = Math.min( image.height, options.maxTextureSize );
 
-			const ctx = canvas.getContext( '2d' );
+			const ctx = canvas.getContext( '2d', {
+				willReadFrequently: true,
+			} );
 
 			if ( flipY === true ) {
 
@@ -2109,7 +2113,7 @@ class GLTFWriter {
 			if ( ! trackNode || ! trackProperty ) {
 
 				console.warn( 'THREE.GLTFExporter: Could not export animation track "%s".', track.name );
-				return null;
+				continue;
 
 			}
 

+ 0 - 25
examples/jsm/lights/IESSpotLight.js

@@ -1,25 +0,0 @@
-import { SpotLight } from 'three';
-
-class IESSpotLight extends SpotLight {
-
-	constructor( color, intensity, distance, angle, penumbra, decay ) {
-
-		super( color, intensity, distance, angle, penumbra, decay );
-
-		this.iesMap = null;
-
-	}
-
-	copy( source, recursive ) {
-
-		super.copy( source, recursive );
-
-		this.iesMap = source.iesMap;
-
-		return this;
-
-	}
-
-}
-
-export default IESSpotLight;

File diff ditekan karena terlalu besar
+ 35 - 0
examples/jsm/lights/RectAreaLightTexturesLib.js


File diff ditekan karena terlalu besar
+ 3 - 30
examples/jsm/lights/RectAreaLightUniformsLib.js


+ 20 - 0
examples/jsm/lines/webgpu/Line2.js

@@ -0,0 +1,20 @@
+import { LineSegments2 } from './LineSegments2.js';
+import { LineGeometry } from '../LineGeometry.js';
+
+import { Line2NodeMaterial } from 'three';
+
+class Line2 extends LineSegments2 {
+
+	constructor( geometry = new LineGeometry(), material = new Line2NodeMaterial( { color: Math.random() * 0xffffff } ) ) {
+
+		super( geometry, material );
+
+		this.isLine2 = true;
+
+		this.type = 'Line2';
+
+	}
+
+}
+
+export { Line2 };

+ 376 - 0
examples/jsm/lines/webgpu/LineSegments2.js

@@ -0,0 +1,376 @@
+import {
+	Box3,
+	InstancedInterleavedBuffer,
+	InterleavedBufferAttribute,
+	Line3,
+	MathUtils,
+	Matrix4,
+	Mesh,
+	Sphere,
+	Vector3,
+	Vector4,
+	Line2NodeMaterial
+} from 'three';
+import { LineSegmentsGeometry } from '../../lines/LineSegmentsGeometry.js';
+
+const _viewport = new Vector4();
+
+const _start = new Vector3();
+const _end = new Vector3();
+
+const _start4 = new Vector4();
+const _end4 = new Vector4();
+
+const _ssOrigin = new Vector4();
+const _ssOrigin3 = new Vector3();
+const _mvMatrix = new Matrix4();
+const _line = new Line3();
+const _closestPoint = new Vector3();
+
+const _box = new Box3();
+const _sphere = new Sphere();
+const _clipToWorldVector = new Vector4();
+
+let _ray, _lineWidth;
+
+// Returns the margin required to expand by in world space given the distance from the camera,
+// line width, resolution, and camera projection
+function getWorldSpaceHalfWidth( camera, distance, resolution ) {
+
+	// transform into clip space, adjust the x and y values by the pixel width offset, then
+	// transform back into world space to get world offset. Note clip space is [-1, 1] so full
+	// width does not need to be halved.
+	_clipToWorldVector.set( 0, 0, - distance, 1.0 ).applyMatrix4( camera.projectionMatrix );
+	_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
+	_clipToWorldVector.x = _lineWidth / resolution.width;
+	_clipToWorldVector.y = _lineWidth / resolution.height;
+	_clipToWorldVector.applyMatrix4( camera.projectionMatrixInverse );
+	_clipToWorldVector.multiplyScalar( 1.0 / _clipToWorldVector.w );
+
+	return Math.abs( Math.max( _clipToWorldVector.x, _clipToWorldVector.y ) );
+
+}
+
+function raycastWorldUnits( lineSegments, intersects ) {
+
+	const matrixWorld = lineSegments.matrixWorld;
+	const geometry = lineSegments.geometry;
+	const instanceStart = geometry.attributes.instanceStart;
+	const instanceEnd = geometry.attributes.instanceEnd;
+	const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
+
+	for ( let i = 0, l = segmentCount; i < l; i ++ ) {
+
+		_line.start.fromBufferAttribute( instanceStart, i );
+		_line.end.fromBufferAttribute( instanceEnd, i );
+
+		_line.applyMatrix4( matrixWorld );
+
+		const pointOnLine = new Vector3();
+		const point = new Vector3();
+
+		_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
+		const isInside = point.distanceTo( pointOnLine ) < _lineWidth * 0.5;
+
+		if ( isInside ) {
+
+			intersects.push( {
+				point,
+				pointOnLine,
+				distance: _ray.origin.distanceTo( point ),
+				object: lineSegments,
+				face: null,
+				faceIndex: i,
+				uv: null,
+				uv1: null,
+			} );
+
+		}
+
+	}
+
+}
+
+function raycastScreenSpace( lineSegments, camera, intersects ) {
+
+	const projectionMatrix = camera.projectionMatrix;
+	const material = lineSegments.material;
+	const resolution = material.resolution;
+	const matrixWorld = lineSegments.matrixWorld;
+
+	const geometry = lineSegments.geometry;
+	const instanceStart = geometry.attributes.instanceStart;
+	const instanceEnd = geometry.attributes.instanceEnd;
+	const segmentCount = Math.min( geometry.instanceCount, instanceStart.count );
+
+	const near = - camera.near;
+
+	//
+
+	// pick a point 1 unit out along the ray to avoid the ray origin
+	// sitting at the camera origin which will cause "w" to be 0 when
+	// applying the projection matrix.
+	_ray.at( 1, _ssOrigin );
+
+	// ndc space [ - 1.0, 1.0 ]
+	_ssOrigin.w = 1;
+	_ssOrigin.applyMatrix4( camera.matrixWorldInverse );
+	_ssOrigin.applyMatrix4( projectionMatrix );
+	_ssOrigin.multiplyScalar( 1 / _ssOrigin.w );
+
+	// screen space
+	_ssOrigin.x *= resolution.x / 2;
+	_ssOrigin.y *= resolution.y / 2;
+	_ssOrigin.z = 0;
+
+	_ssOrigin3.copy( _ssOrigin );
+
+	_mvMatrix.multiplyMatrices( camera.matrixWorldInverse, matrixWorld );
+
+	for ( let i = 0, l = segmentCount; i < l; i ++ ) {
+
+		_start4.fromBufferAttribute( instanceStart, i );
+		_end4.fromBufferAttribute( instanceEnd, i );
+
+		_start4.w = 1;
+		_end4.w = 1;
+
+		// camera space
+		_start4.applyMatrix4( _mvMatrix );
+		_end4.applyMatrix4( _mvMatrix );
+
+		// skip the segment if it's entirely behind the camera
+		const isBehindCameraNear = _start4.z > near && _end4.z > near;
+		if ( isBehindCameraNear ) {
+
+			continue;
+
+		}
+
+		// trim the segment if it extends behind camera near
+		if ( _start4.z > near ) {
+
+			const deltaDist = _start4.z - _end4.z;
+			const t = ( _start4.z - near ) / deltaDist;
+			_start4.lerp( _end4, t );
+
+		} else if ( _end4.z > near ) {
+
+			const deltaDist = _end4.z - _start4.z;
+			const t = ( _end4.z - near ) / deltaDist;
+			_end4.lerp( _start4, t );
+
+		}
+
+		// clip space
+		_start4.applyMatrix4( projectionMatrix );
+		_end4.applyMatrix4( projectionMatrix );
+
+		// ndc space [ - 1.0, 1.0 ]
+		_start4.multiplyScalar( 1 / _start4.w );
+		_end4.multiplyScalar( 1 / _end4.w );
+
+		// screen space
+		_start4.x *= resolution.x / 2;
+		_start4.y *= resolution.y / 2;
+
+		_end4.x *= resolution.x / 2;
+		_end4.y *= resolution.y / 2;
+
+		// create 2d segment
+		_line.start.copy( _start4 );
+		_line.start.z = 0;
+
+		_line.end.copy( _end4 );
+		_line.end.z = 0;
+
+		// get closest point on ray to segment
+		const param = _line.closestPointToPointParameter( _ssOrigin3, true );
+		_line.at( param, _closestPoint );
+
+		// check if the intersection point is within clip space
+		const zPos = MathUtils.lerp( _start4.z, _end4.z, param );
+		const isInClipSpace = zPos >= - 1 && zPos <= 1;
+
+		const isInside = _ssOrigin3.distanceTo( _closestPoint ) < _lineWidth * 0.5;
+
+		if ( isInClipSpace && isInside ) {
+
+			_line.start.fromBufferAttribute( instanceStart, i );
+			_line.end.fromBufferAttribute( instanceEnd, i );
+
+			_line.start.applyMatrix4( matrixWorld );
+			_line.end.applyMatrix4( matrixWorld );
+
+			const pointOnLine = new Vector3();
+			const point = new Vector3();
+
+			_ray.distanceSqToSegment( _line.start, _line.end, point, pointOnLine );
+
+			intersects.push( {
+				point: point,
+				pointOnLine: pointOnLine,
+				distance: _ray.origin.distanceTo( point ),
+				object: lineSegments,
+				face: null,
+				faceIndex: i,
+				uv: null,
+				uv1: null,
+			} );
+
+		}
+
+	}
+
+}
+
+class LineSegments2 extends Mesh {
+
+	constructor( geometry = new LineSegmentsGeometry(), material = new Line2NodeMaterial( { color: Math.random() * 0xffffff } ) ) {
+
+		super( geometry, material );
+
+		this.isLineSegments2 = true;
+
+		this.type = 'LineSegments2';
+
+	}
+
+	// for backwards-compatibility, but could be a method of LineSegmentsGeometry...
+
+	computeLineDistances() {
+
+		const geometry = this.geometry;
+
+		const instanceStart = geometry.attributes.instanceStart;
+		const instanceEnd = geometry.attributes.instanceEnd;
+		const lineDistances = new Float32Array( 2 * instanceStart.count );
+
+		for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
+
+			_start.fromBufferAttribute( instanceStart, i );
+			_end.fromBufferAttribute( instanceEnd, i );
+
+			lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
+			lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
+
+		}
+
+		const instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
+
+		geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
+		geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
+
+		return this;
+
+	}
+
+	raycast( raycaster, intersects ) {
+
+		const worldUnits = this.material.worldUnits;
+		const camera = raycaster.camera;
+
+		if ( camera === null && ! worldUnits ) {
+
+			console.error( 'LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.' );
+
+		}
+
+		const threshold = ( raycaster.params.Line2 !== undefined ) ? raycaster.params.Line2.threshold || 0 : 0;
+
+		_ray = raycaster.ray;
+
+		const matrixWorld = this.matrixWorld;
+		const geometry = this.geometry;
+		const material = this.material;
+
+		_lineWidth = material.linewidth + threshold;
+
+		// check if we intersect the sphere bounds
+		if ( geometry.boundingSphere === null ) {
+
+			geometry.computeBoundingSphere();
+
+		}
+
+		_sphere.copy( geometry.boundingSphere ).applyMatrix4( matrixWorld );
+
+		// increase the sphere bounds by the worst case line screen space width
+		let sphereMargin;
+		if ( worldUnits ) {
+
+			sphereMargin = _lineWidth * 0.5;
+
+		} else {
+
+			const distanceToSphere = Math.max( camera.near, _sphere.distanceToPoint( _ray.origin ) );
+			sphereMargin = getWorldSpaceHalfWidth( camera, distanceToSphere, material.resolution );
+
+		}
+
+		_sphere.radius += sphereMargin;
+
+		if ( _ray.intersectsSphere( _sphere ) === false ) {
+
+			return;
+
+		}
+
+		// check if we intersect the box bounds
+		if ( geometry.boundingBox === null ) {
+
+			geometry.computeBoundingBox();
+
+		}
+
+		_box.copy( geometry.boundingBox ).applyMatrix4( matrixWorld );
+
+		// increase the box bounds by the worst case line width
+		let boxMargin;
+		if ( worldUnits ) {
+
+			boxMargin = _lineWidth * 0.5;
+
+		} else {
+
+			const distanceToBox = Math.max( camera.near, _box.distanceToPoint( _ray.origin ) );
+			boxMargin = getWorldSpaceHalfWidth( camera, distanceToBox, material.resolution );
+
+		}
+
+		_box.expandByScalar( boxMargin );
+
+		if ( _ray.intersectsBox( _box ) === false ) {
+
+			return;
+
+		}
+
+		if ( worldUnits ) {
+
+			raycastWorldUnits( this, intersects );
+
+		} else {
+
+			raycastScreenSpace( this, camera, intersects );
+
+		}
+
+	}
+
+	onBeforeRender( renderer ) {
+
+		const uniforms = this.material.uniforms;
+
+		if ( uniforms && uniforms.resolution ) {
+
+			renderer.getViewport( _viewport );
+			this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
+
+		}
+
+	}
+
+}
+
+export { LineSegments2 };

+ 2 - 9
examples/jsm/loaders/MaterialXLoader.js

@@ -1,12 +1,5 @@
 import {
-	FileLoader,
-	Loader,
-	TextureLoader,
-	RepeatWrapping
-} from 'three';
-
-import {
-	MeshBasicNodeMaterial, MeshPhysicalNodeMaterial,
+	FileLoader, Loader, TextureLoader, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, RepeatWrapping,
 	float, bool, int, vec2, vec3, vec4, color, texture,
 	positionLocal, positionWorld, uv, vertexColor,
 	normalLocal, normalWorld, tangentLocal, tangentWorld,
@@ -20,7 +13,7 @@ import {
 	mx_safepower, mx_contrast,
 	mx_srgb_texture_to_lin_rec709,
 	saturation
-} from '../nodes/Nodes.js';
+} from 'three';
 
 const colorSpaceLib = {
 	mx_srgb_texture_to_lin_rec709

+ 583 - 0
examples/jsm/loaders/UltraHDRLoader.js

@@ -0,0 +1,583 @@
+import {
+	ClampToEdgeWrapping,
+	DataTexture,
+	DataUtils,
+	FileLoader,
+	HalfFloatType,
+	LinearFilter,
+	LinearMipMapLinearFilter,
+	LinearSRGBColorSpace,
+	Loader,
+	RGBAFormat,
+	UVMapping,
+} from 'three';
+
+// UltraHDR Image Format - https://developer.android.com/media/platform/hdr-image-format
+// HDR/EXR to UltraHDR Converter - https://gainmap-creator.monogrid.com/
+
+/**
+ *
+ * Short format brief:
+ *
+ *  [JPEG headers]
+ *  [XMP metadata describing the MPF container and *both* SDR and gainmap images]
+ *  [Optional metadata] [EXIF] [ICC Profile]
+ *  [SDR image]
+ *  [XMP metadata describing only the gainmap image]
+ *  [Gainmap image]
+ *
+ * Each section is separated by a 0xFFXX byte followed by a descriptor byte (0xFFE0, 0xFFE1, 0xFFE2.)
+ * Binary image storages are prefixed with a unique 0xFFD8 16-bit descriptor.
+ */
+
+/**
+ * Current feature set:
+ * - JPEG headers (required)
+ * - XMP metadata (required)
+ *  - XMP validation (not implemented)
+ * - EXIF profile (not implemented)
+ * - ICC profile (not implemented)
+ * - Binary storage for SDR & HDR images (required)
+ * - Gainmap metadata (required)
+ * - Non-JPEG image formats (not implemented)
+ * - Primary image as an HDR image (not implemented)
+ */
+
+/* Calculating this SRGB powers is extremely slow for 4K images and can be sufficiently precalculated for a 3-4x speed boost */
+const SRGB_TO_LINEAR = Array( 1024 )
+	.fill( 0 )
+	.map( ( _, value ) =>
+		Math.pow( ( value / 255 ) * 0.9478672986 + 0.0521327014, 2.4 )
+	);
+
+class UltraHDRLoader extends Loader {
+
+	constructor( manager ) {
+
+		super( manager );
+
+		this.type = HalfFloatType;
+
+	}
+
+	setDataType( value ) {
+
+		this.type = value;
+
+		return this;
+
+	}
+
+	parse( buffer, onLoad ) {
+
+		const xmpMetadata = {
+			version: null,
+			baseRenditionIsHDR: null,
+			gainMapMin: null,
+			gainMapMax: null,
+			gamma: null,
+			offsetSDR: null,
+			offsetHDR: null,
+			hdrCapacityMin: null,
+			hdrCapacityMax: null,
+		};
+		const textDecoder = new TextDecoder();
+
+		const data = new DataView( buffer );
+
+		let byteOffset = 0;
+		const sections = [];
+
+		while ( byteOffset < data.byteLength ) {
+
+			const byte = data.getUint8( byteOffset );
+
+			if ( byte === 0xff ) {
+
+				const leadingByte = data.getUint8( byteOffset + 1 );
+
+				if (
+					[
+						/* Valid section headers */
+						0xd8, // SOI
+						0xe0, // APP0
+						0xe1, // APP1
+						0xe2, // APP2
+					].includes( leadingByte )
+				) {
+
+					sections.push( {
+						sectionType: leadingByte,
+						section: [ byte, leadingByte ],
+						sectionOffset: byteOffset + 2,
+					} );
+
+					byteOffset += 2;
+
+				} else {
+
+					sections[ sections.length - 1 ].section.push( byte, leadingByte );
+
+					byteOffset += 2;
+
+				}
+
+			} else {
+
+				sections[ sections.length - 1 ].section.push( byte );
+
+				byteOffset ++;
+
+			}
+
+		}
+
+		let primaryImage, gainmapImage;
+
+		for ( let i = 0; i < sections.length; i ++ ) {
+
+			const { sectionType, section, sectionOffset } = sections[ i ];
+
+			if ( sectionType === 0xe0 ) {
+				/* JPEG Header - no useful information */
+			} else if ( sectionType === 0xe1 ) {
+
+				/* XMP Metadata */
+
+				this._parseXMPMetadata(
+					textDecoder.decode( new Uint8Array( section ) ),
+					xmpMetadata
+				);
+
+			} else if ( sectionType === 0xe2 ) {
+
+				/* Data Sections - MPF / EXIF / ICC Profile */
+
+				const sectionData = new DataView(
+					new Uint8Array( section.slice( 2 ) ).buffer
+				);
+				const sectionHeader = sectionData.getUint32( 2, false );
+
+				if ( sectionHeader === 0x4d504600 ) {
+
+					/* MPF Section */
+
+					/* Section contains a list of static bytes and ends with offsets indicating location of SDR and gainmap images */
+					/* First bytes after header indicate little / big endian ordering (0x49492A00 - LE / 0x4D4D002A - BE) */
+					/*
+					... 60 bytes indicating tags, versions, etc. ...
+
+					bytes | bits | description
+
+					4       32     primary image size
+					4       32     primary image offset
+					2       16     0x0000
+					2       16     0x0000
+
+					4       32     0x00000000
+					4       32     gainmap image size
+					4       32     gainmap image offset
+					2       16     0x0000
+					2       16     0x0000
+					*/
+
+					const mpfLittleEndian = sectionData.getUint32( 6 ) === 0x49492a00;
+					const mpfBytesOffset = 60;
+
+					/* SDR size includes the metadata length, SDR offset is always 0 */
+
+					const primaryImageSize = sectionData.getUint32(
+						mpfBytesOffset,
+						mpfLittleEndian
+					);
+					const primaryImageOffset = sectionData.getUint32(
+						mpfBytesOffset + 4,
+						mpfLittleEndian
+					);
+
+					/* Gainmap size is an absolute value starting from its offset, gainmap offset needs 6 bytes padding to take into account 0x00 bytes at the end of XMP */
+					const gainmapImageSize = sectionData.getUint32(
+						mpfBytesOffset + 16,
+						mpfLittleEndian
+					);
+					const gainmapImageOffset =
+						sectionData.getUint32( mpfBytesOffset + 20, mpfLittleEndian ) +
+						sectionOffset +
+						6;
+
+					primaryImage = new Uint8Array(
+						data.buffer,
+						primaryImageOffset,
+						primaryImageSize
+					);
+
+					gainmapImage = new Uint8Array(
+						data.buffer,
+						gainmapImageOffset,
+						gainmapImageSize
+					);
+
+				}
+
+			}
+
+		}
+
+		/* Minimal sufficient validation - https://developer.android.com/media/platform/hdr-image-format#signal_of_the_format */
+		if ( ! xmpMetadata.version ) {
+
+			throw new Error( 'THREE.UltraHDRLoader: Not a valid UltraHDR image' );
+
+		}
+
+		if ( primaryImage && gainmapImage ) {
+
+			this._applyGainmapToSDR(
+				xmpMetadata,
+				primaryImage,
+				gainmapImage,
+				( hdrBuffer, width, height ) => {
+
+					onLoad( {
+						width,
+						height,
+						data: hdrBuffer,
+						format: RGBAFormat,
+						type: this.type,
+					} );
+
+				},
+				( error ) => {
+
+					throw new Error( error );
+
+				}
+			);
+
+		} else {
+
+			throw new Error( 'THREE.UltraHDRLoader: Could not parse UltraHDR images' );
+
+		}
+
+	}
+
+	load( url, onLoad, onProgress, onError ) {
+
+		const texture = new DataTexture(
+			this.type === HalfFloatType ? new Uint16Array() : new Float32Array(),
+			0,
+			0,
+			RGBAFormat,
+			this.type,
+			UVMapping,
+			ClampToEdgeWrapping,
+			ClampToEdgeWrapping,
+			LinearFilter,
+			LinearMipMapLinearFilter,
+			1,
+			LinearSRGBColorSpace
+		);
+		texture.generateMipmaps = true;
+		texture.flipY = true;
+
+		const loader = new FileLoader( this.manager );
+		loader.setResponseType( 'arraybuffer' );
+		loader.setRequestHeader( this.requestHeader );
+		loader.setPath( this.path );
+		loader.setWithCredentials( this.withCredentials );
+		loader.load( url, ( buffer ) => {
+
+			try {
+
+				this.parse(
+					buffer,
+					( texData ) => {
+
+						texture.image = {
+							data: texData.data,
+							width: texData.width,
+							height: texData.height,
+						};
+						texture.needsUpdate = true;
+
+						if ( onLoad ) onLoad( texture, texData );
+
+					}
+				);
+
+			} catch ( error ) {
+
+				if ( onError ) onError( error );
+
+				console.error( error );
+
+			}
+
+		}, onProgress, onError );
+
+		return texture;
+
+	}
+
+	_parseXMPMetadata( xmpDataString, xmpMetadata ) {
+
+		const domParser = new DOMParser();
+
+		const xmpXml = domParser.parseFromString(
+			xmpDataString.substring(
+				xmpDataString.indexOf( '<' ),
+				xmpDataString.lastIndexOf( '>' ) + 1
+			),
+			'text/xml'
+		);
+
+		/* Determine if given XMP metadata is the primary GContainer descriptor or a gainmap descriptor */
+		const [ hasHDRContainerDescriptor ] = xmpXml.getElementsByTagName(
+			'Container:Directory'
+		);
+
+		if ( hasHDRContainerDescriptor ) {
+			/* There's not much useful information in the container descriptor besides memory-validation */
+		} else {
+
+			/* Gainmap descriptor - defaults from https://developer.android.com/media/platform/hdr-image-format#HDR_gain_map_metadata */
+
+			const [ gainmapNode ] = xmpXml.getElementsByTagName( 'rdf:Description' );
+
+			xmpMetadata.version = gainmapNode.getAttribute( 'hdrgm:Version' );
+			xmpMetadata.baseRenditionIsHDR =
+				gainmapNode.getAttribute( 'hdrgm:BaseRenditionIsHDR' ) === 'True';
+			xmpMetadata.gainMapMin = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:GainMapMin' ) || 0.0
+			);
+			xmpMetadata.gainMapMax = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:GainMapMax' ) || 1.0
+			);
+			xmpMetadata.gamma = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:Gamma' ) || 1.0
+			);
+			xmpMetadata.offsetSDR = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:OffsetSDR' ) / ( 1 / 64 )
+			);
+			xmpMetadata.offsetHDR = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:OffsetHDR' ) / ( 1 / 64 )
+			);
+			xmpMetadata.hdrCapacityMin = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:HDRCapacityMin' ) || 0.0
+			);
+			xmpMetadata.hdrCapacityMax = parseFloat(
+				gainmapNode.getAttribute( 'hdrgm:HDRCapacityMax' ) || 1.0
+			);
+
+		}
+
+	}
+
+	_srgbToLinear( value ) {
+
+		if ( value / 255 < 0.04045 ) {
+
+			return ( value / 255 ) * 0.0773993808;
+
+		}
+
+		if ( value < 1024 ) {
+
+			return SRGB_TO_LINEAR[ ~ ~ value ];
+
+		}
+
+		return Math.pow( ( value / 255 ) * 0.9478672986 + 0.0521327014, 2.4 );
+
+	}
+
+	_applyGainmapToSDR(
+		xmpMetadata,
+		sdrBuffer,
+		gainmapBuffer,
+		onSuccess,
+		onError
+	) {
+
+		const getImageDataFromBuffer = ( buffer ) =>
+			new Promise( ( resolve, reject ) => {
+
+				const imageLoader = document.createElement( 'img' );
+
+				imageLoader.onload = () => {
+
+					const image = {
+						width: imageLoader.naturalWidth,
+						height: imageLoader.naturalHeight,
+						source: imageLoader,
+					};
+
+					URL.revokeObjectURL( imageLoader.src );
+
+					resolve( image );
+
+				};
+
+				imageLoader.onerror = () => {
+
+					URL.revokeObjectURL( imageLoader.src );
+
+					reject();
+
+				};
+
+				imageLoader.src = URL.createObjectURL(
+					new Blob( [ buffer ], { type: 'image/jpeg' } )
+				);
+
+			} );
+
+		Promise.all( [
+			getImageDataFromBuffer( sdrBuffer ),
+			getImageDataFromBuffer( gainmapBuffer ),
+		] )
+			.then( ( [ sdrImage, gainmapImage ] ) => {
+
+				const sdrImageAspect = sdrImage.width / sdrImage.height;
+				const gainmapImageAspect = gainmapImage.width / gainmapImage.height;
+
+				if ( sdrImageAspect !== gainmapImageAspect ) {
+
+					onError(
+						'THREE.UltraHDRLoader Error: Aspect ratio mismatch between SDR and Gainmap images'
+					);
+
+					return;
+
+				}
+
+				const canvas = document.createElement( 'canvas' );
+				const ctx = canvas.getContext( '2d', {
+					willReadFrequently: true,
+					colorSpace: 'srgb',
+				} );
+
+				canvas.width = sdrImage.width;
+				canvas.height = sdrImage.height;
+
+				/* Use out-of-the-box interpolation of Canvas API to scale gainmap to fit the SDR resolution */
+				ctx.drawImage(
+					gainmapImage.source,
+					0,
+					0,
+					gainmapImage.width,
+					gainmapImage.height,
+					0,
+					0,
+					sdrImage.width,
+					sdrImage.height
+				);
+				const gainmapImageData = ctx.getImageData(
+					0,
+					0,
+					sdrImage.width,
+					sdrImage.height,
+					{ colorSpace: 'srgb' }
+				);
+
+				ctx.drawImage( sdrImage.source, 0, 0 );
+				const sdrImageData = ctx.getImageData(
+					0,
+					0,
+					sdrImage.width,
+					sdrImage.height,
+					{ colorSpace: 'srgb' }
+				);
+
+				/* HDR Recovery formula - https://developer.android.com/media/platform/hdr-image-format#use_the_gain_map_to_create_adapted_HDR_rendition */
+				let hdrBuffer;
+
+				if ( this.type === HalfFloatType ) {
+
+					hdrBuffer = new Uint16Array( sdrImageData.data.length ).fill( 23544 );
+
+				} else {
+
+					hdrBuffer = new Float32Array( sdrImageData.data.length ).fill( 255 );
+
+				}
+
+				const maxDisplayBoost = Math.sqrt(
+					Math.pow(
+						/* 1.8 instead of 2 near-perfectly rectifies approximations introduced by precalculated SRGB_TO_LINEAR values */
+						1.8,
+						xmpMetadata.hdrCapacityMax
+					)
+				);
+				const unclampedWeightFactor =
+					( Math.log2( maxDisplayBoost ) - xmpMetadata.hdrCapacityMin ) /
+					( xmpMetadata.hdrCapacityMax - xmpMetadata.hdrCapacityMin );
+				const weightFactor = Math.min(
+					Math.max( unclampedWeightFactor, 0.0 ),
+					1.0
+				);
+				const useGammaOne = xmpMetadata.gamma === 1.0;
+
+				for (
+					let pixelIndex = 0;
+					pixelIndex < sdrImageData.data.length;
+					pixelIndex += 4
+				) {
+
+					const x = ( pixelIndex / 4 ) % sdrImage.width;
+					const y = Math.floor( pixelIndex / 4 / sdrImage.width );
+
+					for ( let channelIndex = 0; channelIndex < 3; channelIndex ++ ) {
+
+						const sdrValue = sdrImageData.data[ pixelIndex + channelIndex ];
+
+						const gainmapIndex = ( y * sdrImage.width + x ) * 4 + channelIndex;
+						const gainmapValue = gainmapImageData.data[ gainmapIndex ] / 255.0;
+
+						/* Gamma is 1.0 by default */
+						const logRecovery = useGammaOne
+							? gainmapValue
+							: Math.pow( gainmapValue, 1.0 / xmpMetadata.gamma );
+
+						const logBoost =
+							xmpMetadata.gainMapMin * ( 1.0 - logRecovery ) +
+							xmpMetadata.gainMapMax * logRecovery;
+
+						const hdrValue =
+							( sdrValue + xmpMetadata.offsetSDR ) *
+								( logBoost * weightFactor === 0.0
+									? 1.0
+									: Math.pow( 2, logBoost * weightFactor ) ) -
+							xmpMetadata.offsetHDR;
+
+						const linearHDRValue = Math.min(
+							Math.max( this._srgbToLinear( hdrValue ), 0 ),
+							65504
+						);
+
+						hdrBuffer[ pixelIndex + channelIndex ] =
+							this.type === HalfFloatType
+								? DataUtils.toHalfFloat( linearHDRValue )
+								: linearHDRValue;
+
+					}
+
+				}
+
+				onSuccess( hdrBuffer, sdrImage.width, sdrImage.height );
+
+			} )
+			.catch( () => {
+
+				throw new Error(
+					'THREE.UltraHDRLoader Error: Could not parse UltraHDR images'
+				);
+
+			} );
+
+	}
+
+}
+
+export { UltraHDRLoader };

+ 76 - 3
examples/jsm/loaders/VTKLoader.js

@@ -447,7 +447,6 @@ class VTKLoader extends Loader {
 
 							} else {
 
-
 								indices[ indicesIndex ++ ] = strip[ j ];
 								indices[ indicesIndex ++ ] = strip[ j + 1 ];
 								indices[ indicesIndex ++ ] = strip[ j + 2 ];
@@ -620,7 +619,17 @@ class VTKLoader extends Loader {
 
 							const tmp = xmlToJson( item );
 
-							if ( tmp !== '' ) obj[ nodeName ] = tmp;
+							if ( tmp !== '' ) {
+
+								if ( Array.isArray( tmp[ '#text' ] ) ) {
+
+									tmp[ '#text' ] = tmp[ '#text' ][ 0 ];
+
+								}
+
+								obj[ nodeName ] = tmp;
+
+							}
 
 						} else {
 
@@ -633,7 +642,17 @@ class VTKLoader extends Loader {
 
 							const tmp = xmlToJson( item );
 
-							if ( tmp !== '' ) obj[ nodeName ].push( tmp );
+							if ( tmp !== '' ) {
+
+								if ( Array.isArray( tmp[ '#text' ] ) ) {
+
+									tmp[ '#text' ] = tmp[ '#text' ][ 0 ];
+
+								}
+
+								obj[ nodeName ].push( tmp );
+
+							}
 
 						}
 
@@ -894,6 +913,60 @@ class VTKLoader extends Loader {
 			let normals = [];
 			let indices = [];
 
+			if ( json.AppendedData ) {
+
+				const appendedData = json.AppendedData[ '#text' ].slice( 1 );
+				const piece = json.PolyData.Piece;
+
+				const sections = [ 'PointData', 'CellData', 'Points', 'Verts', 'Lines', 'Strips', 'Polys' ];
+				let sectionIndex = 0;
+
+				const offsets = sections.map( s => {
+
+					const sect = piece[ s ];
+
+					if ( sect && sect.DataArray ) {
+
+						const arr = Array.isArray( sect.DataArray ) ? sect.DataArray : [ sect.DataArray ];
+
+						return arr.map( a => a.attributes.offset );
+
+					}
+
+					return [];
+
+				} ).flat();
+
+				for ( const sect of sections ) {
+
+					const section = piece[ sect ];
+
+					if ( section && section.DataArray ) {
+
+						if ( Array.isArray( section.DataArray ) ) {
+
+							for ( const sectionEle of section.DataArray ) {
+
+								sectionEle[ '#text' ] = appendedData.slice( offsets[ sectionIndex ], offsets[ sectionIndex + 1 ] );
+								sectionEle.attributes.format = 'binary';
+								sectionIndex ++;
+
+							}
+
+						} else {
+
+							section.DataArray[ '#text' ] = appendedData.slice( offsets[ sectionIndex ], offsets[ sectionIndex + 1 ] );
+							section.DataArray.attributes.format = 'binary';
+							sectionIndex ++;
+
+						}
+
+					}
+
+				}
+
+			}
+
 			if ( json.PolyData ) {
 
 				const piece = json.PolyData.Piece;

+ 2 - 2
examples/jsm/misc/GPUComputationRenderer.js

@@ -46,8 +46,8 @@ import { FullScreenQuad } from '../postprocessing/Pass.js';
  * // and fill in here the texture data...
  *
  * // Add texture variables
- * const velVar = gpuCompute.addVariable( "textureVelocity", fragmentShaderVel, pos0 );
- * const posVar = gpuCompute.addVariable( "texturePosition", fragmentShaderPos, vel0 );
+ * const velVar = gpuCompute.addVariable( "textureVelocity", fragmentShaderVel, vel0 );
+ * const posVar = gpuCompute.addVariable( "texturePosition", fragmentShaderPos, pos0 );
  *
  * // Add variable dependencies
  * gpuCompute.setVariableDependencies( velVar, [ velVar, posVar ] );

+ 0 - 208
examples/jsm/nodes/Nodes.js

@@ -1,208 +0,0 @@
-// @TODO: We can simplify "export { default as SomeNode, other, exports } from '...'" to just "export * from '...'" if we will use only named exports
-// this will also solve issues like "import TempNode from '../core/Node.js'"
-
-// constants
-export * from './core/constants.js';
-
-// core
-export { default as AssignNode, assign } from './core/AssignNode.js';
-export { default as AttributeNode, attribute } from './core/AttributeNode.js';
-export { default as BypassNode, bypass } from './core/BypassNode.js';
-export { default as CacheNode, cache } from './core/CacheNode.js';
-export { default as ConstNode } from './core/ConstNode.js';
-export { default as ContextNode, context, label } from './core/ContextNode.js';
-export { default as IndexNode, vertexIndex, instanceIndex, drawIndex } from './core/IndexNode.js';
-export { default as LightingModel } from './core/LightingModel.js';
-export { default as Node, addNodeClass, createNodeFromType } from './core/Node.js';
-export { default as VarNode, temp } from './core/VarNode.js';
-export { default as NodeAttribute } from './core/NodeAttribute.js';
-export { default as NodeBuilder } from './core/NodeBuilder.js';
-export { default as NodeCache } from './core/NodeCache.js';
-export { default as NodeCode } from './core/NodeCode.js';
-export { default as NodeFrame } from './core/NodeFrame.js';
-export { default as NodeFunctionInput } from './core/NodeFunctionInput.js';
-export { default as NodeKeywords } from './core/NodeKeywords.js';
-export { default as NodeUniform } from './core/NodeUniform.js';
-export { default as NodeVar } from './core/NodeVar.js';
-export { default as NodeVarying } from './core/NodeVarying.js';
-export { default as ParameterNode, parameter } from './core/ParameterNode.js';
-export { default as PropertyNode, property, varyingProperty, output, diffuseColor, roughness, metalness, clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, shininess, dashSize, gapSize, pointWidth, alphaT, anisotropy, anisotropyB, anisotropyT } from './core/PropertyNode.js';
-export { default as StackNode, stack } from './core/StackNode.js';
-export { default as TempNode } from './core/TempNode.js';
-export { default as UniformGroupNode, uniformGroup, objectGroup, renderGroup, frameGroup } from './core/UniformGroupNode.js';
-export { default as UniformNode, uniform } from './core/UniformNode.js';
-export { default as VaryingNode, varying } from './core/VaryingNode.js';
-export { default as OutputStructNode, outputStruct } from './core/OutputStructNode.js';
-
-import * as NodeUtils from './core/NodeUtils.js';
-export { NodeUtils };
-
-// math
-export { default as MathNode, PI, PI2, EPSILON, INFINITY, radians, degrees, exp, exp2, log, log2, sqrt, inverseSqrt, floor, ceil, normalize, fract, sin, cos, tan, asin, acos, atan, abs, sign, length, lengthSq, negate, oneMinus, dFdx, dFdy, round, reciprocal, trunc, fwidth, bitcast, atan2, min, max, mod, step, reflect, distance, difference, dot, cross, pow, pow2, pow3, pow4, transformDirection, mix, clamp, saturate, refract, smoothstep, faceForward, cbrt, transpose, all, any, equals } from './math/MathNode.js';
-
-export { default as OperatorNode, add, sub, mul, div, remainder, equal, lessThan, greaterThan, lessThanEqual, greaterThanEqual, and, or, not, xor, bitAnd, bitNot, bitOr, bitXor, shiftLeft, shiftRight } from './math/OperatorNode.js';
-export { default as CondNode, cond } from './math/CondNode.js';
-export { default as HashNode, hash } from './math/HashNode.js';
-
-// math utils
-export { parabola, gain, pcurve, sinc } from './math/MathUtils.js';
-export { triNoise3D } from './math/TriNoise3D.js';
-
-// utils
-export { default as ArrayElementNode } from './utils/ArrayElementNode.js';
-export { default as ConvertNode } from './utils/ConvertNode.js';
-export { default as DiscardNode, discard, Return } from './utils/DiscardNode.js';
-export { default as EquirectUVNode, equirectUV } from './utils/EquirectUVNode.js';
-export { default as FunctionOverloadingNode, overloadingFn } from './utils/FunctionOverloadingNode.js';
-export { default as JoinNode } from './utils/JoinNode.js';
-export { default as LoopNode, loop, Continue, Break } from './utils/LoopNode.js';
-export { default as MatcapUVNode, matcapUV } from './utils/MatcapUVNode.js';
-export { default as MaxMipLevelNode, maxMipLevel } from './utils/MaxMipLevelNode.js';
-export { default as OscNode, oscSine, oscSquare, oscTriangle, oscSawtooth } from './utils/OscNode.js';
-export { default as PackingNode, directionToColor, colorToDirection } from './utils/PackingNode.js';
-export { default as RemapNode, remap, remapClamp } from './utils/RemapNode.js';
-export { default as RotateUVNode, rotateUV } from './utils/RotateUVNode.js';
-export { default as RotateNode, rotate } from './utils/RotateNode.js';
-export { default as SetNode } from './utils/SetNode.js';
-export { default as SplitNode } from './utils/SplitNode.js';
-export { default as SpriteSheetUVNode, spritesheetUV } from './utils/SpriteSheetUVNode.js';
-export { default as StorageArrayElementNode } from './utils/StorageArrayElementNode.js';
-export { default as TimerNode, timerLocal, timerGlobal, timerDelta, frameId } from './utils/TimerNode.js';
-export { default as TriplanarTexturesNode, triplanarTextures, triplanarTexture } from './utils/TriplanarTexturesNode.js';
-export { default as ReflectorNode, reflector } from './utils/ReflectorNode.js';
-
-// shadernode
-export * from './shadernode/ShaderNode.js';
-
-// accessors
-export { TBNViewMatrix, parallaxDirection, parallaxUV, transformedBentNormalView } from './accessors/AccessorsUtils.js';
-export { default as UniformsNode, uniforms } from './accessors/UniformsNode.js';
-export * from './accessors/BitangentNode.js';
-export { default as BufferAttributeNode, bufferAttribute, dynamicBufferAttribute, instancedBufferAttribute, instancedDynamicBufferAttribute } from './accessors/BufferAttributeNode.js';
-export { default as BufferNode, buffer } from './accessors/BufferNode.js';
-export * from './accessors/CameraNode.js';
-export { default as VertexColorNode, vertexColor } from './accessors/VertexColorNode.js';
-export { default as CubeTextureNode, cubeTexture } from './accessors/CubeTextureNode.js';
-export { default as InstanceNode, instance } from './accessors/InstanceNode.js';
-export { default as BatchNode, batch } from './accessors/BatchNode.js';
-export { default as MaterialNode, materialAlphaTest, materialColor, materialShininess, materialEmissive, materialOpacity, materialSpecular, materialSpecularStrength, materialReflectivity, materialRoughness, materialMetalness, materialNormal, materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialRotation, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLineScale, materialLineDashSize, materialLineGapSize, materialLineWidth, materialLineDashOffset, materialPointWidth, materialAnisotropy, materialAnisotropyVector, materialDispersion } from './accessors/MaterialNode.js';
-export { default as MaterialReferenceNode, materialReference } from './accessors/MaterialReferenceNode.js';
-export { default as RendererReferenceNode, rendererReference } from './accessors/RendererReferenceNode.js';
-export { default as MorphNode, morphReference } from './accessors/MorphNode.js';
-export { default as TextureBicubicNode, textureBicubic } from './accessors/TextureBicubicNode.js';
-export { default as ModelNode, modelDirection, modelViewMatrix, modelNormalMatrix, modelWorldMatrix, modelPosition, modelViewPosition, modelScale, modelWorldMatrixInverse } from './accessors/ModelNode.js';
-export { default as ModelViewProjectionNode, modelViewProjection } from './accessors/ModelViewProjectionNode.js';
-export * from './accessors/NormalNode.js';
-export { default as Object3DNode, objectDirection, objectViewMatrix, objectNormalMatrix, objectWorldMatrix, objectPosition, objectScale, objectViewPosition } from './accessors/Object3DNode.js';
-export { default as PointUVNode, pointUV } from './accessors/PointUVNode.js';
-export * from './accessors/PositionNode.js';
-export { default as ReferenceNode, reference, referenceBuffer } from './accessors/ReferenceNode.js';
-export * from './accessors/ReflectVectorNode.js';
-export { default as SkinningNode, skinning, skinningReference } from './accessors/SkinningNode.js';
-export { default as SceneNode, backgroundBlurriness, backgroundIntensity } from './accessors/SceneNode.js';
-export { default as StorageBufferNode, storage, storageObject } from './accessors/StorageBufferNode.js';
-export * from './accessors/TangentNode.js';
-export { default as TextureNode, texture, textureLoad, /*textureLevel,*/ sampler } from './accessors/TextureNode.js';
-export { default as TextureSizeNode, textureSize } from './accessors/TextureSizeNode.js';
-export { default as StorageTextureNode, storageTexture, textureStore } from './accessors/StorageTextureNode.js';
-export { default as Texture3DNode, texture3D } from './accessors/Texture3DNode.js';
-export * from './accessors/UVNode.js';
-export { default as UserDataNode, userData } from './accessors/UserDataNode.js';
-
-// display
-export { default as BlendModeNode, burn, dodge, overlay, screen } from './display/BlendModeNode.js';
-export { default as BumpMapNode, bumpMap } from './display/BumpMapNode.js';
-export { default as ColorAdjustmentNode, saturation, vibrance, hue, lumaCoeffs, luminance, threshold } from './display/ColorAdjustmentNode.js';
-export { default as ColorSpaceNode, linearToColorSpace, colorSpaceToLinear, linearTosRGB, sRGBToLinear } from './display/ColorSpaceNode.js';
-export { default as FrontFacingNode, frontFacing, faceDirection } from './display/FrontFacingNode.js';
-export { default as NormalMapNode, normalMap } from './display/NormalMapNode.js';
-export { default as PosterizeNode, posterize } from './display/PosterizeNode.js';
-export { default as ToneMappingNode, toneMapping } from './display/ToneMappingNode.js';
-export { default as ViewportNode, viewport, viewportCoordinate, viewportResolution, viewportTopLeft, viewportBottomLeft, viewportTopRight, viewportBottomRight } from './display/ViewportNode.js';
-export { default as ViewportTextureNode, viewportTexture, viewportMipTexture } from './display/ViewportTextureNode.js';
-export { default as ViewportSharedTextureNode, viewportSharedTexture } from './display/ViewportSharedTextureNode.js';
-export { default as ViewportDepthTextureNode, viewportDepthTexture } from './display/ViewportDepthTextureNode.js';
-export { default as ViewportDepthNode, viewZToOrthographicDepth, orthographicDepthToViewZ, viewZToPerspectiveDepth, perspectiveDepthToViewZ, depth, linearDepth, viewportLinearDepth } from './display/ViewportDepthNode.js';
-export { default as GaussianBlurNode, gaussianBlur } from './display/GaussianBlurNode.js';
-export { default as AfterImageNode, afterImage } from './display/AfterImageNode.js';
-export { default as AnamorphicNode, anamorphic } from './display/AnamorphicNode.js';
-export { default as SobelOperatorNode, sobel } from './display/SobelOperatorNode.js';
-export { default as DepthOfFieldNode, dof } from './display/DepthOfFieldNode.js';
-export { default as DotScreenNode, dotScreen } from './display/DotScreenNode.js';
-export { default as RGBShiftNode, rgbShift } from './display/RGBShiftNode.js';
-
-export { default as PassNode, pass, texturePass, depthPass } from './display/PassNode.js';
-
-// code
-export { default as ExpressionNode, expression } from './code/ExpressionNode.js';
-export { default as CodeNode, code, js, wgsl, glsl } from './code/CodeNode.js';
-export { default as FunctionCallNode, call } from './code/FunctionCallNode.js';
-export { default as FunctionNode, wgslFn, glslFn } from './code/FunctionNode.js';
-export { default as ScriptableNode, scriptable, global } from './code/ScriptableNode.js';
-export { default as ScriptableValueNode, scriptableValue } from './code/ScriptableValueNode.js';
-
-// fog
-export { default as FogNode, fog } from './fog/FogNode.js';
-export { default as FogRangeNode, rangeFog } from './fog/FogRangeNode.js';
-export { default as FogExp2Node, densityFog } from './fog/FogExp2Node.js';
-
-// geometry
-export { default as RangeNode, range } from './geometry/RangeNode.js';
-
-// gpgpu
-export { default as ComputeNode, compute } from './gpgpu/ComputeNode.js';
-
-// lighting
-export { default as LightNode, lightTargetDirection } from './lighting/LightNode.js';
-export { default as PointLightNode } from './lighting/PointLightNode.js';
-export { default as DirectionalLightNode } from './lighting/DirectionalLightNode.js';
-export { default as RectAreaLightNode } from './lighting/RectAreaLightNode.js';
-export { default as SpotLightNode } from './lighting/SpotLightNode.js';
-export { default as IESSpotLightNode } from './lighting/IESSpotLightNode.js';
-export { default as AmbientLightNode } from './lighting/AmbientLightNode.js';
-export { default as LightsNode, lights, lightsNode, addLightNode } from './lighting/LightsNode.js';
-export { default as LightingNode /* @TODO: lighting (abstract), light */ } from './lighting/LightingNode.js';
-export { default as LightingContextNode, lightingContext } from './lighting/LightingContextNode.js';
-export { default as HemisphereLightNode } from './lighting/HemisphereLightNode.js';
-export { default as EnvironmentNode } from './lighting/EnvironmentNode.js';
-export { default as IrradianceNode } from './lighting/IrradianceNode.js';
-export { default as AONode } from './lighting/AONode.js';
-export { default as AnalyticLightNode } from './lighting/AnalyticLightNode.js';
-
-// pmrem
-export { default as PMREMNode, pmremTexture } from './pmrem/PMREMNode.js';
-export * as PMREMUtils from './pmrem/PMREMUtils.js';
-
-// procedural
-export { default as CheckerNode, checker } from './procedural/CheckerNode.js';
-
-// loaders
-export { default as NodeLoader } from './loaders/NodeLoader.js';
-export { default as NodeObjectLoader } from './loaders/NodeObjectLoader.js';
-export { default as NodeMaterialLoader } from './loaders/NodeMaterialLoader.js';
-
-// parsers
-export { default as GLSLNodeParser } from './parsers/GLSLNodeParser.js'; // @TODO: Move to jsm/renderers/webgl.
-
-// materials
-export * from './materials/Materials.js';
-
-// materialX
-export * from './materialx/MaterialXNodes.js';
-
-// functions
-export { default as BRDF_GGX } from './functions/BSDF/BRDF_GGX.js';
-export { default as BRDF_Lambert } from './functions/BSDF/BRDF_Lambert.js';
-export { default as D_GGX } from './functions/BSDF/D_GGX.js';
-export { default as DFGApprox } from './functions/BSDF/DFGApprox.js';
-export { default as F_Schlick } from './functions/BSDF/F_Schlick.js';
-export { default as Schlick_to_F0 } from './functions/BSDF/Schlick_to_F0.js';
-export { default as V_GGX_SmithCorrelated } from './functions/BSDF/V_GGX_SmithCorrelated.js';
-
-export { getDistanceAttenuation } from './lighting/LightUtils.js';
-
-export { default as getGeometryRoughness } from './functions/material/getGeometryRoughness.js';
-export { default as getRoughness } from './functions/material/getRoughness.js';
-
-export { default as PhongLightingModel } from './functions/PhongLightingModel.js';
-export { default as PhysicalLightingModel } from './functions/PhysicalLightingModel.js';

+ 0 - 25
examples/jsm/nodes/accessors/AccessorsUtils.js

@@ -1,25 +0,0 @@
-import { bitangentView } from './BitangentNode.js';
-import { normalView, transformedNormalView } from './NormalNode.js';
-import { tangentView } from './TangentNode.js';
-import { mat3 } from '../shadernode/ShaderNode.js';
-import { mix } from '../math/MathNode.js';
-import { anisotropy, anisotropyB, roughness } from '../core/PropertyNode.js';
-import { positionViewDirection } from './PositionNode.js';
-
-export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
-
-export const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/;
-export const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) );
-
-export const transformedBentNormalView = ( () => {
-
-	// https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy
-
-	let bentNormal = anisotropyB.cross( positionViewDirection );
-	bentNormal = bentNormal.cross( anisotropyB ).normalize();
-	bentNormal = mix( bentNormal, transformedNormalView, anisotropy.mul( roughness.oneMinus() ).oneMinus().pow2().pow2() ).normalize();
-
-	return bentNormal;
-
-
-} )();

+ 0 - 100
examples/jsm/nodes/accessors/BatchNode.js

@@ -1,100 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { normalLocal } from './NormalNode.js';
-import { positionLocal } from './PositionNode.js';
-import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, tslFn } from '../shadernode/ShaderNode.js';
-import { textureLoad } from './TextureNode.js';
-import { textureSize } from './TextureSizeNode.js';
-import { tangentLocal } from './TangentNode.js';
-import { instanceIndex, drawIndex } from '../core/IndexNode.js';
-
-class BatchNode extends Node {
-
-	constructor( batchMesh ) {
-
-		super( 'void' );
-
-		this.batchMesh = batchMesh;
-
-
-		this.instanceColorNode = null;
-
-		this.batchingIdNode = null;
-
-	}
-
-	setup( builder ) {
-
-		// POSITION
-
-		if ( this.batchingIdNode === null ) {
-
-			if ( builder.getDrawIndex() === null ) {
-
-				this.batchingIdNode = instanceIndex;
-
-			} else {
-
-				this.batchingIdNode = drawIndex;
-
-			}
-
-		}
-
-		const getIndirectIndex = tslFn( ( [ id ] ) => {
-
-			const size = textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 );
-			const x = int( id ).remainder( int( size ) );
-			const y = int( id ).div( int( size ) );
-			return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ), null, 'uvec4' ).x;
-
-		} ).setLayout( {
-			name: 'getIndirectIndex',
-			type: 'uint',
-			inputs: [
-				{ name: 'id', type: 'int' }
-			]
-		} );
-
-		const matriceTexture = this.batchMesh._matricesTexture;
-
-		const size = textureSize( textureLoad( matriceTexture ), 0 );
-		const j = float( getIndirectIndex( int( this.batchingIdNode ) ) ).mul( 4 ).toVar();
-
-		const x = int( j.mod( size ) );
-		const y = int( j ).div( int( size ) );
-		const batchingMatrix = mat4(
-			textureLoad( matriceTexture, ivec2( x, y ) ),
-			textureLoad( matriceTexture, ivec2( x.add( 1 ), y ) ),
-			textureLoad( matriceTexture, ivec2( x.add( 2 ), y ) ),
-			textureLoad( matriceTexture, ivec2( x.add( 3 ), y ) )
-		);
-
-		const bm = mat3(
-			batchingMatrix[ 0 ].xyz,
-			batchingMatrix[ 1 ].xyz,
-			batchingMatrix[ 2 ].xyz
-		 );
-
-		positionLocal.assign( batchingMatrix.mul( positionLocal ) );
-
-		const transformedNormal = normalLocal.div( vec3( bm[ 0 ].dot( bm[ 0 ] ), bm[ 1 ].dot( bm[ 1 ] ), bm[ 2 ].dot( bm[ 2 ] ) ) );
-
-		const batchingNormal = bm.mul( transformedNormal ).xyz;
-
-		normalLocal.assign( batchingNormal );
-
-		if ( builder.hasGeometryAttribute( 'tangent' ) ) {
-
-			tangentLocal.mulAssign( bm );
-
-		}
-
-	}
-
-}
-
-export default BatchNode;
-
-export const batch = nodeProxy( BatchNode );
-
-addNodeClass( 'batch', BatchNode );

+ 0 - 13
examples/jsm/nodes/accessors/BitangentNode.js

@@ -1,13 +0,0 @@
-import { varying } from '../core/VaryingNode.js';
-import { cameraViewMatrix } from './CameraNode.js';
-import { normalGeometry, normalLocal, normalView, normalWorld, transformedNormalView } from './NormalNode.js';
-import { tangentGeometry, tangentLocal, tangentView, tangentWorld, transformedTangentView } from './TangentNode.js';
-
-const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz;
-
-export const bitangentGeometry = /*#__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' );
-export const bitangentLocal = /*#__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' );
-export const bitangentView = /*#__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' );
-export const bitangentWorld = /*#__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' );
-export const transformedBitangentView = /*#__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' );
-export const transformedBitangentWorld = /*#__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' );

+ 0 - 159
examples/jsm/nodes/accessors/BufferAttributeNode.js

@@ -1,159 +0,0 @@
-import InputNode from '../core/InputNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { varying } from '../core/VaryingNode.js';
-import { nodeObject, addNodeElement } from '../shadernode/ShaderNode.js';
-import { InterleavedBufferAttribute, InterleavedBuffer, StaticDrawUsage, DynamicDrawUsage } from 'three';
-
-class BufferAttributeNode extends InputNode {
-
-	constructor( value, bufferType = null, bufferStride = 0, bufferOffset = 0 ) {
-
-		super( value, bufferType );
-
-		this.isBufferNode = true;
-
-		this.bufferType = bufferType;
-		this.bufferStride = bufferStride;
-		this.bufferOffset = bufferOffset;
-
-		this.usage = StaticDrawUsage;
-		this.instanced = false;
-
-		this.attribute = null;
-
-		this.global = true;
-
-		if ( value && value.isBufferAttribute === true ) {
-
-			this.attribute = value;
-			this.usage = value.usage;
-			this.instanced = value.isInstancedBufferAttribute;
-
-		}
-
-	}
-
-	getHash( builder ) {
-
-		if ( this.bufferStride === 0 && this.bufferOffset === 0 ) {
-
-			let bufferData = builder.globalCache.getData( this.value );
-
-			if ( bufferData === undefined ) {
-
-				bufferData = {
-					node: this
-				};
-
-				builder.globalCache.setData( this.value, bufferData );
-
-			}
-
-			return bufferData.node.uuid;
-
-		}
-
-		return this.uuid;
-
-	}
-
-	getNodeType( builder ) {
-
-		if ( this.bufferType === null ) {
-
-			this.bufferType = builder.getTypeFromAttribute( this.attribute );
-
-		}
-
-		return this.bufferType;
-
-	}
-
-	setup( builder ) {
-
-		if ( this.attribute !== null ) return;
-
-		const type = this.getNodeType( builder );
-		const array = this.value;
-		const itemSize = builder.getTypeLength( type );
-		const stride = this.bufferStride || itemSize;
-		const offset = this.bufferOffset;
-
-		const buffer = array.isInterleavedBuffer === true ? array : new InterleavedBuffer( array, stride );
-		const bufferAttribute = new InterleavedBufferAttribute( buffer, itemSize, offset );
-
-		buffer.setUsage( this.usage );
-
-		this.attribute = bufferAttribute;
-		this.attribute.isInstancedBufferAttribute = this.instanced; // @TODO: Add a possible: InstancedInterleavedBufferAttribute
-
-	}
-
-	generate( builder ) {
-
-		const nodeType = this.getNodeType( builder );
-
-		const nodeAttribute = builder.getBufferAttributeFromNode( this, nodeType );
-		const propertyName = builder.getPropertyName( nodeAttribute );
-
-		let output = null;
-
-		if ( builder.shaderStage === 'vertex' || builder.shaderStage === 'compute' ) {
-
-			this.name = propertyName;
-
-			output = propertyName;
-
-		} else {
-
-			const nodeVarying = varying( this );
-
-			output = nodeVarying.build( builder, nodeType );
-
-		}
-
-		return output;
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'bufferAttribute';
-
-	}
-
-	setUsage( value ) {
-
-		this.usage = value;
-
-		if ( this.attribute && this.attribute.isBufferAttribute === true ) {
-
-			this.attribute.usage = value;
-
-		}
-
-		return this;
-
-	}
-
-	setInstanced( value ) {
-
-		this.instanced = value;
-
-		return this;
-
-	}
-
-}
-
-export default BufferAttributeNode;
-
-export const bufferAttribute = ( array, type, stride, offset ) => nodeObject( new BufferAttributeNode( array, type, stride, offset ) );
-export const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setUsage( DynamicDrawUsage );
-
-export const instancedBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setInstanced( true );
-export const instancedDynamicBufferAttribute = ( array, type, stride, offset ) => dynamicBufferAttribute( array, type, stride, offset ).setInstanced( true );
-
-addNodeElement( 'toAttribute', ( bufferNode ) => bufferAttribute( bufferNode.value ) );
-
-addNodeClass( 'BufferAttributeNode', BufferAttributeNode );

+ 0 - 36
examples/jsm/nodes/accessors/BufferNode.js

@@ -1,36 +0,0 @@
-import UniformNode from '../core/UniformNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-
-class BufferNode extends UniformNode {
-
-	constructor( value, bufferType, bufferCount = 0 ) {
-
-		super( value, bufferType );
-
-		this.isBufferNode = true;
-
-		this.bufferType = bufferType;
-		this.bufferCount = bufferCount;
-
-	}
-
-	getElementType( builder ) {
-
-		return this.getNodeType( builder );
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'buffer';
-
-	}
-
-}
-
-export default BufferNode;
-
-export const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) );
-
-addNodeClass( 'BufferNode', BufferNode );

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

@@ -1,19 +0,0 @@
-import { uniform } from '../core/UniformNode.js';
-import { sharedUniformGroup } from '../core/UniformGroupNode.js';
-import { Vector3 } from 'three';
-
-const cameraGroup = /*#__PURE__*/ sharedUniformGroup( 'camera' ).onRenderUpdate( () => {
-
-	cameraGroup.needsUpdate = true;
-
-} );
-
-export const cameraNear = /*#__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.near );
-export const cameraFar = /*#__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.far );
-export const cameraLogDepth = /*#__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );
-export const cameraProjectionMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix );
-export const cameraProjectionMatrixInverse = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse );
-export const cameraViewMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse );
-export const cameraWorldMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraWorldMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld );
-export const cameraNormalMatrix = /*#__PURE__*/ uniform( 'mat3' ).label( 'cameraNormalMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix );
-export const cameraPosition = /*#__PURE__*/ uniform( new Vector3() ).label( 'cameraPosition' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) );

+ 0 - 145
examples/jsm/nodes/accessors/ClippingNode.js

@@ -1,145 +0,0 @@
-
-import Node from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-import { positionView } from './PositionNode.js';
-import { diffuseColor, property } from '../core/PropertyNode.js';
-import { tslFn } from '../shadernode/ShaderNode.js';
-import { loop } from '../utils/LoopNode.js';
-import { smoothstep } from '../math/MathNode.js';
-import { uniforms } from './UniformsNode.js';
-
-class ClippingNode extends Node {
-
-	constructor( scope = ClippingNode.DEFAULT ) {
-
-		super();
-
-		this.scope = scope;
-
-	}
-
-	setup( builder ) {
-
-		super.setup( builder );
-
-		const clippingContext = builder.clippingContext;
-		const { localClipIntersection, localClippingCount, globalClippingCount } = clippingContext;
-
-		const numClippingPlanes = globalClippingCount + localClippingCount;
-		const numUnionClippingPlanes = localClipIntersection ? numClippingPlanes - localClippingCount : numClippingPlanes;
-
-		if ( this.scope === ClippingNode.ALPHA_TO_COVERAGE ) {
-
-			return this.setupAlphaToCoverage( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
-
-		} else {
-
-			return this.setupDefault( clippingContext.planes, numClippingPlanes, numUnionClippingPlanes );
-
-		}
-
-	}
-
-	setupAlphaToCoverage( planes, numClippingPlanes, numUnionClippingPlanes ) {
-
-		return tslFn( () => {
-
-			const clippingPlanes = uniforms( planes );
-
-			const distanceToPlane = property( 'float', 'distanceToPlane' );
-			const distanceGradient = property( 'float', 'distanceToGradient' );
-
-			const clipOpacity = property( 'float', 'clipOpacity' );
-
-			clipOpacity.assign( 1 );
-
-			let plane;
-
-			loop( numUnionClippingPlanes, ( { i } ) => {
-
-				plane = clippingPlanes.element( i );
-
-				distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
-				distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
-
-				clipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ) );
-
-				clipOpacity.equal( 0.0 ).discard();
-
-			} );
-
-			if ( numUnionClippingPlanes < numClippingPlanes ) {
-
-				const unionClipOpacity = property( 'float', 'unionclipOpacity' );
-
-				unionClipOpacity.assign( 1 );
-
-				loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
-
-					plane = clippingPlanes.element( i );
-
-					distanceToPlane.assign( positionView.dot( plane.xyz ).negate().add( plane.w ) );
-					distanceGradient.assign( distanceToPlane.fwidth().div( 2.0 ) );
-
-					unionClipOpacity.mulAssign( smoothstep( distanceGradient.negate(), distanceGradient, distanceToPlane ).oneMinus() );
-
-				} );
-
-				clipOpacity.mulAssign( unionClipOpacity.oneMinus() );
-
-			}
-
-			diffuseColor.a.mulAssign( clipOpacity );
-
-			diffuseColor.a.equal( 0.0 ).discard();
-
-		} )();
-
-	}
-
-	setupDefault( planes, numClippingPlanes, numUnionClippingPlanes ) {
-
-		return tslFn( () => {
-
-			const clippingPlanes = uniforms( planes );
-
-			let plane;
-
-			loop( numUnionClippingPlanes, ( { i } ) => {
-
-				plane = clippingPlanes.element( i );
-				positionView.dot( plane.xyz ).greaterThan( plane.w ).discard();
-
-			} );
-
-			if ( numUnionClippingPlanes < numClippingPlanes ) {
-
-				const clipped = property( 'bool', 'clipped' );
-
-				clipped.assign( true );
-
-				loop( { start: numUnionClippingPlanes, end: numClippingPlanes }, ( { i } ) => {
-
-					plane = clippingPlanes.element( i );
-					clipped.assign( positionView.dot( plane.xyz ).greaterThan( plane.w ).and( clipped ) );
-
-				} );
-
-				clipped.discard();
-
-			}
-
-		} )();
-
-	}
-
-}
-
-ClippingNode.ALPHA_TO_COVERAGE = 'alphaToCoverage';
-ClippingNode.DEFAULT = 'default';
-
-export default ClippingNode;
-
-export const clipping = () => nodeObject( new ClippingNode() );
-
-export const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) );

+ 0 - 61
examples/jsm/nodes/accessors/CubeTextureNode.js

@@ -1,61 +0,0 @@
-import TextureNode from './TextureNode.js';
-import { reflectVector } from './ReflectVectorNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { addNodeElement, nodeProxy, vec3 } from '../shadernode/ShaderNode.js';
-import { WebGPUCoordinateSystem } from 'three';
-
-class CubeTextureNode extends TextureNode {
-
-	constructor( value, uvNode = null, levelNode = null ) {
-
-		super( value, uvNode, levelNode );
-
-		this.isCubeTextureNode = true;
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'cubeTexture';
-
-	}
-
-	getDefaultUV() {
-
-		return reflectVector;
-
-	}
-
-	setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for CubeTextureNode
-
-	setupUV( builder, uvNode ) {
-
-		const texture = this.value;
-
-		if ( builder.renderer.coordinateSystem === WebGPUCoordinateSystem || ! texture.isRenderTargetTexture ) {
-
-			return vec3( uvNode.x.negate(), uvNode.yz );
-
-		} else {
-
-			return uvNode;
-
-		}
-
-	}
-
-	generateUV( builder, cubeUV ) {
-
-		return cubeUV.build( builder, 'vec3' );
-
-	}
-
-}
-
-export default CubeTextureNode;
-
-export const cubeTexture = nodeProxy( CubeTextureNode );
-
-addNodeElement( 'cubeTexture', cubeTexture );
-
-addNodeClass( 'CubeTextureNode', CubeTextureNode );

+ 0 - 118
examples/jsm/nodes/accessors/InstanceNode.js

@@ -1,118 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { varyingProperty } from '../core/PropertyNode.js';
-import { instancedBufferAttribute, instancedDynamicBufferAttribute } from './BufferAttributeNode.js';
-import { normalLocal } from './NormalNode.js';
-import { positionLocal } from './PositionNode.js';
-import { nodeProxy, vec3, mat3, mat4 } from '../shadernode/ShaderNode.js';
-import { DynamicDrawUsage, InstancedInterleavedBuffer, InstancedBufferAttribute } from 'three';
-import { NodeUpdateType } from '../core/constants.js';
-
-class InstanceNode extends Node {
-
-	constructor( instanceMesh ) {
-
-		super( 'void' );
-
-		this.instanceMesh = instanceMesh;
-
-		this.instanceMatrixNode = null;
-
-		this.instanceColorNode = null;
-
-		this.updateType = NodeUpdateType.FRAME;
-
-		this.buffer = null;
-		this.bufferColor = null;
-
-	}
-
-	setup( /*builder*/ ) {
-
-		let instanceMatrixNode = this.instanceMatrixNode;
-
-		const instanceMesh = this.instanceMesh;
-
-		if ( instanceMatrixNode === null ) {
-
-			const instanceAttribute = instanceMesh.instanceMatrix;
-			const buffer = new InstancedInterleavedBuffer( instanceAttribute.array, 16, 1 );
-
-			this.buffer = buffer;
-			const bufferFn = instanceAttribute.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
-
-			const instanceBuffers = [
-				// F.Signature -> bufferAttribute( array, type, stride, offset )
-				bufferFn( buffer, 'vec4', 16, 0 ),
-				bufferFn( buffer, 'vec4', 16, 4 ),
-				bufferFn( buffer, 'vec4', 16, 8 ),
-				bufferFn( buffer, 'vec4', 16, 12 )
-			];
-
-			instanceMatrixNode = mat4( ...instanceBuffers );
-
-			this.instanceMatrixNode = instanceMatrixNode;
-
-		}
-
-		const instanceColorAttribute = instanceMesh.instanceColor;
-
-		if ( instanceColorAttribute && this.instanceColorNode === null ) {
-
-			const buffer = new InstancedBufferAttribute( instanceColorAttribute.array, 3 );
-			const bufferFn = instanceColorAttribute.usage === DynamicDrawUsage ? instancedDynamicBufferAttribute : instancedBufferAttribute;
-
-			this.bufferColor = buffer;
-			this.instanceColorNode = vec3( bufferFn( buffer, 'vec3', 3, 0 ) );
-
-		}
-
-		// POSITION
-
-		const instancePosition = instanceMatrixNode.mul( positionLocal ).xyz;
-
-		// NORMAL
-
-		const m = mat3( instanceMatrixNode[ 0 ].xyz, instanceMatrixNode[ 1 ].xyz, instanceMatrixNode[ 2 ].xyz );
-
-		const transformedNormal = normalLocal.div( vec3( m[ 0 ].dot( m[ 0 ] ), m[ 1 ].dot( m[ 1 ] ), m[ 2 ].dot( m[ 2 ] ) ) );
-
-		const instanceNormal = m.mul( transformedNormal ).xyz;
-
-		// ASSIGNS
-
-		positionLocal.assign( instancePosition );
-		normalLocal.assign( instanceNormal );
-
-		// COLOR
-
-		if ( this.instanceColorNode !== null ) {
-
-			varyingProperty( 'vec3', 'vInstanceColor' ).assign( this.instanceColorNode );
-
-		}
-
-	}
-
-	update( /*frame*/ ) {
-
-		if ( this.instanceMesh.instanceMatrix.usage !== DynamicDrawUsage && this.instanceMesh.instanceMatrix.version !== this.buffer.version ) {
-
-			this.buffer.version = this.instanceMesh.instanceMatrix.version;
-
-		}
-
-		if ( this.instanceMesh.instanceColor && this.instanceMesh.instanceColor.usage !== DynamicDrawUsage && this.instanceMesh.instanceColor.version !== this.bufferColor.version ) {
-
-			this.bufferColor.version = this.instanceMesh.instanceColor.version;
-
-		}
-
-	}
-
-}
-
-export default InstanceNode;
-
-export const instance = nodeProxy( InstanceNode );
-
-addNodeClass( 'InstanceNode', InstanceNode );

+ 0 - 21
examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js

@@ -1,21 +0,0 @@
-import MaterialNode from './MaterialNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-
-class InstancedPointsMaterialNode extends MaterialNode {
-
-	setup( /*builder*/ ) {
-
-		return this.getFloat( this.scope );
-
-	}
-
-}
-
-InstancedPointsMaterialNode.POINT_WIDTH = 'pointWidth';
-
-export default InstancedPointsMaterialNode;
-
-export const materialPointWidth = nodeImmutable( InstancedPointsMaterialNode, InstancedPointsMaterialNode.POINT_WIDTH );
-
-addNodeClass( 'InstancedPointsMaterialNode', InstancedPointsMaterialNode );

+ 0 - 420
examples/jsm/nodes/accessors/MaterialNode.js

@@ -1,420 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { reference } from './ReferenceNode.js';
-import { materialReference } from './MaterialReferenceNode.js';
-import { normalView } from './NormalNode.js';
-import { nodeImmutable, float, vec2, mat2 } from '../shadernode/ShaderNode.js';
-import { uniform } from '../core/UniformNode.js';
-import { Vector2 } from 'three';
-
-const _propertyCache = new Map();
-
-class MaterialNode extends Node {
-
-	constructor( scope ) {
-
-		super();
-
-		this.scope = scope;
-
-	}
-
-	getCache( property, type ) {
-
-		let node = _propertyCache.get( property );
-
-		if ( node === undefined ) {
-
-			node = materialReference( property, type );
-
-			_propertyCache.set( property, node );
-
-		}
-
-		return node;
-
-	}
-
-	getFloat( property ) {
-
-		return this.getCache( property, 'float' );
-
-	}
-
-	getColor( property ) {
-
-		return this.getCache( property, 'color' );
-
-	}
-
-	getTexture( property ) {
-
-		return this.getCache( property === 'map' ? 'map' : property + 'Map', 'texture' );
-
-	}
-
-	setup( builder ) {
-
-		const material = builder.context.material;
-		const scope = this.scope;
-
-		let node = null;
-
-		if ( scope === MaterialNode.COLOR ) {
-
-			const colorNode = this.getColor( scope );
-
-			if ( material.map && material.map.isTexture === true ) {
-
-				node = colorNode.mul( this.getTexture( 'map' ) );
-
-			} else {
-
-				node = colorNode;
-
-			}
-
-		} else if ( scope === MaterialNode.OPACITY ) {
-
-			const opacityNode = this.getFloat( scope );
-
-			if ( material.alphaMap && material.alphaMap.isTexture === true ) {
-
-				node = opacityNode.mul( this.getTexture( 'alpha' ) );
-
-			} else {
-
-				node = opacityNode;
-
-			}
-
-		} else if ( scope === MaterialNode.SPECULAR_STRENGTH ) {
-
-			if ( material.specularMap && material.specularMap.isTexture === true ) {
-
-				node = this.getTexture( 'specular' ).r;
-
-			} else {
-
-				node = float( 1 );
-
-			}
-
-		} else if ( scope === MaterialNode.SPECULAR_INTENSITY ) {
-
-			const specularIntensity = this.getFloat( scope );
-
-			if ( material.specularMap ) {
-
-				node = specularIntensity.mul( this.getTexture( scope ).a );
-
-			} else {
-
-				node = specularIntensity;
-
-			}
-
-		} else if ( scope === MaterialNode.SPECULAR_COLOR ) {
-
-			const specularColorNode = this.getColor( scope );
-
-			if ( material.specularColorMap && material.specularColorMap.isTexture === true ) {
-
-				node = specularColorNode.mul( this.getTexture( scope ).rgb );
-
-			} else {
-
-				node = specularColorNode;
-
-			}
-
-		} else if ( scope === MaterialNode.ROUGHNESS ) { // TODO: cleanup similar branches
-
-			const roughnessNode = this.getFloat( scope );
-
-			if ( material.roughnessMap && material.roughnessMap.isTexture === true ) {
-
-				node = roughnessNode.mul( this.getTexture( scope ).g );
-
-			} else {
-
-				node = roughnessNode;
-
-			}
-
-		} else if ( scope === MaterialNode.METALNESS ) {
-
-			const metalnessNode = this.getFloat( scope );
-
-			if ( material.metalnessMap && material.metalnessMap.isTexture === true ) {
-
-				node = metalnessNode.mul( this.getTexture( scope ).b );
-
-			} else {
-
-				node = metalnessNode;
-
-			}
-
-		} else if ( scope === MaterialNode.EMISSIVE ) {
-
-			const emissiveNode = this.getColor( scope );
-
-			if ( material.emissiveMap && material.emissiveMap.isTexture === true ) {
-
-				node = emissiveNode.mul( this.getTexture( scope ) );
-
-			} else {
-
-				node = emissiveNode;
-
-			}
-
-		} else if ( scope === MaterialNode.NORMAL ) {
-
-			if ( material.normalMap ) {
-
-				node = this.getTexture( 'normal' ).normalMap( this.getCache( 'normalScale', 'vec2' ) );
-
-			} else if ( material.bumpMap ) {
-
-				node = this.getTexture( 'bump' ).r.bumpMap( this.getFloat( 'bumpScale' ) );
-
-			} else {
-
-				node = normalView;
-
-			}
-
-		} else if ( scope === MaterialNode.CLEARCOAT ) {
-
-			const clearcoatNode = this.getFloat( scope );
-
-			if ( material.clearcoatMap && material.clearcoatMap.isTexture === true ) {
-
-				node = clearcoatNode.mul( this.getTexture( scope ).r );
-
-			} else {
-
-				node = clearcoatNode;
-
-			}
-
-		} else if ( scope === MaterialNode.CLEARCOAT_ROUGHNESS ) {
-
-			const clearcoatRoughnessNode = this.getFloat( scope );
-
-			if ( material.clearcoatRoughnessMap && material.clearcoatRoughnessMap.isTexture === true ) {
-
-				node = clearcoatRoughnessNode.mul( this.getTexture( scope ).r );
-
-			} else {
-
-				node = clearcoatRoughnessNode;
-
-			}
-
-		} else if ( scope === MaterialNode.CLEARCOAT_NORMAL ) {
-
-			if ( material.clearcoatNormalMap ) {
-
-				node = this.getTexture( scope ).normalMap( this.getCache( scope + 'Scale', 'vec2' ) );
-
-			} else {
-
-				node = normalView;
-
-			}
-
-		} else if ( scope === MaterialNode.SHEEN ) {
-
-			const sheenNode = this.getColor( 'sheenColor' ).mul( this.getFloat( 'sheen' ) ); // Move this mul() to CPU
-
-			if ( material.sheenColorMap && material.sheenColorMap.isTexture === true ) {
-
-				node = sheenNode.mul( this.getTexture( 'sheenColor' ).rgb );
-
-			} else {
-
-				node = sheenNode;
-
-			}
-
-		} else if ( scope === MaterialNode.SHEEN_ROUGHNESS ) {
-
-			const sheenRoughnessNode = this.getFloat( scope );
-
-			if ( material.sheenRoughnessMap && material.sheenRoughnessMap.isTexture === true ) {
-
-				node = sheenRoughnessNode.mul( this.getTexture( scope ).a );
-
-			} else {
-
-				node = sheenRoughnessNode;
-
-			}
-
-			node = node.clamp( 0.07, 1.0 );
-
-		} else if ( scope === MaterialNode.ANISOTROPY ) {
-
-			if ( material.anisotropyMap && material.anisotropyMap.isTexture === true ) {
-
-				const anisotropyPolar = this.getTexture( scope );
-				const anisotropyMat = mat2( materialAnisotropyVector.x, materialAnisotropyVector.y, materialAnisotropyVector.y.negate(), materialAnisotropyVector.x );
-
-				node = anisotropyMat.mul( anisotropyPolar.rg.mul( 2.0 ).sub( vec2( 1.0 ) ).normalize().mul( anisotropyPolar.b ) );
-
-			} else {
-
-				node = materialAnisotropyVector;
-
-			}
-
-		} else if ( scope === MaterialNode.IRIDESCENCE_THICKNESS ) {
-
-			const iridescenceThicknessMaximum = reference( '1', 'float', material.iridescenceThicknessRange );
-
-			if ( material.iridescenceThicknessMap ) {
-
-				const iridescenceThicknessMinimum = reference( '0', 'float', material.iridescenceThicknessRange );
-
-				node = iridescenceThicknessMaximum.sub( iridescenceThicknessMinimum ).mul( this.getTexture( scope ).g ).add( iridescenceThicknessMinimum );
-
-			} else {
-
-				node = iridescenceThicknessMaximum;
-
-			}
-
-		} else if ( scope === MaterialNode.TRANSMISSION ) {
-
-			const transmissionNode = this.getFloat( scope );
-
-			if ( material.transmissionMap ) {
-
-				node = transmissionNode.mul( this.getTexture( scope ).r );
-
-			} else {
-
-				node = transmissionNode;
-
-			}
-
-		} else if ( scope === MaterialNode.THICKNESS ) {
-
-			const thicknessNode = this.getFloat( scope );
-
-			if ( material.thicknessMap ) {
-
-				node = thicknessNode.mul( this.getTexture( scope ).g );
-
-			} else {
-
-				node = thicknessNode;
-
-			}
-
-		} else if ( scope === MaterialNode.IOR ) {
-
-			node = this.getFloat( scope );
-
-		} else {
-
-			const outputType = this.getNodeType( builder );
-
-			node = this.getCache( scope, outputType );
-
-		}
-
-		return node;
-
-	}
-
-}
-
-MaterialNode.ALPHA_TEST = 'alphaTest';
-MaterialNode.COLOR = 'color';
-MaterialNode.OPACITY = 'opacity';
-MaterialNode.SHININESS = 'shininess';
-MaterialNode.SPECULAR = 'specular';
-MaterialNode.SPECULAR_STRENGTH = 'specularStrength';
-MaterialNode.SPECULAR_INTENSITY = 'specularIntensity';
-MaterialNode.SPECULAR_COLOR = 'specularColor';
-MaterialNode.REFLECTIVITY = 'reflectivity';
-MaterialNode.ROUGHNESS = 'roughness';
-MaterialNode.METALNESS = 'metalness';
-MaterialNode.NORMAL = 'normal';
-MaterialNode.CLEARCOAT = 'clearcoat';
-MaterialNode.CLEARCOAT_ROUGHNESS = 'clearcoatRoughness';
-MaterialNode.CLEARCOAT_NORMAL = 'clearcoatNormal';
-MaterialNode.EMISSIVE = 'emissive';
-MaterialNode.ROTATION = 'rotation';
-MaterialNode.SHEEN = 'sheen';
-MaterialNode.SHEEN_ROUGHNESS = 'sheenRoughness';
-MaterialNode.ANISOTROPY = 'anisotropy';
-MaterialNode.IRIDESCENCE = 'iridescence';
-MaterialNode.IRIDESCENCE_IOR = 'iridescenceIOR';
-MaterialNode.IRIDESCENCE_THICKNESS = 'iridescenceThickness';
-MaterialNode.IOR = 'ior';
-MaterialNode.TRANSMISSION = 'transmission';
-MaterialNode.THICKNESS = 'thickness';
-MaterialNode.ATTENUATION_DISTANCE = 'attenuationDistance';
-MaterialNode.ATTENUATION_COLOR = 'attenuationColor';
-MaterialNode.LINE_SCALE = 'scale';
-MaterialNode.LINE_DASH_SIZE = 'dashSize';
-MaterialNode.LINE_GAP_SIZE = 'gapSize';
-MaterialNode.LINE_WIDTH = 'linewidth';
-MaterialNode.LINE_DASH_OFFSET = 'dashOffset';
-MaterialNode.POINT_WIDTH = 'pointWidth';
-MaterialNode.DISPERSION = 'dispersion';
-
-export default MaterialNode;
-
-export const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST );
-export const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR );
-export const materialShininess = nodeImmutable( MaterialNode, MaterialNode.SHININESS );
-export const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE );
-export const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY );
-export const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR );
-
-export const materialSpecularIntensity = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY );
-export const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR );
-
-export const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH );
-export const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY );
-export const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS );
-export const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS );
-export const materialNormal = nodeImmutable( MaterialNode, MaterialNode.NORMAL );
-export const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT );
-export const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS );
-export const materialClearcoatNormal = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL );
-export const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION );
-export const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN );
-export const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS );
-export const materialAnisotropy = nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY );
-export const materialIridescence = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE );
-export const materialIridescenceIOR = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR );
-export const materialIridescenceThickness = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS );
-export const materialTransmission = nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION );
-export const materialThickness = nodeImmutable( MaterialNode, MaterialNode.THICKNESS );
-export const materialIOR = nodeImmutable( MaterialNode, MaterialNode.IOR );
-export const materialAttenuationDistance = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE );
-export const materialAttenuationColor = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR );
-export const materialLineScale = nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE );
-export const materialLineDashSize = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE );
-export const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE );
-export const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH );
-export const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET );
-export const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH );
-export const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION );
-export const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) {
-
-	return frame.material;
-
-} ).onRenderUpdate( function ( { material } ) {
-
-	this.value.set( material.anisotropy * Math.cos( material.anisotropyRotation ), material.anisotropy * Math.sin( material.anisotropyRotation ) );
-
-} );
-
-addNodeClass( 'MaterialNode', MaterialNode );

+ 0 - 41
examples/jsm/nodes/accessors/MaterialReferenceNode.js

@@ -1,41 +0,0 @@
-import ReferenceNode from './ReferenceNode.js';
-//import { renderGroup } from '../core/UniformGroupNode.js';
-//import { NodeUpdateType } from '../core/constants.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-
-class MaterialReferenceNode extends ReferenceNode {
-
-	constructor( property, inputType, material = null ) {
-
-		super( property, inputType, material );
-
-		this.material = material;
-
-		//this.updateType = NodeUpdateType.RENDER;
-
-	}
-
-	/*setNodeType( node ) {
-
-		super.setNodeType( node );
-
-		this.node.groupNode = renderGroup;
-
-	}*/
-
-	updateReference( state ) {
-
-		this.reference = this.material !== null ? this.material : state.material;
-
-		return this.reference;
-
-	}
-
-}
-
-export default MaterialReferenceNode;
-
-export const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) );
-
-addNodeClass( 'MaterialReferenceNode', MaterialReferenceNode );

+ 0 - 36
examples/jsm/nodes/accessors/ModelNode.js

@@ -1,36 +0,0 @@
-import Object3DNode from './Object3DNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-import { uniform } from '../core/UniformNode.js';
-import { Matrix4 } from 'three';
-
-class ModelNode extends Object3DNode {
-
-	constructor( scope = ModelNode.VIEW_MATRIX ) {
-
-		super( scope );
-
-	}
-
-	update( frame ) {
-
-		this.object3d = frame.object;
-
-		super.update( frame );
-
-	}
-
-}
-
-export default ModelNode;
-
-export const modelDirection = nodeImmutable( ModelNode, ModelNode.DIRECTION );
-export const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).label( 'modelViewMatrix' ).temp( 'ModelViewMatrix' );
-export const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX );
-export const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX );
-export const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION );
-export const modelScale = nodeImmutable( ModelNode, ModelNode.SCALE );
-export const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION );
-export const modelWorldMatrixInverse = uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() );
-
-addNodeClass( 'ModelNode', ModelNode );

+ 0 - 39
examples/jsm/nodes/accessors/ModelViewProjectionNode.js

@@ -1,39 +0,0 @@
-import { addNodeClass } from '../core/Node.js';
-import TempNode from '../core/TempNode.js';
-import { cameraProjectionMatrix } from './CameraNode.js';
-import { modelViewMatrix } from './ModelNode.js';
-import { positionLocal } from './PositionNode.js';
-import { nodeProxy } from '../shadernode/ShaderNode.js';
-import { varying } from '../core/VaryingNode.js';
-
-class ModelViewProjectionNode extends TempNode {
-
-	constructor( positionNode = null ) {
-
-		super( 'vec4' );
-
-		this.positionNode = positionNode;
-
-	}
-
-	setup( builder ) {
-
-		if ( builder.shaderStage === 'fragment' ) {
-
-			return varying( builder.context.mvp );
-
-		}
-
-		const position = this.positionNode || positionLocal;
-
-		return cameraProjectionMatrix.mul( modelViewMatrix ).mul( position );
-
-	}
-
-}
-
-export default ModelViewProjectionNode;
-
-export const modelViewProjection = nodeProxy( ModelViewProjectionNode );
-
-addNodeClass( 'ModelViewProjectionNode', ModelViewProjectionNode );

+ 0 - 255
examples/jsm/nodes/accessors/MorphNode.js

@@ -1,255 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { NodeUpdateType } from '../core/constants.js';
-import { float, nodeProxy, tslFn } from '../shadernode/ShaderNode.js';
-import { uniform } from '../core/UniformNode.js';
-import { reference } from './ReferenceNode.js';
-import { positionLocal } from './PositionNode.js';
-import { normalLocal } from './NormalNode.js';
-import { textureLoad } from './TextureNode.js';
-import { instanceIndex, vertexIndex } from '../core/IndexNode.js';
-import { ivec2, int } from '../shadernode/ShaderNode.js';
-import { DataArrayTexture, Vector2, Vector4, FloatType } from 'three';
-import { loop } from '../utils/LoopNode.js';
-
-const morphTextures = new WeakMap();
-const morphVec4 = new Vector4();
-
-const getMorph = tslFn( ( { bufferMap, influence, stride, width, depth, offset } ) => {
-
-	const texelIndex = int( vertexIndex ).mul( stride ).add( offset );
-
-	const y = texelIndex.div( width );
-	const x = texelIndex.sub( y.mul( width ) );
-
-	const bufferAttrib = textureLoad( bufferMap, ivec2( x, y ) ).depth( depth );
-
-	return bufferAttrib.mul( influence );
-
-} );
-
-function getEntry( geometry ) {
-
-	const hasMorphPosition = geometry.morphAttributes.position !== undefined;
-	const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
-	const hasMorphColors = geometry.morphAttributes.color !== undefined;
-
-	// instead of using attributes, the WebGL 2 code path encodes morph targets
-	// into an array of data textures. Each layer represents a single morph target.
-
-	const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
-	const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
-
-	let entry = morphTextures.get( geometry );
-
-	if ( entry === undefined || entry.count !== morphTargetsCount ) {
-
-		if ( entry !== undefined ) entry.texture.dispose();
-
-		const morphTargets = geometry.morphAttributes.position || [];
-		const morphNormals = geometry.morphAttributes.normal || [];
-		const morphColors = geometry.morphAttributes.color || [];
-
-		let vertexDataCount = 0;
-
-		if ( hasMorphPosition === true ) vertexDataCount = 1;
-		if ( hasMorphNormals === true ) vertexDataCount = 2;
-		if ( hasMorphColors === true ) vertexDataCount = 3;
-
-		let width = geometry.attributes.position.count * vertexDataCount;
-		let height = 1;
-
-		const maxTextureSize = 4096; // @TODO: Use 'capabilities.maxTextureSize'
-
-		if ( width > maxTextureSize ) {
-
-			height = Math.ceil( width / maxTextureSize );
-			width = maxTextureSize;
-
-		}
-
-		const buffer = new Float32Array( width * height * 4 * morphTargetsCount );
-
-		const bufferTexture = new DataArrayTexture( buffer, width, height, morphTargetsCount );
-		bufferTexture.type = FloatType;
-		bufferTexture.needsUpdate = true;
-
-		// fill buffer
-
-		const vertexDataStride = vertexDataCount * 4;
-
-		for ( let i = 0; i < morphTargetsCount; i ++ ) {
-
-			const morphTarget = morphTargets[ i ];
-			const morphNormal = morphNormals[ i ];
-			const morphColor = morphColors[ i ];
-
-			const offset = width * height * 4 * i;
-
-			for ( let j = 0; j < morphTarget.count; j ++ ) {
-
-				const stride = j * vertexDataStride;
-
-				if ( hasMorphPosition === true ) {
-
-					morphVec4.fromBufferAttribute( morphTarget, j );
-
-					buffer[ offset + stride + 0 ] = morphVec4.x;
-					buffer[ offset + stride + 1 ] = morphVec4.y;
-					buffer[ offset + stride + 2 ] = morphVec4.z;
-					buffer[ offset + stride + 3 ] = 0;
-
-				}
-
-				if ( hasMorphNormals === true ) {
-
-					morphVec4.fromBufferAttribute( morphNormal, j );
-
-					buffer[ offset + stride + 4 ] = morphVec4.x;
-					buffer[ offset + stride + 5 ] = morphVec4.y;
-					buffer[ offset + stride + 6 ] = morphVec4.z;
-					buffer[ offset + stride + 7 ] = 0;
-
-				}
-
-				if ( hasMorphColors === true ) {
-
-					morphVec4.fromBufferAttribute( morphColor, j );
-
-					buffer[ offset + stride + 8 ] = morphVec4.x;
-					buffer[ offset + stride + 9 ] = morphVec4.y;
-					buffer[ offset + stride + 10 ] = morphVec4.z;
-					buffer[ offset + stride + 11 ] = ( morphColor.itemSize === 4 ) ? morphVec4.w : 1;
-
-				}
-
-			}
-
-		}
-
-		entry = {
-			count: morphTargetsCount,
-			texture: bufferTexture,
-			stride: vertexDataCount,
-			size: new Vector2( width, height )
-		};
-
-		morphTextures.set( geometry, entry );
-
-		function disposeTexture() {
-
-			bufferTexture.dispose();
-
-			morphTextures.delete( geometry );
-
-			geometry.removeEventListener( 'dispose', disposeTexture );
-
-		}
-
-		geometry.addEventListener( 'dispose', disposeTexture );
-
-	}
-
-	return entry;
-
-}
-
-
-class MorphNode extends Node {
-
-	constructor( mesh ) {
-
-		super( 'void' );
-
-		this.mesh = mesh;
-		this.morphBaseInfluence = uniform( 1 );
-
-		this.updateType = NodeUpdateType.OBJECT;
-
-	}
-
-	setup( builder ) {
-
-		const { geometry } = builder;
-
-		const hasMorphPosition = geometry.morphAttributes.position !== undefined;
-		const hasMorphNormals = geometry.morphAttributes.normal !== undefined;
-
-		const morphAttribute = geometry.morphAttributes.position || geometry.morphAttributes.normal || geometry.morphAttributes.color;
-		const morphTargetsCount = ( morphAttribute !== undefined ) ? morphAttribute.length : 0;
-
-		// nodes
-
-		const { texture: bufferMap, stride, size } = getEntry( geometry );
-
-		if ( hasMorphPosition === true ) positionLocal.mulAssign( this.morphBaseInfluence );
-		if ( hasMorphNormals === true ) normalLocal.mulAssign( this.morphBaseInfluence );
-
-		const width = int( size.width );
-
-		loop( morphTargetsCount, ( { i } ) => {
-
-			const influence = float( 0 ).toVar();
-
-			if ( this.mesh.count > 1 && ( this.mesh.morphTexture !== null && this.mesh.morphTexture !== undefined ) ) {
-
-				influence.assign( textureLoad( this.mesh.morphTexture, ivec2( int( i ).add( 1 ), int( instanceIndex ) ) ).r );
-
-			} else {
-
-				influence.assign( reference( 'morphTargetInfluences', 'float' ).element( i ).toVar() );
-
-			}
-
-			if ( hasMorphPosition === true ) {
-
-				positionLocal.addAssign( getMorph( {
-					bufferMap,
-					influence,
-					stride,
-					width,
-					depth: i,
-					offset: int( 0 )
-				} ) );
-
-			}
-
-			if ( hasMorphNormals === true ) {
-
-				normalLocal.addAssign( getMorph( {
-					bufferMap,
-					influence,
-					stride,
-					width,
-					depth: i,
-					offset: int( 1 )
-				} ) );
-
-			}
-
-		} );
-
-	}
-
-	update() {
-
-		const morphBaseInfluence = this.morphBaseInfluence;
-
-		if ( this.mesh.geometry.morphTargetsRelative ) {
-
-			morphBaseInfluence.value = 1;
-
-		} else {
-
-			morphBaseInfluence.value = 1 - this.mesh.morphTargetInfluences.reduce( ( a, b ) => a + b, 0 );
-
-		}
-
-	}
-
-}
-
-export default MorphNode;
-
-export const morphReference = nodeProxy( MorphNode );
-
-addNodeClass( 'MorphNode', MorphNode );

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

@@ -1,14 +0,0 @@
-import { attribute } from '../core/AttributeNode.js';
-import { varying } from '../core/VaryingNode.js';
-import { property } from '../core/PropertyNode.js';
-import { cameraViewMatrix } from './CameraNode.js';
-import { modelNormalMatrix } from './ModelNode.js';
-import { vec3 } from '../shadernode/ShaderNode.js';
-
-export const normalGeometry = /*#__PURE__*/ attribute( 'normal', 'vec3', vec3( 0, 1, 0 ) );
-export const normalLocal = /*#__PURE__*/ normalGeometry.toVar( 'normalLocal' );
-export const normalView = /*#__PURE__*/ varying( modelNormalMatrix.mul( normalLocal ), 'v_normalView' ).normalize().toVar( 'normalView' );
-export const normalWorld = /*#__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'v_normalWorld' ).normalize().toVar( 'transformedNormalWorld' );
-export const transformedNormalView = /*#__PURE__*/ property( 'vec3', 'transformedNormalView' );
-export const transformedNormalWorld = /*#__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' );
-export const transformedClearcoatNormalView = /*#__PURE__*/ property( 'vec3', 'transformedClearcoatNormalView' );

+ 0 - 150
examples/jsm/nodes/accessors/Object3DNode.js

@@ -1,150 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { NodeUpdateType } from '../core/constants.js';
-import UniformNode from '../core/UniformNode.js';
-import { nodeProxy } from '../shadernode/ShaderNode.js';
-
-import { Vector3 } from 'three';
-
-class Object3DNode extends Node {
-
-	constructor( scope = Object3DNode.VIEW_MATRIX, object3d = null ) {
-
-		super();
-
-		this.scope = scope;
-		this.object3d = object3d;
-
-		this.updateType = NodeUpdateType.OBJECT;
-
-		this._uniformNode = new UniformNode( null );
-
-	}
-
-	getNodeType() {
-
-		const scope = this.scope;
-
-		if ( scope === Object3DNode.WORLD_MATRIX || scope === Object3DNode.VIEW_MATRIX ) {
-
-			return 'mat4';
-
-		} else if ( scope === Object3DNode.NORMAL_MATRIX ) {
-
-			return 'mat3';
-
-		} else if ( scope === Object3DNode.POSITION || scope === Object3DNode.VIEW_POSITION || scope === Object3DNode.DIRECTION || scope === Object3DNode.SCALE ) {
-
-			return 'vec3';
-
-		}
-
-	}
-
-	update( frame ) {
-
-		const object = this.object3d;
-		const uniformNode = this._uniformNode;
-		const scope = this.scope;
-
-		if ( scope === Object3DNode.VIEW_MATRIX ) {
-
-			uniformNode.value = object.modelViewMatrix;
-
-		} else if ( scope === Object3DNode.NORMAL_MATRIX ) {
-
-			uniformNode.value = object.normalMatrix;
-
-		} else if ( scope === Object3DNode.WORLD_MATRIX ) {
-
-			uniformNode.value = object.matrixWorld;
-
-		} else if ( scope === Object3DNode.POSITION ) {
-
-			uniformNode.value = uniformNode.value || new Vector3();
-
-			uniformNode.value.setFromMatrixPosition( object.matrixWorld );
-
-		} else if ( scope === Object3DNode.SCALE ) {
-
-			uniformNode.value = uniformNode.value || new Vector3();
-
-			uniformNode.value.setFromMatrixScale( object.matrixWorld );
-
-		} else if ( scope === Object3DNode.DIRECTION ) {
-
-			uniformNode.value = uniformNode.value || new Vector3();
-
-			object.getWorldDirection( uniformNode.value );
-
-		} else if ( scope === Object3DNode.VIEW_POSITION ) {
-
-			const camera = frame.camera;
-
-			uniformNode.value = uniformNode.value || new Vector3();
-			uniformNode.value.setFromMatrixPosition( object.matrixWorld );
-
-			uniformNode.value.applyMatrix4( camera.matrixWorldInverse );
-
-		}
-
-	}
-
-	generate( builder ) {
-
-		const scope = this.scope;
-
-		if ( scope === Object3DNode.WORLD_MATRIX || scope === Object3DNode.VIEW_MATRIX ) {
-
-			this._uniformNode.nodeType = 'mat4';
-
-		} else if ( scope === Object3DNode.NORMAL_MATRIX ) {
-
-			this._uniformNode.nodeType = 'mat3';
-
-		} else if ( scope === Object3DNode.POSITION || scope === Object3DNode.VIEW_POSITION || scope === Object3DNode.DIRECTION || scope === Object3DNode.SCALE ) {
-
-			this._uniformNode.nodeType = 'vec3';
-
-		}
-
-		return this._uniformNode.build( builder );
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.scope = this.scope;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		this.scope = data.scope;
-
-	}
-
-}
-
-Object3DNode.VIEW_MATRIX = 'viewMatrix';
-Object3DNode.NORMAL_MATRIX = 'normalMatrix';
-Object3DNode.WORLD_MATRIX = 'worldMatrix';
-Object3DNode.POSITION = 'position';
-Object3DNode.SCALE = 'scale';
-Object3DNode.VIEW_POSITION = 'viewPosition';
-Object3DNode.DIRECTION = 'direction';
-
-export default Object3DNode;
-
-export const objectDirection = nodeProxy( Object3DNode, Object3DNode.DIRECTION );
-export const objectViewMatrix = nodeProxy( Object3DNode, Object3DNode.VIEW_MATRIX );
-export const objectNormalMatrix = nodeProxy( Object3DNode, Object3DNode.NORMAL_MATRIX );
-export const objectWorldMatrix = nodeProxy( Object3DNode, Object3DNode.WORLD_MATRIX );
-export const objectPosition = nodeProxy( Object3DNode, Object3DNode.POSITION );
-export const objectScale = nodeProxy( Object3DNode, Object3DNode.SCALE );
-export const objectViewPosition = nodeProxy( Object3DNode, Object3DNode.VIEW_POSITION );
-
-addNodeClass( 'Object3DNode', Object3DNode );

+ 0 - 26
examples/jsm/nodes/accessors/PointUVNode.js

@@ -1,26 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-
-class PointUVNode extends Node {
-
-	constructor() {
-
-		super( 'vec2' );
-
-		this.isPointUVNode = true;
-
-	}
-
-	generate( /*builder*/ ) {
-
-		return 'vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )';
-
-	}
-
-}
-
-export default PointUVNode;
-
-export const pointUV = nodeImmutable( PointUVNode );
-
-addNodeClass( 'PointUVNode', PointUVNode );

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

@@ -1,10 +0,0 @@
-import { attribute } from '../core/AttributeNode.js';
-import { varying } from '../core/VaryingNode.js';
-import { modelWorldMatrix, modelViewMatrix } from './ModelNode.js';
-
-export const positionGeometry = /*#__PURE__*/ attribute( 'position', 'vec3' );
-export const positionLocal = /*#__PURE__*/ positionGeometry.toVar( 'positionLocal' );
-export const positionWorld = /*#__PURE__*/ varying( modelWorldMatrix.mul( positionLocal ).xyz, 'v_positionWorld' );
-export const positionWorldDirection = /*#__PURE__*/ varying( positionLocal.transformDirection( modelWorldMatrix ), 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' );
-export const positionView = /*#__PURE__*/ varying( modelViewMatrix.mul( positionLocal ).xyz, 'v_positionView' );
-export const positionViewDirection = /*#__PURE__*/ varying( positionView.negate(), 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' );

+ 0 - 166
examples/jsm/nodes/accessors/ReferenceNode.js

@@ -1,166 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { NodeUpdateType } from '../core/constants.js';
-import { uniform } from '../core/UniformNode.js';
-import { texture } from './TextureNode.js';
-import { buffer } from './BufferNode.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-import { uniforms } from './UniformsNode.js';
-import ArrayElementNode from '../utils/ArrayElementNode.js';
-
-class ReferenceElementNode extends ArrayElementNode {
-
-	constructor( referenceNode, indexNode ) {
-
-		super( referenceNode, indexNode );
-
-		this.referenceNode = referenceNode;
-
-		this.isReferenceElementNode = true;
-
-	}
-
-	getNodeType() {
-
-		return this.referenceNode.uniformType;
-
-	}
-
-	generate( builder ) {
-
-		const snippet = super.generate( builder );
-		const arrayType = this.referenceNode.getNodeType();
-		const elementType = this.getNodeType();
-
-		return builder.format( snippet, arrayType, elementType );
-
-	}
-
-}
-
-class ReferenceNode extends Node {
-
-	constructor( property, uniformType, object = null, count = null ) {
-
-		super();
-
-		this.property = property;
-		this.uniformType = uniformType;
-		this.object = object;
-		this.count = count;
-
-		this.properties = property.split( '.' );
-		this.reference = null;
-		this.node = null;
-
-		this.updateType = NodeUpdateType.OBJECT;
-
-	}
-
-	element( indexNode ) {
-
-		return nodeObject( new ReferenceElementNode( this, nodeObject( indexNode ) ) );
-
-	}
-
-	setNodeType( uniformType ) {
-
-		let node = null;
-
-		if ( this.count !== null ) {
-
-			node = buffer( null, uniformType, this.count );
-
-		} else if ( Array.isArray( this.getValueFromReference() ) ) {
-
-			node = uniforms( null, uniformType );
-
-		} else if ( uniformType === 'texture' ) {
-
-			node = texture( null );
-
-		} else {
-
-			node = uniform( null, uniformType );
-
-		}
-
-		this.node = node;
-
-	}
-
-	getNodeType( builder ) {
-
-		if ( this.node === null ) {
-
-			this.updateValue();
-
-		}
-
-		return this.node.getNodeType( builder );
-
-	}
-
-	getValueFromReference( object = this.reference ) {
-
-		const { properties } = this;
-
-		let value = object[ properties[ 0 ] ];
-
-		for ( let i = 1; i < properties.length; i ++ ) {
-
-			value = value[ properties[ i ] ];
-
-		}
-
-		return value;
-
-	}
-
-	updateReference( state ) {
-
-		this.reference = this.object !== null ? this.object : state.object;
-
-		return this.reference;
-
-	}
-
-	setup() {
-
-		this.updateValue();
-
-		return this.node;
-
-	}
-
-	update( /*frame*/ ) {
-
-		this.updateValue();
-
-	}
-
-	updateValue() {
-
-		if ( this.node === null ) this.setNodeType( this.uniformType );
-
-		const value = this.getValueFromReference();
-
-		if ( Array.isArray( value ) ) {
-
-			this.node.array = value;
-
-		} else {
-
-			this.node.value = value;
-
-		}
-
-	}
-
-}
-
-export default ReferenceNode;
-
-export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );
-export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceNode( name, type, object, count ) );
-
-addNodeClass( 'ReferenceNode', ReferenceNode );

+ 0 - 6
examples/jsm/nodes/accessors/ReflectVectorNode.js

@@ -1,6 +0,0 @@
-import { cameraViewMatrix } from './CameraNode.js';
-import { transformedNormalView } from './NormalNode.js';
-import { positionViewDirection } from './PositionNode.js';
-
-export const reflectView = /*#__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView );
-export const reflectVector = /*#__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );

+ 0 - 29
examples/jsm/nodes/accessors/RendererReferenceNode.js

@@ -1,29 +0,0 @@
-import ReferenceNode from './ReferenceNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-
-class RendererReferenceNode extends ReferenceNode {
-
-	constructor( property, inputType, renderer = null ) {
-
-		super( property, inputType, renderer );
-
-		this.renderer = renderer;
-
-	}
-
-	updateReference( state ) {
-
-		this.reference = this.renderer !== null ? this.renderer : state.renderer;
-
-		return this.reference;
-
-	}
-
-}
-
-export default RendererReferenceNode;
-
-export const rendererReference = ( name, type, renderer ) => nodeObject( new RendererReferenceNode( name, type, renderer ) );
-
-addNodeClass( 'RendererReferenceNode', RendererReferenceNode );

+ 0 - 52
examples/jsm/nodes/accessors/SceneNode.js

@@ -1,52 +0,0 @@
-import Node from '../core/Node.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-import { reference } from './ReferenceNode.js';
-
-class SceneNode extends Node {
-
-	constructor( scope = SceneNode.BACKGROUND_BLURRINESS, scene = null ) {
-
-		super();
-
-		this.scope = scope;
-		this.scene = scene;
-
-	}
-
-	setup( builder ) {
-
-		const scope = this.scope;
-		const scene = this.scene !== null ? this.scene : builder.scene;
-
-		let output;
-
-		if ( scope === SceneNode.BACKGROUND_BLURRINESS ) {
-
-			output = reference( 'backgroundBlurriness', 'float', scene );
-
-		} else if ( scope === SceneNode.BACKGROUND_INTENSITY ) {
-
-			output = reference( 'backgroundIntensity', 'float', scene );
-
-		} else {
-
-			console.error( 'THREE.SceneNode: Unknown scope:', scope );
-
-		}
-
-		return output;
-
-	}
-
-}
-
-SceneNode.BACKGROUND_BLURRINESS = 'backgroundBlurriness';
-SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity';
-
-export default SceneNode;
-
-export const backgroundBlurriness = nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS );
-export const backgroundIntensity = nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY );
-
-addNodeClass( 'SceneNode', SceneNode );

+ 0 - 124
examples/jsm/nodes/accessors/SkinningNode.js

@@ -1,124 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { NodeUpdateType } from '../core/constants.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-import { attribute } from '../core/AttributeNode.js';
-import { reference, referenceBuffer } from './ReferenceNode.js';
-import { add } from '../math/OperatorNode.js';
-import { normalLocal } from './NormalNode.js';
-import { positionLocal } from './PositionNode.js';
-import { tangentLocal } from './TangentNode.js';
-import { uniform } from '../core/UniformNode.js';
-import { buffer } from './BufferNode.js';
-
-class SkinningNode extends Node {
-
-	constructor( skinnedMesh, useReference = false ) {
-
-		super( 'void' );
-
-		this.skinnedMesh = skinnedMesh;
-		this.useReference = useReference;
-
-		this.updateType = NodeUpdateType.OBJECT;
-
-		//
-
-		this.skinIndexNode = attribute( 'skinIndex', 'uvec4' );
-		this.skinWeightNode = attribute( 'skinWeight', 'vec4' );
-
-		let bindMatrixNode, bindMatrixInverseNode, boneMatricesNode;
-
-		if ( useReference ) {
-
-			bindMatrixNode = reference( 'bindMatrix', 'mat4' );
-			bindMatrixInverseNode = reference( 'bindMatrixInverse', 'mat4' );
-			boneMatricesNode = referenceBuffer( 'skeleton.boneMatrices', 'mat4', skinnedMesh.skeleton.bones.length );
-
-		} else {
-
-			bindMatrixNode = uniform( skinnedMesh.bindMatrix, 'mat4' );
-			bindMatrixInverseNode = uniform( skinnedMesh.bindMatrixInverse, 'mat4' );
-			boneMatricesNode = buffer( skinnedMesh.skeleton.boneMatrices, 'mat4', skinnedMesh.skeleton.bones.length );
-
-		}
-
-		this.bindMatrixNode = bindMatrixNode;
-		this.bindMatrixInverseNode = bindMatrixInverseNode;
-		this.boneMatricesNode = boneMatricesNode;
-
-	}
-
-	setup( builder ) {
-
-		const { skinIndexNode, skinWeightNode, bindMatrixNode, bindMatrixInverseNode, boneMatricesNode } = this;
-
-		const boneMatX = boneMatricesNode.element( skinIndexNode.x );
-		const boneMatY = boneMatricesNode.element( skinIndexNode.y );
-		const boneMatZ = boneMatricesNode.element( skinIndexNode.z );
-		const boneMatW = boneMatricesNode.element( skinIndexNode.w );
-
-		// POSITION
-
-		const skinVertex = bindMatrixNode.mul( positionLocal );
-
-		const skinned = add(
-			boneMatX.mul( skinWeightNode.x ).mul( skinVertex ),
-			boneMatY.mul( skinWeightNode.y ).mul( skinVertex ),
-			boneMatZ.mul( skinWeightNode.z ).mul( skinVertex ),
-			boneMatW.mul( skinWeightNode.w ).mul( skinVertex )
-		);
-
-		const skinPosition = bindMatrixInverseNode.mul( skinned ).xyz;
-
-		// NORMAL
-
-		let skinMatrix = add(
-			skinWeightNode.x.mul( boneMatX ),
-			skinWeightNode.y.mul( boneMatY ),
-			skinWeightNode.z.mul( boneMatZ ),
-			skinWeightNode.w.mul( boneMatW )
-		);
-
-		skinMatrix = bindMatrixInverseNode.mul( skinMatrix ).mul( bindMatrixNode );
-
-		const skinNormal = skinMatrix.transformDirection( normalLocal ).xyz;
-
-		// ASSIGNS
-
-		positionLocal.assign( skinPosition );
-		normalLocal.assign( skinNormal );
-
-		if ( builder.hasGeometryAttribute( 'tangent' ) ) {
-
-			tangentLocal.assign( skinNormal );
-
-		}
-
-	}
-
-	generate( builder, output ) {
-
-		if ( output !== 'void' ) {
-
-			return positionLocal.build( builder, output );
-
-		}
-
-	}
-
-	update( frame ) {
-
-		const object = this.useReference ? frame.object : this.skinnedMesh;
-
-		object.skeleton.update();
-
-	}
-
-}
-
-export default SkinningNode;
-
-export const skinning = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh ) );
-export const skinningReference = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh, true ) );
-
-addNodeClass( 'SkinningNode', SkinningNode );

+ 0 - 130
examples/jsm/nodes/accessors/StorageBufferNode.js

@@ -1,130 +0,0 @@
-import BufferNode from './BufferNode.js';
-import { bufferAttribute } from './BufferAttributeNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-import { varying } from '../core/VaryingNode.js';
-import { storageElement } from '../utils/StorageArrayElementNode.js';
-import { GPUBufferBindingType } from '../../renderers/webgpu/utils/WebGPUConstants.js';
-
-class StorageBufferNode extends BufferNode {
-
-	constructor( value, bufferType, bufferCount = 0 ) {
-
-		super( value, bufferType, bufferCount );
-
-		this.isStorageBufferNode = true;
-
-		this.access = GPUBufferBindingType.Storage;
-
-		this.bufferObject = false;
-		this.bufferCount = bufferCount;
-
-		this._attribute = null;
-		this._varying = null;
-
-		this.global = true;
-
-		if ( value.isStorageBufferAttribute !== true && value.isStorageInstancedBufferAttribute !== true ) {
-
-			// TOOD: Improve it, possibly adding a new property to the BufferAttribute to identify it as a storage buffer read-only attribute in Renderer
-
-			if ( value.isInstancedBufferAttribute ) value.isStorageInstancedBufferAttribute = true;
-			else value.isStorageBufferAttribute = true;
-
-		}
-
-	}
-
-	getHash( builder ) {
-
-		if ( this.bufferCount === 0 ) {
-
-			let bufferData = builder.globalCache.getData( this.value );
-
-			if ( bufferData === undefined ) {
-
-				bufferData = {
-					node: this
-				};
-
-				builder.globalCache.setData( this.value, bufferData );
-
-			}
-
-			return bufferData.node.uuid;
-
-		}
-
-		return this.uuid;
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'storageBuffer';
-
-	}
-
-	element( indexNode ) {
-
-		return storageElement( this, indexNode );
-
-	}
-
-	setBufferObject( value ) {
-
-		this.bufferObject = value;
-
-		return this;
-
-	}
-
-	setAccess( value ) {
-
-		this.access = value;
-
-		return this;
-
-	}
-
-	toReadOnly() {
-
-		return this.setAccess( GPUBufferBindingType.ReadOnlyStorage );
-
-	}
-
-	generate( builder ) {
-
-		if ( builder.isAvailable( 'storageBuffer' ) ) {
-
-			return super.generate( builder );
-
-		}
-
-		const nodeType = this.getNodeType( builder );
-
-		if ( this._attribute === null ) {
-
-			this._attribute = bufferAttribute( this.value );
-			this._varying = varying( this._attribute );
-
-		}
-
-
-		const output = this._varying.build( builder, nodeType );
-
-		builder.registerTransform( output, this._attribute );
-
-		return output;
-
-	}
-
-}
-
-export default StorageBufferNode;
-
-// Read-Write Storage
-export const storage = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ) );
-export const storageObject = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ).setBufferObject( true ) );
-
-addNodeClass( 'StorageBufferNode', StorageBufferNode );

+ 0 - 104
examples/jsm/nodes/accessors/StorageTextureNode.js

@@ -1,104 +0,0 @@
-import { addNodeClass } from '../core/Node.js';
-import TextureNode from './TextureNode.js';
-import { nodeProxy } from '../shadernode/ShaderNode.js';
-import { GPUStorageTextureAccess } from '../../renderers/webgpu/utils/WebGPUConstants.js';
-
-class StorageTextureNode extends TextureNode {
-
-	constructor( value, uvNode, storeNode = null ) {
-
-		super( value, uvNode );
-
-		this.storeNode = storeNode;
-
-		this.isStorageTextureNode = true;
-
-		this.access = GPUStorageTextureAccess.WriteOnly;
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'storageTexture';
-
-	}
-
-	setup( builder ) {
-
-		super.setup( builder );
-
-		const properties = builder.getNodeProperties( this );
-		properties.storeNode = this.storeNode;
-
-	}
-
-	setAccess( value ) {
-
-		this.access = value;
-		return this;
-
-	}
-
-	generate( builder, output ) {
-
-		let snippet;
-
-		if ( this.storeNode !== null ) {
-
-			snippet = this.generateStore( builder );
-
-		} else {
-
-			snippet = super.generate( builder, output );
-
-		}
-
-		return snippet;
-
-	}
-
-	toReadOnly() {
-
-		return this.setAccess( GPUStorageTextureAccess.ReadOnly );
-
-	}
-
-	toWriteOnly() {
-
-		return this.setAccess( GPUStorageTextureAccess.WriteOnly );
-
-	}
-
-	generateStore( builder ) {
-
-		const properties = builder.getNodeProperties( this );
-
-		const { uvNode, storeNode } = properties;
-
-		const textureProperty = super.generate( builder, 'property' );
-		const uvSnippet = uvNode.build( builder, 'uvec2' );
-		const storeSnippet = storeNode.build( builder, 'vec4' );
-
-		const snippet = builder.generateTextureStore( builder, textureProperty, uvSnippet, storeSnippet );
-
-		builder.addLineFlowCode( snippet );
-
-	}
-
-}
-
-export default StorageTextureNode;
-
-export const storageTexture = nodeProxy( StorageTextureNode );
-
-export const textureStore = ( value, uvNode, storeNode ) => {
-
-	const node = storageTexture( value, uvNode, storeNode );
-
-	if ( storeNode !== null ) node.append();
-
-	return node;
-
-};
-
-addNodeClass( 'StorageTextureNode', StorageTextureNode );

+ 0 - 23
examples/jsm/nodes/accessors/TangentNode.js

@@ -1,23 +0,0 @@
-import { attribute } from '../core/AttributeNode.js';
-import { varying } from '../core/VaryingNode.js';
-import { cameraViewMatrix } from './CameraNode.js';
-import { modelViewMatrix } from './ModelNode.js';
-import { tslFn, vec4 } from '../shadernode/ShaderNode.js';
-
-export const tangentGeometry = /*#__PURE__*/ tslFn( ( stack, builder ) => {
-
-	if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
-
-		builder.geometry.computeTangents();
-
-	}
-
-	return attribute( 'tangent', 'vec4' );
-
-} )();
-
-export const tangentLocal = /*#__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' );
-export const tangentView = /*#__PURE__*/ varying( modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz, 'v_tangentView' ).normalize().toVar( 'tangentView' );
-export const tangentWorld = /*#__PURE__*/ varying( tangentView.transformDirection( cameraViewMatrix ), 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' );
-export const transformedTangentView = /*#__PURE__*/ tangentView.toVar( 'transformedTangentView' );
-export const transformedTangentWorld = /*#__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' );

+ 0 - 100
examples/jsm/nodes/accessors/Texture3DNode.js

@@ -1,100 +0,0 @@
-import TextureNode from './TextureNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeProxy, vec3, tslFn, If } from '../shadernode/ShaderNode.js';
-
-const normal = tslFn( ( { texture, uv } ) => {
-
-	const epsilon = 0.0001;
-
-	const ret = vec3().temp();
-
-	If( uv.x.lessThan( epsilon ), () => {
-
-		ret.assign( vec3( 1, 0, 0 ) );
-
-	} ).elseif( uv.y.lessThan( epsilon ), () => {
-
-		ret.assign( vec3( 0, 1, 0 ) );
-
-	} ).elseif( uv.z.lessThan( epsilon ), () => {
-
-		ret.assign( vec3( 0, 0, 1 ) );
-
-	} ).elseif( uv.x.greaterThan( 1 - epsilon ), () => {
-
-		ret.assign( vec3( - 1, 0, 0 ) );
-
-	} ).elseif( uv.y.greaterThan( 1 - epsilon ), () => {
-
-		ret.assign( vec3( 0, - 1, 0 ) );
-
-	} ).elseif( uv.z.greaterThan( 1 - epsilon ), () => {
-
-		ret.assign( vec3( 0, 0, - 1 ) );
-
-	} ).else( () => {
-
-		const step = 0.01;
-
-		const x = texture.uv( uv.add( vec3( - step, 0.0, 0.0 ) ) ).r.sub( texture.uv( uv.add( vec3( step, 0.0, 0.0 ) ) ).r );
-		const y = texture.uv( uv.add( vec3( 0.0, - step, 0.0 ) ) ).r.sub( texture.uv( uv.add( vec3( 0.0, step, 0.0 ) ) ).r );
-		const z = texture.uv( uv.add( vec3( 0.0, 0.0, - step ) ) ).r.sub( texture.uv( uv.add( vec3( 0.0, 0.0, step ) ) ).r );
-
-		ret.assign( vec3( x, y, z ) );
-
-	} );
-
-	return ret.normalize();
-
-} );
-
-
-class Texture3DNode extends TextureNode {
-
-	constructor( value, uvNode = null, levelNode = null ) {
-
-		super( value, uvNode, levelNode );
-
-		this.isTexture3DNode = true;
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'texture3D';
-
-	}
-
-	getDefaultUV() {
-
-		return vec3( 0.5, 0.5, 0.5 );
-
-	}
-
-	setUpdateMatrix( /*updateMatrix*/ ) { } // Ignore .updateMatrix for 3d TextureNode
-
-	setupUV( builder, uvNode ) {
-
-		return uvNode;
-
-	}
-
-	generateUV( builder, uvNode ) {
-
-		return uvNode.build( builder, 'vec3' );
-
-	}
-
-	normal( uvNode ) {
-
-		return normal( { texture: this, uv: uvNode } );
-
-	}
-
-}
-
-export default Texture3DNode;
-
-export const texture3D = nodeProxy( Texture3DNode );
-
-addNodeClass( 'Texture3DNode', Texture3DNode );

+ 0 - 94
examples/jsm/nodes/accessors/TextureBicubicNode.js

@@ -1,94 +0,0 @@
-import TempNode from '../core/TempNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { add, mul, div } from '../math/OperatorNode.js';
-import { floor, ceil, fract, pow } from '../math/MathNode.js';
-import { nodeProxy, addNodeElement, float, vec2, vec4, int } from '../shadernode/ShaderNode.js';
-
-// Mipped Bicubic Texture Filtering by N8
-// https://www.shadertoy.com/view/Dl2SDW
-
-const bC = 1.0 / 6.0;
-
-const w0 = ( a ) => mul( bC, mul( a, mul( a, a.negate().add( 3.0 ) ).sub( 3.0 ) ).add( 1.0 ) );
-
-const w1 = ( a ) => mul( bC, mul( a, mul( a, mul( 3.0, a ).sub( 6.0 ) ) ).add( 4.0 ) );
-
-const w2 = ( a ) => mul( bC, mul( a, mul( a, mul( - 3.0, a ).add( 3.0 ) ).add( 3.0 ) ).add( 1.0 ) );
-
-const w3 = ( a ) => mul( bC, pow( a, 3 ) );
-
-const g0 = ( a ) => w0( a ).add( w1( a ) );
-
-const g1 = ( a ) => w2( a ).add( w3( a ) );
-
-// h0 and h1 are the two offset functions
-const h0 = ( a ) => add( - 1.0, w1( a ).div( w0( a ).add( w1( a ) ) ) );
-
-const h1 = ( a ) => add( 1.0, w3( a ).div( w2( a ).add( w3( a ) ) ) );
-
-const bicubic = ( textureNode, texelSize, lod ) => {
-
-	const uv = textureNode.uvNode;
-	const uvScaled = mul( uv, texelSize.zw ).add( 0.5 );
-
-	const iuv = floor( uvScaled );
-	const fuv = fract( uvScaled );
-
-	const g0x = g0( fuv.x );
-	const g1x = g1( fuv.x );
-	const h0x = h0( fuv.x );
-	const h1x = h1( fuv.x );
-	const h0y = h0( fuv.y );
-	const h1y = h1( fuv.y );
-
-	const p0 = vec2( iuv.x.add( h0x ), iuv.y.add( h0y ) ).sub( 0.5 ).mul( texelSize.xy );
-	const p1 = vec2( iuv.x.add( h1x ), iuv.y.add( h0y ) ).sub( 0.5 ).mul( texelSize.xy );
-	const p2 = vec2( iuv.x.add( h0x ), iuv.y.add( h1y ) ).sub( 0.5 ).mul( texelSize.xy );
-	const p3 = vec2( iuv.x.add( h1x ), iuv.y.add( h1y ) ).sub( 0.5 ).mul( texelSize.xy );
-
-	const a = g0( fuv.y ).mul( add( g0x.mul( textureNode.uv( p0 ).level( lod ) ), g1x.mul( textureNode.uv( p1 ).level( lod ) ) ) );
-	const b = g1( fuv.y ).mul( add( g0x.mul( textureNode.uv( p2 ).level( lod ) ), g1x.mul( textureNode.uv( p3 ).level( lod ) ) ) );
-
-	return a.add( b );
-
-};
-
-const textureBicubicMethod = ( textureNode, lodNode ) => {
-
-	const fLodSize = vec2( textureNode.size( int( lodNode ) ) );
-	const cLodSize = vec2( textureNode.size( int( lodNode.add( 1.0 ) ) ) );
-	const fLodSizeInv = div( 1.0, fLodSize );
-	const cLodSizeInv = div( 1.0, cLodSize );
-	const fSample = bicubic( textureNode, vec4( fLodSizeInv, fLodSize ), floor( lodNode ) );
-	const cSample = bicubic( textureNode, vec4( cLodSizeInv, cLodSize ), ceil( lodNode ) );
-
-	return fract( lodNode ).mix( fSample, cSample );
-
-};
-
-class TextureBicubicNode extends TempNode {
-
-	constructor( textureNode, blurNode = float( 3 ) ) {
-
-		super( 'vec4' );
-
-		this.textureNode = textureNode;
-		this.blurNode = blurNode;
-
-	}
-
-	setup() {
-
-		return textureBicubicMethod( this.textureNode, this.blurNode );
-
-	}
-
-}
-
-export default TextureBicubicNode;
-
-export const textureBicubic = nodeProxy( TextureBicubicNode );
-
-addNodeElement( 'bicubic', textureBicubic );
-
-addNodeClass( 'TextureBicubicNode', TextureBicubicNode );

+ 0 - 415
examples/jsm/nodes/accessors/TextureNode.js

@@ -1,415 +0,0 @@
-import UniformNode, { uniform } from '../core/UniformNode.js';
-import { uv } from './UVNode.js';
-import { textureSize } from './TextureSizeNode.js';
-import { colorSpaceToLinear } from '../display/ColorSpaceNode.js';
-import { expression } from '../code/ExpressionNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { maxMipLevel } from '../utils/MaxMipLevelNode.js';
-import { addNodeElement, nodeProxy, vec3, nodeObject } from '../shadernode/ShaderNode.js';
-import { NodeUpdateType } from '../core/constants.js';
-import { IntType, UnsignedIntType } from 'three';
-
-class TextureNode extends UniformNode {
-
-	constructor( value, uvNode = null, levelNode = null ) {
-
-		super( value );
-
-		this.isTextureNode = true;
-
-		this.uvNode = uvNode;
-		this.levelNode = levelNode;
-		this.compareNode = null;
-		this.depthNode = null;
-		this.gradNode = null;
-
-		this.sampler = true;
-		this.updateMatrix = false;
-		this.updateType = NodeUpdateType.NONE;
-
-		this.referenceNode = null;
-
-		this._value = value;
-
-		this.setUpdateMatrix( uvNode === null );
-
-	}
-
-	set value( value ) {
-
-		if ( this.referenceNode ) {
-
-			this.referenceNode.value = value;
-
-		} else {
-
-			this._value = value;
-
-		}
-
-	}
-
-	get value() {
-
-		return this.referenceNode ? this.referenceNode.value : this._value;
-
-	}
-
-	getUniformHash( /*builder*/ ) {
-
-		return this.value.uuid;
-
-	}
-
-	getNodeType( /*builder*/ ) {
-
-		if ( this.value.isDepthTexture === true ) return 'float';
-
-		if ( this.value.type === UnsignedIntType ) {
-
-			return 'uvec4';
-
-		} else if ( this.value.type === IntType ) {
-
-			return 'ivec4';
-
-		}
-
-		return 'vec4';
-
-	}
-
-	getInputType( /*builder*/ ) {
-
-		return 'texture';
-
-	}
-
-	getDefaultUV() {
-
-		return uv( this.value.channel );
-
-	}
-
-	updateReference( /*state*/ ) {
-
-		return this.value;
-
-	}
-
-	getTransformedUV( uvNode ) {
-
-		const texture = this.value;
-
-		return uniform( texture.matrix ).mul( vec3( uvNode, 1 ) ).xy;
-
-	}
-
-	setUpdateMatrix( value ) {
-
-		this.updateMatrix = value;
-		this.updateType = value ? NodeUpdateType.FRAME : NodeUpdateType.NONE;
-
-		return this;
-
-	}
-
-	setupUV( builder, uvNode ) {
-
-		const texture = this.value;
-
-		if ( builder.isFlipY() && ( texture.isRenderTargetTexture === true || texture.isFramebufferTexture === true || texture.isDepthTexture === true ) ) {
-
-			uvNode = uvNode.setY( uvNode.y.oneMinus() );
-
-		}
-
-		return uvNode;
-
-	}
-
-	setup( builder ) {
-
-		const properties = builder.getNodeProperties( this );
-
-		//
-
-		let uvNode = this.uvNode;
-
-		if ( ( uvNode === null || builder.context.forceUVContext === true ) && builder.context.getUV ) {
-
-			uvNode = builder.context.getUV( this );
-
-		}
-
-		if ( ! uvNode ) uvNode = this.getDefaultUV();
-
-		if ( this.updateMatrix === true ) {
-
-			uvNode = this.getTransformedUV( uvNode );
-
-		}
-
-		uvNode = this.setupUV( builder, uvNode );
-
-		//
-
-		let levelNode = this.levelNode;
-
-		if ( levelNode === null && builder.context.getTextureLevel ) {
-
-			levelNode = builder.context.getTextureLevel( this );
-
-		}
-
-		//
-
-		properties.uvNode = uvNode;
-		properties.levelNode = levelNode;
-		properties.compareNode = this.compareNode;
-		properties.gradNode = this.gradNode;
-		properties.depthNode = this.depthNode;
-
-	}
-
-	generateUV( builder, uvNode ) {
-
-		return uvNode.build( builder, this.sampler === true ? 'vec2' : 'ivec2' );
-
-	}
-
-	generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, depthSnippet, compareSnippet, gradSnippet ) {
-
-		const texture = this.value;
-
-		let snippet;
-
-		if ( levelSnippet ) {
-
-			snippet = builder.generateTextureLevel( texture, textureProperty, uvSnippet, levelSnippet, depthSnippet );
-
-		} else if ( gradSnippet ) {
-
-			snippet = builder.generateTextureGrad( texture, textureProperty, uvSnippet, gradSnippet, depthSnippet );
-
-		} else if ( compareSnippet ) {
-
-			snippet = builder.generateTextureCompare( texture, textureProperty, uvSnippet, compareSnippet, depthSnippet );
-
-		} else if ( this.sampler === false ) {
-
-			snippet = builder.generateTextureLoad( texture, textureProperty, uvSnippet, depthSnippet );
-
-		} else {
-
-			snippet = builder.generateTexture( texture, textureProperty, uvSnippet, depthSnippet );
-
-		}
-
-		return snippet;
-
-	}
-
-	generate( builder, output ) {
-
-		const properties = builder.getNodeProperties( this );
-
-		const texture = this.value;
-
-		if ( ! texture || texture.isTexture !== true ) {
-
-			throw new Error( 'TextureNode: Need a three.js texture.' );
-
-		}
-
-		const textureProperty = super.generate( builder, 'property' );
-
-		if ( output === 'sampler' ) {
-
-			return textureProperty + '_sampler';
-
-		} else if ( builder.isReference( output ) ) {
-
-			return textureProperty;
-
-		} else {
-
-			const nodeData = builder.getDataFromNode( this );
-
-			let propertyName = nodeData.propertyName;
-
-			if ( propertyName === undefined ) {
-
-				const { uvNode, levelNode, compareNode, depthNode, gradNode } = properties;
-
-				const uvSnippet = this.generateUV( builder, uvNode );
-				const levelSnippet = levelNode ? levelNode.build( builder, 'float' ) : null;
-				const depthSnippet = depthNode ? depthNode.build( builder, 'int' ) : null;
-				const compareSnippet = compareNode ? compareNode.build( builder, 'float' ) : null;
-				const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
-
-				const nodeVar = builder.getVarFromNode( this );
-
-				propertyName = builder.getPropertyName( nodeVar );
-
-				const snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, depthSnippet, compareSnippet, gradSnippet );
-
-				builder.addLineFlowCode( `${propertyName} = ${snippet}` );
-
-				nodeData.snippet = snippet;
-				nodeData.propertyName = propertyName;
-
-			}
-
-			let snippet = propertyName;
-			const nodeType = this.getNodeType( builder );
-
-			if ( builder.needsColorSpaceToLinear( texture ) ) {
-
-				snippet = colorSpaceToLinear( expression( snippet, nodeType ), texture.colorSpace ).setup( builder ).build( builder, nodeType );
-
-			}
-
-			return builder.format( snippet, nodeType, output );
-
-		}
-
-	}
-
-	setSampler( value ) {
-
-		this.sampler = value;
-
-		return this;
-
-	}
-
-	getSampler() {
-
-		return this.sampler;
-
-	}
-
-	// @TODO: Move to TSL
-
-	uv( uvNode ) {
-
-		const textureNode = this.clone();
-		textureNode.uvNode = uvNode;
-		textureNode.referenceNode = this;
-
-		return nodeObject( textureNode );
-
-	}
-
-	blur( levelNode ) {
-
-		const textureNode = this.clone();
-		textureNode.levelNode = levelNode.mul( maxMipLevel( textureNode ) );
-		textureNode.referenceNode = this;
-
-		return nodeObject( textureNode );
-
-	}
-
-	level( levelNode ) {
-
-		const textureNode = this.clone();
-		textureNode.levelNode = levelNode;
-		textureNode.referenceNode = this;
-
-		return textureNode;
-
-	}
-
-	size( levelNode ) {
-
-		return textureSize( this, levelNode );
-
-	}
-
-	compare( compareNode ) {
-
-		const textureNode = this.clone();
-		textureNode.compareNode = nodeObject( compareNode );
-		textureNode.referenceNode = this;
-
-		return nodeObject( textureNode );
-
-	}
-
-	grad( gradNodeX, gradNodeY ) {
-
-		const textureNode = this.clone();
-		textureNode.gradNode = [ nodeObject( gradNodeX ), nodeObject( gradNodeY ) ];
-
-		textureNode.referenceNode = this;
-
-		return nodeObject( textureNode );
-
-	}
-
-	depth( depthNode ) {
-
-		const textureNode = this.clone();
-		textureNode.depthNode = nodeObject( depthNode );
-		textureNode.referenceNode = this;
-
-		return nodeObject( textureNode );
-
-	}
-
-	// --
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value.toJSON( data.meta ).uuid;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		this.value = data.meta.textures[ data.value ];
-
-	}
-
-	update() {
-
-		const texture = this.value;
-
-		if ( texture.matrixAutoUpdate === true ) {
-
-			texture.updateMatrix();
-
-		}
-
-	}
-
-	clone() {
-
-		const newNode = new this.constructor( this.value, this.uvNode, this.levelNode );
-		newNode.sampler = this.sampler;
-
-		return newNode;
-
-	}
-
-}
-
-export default TextureNode;
-
-export const texture = nodeProxy( TextureNode );
-export const textureLoad = ( ...params ) => texture( ...params ).setSampler( false );
-
-//export const textureLevel = ( value, uv, level ) => texture( value, uv ).level( level );
-
-export const sampler = ( aTexture ) => ( aTexture.isNode === true ? aTexture : texture( aTexture ) ).convert( 'sampler' );
-
-addNodeElement( 'texture', texture );
-//addNodeElement( 'textureLevel', textureLevel );
-
-addNodeClass( 'TextureNode', TextureNode );

+ 0 - 35
examples/jsm/nodes/accessors/TextureSizeNode.js

@@ -1,35 +0,0 @@
-import Node from '../core/Node.js';
-import { addNodeClass } from '../core/Node.js';
-import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
-
-class TextureSizeNode extends Node {
-
-	constructor( textureNode, levelNode = null ) {
-
-		super( 'uvec2' );
-
-		this.isTextureSizeNode = true;
-
-		this.textureNode = textureNode;
-		this.levelNode = levelNode;
-
-	}
-
-	generate( builder, output ) {
-
-		const textureProperty = this.textureNode.build( builder, 'property' );
-		const levelNode = this.levelNode.build( builder, 'int' );
-
-		return builder.format( `${ builder.getMethod( 'textureDimensions' ) }( ${ textureProperty }, ${ levelNode } )`, this.getNodeType( builder ), output );
-
-	}
-
-}
-
-export default TextureSizeNode;
-
-export const textureSize = nodeProxy( TextureSizeNode );
-
-addNodeElement( 'textureSize', textureSize );
-
-addNodeClass( 'TextureSizeNode', TextureSizeNode );

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

@@ -1,3 +0,0 @@
-import { attribute } from '../core/AttributeNode.js';
-
-export const uv = ( index ) => attribute( 'uv' + ( index > 0 ? index : '' ), 'vec2' );

+ 0 - 146
examples/jsm/nodes/accessors/UniformsNode.js

@@ -1,146 +0,0 @@
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-import { NodeUpdateType } from '../core/constants.js';
-import { getValueType } from '../core/NodeUtils.js';
-import ArrayElementNode from '../utils/ArrayElementNode.js';
-import BufferNode from './BufferNode.js';
-
-class UniformsElementNode extends ArrayElementNode {
-
-	constructor( arrayBuffer, indexNode ) {
-
-		super( arrayBuffer, indexNode );
-
-		this.isArrayBufferElementNode = true;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.node.getElementType( builder );
-
-	}
-
-	generate( builder ) {
-
-		const snippet = super.generate( builder );
-		const type = this.getNodeType();
-
-		return builder.format( snippet, 'vec4', type );
-
-	}
-
-}
-
-class UniformsNode extends BufferNode {
-
-	constructor( value, elementType = null ) {
-
-		super( null, 'vec4' );
-
-		this.array = value;
-		this.elementType = elementType;
-
-		this._elementType = null;
-		this._elementLength = 0;
-
-		this.updateType = NodeUpdateType.RENDER;
-
-		this.isArrayBufferNode = true;
-
-	}
-
-	getElementType() {
-
-		return this.elementType || this._elementType;
-
-	}
-
-	getElementLength() {
-
-		return this._elementLength;
-
-	}
-
-	update( /*frame*/ ) {
-
-		const { array, value } = this;
-
-		const elementLength = this.getElementLength();
-		const elementType = this.getElementType();
-
-		if ( elementLength === 1 ) {
-
-			for ( let i = 0; i < array.length; i ++ ) {
-
-				const index = i * 4;
-
-				value[ index ] = array[ i ];
-
-			}
-
-		} else if ( elementType === 'color' ) {
-
-			for ( let i = 0; i < array.length; i ++ ) {
-
-				const index = i * 4;
-				const vector = array[ i ];
-
-				value[ index ] = vector.r;
-				value[ index + 1 ] = vector.g;
-				value[ index + 2 ] = vector.b || 0;
-				//value[ index + 3 ] = vector.a || 0;
-
-			}
-
-		} else {
-
-			for ( let i = 0; i < array.length; i ++ ) {
-
-				const index = i * 4;
-				const vector = array[ i ];
-
-				value[ index ] = vector.x;
-				value[ index + 1 ] = vector.y;
-				value[ index + 2 ] = vector.z || 0;
-				value[ index + 3 ] = vector.w || 0;
-
-			}
-
-		}
-
-	}
-
-	setup( builder ) {
-
-		const length = this.array.length;
-
-		this._elementType = this.elementType === null ? getValueType( this.array[ 0 ] ) : this.elementType;
-		this._elementLength = builder.getTypeLength( this._elementType );
-
-		let arrayType = Float32Array;
-
-		if ( this._elementType.charAt( 0 ) === 'i' ) arrayType = Int32Array;
-		else if ( this._elementType.charAt( 0 ) === 'u' ) arrayType = Uint32Array;
-
-		this.value = new arrayType( length * 4 );
-		this.bufferCount = length;
-		this.bufferType = builder.changeComponentType( 'vec4', builder.getComponentType( this._elementType ) );
-
-		return super.setup( builder );
-
-	}
-
-	element( indexNode ) {
-
-		return nodeObject( new UniformsElementNode( this, nodeObject( indexNode ) ) );
-
-	}
-
-}
-
-export default UniformsNode;
-
-export const uniforms = ( values, nodeType ) => nodeObject( new UniformsNode( values, nodeType ) );
-
-addNodeClass( 'UniformsNode', UniformsNode );

+ 0 - 29
examples/jsm/nodes/accessors/UserDataNode.js

@@ -1,29 +0,0 @@
-import ReferenceNode from './ReferenceNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-
-class UserDataNode extends ReferenceNode {
-
-	constructor( property, inputType, userData = null ) {
-
-		super( property, inputType, userData );
-
-		this.userData = userData;
-
-	}
-
-	update( frame ) {
-
-		this.reference = this.userData !== null ? this.userData : frame.object.userData;
-
-		super.update( frame );
-
-	}
-
-}
-
-export default UserDataNode;
-
-export const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) );
-
-addNodeClass( 'UserDataNode', UserDataNode );

+ 0 - 70
examples/jsm/nodes/accessors/VertexColorNode.js

@@ -1,70 +0,0 @@
-import { addNodeClass } from '../core/Node.js';
-import AttributeNode from '../core/AttributeNode.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-import { Vector4 } from 'three';
-
-class VertexColorNode extends AttributeNode {
-
-	constructor( index = 0 ) {
-
-		super( null, 'vec4' );
-
-		this.isVertexColorNode = true;
-
-		this.index = index;
-
-	}
-
-	getAttributeName( /*builder*/ ) {
-
-		const index = this.index;
-
-		return 'color' + ( index > 0 ? index : '' );
-
-	}
-
-	generate( builder ) {
-
-		const attributeName = this.getAttributeName( builder );
-		const geometryAttribute = builder.hasGeometryAttribute( attributeName );
-
-		let result;
-
-		if ( geometryAttribute === true ) {
-
-			result = super.generate( builder );
-
-		} else {
-
-			// Vertex color fallback should be white
-			result = builder.generateConst( this.nodeType, new Vector4( 1, 1, 1, 1 ) );
-
-		}
-
-		return result;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.index = this.index;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		this.index = data.index;
-
-	}
-
-}
-
-export default VertexColorNode;
-
-export const vertexColor = ( ...params ) => nodeObject( new VertexColorNode( ...params ) );
-
-addNodeClass( 'VertexColorNode', VertexColorNode );

+ 0 - 84
examples/jsm/nodes/code/CodeNode.js

@@ -1,84 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { nodeProxy } from '../shadernode/ShaderNode.js';
-
-class CodeNode extends Node {
-
-	constructor( code = '', includes = [], language = '' ) {
-
-		super( 'code' );
-
-		this.isCodeNode = true;
-
-		this.code = code;
-		this.language = language;
-
-		this.includes = includes;
-
-	}
-
-	isGlobal() {
-
-		return true;
-
-	}
-
-	setIncludes( includes ) {
-
-		this.includes = includes;
-
-		return this;
-
-	}
-
-	getIncludes( /*builder*/ ) {
-
-		return this.includes;
-
-	}
-
-	generate( builder ) {
-
-		const includes = this.getIncludes( builder );
-
-		for ( const include of includes ) {
-
-			include.build( builder );
-
-		}
-
-		const nodeCode = builder.getCodeFromNode( this, this.getNodeType( builder ) );
-		nodeCode.code = this.code;
-
-		return nodeCode.code;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.code = this.code;
-		data.language = this.language;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		this.code = data.code;
-		this.language = data.language;
-
-	}
-
-}
-
-export default CodeNode;
-
-export const code = nodeProxy( CodeNode );
-
-export const js = ( src, includes ) => code( src, includes, 'js' );
-export const wgsl = ( src, includes ) => code( src, includes, 'wgsl' );
-export const glsl = ( src, includes ) => code( src, includes, 'glsl' );
-
-addNodeClass( 'CodeNode', CodeNode );

+ 0 - 37
examples/jsm/nodes/code/ExpressionNode.js

@@ -1,37 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { nodeProxy } from '../shadernode/ShaderNode.js';
-
-class ExpressionNode extends Node {
-
-	constructor( snippet = '', nodeType = 'void' ) {
-
-		super( nodeType );
-
-		this.snippet = snippet;
-
-	}
-
-	generate( builder, output ) {
-
-		const type = this.getNodeType( builder );
-		const snippet = this.snippet;
-
-		if ( type === 'void' ) {
-
-			builder.addLineFlowCode( snippet );
-
-		} else {
-
-			return builder.format( `( ${ snippet } )`, type, output );
-
-		}
-
-	}
-
-}
-
-export default ExpressionNode;
-
-export const expression = nodeProxy( ExpressionNode );
-
-addNodeClass( 'ExpressionNode', ExpressionNode );

+ 0 - 96
examples/jsm/nodes/code/FunctionCallNode.js

@@ -1,96 +0,0 @@
-import TempNode from '../core/TempNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { addNodeElement, nodeArray, nodeObject, nodeObjects } from '../shadernode/ShaderNode.js';
-
-class FunctionCallNode extends TempNode {
-
-	constructor( functionNode = null, parameters = {} ) {
-
-		super();
-
-		this.functionNode = functionNode;
-		this.parameters = parameters;
-
-	}
-
-	setParameters( parameters ) {
-
-		this.parameters = parameters;
-
-		return this;
-
-	}
-
-	getParameters() {
-
-		return this.parameters;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.functionNode.getNodeType( builder );
-
-	}
-
-	generate( builder ) {
-
-		const params = [];
-
-		const functionNode = this.functionNode;
-
-		const inputs = functionNode.getInputs( builder );
-		const parameters = this.parameters;
-
-		if ( Array.isArray( parameters ) ) {
-
-			for ( let i = 0; i < parameters.length; i ++ ) {
-
-				const inputNode = inputs[ i ];
-				const node = parameters[ i ];
-
-				params.push( node.build( builder, inputNode.type ) );
-
-			}
-
-		} else {
-
-			for ( const inputNode of inputs ) {
-
-				const node = parameters[ inputNode.name ];
-
-				if ( node !== undefined ) {
-
-					params.push( node.build( builder, inputNode.type ) );
-
-				} else {
-
-					throw new Error( `FunctionCallNode: Input '${inputNode.name}' not found in FunctionNode.` );
-
-				}
-
-			}
-
-		}
-
-		const functionName = functionNode.build( builder, 'property' );
-
-		return `${functionName}( ${params.join( ', ' )} )`;
-
-	}
-
-}
-
-export default FunctionCallNode;
-
-export const call = ( func, ...params ) => {
-
-	params = params.length > 1 || ( params[ 0 ] && params[ 0 ].isNode === true ) ? nodeArray( params ) : nodeObjects( params[ 0 ] );
-
-	return nodeObject( new FunctionCallNode( nodeObject( func ), params ) );
-
-};
-
-addNodeElement( 'call', call );
-
-addNodeClass( 'FunctionCallNode', FunctionCallNode );

+ 0 - 130
examples/jsm/nodes/code/FunctionNode.js

@@ -1,130 +0,0 @@
-import CodeNode from './CodeNode.js';
-import { addNodeClass } from '../core/Node.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-
-class FunctionNode extends CodeNode {
-
-	constructor( code = '', includes = [], language = '' ) {
-
-		super( code, includes, language );
-
-		this.keywords = {};
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.getNodeFunction( builder ).type;
-
-	}
-
-	getInputs( builder ) {
-
-		return this.getNodeFunction( builder ).inputs;
-
-	}
-
-	getNodeFunction( builder ) {
-
-		const nodeData = builder.getDataFromNode( this );
-
-		let nodeFunction = nodeData.nodeFunction;
-
-		if ( nodeFunction === undefined ) {
-
-			nodeFunction = builder.parser.parseFunction( this.code );
-
-			nodeData.nodeFunction = nodeFunction;
-
-		}
-
-		return nodeFunction;
-
-	}
-
-	generate( builder, output ) {
-
-		super.generate( builder );
-
-		const nodeFunction = this.getNodeFunction( builder );
-
-		const name = nodeFunction.name;
-		const type = nodeFunction.type;
-
-		const nodeCode = builder.getCodeFromNode( this, type );
-
-		if ( name !== '' ) {
-
-			// use a custom property name
-
-			nodeCode.name = name;
-
-		}
-
-		const propertyName = builder.getPropertyName( nodeCode );
-
-		let code = this.getNodeFunction( builder ).getCode( propertyName );
-
-		const keywords = this.keywords;
-		const keywordsProperties = Object.keys( keywords );
-
-		if ( keywordsProperties.length > 0 ) {
-
-			for ( const property of keywordsProperties ) {
-
-				const propertyRegExp = new RegExp( `\\b${property}\\b`, 'g' );
-				const nodeProperty = keywords[ property ].build( builder, 'property' );
-
-				code = code.replace( propertyRegExp, nodeProperty );
-
-			}
-
-		}
-
-		nodeCode.code = code + '\n';
-
-		if ( output === 'property' ) {
-
-			return propertyName;
-
-		} else {
-
-			return builder.format( `${ propertyName }()`, type, output );
-
-		}
-
-	}
-
-}
-
-export default FunctionNode;
-
-const nativeFn = ( code, includes = [], language = '' ) => {
-
-	for ( let i = 0; i < includes.length; i ++ ) {
-
-		const include = includes[ i ];
-
-		// TSL Function: glslFn, wgslFn
-
-		if ( typeof include === 'function' ) {
-
-			includes[ i ] = include.functionNode;
-
-		}
-
-	}
-
-	const functionNode = nodeObject( new FunctionNode( code, includes, language ) );
-
-	const fn = ( ...params ) => functionNode.call( ...params );
-	fn.functionNode = functionNode;
-
-	return fn;
-
-};
-
-export const glslFn = ( code, includes ) => nativeFn( code, includes, 'glsl' );
-export const wgslFn = ( code, includes ) => nativeFn( code, includes, 'wgsl' );
-
-addNodeClass( 'FunctionNode', FunctionNode );

+ 0 - 488
examples/jsm/nodes/code/ScriptableNode.js

@@ -1,488 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { scriptableValue } from './ScriptableValueNode.js';
-import { addNodeElement, nodeProxy, float } from '../shadernode/ShaderNode.js';
-
-class Resources extends Map {
-
-	get( key, callback = null, ...params ) {
-
-		if ( this.has( key ) ) return super.get( key );
-
-		if ( callback !== null ) {
-
-			const value = callback( ...params );
-			this.set( key, value );
-			return value;
-
-		}
-
-	}
-
-}
-
-class Parameters {
-
-	constructor( scriptableNode ) {
-
-		this.scriptableNode = scriptableNode;
-
-	}
-
-	get parameters() {
-
-		return this.scriptableNode.parameters;
-
-	}
-
-	get layout() {
-
-		return this.scriptableNode.getLayout();
-
-	}
-
-	getInputLayout( id ) {
-
-		return this.scriptableNode.getInputLayout( id );
-
-	}
-
-	get( name ) {
-
-		const param = this.parameters[ name ];
-		const value = param ? param.getValue() : null;
-
-		return value;
-
-	}
-
-}
-
-export const global = new Resources();
-
-class ScriptableNode extends Node {
-
-	constructor( codeNode = null, parameters = {} ) {
-
-		super();
-
-		this.codeNode = codeNode;
-		this.parameters = parameters;
-
-		this._local = new Resources();
-		this._output = scriptableValue();
-		this._outputs = {};
-		this._source = this.source;
-		this._method = null;
-		this._object = null;
-		this._value = null;
-		this._needsOutputUpdate = true;
-
-		this.onRefresh = this.onRefresh.bind( this );
-
-		this.isScriptableNode = true;
-
-	}
-
-	get source() {
-
-		return this.codeNode ? this.codeNode.code : '';
-
-	}
-
-	setLocal( name, value ) {
-
-		return this._local.set( name, value );
-
-	}
-
-	getLocal( name ) {
-
-		return this._local.get( name );
-
-	}
-
-	onRefresh() {
-
-		this._refresh();
-
-	}
-
-	getInputLayout( id ) {
-
-		for ( const element of this.getLayout() ) {
-
-			if ( element.inputType && ( element.id === id || element.name === id ) ) {
-
-				return element;
-
-			}
-
-		}
-
-	}
-
-	getOutputLayout( id ) {
-
-		for ( const element of this.getLayout() ) {
-
-			if ( element.outputType && ( element.id === id || element.name === id ) ) {
-
-				return element;
-
-			}
-
-		}
-
-	}
-
-	setOutput( name, value ) {
-
-		const outputs = this._outputs;
-
-		if ( outputs[ name ] === undefined ) {
-
-			outputs[ name ] = scriptableValue( value );
-
-		} else {
-
-			outputs[ name ].value = value;
-
-		}
-
-		return this;
-
-	}
-
-	getOutput( name ) {
-
-		return this._outputs[ name ];
-
-	}
-
-	getParameter( name ) {
-
-		return this.parameters[ name ];
-
-	}
-
-	setParameter( name, value ) {
-
-		const parameters = this.parameters;
-
-		if ( value && value.isScriptableNode ) {
-
-			this.deleteParameter( name );
-
-			parameters[ name ] = value;
-			parameters[ name ].getDefaultOutput().events.addEventListener( 'refresh', this.onRefresh );
-
-		} else if ( value && value.isScriptableValueNode ) {
-
-			this.deleteParameter( name );
-
-			parameters[ name ] = value;
-			parameters[ name ].events.addEventListener( 'refresh', this.onRefresh );
-
-		} else if ( parameters[ name ] === undefined ) {
-
-			parameters[ name ] = scriptableValue( value );
-			parameters[ name ].events.addEventListener( 'refresh', this.onRefresh );
-
-		} else {
-
-			parameters[ name ].value = value;
-
-		}
-
-		return this;
-
-	}
-
-	getValue() {
-
-		return this.getDefaultOutput().getValue();
-
-	}
-
-	deleteParameter( name ) {
-
-		let valueNode = this.parameters[ name ];
-
-		if ( valueNode ) {
-
-			if ( valueNode.isScriptableNode ) valueNode = valueNode.getDefaultOutput();
-
-			valueNode.events.removeEventListener( 'refresh', this.onRefresh );
-
-		}
-
-		return this;
-
-	}
-
-	clearParameters() {
-
-		for ( const name of Object.keys( this.parameters ) ) {
-
-			this.deleteParameter( name );
-
-		}
-
-		this.needsUpdate = true;
-
-		return this;
-
-	}
-
-	call( name, ...params ) {
-
-		const object = this.getObject();
-		const method = object[ name ];
-
-		if ( typeof method === 'function' ) {
-
-			return method( ...params );
-
-		}
-
-	}
-
-	async callAsync( name, ...params ) {
-
-		const object = this.getObject();
-		const method = object[ name ];
-
-		if ( typeof method === 'function' ) {
-
-			return method.constructor.name === 'AsyncFunction' ? await method( ...params ) : method( ...params );
-
-		}
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.getDefaultOutputNode().getNodeType( builder );
-
-	}
-
-	refresh( output = null ) {
-
-		if ( output !== null ) {
-
-			this.getOutput( output ).refresh();
-
-		} else {
-
-			this._refresh();
-
-		}
-
-	}
-
-	getObject() {
-
-		if ( this.needsUpdate ) this.dispose();
-		if ( this._object !== null ) return this._object;
-
-		//
-
-		const refresh = () => this.refresh();
-		const setOutput = ( id, value ) => this.setOutput( id, value );
-
-		const parameters = new Parameters( this );
-
-		const THREE = global.get( 'THREE' );
-		const TSL = global.get( 'TSL' );
-
-		const method = this.getMethod( this.codeNode );
-		const params = [ parameters, this._local, global, refresh, setOutput, THREE, TSL ];
-
-		this._object = method( ...params );
-
-		const layout = this._object.layout;
-
-		if ( layout ) {
-
-			if ( layout.cache === false ) {
-
-				this._local.clear();
-
-			}
-
-			// default output
-			this._output.outputType = layout.outputType || null;
-
-			if ( Array.isArray( layout.elements ) ) {
-
-				for ( const element of layout.elements ) {
-
-					const id = element.id || element.name;
-
-					if ( element.inputType ) {
-
-						if ( this.getParameter( id ) === undefined ) this.setParameter( id, null );
-
-						this.getParameter( id ).inputType = element.inputType;
-
-					}
-
-					if ( element.outputType ) {
-
-						if ( this.getOutput( id ) === undefined ) this.setOutput( id, null );
-
-						this.getOutput( id ).outputType = element.outputType;
-
-					}
-
-				}
-
-			}
-
-		}
-
-		return this._object;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		for ( const name in this.parameters ) {
-
-			let valueNode = this.parameters[ name ];
-
-			if ( valueNode.isScriptableNode ) valueNode = valueNode.getDefaultOutput();
-
-			valueNode.events.addEventListener( 'refresh', this.onRefresh );
-
-		}
-
-	}
-
-	getLayout() {
-
-		return this.getObject().layout;
-
-	}
-
-	getDefaultOutputNode() {
-
-		const output = this.getDefaultOutput().value;
-
-		if ( output && output.isNode ) {
-
-			return output;
-
-		}
-
-		return float();
-
-	}
-
-	getDefaultOutput()	{
-
-		return this._exec()._output;
-
-	}
-
-	getMethod() {
-
-		if ( this.needsUpdate ) this.dispose();
-		if ( this._method !== null ) return this._method;
-
-		//
-
-		const parametersProps = [ 'parameters', 'local', 'global', 'refresh', 'setOutput', 'THREE', 'TSL' ];
-		const interfaceProps = [ 'layout', 'init', 'main', 'dispose' ];
-
-		const properties = interfaceProps.join( ', ' );
-		const declarations = 'var ' + properties + '; var output = {};\n';
-		const returns = '\nreturn { ...output, ' + properties + ' };';
-
-		const code = declarations + this.codeNode.code + returns;
-
-		//
-
-		this._method = new Function( ...parametersProps, code );
-
-		return this._method;
-
-	}
-
-	dispose() {
-
-		if ( this._method === null ) return;
-
-		if ( this._object && typeof this._object.dispose === 'function' ) {
-
-			this._object.dispose();
-
-		}
-
-		this._method = null;
-		this._object = null;
-		this._source = null;
-		this._value = null;
-		this._needsOutputUpdate = true;
-		this._output.value = null;
-		this._outputs = {};
-
-	}
-
-	setup() {
-
-		return this.getDefaultOutputNode();
-
-	}
-
-	set needsUpdate( value ) {
-
-		if ( value === true ) this.dispose();
-
-	}
-
-	get needsUpdate() {
-
-		return this.source !== this._source;
-
-	}
-
-	_exec()	{
-
-		if ( this.codeNode === null ) return this;
-
-		if ( this._needsOutputUpdate === true ) {
-
-			this._value = this.call( 'main' );
-
-			this._needsOutputUpdate = false;
-
-		}
-
-		this._output.value = this._value;
-
-		return this;
-
-	}
-
-	_refresh() {
-
-		this.needsUpdate = true;
-
-		this._exec();
-
-		this._output.refresh();
-
-	}
-
-}
-
-export default ScriptableNode;
-
-export const scriptable = nodeProxy( ScriptableNode );
-
-addNodeElement( 'scriptable', scriptable );
-
-addNodeClass( 'ScriptableNode', ScriptableNode );

+ 0 - 167
examples/jsm/nodes/code/ScriptableValueNode.js

@@ -1,167 +0,0 @@
-import Node, { addNodeClass } from '../core/Node.js';
-import { arrayBufferToBase64, base64ToArrayBuffer } from '../core/NodeUtils.js';
-import { addNodeElement, nodeProxy, float } from '../shadernode/ShaderNode.js';
-import { EventDispatcher } from 'three';
-
-class ScriptableValueNode extends Node {
-
-	constructor( value = null ) {
-
-		super();
-
-		this._value = value;
-		this._cache = null;
-
-		this.inputType = null;
-		this.outpuType = null;
-
-		this.events = new EventDispatcher();
-
-		this.isScriptableValueNode = true;
-
-	}
-
-	get isScriptableOutputNode() {
-
-		return this.outputType !== null;
-
-	}
-
-	set value( val ) {
-
-		if ( this._value === val ) return;
-
-		if ( this._cache && this.inputType === 'URL' && this.value.value instanceof ArrayBuffer ) {
-
-			URL.revokeObjectURL( this._cache );
-
-			this._cache = null;
-
-		}
-
-		this._value = val;
-
-		this.events.dispatchEvent( { type: 'change' } );
-
-		this.refresh();
-
-	}
-
-	get value() {
-
-		return this._value;
-
-	}
-
-	refresh() {
-
-		this.events.dispatchEvent( { type: 'refresh' } );
-
-	}
-
-	getValue() {
-
-		const value = this.value;
-
-		if ( value && this._cache === null && this.inputType === 'URL' && value.value instanceof ArrayBuffer ) {
-
-			this._cache = URL.createObjectURL( new Blob( [ value.value ] ) );
-
-		} else if ( value && value.value !== null && value.value !== undefined && (
-			( ( this.inputType === 'URL' || this.inputType === 'String' ) && typeof value.value === 'string' ) ||
-			( this.inputType === 'Number' && typeof value.value === 'number' ) ||
-			( this.inputType === 'Vector2' && value.value.isVector2 ) ||
-			( this.inputType === 'Vector3' && value.value.isVector3 ) ||
-			( this.inputType === 'Vector4' && value.value.isVector4 ) ||
-			( this.inputType === 'Color' && value.value.isColor ) ||
-			( this.inputType === 'Matrix3' && value.value.isMatrix3 ) ||
-			( this.inputType === 'Matrix4' && value.value.isMatrix4 )
-		) ) {
-
-			return value.value;
-
-		}
-
-		return this._cache || value;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.value && this.value.isNode ? this.value.getNodeType( builder ) : 'float';
-
-	}
-
-	setup() {
-
-		return this.value && this.value.isNode ? this.value : float();
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		if ( this.value !== null ) {
-
-			if ( this.inputType === 'ArrayBuffer' ) {
-
-				data.value = arrayBufferToBase64( this.value );
-
-			} else {
-
-				data.value = this.value ? this.value.toJSON( data.meta ).uuid : null;
-
-			}
-
-		} else {
-
-			data.value = null;
-
-		}
-
-		data.inputType = this.inputType;
-		data.outputType = this.outputType;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		let value = null;
-
-		if ( data.value !== null ) {
-
-			if ( data.inputType === 'ArrayBuffer' ) {
-
-				value = base64ToArrayBuffer( data.value );
-
-			} else if ( data.inputType === 'Texture' ) {
-
-				value = data.meta.textures[ data.value ];
-
-			} else {
-
-				value = data.meta.nodes[ data.value ] || null;
-
-			}
-
-		}
-
-		this.value = value;
-
-		this.inputType = data.inputType;
-		this.outputType = data.outputType;
-
-	}
-
-}
-
-export default ScriptableValueNode;
-
-export const scriptableValue = nodeProxy( ScriptableValueNode );
-
-addNodeElement( 'scriptableValue', scriptableValue );
-
-addNodeClass( 'ScriptableValueNode', ScriptableValueNode );

+ 0 - 128
examples/jsm/nodes/core/AssignNode.js

@@ -1,128 +0,0 @@
-import { addNodeClass } from '../core/Node.js';
-import TempNode from '../core/TempNode.js';
-import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
-import { vectorComponents } from '../core/constants.js';
-
-class AssignNode extends TempNode {
-
-	constructor( targetNode, sourceNode ) {
-
-		super();
-
-		this.targetNode = targetNode;
-		this.sourceNode = sourceNode;
-
-	}
-
-	hasDependencies() {
-
-		return false;
-
-	}
-
-	getNodeType( builder, output ) {
-
-		return output !== 'void' ? this.targetNode.getNodeType( builder ) : 'void';
-
-	}
-
-	needsSplitAssign( builder ) {
-
-		const { targetNode } = this;
-
-		if ( builder.isAvailable( 'swizzleAssign' ) === false && targetNode.isSplitNode && targetNode.components.length > 1 ) {
-
-			const targetLength = builder.getTypeLength( targetNode.node.getNodeType( builder ) );
-			const assignDiferentVector = vectorComponents.join( '' ).slice( 0, targetLength ) !== targetNode.components;
-
-			return assignDiferentVector;
-
-		}
-
-		return false;
-
-	}
-
-	generate( builder, output ) {
-
-		const { targetNode, sourceNode } = this;
-
-		const needsSplitAssign = this.needsSplitAssign( builder );
-
-		const targetType = targetNode.getNodeType( builder );
-
-		const target = targetNode.context( { assign: true } ).build( builder );
-		const source = sourceNode.build( builder, targetType );
-
-		const sourceType = sourceNode.getNodeType( builder );
-
-		const nodeData = builder.getDataFromNode( this );
-
-		//
-
-		let snippet;
-
-		if ( nodeData.initialized === true ) {
-
-			if ( output !== 'void' ) {
-
-				snippet = target;
-
-			}
-
-		} else if ( needsSplitAssign ) {
-
-			const sourceVar = builder.getVarFromNode( this, null, targetType );
-			const sourceProperty = builder.getPropertyName( sourceVar );
-
-			builder.addLineFlowCode( `${ sourceProperty } = ${ source }` );
-
-			const targetRoot = targetNode.node.context( { assign: true } ).build( builder );
-
-			for ( let i = 0; i < targetNode.components.length; i ++ ) {
-
-				const component = targetNode.components[ i ];
-
-				builder.addLineFlowCode( `${ targetRoot }.${ component } = ${ sourceProperty }[ ${ i } ]` );
-
-			}
-
-			if ( output !== 'void' ) {
-
-				snippet = target;
-
-			}
-
-		} else {
-
-			snippet = `${ target } = ${ source }`;
-
-			if ( output === 'void' || sourceType === 'void' ) {
-
-				builder.addLineFlowCode( snippet );
-
-				if ( output !== 'void' ) {
-
-					snippet = target;
-
-				}
-
-			}
-
-		}
-
-		nodeData.initialized = true;
-
-		return builder.format( snippet, targetType, output );
-
-	}
-
-}
-
-export default AssignNode;
-
-export const assign = nodeProxy( AssignNode );
-
-addNodeClass( 'AssignNode', AssignNode );
-
-addNodeElement( 'assign', assign );

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

@@ -1,116 +0,0 @@
-import Node, { addNodeClass } from './Node.js';
-import { varying } from './VaryingNode.js';
-import { nodeObject } from '../shadernode/ShaderNode.js';
-
-class AttributeNode extends Node {
-
-	constructor( attributeName, nodeType = null, defaultNode = null ) {
-
-		super( nodeType );
-
-		this.defaultNode = defaultNode;
-
-		this.global = true;
-
-		this._attributeName = attributeName;
-
-	}
-
-	getHash( builder ) {
-
-		return this.getAttributeName( builder );
-
-	}
-
-	getNodeType( builder ) {
-
-		let nodeType = super.getNodeType( builder );
-
-		if ( nodeType === null ) {
-
-			const attributeName = this.getAttributeName( builder );
-
-			if ( builder.hasGeometryAttribute( attributeName ) ) {
-
-				const attribute = builder.geometry.getAttribute( attributeName );
-
-				nodeType = builder.getTypeFromAttribute( attribute );
-
-			} else {
-
-				nodeType = 'float';
-
-			}
-
-		}
-
-		return nodeType;
-
-	}
-
-	setAttributeName( attributeName ) {
-
-		this._attributeName = attributeName;
-
-		return this;
-
-	}
-
-	getAttributeName( /*builder*/ ) {
-
-		return this._attributeName;
-
-	}
-
-	generate( builder ) {
-
-		const attributeName = this.getAttributeName( builder );
-		const nodeType = this.getNodeType( builder );
-		const geometryAttribute = builder.hasGeometryAttribute( attributeName );
-
-		if ( geometryAttribute === true ) {
-
-			const attribute = builder.geometry.getAttribute( attributeName );
-			const attributeType = builder.getTypeFromAttribute( attribute );
-
-			const nodeAttribute = builder.getAttribute( attributeName, attributeType );
-
-			if ( builder.shaderStage === 'vertex' ) {
-
-				return builder.format( nodeAttribute.name, attributeType, nodeType );
-
-			} else {
-
-				const nodeVarying = varying( this );
-
-				return nodeVarying.build( builder, nodeType );
-
-			}
-
-		} else {
-
-			console.warn( `AttributeNode: Vertex attribute "${ attributeName }" not found on geometry.` );
-
-			const { defaultNode } = this;
-
-			if ( defaultNode !== null ) {
-
-				return defaultNode.build( builder, nodeType );
-
-			} else {
-
-				return builder.generateConst( nodeType );
-
-			}
-
-		}
-
-	}
-
-}
-
-export default AttributeNode;
-
-export const attribute = ( name, nodeType, defaultNode ) => nodeObject( new AttributeNode( name, nodeType, nodeObject( defaultNode ) ) );
-
-addNodeClass( 'AttributeNode', AttributeNode );

+ 0 - 45
examples/jsm/nodes/core/BypassNode.js

@@ -1,45 +0,0 @@
-import Node, { addNodeClass } from './Node.js';
-import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
-
-class BypassNode extends Node {
-
-	constructor( returnNode, callNode ) {
-
-		super();
-
-		this.isBypassNode = true;
-
-		this.outputNode = returnNode;
-		this.callNode = callNode;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.outputNode.getNodeType( builder );
-
-	}
-
-	generate( builder ) {
-
-		const snippet = this.callNode.build( builder, 'void' );
-
-		if ( snippet !== '' ) {
-
-			builder.addLineFlowCode( snippet );
-
-		}
-
-		return this.outputNode.build( builder );
-
-	}
-
-}
-
-export default BypassNode;
-
-export const bypass = nodeProxy( BypassNode );
-
-addNodeElement( 'bypass', bypass );
-
-addNodeClass( 'BypassNode', BypassNode );

+ 0 - 46
examples/jsm/nodes/core/CacheNode.js

@@ -1,46 +0,0 @@
-import Node, { addNodeClass } from './Node.js';
-import { addNodeElement, nodeObject } from '../shadernode/ShaderNode.js';
-
-class CacheNode extends Node {
-
-	constructor( node, parent = true ) {
-
-		super();
-
-		this.node = node;
-		this.parent = parent;
-
-		this.isCacheNode = true;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.node.getNodeType( builder );
-
-	}
-
-	build( builder, ...params ) {
-
-		const previousCache = builder.getCache();
-		const cache = builder.getCacheFromNode( this, parent );
-
-		builder.setCache( cache );
-
-		const data = this.node.build( builder, ...params );
-
-		builder.setCache( previousCache );
-
-		return data;
-
-	}
-
-}
-
-export default CacheNode;
-
-export const cache = ( node, ...params ) => nodeObject( new CacheNode( nodeObject( node ), ...params ) );
-
-addNodeElement( 'cache', cache );
-
-addNodeClass( 'CacheNode', CacheNode );

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

@@ -1,32 +0,0 @@
-import InputNode from './InputNode.js';
-import { addNodeClass } from './Node.js';
-
-class ConstNode extends InputNode {
-
-	constructor( value, nodeType = null ) {
-
-		super( value, nodeType );
-
-		this.isConstNode = true;
-
-	}
-
-	generateConst( builder ) {
-
-		return builder.generateConst( this.getNodeType( builder ), this.value );
-
-	}
-
-	generate( builder, output ) {
-
-		const type = this.getNodeType( builder );
-
-		return builder.format( this.generateConst( builder ), type, output );
-
-	}
-
-}
-
-export default ConstNode;
-
-addNodeClass( 'ConstNode', ConstNode );

+ 0 - 67
examples/jsm/nodes/core/ContextNode.js

@@ -1,67 +0,0 @@
-import Node, { addNodeClass } from './Node.js';
-import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
-
-class ContextNode extends Node {
-
-	constructor( node, context = {} ) {
-
-		super();
-
-		this.isContextNode = true;
-
-		this.node = node;
-		this.context = context;
-
-	}
-
-	getNodeType( builder ) {
-
-		return this.node.getNodeType( builder );
-
-	}
-
-	analyze( builder ) {
-
-		this.node.build( builder );
-
-	}
-
-	setup( builder ) {
-
-		const previousContext = builder.getContext();
-
-		builder.setContext( { ...builder.context, ...this.context } );
-
-		const node = this.node.build( builder );
-
-		builder.setContext( previousContext );
-
-		return node;
-
-	}
-
-	generate( builder, output ) {
-
-		const previousContext = builder.getContext();
-
-		builder.setContext( { ...builder.context, ...this.context } );
-
-		const snippet = this.node.build( builder, output );
-
-		builder.setContext( previousContext );
-
-		return snippet;
-
-	}
-
-}
-
-export default ContextNode;
-
-export const context = nodeProxy( ContextNode );
-export const label = ( node, name ) => context( node, { label: name } );
-
-addNodeElement( 'context', context );
-addNodeElement( 'label', label );
-
-addNodeClass( 'ContextNode', ContextNode );

+ 0 - 72
examples/jsm/nodes/core/IndexNode.js

@@ -1,72 +0,0 @@
-import Node, { addNodeClass } from './Node.js';
-import { varying } from './VaryingNode.js';
-import { nodeImmutable } from '../shadernode/ShaderNode.js';
-
-class IndexNode extends Node {
-
-	constructor( scope ) {
-
-		super( 'uint' );
-
-		this.scope = scope;
-
-		this.isInstanceIndexNode = true;
-
-	}
-
-	generate( builder ) {
-
-		const nodeType = this.getNodeType( builder );
-		const scope = this.scope;
-
-		let propertyName;
-
-		if ( scope === IndexNode.VERTEX ) {
-
-			propertyName = builder.getVertexIndex();
-
-		} else if ( scope === IndexNode.INSTANCE ) {
-
-			propertyName = builder.getInstanceIndex();
-
-		} else if ( scope === IndexNode.DRAW ) {
-
-			propertyName = builder.getDrawIndex();
-
-		} else {
-
-			throw new Error( 'THREE.IndexNode: Unknown scope: ' + scope );
-
-		}
-
-		let output;
-
-		if ( builder.shaderStage === 'vertex' || builder.shaderStage === 'compute' ) {
-
-			output = propertyName;
-
-		} else {
-
-			const nodeVarying = varying( this );
-
-			output = nodeVarying.build( builder, nodeType );
-
-		}
-
-		return output;
-
-	}
-
-}
-
-IndexNode.VERTEX = 'vertex';
-IndexNode.INSTANCE = 'instance';
-IndexNode.DRAW = 'draw';
-
-export default IndexNode;
-
-export const vertexIndex = nodeImmutable( IndexNode, IndexNode.VERTEX );
-export const instanceIndex = nodeImmutable( IndexNode, IndexNode.INSTANCE );
-export const drawIndex = nodeImmutable( IndexNode, IndexNode.DRAW );
-
-addNodeClass( 'IndexNode', IndexNode );

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

@@ -1,83 +0,0 @@
-import Node, { addNodeClass } from './Node.js';
-import { getValueType, getValueFromType, arrayBufferToBase64 } from './NodeUtils.js';
-
-class InputNode extends Node {
-
-	constructor( value, nodeType = null ) {
-
-		super( nodeType );
-
-		this.isInputNode = true;
-
-		this.value = value;
-		this.precision = null;
-
-	}
-
-	getNodeType( /*builder*/ ) {
-
-		if ( this.nodeType === null ) {
-
-			return getValueType( this.value );
-
-		}
-
-		return this.nodeType;
-
-	}
-
-	getInputType( builder ) {
-
-		return this.getNodeType( builder );
-
-	}
-
-	setPrecision( precision ) {
-
-		this.precision = precision;
-
-		return this;
-
-	}
-
-	serialize( data ) {
-
-		super.serialize( data );
-
-		data.value = this.value;
-
-		if ( this.value && this.value.toArray ) data.value = this.value.toArray();
-
-		data.valueType = getValueType( this.value );
-		data.nodeType = this.nodeType;
-
-		if ( data.valueType === 'ArrayBuffer' ) data.value = arrayBufferToBase64( data.value );
-
-		data.precision = this.precision;
-
-	}
-
-	deserialize( data ) {
-
-		super.deserialize( data );
-
-		this.nodeType = data.nodeType;
-		this.value = Array.isArray( data.value ) ? getValueFromType( data.valueType, ...data.value ) : data.value;
-
-		this.precision = data.precision || null;
-
-		if ( this.value && this.value.fromArray ) this.value = this.value.fromArray( data.value );
-
-	}
-
-	generate( /*builder, output*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-}
-
-export default InputNode;
-
-addNodeClass( 'InputNode', InputNode );

+ 0 - 19
examples/jsm/nodes/core/LightingModel.js

@@ -1,19 +0,0 @@
-class LightingModel {
-
-	start( /*input, stack, builder*/ ) { }
-
-	finish( /*input, stack, builder*/ ) { }
-
-	direct( /*input, stack, builder*/ ) { }
-
-	directRectArea( /*input, stack, builder*/ ) {}
-
-	indirectDiffuse( /*input, stack, builder*/ ) { }
-
-	indirectSpecular( /*input, stack, builder*/ ) { }
-
-	ambientOcclusion( /*input, stack, builder*/ ) { }
-
-}
-
-export default LightingModel;

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

@@ -1,578 +0,0 @@
-import { EventDispatcher } from 'three';
-import { NodeUpdateType } from './constants.js';
-import { getNodeChildren, getCacheKey } from './NodeUtils.js';
-import { MathUtils } from 'three';
-
-const NodeClasses = new Map();
-
-let _nodeId = 0;
-
-class Node extends EventDispatcher {
-
-	constructor( nodeType = null ) {
-
-		super();
-
-		this.nodeType = nodeType;
-
-		this.updateType = NodeUpdateType.NONE;
-		this.updateBeforeType = NodeUpdateType.NONE;
-		this.updateAfterType = NodeUpdateType.NONE;
-
-		this.uuid = MathUtils.generateUUID();
-
-		this.version = 0;
-
-		this._cacheKey = null;
-		this._cacheKeyVersion = 0;
-
-		this.global = false;
-
-		this.isNode = true;
-
-		Object.defineProperty( this, 'id', { value: _nodeId ++ } );
-
-	}
-
-	set needsUpdate( value ) {
-
-		if ( value === true ) {
-
-			this.version ++;
-
-		}
-
-	}
-
-	get type() {
-
-		return this.constructor.type;
-
-	}
-
-	onUpdate( callback, updateType ) {
-
-		this.updateType = updateType;
-		this.update = callback.bind( this.getSelf() );
-
-		return this;
-
-	}
-
-	onFrameUpdate( callback ) {
-
-		return this.onUpdate( callback, NodeUpdateType.FRAME );
-
-	}
-
-	onRenderUpdate( callback ) {
-
-		return this.onUpdate( callback, NodeUpdateType.RENDER );
-
-	}
-
-	onObjectUpdate( callback ) {
-
-		return this.onUpdate( callback, NodeUpdateType.OBJECT );
-
-	}
-
-	onReference( callback ) {
-
-		this.updateReference = callback.bind( this.getSelf() );
-
-		return this;
-
-	}
-
-	getSelf() {
-
-		// Returns non-node object.
-
-		return this.self || this;
-
-	}
-
-	updateReference( /*state*/ ) {
-
-		return this;
-
-	}
-
-	isGlobal( /*builder*/ ) {
-
-		return this.global;
-
-	}
-
-	* getChildren() {
-
-		for ( const { childNode } of getNodeChildren( this ) ) {
-
-			yield childNode;
-
-		}
-
-	}
-
-	dispose() {
-
-		this.dispatchEvent( { type: 'dispose' } );
-
-	}
-
-	traverse( callback ) {
-
-		callback( this );
-
-		for ( const childNode of this.getChildren() ) {
-
-			childNode.traverse( callback );
-
-		}
-
-	}
-
-	getCacheKey( force = false ) {
-
-		force = force || this.version !== this._cacheKeyVersion;
-
-		if ( force === true || this._cacheKey === null ) {
-
-			this._cacheKey = getCacheKey( this, force );
-			this._cacheKeyVersion = this.version;
-
-		}
-
-		return this._cacheKey;
-
-	}
-
-	getHash( /*builder*/ ) {
-
-		return this.uuid;
-
-	}
-
-	getUpdateType() {
-
-		return this.updateType;
-
-	}
-
-	getUpdateBeforeType() {
-
-		return this.updateBeforeType;
-
-	}
-
-	getUpdateAfterType() {
-
-		return this.updateAfterType;
-
-	}
-
-	getElementType( builder ) {
-
-		const type = this.getNodeType( builder );
-		const elementType = builder.getElementType( type );
-
-		return elementType;
-
-	}
-
-	getNodeType( builder ) {
-
-		const nodeProperties = builder.getNodeProperties( this );
-
-		if ( nodeProperties.outputNode ) {
-
-			return nodeProperties.outputNode.getNodeType( builder );
-
-		}
-
-		return this.nodeType;
-
-	}
-
-	getShared( builder ) {
-
-		const hash = this.getHash( builder );
-		const nodeFromHash = builder.getNodeFromHash( hash );
-
-		return nodeFromHash || this;
-
-	}
-
-	setup( builder ) {
-
-		const nodeProperties = builder.getNodeProperties( this );
-
-		let index = 0;
-
-		for ( const childNode of this.getChildren() ) {
-
-			nodeProperties[ 'node' + index ++ ] = childNode;
-
-		}
-
-		// return a outputNode if exists
-		return null;
-
-	}
-
-	construct( builder ) { // @deprecated, r157
-
-		console.warn( 'THREE.Node: construct() is deprecated. Use setup() instead.' );
-
-		return this.setup( builder );
-
-	}
-
-	increaseUsage( builder ) {
-
-		const nodeData = builder.getDataFromNode( this );
-		nodeData.usageCount = nodeData.usageCount === undefined ? 1 : nodeData.usageCount + 1;
-
-		return nodeData.usageCount;
-
-	}
-
-	analyze( builder ) {
-
-		const usageCount = this.increaseUsage( builder );
-
-		if ( usageCount === 1 ) {
-
-			// node flow children
-
-			const nodeProperties = builder.getNodeProperties( this );
-
-			for ( const childNode of Object.values( nodeProperties ) ) {
-
-				if ( childNode && childNode.isNode === true ) {
-
-					childNode.build( builder );
-
-				}
-
-			}
-
-		}
-
-	}
-
-	generate( builder, output ) {
-
-		const { outputNode } = builder.getNodeProperties( this );
-
-		if ( outputNode && outputNode.isNode === true ) {
-
-			return outputNode.build( builder, output );
-
-		}
-
-	}
-
-	updateBefore( /*frame*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	updateAfter( /*frame*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	update( /*frame*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	build( builder, output = null ) {
-
-		const refNode = this.getShared( builder );
-
-		if ( this !== refNode ) {
-
-			return refNode.build( builder, output );
-
-		}
-
-		builder.addNode( this );
-		builder.addChain( this );
-
-		/* Build stages expected results:
-			- "setup"		-> Node
-			- "analyze"		-> null
-			- "generate"	-> String
-		*/
-		let result = null;
-
-		const buildStage = builder.getBuildStage();
-
-		if ( buildStage === 'setup' ) {
-
-			this.updateReference( builder );
-
-			const properties = builder.getNodeProperties( this );
-
-			if ( properties.initialized !== true ) {
-
-				const stackNodesBeforeSetup = builder.stack.nodes.length;
-
-				properties.initialized = true;
-				properties.outputNode = this.setup( builder );
-
-				if ( properties.outputNode !== null && builder.stack.nodes.length !== stackNodesBeforeSetup ) {
-
-					properties.outputNode = builder.stack;
-
-				}
-
-				for ( const childNode of Object.values( properties ) ) {
-
-					if ( childNode && childNode.isNode === true ) {
-
-						childNode.build( builder );
-
-					}
-
-				}
-
-			}
-
-		} else if ( buildStage === 'analyze' ) {
-
-			this.analyze( builder );
-
-		} else if ( buildStage === 'generate' ) {
-
-			const isGenerateOnce = this.generate.length === 1;
-
-			if ( isGenerateOnce ) {
-
-				const type = this.getNodeType( builder );
-				const nodeData = builder.getDataFromNode( this );
-
-				result = nodeData.snippet;
-
-				if ( result === undefined ) {
-
-					result = this.generate( builder ) || '';
-
-					nodeData.snippet = result;
-
-				}
-
-				result = builder.format( result, type, output );
-
-			} else {
-
-				result = this.generate( builder, output ) || '';
-
-			}
-
-		}
-
-		builder.removeChain( this );
-
-		return result;
-
-	}
-
-	getSerializeChildren() {
-
-		return getNodeChildren( this );
-
-	}
-
-	serialize( json ) {
-
-		const nodeChildren = this.getSerializeChildren();
-
-		const inputNodes = {};
-
-		for ( const { property, index, childNode } of nodeChildren ) {
-
-			if ( index !== undefined ) {
-
-				if ( inputNodes[ property ] === undefined ) {
-
-					inputNodes[ property ] = Number.isInteger( index ) ? [] : {};
-
-				}
-
-				inputNodes[ property ][ index ] = childNode.toJSON( json.meta ).uuid;
-
-			} else {
-
-				inputNodes[ property ] = childNode.toJSON( json.meta ).uuid;
-
-			}
-
-		}
-
-		if ( Object.keys( inputNodes ).length > 0 ) {
-
-			json.inputNodes = inputNodes;
-
-		}
-
-	}
-
-	deserialize( json ) {
-
-		if ( json.inputNodes !== undefined ) {
-
-			const nodes = json.meta.nodes;
-
-			for ( const property in json.inputNodes ) {
-
-				if ( Array.isArray( json.inputNodes[ property ] ) ) {
-
-					const inputArray = [];
-
-					for ( const uuid of json.inputNodes[ property ] ) {
-
-						inputArray.push( nodes[ uuid ] );
-
-					}
-
-					this[ property ] = inputArray;
-
-				} else if ( typeof json.inputNodes[ property ] === 'object' ) {
-
-					const inputObject = {};
-
-					for ( const subProperty in json.inputNodes[ property ] ) {
-
-						const uuid = json.inputNodes[ property ][ subProperty ];
-
-						inputObject[ subProperty ] = nodes[ uuid ];
-
-					}
-
-					this[ property ] = inputObject;
-
-				} else {
-
-					const uuid = json.inputNodes[ property ];
-
-					this[ property ] = nodes[ uuid ];
-
-				}
-
-			}
-
-		}
-
-	}
-
-	toJSON( meta ) {
-
-		const { uuid, type } = this;
-		const isRoot = ( meta === undefined || typeof meta === 'string' );
-
-		if ( isRoot ) {
-
-			meta = {
-				textures: {},
-				images: {},
-				nodes: {}
-			};
-
-		}
-
-		// serialize
-
-		let data = meta.nodes[ uuid ];
-
-		if ( data === undefined ) {
-
-			data = {
-				uuid,
-				type,
-				meta,
-				metadata: {
-					version: 4.6,
-					type: 'Node',
-					generator: 'Node.toJSON'
-				}
-			};
-
-			if ( isRoot !== true ) meta.nodes[ data.uuid ] = data;
-
-			this.serialize( data );
-
-			delete data.meta;
-
-		}
-
-		// TODO: Copied from Object3D.toJSON
-
-		function extractFromCache( cache ) {
-
-			const values = [];
-
-			for ( const key in cache ) {
-
-				const data = cache[ key ];
-				delete data.metadata;
-				values.push( data );
-
-			}
-
-			return values;
-
-		}
-
-		if ( isRoot ) {
-
-			const textures = extractFromCache( meta.textures );
-			const images = extractFromCache( meta.images );
-			const nodes = extractFromCache( meta.nodes );
-
-			if ( textures.length > 0 ) data.textures = textures;
-			if ( images.length > 0 ) data.images = images;
-			if ( nodes.length > 0 ) data.nodes = nodes;
-
-		}
-
-		return data;
-
-	}
-
-}
-
-export default Node;
-
-export function addNodeClass( type, nodeClass ) {
-
-	if ( typeof nodeClass !== 'function' || ! type ) throw new Error( `Node class ${ type } is not a class` );
-	if ( NodeClasses.has( type ) ) {
-
-		console.warn( `Redefinition of node class ${ type }` );
-		return;
-
-	}
-
-	NodeClasses.set( type, nodeClass );
-	nodeClass.type = type;
-
-}
-
-export function createNodeFromType( type ) {
-
-	const Class = NodeClasses.get( type );
-
-	if ( Class !== undefined ) {
-
-		return new Class();
-
-	}
-
-}

+ 0 - 15
examples/jsm/nodes/core/NodeAttribute.js

@@ -1,15 +0,0 @@
-class NodeAttribute {
-
-	constructor( name, type, node = null ) {
-
-		this.isNodeAttribute = true;
-
-		this.name = name;
-		this.type = type;
-		this.node = node;
-
-	}
-
-}
-
-export default NodeAttribute;

+ 0 - 1393
examples/jsm/nodes/core/NodeBuilder.js

@@ -1,1393 +0,0 @@
-import NodeUniform from './NodeUniform.js';
-import NodeAttribute from './NodeAttribute.js';
-import NodeVarying from './NodeVarying.js';
-import NodeVar from './NodeVar.js';
-import NodeCode from './NodeCode.js';
-import NodeKeywords from './NodeKeywords.js';
-import NodeCache from './NodeCache.js';
-import ParameterNode from './ParameterNode.js';
-import FunctionNode from '../code/FunctionNode.js';
-import { createNodeMaterialFromType, default as NodeMaterial } from '../materials/NodeMaterial.js';
-import { NodeUpdateType, defaultBuildStages, shaderStages } from './constants.js';
-
-import {
-	NumberNodeUniform, Vector2NodeUniform, Vector3NodeUniform, Vector4NodeUniform,
-	ColorNodeUniform, Matrix3NodeUniform, Matrix4NodeUniform
-} from '../../renderers/common/nodes/NodeUniform.js';
-
-import BindGroup from '../../renderers/common/BindGroup.js';
-
-import {
-	REVISION, RenderTarget, Color, Vector2, Vector3, Vector4, IntType, UnsignedIntType, Float16BufferAttribute,
-	LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter
-} from 'three';
-
-import { stack } from './StackNode.js';
-import { getCurrentStack, setCurrentStack } from '../shadernode/ShaderNode.js';
-
-import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
-import ChainMap from '../../renderers/common/ChainMap.js';
-
-import PMREMGenerator from '../../renderers/common/extras/PMREMGenerator.js';
-
-const rendererCache = new WeakMap();
-
-const typeFromLength = new Map( [
-	[ 2, 'vec2' ],
-	[ 3, 'vec3' ],
-	[ 4, 'vec4' ],
-	[ 9, 'mat3' ],
-	[ 16, 'mat4' ]
-] );
-
-const typeFromArray = new Map( [
-	[ Int8Array, 'int' ],
-	[ Int16Array, 'int' ],
-	[ Int32Array, 'int' ],
-	[ Uint8Array, 'uint' ],
-	[ Uint16Array, 'uint' ],
-	[ Uint32Array, 'uint' ],
-	[ Float32Array, 'float' ]
-] );
-
-const toFloat = ( value ) => {
-
-	value = Number( value );
-
-	return value + ( value % 1 ? '' : '.0' );
-
-};
-
-class NodeBuilder {
-
-	constructor( object, renderer, parser ) {
-
-		this.object = object;
-		this.material = ( object && object.material ) || null;
-		this.geometry = ( object && object.geometry ) || null;
-		this.renderer = renderer;
-		this.parser = parser;
-		this.scene = null;
-		this.camera = null;
-
-		this.nodes = [];
-		this.updateNodes = [];
-		this.updateBeforeNodes = [];
-		this.updateAfterNodes = [];
-		this.hashNodes = {};
-
-		this.lightsNode = null;
-		this.environmentNode = null;
-		this.fogNode = null;
-
-		this.clippingContext = null;
-
-		this.vertexShader = null;
-		this.fragmentShader = null;
-		this.computeShader = null;
-
-		this.flowNodes = { vertex: [], fragment: [], compute: [] };
-		this.flowCode = { vertex: '', fragment: '', compute: '' };
-		this.uniforms = { vertex: [], fragment: [], compute: [], index: 0 };
-		this.structs = { vertex: [], fragment: [], compute: [], index: 0 };
-		this.bindings = { vertex: {}, fragment: {}, compute: {} };
-		this.bindingsIndexes = {};
-		this.bindGroups = null;
-		this.attributes = [];
-		this.bufferAttributes = [];
-		this.varyings = [];
-		this.codes = {};
-		this.vars = {};
-		this.flow = { code: '' };
-		this.chaining = [];
-		this.stack = stack();
-		this.stacks = [];
-		this.tab = '\t';
-
-		this.instanceBindGroups = true;
-
-		this.currentFunctionNode = null;
-
-		this.context = {
-			keywords: new NodeKeywords(),
-			material: this.material
-		};
-
-		this.cache = new NodeCache();
-		this.globalCache = this.cache;
-
-		this.flowsData = new WeakMap();
-
-		this.shaderStage = null;
-		this.buildStage = null;
-
-	}
-
-	getBingGroupsCache() {
-
-		let bindGroupsCache = rendererCache.get( this.renderer );
-
-		if ( bindGroupsCache === undefined ) {
-
-			bindGroupsCache = new ChainMap();
-
-			rendererCache.set( this.renderer, bindGroupsCache );
-
-		}
-
-		return bindGroupsCache;
-
-	}
-
-	createRenderTarget( width, height, options ) {
-
-		return new RenderTarget( width, height, options );
-
-	}
-
-	createCubeRenderTarget( size, options ) {
-
-		return new CubeRenderTarget( size, options );
-
-	}
-
-	createPMREMGenerator() {
-
-		// TODO: Move Materials.js to outside of the Nodes.js in order to remove this function and improve tree-shaking support
-
-		return new PMREMGenerator( this.renderer );
-
-	}
-
-	includes( node ) {
-
-		return this.nodes.includes( node );
-
-	}
-
-	_getBindGroup( groupName, bindings ) {
-
-		const bindGroupsCache = this.getBingGroupsCache();
-
-		// cache individual uniforms group
-
-		const bindingsArray = [];
-
-		let sharedGroup = true;
-
-		for ( const binding of bindings ) {
-
-			if ( binding.groupNode.shared === true ) {
-
-				// nodes is the chainmap key
-				const nodes = binding.getNodes();
-
-				let sharedBinding = bindGroupsCache.get( nodes );
-
-				if ( sharedBinding === undefined ) {
-
-					bindGroupsCache.set( nodes, binding );
-
-					sharedBinding = binding;
-
-				}
-
-				bindingsArray.push( sharedBinding );
-
-			} else {
-
-				bindingsArray.push( binding );
-
-				sharedGroup = false;
-
-			}
-
-		}
-
-		//
-
-		let bindGroup;
-
-		if ( sharedGroup ) {
-
-			bindGroup = bindGroupsCache.get( bindingsArray );
-
-			if ( bindGroup === undefined ) {
-
-				bindGroup = new BindGroup( groupName, bindingsArray );
-				bindGroupsCache.set( bindingsArray, bindGroup );
-
-			}
-
-		} else {
-
-			bindGroup = new BindGroup( groupName, bindingsArray );
-
-		}
-
-		return bindGroup;
-
-	}
-
-	getBindGroupArray( groupName, shaderStage ) {
-
-		const bindings = this.bindings[ shaderStage ];
-
-		let bindGroup = bindings[ groupName ];
-
-		if ( bindGroup === undefined ) {
-
-			if ( this.bindingsIndexes[ groupName ] === undefined ) {
-
-				this.bindingsIndexes[ groupName ] = { binding: 0, group: Object.keys( this.bindingsIndexes ).length };
-
-			}
-
-			bindings[ groupName ] = bindGroup = [];
-
-		}
-
-		return bindGroup;
-
-	}
-
-	getBindings() {
-
-		let bindingsGroups = this.bindGroups;
-
-		if ( bindingsGroups === null ) {
-
-			const groups = {};
-			const bindings = this.bindings;
-
-			for ( const shaderStage of shaderStages ) {
-
-				for ( const groupName in bindings[ shaderStage ] ) {
-
-					const uniforms = bindings[ shaderStage ][ groupName ];
-
-					const groupUniforms = groups[ groupName ] || ( groups[ groupName ] = [] );
-					groupUniforms.push( ...uniforms );
-
-				}
-
-			}
-
-			bindingsGroups = [];
-
-			for ( const groupName in groups ) {
-
-				const group = groups[ groupName ];
-
-				const bindingsGroup = this._getBindGroup( groupName, group );
-
-				bindingsGroups.push( bindingsGroup );
-
-			}
-
-			this.bindGroups = bindingsGroups;
-
-		}
-
-		return bindingsGroups;
-
-	}
-
-	setHashNode( node, hash ) {
-
-		this.hashNodes[ hash ] = node;
-
-	}
-
-	addNode( node ) {
-
-		if ( this.nodes.includes( node ) === false ) {
-
-			this.nodes.push( node );
-
-			this.setHashNode( node, node.getHash( this ) );
-
-		}
-
-	}
-
-	buildUpdateNodes() {
-
-		for ( const node of this.nodes ) {
-
-			const updateType = node.getUpdateType();
-			const updateBeforeType = node.getUpdateBeforeType();
-			const updateAfterType = node.getUpdateAfterType();
-
-			if ( updateType !== NodeUpdateType.NONE ) {
-
-				this.updateNodes.push( node.getSelf() );
-
-			}
-
-			if ( updateBeforeType !== NodeUpdateType.NONE ) {
-
-				this.updateBeforeNodes.push( node );
-
-			}
-
-			if ( updateAfterType !== NodeUpdateType.NONE ) {
-
-				this.updateAfterNodes.push( node );
-
-			}
-
-		}
-
-	}
-
-	get currentNode() {
-
-		return this.chaining[ this.chaining.length - 1 ];
-
-	}
-
-	isFilteredTexture( texture ) {
-
-		return ( texture.magFilter === LinearFilter || texture.magFilter === LinearMipmapNearestFilter || texture.magFilter === NearestMipmapLinearFilter || texture.magFilter === LinearMipmapLinearFilter ||
-			texture.minFilter === LinearFilter || texture.minFilter === LinearMipmapNearestFilter || texture.minFilter === NearestMipmapLinearFilter || texture.minFilter === LinearMipmapLinearFilter );
-
-	}
-
-	addChain( node ) {
-
-		/*
-		if ( this.chaining.indexOf( node ) !== - 1 ) {
-
-			console.warn( 'Recursive node: ', node );
-
-		}
-		*/
-
-		this.chaining.push( node );
-
-	}
-
-	removeChain( node ) {
-
-		const lastChain = this.chaining.pop();
-
-		if ( lastChain !== node ) {
-
-			throw new Error( 'NodeBuilder: Invalid node chaining!' );
-
-		}
-
-	}
-
-	getMethod( method ) {
-
-		return method;
-
-	}
-
-	getNodeFromHash( hash ) {
-
-		return this.hashNodes[ hash ];
-
-	}
-
-	addFlow( shaderStage, node ) {
-
-		this.flowNodes[ shaderStage ].push( node );
-
-		return node;
-
-	}
-
-	setContext( context ) {
-
-		this.context = context;
-
-	}
-
-	getContext() {
-
-		return this.context;
-
-	}
-
-	setCache( cache ) {
-
-		this.cache = cache;
-
-	}
-
-	getCache() {
-
-		return this.cache;
-
-	}
-
-	getCacheFromNode( node, parent = true ) {
-
-		const data = this.getDataFromNode( node );
-		if ( data.cache === undefined ) data.cache = new NodeCache( parent ? this.getCache() : null );
-
-		return data.cache;
-
-	}
-
-	isAvailable( /*name*/ ) {
-
-		return false;
-
-	}
-
-	getVertexIndex() {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getInstanceIndex() {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getDrawIndex() {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getFrontFacing() {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getFragCoord() {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	isFlipY() {
-
-		return false;
-
-	}
-
-	generateTexture( /* texture, textureProperty, uvSnippet */ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	generateTextureLod( /* texture, textureProperty, uvSnippet, levelSnippet */ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	generateConst( type, value = null ) {
-
-		if ( value === null ) {
-
-			if ( type === 'float' || type === 'int' || type === 'uint' ) value = 0;
-			else if ( type === 'bool' ) value = false;
-			else if ( type === 'color' ) value = new Color();
-			else if ( type === 'vec2' ) value = new Vector2();
-			else if ( type === 'vec3' ) value = new Vector3();
-			else if ( type === 'vec4' ) value = new Vector4();
-
-		}
-
-		if ( type === 'float' ) return toFloat( value );
-		if ( type === 'int' ) return `${ Math.round( value ) }`;
-		if ( type === 'uint' ) return value >= 0 ? `${ Math.round( value ) }u` : '0u';
-		if ( type === 'bool' ) return value ? 'true' : 'false';
-		if ( type === 'color' ) return `${ this.getType( 'vec3' ) }( ${ toFloat( value.r ) }, ${ toFloat( value.g ) }, ${ toFloat( value.b ) } )`;
-
-		const typeLength = this.getTypeLength( type );
-
-		const componentType = this.getComponentType( type );
-
-		const generateConst = value => this.generateConst( componentType, value );
-
-		if ( typeLength === 2 ) {
-
-			return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) } )`;
-
-		} else if ( typeLength === 3 ) {
-
-			return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) } )`;
-
-		} else if ( typeLength === 4 ) {
-
-			return `${ this.getType( type ) }( ${ generateConst( value.x ) }, ${ generateConst( value.y ) }, ${ generateConst( value.z ) }, ${ generateConst( value.w ) } )`;
-
-		} else if ( typeLength > 4 && value && ( value.isMatrix3 || value.isMatrix4 ) ) {
-
-			return `${ this.getType( type ) }( ${ value.elements.map( generateConst ).join( ', ' ) } )`;
-
-		} else if ( typeLength > 4 ) {
-
-			return `${ this.getType( type ) }()`;
-
-		}
-
-		throw new Error( `NodeBuilder: Type '${type}' not found in generate constant attempt.` );
-
-	}
-
-	getType( type ) {
-
-		if ( type === 'color' ) return 'vec3';
-
-		return type;
-
-	}
-
-	hasGeometryAttribute( name ) {
-
-		return this.geometry && this.geometry.getAttribute( name ) !== undefined;
-
-	}
-
-	getAttribute( name, type ) {
-
-		const attributes = this.attributes;
-
-		// find attribute
-
-		for ( const attribute of attributes ) {
-
-			if ( attribute.name === name ) {
-
-				return attribute;
-
-			}
-
-		}
-
-		// create a new if no exist
-
-		const attribute = new NodeAttribute( name, type );
-
-		attributes.push( attribute );
-
-		return attribute;
-
-	}
-
-	getPropertyName( node/*, shaderStage*/ ) {
-
-		return node.name;
-
-	}
-
-	isVector( type ) {
-
-		return /vec\d/.test( type );
-
-	}
-
-	isMatrix( type ) {
-
-		return /mat\d/.test( type );
-
-	}
-
-	isReference( type ) {
-
-		return type === 'void' || type === 'property' || type === 'sampler' || type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'depthTexture' || type === 'texture3D';
-
-	}
-
-	needsColorSpaceToLinear( /*texture*/ ) {
-
-		return false;
-
-	}
-
-	getComponentTypeFromTexture( texture ) {
-
-		const type = texture.type;
-
-		if ( texture.isDataTexture ) {
-
-			if ( type === IntType ) return 'int';
-			if ( type === UnsignedIntType ) return 'uint';
-
-		}
-
-		return 'float';
-
-	}
-
-	getElementType( type ) {
-
-		if ( type === 'mat2' ) return 'vec2';
-		if ( type === 'mat3' ) return 'vec3';
-		if ( type === 'mat4' ) return 'vec4';
-
-		return this.getComponentType( type );
-
-	}
-
-	getComponentType( type ) {
-
-		type = this.getVectorType( type );
-
-		if ( type === 'float' || type === 'bool' || type === 'int' || type === 'uint' ) return type;
-
-		const componentType = /(b|i|u|)(vec|mat)([2-4])/.exec( type );
-
-		if ( componentType === null ) return null;
-
-		if ( componentType[ 1 ] === 'b' ) return 'bool';
-		if ( componentType[ 1 ] === 'i' ) return 'int';
-		if ( componentType[ 1 ] === 'u' ) return 'uint';
-
-		return 'float';
-
-	}
-
-	getVectorType( type ) {
-
-		if ( type === 'color' ) return 'vec3';
-		if ( type === 'texture' || type === 'cubeTexture' || type === 'storageTexture' || type === 'texture3D' ) return 'vec4';
-
-		return type;
-
-	}
-
-	getTypeFromLength( length, componentType = 'float' ) {
-
-		if ( length === 1 ) return componentType;
-
-		const baseType = typeFromLength.get( length );
-		const prefix = componentType === 'float' ? '' : componentType[ 0 ];
-
-		return prefix + baseType;
-
-	}
-
-	getTypeFromArray( array ) {
-
-		return typeFromArray.get( array.constructor );
-
-	}
-
-	getTypeFromAttribute( attribute ) {
-
-		let dataAttribute = attribute;
-
-		if ( attribute.isInterleavedBufferAttribute ) dataAttribute = attribute.data;
-
-		const array = dataAttribute.array;
-		const itemSize = attribute.itemSize;
-		const normalized = attribute.normalized;
-
-		let arrayType;
-
-		if ( ! ( attribute instanceof Float16BufferAttribute ) && normalized !== true ) {
-
-			arrayType = this.getTypeFromArray( array );
-
-		}
-
-		return this.getTypeFromLength( itemSize, arrayType );
-
-	}
-
-	getTypeLength( type ) {
-
-		const vecType = this.getVectorType( type );
-		const vecNum = /vec([2-4])/.exec( vecType );
-
-		if ( vecNum !== null ) return Number( vecNum[ 1 ] );
-		if ( vecType === 'float' || vecType === 'bool' || vecType === 'int' || vecType === 'uint' ) return 1;
-		if ( /mat2/.test( type ) === true ) return 4;
-		if ( /mat3/.test( type ) === true ) return 9;
-		if ( /mat4/.test( type ) === true ) return 16;
-
-		return 0;
-
-	}
-
-	getVectorFromMatrix( type ) {
-
-		return type.replace( 'mat', 'vec' );
-
-	}
-
-	changeComponentType( type, newComponentType ) {
-
-		return this.getTypeFromLength( this.getTypeLength( type ), newComponentType );
-
-	}
-
-	getIntegerType( type ) {
-
-		const componentType = this.getComponentType( type );
-
-		if ( componentType === 'int' || componentType === 'uint' ) return type;
-
-		return this.changeComponentType( type, 'int' );
-
-	}
-
-	addStack() {
-
-		this.stack = stack( this.stack );
-
-		this.stacks.push( getCurrentStack() || this.stack );
-		setCurrentStack( this.stack );
-
-		return this.stack;
-
-	}
-
-	removeStack() {
-
-		const lastStack = this.stack;
-		this.stack = lastStack.parent;
-
-		setCurrentStack( this.stacks.pop() );
-
-		return lastStack;
-
-	}
-
-	getDataFromNode( node, shaderStage = this.shaderStage, cache = null ) {
-
-		cache = cache === null ? ( node.isGlobal( this ) ? this.globalCache : this.cache ) : cache;
-
-		let nodeData = cache.getData( node );
-
-		if ( nodeData === undefined ) {
-
-			nodeData = {};
-
-			cache.setData( node, nodeData );
-
-		}
-
-		if ( nodeData[ shaderStage ] === undefined ) nodeData[ shaderStage ] = {};
-
-		return nodeData[ shaderStage ];
-
-	}
-
-	getNodeProperties( node, shaderStage = 'any' ) {
-
-		const nodeData = this.getDataFromNode( node, shaderStage );
-
-		return nodeData.properties || ( nodeData.properties = { outputNode: null } );
-
-	}
-
-	getBufferAttributeFromNode( node, type ) {
-
-		const nodeData = this.getDataFromNode( node );
-
-		let bufferAttribute = nodeData.bufferAttribute;
-
-		if ( bufferAttribute === undefined ) {
-
-			const index = this.uniforms.index ++;
-
-			bufferAttribute = new NodeAttribute( 'nodeAttribute' + index, type, node );
-
-			this.bufferAttributes.push( bufferAttribute );
-
-			nodeData.bufferAttribute = bufferAttribute;
-
-		}
-
-		return bufferAttribute;
-
-	}
-
-	getStructTypeFromNode( node, shaderStage = this.shaderStage ) {
-
-		const nodeData = this.getDataFromNode( node, shaderStage );
-
-		if ( nodeData.structType === undefined ) {
-
-			const index = this.structs.index ++;
-
-			node.name = `StructType${ index }`;
-			this.structs[ shaderStage ].push( node );
-
-			nodeData.structType = node;
-
-		}
-
-		return node;
-
-	}
-
-	getUniformFromNode( node, type, shaderStage = this.shaderStage, name = null ) {
-
-		const nodeData = this.getDataFromNode( node, shaderStage, this.globalCache );
-
-		let nodeUniform = nodeData.uniform;
-
-		if ( nodeUniform === undefined ) {
-
-			const index = this.uniforms.index ++;
-
-			nodeUniform = new NodeUniform( name || ( 'nodeUniform' + index ), type, node );
-
-			this.uniforms[ shaderStage ].push( nodeUniform );
-
-			nodeData.uniform = nodeUniform;
-
-		}
-
-		return nodeUniform;
-
-	}
-
-	getVarFromNode( node, name = null, type = node.getNodeType( this ), shaderStage = this.shaderStage ) {
-
-		const nodeData = this.getDataFromNode( node, shaderStage );
-
-		let nodeVar = nodeData.variable;
-
-		if ( nodeVar === undefined ) {
-
-			const vars = this.vars[ shaderStage ] || ( this.vars[ shaderStage ] = [] );
-
-			if ( name === null ) name = 'nodeVar' + vars.length;
-
-			nodeVar = new NodeVar( name, type );
-
-			vars.push( nodeVar );
-
-			nodeData.variable = nodeVar;
-
-		}
-
-		return nodeVar;
-
-	}
-
-	getVaryingFromNode( node, name = null, type = node.getNodeType( this ) ) {
-
-		const nodeData = this.getDataFromNode( node, 'any' );
-
-		let nodeVarying = nodeData.varying;
-
-		if ( nodeVarying === undefined ) {
-
-			const varyings = this.varyings;
-			const index = varyings.length;
-
-			if ( name === null ) name = 'nodeVarying' + index;
-
-			nodeVarying = new NodeVarying( name, type );
-
-			varyings.push( nodeVarying );
-
-			nodeData.varying = nodeVarying;
-
-		}
-
-		return nodeVarying;
-
-	}
-
-	getCodeFromNode( node, type, shaderStage = this.shaderStage ) {
-
-		const nodeData = this.getDataFromNode( node );
-
-		let nodeCode = nodeData.code;
-
-		if ( nodeCode === undefined ) {
-
-			const codes = this.codes[ shaderStage ] || ( this.codes[ shaderStage ] = [] );
-			const index = codes.length;
-
-			nodeCode = new NodeCode( 'nodeCode' + index, type );
-
-			codes.push( nodeCode );
-
-			nodeData.code = nodeCode;
-
-		}
-
-		return nodeCode;
-
-	}
-
-	addLineFlowCode( code ) {
-
-		if ( code === '' ) return this;
-
-		code = this.tab + code;
-
-		if ( ! /;\s*$/.test( code ) ) {
-
-			code = code + ';\n';
-
-		}
-
-		this.flow.code += code;
-
-		return this;
-
-	}
-
-	addFlowCode( code ) {
-
-		this.flow.code += code;
-
-		return this;
-
-	}
-
-	addFlowTab() {
-
-		this.tab += '\t';
-
-		return this;
-
-	}
-
-	removeFlowTab() {
-
-		this.tab = this.tab.slice( 0, - 1 );
-
-		return this;
-
-	}
-
-	getFlowData( node/*, shaderStage*/ ) {
-
-		return this.flowsData.get( node );
-
-	}
-
-	flowNode( node ) {
-
-		const output = node.getNodeType( this );
-
-		const flowData = this.flowChildNode( node, output );
-
-		this.flowsData.set( node, flowData );
-
-		return flowData;
-
-	}
-
-	buildFunctionNode( shaderNode ) {
-
-		const fn = new FunctionNode();
-
-		const previous = this.currentFunctionNode;
-
-		this.currentFunctionNode = fn;
-
-		fn.code = this.buildFunctionCode( shaderNode );
-
-		this.currentFunctionNode = previous;
-
-		return fn;
-
-	}
-
-	flowShaderNode( shaderNode ) {
-
-		const layout = shaderNode.layout;
-
-		let inputs;
-
-		if ( shaderNode.isArrayInput ) {
-
-			inputs = [];
-
-			for ( const input of layout.inputs ) {
-
-				inputs.push( new ParameterNode( input.type, input.name ) );
-
-			}
-
-		} else {
-
-			inputs = {};
-
-			for ( const input of layout.inputs ) {
-
-				inputs[ input.name ] = new ParameterNode( input.type, input.name );
-
-			}
-
-		}
-
-		//
-
-		shaderNode.layout = null;
-
-		const callNode = shaderNode.call( inputs );
-		const flowData = this.flowStagesNode( callNode, layout.type );
-
-		shaderNode.layout = layout;
-
-		return flowData;
-
-	}
-
-	flowStagesNode( node, output = null ) {
-
-		const previousFlow = this.flow;
-		const previousVars = this.vars;
-		const previousCache = this.cache;
-		const previousBuildStage = this.buildStage;
-		const previousStack = this.stack;
-
-		const flow = {
-			code: ''
-		};
-
-		this.flow = flow;
-		this.vars = {};
-		this.cache = new NodeCache();
-		this.stack = stack();
-
-		for ( const buildStage of defaultBuildStages ) {
-
-			this.setBuildStage( buildStage );
-
-			flow.result = node.build( this, output );
-
-		}
-
-		flow.vars = this.getVars( this.shaderStage );
-
-		this.flow = previousFlow;
-		this.vars = previousVars;
-		this.cache = previousCache;
-		this.stack = previousStack;
-
-		this.setBuildStage( previousBuildStage );
-
-		return flow;
-
-	}
-
-	getFunctionOperator() {
-
-		return null;
-
-	}
-
-	flowChildNode( node, output = null ) {
-
-		const previousFlow = this.flow;
-
-		const flow = {
-			code: ''
-		};
-
-		this.flow = flow;
-
-		flow.result = node.build( this, output );
-
-		this.flow = previousFlow;
-
-		return flow;
-
-	}
-
-	flowNodeFromShaderStage( shaderStage, node, output = null, propertyName = null ) {
-
-		const previousShaderStage = this.shaderStage;
-
-		this.setShaderStage( shaderStage );
-
-		const flowData = this.flowChildNode( node, output );
-
-		if ( propertyName !== null ) {
-
-			flowData.code += `${ this.tab + propertyName } = ${ flowData.result };\n`;
-
-		}
-
-		this.flowCode[ shaderStage ] = this.flowCode[ shaderStage ] + flowData.code;
-
-		this.setShaderStage( previousShaderStage );
-
-		return flowData;
-
-	}
-
-	getAttributesArray() {
-
-		return this.attributes.concat( this.bufferAttributes );
-
-	}
-
-	getAttributes( /*shaderStage*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getVaryings( /*shaderStage*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getVar( type, name ) {
-
-		return `${ this.getType( type ) } ${ name }`;
-
-	}
-
-	getVars( shaderStage ) {
-
-		let snippet = '';
-
-		const vars = this.vars[ shaderStage ];
-
-		if ( vars !== undefined ) {
-
-			for ( const variable of vars ) {
-
-				snippet += `${ this.getVar( variable.type, variable.name ) }; `;
-
-			}
-
-		}
-
-		return snippet;
-
-	}
-
-	getUniforms( /*shaderStage*/ ) {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	getCodes( shaderStage ) {
-
-		const codes = this.codes[ shaderStage ];
-
-		let code = '';
-
-		if ( codes !== undefined ) {
-
-			for ( const nodeCode of codes ) {
-
-				code += nodeCode.code + '\n';
-
-			}
-
-		}
-
-		return code;
-
-	}
-
-	getHash() {
-
-		return this.vertexShader + this.fragmentShader + this.computeShader;
-
-	}
-
-	setShaderStage( shaderStage ) {
-
-		this.shaderStage = shaderStage;
-
-	}
-
-	getShaderStage() {
-
-		return this.shaderStage;
-
-	}
-
-	setBuildStage( buildStage ) {
-
-		this.buildStage = buildStage;
-
-	}
-
-	getBuildStage() {
-
-		return this.buildStage;
-
-	}
-
-	buildCode() {
-
-		console.warn( 'Abstract function.' );
-
-	}
-
-	build() {
-
-		const { object, material } = this;
-
-
-		if ( material !== null ) {
-
-			NodeMaterial.fromMaterial( material ).build( this );
-
-		} else {
-
-			this.addFlow( 'compute', object );
-
-		}
-
-		// setup() -> stage 1: create possible new nodes and returns an output reference node
-		// analyze()   -> stage 2: analyze nodes to possible optimization and validation
-		// generate()  -> stage 3: generate shader
-
-		for ( const buildStage of defaultBuildStages ) {
-
-			this.setBuildStage( buildStage );
-
-			if ( this.context.vertex && this.context.vertex.isNode ) {
-
-				this.flowNodeFromShaderStage( 'vertex', this.context.vertex );
-
-			}
-
-			for ( const shaderStage of shaderStages ) {
-
-				this.setShaderStage( shaderStage );
-
-				const flowNodes = this.flowNodes[ shaderStage ];
-
-				for ( const node of flowNodes ) {
-
-					if ( buildStage === 'generate' ) {
-
-						this.flowNode( node );
-
-					} else {
-
-						node.build( this );
-
-					}
-
-				}
-
-			}
-
-		}
-
-		this.setBuildStage( null );
-		this.setShaderStage( null );
-
-		// stage 4: build code for a specific output
-
-		this.buildCode();
-		this.buildUpdateNodes();
-
-		return this;
-
-	}
-
-	getNodeUniform( uniformNode, type ) {
-
-		if ( type === 'float' || type === 'int' || type === 'uint' ) return new NumberNodeUniform( uniformNode );
-		if ( type === 'vec2' || type === 'ivec2' || type === 'uvec2' ) return new Vector2NodeUniform( uniformNode );
-		if ( type === 'vec3' || type === 'ivec3' || type === 'uvec3' ) return new Vector3NodeUniform( uniformNode );
-		if ( type === 'vec4' || type === 'ivec4' || type === 'uvec4' ) return new Vector4NodeUniform( uniformNode );
-		if ( type === 'color' ) return new ColorNodeUniform( uniformNode );
-		if ( type === 'mat3' ) return new Matrix3NodeUniform( uniformNode );
-		if ( type === 'mat4' ) return new Matrix4NodeUniform( uniformNode );
-
-		throw new Error( `Uniform "${type}" not declared.` );
-
-	}
-
-	createNodeMaterial( type = 'NodeMaterial' ) {
-
-		// TODO: Move Materials.js to outside of the Nodes.js in order to remove this function and improve tree-shaking support
-
-		return createNodeMaterialFromType( type );
-
-	}
-
-	format( snippet, fromType, toType ) {
-
-		fromType = this.getVectorType( fromType );
-		toType = this.getVectorType( toType );
-
-		if ( fromType === toType || toType === null || this.isReference( toType ) ) {
-
-			return snippet;
-
-		}
-
-		const fromTypeLength = this.getTypeLength( fromType );
-		const toTypeLength = this.getTypeLength( toType );
-
-		if ( fromTypeLength > 4 ) { // fromType is matrix-like
-
-			// @TODO: ignore for now
-
-			return snippet;
-
-		}
-
-		if ( toTypeLength > 4 || toTypeLength === 0 ) { // toType is matrix-like or unknown
-
-			// @TODO: ignore for now
-
-			return snippet;
-
-		}
-
-		if ( fromTypeLength === toTypeLength ) {
-
-			return `${ this.getType( toType ) }( ${ snippet } )`;
-
-		}
-
-		if ( fromTypeLength > toTypeLength ) {
-
-			return this.format( `${ snippet }.${ 'xyz'.slice( 0, toTypeLength ) }`, this.getTypeFromLength( toTypeLength, this.getComponentType( fromType ) ), toType );
-
-		}
-
-		if ( toTypeLength === 4 && fromTypeLength > 1 ) { // toType is vec4-like
-
-			return `${ this.getType( toType ) }( ${ this.format( snippet, fromType, 'vec3' ) }, 1.0 )`;
-
-		}
-
-		if ( fromTypeLength === 2 ) { // fromType is vec2-like and toType is vec3-like
-
-			return `${ this.getType( toType ) }( ${ this.format( snippet, fromType, 'vec2' ) }, 0.0 )`;
-
-		}
-
-		if ( fromTypeLength === 1 && toTypeLength > 1 && fromType !== this.getComponentType( toType ) ) { // fromType is float-like
-
-			// convert a number value to vector type, e.g:
-			// vec3( 1u ) -> vec3( float( 1u ) )
-
-			snippet = `${ this.getType( this.getComponentType( toType ) ) }( ${ snippet } )`;
-
-		}
-
-		return `${ this.getType( toType ) }( ${ snippet } )`; // fromType is float-like
-
-	}
-
-	getSignature() {
-
-		return `// Three.js r${ REVISION } - Node System\n`;
-
-	}
-
-}
-
-export default NodeBuilder;

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini

粤ICP备19079148号