super-three 0.135.0 → 0.136.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 (175) hide show
  1. package/build/three.js +527 -332
  2. package/build/three.min.js +1 -1
  3. package/build/three.module.js +752 -370
  4. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  5. package/examples/js/animation/CCDIKSolver.js +0 -1
  6. package/examples/js/animation/MMDPhysics.js +1 -3
  7. package/examples/js/controls/ArcballControls.js +38 -52
  8. package/examples/js/controls/TransformControls.js +24 -1
  9. package/examples/js/curves/CurveExtras.js +0 -2
  10. package/examples/js/effects/AsciiEffect.js +2 -9
  11. package/examples/js/exporters/GLTFExporter.js +1 -1
  12. package/examples/js/geometries/TeapotGeometry.js +0 -1
  13. package/examples/js/interactive/SelectionBox.js +2 -0
  14. package/examples/js/interactive/SelectionHelper.js +22 -7
  15. package/examples/js/lights/RectAreaLightUniformsLib.js +4 -0
  16. package/examples/js/loaders/AMFLoader.js +0 -2
  17. package/examples/js/loaders/ColladaLoader.js +1 -2
  18. package/examples/js/loaders/EXRLoader.js +185 -262
  19. package/examples/js/loaders/FBXLoader.js +3 -4
  20. package/examples/js/loaders/GLTFLoader.js +2 -2
  21. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -8
  22. package/examples/js/loaders/KTX2Loader.js +11 -2
  23. package/examples/js/loaders/KTXLoader.js +1 -1
  24. package/examples/js/loaders/LDrawLoader.js +26 -30
  25. package/examples/js/loaders/LUT3dlLoader.js +2 -0
  26. package/examples/js/loaders/LUTCubeLoader.js +2 -0
  27. package/examples/js/loaders/MMDLoader.js +0 -1
  28. package/examples/js/loaders/NRRDLoader.js +9 -2
  29. package/examples/js/loaders/OBJLoader.js +0 -2
  30. package/examples/js/loaders/PLYLoader.js +1 -1
  31. package/examples/js/loaders/RGBELoader.js +0 -15
  32. package/examples/js/loaders/RGBMLoader.js +55 -5
  33. package/examples/js/loaders/SVGLoader.js +2 -2
  34. package/examples/js/loaders/VOXLoader.js +1 -0
  35. package/examples/js/loaders/VRMLLoader.js +2 -1
  36. package/examples/js/math/ImprovedNoise.js +1 -1
  37. package/examples/js/misc/GPUComputationRenderer.js +3 -1
  38. package/examples/js/objects/Lensflare.js +2 -10
  39. package/examples/js/objects/Reflector.js +7 -0
  40. package/examples/js/objects/Refractor.js +7 -0
  41. package/examples/js/objects/Sky.js +1 -1
  42. package/examples/js/objects/Water.js +2 -2
  43. package/examples/js/objects/Water2.js +4 -7
  44. package/examples/js/postprocessing/GlitchPass.js +3 -1
  45. package/examples/js/postprocessing/SSAOPass.js +1 -0
  46. package/examples/js/shaders/ConvolutionShader.js +0 -1
  47. package/examples/js/shaders/FXAAShader.js +1 -1
  48. package/examples/js/shaders/FilmShader.js +1 -1
  49. package/examples/js/shaders/GammaCorrectionShader.js +1 -1
  50. package/examples/js/shaders/HorizontalBlurShader.js +1 -2
  51. package/examples/js/shaders/SSRShader.js +1 -1
  52. package/examples/js/shaders/SSRrShader.js +1 -1
  53. package/examples/js/shaders/VerticalBlurShader.js +1 -2
  54. package/examples/js/utils/GeometryUtils.js +1 -1
  55. package/examples/js/utils/RoughnessMipmapper.js +18 -29
  56. package/examples/jsm/animation/CCDIKSolver.js +0 -1
  57. package/examples/jsm/animation/MMDPhysics.js +0 -2
  58. package/examples/jsm/controls/ArcballControls.js +27 -56
  59. package/examples/jsm/controls/TransformControls.js +24 -1
  60. package/examples/jsm/curves/CurveExtras.js +0 -2
  61. package/examples/jsm/effects/AsciiEffect.js +2 -9
  62. package/examples/jsm/exporters/GLTFExporter.js +1 -1
  63. package/examples/jsm/geometries/TeapotGeometry.js +0 -1
  64. package/examples/jsm/interactive/SelectionBox.js +1 -0
  65. package/examples/jsm/interactive/SelectionHelper.js +19 -7
  66. package/examples/jsm/libs/flow.module.js +256 -136
  67. package/examples/jsm/lights/RectAreaLightUniformsLib.js +7 -0
  68. package/examples/jsm/loaders/AMFLoader.js +0 -2
  69. package/examples/jsm/loaders/ColladaLoader.js +1 -2
  70. package/examples/jsm/loaders/EXRLoader.js +184 -293
  71. package/examples/jsm/loaders/FBXLoader.js +3 -4
  72. package/examples/jsm/loaders/GLTFLoader.js +2 -2
  73. package/examples/jsm/loaders/HDRCubeTextureLoader.js +1 -14
  74. package/examples/jsm/loaders/KTX2Loader.js +13 -4
  75. package/examples/jsm/loaders/KTXLoader.js +1 -1
  76. package/examples/jsm/loaders/LDrawLoader.js +23 -24
  77. package/examples/jsm/loaders/LUT3dlLoader.js +2 -0
  78. package/examples/jsm/loaders/LUTCubeLoader.js +2 -0
  79. package/examples/jsm/loaders/MMDLoader.js +0 -1
  80. package/examples/jsm/loaders/NRRDLoader.js +10 -2
  81. package/examples/jsm/loaders/OBJLoader.js +0 -2
  82. package/examples/jsm/loaders/PLYLoader.js +1 -1
  83. package/examples/jsm/loaders/RGBELoader.js +0 -20
  84. package/examples/jsm/loaders/RGBMLoader.js +61 -7
  85. package/examples/jsm/loaders/SVGLoader.js +2 -2
  86. package/examples/jsm/loaders/TDSLoader.js +30 -9
  87. package/examples/jsm/loaders/VOXLoader.js +1 -0
  88. package/examples/jsm/loaders/VRMLLoader.js +2 -1
  89. package/examples/jsm/math/ImprovedNoise.js +1 -1
  90. package/examples/jsm/misc/GPUComputationRenderer.js +3 -1
  91. package/examples/jsm/node-editor/NodeEditor.js +23 -22
  92. package/examples/jsm/node-editor/examples/rim.json +1 -1
  93. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +48 -9
  94. package/examples/jsm/node-editor/utils/OscillatorEditor.js +1 -1
  95. package/examples/jsm/nodes/core/NodeBuilder.js +2 -2
  96. package/examples/jsm/nodes/materials/nodes/StandardNode.js +1 -0
  97. package/examples/jsm/nodes/math/MathNode.js +12 -0
  98. package/examples/jsm/nodes/misc/BumpMapNode.js +1 -1
  99. package/examples/jsm/nodes/misc/TextureCubeUVNode.js +1 -4
  100. package/examples/jsm/nodes/utils/ColorSpaceNode.js +1 -116
  101. package/examples/jsm/objects/Lensflare.js +3 -14
  102. package/examples/jsm/objects/Reflector.js +7 -0
  103. package/examples/jsm/objects/Refractor.js +7 -0
  104. package/examples/jsm/objects/Sky.js +1 -1
  105. package/examples/jsm/objects/Water.js +2 -2
  106. package/examples/jsm/objects/Water2.js +4 -8
  107. package/examples/jsm/postprocessing/GlitchPass.js +3 -1
  108. package/examples/jsm/postprocessing/SAOPass.js +1 -1
  109. package/examples/jsm/postprocessing/SSAOPass.js +1 -0
  110. package/examples/jsm/renderers/nodes/Nodes.js +1 -0
  111. package/examples/jsm/renderers/nodes/ShaderNode.js +7 -6
  112. package/examples/jsm/renderers/nodes/core/InputNode.js +1 -1
  113. package/examples/jsm/renderers/nodes/core/NodeBuilder.js +1 -1
  114. package/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +26 -31
  115. package/examples/jsm/renderers/nodes/functions/BSDFs.js +2 -2
  116. package/examples/jsm/renderers/nodes/functions/PhysicalMaterialFunctions.js +27 -0
  117. package/examples/jsm/renderers/nodes/inputs/TextureNode.js +1 -1
  118. package/examples/jsm/renderers/nodes/math/MathNode.js +5 -3
  119. package/examples/jsm/renderers/nodes/math/OperatorNode.js +2 -2
  120. package/examples/jsm/renderers/nodes/utils/TimerNode.js +1 -1
  121. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +14 -14
  122. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +7 -6
  123. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +1 -1
  124. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +42 -61
  125. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +2 -2
  126. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +0 -1
  127. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +30 -4
  128. package/examples/jsm/shaders/ConvolutionShader.js +0 -1
  129. package/examples/jsm/shaders/FXAAShader.js +1 -1
  130. package/examples/jsm/shaders/FilmShader.js +1 -1
  131. package/examples/jsm/shaders/GammaCorrectionShader.js +1 -1
  132. package/examples/jsm/shaders/HorizontalBlurShader.js +1 -2
  133. package/examples/jsm/shaders/SSRShader.js +1 -1
  134. package/examples/jsm/shaders/SSRrShader.js +1 -1
  135. package/examples/jsm/shaders/VerticalBlurShader.js +1 -2
  136. package/examples/jsm/utils/GeometryUtils.js +1 -1
  137. package/examples/jsm/utils/RoughnessMipmapper.js +19 -32
  138. package/examples/jsm/utils/WorkerPool.js +11 -11
  139. package/package.json +15 -9
  140. package/src/Three.Legacy.js +12 -0
  141. package/src/Three.js +1 -2
  142. package/src/constants.js +1 -7
  143. package/src/core/Object3D.js +1 -1
  144. package/src/extras/PMREMGenerator.js +19 -110
  145. package/src/extras/core/Interpolations.js +1 -1
  146. package/src/geometries/LatheGeometry.js +70 -47
  147. package/src/helpers/CameraHelper.js +1 -1
  148. package/src/loaders/FileLoader.js +23 -6
  149. package/src/math/Color.js +0 -38
  150. package/src/math/Ray.js +2 -2
  151. package/src/math/Sphere.js +10 -1
  152. package/src/objects/Skeleton.js +1 -0
  153. package/src/renderers/WebGLRenderer.js +23 -16
  154. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +1 -1
  155. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +2 -24
  156. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +0 -47
  157. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +1 -1
  158. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +27 -1
  159. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +10 -0
  161. package/src/renderers/webgl/WebGLCapabilities.js +0 -2
  162. package/src/renderers/webgl/WebGLMorphtargets.js +1 -0
  163. package/src/renderers/webgl/WebGLProgram.js +2 -19
  164. package/src/renderers/webgl/WebGLPrograms.js +191 -35
  165. package/src/renderers/webgl/WebGLRenderLists.js +4 -14
  166. package/src/renderers/webgl/WebGLShaderCache.js +120 -0
  167. package/src/renderers/webgl/WebGLState.js +45 -0
  168. package/src/renderers/webgl/WebGLTextures.js +195 -26
  169. package/src/renderers/webxr/WebXRManager.js +10 -3
  170. package/src/scenes/Scene.js +1 -1
  171. package/src/textures/DataTexture.js +0 -2
  172. package/src/textures/DataTexture2DArray.js +0 -2
  173. package/src/textures/DataTexture3D.js +0 -2
  174. package/src/textures/FramebufferTexture.js +25 -0
  175. package/src/utils.js +1 -37
