super-three 0.169.0 → 0.170.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/build/three.cjs +989 -1131
  2. package/build/three.module.js +990 -1128
  3. package/build/three.module.min.js +1 -1
  4. package/build/three.webgpu.js +8398 -9842
  5. package/build/three.webgpu.min.js +1 -1
  6. package/build/three.webgpu.nodes.js +8398 -9842
  7. package/build/three.webgpu.nodes.min.js +1 -1
  8. package/examples/jsm/Addons.js +3 -3
  9. package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
  10. package/examples/jsm/animation/MMDPhysics.js +2 -0
  11. package/examples/jsm/controls/TransformControls.js +22 -6
  12. package/examples/jsm/csm/CSM.js +2 -2
  13. package/examples/jsm/csm/CSMFrustum.js +7 -4
  14. package/examples/jsm/csm/CSMHelper.js +2 -0
  15. package/examples/jsm/csm/CSMShadowNode.js +435 -0
  16. package/examples/jsm/curves/NURBSCurve.js +34 -3
  17. package/examples/jsm/exporters/GLTFExporter.js +138 -71
  18. package/examples/jsm/exporters/KTX2Exporter.js +35 -12
  19. package/examples/jsm/exporters/MMDExporter.js +6 -0
  20. package/examples/jsm/exporters/USDZExporter.js +21 -3
  21. package/examples/jsm/geometries/DecalGeometry.js +65 -20
  22. package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
  23. package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
  24. package/examples/jsm/interactive/HTMLMesh.js +1 -0
  25. package/examples/jsm/lighting/TiledLighting.js +18 -0
  26. package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
  27. package/examples/jsm/lines/LineMaterial.js +7 -2
  28. package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
  29. package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
  30. package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
  31. package/examples/jsm/loaders/3DMLoader.js +1 -0
  32. package/examples/jsm/loaders/3MFLoader.js +91 -0
  33. package/examples/jsm/loaders/FBXLoader.js +12 -2
  34. package/examples/jsm/loaders/GLTFLoader.js +2 -0
  35. package/examples/jsm/loaders/KTX2Loader.js +140 -49
  36. package/examples/jsm/loaders/LDrawLoader.js +22 -136
  37. package/examples/jsm/loaders/LottieLoader.js +1 -0
  38. package/examples/jsm/loaders/MMDLoader.js +9 -2
  39. package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
  40. package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
  41. package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
  42. package/examples/jsm/math/ColorSpaces.js +76 -0
  43. package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
  44. package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
  45. package/examples/jsm/misc/VolumeSlice.js +1 -0
  46. package/examples/jsm/objects/WaterMesh.js +8 -8
  47. package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
  48. package/examples/jsm/postprocessing/SSRPass.js +6 -0
  49. package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
  50. package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
  51. package/examples/jsm/shaders/FXAAShader.js +225 -224
  52. package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
  53. package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
  54. package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
  55. package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
  56. package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
  57. package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
  58. package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
  59. package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
  60. package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
  61. package/examples/jsm/tsl/display/FXAANode.js +316 -0
  62. package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
  63. package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
  64. package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
  65. package/examples/jsm/tsl/display/LensflareNode.js +161 -0
  66. package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
  67. package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
  68. package/examples/jsm/tsl/display/OutlineNode.js +434 -0
  69. package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
  70. package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
  71. package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
  72. package/examples/jsm/tsl/display/SMAANode.js +620 -0
  73. package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
  74. package/examples/jsm/tsl/display/SSRNode.js +343 -0
  75. package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
  76. package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
  77. package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
  78. package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
  79. package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
  80. package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
  81. package/examples/jsm/tsl/display/hashBlur.js +24 -0
  82. package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
  83. package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
  84. package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
  85. package/examples/jsm/webxr/Text2D.js +6 -6
  86. package/package.json +2 -2
  87. package/src/Three.WebGPU.Nodes.js +4 -0
  88. package/src/Three.WebGPU.js +4 -0
  89. package/src/constants.js +1 -6
  90. package/src/core/BufferGeometry.js +44 -6
  91. package/src/geometries/CylinderGeometry.js +2 -2
  92. package/src/materials/LineBasicMaterial.js +6 -2
  93. package/src/materials/LineDashedMaterial.js +6 -2
  94. package/src/materials/Material.js +14 -1
  95. package/src/materials/MeshBasicMaterial.js +6 -2
  96. package/src/materials/MeshDepthMaterial.js +6 -2
  97. package/src/materials/MeshDistanceMaterial.js +6 -2
  98. package/src/materials/MeshLambertMaterial.js +6 -2
  99. package/src/materials/MeshMatcapMaterial.js +6 -2
  100. package/src/materials/MeshNormalMaterial.js +6 -2
  101. package/src/materials/MeshPhongMaterial.js +6 -2
  102. package/src/materials/MeshPhysicalMaterial.js +6 -2
  103. package/src/materials/MeshStandardMaterial.js +6 -2
  104. package/src/materials/MeshToonMaterial.js +6 -2
  105. package/src/materials/PointsMaterial.js +6 -2
  106. package/src/materials/RawShaderMaterial.js +6 -2
  107. package/src/materials/ShaderMaterial.js +6 -2
  108. package/src/materials/ShadowMaterial.js +6 -2
  109. package/src/materials/SpriteMaterial.js +6 -2
  110. package/src/materials/nodes/NodeMaterial.js +31 -9
  111. package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
  112. package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
  113. package/src/math/ColorManagement.js +118 -85
  114. package/src/math/Vector4.js +11 -0
  115. package/src/nodes/Nodes.js +1 -21
  116. package/src/nodes/TSL.js +6 -24
  117. package/src/nodes/accessors/Camera.js +0 -1
  118. package/src/nodes/accessors/SceneNode.js +35 -1
  119. package/src/nodes/accessors/StorageBufferNode.js +32 -10
  120. package/src/nodes/accessors/VelocityNode.js +13 -3
  121. package/src/nodes/code/FunctionCallNode.js +16 -5
  122. package/src/nodes/code/ScriptableNode.js +4 -4
  123. package/src/nodes/core/Node.js +1 -0
  124. package/src/nodes/core/NodeBuilder.js +29 -5
  125. package/src/nodes/core/VarNode.js +15 -3
  126. package/src/nodes/display/ColorAdjustment.js +53 -4
  127. package/src/nodes/display/ColorSpaceFunctions.js +5 -5
  128. package/src/nodes/display/ColorSpaceNode.js +27 -39
  129. package/src/nodes/display/PassNode.js +6 -4
  130. package/src/nodes/display/ToneMappingNode.js +1 -1
  131. package/src/nodes/display/ViewportDepthNode.js +33 -1
  132. package/src/nodes/functions/PhysicalLightingModel.js +21 -15
  133. package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
  134. package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
  135. package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
  136. package/src/nodes/gpgpu/ComputeNode.js +9 -1
  137. package/src/nodes/lighting/AnalyticLightNode.js +12 -416
  138. package/src/nodes/lighting/LightsNode.js +24 -12
  139. package/src/nodes/lighting/PointLightNode.js +36 -26
  140. package/src/nodes/lighting/RectAreaLightNode.js +3 -0
  141. package/src/nodes/lighting/ShadowNode.js +484 -0
  142. package/src/nodes/utils/LoopNode.js +2 -2
  143. package/src/nodes/utils/Oscillators.js +6 -0
  144. package/src/nodes/utils/PostProcessingUtils.js +89 -0
  145. package/src/nodes/utils/ReflectorNode.js +101 -15
  146. package/src/nodes/utils/Timer.js +29 -0
  147. package/src/objects/BatchedMesh.js +458 -241
  148. package/src/renderers/WebGLRenderer.js +121 -126
  149. package/src/renderers/common/Attributes.js +4 -0
  150. package/src/renderers/common/Backend.js +2 -0
  151. package/src/renderers/common/Background.js +14 -4
  152. package/src/renderers/common/Bindings.js +3 -2
  153. package/src/renderers/common/Constants.js +2 -1
  154. package/src/renderers/common/Geometries.js +20 -0
  155. package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
  156. package/src/renderers/common/Lighting.js +45 -0
  157. package/src/renderers/common/PostProcessingUtils.js +86 -0
  158. package/src/renderers/common/RenderList.js +39 -11
  159. package/src/renderers/common/RenderLists.js +4 -2
  160. package/src/renderers/common/RenderObject.js +18 -1
  161. package/src/renderers/common/Renderer.js +165 -26
  162. package/src/renderers/common/Textures.js +30 -14
  163. package/src/renderers/common/nodes/NodeLibrary.js +1 -14
  164. package/src/renderers/common/nodes/Nodes.js +2 -2
  165. package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
  166. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
  167. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
  168. package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
  169. package/src/renderers/webgl/WebGLCapabilities.js +0 -7
  170. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
  171. package/src/renderers/webgl/WebGLProgram.js +24 -28
  172. package/src/renderers/webgl/WebGLPrograms.js +5 -2
  173. package/src/renderers/webgl/WebGLState.js +37 -1
  174. package/src/renderers/webgl/WebGLTextures.js +29 -12
  175. package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
  176. package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
  177. package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
  178. package/src/renderers/webgpu/WebGPUBackend.js +105 -25
  179. package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
  180. package/src/renderers/webgpu/WebGPURenderer.js +1 -1
  181. package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
  182. package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
  183. package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
  184. package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
  185. package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
  186. package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
  187. package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
  188. package/src/renderers/webxr/WebXRManager.js +4 -4
  189. package/examples/jsm/cameras/CinematicCamera.js +0 -208
  190. package/src/nodes/display/FXAANode.js +0 -332
  191. package/src/nodes/utils/OscNode.js +0 -85
  192. package/src/nodes/utils/TimerNode.js +0 -97
  193. package/src/renderers/webvr/WebVRManager.js +0 -495
  194. package/src/renderers/webvr/WebVRUtils.js +0 -66
  195. /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
