super-three 0.161.0 → 0.163.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 (206) hide show
  1. package/build/three.cjs +822 -1332
  2. package/build/three.module.js +820 -1328
  3. package/build/three.module.min.js +1 -1
  4. package/examples/jsm/controls/DragControls.js +91 -30
  5. package/examples/jsm/controls/OrbitControls.js +32 -6
  6. package/examples/jsm/controls/TransformControls.js +9 -9
  7. package/examples/jsm/exporters/GLTFExporter.js +30 -3
  8. package/examples/jsm/exporters/USDZExporter.js +15 -0
  9. package/examples/jsm/geometries/TextGeometry.js +10 -2
  10. package/examples/jsm/interactive/HTMLMesh.js +7 -9
  11. package/examples/jsm/interactive/InteractiveGroup.js +15 -25
  12. package/examples/jsm/libs/fflate.module.js +694 -496
  13. package/examples/jsm/libs/rhino3dm/rhino3dm.js +1 -8723
  14. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +1 -8734
  15. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  16. package/examples/jsm/libs/tween.module.js +32 -14
  17. package/examples/jsm/lines/LineMaterial.js +0 -2
  18. package/examples/jsm/loaders/3DMLoader.js +13 -21
  19. package/examples/jsm/loaders/3MFLoader.js +2 -0
  20. package/examples/jsm/loaders/EXRLoader.js +89 -19
  21. package/examples/jsm/loaders/FBXLoader.js +1 -1
  22. package/examples/jsm/loaders/GLTFLoader.js +6 -0
  23. package/examples/jsm/loaders/KTX2Loader.js +2 -6
  24. package/examples/jsm/loaders/LUT3dlLoader.js +0 -15
  25. package/examples/jsm/loaders/LUTCubeLoader.js +0 -14
  26. package/examples/jsm/loaders/LUTImageLoader.js +0 -14
  27. package/examples/jsm/loaders/RGBMLoader.js +16 -0
  28. package/examples/jsm/loaders/VOXLoader.js +9 -2
  29. package/examples/jsm/loaders/VRMLLoader.js +6 -2
  30. package/examples/jsm/misc/GPUComputationRenderer.js +0 -6
  31. package/examples/jsm/misc/ProgressiveLightMap.js +1 -0
  32. package/examples/jsm/nodes/Nodes.js +15 -8
  33. package/examples/jsm/nodes/accessors/AccessorsUtils.js +10 -0
  34. package/examples/jsm/nodes/accessors/BatchNode.js +78 -0
  35. package/examples/jsm/nodes/accessors/ClippingNode.js +144 -0
  36. package/examples/jsm/nodes/accessors/InstanceNode.js +25 -2
  37. package/examples/jsm/nodes/accessors/MaterialNode.js +2 -2
  38. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +2 -12
  39. package/examples/jsm/nodes/accessors/MorphNode.js +20 -10
  40. package/examples/jsm/nodes/accessors/NormalNode.js +12 -2
  41. package/examples/jsm/nodes/accessors/ReferenceNode.js +87 -29
  42. package/examples/jsm/nodes/accessors/RendererReferenceNode.js +29 -0
  43. package/examples/jsm/nodes/accessors/SkinningNode.js +31 -10
  44. package/examples/jsm/nodes/accessors/StorageBufferNode.js +18 -0
  45. package/examples/jsm/nodes/accessors/TangentNode.js +8 -2
  46. package/examples/jsm/nodes/accessors/TextureNode.js +30 -7
  47. package/examples/jsm/nodes/accessors/UniformsNode.js +140 -0
  48. package/examples/jsm/nodes/code/CodeNode.js +6 -0
  49. package/examples/jsm/nodes/core/AssignNode.js +68 -12
  50. package/examples/jsm/nodes/core/Node.js +67 -6
  51. package/examples/jsm/nodes/core/NodeBuilder.js +23 -24
  52. package/examples/jsm/nodes/core/NodeFrame.js +8 -8
  53. package/examples/jsm/nodes/core/NodeUtils.js +2 -2
  54. package/examples/jsm/nodes/core/TempNode.js +1 -1
  55. package/examples/jsm/nodes/core/UniformNode.js +20 -0
  56. package/examples/jsm/nodes/display/BlendModeNode.js +30 -1
  57. package/examples/jsm/nodes/display/NormalMapNode.js +3 -5
  58. package/examples/jsm/nodes/display/PassNode.js +17 -1
  59. package/examples/jsm/nodes/display/ToneMappingNode.js +8 -4
  60. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +6 -0
  61. package/examples/jsm/nodes/fog/FogExp2Node.js +4 -5
  62. package/examples/jsm/nodes/fog/FogNode.js +13 -3
  63. package/examples/jsm/nodes/fog/FogRangeNode.js +4 -3
  64. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
  65. package/examples/jsm/nodes/lighting/EnvironmentNode.js +12 -69
  66. package/examples/jsm/nodes/materials/NodeMaterial.js +70 -17
  67. package/examples/jsm/nodes/math/CondNode.js +42 -7
  68. package/examples/jsm/nodes/math/MathNode.js +20 -0
  69. package/examples/jsm/nodes/pmrem/PMREMNode.js +193 -0
  70. package/examples/jsm/nodes/pmrem/PMREMUtils.js +288 -0
  71. package/examples/jsm/nodes/shadernode/ShaderNode.js +1 -1
  72. package/examples/jsm/nodes/utils/ArrayElementNode.js +0 -6
  73. package/examples/jsm/nodes/utils/EquirectUVNode.js +1 -1
  74. package/examples/jsm/nodes/utils/LoopNode.js +2 -0
  75. package/examples/jsm/nodes/utils/StorageArrayElementNode.js +91 -0
  76. package/examples/jsm/objects/QuadMesh.js +7 -23
  77. package/examples/jsm/physics/RapierPhysics.js +4 -4
  78. package/examples/jsm/postprocessing/GlitchPass.js +0 -3
  79. package/examples/jsm/postprocessing/LUTPass.js +5 -71
  80. package/examples/jsm/postprocessing/OutputPass.js +2 -0
  81. package/examples/jsm/postprocessing/SAOPass.js +0 -1
  82. package/examples/jsm/postprocessing/SSAOPass.js +0 -3
  83. package/examples/jsm/renderers/common/Animation.js +3 -0
  84. package/examples/jsm/renderers/common/Background.js +3 -3
  85. package/examples/jsm/renderers/common/ClippingContext.js +165 -0
  86. package/examples/jsm/renderers/common/Info.js +11 -19
  87. package/examples/jsm/renderers/common/PostProcessing.js +12 -4
  88. package/examples/jsm/renderers/common/RenderContext.js +3 -1
  89. package/examples/jsm/renderers/common/RenderContexts.js +2 -13
  90. package/examples/jsm/renderers/common/RenderObject.js +46 -3
  91. package/examples/jsm/renderers/common/RenderObjects.js +2 -0
  92. package/examples/jsm/renderers/common/Renderer.js +113 -39
  93. package/examples/jsm/renderers/common/StorageBufferAttribute.js +2 -2
  94. package/examples/jsm/renderers/common/StorageInstancedBufferAttribute.js +17 -0
  95. package/examples/jsm/renderers/common/Textures.js +3 -13
  96. package/examples/jsm/renderers/common/UniformsGroup.js +6 -4
  97. package/examples/jsm/renderers/common/extras/PMREMGenerator.js +777 -0
  98. package/examples/jsm/renderers/common/nodes/NodeStorageBuffer.js +23 -0
  99. package/examples/jsm/renderers/common/nodes/NodeUniformBuffer.js +23 -0
  100. package/examples/jsm/renderers/common/nodes/Nodes.js +6 -18
  101. package/examples/jsm/renderers/webgl/WebGLBackend.js +174 -30
  102. package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +141 -0
  103. package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +136 -11
  104. package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +8 -2
  105. package/examples/jsm/renderers/webgl/utils/WebGLConstants.js +1 -0
  106. package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +90 -0
  107. package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -1
  108. package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -2
  109. package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -2
  110. package/examples/jsm/renderers/webgpu/WebGPUBackend.js +67 -37
  111. package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +20 -43
  112. package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +32 -1
  113. package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +18 -4
  114. package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +94 -20
  115. package/examples/jsm/shaders/OutputShader.js +4 -0
  116. package/examples/jsm/utils/GPUStatsPanel.js +10 -45
  117. package/examples/jsm/utils/SkeletonUtils.js +14 -3
  118. package/examples/jsm/utils/TextureUtils.js +1 -1
  119. package/examples/jsm/webxr/VRButton.js +13 -5
  120. package/examples/jsm/webxr/XRButton.js +0 -1
  121. package/examples/jsm/webxr/XRControllerModelFactory.js +8 -0
  122. package/package.json +4 -3
  123. package/src/Three.Legacy.js +20 -0
  124. package/src/Three.js +0 -2
  125. package/src/animation/AnimationClip.js +1 -1
  126. package/src/constants.js +4 -7
  127. package/src/core/BufferAttribute.js +0 -11
  128. package/src/core/BufferGeometry.js +23 -29
  129. package/src/core/Object3D.js +21 -7
  130. package/src/core/Raycaster.js +18 -4
  131. package/src/core/RenderTarget.js +44 -21
  132. package/src/extras/PMREMGenerator.js +11 -0
  133. package/src/extras/curves/EllipseCurve.js +2 -2
  134. package/src/helpers/SpotLightHelper.js +18 -1
  135. package/src/loaders/DataTextureLoader.js +0 -4
  136. package/src/loaders/MaterialLoader.js +1 -0
  137. package/src/loaders/ObjectLoader.js +4 -1
  138. package/src/materials/Material.js +2 -1
  139. package/src/materials/MeshBasicMaterial.js +3 -0
  140. package/src/materials/MeshLambertMaterial.js +3 -0
  141. package/src/materials/MeshPhongMaterial.js +3 -0
  142. package/src/materials/MeshStandardMaterial.js +3 -0
  143. package/src/materials/ShaderMaterial.js +0 -4
  144. package/src/math/Quaternion.js +13 -12
  145. package/src/math/Spherical.js +4 -5
  146. package/src/math/Vector3.js +7 -7
  147. package/src/objects/BatchedMesh.js +4 -3
  148. package/src/objects/InstancedMesh.js +63 -0
  149. package/src/objects/Mesh.js +0 -1
  150. package/src/renderers/WebGLCubeRenderTarget.js +1 -10
  151. package/src/renderers/WebGLRenderer.js +70 -136
  152. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +1 -0
  153. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
  154. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
  155. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +2 -2
  156. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +1 -1
  157. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +2 -10
  158. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +2 -16
  159. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -1
  160. package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +14 -0
  161. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +11 -2
  162. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +32 -22
  163. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +23 -0
  164. package/src/renderers/shaders/ShaderChunk.js +2 -0
  165. package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +3 -2
  166. package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
  167. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
  168. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +1 -0
  169. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -0
  170. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +1 -0
  171. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +1 -0
  172. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -0
  173. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +1 -0
  174. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +1 -0
  175. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +1 -0
  176. package/src/renderers/shaders/ShaderLib/points.glsl.js +1 -0
  177. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
  178. package/src/renderers/shaders/ShaderLib.js +3 -2
  179. package/src/renderers/shaders/UniformsLib.js +1 -0
  180. package/src/renderers/shaders/UniformsUtils.js +10 -1
  181. package/src/renderers/webgl/WebGLAttributes.js +6 -33
  182. package/src/renderers/webgl/WebGLBackground.js +18 -0
  183. package/src/renderers/webgl/WebGLBindingStates.js +14 -51
  184. package/src/renderers/webgl/WebGLBufferRenderer.js +3 -25
  185. package/src/renderers/webgl/WebGLCapabilities.js +2 -12
  186. package/src/renderers/webgl/WebGLCubeUVMaps.js +10 -6
  187. package/src/renderers/webgl/WebGLExtensions.js +4 -19
  188. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +3 -25
  189. package/src/renderers/webgl/WebGLLights.js +6 -32
  190. package/src/renderers/webgl/WebGLMaterials.js +26 -4
  191. package/src/renderers/webgl/WebGLMorphtargets.js +79 -210
  192. package/src/renderers/webgl/WebGLProgram.js +30 -48
  193. package/src/renderers/webgl/WebGLPrograms.js +5 -14
  194. package/src/renderers/webgl/WebGLRenderStates.js +8 -6
  195. package/src/renderers/webgl/WebGLState.js +21 -75
  196. package/src/renderers/webgl/WebGLTextures.js +143 -275
  197. package/src/renderers/webgl/WebGLUniformsGroups.js +1 -1
  198. package/src/renderers/webgl/WebGLUtils.js +6 -57
  199. package/src/renderers/webxr/WebXRDepthSensing.js +2 -3
  200. package/src/renderers/webxr/WebXRManager.js +2 -2
  201. package/src/scenes/Scene.js +14 -0
  202. package/src/textures/Texture.js +6 -24
  203. package/examples/jsm/nodes/core/ArrayUniformNode.js +0 -26
  204. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +0 -37
  205. package/src/renderers/WebGL1Renderer.js +0 -7
  206. package/src/renderers/WebGLMultipleRenderTargets.js +0 -82