@@ -4,7 +4,7 @@
4
4
  * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
5
5
  * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
6
6
  *
7
- * ported from https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.khronosTextureContainer.ts
7
+ * ported from https://github.com/BabylonJS/Babylon.js/blob/master/src/Misc/khronosTextureContainer.ts
8
8
  */
9
9
 
10
10
  class KTXLoader extends THREE.CompressedTextureLoader {
@@ -916,11 +916,13 @@
916
916
  mainEdgeColourCode: parentScope ? parentScope.mainEdgeColourCode : '24',
917
917
  currentMatrix: new THREE.Matrix4(),
918
918
  matrix: new THREE.Matrix4(),
919
+ type: 'Model',
920
+ groupObject: null,
919
921
  // If false, it is a root material scope previous to parse
920
922
  isFromParse: true,
921
- faces: null,
922
- lineSegments: null,
923
- conditionalSegments: null,
923
+ faces: [],
924
+ lineSegments: [],
925
+ conditionalSegments: [],
924
926
  totalFaces: 0,
925
927
  // If true, this object is the start of a construction step
926
928
  startingConstructionStep: false
@@ -1135,21 +1137,11 @@
1135
1137
  break;
1136
1138
 
1137
1139
  case FINISH_TYPE_PEARLESCENT:
1138
- // Try to imitate pearlescency by setting the specular to the complementary of the color, and low shininess
1139
- const specular = new THREE.Color( colour );
1140
- const hsl = specular.getHSL( {
1141
- h: 0,
1142
- s: 0,
1143
- l: 0
1144
- } );
1145
- hsl.h = ( hsl.h + 0.5 ) % 1;
1146
- hsl.l = Math.min( 1, hsl.l + ( 1 - hsl.l ) * 0.7 );
1147
- specular.setHSL( hsl.h, hsl.s, hsl.l );
1148
- material = new THREE.MeshPhongMaterial( {
1140
+ // Try to imitate pearlescency by making the surface glossy
1141
+ material = new THREE.MeshStandardMaterial( {
1149
1142
  color: colour,
1150
- specular: specular,
1151
- shininess: 10,
1152
- reflectivity: 0.3
1143
+ roughness: 0.3,
1144
+ metalness: 0.25
1153
1145
  } );
1154
1146
  break;
1155
1147
 
@@ -1375,21 +1367,9 @@
1375
1367
 
1376
1368
  case '!LDRAW_ORG':
1377
1369
  type = lp.getToken();
1378
- currentParseScope.faces = [];
1379
- currentParseScope.lineSegments = [];
1380
- currentParseScope.conditionalSegments = [];
1381
- currentParseScope.type = type;
1382
- const isRoot = ! parentParseScope.isFromParse;
1383
-
1384
- if ( isRoot || scope.separateObjects && ! isPrimitiveType( type ) ) {
1385
-
1386
- currentParseScope.groupObject = new THREE.Group();
1387
- currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep;
1388
-
1389
- } // If the scale of the object is negated then the triangle winding order
1370
+ currentParseScope.type = type; // If the scale of the object is negated then the triangle winding order
1390
1371
  // needs to be flipped.
1391
1372
 
1392
-
1393
1373
  if ( currentParseScope.matrix.determinant() < 0 && ( scope.separateObjects && isPrimitiveType( type ) || ! scope.separateObjects ) ) {
1394
1374
 
1395
1375
  currentParseScope.inverted = ! currentParseScope.inverted;
@@ -1709,6 +1689,14 @@
1709
1689
  currentParseScope.subobjects = subobjects;
1710
1690
  currentParseScope.numSubobjects = subobjects.length;
1711
1691
  currentParseScope.subobjectIndex = 0;
1692
+ const isRoot = ! parentParseScope.isFromParse;
1693
+
1694
+ if ( isRoot || scope.separateObjects && ! isPrimitiveType( type ) ) {
1695
+
1696
+ currentParseScope.groupObject = new THREE.Group();
1697
+ currentParseScope.groupObject.userData.startingConstructionStep = currentParseScope.startingConstructionStep;
1698
+
1699
+ }
1712
1700
 
1713
1701
  }
1714
1702
 
@@ -1737,6 +1725,13 @@
1737
1725
 
1738
1726
  finalizeObject( subobjectParseScope ) {
1739
1727
 
1728
+ // fail gracefully if an object could not be loaded
1729
+ if ( subobjectParseScope === null ) {
1730
+
1731
+ return;
1732
+
1733
+ }
1734
+
1740
1735
  const parentParseScope = subobjectParseScope.parentScope; // Smooth the normals if this is a part or if this is a case where the subpart
1741
1736
  // is added directly into the parent model (meaning it will never get smoothed by
1742
1737
  // being added to a part)
@@ -1919,6 +1914,7 @@
1919
1914
  } ).catch( function () {
1920
1915
 
1921
1916
  console.warn( 'LDrawLoader: Subobject "' + subobject.fileName + '" could not be found.' );
1917
+ return null;
1922
1918
 
1923
1919
  } );
1924
1920
 
@@ -102,6 +102,7 @@
102
102
  texture.wrapS = THREE.ClampToEdgeWrapping;
103
103
  texture.wrapT = THREE.ClampToEdgeWrapping;
104
104
  texture.generateMipmaps = false;
105
+ texture.needsUpdate = true;
105
106
  const texture3D = new THREE.DataTexture3D();
106
107
  texture3D.image.data = data;
107
108
  texture3D.image.width = size;
@@ -115,6 +116,7 @@
115
116
  texture3D.wrapT = THREE.ClampToEdgeWrapping;
116
117
  texture3D.wrapR = THREE.ClampToEdgeWrapping;
117
118
  texture3D.generateMipmaps = false;
119
+ texture3D.needsUpdate = true;
118
120
  return {
119
121
  size,
120
122
  texture,
@@ -108,6 +108,7 @@
108
108
  texture.wrapS = THREE.ClampToEdgeWrapping;
109
109
  texture.wrapT = THREE.ClampToEdgeWrapping;
110
110
  texture.generateMipmaps = false;
111
+ texture.needsUpdate = true;
111
112
  const texture3D = new THREE.DataTexture3D();
112
113
  texture3D.image.data = data;
113
114
  texture3D.image.width = size;
@@ -121,6 +122,7 @@
121
122
  texture3D.wrapT = THREE.ClampToEdgeWrapping;
122
123
  texture3D.wrapR = THREE.ClampToEdgeWrapping;
123
124
  texture3D.generateMipmaps = false;
125
+ texture3D.needsUpdate = true;
124
126
  return {
125
127
  title,
126
128
  size,
@@ -287,7 +287,6 @@
287
287
  /*
288
288
  * base64 encoded defalut toon textures toon00.bmp - toon10.bmp.
289
289
  * We don't need to request external toon image files.
290
- * This idea is from http://www20.atpages.jp/katwat/three.js_r58/examples/mytest37/mmd.three.js
291
290
  */
292
291
 
293
292
 
@@ -207,7 +207,10 @@
207
207
  if ( ! headerObject.vectors ) {
208
208
 
209
209
  //if no space direction is set, let's use the identity
210
- headerObject.vectors = [ new THREE.Vector3( 1, 0, 0 ), new THREE.Vector3( 0, 1, 0 ), new THREE.Vector3( 0, 0, 1 ) ]; //apply spacing if defined
210
+ headerObject.vectors = [];
211
+ headerObject.vectors.push( [ 1, 0, 0 ] );
212
+ headerObject.vectors.push( [ 0, 1, 0 ] );
213
+ headerObject.vectors.push( [ 0, 0, 1 ] ); //apply spacing if defined
211
214
 
212
215
  if ( headerObject.spacings ) {
213
216
 
@@ -215,7 +218,11 @@
215
218
 
216
219
  if ( ! isNaN( headerObject.spacings[ i ] ) ) {
217
220
 
218
- headerObject.vectors[ i ].multiplyScalar( headerObject.spacings[ i ] );
221
+ for ( let j = 0; j <= 2; j ++ ) {
222
+
223
+ headerObject.vectors[ i ][ j ] *= headerObject.spacings[ i ];
224
+
225
+ }
219
226
 
220
227
  }
221
228
 
@@ -583,8 +583,6 @@
583
583
 
584
584
  /*
585
585
  * http://paulbourke.net/dataformats/obj/
586
- * or
587
- * http://www.cs.utah.edu/~boulos/cs3505/obj_spec.pdf
588
586
  *
589
587
  * From chapter "Grouping" Syntax explanation "s group_number":
590
588
  * "group_number is the smoothing group number. To turn off smoothing groups, use a value of 0 or off.
@@ -79,7 +79,7 @@
79
79
 
80
80
  function parseHeader( data ) {
81
81
 
82
- const patternHeader = /ply([\s\S]*)end_header\r?\n/;
82
+ const patternHeader = /^ply([\s\S]*)end_header\r?\n/;
83
83
  let headerText = '';
84
84
  let headerLength = 0;
85
85
  const result = patternHeader.exec( data );
@@ -374,13 +374,6 @@
374
374
 
375
375
  switch ( this.type ) {
376
376
 
377
- case THREE.UnsignedByteType:
378
- data = image_rgba_data;
379
- format = THREE.RGBEFormat; // handled as THREE.RGBAFormat in shaders
380
-
381
- type = THREE.UnsignedByteType;
382
- break;
383
-
384
377
  case THREE.FloatType:
385
378
  numElements = image_rgba_data.length / 4;
386
379
  const floatArray = new Float32Array( numElements * 3 );
@@ -449,14 +442,6 @@
449
442
 
450
443
  switch ( texture.type ) {
451
444
 
452
- case THREE.UnsignedByteType:
453
- texture.encoding = THREE.RGBEEncoding;
454
- texture.minFilter = THREE.NearestFilter;
455
- texture.magFilter = THREE.NearestFilter;
456
- texture.generateMipmaps = false;
457
- texture.flipY = true;
458
- break;
459
-
460
445
  case THREE.FloatType:
461
446
  texture.encoding = THREE.LinearEncoding;
462
447
  texture.minFilter = THREE.LinearFilter;
@@ -2,6 +2,28 @@
2
2
 
3
3
  class RGBMLoader extends THREE.DataTextureLoader {
4
4
 
5
+ constructor( manager ) {
6
+
7
+ super( manager );
8
+ this.type = THREE.HalfFloatType;
9
+ this.maxRange = 7; // more information about this property at https://iwasbeingirony.blogspot.com/2010/06/difference-between-rgbm-and-rgbd.html
10
+
11
+ }
12
+
13
+ setDataType( value ) {
14
+
15
+ this.type = value;
16
+ return this;
17
+
18
+ }
19
+
20
+ setMaxRange( value ) {
21
+
22
+ this.maxRange = value;
23
+ return this;
24
+
25
+ }
26
+
5
27
  loadCubemap( urls, onLoad, onProgress, onError ) {
6
28
 
7
29
  const texture = new THREE.CubeTexture();
@@ -32,7 +54,7 @@
32
54
 
33
55
  }
34
56
 
35
- texture.encoding = THREE.RGBM7Encoding;
57
+ texture.type = this.type;
36
58
  texture.format = THREE.RGBAFormat;
37
59
  texture.minFilter = THREE.LinearFilter;
38
60
  texture.generateMipmaps = false;
@@ -44,14 +66,42 @@
44
66
 
45
67
  const img = UPNG.decode( buffer );
46
68
  const rgba = UPNG.toRGBA8( img )[ 0 ];
69
+ const data = new Uint8Array( rgba );
70
+ const size = img.width * img.height * 4;
71
+ const output = this.type === THREE.HalfFloatType ? new Uint16Array( size ) : new Float32Array( size ); // decode RGBM
72
+
73
+ for ( let i = 0; i < data.length; i += 4 ) {
74
+
75
+ const r = data[ i + 0 ] / 255;
76
+ const g = data[ i + 1 ] / 255;
77
+ const b = data[ i + 2 ] / 255;
78
+ const a = data[ i + 3 ] / 255;
79
+
80
+ if ( this.type === THREE.HalfFloatType ) {
81
+
82
+ output[ i + 0 ] = THREE.DataUtils.toHalfFloat( Math.min( r * a * this.maxRange, 65504 ) );
83
+ output[ i + 1 ] = THREE.DataUtils.toHalfFloat( Math.min( g * a * this.maxRange, 65504 ) );
84
+ output[ i + 2 ] = THREE.DataUtils.toHalfFloat( Math.min( b * a * this.maxRange, 65504 ) );
85
+ output[ i + 3 ] = THREE.DataUtils.toHalfFloat( 1 );
86
+
87
+ } else {
88
+
89
+ output[ i + 0 ] = r * a * this.maxRange;
90
+ output[ i + 1 ] = g * a * this.maxRange;
91
+ output[ i + 2 ] = b * a * this.maxRange;
92
+ output[ i + 3 ] = 1;
93
+
94
+ }
95
+
96
+ }
97
+
47
98
  return {
48
99
  width: img.width,
49
100
  height: img.height,
50
- data: new Uint8Array( rgba ),
101
+ data: output,
51
102
  format: THREE.RGBAFormat,
52
- type: THREE.UnsignedByteType,
53
- flipY: true,
54
- encoding: THREE.RGBM7Encoding
103
+ type: this.type,
104
+ flipY: true
55
105
  };
56
106
 
57
107
  }
@@ -225,7 +225,7 @@
225
225
 
226
226
  }
227
227
 
228
- if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
228
+ if ( j === 0 ) firstPoint.copy( point );
229
229
 
230
230
  }
231
231
 
@@ -382,7 +382,7 @@
382
382
 
383
383
  }
384
384
 
385
- if ( j === 0 && doSetFirstPoint === true ) firstPoint.copy( point );
385
+ if ( j === 0 ) firstPoint.copy( point );
386
386
 
387
387
  }
388
388
 
@@ -236,6 +236,7 @@
236
236
  this.minFilter = THREE.NearestFilter;
237
237
  this.magFilter = THREE.LinearFilter;
238
238
  this.unpackAlignment = 1;
239
+ this.needsUpdate = true;
239
240
 
240
241
  }
241
242
 
@@ -139,7 +139,7 @@
139
139
 
140
140
  const StringLiteral = createToken( {
141
141
  name: 'StringLiteral',
142
- pattern: /"(:?[^\\"\n\r]+|\\(:?[bfnrtv"\\/]|u[0-9a-fA-F]{4}))*"/
142
+ pattern: /"(?:[^\\"\n\r]|\\[bfnrtv"\\/]|\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])*"/
143
143
  } );
144
144
  const HexLiteral = createToken( {
145
145
  name: 'HexLiteral',
@@ -1282,6 +1282,7 @@
1282
1282
  }
1283
1283
 
1284
1284
  texture = new THREE.DataTexture( data, width, height, useAlpha === true ? THREE.RGBAFormat : THREE.RGBFormat );
1285
+ texture.needsUpdate = true;
1285
1286
  texture.__type = textureType; // needed for material modifications
1286
1287
 
1287
1288
  break;
@@ -1,6 +1,6 @@
1
1
  ( function () {
2
2
 
3
- // http://mrl.nyu.edu/~perlin/noise/
3
+ // https://cs.nyu.edu/~perlin/noise/
4
4
  const _p = [ 151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180 ];
5
5
 
6
6
  for ( let i = 0; i < 256; i ++ ) {
@@ -310,7 +310,9 @@
310
310
  this.createTexture = function () {
311
311
 
312
312
  const data = new Float32Array( sizeX * sizeY * 4 );
313
- return new THREE.DataTexture( data, sizeX, sizeY, THREE.RGBAFormat, THREE.FloatType );
313
+ const texture = new THREE.DataTexture( data, sizeX, sizeY, THREE.RGBAFormat, THREE.FloatType );
314
+ texture.needsUpdate = true;
315
+ return texture;
314
316
 
315
317
  };
316
318
 
@@ -15,16 +15,8 @@
15
15
  const positionScreen = new THREE.Vector3();
16
16
  const positionView = new THREE.Vector3(); // textures
17
17
 
18
- const tempMap = new THREE.DataTexture( new Uint8Array( 16 * 16 * 3 ), 16, 16, THREE.RGBFormat );
19
- tempMap.minFilter = THREE.NearestFilter;
20
- tempMap.magFilter = THREE.NearestFilter;
21
- tempMap.wrapS = THREE.ClampToEdgeWrapping;
22
- tempMap.wrapT = THREE.ClampToEdgeWrapping;
23
- const occlusionMap = new THREE.DataTexture( new Uint8Array( 16 * 16 * 3 ), 16, 16, THREE.RGBFormat );
24
- occlusionMap.minFilter = THREE.NearestFilter;
25
- occlusionMap.magFilter = THREE.NearestFilter;
26
- occlusionMap.wrapS = THREE.ClampToEdgeWrapping;
27
- occlusionMap.wrapT = THREE.ClampToEdgeWrapping; // material
18
+ const tempMap = new THREE.FramebufferTexture( 16, 16, THREE.RGBFormat );
19
+ const occlusionMap = new THREE.FramebufferTexture( 16, 16, THREE.RGBFormat ); // material
28
20
 
29
21
  const geometry = Lensflare.Geometry;
30
22
  const material1a = new THREE.RawShaderMaterial( {
@@ -135,6 +135,13 @@
135
135
 
136
136
  };
137
137
 
138
+ this.dispose = function () {
139
+
140
+ renderTarget.dispose();
141
+ scope.material.dispose();
142
+
143
+ };
144
+
138
145
  }
139
146
 
140
147
  }
@@ -189,6 +189,13 @@
189
189
 
190
190
  };
191
191
 
192
+ this.dispose = function () {
193
+
194
+ renderTarget.dispose();
195
+ scope.material.dispose();
196
+
197
+ };
198
+
192
199
  }
193
200
 
194
201
  }
@@ -6,7 +6,7 @@
6
6
  * https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight
7
7
  *
8
8
  * First implemented by Simon Wallner
9
- * http://www.simonwallner.at/projects/atmospheric-scattering
9
+ * http://simonwallner.at/project/atmospheric-scattering/
10
10
  *
11
11
  * Improved by Martin Upitis
12
12
  * http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR
@@ -2,8 +2,8 @@
2
2
 
3
3
  /**
4
4
  * Work based on :
5
- * http://slayvin.net : Flat mirror for three.js
6
- * http://www.adelphi.edu/~stemkoski : An implementation of water shader based on the flat mirror
5
+ * https://github.com/Slayvin: Flat mirror for three.js
6
+ * https://home.adelphi.edu/~stemkoski/ : An implementation of water shader based on the flat mirror
7
7
  * http://29a.ch/ && http://29a.ch/slides/2012/webglwater/ : Water shader explanations in WebGL
8
8
  */
9
9
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  /**
4
4
  * References:
5
- * http://www.valvesoftware.com/publications/2010/siggraph2010_vlachos_waterflow.pdf
6
- * http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html
5
+ * https://alex.vlachos.com/graphics/Vlachos-SIGGRAPH10-WaterFlow.pdf
6
+ * http://graphicsrunner.blogspot.de/2010/08/water-using-flow-maps.html
7
7
  *
8
8
  */
9
9
 
@@ -23,7 +23,6 @@
23
23
  const reflectivity = options.reflectivity || 0.02;
24
24
  const scale = options.scale || 1;
25
25
  const shader = options.shader || Water.WaterShader;
26
- const encoding = options.encoding !== undefined ? options.encoding : THREE.LinearEncoding;
27
26
  const textureLoader = new THREE.TextureLoader();
28
27
  const flowMap = options.flowMap || undefined;
29
28
  const normalMap0 = options.normalMap0 || textureLoader.load( 'textures/water/Water_1_M_Normal.jpg' );
@@ -51,14 +50,12 @@
51
50
  const reflector = new THREE.Reflector( geometry, {
52
51
  textureWidth: textureWidth,
53
52
  textureHeight: textureHeight,
54
- clipBias: clipBias,
55
- encoding: encoding
53
+ clipBias: clipBias
56
54
  } );
57
55
  const refractor = new THREE.Refractor( geometry, {
58
56
  textureWidth: textureWidth,
59
57
  textureHeight: textureHeight,
60
- clipBias: clipBias,
61
- encoding: encoding
58
+ clipBias: clipBias
62
59
  } );
63
60
  reflector.matrixAutoUpdate = false;
64
61
  refractor.matrixAutoUpdate = false; // material
@@ -93,7 +93,9 @@
93
93
 
94
94
  }
95
95
 
96
- return new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
96
+ const texture = new THREE.DataTexture( data_arr, dt_size, dt_size, THREE.RGBFormat, THREE.FloatType );
97
+ texture.needsUpdate = true;
98
+ return texture;
97
99
 
98
100
  }
99
101
 
@@ -316,6 +316,7 @@
316
316
  this.noiseTexture = new THREE.DataTexture( data, width, height, THREE.RGBAFormat, THREE.FloatType );
317
317
  this.noiseTexture.wrapS = THREE.RepeatWrapping;
318
318
  this.noiseTexture.wrapT = THREE.RepeatWrapping;
319
+ this.noiseTexture.needsUpdate = true;
319
320
 
320
321
  }
321
322
 
@@ -3,7 +3,6 @@
3
3
  /**
4
4
  * Convolution shader
5
5
  * ported from o3d sample to WebGL / GLSL
6
- * http://o3d.googlecode.com/svn/trunk/samples/convolution.html
7
6
  */
8
7
 
9
8
  const ConvolutionShader = {
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * NVIDIA FXAA by Timothy Lottes
5
- * http://timothylottes.blogspot.com/2011/06/fxaa3-source-released.html
5
+ * https://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
6
6
  * - WebGL port by @supereggbert
7
7
  * http://www.glge.org/demos/fxaa/
8
8
  */
@@ -4,7 +4,7 @@
4
4
  * Film grain & scanlines shader
5
5
  *
6
6
  * - ported from HLSL to WebGL / GLSL
7
- * http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
7
+ * https://web.archive.org/web/20210226214859/http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
8
8
  *
9
9
  * Screen Space Static Postprocessor
10
10
  *
@@ -34,7 +34,7 @@
34
34
 
35
35
  vec4 tex = texture2D( tDiffuse, vUv );
36
36
 
37
- gl_FragColor = LinearTosRGB( tex ); // optional: LinearToGamma( tex, float( GAMMA_FACTOR ) );
37
+ gl_FragColor = LinearTosRGB( tex );
38
38
 
39
39
  }`
40
40
  };
@@ -2,8 +2,7 @@
2
2
 
3
3
  /**
4
4
  * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
5
- * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/
6
- * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html
5
+ * - see http://www.cake23.de/traveling-wavefronts-lit-up.html
7
6
  *
8
7
  * - 9 samples per pass
9
8
  * - standard deviation 2.7
@@ -197,7 +197,7 @@
197
197
  vec3 vP=getViewPosition( uv, d, cW );
198
198
 
199
199
  #ifdef PERSPECTIVE_CAMERA
200
- // https://www.comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf
200
+ // https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf
201
201
  float recipVPZ=1./viewPosition.z;
202
202
  float viewReflectRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));
203
203
  #else
@@ -215,7 +215,7 @@
215
215
  vec3 vP=getViewPosition( uv, d, cW );
216
216
 
217
217
  #ifdef PERSPECTIVE_CAMERA
218
- // https://www.comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf
218
+ // https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf
219
219
  float recipVPZ=1./viewPosition.z;
220
220
  float viewRefractRayZ=1./(recipVPZ+s*(1./d1viewPosition.z-recipVPZ));
221
221
  float sD=surfDist*cW;
@@ -2,8 +2,7 @@
2
2
 
3
3
  /**
4
4
  * Two pass Gaussian blur filter (horizontal and vertical blur shaders)
5
- * - described in http://www.gamerendering.com/2008/10/11/gaussian-blur-filter-shader/
6
- * and used in http://www.cake23.de/traveling-wavefronts-lit-up.html
5
+ * - see http://www.cake23.de/traveling-wavefronts-lit-up.html
7
6
  *
8
7
  * - 9 samples per pass
9
8
  * - standard deviation 2.7
@@ -41,7 +41,7 @@
41
41
  * Generates 3D-Coordinates in a very fast way.
42
42
  *
43
43
  * Based on work by:
44
- * @link http://www.openprocessing.org/visuals/?visualID=15599
44
+ * @link https://openprocessing.org/user/5654
45
45
  *
46
46
  * @param center Center of Hilbert curve.
47
47
  * @param size Total width of Hilbert curve.