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
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ColorManagement,
2
3
  FloatType,
3
4
  HalfFloatType,
4
5
  UnsignedByteType,
@@ -10,6 +11,7 @@ import {
10
11
  NoColorSpace,
11
12
  LinearSRGBColorSpace,
12
13
  SRGBColorSpace,
14
+ SRGBTransfer,
13
15
  DataTexture,
14
16
  REVISION,
15
17
  } from 'three';
@@ -43,6 +45,13 @@ import {
43
45
  VK_FORMAT_R8G8B8A8_UNORM,
44
46
  } from '../libs/ktx-parse.module.js';
45
47
 
48
+ /**
49
+ * References:
50
+ * - https://github.khronos.org/KTX-Specification/ktxspec.v2.html
51
+ * - https://registry.khronos.org/DataFormat/specs/1.3/dataformat.1.3.html
52
+ * - https://github.com/donmccurdy/KTX-Parse
53
+ */
54
+
46
55
  const VK_FORMAT_MAP = {
47
56
 
48
57
  [ RGBAFormat ]: {
@@ -95,14 +104,23 @@ const VK_FORMAT_MAP = {
95
104
 
96
105
  };
97
106
 
98
- const KHR_DF_CHANNEL_MAP = {
107
+ const KHR_DF_CHANNEL_MAP = [
99
108
 
100
- 0: KHR_DF_CHANNEL_RGBSDA_RED,
101
- 1: KHR_DF_CHANNEL_RGBSDA_GREEN,
102
- 2: KHR_DF_CHANNEL_RGBSDA_BLUE,
103
- 3: KHR_DF_CHANNEL_RGBSDA_ALPHA,
109
+ KHR_DF_CHANNEL_RGBSDA_RED,
110
+ KHR_DF_CHANNEL_RGBSDA_GREEN,
111
+ KHR_DF_CHANNEL_RGBSDA_BLUE,
112
+ KHR_DF_CHANNEL_RGBSDA_ALPHA,
104
113
 
105
- };
114
+ ];
115
+
116
+ // TODO: sampleLower and sampleUpper may change based on color space.
117
+ const KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER = {
118
+
119
+ [ FloatType ]: [ 0xbf800000, 0x3f800000 ],
120
+ [ HalfFloatType ]: [ 0xbf800000, 0x3f800000 ],
121
+ [ UnsignedByteType ]: [ 0, 255 ],
122
+
123
+ }
106
124
 
107
125
  const ERROR_INPUT = 'THREE.KTX2Exporter: Supported inputs are DataTexture, Data3DTexture, or WebGLRenderer and WebGLRenderTarget.';
108
126
  const ERROR_FORMAT = 'THREE.KTX2Exporter: Supported formats are RGBAFormat, RGFormat, or RedFormat.';
@@ -172,7 +190,7 @@ export class KTX2Exporter {
172
190
  basicDesc.colorPrimaries = texture.colorSpace === NoColorSpace
173
191
  ? KHR_DF_PRIMARIES_UNSPECIFIED
174
192
  : KHR_DF_PRIMARIES_BT709;
175
- basicDesc.transferFunction = texture.colorSpace === SRGBColorSpace
193
+ basicDesc.transferFunction = ColorManagement.getTransfer( texture.colorSpace ) === SRGBTransfer
176
194
  ? KHR_DF_TRANSFER_SRGB
177
195
  : KHR_DF_TRANSFER_LINEAR;
178
196
 
@@ -188,7 +206,8 @@ export class KTX2Exporter {
188
206
 
189
207
  let channelType = KHR_DF_CHANNEL_MAP[ i ];
190
208
 
191
- if ( texture.colorSpace === LinearSRGBColorSpace || texture.colorSpace === NoColorSpace ) {
209
+ // Assign KHR_DF_SAMPLE_DATATYPE_LINEAR if the channel is linear _and_ differs from the transfer function.
210
+ if ( channelType === KHR_DF_CHANNEL_RGBSDA_ALPHA && basicDesc.transferFunction !== KHR_DF_TRANSFER_LINEAR ) {
192
211
 
193
212
  channelType |= KHR_DF_SAMPLE_DATATYPE_LINEAR;
194
213
 
@@ -204,11 +223,11 @@ export class KTX2Exporter {
204
223
  basicDesc.samples.push( {
205
224
 
206
225
  channelType: channelType,
207
- bitOffset: i * array.BYTES_PER_ELEMENT,
226
+ bitOffset: i * array.BYTES_PER_ELEMENT * 8,
208
227
  bitLength: array.BYTES_PER_ELEMENT * 8 - 1,
209
228
  samplePosition: [ 0, 0, 0, 0 ],
210
- sampleLower: texture.type === UnsignedByteType ? 0 : - 1,
211
- sampleUpper: texture.type === UnsignedByteType ? 255 : 1,
229
+ sampleLower: KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER[ texture.type ][ 0 ],
230
+ sampleUpper: KHR_DF_CHANNEL_SAMPLE_LOWER_UPPER[ texture.type ][ 1 ],
212
231
 
213
232
  } );
214
233
 
@@ -269,7 +288,11 @@ async function toDataTexture( renderer, rtt ) {
269
288
 
270
289
  }
271
290
 
272
- return new DataTexture( view, rtt.width, rtt.height, rtt.texture.format, rtt.texture.type );
291
+ const texture = new DataTexture( view, rtt.width, rtt.height, rtt.texture.format, rtt.texture.type );
292
+
293
+ texture.colorSpace = rtt.texture.colorSpace;
294
+
295
+ return texture;
273
296
 
274
297
  }
275
298
 
@@ -12,6 +12,12 @@ import { MMDParser } from '../libs/mmdparser.module.js';
12
12
 
13
13
  class MMDExporter {
14
14
 
15
+ constructor() {
16
+
17
+ console.warn( 'THREE.MMDExporter: The module has been deprecated and will be removed with r172. Please migrate to https://github.com/takahirox/three-mmd-loader instead.' );
18
+
19
+ }
20
+
15
21
  /* TODO: implement
16
22
  // mesh -> pmd
17
23
  this.parsePmd = function ( object ) {
@@ -9,10 +9,20 @@ import {
9
9
  zipSync,
10
10
  } from '../libs/fflate.module.js';
11
11
 
12
- import { decompress } from './../utils/TextureUtils.js';
13
-
14
12
  class USDZExporter {
15
13
 
14
+ constructor() {
15
+
16
+ this.textureUtils = null;
17
+
18
+ }
19
+
20
+ setTextureUtils( utils ) {
21
+
22
+ this.textureUtils = utils;
23
+
24
+ }
25
+
16
26
  parse( scene, onDone, onError, options ) {
17
27
 
18
28
  this.parseAsync( scene, options ).then( onDone ).catch( onError );
@@ -98,7 +108,15 @@ class USDZExporter {
98
108
 
99
109
  if ( texture.isCompressedTexture === true ) {
100
110
 
101
- texture = decompress( texture );
111
+ if ( this.textureUtils === null ) {
112
+
113
+ throw new Error( 'THREE.USDZExporter: setTextureUtils() must be called to process compressed textures.' );
114
+
115
+ } else {
116
+
117
+ texture = await this.textureUtils.decompress( texture );
118
+
119
+ }
102
120
 
103
121
  }
104
122
 
@@ -55,9 +55,16 @@ class DecalGeometry extends BufferGeometry {
55
55
  // build geometry
56
56
 
57
57
  this.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );
58
- this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
59
58
  this.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );
60
59
 
60
+ if ( normals.length > 0 ) {
61
+
62
+ this.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );
63
+
64
+ }
65
+
66
+ //
67
+
61
68
  function generate() {
62
69
 
63
70
  let decalVertices = [];
@@ -86,9 +93,17 @@ class DecalGeometry extends BufferGeometry {
86
93
  for ( let i = 0; i < index.count; i ++ ) {
87
94
 
88
95
  vertex.fromBufferAttribute( positionAttribute, index.getX( i ) );
89
- normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
90
96
 
91
- pushDecalVertex( decalVertices, vertex, normal );
97
+ if ( normalAttribute ) {
98
+
99
+ normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
100
+ pushDecalVertex( decalVertices, vertex, normal );
101
+
102
+ } else {
103
+
104
+ pushDecalVertex( decalVertices, vertex );
105
+
106
+ }
92
107
 
93
108
  }
94
109
 
@@ -99,9 +114,17 @@ class DecalGeometry extends BufferGeometry {
99
114
  for ( let i = 0; i < positionAttribute.count; i ++ ) {
100
115
 
101
116
  vertex.fromBufferAttribute( positionAttribute, i );
102
- normal.fromBufferAttribute( normalAttribute, i );
103
117
 
104
- pushDecalVertex( decalVertices, vertex, normal );
118
+ if ( normalAttribute ) {
119
+
120
+ normal.fromBufferAttribute( normalAttribute, i );
121
+ pushDecalVertex( decalVertices, vertex, normal );
122
+
123
+ } else {
124
+
125
+ pushDecalVertex( decalVertices, vertex );
126
+
127
+ }
105
128
 
106
129
  }
107
130
 
@@ -136,22 +159,34 @@ class DecalGeometry extends BufferGeometry {
136
159
  // now create vertex and normal buffer data
137
160
 
138
161
  vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z );
139
- normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
162
+
163
+ if ( decalVertex.normal !== null ) {
164
+
165
+ normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
166
+
167
+ }
140
168
 
141
169
  }
142
170
 
143
171
  }
144
172
 
145
- function pushDecalVertex( decalVertices, vertex, normal ) {
173
+ function pushDecalVertex( decalVertices, vertex, normal = null ) {
146
174
 
147
175
  // transform the vertex to world space, then to projector space
148
176
 
149
177
  vertex.applyMatrix4( mesh.matrixWorld );
150
178
  vertex.applyMatrix4( projectorMatrixInverse );
151
179
 
152
- normal.applyNormalMatrix( normalMatrix );
180
+ if ( normal ) {
181
+
182
+ normal.applyNormalMatrix( normalMatrix );
183
+ decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
184
+
185
+ } else {
153
186
 
154
- decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
187
+ decalVertices.push( new DecalVertex( vertex.clone() ) );
188
+
189
+ }
155
190
 
156
191
  }
157
192
 
@@ -313,18 +348,25 @@ class DecalGeometry extends BufferGeometry {
313
348
 
314
349
  const s0 = d0 / ( d0 - d1 );
315
350
 
316
- const v = new DecalVertex(
317
- new Vector3(
318
- v0.position.x + s0 * ( v1.position.x - v0.position.x ),
319
- v0.position.y + s0 * ( v1.position.y - v0.position.y ),
320
- v0.position.z + s0 * ( v1.position.z - v0.position.z )
321
- ),
322
- new Vector3(
351
+ const position = new Vector3(
352
+ v0.position.x + s0 * ( v1.position.x - v0.position.x ),
353
+ v0.position.y + s0 * ( v1.position.y - v0.position.y ),
354
+ v0.position.z + s0 * ( v1.position.z - v0.position.z )
355
+ );
356
+
357
+ let normal = null;
358
+
359
+ if ( v0.normal !== null && v1.normal !== null ) {
360
+
361
+ normal = new Vector3(
323
362
  v0.normal.x + s0 * ( v1.normal.x - v0.normal.x ),
324
363
  v0.normal.y + s0 * ( v1.normal.y - v0.normal.y ),
325
364
  v0.normal.z + s0 * ( v1.normal.z - v0.normal.z )
326
- )
327
- );
365
+ );
366
+
367
+ }
368
+
369
+ const v = new DecalVertex( position, normal );
328
370
 
329
371
  // need to clip more values (texture coordinates)? do it this way:
330
372
  // intersectpoint.value = a.value + s * ( b.value - a.value );
@@ -341,7 +383,7 @@ class DecalGeometry extends BufferGeometry {
341
383
 
342
384
  class DecalVertex {
343
385
 
344
- constructor( position, normal ) {
386
+ constructor( position, normal = null ) {
345
387
 
346
388
  this.position = position;
347
389
  this.normal = normal;
@@ -350,7 +392,10 @@ class DecalVertex {
350
392
 
351
393
  clone() {
352
394
 
353
- return new this.constructor( this.position.clone(), this.normal.clone() );
395
+ const position = this.position.clone();
396
+ const normal = ( this.normal !== null ) ? this.normal.clone() : null;
397
+
398
+ return new this.constructor( position, normal );
354
399
 
355
400
  }
356
401
 
@@ -78,6 +78,8 @@ class InstancedPointsGeometry extends InstancedBufferGeometry {
78
78
  this.computeBoundingBox();
79
79
  this.computeBoundingSphere();
80
80
 
81
+ this.instanceCount = points.length / 3;
82
+
81
83
  return this;
82
84
 
83
85
  }
@@ -0,0 +1,175 @@
1
+ import {
2
+ BoxGeometry,
3
+ BufferAttribute,
4
+ Mesh,
5
+ PlaneGeometry,
6
+ Vector3,
7
+ } from 'three';
8
+ import { NodeMaterial, texture as textureNode, cubeTexture, texture3D, float, vec4 } from 'three/tsl';
9
+ import { mergeGeometries } from '../utils/BufferGeometryUtils.js';
10
+
11
+ class TextureHelper extends Mesh {
12
+
13
+ constructor( texture, width = 1, height = 1, depth = 1 ) {
14
+
15
+ const material = new NodeMaterial();
16
+ material.name = 'TextureHelper';
17
+
18
+ let colorNode;
19
+
20
+ if ( texture.isCubeTexture ) {
21
+
22
+ colorNode = cubeTexture( texture );
23
+
24
+ } else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
25
+
26
+ colorNode = texture3D( texture );
27
+
28
+ } else {
29
+
30
+ colorNode = textureNode( texture );
31
+
32
+ }
33
+
34
+ const alphaNode = float( getAlpha( texture ) );
35
+
36
+ material.colorNode = vec4( colorNode.rgb, alphaNode );
37
+
38
+ const geometry = texture.isCubeTexture
39
+ ? createCubeGeometry( width, height, depth )
40
+ : createSliceGeometry( texture, width, height, depth );
41
+
42
+ super( geometry, material );
43
+
44
+ this.texture = texture;
45
+ this.type = 'TextureHelper';
46
+
47
+ }
48
+
49
+ dispose() {
50
+
51
+ this.geometry.dispose();
52
+ this.material.dispose();
53
+
54
+ }
55
+
56
+ }
57
+
58
+ function getImageCount( texture ) {
59
+
60
+ if ( texture.isCubeTexture ) {
61
+
62
+ return 6;
63
+
64
+ } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
65
+
66
+ return texture.image.depth;
67
+
68
+ } else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
69
+
70
+ return texture.image.depth;
71
+
72
+ } else {
73
+
74
+ return 1;
75
+
76
+ }
77
+
78
+ }
79
+
80
+ function getAlpha( texture ) {
81
+
82
+ if ( texture.isCubeTexture ) {
83
+
84
+ return 1;
85
+
86
+ } else if ( texture.isDataArrayTexture || texture.isCompressedArrayTexture ) {
87
+
88
+ return Math.max( 1 / texture.image.depth, 0.25 );
89
+
90
+ } else if ( texture.isData3DTexture || texture.isCompressed3DTexture ) {
91
+
92
+ return Math.max( 1 / texture.image.depth, 0.25 );
93
+
94
+ } else {
95
+
96
+ return 1;
97
+
98
+ }
99
+
100
+ }
101
+
102
+ function createCubeGeometry( width, height, depth ) {
103
+
104
+ const geometry = new BoxGeometry( width, height, depth );
105
+
106
+ const position = geometry.attributes.position;
107
+ const uv = geometry.attributes.uv;
108
+ const uvw = new BufferAttribute( new Float32Array( uv.count * 3 ), 3 );
109
+
110
+ const _direction = new Vector3();
111
+
112
+ for ( let j = 0, jl = uv.count; j < jl; ++ j ) {
113
+
114
+ _direction.fromBufferAttribute( position, j ).normalize();
115
+
116
+ const u = _direction.x;
117
+ const v = _direction.y;
118
+ const w = _direction.z;
119
+
120
+ uvw.setXYZ( j, u, v, w );
121
+
122
+ }
123
+
124
+ geometry.deleteAttribute( 'uv' );
125
+ geometry.setAttribute( 'uv', uvw );
126
+
127
+ return geometry;
128
+
129
+ }
130
+
131
+ function createSliceGeometry( texture, width, height, depth ) {
132
+
133
+ const sliceCount = getImageCount( texture );
134
+
135
+ const geometries = [];
136
+
137
+ for ( let i = 0; i < sliceCount; ++ i ) {
138
+
139
+ const geometry = new PlaneGeometry( width, height );
140
+
141
+ if ( sliceCount > 1 ) {
142
+
143
+ geometry.translate( 0, 0, depth * ( i / ( sliceCount - 1 ) - 0.5 ) );
144
+
145
+ }
146
+
147
+ const uv = geometry.attributes.uv;
148
+ const uvw = new BufferAttribute( new Float32Array( uv.count * 3 ), 3 );
149
+
150
+ for ( let j = 0, jl = uv.count; j < jl; ++ j ) {
151
+
152
+ const u = uv.getX( j );
153
+ const v = texture.flipY ? uv.getY( j ) : 1 - uv.getY( j );
154
+ const w = sliceCount === 1
155
+ ? 1
156
+ : texture.isDataArrayTexture || texture.isCompressedArrayTexture
157
+ ? i
158
+ : i / ( sliceCount - 1 );
159
+
160
+ uvw.setXYZ( j, u, v, w );
161
+
162
+ }
163
+
164
+ geometry.deleteAttribute( 'uv' );
165
+ geometry.setAttribute( 'uv', uvw );
166
+
167
+ geometries.push( geometry );
168
+
169
+ }
170
+
171
+ return mergeGeometries( geometries );
172
+
173
+ }
174
+
175
+ export { TextureHelper };
@@ -62,6 +62,7 @@ class HTMLTexture extends CanvasTexture {
62
62
  this.colorSpace = SRGBColorSpace;
63
63
  this.minFilter = LinearFilter;
64
64
  this.magFilter = LinearFilter;
65
+ this.generateMipmaps = false;
65
66
 
66
67
  // Create an observer on the DOM, and run html2canvas update in the next loop
67
68
  const observer = new MutationObserver( () => {
@@ -0,0 +1,18 @@
1
+ import { Lighting } from 'three';
2
+ import { tiledLights } from '../tsl/lighting/TiledLightsNode.js';
3
+
4
+ export class TiledLighting extends Lighting {
5
+
6
+ constructor() {
7
+
8
+ super();
9
+
10
+ }
11
+
12
+ createNode( lights = [] ) {
13
+
14
+ return tiledLights().setLights( lights );
15
+
16
+ }
17
+
18
+ }
@@ -71,7 +71,7 @@ class RectAreaLightTexturesLib {
71
71
  LTC_HALF_2.needsUpdate = true;
72
72
 
73
73
  this.LTC_HALF_1 = LTC_HALF_1;
74
- this.LTC_HALF_1 = LTC_HALF_2;
74
+ this.LTC_HALF_2 = LTC_HALF_2;
75
75
 
76
76
  this.LTC_FLOAT_1 = LTC_FLOAT_1;
77
77
  this.LTC_FLOAT_2 = LTC_FLOAT_2;
@@ -405,12 +405,17 @@ ShaderLib[ 'line' ] = {
405
405
 
406
406
  class LineMaterial extends ShaderMaterial {
407
407
 
408
+
409
+ static get type() {
410
+
411
+ return 'LineMaterial';
412
+
413
+ }
414
+
408
415
  constructor( parameters ) {
409
416
 
410
417
  super( {
411
418
 
412
- type: 'LineMaterial',
413
-
414
419
  uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
415
420
 
416
421
  vertexShader: ShaderLib[ 'line' ].vertexShader,
@@ -82,6 +82,8 @@ class LineSegmentsGeometry extends InstancedBufferGeometry {
82
82
  this.setAttribute( 'instanceStart', new InterleavedBufferAttribute( instanceBuffer, 3, 0 ) ); // xyz
83
83
  this.setAttribute( 'instanceEnd', new InterleavedBufferAttribute( instanceBuffer, 3, 3 ) ); // xyz
84
84
 
85
+ this.instanceCount = this.attributes.instanceStart.count;
86
+
85
87
  //
86
88
 
87
89
  this.computeBoundingBox();
@@ -13,8 +13,6 @@ import {
13
13
  } from 'three';
14
14
  import { LineSegmentsGeometry } from '../../lines/LineSegmentsGeometry.js';
15
15
 
16
- const _viewport = new Vector4();
17
-
18
16
  const _start = new Vector3();
19
17
  const _end = new Vector3();
20
18
 
@@ -358,19 +356,6 @@ class LineSegments2 extends Mesh {
358
356
 
359
357
  }
360
358
 
361
- onBeforeRender( renderer ) {
362
-
363
- const uniforms = this.material.uniforms;
364
-
365
- if ( uniforms && uniforms.resolution ) {
366
-
367
- renderer.getViewport( _viewport );
368
- this.material.uniforms.resolution.value.set( _viewport.z, _viewport.w );
369
-
370
- }
371
-
372
- }
373
-
374
359
  }
375
360
 
376
361
  export { LineSegments2 };
@@ -0,0 +1,56 @@
1
+ import {
2
+ InstancedInterleavedBuffer,
3
+ InterleavedBufferAttribute,
4
+ Line2NodeMaterial,
5
+ Mesh,
6
+ Vector3
7
+ } from 'three';
8
+ import { LineSegmentsGeometry } from '../../lines/LineSegmentsGeometry.js';
9
+
10
+ const _start = new Vector3();
11
+ const _end = new Vector3();
12
+
13
+ class Wireframe extends Mesh {
14
+
15
+ constructor( geometry = new LineSegmentsGeometry(), material = new Line2NodeMaterial( { color: Math.random() * 0xffffff } ) ) {
16
+
17
+ super( geometry, material );
18
+
19
+ this.isWireframe = true;
20
+
21
+ this.type = 'Wireframe';
22
+
23
+ }
24
+
25
+ // for backwards-compatibility, but could be a method of LineSegmentsGeometry...
26
+
27
+ computeLineDistances() {
28
+
29
+ const geometry = this.geometry;
30
+
31
+ const instanceStart = geometry.attributes.instanceStart;
32
+ const instanceEnd = geometry.attributes.instanceEnd;
33
+ const lineDistances = new Float32Array( 2 * instanceStart.count );
34
+
35
+ for ( let i = 0, j = 0, l = instanceStart.count; i < l; i ++, j += 2 ) {
36
+
37
+ _start.fromBufferAttribute( instanceStart, i );
38
+ _end.fromBufferAttribute( instanceEnd, i );
39
+
40
+ lineDistances[ j ] = ( j === 0 ) ? 0 : lineDistances[ j - 1 ];
41
+ lineDistances[ j + 1 ] = lineDistances[ j ] + _start.distanceTo( _end );
42
+
43
+ }
44
+
45
+ const instanceDistanceBuffer = new InstancedInterleavedBuffer( lineDistances, 2, 1 ); // d0, d1
46
+
47
+ geometry.setAttribute( 'instanceDistanceStart', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 0 ) ); // d0
48
+ geometry.setAttribute( 'instanceDistanceEnd', new InterleavedBufferAttribute( instanceDistanceBuffer, 1, 1 ) ); // d1
49
+
50
+ return this;
51
+
52
+ }
53
+
54
+ }
55
+
56
+ export { Wireframe };
@@ -745,6 +745,7 @@ class Rhino3dmLoader extends Loader {
745
745
 
746
746
  const texture = new CanvasTexture( ctx.canvas );
747
747
  texture.minFilter = LinearFilter;
748
+ texture.generateMipmaps = false;
748
749
  texture.wrapS = ClampToEdgeWrapping;
749
750
  texture.wrapT = ClampToEdgeWrapping;
750
751