@@ -35,6 +35,7 @@ class BufferGeometry extends EventDispatcher {
35
35
  this.type = 'BufferGeometry';
36
36
 
37
37
  this.index = null;
38
+ this.indirect = null;
38
39
  this.attributes = {};
39
40
 
40
41
  this.morphAttributes = {};
@@ -73,6 +74,20 @@ class BufferGeometry extends EventDispatcher {
73
74
 
74
75
  }
75
76
 
77
+ setIndirect( indirect ) {
78
+
79
+ this.indirect = indirect;
80
+
81
+ return this;
82
+
83
+ }
84
+
85
+ getIndirect() {
86
+
87
+ return this.indirect;
88
+
89
+ }
90
+
76
91
  getAttribute( name ) {
77
92
 
78
93
  return this.attributes[ name ];
@@ -272,16 +287,39 @@ class BufferGeometry extends EventDispatcher {
272
287
 
273
288
  setFromPoints( points ) {
274
289
 
275
- const position = [];
290
+ const positionAttribute = this.getAttribute( 'position' );
276
291
 
277
- for ( let i = 0, l = points.length; i < l; i ++ ) {
292
+ if ( positionAttribute === undefined ) {
278
293
 
279
- const point = points[ i ];
280
- position.push( point.x, point.y, point.z || 0 );
294
+ const position = [];
281
295
 
282
- }
296
+ for ( let i = 0, l = points.length; i < l; i ++ ) {
297
+
298
+ const point = points[ i ];
299
+ position.push( point.x, point.y, point.z || 0 );
300
+
301
+ }
302
+
303
+ this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
304
+
305
+ } else {
306
+
307
+ for ( let i = 0, l = positionAttribute.count; i < l; i ++ ) {
308
+
309
+ const point = points[ i ];
310
+ positionAttribute.setXYZ( i, point.x, point.y, point.z || 0 );
311
+
312
+ }
313
+
314
+ if ( points.length > positionAttribute.count ) {
283
315
 
284
- this.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );
316
+ console.warn( 'THREE.BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry.' );
317
+
318
+ }
319
+
320
+ positionAttribute.needsUpdate = true;
321
+
322
+ }
285
323
 
286
324
  return this;
287
325
 
@@ -133,14 +133,14 @@ class CylinderGeometry extends BufferGeometry {
133
133
 
134
134
  // faces
135
135
 
136
- if ( radiusTop > 0 ) {
136
+ if ( radiusTop > 0 || y !== 0 ) {
137
137
 
138
138
  indices.push( a, b, d );
139
139
  groupCount += 3;
140
140
 
141
141
  }
142
142
 
143
- if ( radiusBottom > 0 ) {
143
+ if ( radiusBottom > 0 || y !== heightSegments - 1 ) {
144
144
 
145
145
  indices.push( b, c, d );
146
146
  groupCount += 3;
@@ -3,14 +3,18 @@ import { Color } from '../math/Color.js';
3
3
 
4
4
  class LineBasicMaterial extends Material {
5
5
 
6
+ static get type() {
7
+
8
+ return 'LineBasicMaterial';
9
+
10
+ }
11
+
6
12
  constructor( parameters ) {
7
13
 
8
14
  super();
9
15
 
10
16
  this.isLineBasicMaterial = true;
11
17
 
12
- this.type = 'LineBasicMaterial';
13
-
14
18
  this.color = new Color( 0xffffff );
15
19
 
16
20
  this.map = null;
@@ -2,14 +2,18 @@ import { LineBasicMaterial } from './LineBasicMaterial.js';
2
2
 
3
3
  class LineDashedMaterial extends LineBasicMaterial {
4
4
 
5
+ static get type() {
6
+
7
+ return 'LineDashedMaterial';
8
+
9
+ }
10
+
5
11
  constructor( parameters ) {
6
12
 
7
13
  super();
8
14
 
9
15
  this.isLineDashedMaterial = true;
10
16
 
11
- this.type = 'LineDashedMaterial';
12
-
13
17
  this.scale = 1;
14
18
  this.dashSize = 3;
15
19
  this.gapSize = 1;
@@ -7,6 +7,20 @@ let _materialId = 0;
7
7
 
8
8
  class Material extends EventDispatcher {
9
9
 
10
+ static get type() {
11
+
12
+ return 'Material';
13
+
14
+ }
15
+
16
+ get type() {
17
+
18
+ return this.constructor.type;
19
+
20
+ }
21
+
22
+ set type( _value ) { /* */ }
23
+
10
24
  constructor() {
11
25
 
12
26
  super();
@@ -18,7 +32,6 @@ class Material extends EventDispatcher {
18
32
  this.uuid = MathUtils.generateUUID();
19
33
 
20
34
  this.name = '';
21
- this.type = 'Material';
22
35
 
23
36
  this.blending = NormalBlending;
24
37
  this.side = FrontSide;
@@ -5,14 +5,18 @@ import { Euler } from '../math/Euler.js';
5
5
 
6
6
  class MeshBasicMaterial extends Material {
7
7
 
8
+ static get type() {
9
+
10
+ return 'MeshBasicMaterial';
11
+
12
+ }
13
+
8
14
  constructor( parameters ) {
9
15
 
10
16
  super();
11
17
 
12
18
  this.isMeshBasicMaterial = true;
13
19
 
14
- this.type = 'MeshBasicMaterial';
15
-
16
20
  this.color = new Color( 0xffffff ); // emissive
17
21
 
18
22
  this.map = null;
@@ -3,14 +3,18 @@ import { BasicDepthPacking } from '../constants.js';
3
3
 
4
4
  class MeshDepthMaterial extends Material {
5
5
 
6
+ static get type() {
7
+
8
+ return 'MeshDepthMaterial';
9
+
10
+ }
11
+
6
12
  constructor( parameters ) {
7
13
 
8
14
  super();
9
15
 
10
16
  this.isMeshDepthMaterial = true;
11
17
 
12
- this.type = 'MeshDepthMaterial';
13
-
14
18
  this.depthPacking = BasicDepthPacking;
15
19
 
16
20
  this.map = null;
@@ -2,14 +2,18 @@ import { Material } from './Material.js';
2
2
 
3
3
  class MeshDistanceMaterial extends Material {
4
4
 
5
+ static get type() {
6
+
7
+ return 'MeshDistanceMaterial';
8
+
9
+ }
10
+
5
11
  constructor( parameters ) {
6
12
 
7
13
  super();
8
14
 
9
15
  this.isMeshDistanceMaterial = true;
10
16
 
11
- this.type = 'MeshDistanceMaterial';
12
-
13
17
  this.map = null;
14
18
 
15
19
  this.alphaMap = null;
@@ -6,14 +6,18 @@ import { Euler } from '../math/Euler.js';
6
6
 
7
7
  class MeshLambertMaterial extends Material {
8
8
 
9
+ static get type() {
10
+
11
+ return 'MeshLambertMaterial';
12
+
13
+ }
14
+
9
15
  constructor( parameters ) {
10
16
 
11
17
  super();
12
18
 
13
19
  this.isMeshLambertMaterial = true;
14
20
 
15
- this.type = 'MeshLambertMaterial';
16
-
17
21
  this.color = new Color( 0xffffff ); // diffuse
18
22
 
19
23
  this.map = null;
@@ -5,6 +5,12 @@ import { Color } from '../math/Color.js';
5
5
 
6
6
  class MeshMatcapMaterial extends Material {
7
7
 
8
+ static get type() {
9
+
10
+ return 'MeshMatcapMaterial';
11
+
12
+ }
13
+
8
14
  constructor( parameters ) {
9
15
 
10
16
  super();
@@ -13,8 +19,6 @@ class MeshMatcapMaterial extends Material {
13
19
 
14
20
  this.defines = { 'MATCAP': '' };
15
21
 
16
- this.type = 'MeshMatcapMaterial';
17
-
18
22
  this.color = new Color( 0xffffff ); // diffuse
19
23
 
20
24
  this.matcap = null;
@@ -4,14 +4,18 @@ import { Vector2 } from '../math/Vector2.js';
4
4
 
5
5
  class MeshNormalMaterial extends Material {
6
6
 
7
+ static get type() {
8
+
9
+ return 'MeshNormalMaterial';
10
+
11
+ }
12
+
7
13
  constructor( parameters ) {
8
14
 
9
15
  super();
10
16
 
11
17
  this.isMeshNormalMaterial = true;
12
18
 
13
- this.type = 'MeshNormalMaterial';
14
-
15
19
  this.bumpMap = null;
16
20
  this.bumpScale = 1;
17
21
 
@@ -6,14 +6,18 @@ import { Euler } from '../math/Euler.js';
6
6
 
7
7
  class MeshPhongMaterial extends Material {
8
8
 
9
+ static get type() {
10
+
11
+ return 'MeshPhongMaterial';
12
+
13
+ }
14
+
9
15
  constructor( parameters ) {
10
16
 
11
17
  super();
12
18
 
13
19
  this.isMeshPhongMaterial = true;
14
20
 
15
- this.type = 'MeshPhongMaterial';
16
-
17
21
  this.color = new Color( 0xffffff ); // diffuse
18
22
  this.specular = new Color( 0x111111 );
19
23
  this.shininess = 30;
@@ -5,6 +5,12 @@ import * as MathUtils from '../math/MathUtils.js';
5
5
 
6
6
  class MeshPhysicalMaterial extends MeshStandardMaterial {
7
7
 
8
+ static get type() {
9
+
10
+ return 'MeshPhysicalMaterial';
11
+
12
+ }
13
+
8
14
  constructor( parameters ) {
9
15
 
10
16
  super();
@@ -18,8 +24,6 @@ class MeshPhysicalMaterial extends MeshStandardMaterial {
18
24
 
19
25
  };
20
26
 
21
- this.type = 'MeshPhysicalMaterial';
22
-
23
27
  this.anisotropyRotation = 0;
24
28
  this.anisotropyMap = null;
25
29
 
@@ -6,6 +6,12 @@ import { Euler } from '../math/Euler.js';
6
6
 
7
7
  class MeshStandardMaterial extends Material {
8
8
 
9
+ static get type() {
10
+
11
+ return 'MeshStandardMaterial';
12
+
13
+ }
14
+
9
15
  constructor( parameters ) {
10
16
 
11
17
  super();
@@ -14,8 +20,6 @@ class MeshStandardMaterial extends Material {
14
20
 
15
21
  this.defines = { 'STANDARD': '' };
16
22
 
17
- this.type = 'MeshStandardMaterial';
18
-
19
23
  this.color = new Color( 0xffffff ); // diffuse
20
24
  this.roughness = 1.0;
21
25
  this.metalness = 0.0;
@@ -5,6 +5,12 @@ import { Color } from '../math/Color.js';
5
5
 
6
6
  class MeshToonMaterial extends Material {
7
7
 
8
+ static get type() {
9
+
10
+ return 'MeshToonMaterial';
11
+
12
+ }
13
+
8
14
  constructor( parameters ) {
9
15
 
10
16
  super();
@@ -13,8 +19,6 @@ class MeshToonMaterial extends Material {
13
19
 
14
20
  this.defines = { 'TOON': '' };
15
21
 
16
- this.type = 'MeshToonMaterial';
17
-
18
22
  this.color = new Color( 0xffffff );
19
23
 
20
24
  this.map = null;
@@ -3,14 +3,18 @@ import { Color } from '../math/Color.js';
3
3
 
4
4
  class PointsMaterial extends Material {
5
5
 
6
+ static get type() {
7
+
8
+ return 'PointsMaterial';
9
+
10
+ }
11
+
6
12
  constructor( parameters ) {
7
13
 
8
14
  super();
9
15
 
10
16
  this.isPointsMaterial = true;
11
17
 
12
- this.type = 'PointsMaterial';
13
-
14
18
  this.color = new Color( 0xffffff );
15
19
 
16
20
  this.map = null;
@@ -2,14 +2,18 @@ import { ShaderMaterial } from './ShaderMaterial.js';
2
2
 
3
3
  class RawShaderMaterial extends ShaderMaterial {
4
4
 
5
+ static get type() {
6
+
7
+ return 'RawShaderMaterial';
8
+
9
+ }
10
+
5
11
  constructor( parameters ) {
6
12
 
7
13
  super( parameters );
8
14
 
9
15
  this.isRawShaderMaterial = true;
10
16
 
11
- this.type = 'RawShaderMaterial';
12
-
13
17
  }
14
18
 
15
19
  }
@@ -6,14 +6,18 @@ import default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.
6
6
 
7
7
  class ShaderMaterial extends Material {
8
8
 
9
+ static get type() {
10
+
11
+ return 'ShaderMaterial';
12
+
13
+ }
14
+
9
15
  constructor( parameters ) {
10
16
 
11
17
  super();
12
18
 
13
19
  this.isShaderMaterial = true;
14
20
 
15
- this.type = 'ShaderMaterial';
16
-
17
21
  this.defines = {};
18
22
  this.uniforms = {};
19
23
  this.uniformsGroups = [];
@@ -3,14 +3,18 @@ import { Color } from '../math/Color.js';
3
3
 
4
4
  class ShadowMaterial extends Material {
5
5
 
6
+ static get type() {
7
+
8
+ return 'ShadowMaterial';
9
+
10
+ }
11
+
6
12
  constructor( parameters ) {
7
13
 
8
14
  super();
9
15
 
10
16
  this.isShadowMaterial = true;
11
17
 
12
- this.type = 'ShadowMaterial';
13
-
14
18
  this.color = new Color( 0x000000 );
15
19
  this.transparent = true;
16
20
 
@@ -3,14 +3,18 @@ import { Color } from '../math/Color.js';
3
3
 
4
4
  class SpriteMaterial extends Material {
5
5
 
6
+ static get type() {
7
+
8
+ return 'SpriteMaterial';
9
+
10
+ }
11
+
6
12
  constructor( parameters ) {
7
13
 
8
14
  super();
9
15
 
10
16
  this.isSpriteMaterial = true;
11
17
 
12
- this.type = 'SpriteMaterial';
13
-
14
18
  this.color = new Color( 0xffffff );
15
19
 
16
20
  this.map = null;
@@ -10,19 +10,19 @@ import { normalLocal } from '../../nodes/accessors/Normal.js';
10
10
  import { instance } from '../../nodes/accessors/InstanceNode.js';
11
11
  import { batch } from '../../nodes/accessors/BatchNode.js';
12
12
  import { materialReference } from '../../nodes/accessors/MaterialReferenceNode.js';
13
- import { positionLocal } from '../../nodes/accessors/Position.js';
13
+ import { positionLocal, positionView } from '../../nodes/accessors/Position.js';
14
14
  import { skinningReference } from '../../nodes/accessors/SkinningNode.js';
15
15
  import { morphReference } from '../../nodes/accessors/MorphNode.js';
16
- import { lights } from '../../nodes/lighting/LightsNode.js';
17
16
  import { mix } from '../../nodes/math/MathNode.js';
18
17
  import { float, vec3, vec4 } from '../../nodes/tsl/TSLBase.js';
19
18
  import AONode from '../../nodes/lighting/AONode.js';
20
19
  import { lightingContext } from '../../nodes/lighting/LightingContextNode.js';
21
20
  import IrradianceNode from '../../nodes/lighting/IrradianceNode.js';
22
- import { depth } from '../../nodes/display/ViewportDepthNode.js';
23
- import { cameraLogDepth } from '../../nodes/accessors/Camera.js';
21
+ import { depth, perspectiveDepthToLogarithmicDepth, viewZToOrthographicDepth } from '../../nodes/display/ViewportDepthNode.js';
22
+ import { cameraFar, cameraNear } from '../../nodes/accessors/Camera.js';
24
23
  import { clipping, clippingAlpha } from '../../nodes/accessors/ClippingNode.js';
25
24
  import NodeMaterialObserver from './manager/NodeMaterialObserver.js';
25
+ import getAlphaHashThreshold from '../../nodes/functions/material/getAlphaHashThreshold.js';
26
26
 
27
27
  class NodeMaterial extends Material {
28
28
 
@@ -57,6 +57,7 @@ class NodeMaterial extends Material {
57
57
  this.alphaTestNode = null;
58
58
 
59
59
  this.positionNode = null;
60
+ this.geometryNode = null;
60
61
 
61
62
  this.depthNode = null;
62
63
  this.shadowNode = null;
@@ -98,6 +99,12 @@ class NodeMaterial extends Material {
98
99
 
99
100
  builder.stack.outputNode = this.vertexNode || this.setupPosition( builder );
100
101
 
102
+ if ( this.geometryNode !== null ) {
103
+
104
+ builder.stack.outputNode = builder.stack.outputNode.bypass( this.geometryNode );
105
+
106
+ }
107
+
101
108
  builder.addFlow( 'vertex', builder.removeStack() );
102
109
 
103
110
  // < FRAGMENT STAGE >
@@ -215,7 +222,7 @@ class NodeMaterial extends Material {
215
222
 
216
223
  setupDepth( builder ) {
217
224
 
218
- const { renderer } = builder;
225
+ const { renderer, camera } = builder;
219
226
 
220
227
  // Depth
221
228
 
@@ -231,9 +238,15 @@ class NodeMaterial extends Material {
231
238
 
232
239
  } else if ( renderer.logarithmicDepthBuffer === true ) {
233
240
 
234
- const fragDepth = modelViewProjection().w.add( 1 );
241
+ if ( camera.isPerspectiveCamera ) {
235
242
 
236
- depthNode = fragDepth.log2().mul( cameraLogDepth ).mul( 0.5 );
243
+ depthNode = perspectiveDepthToLogarithmicDepth( modelViewProjection().w, cameraNear, cameraFar );
244
+
245
+ } else {
246
+
247
+ depthNode = viewZToOrthographicDepth( positionView.z, cameraNear, cameraFar );
248
+
249
+ }
237
250
 
238
251
  }
239
252
 
@@ -355,6 +368,14 @@ class NodeMaterial extends Material {
355
368
 
356
369
  }
357
370
 
371
+ // ALPHA HASH
372
+
373
+ if ( this.alphaHash === true ) {
374
+
375
+ diffuseColor.a.lessThan( getAlphaHashThreshold( positionLocal ) ).discard();
376
+
377
+ }
378
+
358
379
  if ( this.transparent === false && this.blending === NormalBlending && this.alphaToCoverage === false ) {
359
380
 
360
381
  diffuseColor.a.assign( 1.0 );
@@ -447,7 +468,7 @@ class NodeMaterial extends Material {
447
468
 
448
469
  if ( materialLightsNode.length > 0 ) {
449
470
 
450
- lightsN = lights( [ ...lightsN.getLights(), ...materialLightsNode ] );
471
+ lightsN = builder.renderer.lighting.createNode( [ ...lightsN.getLights(), ...materialLightsNode ] );
451
472
 
452
473
  }
453
474
 
@@ -474,7 +495,7 @@ class NodeMaterial extends Material {
474
495
 
475
496
  let outgoingLightNode = this.setupOutgoingLight( builder );
476
497
 
477
- if ( lightsNode && lightsNode.getScope().getLights().length > 0 ) {
498
+ if ( lightsNode && lightsNode.getScope().hasLights ) {
478
499
 
479
500
  const lightingModel = this.setupLightingModel( builder );
480
501
 
@@ -622,6 +643,7 @@ class NodeMaterial extends Material {
622
643
  this.alphaTestNode = source.alphaTestNode;
623
644
 
624
645
  this.positionNode = source.positionNode;
646
+ this.geometryNode = source.geometryNode;
625
647
 
626
648
  this.depthNode = source.depthNode;
627
649
  this.shadowNode = source.shadowNode;
@@ -59,9 +59,18 @@ class SpriteNodeMaterial extends NodeMaterial {
59
59
  }
60
60
 
61
61
 
62
- if ( ! sizeAttenuation && camera.isPerspectiveCamera ) {
62
+ if ( ! sizeAttenuation ) {
63
63
 
64
- scale = scale.mul( mvPosition.z.negate() );
64
+ if ( camera.isPerspectiveCamera ) {
65
+
66
+ scale = scale.mul( mvPosition.z.negate() );
67
+
68
+ } else {
69
+
70
+ const orthoScale = float( 2.0 ).div( cameraProjectionMatrix.element( 1 ).element( 1 ) );
71
+ scale = scale.mul( orthoScale.mul( 2 ) );
72
+
73
+ }
65
74
 
66
75
  }
67
76