@@ -0,0 +1,288 @@
1
+ import { tslFn, int, float, vec2, vec3, vec4, If } from '../shadernode/ShaderNode.js';
2
+ import { cos, sin, abs, max, exp2, log2, clamp, fract, mix, floor, normalize, cross, all } from '../math/MathNode.js';
3
+ import { mul } from '../math/OperatorNode.js';
4
+ import { cond } from '../math/CondNode.js';
5
+ import { loop, Break } from '../utils/LoopNode.js';
6
+
7
+ // These defines must match with PMREMGenerator
8
+
9
+ const cubeUV_r0 = float( 1.0 );
10
+ const cubeUV_m0 = float( - 2.0 );
11
+ const cubeUV_r1 = float( 0.8 );
12
+ const cubeUV_m1 = float( - 1.0 );
13
+ const cubeUV_r4 = float( 0.4 );
14
+ const cubeUV_m4 = float( 2.0 );
15
+ const cubeUV_r5 = float( 0.305 );
16
+ const cubeUV_m5 = float( 3.0 );
17
+ const cubeUV_r6 = float( 0.21 );
18
+ const cubeUV_m6 = float( 4.0 );
19
+
20
+ const cubeUV_minMipLevel = float( 4.0 );
21
+ const cubeUV_minTileSize = float( 16.0 );
22
+
23
+ // These shader functions convert between the UV coordinates of a single face of
24
+ // a cubemap, the 0-5 integer index of a cube face, and the direction vector for
25
+ // sampling a textureCube (not generally normalized ).
26
+
27
+ const getFace = tslFn( ( [ direction ] ) => {
28
+
29
+ const absDirection = vec3( abs( direction ) ).toVar();
30
+ const face = float( - 1.0 ).toVar();
31
+
32
+ If( absDirection.x.greaterThan( absDirection.z ), () => {
33
+
34
+ If( absDirection.x.greaterThan( absDirection.y ), () => {
35
+
36
+ face.assign( cond( direction.x.greaterThan( 0.0 ), 0.0, 3.0 ) );
37
+
38
+ } ).else( () => {
39
+
40
+ face.assign( cond( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
41
+
42
+ } );
43
+
44
+ } ).else( () => {
45
+
46
+ If( absDirection.z.greaterThan( absDirection.y ), () => {
47
+
48
+ face.assign( cond( direction.z.greaterThan( 0.0 ), 2.0, 5.0 ) );
49
+
50
+ } ).else( () => {
51
+
52
+ face.assign( cond( direction.y.greaterThan( 0.0 ), 1.0, 4.0 ) );
53
+
54
+ } );
55
+
56
+ } );
57
+
58
+ return face;
59
+
60
+ } ).setLayout( {
61
+ name: 'getFace',
62
+ type: 'float',
63
+ inputs: [
64
+ { name: 'direction', type: 'vec3' }
65
+ ]
66
+ } );
67
+
68
+ // RH coordinate system; PMREM face-indexing convention
69
+ const getUV = tslFn( ( [ direction, face ] ) => {
70
+
71
+ const uv = vec2().toVar();
72
+
73
+ If( face.equal( 0.0 ), () => {
74
+
75
+ uv.assign( vec2( direction.z, direction.y ).div( abs( direction.x ) ) ); // pos x
76
+
77
+ } ).elseif( face.equal( 1.0 ), () => {
78
+
79
+ uv.assign( vec2( direction.x.negate(), direction.z.negate() ).div( abs( direction.y ) ) ); // pos y
80
+
81
+ } ).elseif( face.equal( 2.0 ), () => {
82
+
83
+ uv.assign( vec2( direction.x.negate(), direction.y ).div( abs( direction.z ) ) ); // pos z
84
+
85
+ } ).elseif( face.equal( 3.0 ), () => {
86
+
87
+ uv.assign( vec2( direction.z.negate(), direction.y ).div( abs( direction.x ) ) ); // neg x
88
+
89
+ } ).elseif( face.equal( 4.0 ), () => {
90
+
91
+ uv.assign( vec2( direction.x.negate(), direction.z ).div( abs( direction.y ) ) ); // neg y
92
+
93
+ } ).else( () => {
94
+
95
+ uv.assign( vec2( direction.x, direction.y ).div( abs( direction.z ) ) ); // neg z
96
+
97
+ } );
98
+
99
+ return mul( 0.5, uv.add( 1.0 ) );
100
+
101
+ } ).setLayout( {
102
+ name: 'getUV',
103
+ type: 'vec2',
104
+ inputs: [
105
+ { name: 'direction', type: 'vec3' },
106
+ { name: 'face', type: 'float' }
107
+ ]
108
+ } );
109
+
110
+ const roughnessToMip = tslFn( ( [ roughness ] ) => {
111
+
112
+ const mip = float( 0.0 ).toVar();
113
+
114
+ If( roughness.greaterThanEqual( cubeUV_r1 ), () => {
115
+
116
+ mip.assign( cubeUV_r0.sub( roughness ).mul( cubeUV_m1.sub( cubeUV_m0 ) ).div( cubeUV_r0.sub( cubeUV_r1 ) ).add( cubeUV_m0 ) );
117
+
118
+ } ).elseif( roughness.greaterThanEqual( cubeUV_r4 ), () => {
119
+
120
+ mip.assign( cubeUV_r1.sub( roughness ).mul( cubeUV_m4.sub( cubeUV_m1 ) ).div( cubeUV_r1.sub( cubeUV_r4 ) ).add( cubeUV_m1 ) );
121
+
122
+ } ).elseif( roughness.greaterThanEqual( cubeUV_r5 ), () => {
123
+
124
+ mip.assign( cubeUV_r4.sub( roughness ).mul( cubeUV_m5.sub( cubeUV_m4 ) ).div( cubeUV_r4.sub( cubeUV_r5 ) ).add( cubeUV_m4 ) );
125
+
126
+ } ).elseif( roughness.greaterThanEqual( cubeUV_r6 ), () => {
127
+
128
+ mip.assign( cubeUV_r5.sub( roughness ).mul( cubeUV_m6.sub( cubeUV_m5 ) ).div( cubeUV_r5.sub( cubeUV_r6 ) ).add( cubeUV_m5 ) );
129
+
130
+ } ).else( () => {
131
+
132
+ mip.assign( float( - 2.0 ).mul( log2( mul( 1.16, roughness ) ) ) ); // 1.16 = 1.79^0.25
133
+
134
+ } );
135
+
136
+ return mip;
137
+
138
+ } ).setLayout( {
139
+ name: 'roughnessToMip',
140
+ type: 'float',
141
+ inputs: [
142
+ { name: 'roughness', type: 'float' }
143
+ ]
144
+ } );
145
+
146
+ // RH coordinate system; PMREM face-indexing convention
147
+ export const getDirection = tslFn( ( [ uv_immutable, face ] ) => {
148
+
149
+ const uv = uv_immutable.toVar();
150
+ uv.assign( mul( 2.0, uv ).sub( 1.0 ) );
151
+ const direction = vec3( uv, 1.0 ).toVar();
152
+
153
+ If( face.equal( 0.0 ), () => {
154
+
155
+ direction.assign( direction.zyx ); // ( 1, v, u ) pos x
156
+
157
+ } ).elseif( face.equal( 1.0 ), () => {
158
+
159
+ direction.assign( direction.xzy );
160
+ direction.xz.mulAssign( - 1.0 ); // ( -u, 1, -v ) pos y
161
+
162
+ } ).elseif( face.equal( 2.0 ), () => {
163
+
164
+ direction.x.mulAssign( - 1.0 ); // ( -u, v, 1 ) pos z
165
+
166
+ } ).elseif( face.equal( 3.0 ), () => {
167
+
168
+ direction.assign( direction.zyx );
169
+ direction.xz.mulAssign( - 1.0 ); // ( -1, v, -u ) neg x
170
+
171
+ } ).elseif( face.equal( 4.0 ), () => {
172
+
173
+ direction.assign( direction.xzy );
174
+ direction.xy.mulAssign( - 1.0 ); // ( -u, -1, v ) neg y
175
+
176
+ } ).elseif( face.equal( 5.0 ), () => {
177
+
178
+ direction.z.mulAssign( - 1.0 ); // ( u, v, -1 ) neg zS
179
+
180
+ } );
181
+
182
+ return direction;
183
+
184
+ } ).setLayout( {
185
+ name: 'getDirection',
186
+ type: 'vec3',
187
+ inputs: [
188
+ { name: 'uv', type: 'vec2' },
189
+ { name: 'face', type: 'float' }
190
+ ]
191
+ } );
192
+
193
+ //
194
+
195
+ export const textureCubeUV = tslFn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
196
+
197
+ const roughness = float( roughness_immutable );
198
+ const sampleDir = vec3( sampleDir_immutable );
199
+
200
+ const mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
201
+ const mipF = fract( mip );
202
+ const mipInt = floor( mip );
203
+ const color0 = vec3( bilinearCubeUV( envMap, sampleDir, mipInt, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ) ).toVar();
204
+
205
+ If( mipF.notEqual( 0.0 ), () => {
206
+
207
+ const color1 = vec3( bilinearCubeUV( envMap, sampleDir, mipInt.add( 1.0 ), CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ) ).toVar();
208
+
209
+ color0.assign( mix( color0, color1, mipF ) );
210
+
211
+ } );
212
+
213
+ return color0;
214
+
215
+ } );
216
+
217
+ const bilinearCubeUV = tslFn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => {
218
+
219
+ const mipInt = float( mipInt_immutable ).toVar();
220
+ const direction = vec3( direction_immutable );
221
+ const face = float( getFace( direction ) ).toVar();
222
+ const filterInt = float( max( cubeUV_minMipLevel.sub( mipInt ), 0.0 ) ).toVar();
223
+ mipInt.assign( max( mipInt, cubeUV_minMipLevel ) );
224
+ const faceSize = float( exp2( mipInt ) ).toVar();
225
+ const uv = vec2( getUV( direction, face ).mul( faceSize.sub( 2.0 ) ).add( 1.0 ) ).toVar();
226
+
227
+ If( face.greaterThan( 2.0 ), () => {
228
+
229
+ uv.y.addAssign( faceSize );
230
+ face.subAssign( 3.0 );
231
+
232
+ } );
233
+
234
+ uv.x.addAssign( face.mul( faceSize ) );
235
+ uv.x.addAssign( filterInt.mul( mul( 3.0, cubeUV_minTileSize ) ) );
236
+ uv.y.addAssign( mul( 4.0, exp2( CUBEUV_MAX_MIP ).sub( faceSize ) ) );
237
+ uv.x.mulAssign( CUBEUV_TEXEL_WIDTH );
238
+ uv.y.mulAssign( CUBEUV_TEXEL_HEIGHT );
239
+
240
+ return envMap.uv( uv );
241
+
242
+ } );
243
+
244
+ const getSample = tslFn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
245
+
246
+ const cosTheta = cos( theta );
247
+
248
+ // Rodrigues' axis-angle rotation
249
+ const sampleDirection = outputDirection.mul( cosTheta )
250
+ .add( axis.cross( outputDirection ).mul( sin( theta ) ) )
251
+ .add( axis.mul( axis.dot( outputDirection ).mul( cosTheta.oneMinus() ) ) );
252
+
253
+ return bilinearCubeUV( envMap, sampleDirection, mipInt, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP );
254
+
255
+ } );
256
+
257
+ export const blur = tslFn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => {
258
+
259
+ const axis = vec3( cond( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar();
260
+
261
+ If( all( axis.equals( vec3( 0.0 ) ) ), () => {
262
+
263
+ axis.assign( vec3( outputDirection.z, 0.0, outputDirection.x.negate() ) );
264
+
265
+ } );
266
+
267
+ axis.assign( normalize( axis ) );
268
+
269
+ const gl_FragColor = vec3().toVar();
270
+ gl_FragColor.addAssign( weights.element( int( 0 ) ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
271
+
272
+ loop( { start: int( 1 ), end: n }, ( { i } ) => {
273
+
274
+ If( i.greaterThanEqual( samples ), () => {
275
+
276
+ Break();
277
+
278
+ } );
279
+
280
+ const theta = float( dTheta.mul( float( i ) ) ).toVar();
281
+ gl_FragColor.addAssign( weights.element( i ).mul( getSample( { theta: theta.mul( - 1.0 ), axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
282
+ gl_FragColor.addAssign( weights.element( i ).mul( getSample( { theta, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
283
+
284
+ } );
285
+
286
+ return vec4( gl_FragColor, 1 );
287
+
288
+ } );
@@ -555,7 +555,7 @@ addNodeElement( 'append', append );
555
555
  export const color = new ConvertType( 'color' );
556
556
 
557
557
  export const float = new ConvertType( 'float', cacheMaps.float );
558
- export const int = new ConvertType( 'int', cacheMaps.int );
558
+ export const int = new ConvertType( 'int', cacheMaps.ints );
559
559
  export const uint = new ConvertType( 'uint', cacheMaps.uint );
560
560
  export const bool = new ConvertType( 'bool', cacheMaps.bool );
561
561
 
@@ -24,12 +24,6 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
24
24
  const nodeSnippet = this.node.build( builder );
25
25
  const indexSnippet = this.indexNode.build( builder, 'uint' );
26
26
 
27
- if ( this.node.isStorageBufferNode && ! builder.isAvailable( 'storageBuffer' ) ) {
28
-
29
- return nodeSnippet;
30
-
31
- }
32
-
33
27
  return `${nodeSnippet}[ ${indexSnippet} ]`;
34
28
 
35
29
  }
@@ -18,7 +18,7 @@ class EquirectUVNode extends TempNode {
18
18
  const dir = this.dirNode;
19
19
 
20
20
  const u = dir.z.atan2( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
21
- const v = dir.y.negate().clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 ); // @TODO: The use of negate() here could be an NDC issue.
21
+ const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );
22
22
 
23
23
  return vec2( u, v );
24
24
 
@@ -192,6 +192,8 @@ class LoopNode extends Node {
192
192
  export default LoopNode;
193
193
 
194
194
  export const loop = ( ...params ) => nodeObject( new LoopNode( nodeArray( params, 'int' ) ) ).append();
195
+ export const Continue = () => expression( 'continue' ).append();
196
+ export const Break = () => expression( 'break' ).append();
195
197
 
196
198
  addNodeElement( 'loop', ( returns, ...params ) => bypass( returns, loop( ...params ) ) );
197
199
 
@@ -0,0 +1,91 @@
1
+ import { addNodeClass } from '../core/Node.js';
2
+ import { nodeProxy, addNodeElement } from '../shadernode/ShaderNode.js';
3
+ import ArrayElementNode from './ArrayElementNode.js';
4
+
5
+ class StorageArrayElementNode extends ArrayElementNode {
6
+
7
+ constructor( storageBufferNode, indexNode ) {
8
+
9
+ super( storageBufferNode, indexNode );
10
+
11
+ this.isStorageArrayElementNode = true;
12
+
13
+ }
14
+
15
+ set storageBufferNode( value ) {
16
+
17
+ this.node = value;
18
+
19
+ }
20
+
21
+ get storageBufferNode() {
22
+
23
+ return this.node;
24
+
25
+ }
26
+
27
+ setup( builder ) {
28
+
29
+ if ( builder.isAvailable( 'storageBuffer' ) === false ) {
30
+
31
+ if ( ! this.node.instanceIndex && this.node.bufferObject === true ) {
32
+
33
+ builder.setupPBO( this.node );
34
+
35
+ }
36
+
37
+ }
38
+
39
+ return super.setup( builder );
40
+
41
+ }
42
+
43
+ generate( builder, output ) {
44
+
45
+ let snippet;
46
+
47
+ const isAssignContext = builder.context.assign;
48
+
49
+ //
50
+
51
+ if ( builder.isAvailable( 'storageBuffer' ) === false ) {
52
+
53
+ const { node } = this;
54
+
55
+ if ( ! node.instanceIndex && this.node.bufferObject === true && isAssignContext !== true ) {
56
+
57
+ snippet = builder.generatePBO( this );
58
+
59
+ } else {
60
+
61
+ snippet = node.build( builder );
62
+
63
+ }
64
+
65
+ } else {
66
+
67
+ snippet = super.generate( builder );
68
+
69
+ }
70
+
71
+ if ( isAssignContext !== true ) {
72
+
73
+ const type = this.getNodeType( builder );
74
+
75
+ snippet = builder.format( snippet, type, output );
76
+
77
+ }
78
+
79
+ return snippet;
80
+
81
+ }
82
+
83
+ }
84
+
85
+ export default StorageArrayElementNode;
86
+
87
+ export const storageElement = nodeProxy( StorageArrayElementNode );
88
+
89
+ addNodeElement( 'storageElement', storageElement );
90
+
91
+ addNodeClass( 'StorageArrayElementNode', StorageArrayElementNode );
@@ -23,41 +23,25 @@ class QuadGeometry extends BufferGeometry {
23
23
 
24
24
  const _geometry = new QuadGeometry();
25
25
 
26
- class QuadMesh {
26
+ class QuadMesh extends Mesh {
27
27
 
28
28
  constructor( material = null ) {
29
29
 
30
- this._mesh = new Mesh( _geometry, material );
30
+ super( _geometry, material );
31
31
 
32
- }
33
-
34
- dispose() {
35
-
36
- this._mesh.geometry.dispose();
37
-
38
- }
39
-
40
- async renderAsync( renderer ) {
41
-
42
- await renderer.renderAsync( this._mesh, _camera );
43
-
44
- }
45
-
46
- get material() {
47
-
48
- return this._mesh.material;
32
+ this.camera = _camera;
49
33
 
50
34
  }
51
35
 
52
- set material( value ) {
36
+ renderAsync( renderer ) {
53
37
 
54
- this._mesh.material = value;
38
+ return renderer.renderAsync( this, _camera );
55
39
 
56
40
  }
57
41
 
58
- get render() {
42
+ render( renderer ) {
59
43
 
60
- return this.renderAsync;
44
+ renderer.render( this, _camera );
61
45
 
62
46
  }
63
47
 
@@ -1,6 +1,6 @@
1
1
  import { Clock, Vector3, Quaternion, Matrix4 } from 'three';
2
2
 
3
- const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.11.2';
3
+ const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.12.0';
4
4
 
5
5
  const frameRate = 60;
6
6
 
@@ -9,7 +9,7 @@ const ZERO = new Vector3();
9
9
 
10
10
  let RAPIER = null;
11
11
 
12
- function getCollider( geometry ) {
12
+ function getShape( geometry ) {
13
13
 
14
14
  const parameters = geometry.parameters;
15
15
 
@@ -43,7 +43,7 @@ async function RapierPhysics() {
43
43
 
44
44
  }
45
45
 
46
- // Docs: https://rapier.rs/docs/api/javascript/JavaScript3D/
46
+ // Docs: https://rapier.rs/docs/api/javascript/JavaScript3D/
47
47
 
48
48
  const gravity = new Vector3( 0.0, - 9.81, 0.0 );
49
49
  const world = new RAPIER.World( gravity );
@@ -77,7 +77,7 @@ async function RapierPhysics() {
77
77
 
78
78
  function addMesh( mesh, mass = 0, restitution = 0 ) {
79
79
 
80
- const shape = getCollider( mesh.geometry );
80
+ const shape = getShape( mesh.geometry );
81
81
 
82
82
  if ( shape === null ) return;
83
83
 
@@ -3,7 +3,6 @@ import {
3
3
  FloatType,
4
4
  MathUtils,
5
5
  RedFormat,
6
- LuminanceFormat,
7
6
  ShaderMaterial,
8
7
  UniformsUtils
9
8
  } from 'three';
@@ -40,8 +39,6 @@ class GlitchPass extends Pass {
40
39
 
41
40
  render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
42
41
 
43
- if ( renderer.capabilities.isWebGL2 === false ) this.uniforms[ 'tDisp' ].value.format = LuminanceFormat;
44
-
45
42
  this.uniforms[ 'tDiffuse' ].value = readBuffer.texture;
46
43
  this.uniforms[ 'seed' ].value = Math.random();//default seeding
47
44
  this.uniforms[ 'byp' ].value = 0;
@@ -4,12 +4,7 @@ const LUTShader = {
4
4
 
5
5
  name: 'LUTShader',
6
6
 
7
- defines: {
8
- USE_3DTEXTURE: 1,
9
- },
10
-
11
7
  uniforms: {
12
- lut3d: { value: null },
13
8
 
14
9
  lut: { value: null },
15
10
  lutSize: { value: 0 },
@@ -34,45 +29,7 @@ const LUTShader = {
34
29
  fragmentShader: /* glsl */`
35
30
 
36
31
  uniform float lutSize;
37
- #if USE_3DTEXTURE
38
- precision highp sampler3D;
39
- uniform sampler3D lut3d;
40
- #else
41
- uniform sampler2D lut;
42
-
43
- vec3 lutLookup( sampler2D tex, float size, vec3 rgb ) {
44
-
45
- float sliceHeight = 1.0 / size;
46
- float yPixelHeight = 1.0 / ( size * size );
47
-
48
- // Get the slices on either side of the sample
49
- float slice = rgb.b * size;
50
- float interp = fract( slice );
51
- float slice0 = slice - interp;
52
- float centeredInterp = interp - 0.5;
53
-
54
- float slice1 = slice0 + sign( centeredInterp );
55
-
56
- // Pull y sample in by half a pixel in each direction to avoid color
57
- // bleeding from adjacent slices.
58
- float greenOffset = clamp( rgb.g * sliceHeight, yPixelHeight * 0.5, sliceHeight - yPixelHeight * 0.5 );
59
-
60
- vec2 uv0 = vec2(
61
- rgb.r,
62
- slice0 * sliceHeight + greenOffset
63
- );
64
- vec2 uv1 = vec2(
65
- rgb.r,
66
- slice1 * sliceHeight + greenOffset
67
- );
68
-
69
- vec3 sample0 = texture2D( tex, uv0 ).rgb;
70
- vec3 sample1 = texture2D( tex, uv1 ).rgb;
71
-
72
- return mix( sample0, sample1, abs( centeredInterp ) );
73
-
74
- }
75
- #endif
32
+ uniform sampler3D lut;
76
33
 
77
34
  varying vec2 vUv;
78
35
  uniform float intensity;
@@ -88,15 +45,8 @@ const LUTShader = {
88
45
  float halfPixelWidth = 0.5 / lutSize;
89
46
  vec3 uvw = vec3( halfPixelWidth ) + val.rgb * ( 1.0 - pixelWidth );
90
47
 
91
- #if USE_3DTEXTURE
92
48
 
93
- lutVal = vec4( texture( lut3d, uvw ).rgb, val.a );
94
-
95
- #else
96
-
97
- lutVal = vec4( lutLookup( lut, lutSize, uvw ), val.a );
98
-
99
- #endif
49
+ lutVal = vec4( texture( lut, uvw ).rgb, val.a );
100
50
 
101
51
  gl_FragColor = vec4( mix( val, lutVal, intensity ) );
102
52
 
@@ -111,31 +61,15 @@ class LUTPass extends ShaderPass {
111
61
  set lut( v ) {
112
62
 
113
63
  const material = this.material;
64
+
114
65
  if ( v !== this.lut ) {
115
66
 
116
- material.uniforms.lut3d.value = null;
117
67
  material.uniforms.lut.value = null;
118
68
 
119
69
  if ( v ) {
120
70
 
121
- const is3dTextureDefine = v.isData3DTexture ? 1 : 0;
122
- if ( is3dTextureDefine !== material.defines.USE_3DTEXTURE ) {
123
-
124
- material.defines.USE_3DTEXTURE = is3dTextureDefine;
125
- material.needsUpdate = true;
126
-
127
- }
128
-
129
71
  material.uniforms.lutSize.value = v.image.width;
130
- if ( v.isData3DTexture ) {
131
-
132
- material.uniforms.lut3d.value = v;
133
-
134
- } else {
135
-
136
- material.uniforms.lut.value = v;
137
-
138
- }
72
+ material.uniforms.lut.value = v;
139
73
 
140
74
  }
141
75
 
@@ -145,7 +79,7 @@ class LUTPass extends ShaderPass {
145
79
 
146
80
  get lut() {
147
81
 
148
- return this.material.uniforms.lut.value || this.material.uniforms.lut3d.value;
82
+ return this.material.uniforms.lut.value;
149
83
 
150
84
  }
151
85
 
@@ -7,6 +7,7 @@ import {
7
7
  CineonToneMapping,
8
8
  AgXToneMapping,
9
9
  ACESFilmicToneMapping,
10
+ NeutralToneMapping,
10
11
  SRGBTransfer
11
12
  } from 'three';
12
13
  import { Pass, FullScreenQuad } from './Pass.js';
@@ -61,6 +62,7 @@ class OutputPass extends Pass {
61
62
  else if ( this._toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
62
63
  else if ( this._toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
63
64
  else if ( this._toneMapping === AgXToneMapping ) this.material.defines.AGX_TONE_MAPPING = '';
65
+ else if ( this._toneMapping === NeutralToneMapping ) this.material.defines.NEUTRAL_TONE_MAPPING = '';
64
66
 
65
67
  this.material.needsUpdate = true;
66
68
 
@@ -81,7 +81,6 @@ class SAOPass extends Pass {
81
81
  vertexShader: SAOShader.vertexShader,
82
82
  uniforms: UniformsUtils.clone( SAOShader.uniforms )
83
83
  } );
84
- this.saoMaterial.extensions.derivatives = true;
85
84
  this.saoMaterial.defines[ 'PERSPECTIVE_CAMERA' ] = this.camera.isPerspectiveCamera ? 1 : 0;
86
85
  this.saoMaterial.uniforms[ 'tDepth' ].value = depthTexture;
87
86
  this.saoMaterial.uniforms[ 'tNormal' ].value = this.normalRenderTarget.texture;
@@ -13,7 +13,6 @@ import {
13
13
  NearestFilter,
14
14
  NoBlending,
15
15
  RedFormat,
16
- LuminanceFormat,
17
16
  DepthStencilFormat,
18
17
  UnsignedInt248Type,
19
18
  RepeatWrapping,
@@ -177,8 +176,6 @@ class SSAOPass extends Pass {
177
176
 
178
177
  render( renderer, writeBuffer, readBuffer /*, deltaTime, maskActive */ ) {
179
178
 
180
- if ( renderer.capabilities.isWebGL2 === false ) this.noiseTexture.format = LuminanceFormat;
181
-
182
179
  // render normals and depth (honor only meshes, points and lines do not contribute to SSAO)
183
180
 
184
181
  this.overrideVisibility();
@@ -18,6 +18,8 @@ class Animation {
18
18
 
19
19
  this.requestId = self.requestAnimationFrame( update );
20
20
 
21
+ if ( this.info.autoReset === true ) this.info.reset();
22
+
21
23
  this.nodes.nodeFrame.update();
22
24
 
23
25
  this.info.frame = this.nodes.nodeFrame.frameId;
@@ -33,6 +35,7 @@ class Animation {
33
35
  dispose() {
34
36
 
35
37
  self.cancelAnimationFrame( this.requestId );
38
+ this.requestId = null;
36
39
 
37
40
  }
38
41