three-stdlib 2.8.9 → 2.8.12

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 (480) hide show
  1. package/Nodes-607e9ed8.js +471 -0
  2. package/Nodes-627a8bdf.js +1 -0
  3. package/index.cjs.js +1 -1
  4. package/index.d.ts +1 -127
  5. package/index.js +122 -128
  6. package/lines/LineMaterial.d.ts +7 -6
  7. package/loaders/NodeMaterialLoader.cjs.js +1 -1
  8. package/loaders/NodeMaterialLoader.js +2 -136
  9. package/modifiers/CurveModifier.cjs.js +1 -1
  10. package/modifiers/CurveModifier.d.ts +13 -9
  11. package/modifiers/CurveModifier.js +27 -30
  12. package/nodes/Nodes.cjs.js +1 -1
  13. package/nodes/Nodes.js +203 -76
  14. package/nodes/ShaderNode.cjs.js +1 -0
  15. package/nodes/ShaderNode.js +308 -0
  16. package/nodes/accessors/BufferNode.cjs.js +1 -0
  17. package/nodes/accessors/BufferNode.js +18 -0
  18. package/nodes/accessors/CameraNode.cjs.js +1 -1
  19. package/nodes/accessors/CameraNode.js +32 -138
  20. package/nodes/accessors/CubeTextureNode.cjs.js +1 -0
  21. package/nodes/accessors/CubeTextureNode.js +53 -0
  22. package/nodes/accessors/MaterialNode.cjs.js +1 -0
  23. package/nodes/accessors/MaterialNode.js +80 -0
  24. package/nodes/accessors/MaterialReferenceNode.cjs.js +1 -0
  25. package/nodes/accessors/MaterialReferenceNode.js +16 -0
  26. package/nodes/accessors/ModelNode.cjs.js +1 -0
  27. package/nodes/accessors/ModelNode.js +10 -0
  28. package/nodes/accessors/ModelViewProjectionNode.cjs.js +1 -0
  29. package/nodes/accessors/ModelViewProjectionNode.js +22 -0
  30. package/nodes/accessors/NormalNode.cjs.js +1 -1
  31. package/nodes/accessors/NormalNode.js +48 -78
  32. package/nodes/accessors/Object3DNode.cjs.js +1 -0
  33. package/nodes/accessors/Object3DNode.js +85 -0
  34. package/nodes/accessors/PointUVNode.cjs.js +1 -0
  35. package/nodes/accessors/PointUVNode.js +16 -0
  36. package/nodes/accessors/PositionNode.cjs.js +1 -1
  37. package/nodes/accessors/PositionNode.js +49 -87
  38. package/nodes/accessors/ReferenceNode.cjs.js +1 -0
  39. package/nodes/accessors/ReferenceNode.js +43 -0
  40. package/nodes/accessors/ReflectNode.cjs.js +1 -1
  41. package/nodes/accessors/ReflectNode.js +35 -98
  42. package/nodes/accessors/SkinningNode.cjs.js +1 -0
  43. package/nodes/accessors/SkinningNode.js +59 -0
  44. package/nodes/accessors/TextureNode.cjs.js +1 -0
  45. package/nodes/accessors/TextureNode.js +68 -0
  46. package/nodes/accessors/UVNode.cjs.js +1 -1
  47. package/nodes/accessors/UVNode.js +20 -38
  48. package/nodes/core/ArrayUniformNode.cjs.js +1 -0
  49. package/nodes/core/ArrayUniformNode.js +17 -0
  50. package/nodes/core/AttributeNode.cjs.js +1 -1
  51. package/nodes/core/AttributeNode.js +31 -40
  52. package/nodes/core/BypassNode.cjs.js +1 -0
  53. package/nodes/core/BypassNode.js +28 -0
  54. package/nodes/core/CodeNode.cjs.js +1 -0
  55. package/nodes/core/CodeNode.js +35 -0
  56. package/nodes/core/ConstNode.cjs.js +1 -1
  57. package/nodes/core/ConstNode.js +10 -78
  58. package/nodes/core/ContextNode.cjs.js +1 -0
  59. package/nodes/core/ContextNode.js +26 -0
  60. package/nodes/core/ExpressionNode.cjs.js +1 -1
  61. package/nodes/core/ExpressionNode.js +19 -8
  62. package/nodes/core/FunctionCallNode.cjs.js +1 -1
  63. package/nodes/core/FunctionCallNode.js +31 -60
  64. package/nodes/core/FunctionNode.cjs.js +1 -1
  65. package/nodes/core/FunctionNode.js +45 -166
  66. package/nodes/core/InputNode.cjs.js +1 -1
  67. package/nodes/core/InputNode.js +43 -57
  68. package/nodes/core/Node.cjs.js +1 -1
  69. package/nodes/core/Node.js +155 -113
  70. package/nodes/core/NodeAttribute.cjs.js +1 -0
  71. package/nodes/core/NodeAttribute.js +11 -0
  72. package/nodes/core/NodeBuilder.cjs.js +1 -1
  73. package/nodes/core/NodeBuilder.js +422 -548
  74. package/nodes/core/NodeCode.cjs.js +1 -0
  75. package/nodes/core/NodeCode.js +13 -0
  76. package/nodes/core/NodeFrame.cjs.js +1 -1
  77. package/nodes/core/NodeFrame.js +34 -27
  78. package/nodes/core/NodeFunction.cjs.js +1 -0
  79. package/nodes/core/NodeFunction.js +17 -0
  80. package/nodes/core/NodeFunctionInput.cjs.js +1 -0
  81. package/nodes/core/NodeFunctionInput.js +14 -0
  82. package/nodes/core/NodeKeywords.cjs.js +1 -0
  83. package/nodes/core/NodeKeywords.js +54 -0
  84. package/nodes/core/NodeParser.cjs.js +1 -0
  85. package/nodes/core/NodeParser.js +8 -0
  86. package/nodes/core/NodeUniform.cjs.js +1 -1
  87. package/nodes/core/NodeUniform.js +18 -17
  88. package/nodes/core/NodeUtils.cjs.js +1 -1
  89. package/nodes/core/NodeUtils.js +55 -35
  90. package/nodes/core/NodeVar.cjs.js +1 -0
  91. package/nodes/core/NodeVar.js +11 -0
  92. package/nodes/core/NodeVary.cjs.js +1 -0
  93. package/nodes/core/NodeVary.js +11 -0
  94. package/nodes/core/PropertyNode.cjs.js +1 -0
  95. package/nodes/core/PropertyNode.js +26 -0
  96. package/nodes/core/TempNode.cjs.js +1 -1
  97. package/nodes/core/TempNode.js +21 -88
  98. package/nodes/core/UniformNode.cjs.js +1 -0
  99. package/nodes/core/UniformNode.js +28 -0
  100. package/nodes/core/VarNode.cjs.js +1 -1
  101. package/nodes/core/VarNode.js +28 -35
  102. package/nodes/core/VaryNode.cjs.js +1 -0
  103. package/nodes/core/VaryNode.js +38 -0
  104. package/nodes/core/constants.cjs.js +1 -0
  105. package/nodes/core/constants.js +11 -0
  106. package/nodes/display/ColorSpaceNode.cjs.js +1 -0
  107. package/nodes/display/ColorSpaceNode.js +67 -0
  108. package/nodes/display/NormalMapNode.cjs.js +1 -0
  109. package/nodes/display/NormalMapNode.js +71 -0
  110. package/nodes/fog/FogNode.cjs.js +1 -0
  111. package/nodes/fog/FogNode.js +18 -0
  112. package/nodes/fog/FogRangeNode.cjs.js +1 -0
  113. package/nodes/fog/FogRangeNode.js +20 -0
  114. package/nodes/functions/BSDFs.cjs.js +1 -0
  115. package/nodes/functions/BSDFs.js +121 -0
  116. package/nodes/functions/PhysicalMaterialFunctions.cjs.js +1 -0
  117. package/nodes/functions/PhysicalMaterialFunctions.js +57 -0
  118. package/nodes/lights/LightContextNode.cjs.js +1 -0
  119. package/nodes/lights/LightContextNode.js +43 -0
  120. package/nodes/lights/LightNode.cjs.js +1 -0
  121. package/nodes/lights/LightNode.js +61 -0
  122. package/nodes/lights/LightsNode.cjs.js +1 -0
  123. package/nodes/lights/LightsNode.js +77 -0
  124. package/nodes/loaders/NodeLoader.cjs.js +1 -0
  125. package/nodes/loaders/NodeLoader.js +80 -0
  126. package/nodes/loaders/NodeMaterialLoader.cjs.js +1 -0
  127. package/nodes/loaders/NodeMaterialLoader.js +29 -0
  128. package/nodes/loaders/NodeObjectLoader.cjs.js +1 -0
  129. package/nodes/loaders/NodeObjectLoader.js +49 -0
  130. package/nodes/materials/LineBasicNodeMaterial.cjs.js +1 -0
  131. package/nodes/materials/LineBasicNodeMaterial.js +31 -0
  132. package/nodes/materials/Materials.cjs.js +1 -0
  133. package/nodes/materials/Materials.js +27 -0
  134. package/nodes/materials/MeshBasicNodeMaterial.cjs.js +1 -0
  135. package/nodes/materials/MeshBasicNodeMaterial.js +32 -0
  136. package/nodes/materials/MeshStandardNodeMaterial.cjs.js +1 -1
  137. package/nodes/materials/MeshStandardNodeMaterial.js +41 -13
  138. package/nodes/materials/NodeMaterial.cjs.js +1 -1
  139. package/nodes/materials/NodeMaterial.js +67 -140
  140. package/nodes/materials/PointsNodeMaterial.cjs.js +1 -0
  141. package/nodes/materials/PointsNodeMaterial.js +34 -0
  142. package/nodes/math/CondNode.cjs.js +1 -1
  143. package/nodes/math/CondNode.js +33 -74
  144. package/nodes/math/MathNode.cjs.js +1 -1
  145. package/nodes/math/MathNode.js +193 -193
  146. package/nodes/math/OperatorNode.cjs.js +1 -1
  147. package/nodes/math/OperatorNode.js +116 -52
  148. package/nodes/parsers/GLSLNodeFunction.cjs.js +1 -0
  149. package/nodes/parsers/GLSLNodeFunction.js +101 -0
  150. package/nodes/parsers/GLSLNodeParser.cjs.js +1 -0
  151. package/nodes/parsers/GLSLNodeParser.js +13 -0
  152. package/nodes/parsers/WGSLNodeFunction.cjs.js +1 -0
  153. package/nodes/parsers/WGSLNodeFunction.js +71 -0
  154. package/nodes/parsers/WGSLNodeParser.cjs.js +1 -0
  155. package/nodes/parsers/WGSLNodeParser.js +13 -0
  156. package/nodes/procedural/CheckerNode.cjs.js +1 -1
  157. package/nodes/procedural/CheckerNode.js +22 -40
  158. package/nodes/utils/ArrayElementNode.cjs.js +1 -0
  159. package/nodes/utils/ArrayElementNode.js +22 -0
  160. package/nodes/utils/ConvertNode.cjs.js +1 -0
  161. package/nodes/utils/ConvertNode.js +29 -0
  162. package/nodes/utils/JoinNode.cjs.js +1 -1
  163. package/nodes/utils/JoinNode.js +19 -69
  164. package/nodes/utils/MatcapUVNode.cjs.js +1 -0
  165. package/nodes/utils/MatcapUVNode.js +18 -0
  166. package/nodes/utils/OscNode.cjs.js +1 -0
  167. package/nodes/utils/OscNode.js +55 -0
  168. package/nodes/utils/SplitNode.cjs.js +1 -0
  169. package/nodes/utils/SplitNode.js +58 -0
  170. package/nodes/utils/SpriteSheetUVNode.cjs.js +1 -0
  171. package/nodes/utils/SpriteSheetUVNode.js +39 -0
  172. package/nodes/utils/TimerNode.cjs.js +1 -1
  173. package/nodes/utils/TimerNode.js +38 -56
  174. package/objects/Lensflare.cjs.js +1 -1
  175. package/objects/Lensflare.js +11 -3
  176. package/package.json +3 -3
  177. package/postprocessing/AfterimagePass.d.ts +2 -30
  178. package/shaders/ACESFilmicToneMappingShader.cjs.js +1 -1
  179. package/shaders/ACESFilmicToneMappingShader.d.ts +9 -0
  180. package/shaders/ACESFilmicToneMappingShader.js +1 -1
  181. package/shaders/AfterimageShader.d.ts +9 -15
  182. package/shaders/BasicShader.cjs.js +1 -1
  183. package/shaders/BasicShader.d.ts +5 -5
  184. package/shaders/BasicShader.js +1 -1
  185. package/shaders/BleachBypassShader.cjs.js +1 -1
  186. package/shaders/BleachBypassShader.d.ts +8 -9
  187. package/shaders/BleachBypassShader.js +1 -1
  188. package/shaders/BlendShader.cjs.js +1 -1
  189. package/shaders/BlendShader.d.ts +13 -7
  190. package/shaders/BlendShader.js +1 -1
  191. package/shaders/BokehShader.cjs.js +1 -1
  192. package/shaders/BokehShader.d.ts +18 -19
  193. package/shaders/BokehShader.js +1 -1
  194. package/shaders/BokehShader2.cjs.js +1 -1
  195. package/shaders/BokehShader2.d.ts +80 -34
  196. package/shaders/BokehShader2.js +2 -2
  197. package/shaders/BrightnessContrastShader.cjs.js +1 -1
  198. package/shaders/BrightnessContrastShader.d.ts +10 -6
  199. package/shaders/BrightnessContrastShader.js +1 -1
  200. package/shaders/ColorCorrectionShader.cjs.js +1 -1
  201. package/shaders/ColorCorrectionShader.d.ts +14 -7
  202. package/shaders/ColorCorrectionShader.js +1 -1
  203. package/shaders/ColorifyShader.cjs.js +1 -1
  204. package/shaders/ColorifyShader.d.ts +8 -5
  205. package/shaders/ColorifyShader.js +1 -1
  206. package/shaders/ConvolutionShader.cjs.js +1 -1
  207. package/shaders/ConvolutionShader.d.ts +15 -16
  208. package/shaders/ConvolutionShader.js +9 -14
  209. package/shaders/CopyShader.d.ts +8 -12
  210. package/shaders/DOFMipMapShader.cjs.js +1 -1
  211. package/shaders/DOFMipMapShader.d.ts +13 -7
  212. package/shaders/DOFMipMapShader.js +1 -1
  213. package/shaders/DepthLimitedBlurShader.cjs.js +1 -1
  214. package/shaders/DepthLimitedBlurShader.d.ts +26 -25
  215. package/shaders/DepthLimitedBlurShader.js +12 -16
  216. package/shaders/DigitalGlitch.cjs.js +1 -1
  217. package/shaders/DigitalGlitch.d.ts +34 -14
  218. package/shaders/DigitalGlitch.js +1 -10
  219. package/shaders/DotScreenShader.cjs.js +1 -1
  220. package/shaders/DotScreenShader.d.ts +17 -8
  221. package/shaders/DotScreenShader.js +1 -1
  222. package/shaders/FXAAShader.cjs.js +1 -1
  223. package/shaders/FXAAShader.d.ts +8 -5
  224. package/shaders/FXAAShader.js +1 -1
  225. package/shaders/FilmShader.cjs.js +1 -1
  226. package/shaders/FilmShader.d.ts +19 -9
  227. package/shaders/FilmShader.js +1 -1
  228. package/shaders/FocusShader.cjs.js +1 -1
  229. package/shaders/FocusShader.d.ts +16 -8
  230. package/shaders/FocusShader.js +1 -1
  231. package/shaders/FreiChenShader.cjs.js +1 -1
  232. package/shaders/FreiChenShader.d.ts +8 -5
  233. package/shaders/FreiChenShader.js +1 -1
  234. package/shaders/FresnelShader.cjs.js +1 -1
  235. package/shaders/FresnelShader.d.ts +21 -0
  236. package/shaders/FresnelShader.js +1 -1
  237. package/shaders/GammaCorrectionShader.d.ts +7 -7
  238. package/shaders/GodRaysShader.cjs.js +1 -1
  239. package/shaders/GodRaysShader.d.ts +38 -20
  240. package/shaders/GodRaysShader.js +4 -4
  241. package/shaders/HalftoneShader.cjs.js +1 -1
  242. package/shaders/HalftoneShader.d.ts +40 -16
  243. package/shaders/HalftoneShader.js +1 -1
  244. package/shaders/HorizontalBlurShader.d.ts +8 -8
  245. package/shaders/HorizontalTiltShiftShader.cjs.js +1 -1
  246. package/shaders/HorizontalTiltShiftShader.d.ts +10 -6
  247. package/shaders/HorizontalTiltShiftShader.js +1 -1
  248. package/shaders/HueSaturationShader.cjs.js +1 -1
  249. package/shaders/HueSaturationShader.d.ts +10 -6
  250. package/shaders/HueSaturationShader.js +1 -1
  251. package/shaders/KaleidoShader.cjs.js +1 -1
  252. package/shaders/KaleidoShader.d.ts +10 -6
  253. package/shaders/KaleidoShader.js +1 -1
  254. package/shaders/LuminosityHighPassShader.cjs.js +1 -1
  255. package/shaders/LuminosityHighPassShader.d.ts +17 -8
  256. package/shaders/LuminosityHighPassShader.js +1 -1
  257. package/shaders/LuminosityShader.cjs.js +1 -1
  258. package/shaders/LuminosityShader.d.ts +4 -4
  259. package/shaders/LuminosityShader.js +1 -1
  260. package/shaders/MirrorShader.cjs.js +1 -1
  261. package/shaders/MirrorShader.d.ts +7 -5
  262. package/shaders/MirrorShader.js +1 -1
  263. package/shaders/NormalMapShader.cjs.js +1 -1
  264. package/shaders/NormalMapShader.d.ts +14 -7
  265. package/shaders/NormalMapShader.js +1 -1
  266. package/shaders/ParallaxShader.cjs.js +1 -1
  267. package/shaders/ParallaxShader.d.ts +28 -0
  268. package/shaders/ParallaxShader.js +1 -1
  269. package/shaders/PixelShader.cjs.js +1 -1
  270. package/shaders/PixelShader.d.ts +10 -6
  271. package/shaders/PixelShader.js +1 -1
  272. package/shaders/RGBShiftShader.cjs.js +1 -1
  273. package/shaders/RGBShiftShader.d.ts +10 -6
  274. package/shaders/RGBShiftShader.js +1 -1
  275. package/shaders/SAOShader.cjs.js +1 -1
  276. package/shaders/SAOShader.d.ts +24 -29
  277. package/shaders/SAOShader.js +1 -5
  278. package/shaders/SMAAShader.cjs.js +1 -1
  279. package/shaders/SMAAShader.d.ts +31 -16
  280. package/shaders/SMAAShader.js +3 -3
  281. package/shaders/SSAOShader.cjs.js +1 -1
  282. package/shaders/SSAOShader.d.ts +58 -25
  283. package/shaders/SSAOShader.js +3 -3
  284. package/shaders/SSRShader.cjs.js +1 -1
  285. package/shaders/SSRShader.d.ts +67 -36
  286. package/shaders/SSRShader.js +3 -3
  287. package/shaders/SepiaShader.cjs.js +1 -1
  288. package/shaders/SepiaShader.d.ts +7 -5
  289. package/shaders/SepiaShader.js +1 -1
  290. package/shaders/SobelOperatorShader.cjs.js +1 -1
  291. package/shaders/SobelOperatorShader.d.ts +8 -5
  292. package/shaders/SobelOperatorShader.js +1 -1
  293. package/shaders/SubsurfaceScatteringShader.cjs.js +1 -1
  294. package/shaders/SubsurfaceScatteringShader.d.ts +2 -34
  295. package/shaders/SubsurfaceScatteringShader.js +3 -3
  296. package/shaders/TechnicolorShader.cjs.js +1 -1
  297. package/shaders/TechnicolorShader.d.ts +4 -4
  298. package/shaders/TechnicolorShader.js +1 -1
  299. package/shaders/ToneMapShader.cjs.js +1 -1
  300. package/shaders/ToneMapShader.d.ts +19 -9
  301. package/shaders/ToneMapShader.js +1 -1
  302. package/shaders/ToonShader.cjs.js +1 -1
  303. package/shaders/ToonShader.d.ts +80 -34
  304. package/shaders/ToonShader.js +4 -4
  305. package/shaders/TriangleBlurShader.cjs.js +1 -1
  306. package/shaders/TriangleBlurShader.d.ts +8 -5
  307. package/shaders/TriangleBlurShader.js +1 -1
  308. package/shaders/UnpackDepthRGBAShader.cjs.js +1 -1
  309. package/shaders/UnpackDepthRGBAShader.d.ts +7 -5
  310. package/shaders/UnpackDepthRGBAShader.js +1 -1
  311. package/shaders/VerticalBlurShader.cjs.js +1 -1
  312. package/shaders/VerticalBlurShader.d.ts +8 -8
  313. package/shaders/VerticalBlurShader.js +1 -1
  314. package/shaders/VerticalTiltShiftShader.cjs.js +1 -1
  315. package/shaders/VerticalTiltShiftShader.d.ts +10 -6
  316. package/shaders/VerticalTiltShiftShader.js +1 -1
  317. package/shaders/VignetteShader.cjs.js +1 -1
  318. package/shaders/VignetteShader.d.ts +10 -6
  319. package/shaders/VignetteShader.js +1 -1
  320. package/shaders/VolumeShader.cjs.js +1 -1
  321. package/shaders/VolumeShader.d.ts +20 -9
  322. package/shaders/VolumeShader.js +1 -1
  323. package/shaders/WaterRefractionShader.cjs.js +1 -1
  324. package/shaders/WaterRefractionShader.d.ts +16 -8
  325. package/shaders/WaterRefractionShader.js +1 -1
  326. package/shaders/index.cjs.js +1 -0
  327. package/shaders/index.d.ts +53 -0
  328. package/shaders/index.js +53 -0
  329. package/shaders/types.cjs.js +1 -0
  330. package/shaders/types.d.ts +14 -0
  331. package/shaders/types.js +1 -0
  332. package/types/shared.d.ts +0 -20
  333. package/Nodes-894ac9dc.js +0 -1
  334. package/Nodes-af575af7.js +0 -157
  335. package/nodes/accessors/ColorsNode.cjs.js +0 -1
  336. package/nodes/accessors/ColorsNode.d.ts +0 -10
  337. package/nodes/accessors/ColorsNode.js +0 -40
  338. package/nodes/accessors/LightNode.cjs.js +0 -1
  339. package/nodes/accessors/LightNode.d.ts +0 -12
  340. package/nodes/accessors/LightNode.js +0 -41
  341. package/nodes/accessors/ResolutionNode.cjs.js +0 -1
  342. package/nodes/accessors/ResolutionNode.d.ts +0 -14
  343. package/nodes/accessors/ResolutionNode.js +0 -41
  344. package/nodes/accessors/ScreenUVNode.cjs.js +0 -1
  345. package/nodes/accessors/ScreenUVNode.d.ts +0 -11
  346. package/nodes/accessors/ScreenUVNode.js +0 -43
  347. package/nodes/core/NodeLib.cjs.js +0 -1
  348. package/nodes/core/NodeLib.d.ts +0 -22
  349. package/nodes/core/NodeLib.js +0 -37
  350. package/nodes/core/StructNode.cjs.js +0 -1
  351. package/nodes/core/StructNode.d.ts +0 -19
  352. package/nodes/core/StructNode.js +0 -72
  353. package/nodes/effects/BlurNode.cjs.js +0 -1
  354. package/nodes/effects/BlurNode.d.ts +0 -31
  355. package/nodes/effects/BlurNode.js +0 -100
  356. package/nodes/effects/ColorAdjustmentNode.cjs.js +0 -1
  357. package/nodes/effects/ColorAdjustmentNode.d.ts +0 -27
  358. package/nodes/effects/ColorAdjustmentNode.js +0 -73
  359. package/nodes/effects/LuminanceNode.cjs.js +0 -1
  360. package/nodes/effects/LuminanceNode.d.ts +0 -18
  361. package/nodes/effects/LuminanceNode.js +0 -46
  362. package/nodes/inputs/BoolNode.cjs.js +0 -1
  363. package/nodes/inputs/BoolNode.d.ts +0 -19
  364. package/nodes/inputs/BoolNode.js +0 -36
  365. package/nodes/inputs/ColorNode.cjs.js +0 -1
  366. package/nodes/inputs/ColorNode.d.ts +0 -21
  367. package/nodes/inputs/ColorNode.js +0 -41
  368. package/nodes/inputs/CubeTextureNode.cjs.js +0 -1
  369. package/nodes/inputs/CubeTextureNode.d.ts +0 -17
  370. package/nodes/inputs/CubeTextureNode.js +0 -79
  371. package/nodes/inputs/FloatNode.cjs.js +0 -1
  372. package/nodes/inputs/FloatNode.d.ts +0 -19
  373. package/nodes/inputs/FloatNode.js +0 -36
  374. package/nodes/inputs/IntNode.cjs.js +0 -1
  375. package/nodes/inputs/IntNode.d.ts +0 -19
  376. package/nodes/inputs/IntNode.js +0 -36
  377. package/nodes/inputs/Matrix3Node.cjs.js +0 -1
  378. package/nodes/inputs/Matrix3Node.d.ts +0 -22
  379. package/nodes/inputs/Matrix3Node.js +0 -46
  380. package/nodes/inputs/Matrix4Node.cjs.js +0 -1
  381. package/nodes/inputs/Matrix4Node.d.ts +0 -22
  382. package/nodes/inputs/Matrix4Node.js +0 -46
  383. package/nodes/inputs/PropertyNode.cjs.js +0 -1
  384. package/nodes/inputs/PropertyNode.d.ts +0 -10
  385. package/nodes/inputs/PropertyNode.js +0 -35
  386. package/nodes/inputs/RTTNode.cjs.js +0 -1
  387. package/nodes/inputs/RTTNode.d.ts +0 -27
  388. package/nodes/inputs/RTTNode.js +0 -103
  389. package/nodes/inputs/ReflectorNode.cjs.js +0 -1
  390. package/nodes/inputs/ReflectorNode.d.ts +0 -21
  391. package/nodes/inputs/ReflectorNode.js +0 -60
  392. package/nodes/inputs/ScreenNode.cjs.js +0 -1
  393. package/nodes/inputs/ScreenNode.d.ts +0 -11
  394. package/nodes/inputs/ScreenNode.js +0 -20
  395. package/nodes/inputs/TextureNode.cjs.js +0 -1
  396. package/nodes/inputs/TextureNode.d.ts +0 -20
  397. package/nodes/inputs/TextureNode.js +0 -83
  398. package/nodes/inputs/Vector2Node.cjs.js +0 -1
  399. package/nodes/inputs/Vector2Node.d.ts +0 -21
  400. package/nodes/inputs/Vector2Node.js +0 -40
  401. package/nodes/inputs/Vector3Node.cjs.js +0 -1
  402. package/nodes/inputs/Vector3Node.d.ts +0 -21
  403. package/nodes/inputs/Vector3Node.js +0 -41
  404. package/nodes/inputs/Vector4Node.cjs.js +0 -1
  405. package/nodes/inputs/Vector4Node.d.ts +0 -21
  406. package/nodes/inputs/Vector4Node.js +0 -42
  407. package/nodes/materials/BasicNodeMaterial.cjs.js +0 -1
  408. package/nodes/materials/BasicNodeMaterial.d.ts +0 -11
  409. package/nodes/materials/BasicNodeMaterial.js +0 -15
  410. package/nodes/materials/PhongNodeMaterial.cjs.js +0 -1
  411. package/nodes/materials/PhongNodeMaterial.d.ts +0 -21
  412. package/nodes/materials/PhongNodeMaterial.js +0 -15
  413. package/nodes/materials/SpriteNodeMaterial.cjs.js +0 -1
  414. package/nodes/materials/SpriteNodeMaterial.d.ts +0 -12
  415. package/nodes/materials/SpriteNodeMaterial.js +0 -15
  416. package/nodes/materials/StandardNodeMaterial.cjs.js +0 -1
  417. package/nodes/materials/StandardNodeMaterial.d.ts +0 -25
  418. package/nodes/materials/StandardNodeMaterial.js +0 -15
  419. package/nodes/materials/nodes/BasicNode.cjs.js +0 -1
  420. package/nodes/materials/nodes/BasicNode.d.ts +0 -15
  421. package/nodes/materials/nodes/BasicNode.js +0 -91
  422. package/nodes/materials/nodes/MeshStandardNode.cjs.js +0 -1
  423. package/nodes/materials/nodes/MeshStandardNode.d.ts +0 -25
  424. package/nodes/materials/nodes/MeshStandardNode.js +0 -81
  425. package/nodes/materials/nodes/PhongNode.cjs.js +0 -1
  426. package/nodes/materials/nodes/PhongNode.d.ts +0 -14
  427. package/nodes/materials/nodes/PhongNode.js +0 -212
  428. package/nodes/materials/nodes/RawNode.cjs.js +0 -1
  429. package/nodes/materials/nodes/RawNode.d.ts +0 -10
  430. package/nodes/materials/nodes/RawNode.js +0 -42
  431. package/nodes/materials/nodes/SpriteNode.cjs.js +0 -1
  432. package/nodes/materials/nodes/SpriteNode.d.ts +0 -13
  433. package/nodes/materials/nodes/SpriteNode.js +0 -113
  434. package/nodes/materials/nodes/StandardNode.cjs.js +0 -1
  435. package/nodes/materials/nodes/StandardNode.d.ts +0 -15
  436. package/nodes/materials/nodes/StandardNode.js +0 -336
  437. package/nodes/misc/BumpMapNode.cjs.js +0 -1
  438. package/nodes/misc/BumpMapNode.d.ts +0 -21
  439. package/nodes/misc/BumpMapNode.js +0 -80
  440. package/nodes/misc/NormalMapNode.cjs.js +0 -1
  441. package/nodes/misc/NormalMapNode.d.ts +0 -19
  442. package/nodes/misc/NormalMapNode.js +0 -102
  443. package/nodes/misc/TextureCubeNode.cjs.js +0 -1
  444. package/nodes/misc/TextureCubeNode.d.ts +0 -21
  445. package/nodes/misc/TextureCubeNode.js +0 -52
  446. package/nodes/misc/TextureCubeUVNode.cjs.js +0 -1
  447. package/nodes/misc/TextureCubeUVNode.d.ts +0 -18
  448. package/nodes/misc/TextureCubeUVNode.js +0 -229
  449. package/nodes/postprocessing/NodePass.cjs.js +0 -1
  450. package/nodes/postprocessing/NodePass.d.ts +0 -15
  451. package/nodes/postprocessing/NodePass.js +0 -61
  452. package/nodes/postprocessing/NodePostProcessing.cjs.js +0 -1
  453. package/nodes/postprocessing/NodePostProcessing.d.ts +0 -26
  454. package/nodes/postprocessing/NodePostProcessing.js +0 -91
  455. package/nodes/procedural/NoiseNode.cjs.js +0 -1
  456. package/nodes/procedural/NoiseNode.d.ts +0 -17
  457. package/nodes/procedural/NoiseNode.js +0 -43
  458. package/nodes/utils/BypassNode.cjs.js +0 -1
  459. package/nodes/utils/BypassNode.d.ts +0 -11
  460. package/nodes/utils/BypassNode.js +0 -55
  461. package/nodes/utils/ColorSpaceNode.cjs.js +0 -1
  462. package/nodes/utils/ColorSpaceNode.d.ts +0 -55
  463. package/nodes/utils/ColorSpaceNode.js +0 -106
  464. package/nodes/utils/MaxMIPLevelNode.cjs.js +0 -1
  465. package/nodes/utils/MaxMIPLevelNode.d.ts +0 -11
  466. package/nodes/utils/MaxMIPLevelNode.js +0 -38
  467. package/nodes/utils/SpecularMIPLevelNode.cjs.js +0 -1
  468. package/nodes/utils/SpecularMIPLevelNode.d.ts +0 -17
  469. package/nodes/utils/SpecularMIPLevelNode.js +0 -61
  470. package/nodes/utils/SubSlotNode.cjs.js +0 -1
  471. package/nodes/utils/SubSlotNode.js +0 -53
  472. package/nodes/utils/SwitchNode.cjs.js +0 -1
  473. package/nodes/utils/SwitchNode.d.ts +0 -11
  474. package/nodes/utils/SwitchNode.js +0 -69
  475. package/nodes/utils/UVTransformNode.cjs.js +0 -1
  476. package/nodes/utils/UVTransformNode.d.ts +0 -15
  477. package/nodes/utils/UVTransformNode.js +0 -46
  478. package/nodes/utils/VelocityNode.cjs.js +0 -1
  479. package/nodes/utils/VelocityNode.d.ts +0 -28
  480. package/nodes/utils/VelocityNode.js +0 -115
@@ -0,0 +1,39 @@
1
+ import Node from '../core/Node.js';
2
+ import ConstNode from '../core/ConstNode.js';
3
+ import UVNode from '../accessors/UVNode.js';
4
+ import MathNode from '../math/MathNode.js';
5
+ import OperatorNode from '../math/OperatorNode.js';
6
+ import SplitNode from './SplitNode.js';
7
+ import JoinNode from './JoinNode.js';
8
+
9
+ class SpriteSheetUVNode extends Node {
10
+ constructor(countNode, uvNode = new UVNode(), frameNode = new ConstNode(0)) {
11
+ super('vec2');
12
+ this.countNode = countNode;
13
+ this.uvNode = uvNode;
14
+ this.frameNode = frameNode;
15
+ }
16
+
17
+ generate(builder) {
18
+ const count = this.countNode;
19
+ const uv = this.uvNode;
20
+ const frame = this.frameNode;
21
+ const one = new ConstNode(1);
22
+ const width = new SplitNode(count, 'x');
23
+ const height = new SplitNode(count, 'y');
24
+ const total = new OperatorNode('*', width, height);
25
+ const roundFrame = new MathNode(MathNode.FLOOR, new MathNode(MathNode.MOD, frame, total));
26
+ const frameNum = new OperatorNode('+', roundFrame, one);
27
+ const cell = new MathNode(MathNode.MOD, roundFrame, width);
28
+ const row = new MathNode(MathNode.CEIL, new OperatorNode('/', frameNum, width));
29
+ const rowInv = new OperatorNode('-', height, row);
30
+ const scale = new OperatorNode('/', one, count);
31
+ const uvFrameOffset = new JoinNode([new OperatorNode('*', cell, new SplitNode(scale, 'x')), new OperatorNode('*', rowInv, new SplitNode(scale, 'y'))]);
32
+ const uvScale = new OperatorNode('*', uv, scale);
33
+ const uvFrame = new OperatorNode('+', uvScale, uvFrameOffset);
34
+ return uvFrame.build(builder, this.getNodeType(builder));
35
+ }
36
+
37
+ }
38
+
39
+ export default SpriteSheetUVNode;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../inputs/FloatNode.cjs.js"),t=require("../core/NodeLib.cjs.js");function o(t,i,s){e.FloatNode.call(this),this.scale=void 0!==t?t:1,this.scope=i||o.GLOBAL,this.timeScale=void 0!==s?s:void 0!==t}require("../core/InputNode.cjs.js"),require("../core/TempNode.cjs.js"),require("three"),require("../core/Node.cjs.js"),o.GLOBAL="global",o.LOCAL="local",o.DELTA="delta",o.prototype=Object.create(e.FloatNode.prototype),o.prototype.constructor=o,o.prototype.nodeType="Timer",o.prototype.getReadonly=function(){return!1},o.prototype.getUnique=function(){return this.timeScale&&(this.scope===o.GLOBAL||this.scope===o.DELTA)},o.prototype.updateFrame=function(e){var t=this.timeScale?this.scale:1;switch(this.scope){case o.LOCAL:this.value+=e.delta*t;break;case o.DELTA:this.value=e.delta*t;break;default:this.value=e.time*t}},o.prototype.copy=function(t){return e.FloatNode.prototype.copy.call(this,t),this.scope=t.scope,this.scale=t.scale,this.timeScale=t.timeScale,this},o.prototype.toJSON=function(t){var o=e.FloatNode.prototype.toJSON.call(this,t);return o.scope=this.scope,o.scale=this.scale,o.timeScale=this.timeScale,o},t.NodeLib.addKeyword("time",(function(){return new o})),exports.TimerNode=o;
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),s=require("../core/UniformNode.cjs.js"),r=require("../core/constants.cjs.js");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../core/InputNode.cjs.js"),require("../core/Node.cjs.js"),require("../core/NodeUtils.cjs.js"),require("three");var i=t(e);class a extends s{constructor(e=a.LOCAL){super(0),this.scope=e,this.scale=1,this.updateType=r.NodeUpdateType.Frame}update(e){const s=this.scope,r=this.scale;s===a.LOCAL?this.value+=e.deltaTime*r:this.value=s===a.DELTA?e.deltaTime*r:e.time*r}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}i.default(a,"LOCAL","local"),i.default(a,"GLOBAL","global"),i.default(a,"DELTA","delta"),module.exports=a;
@@ -1,65 +1,47 @@
1
- import { FloatNode } from '../inputs/FloatNode.js';
2
- import { NodeLib } from '../core/NodeLib.js';
3
-
4
- function TimerNode(scale, scope, timeScale) {
5
- FloatNode.call(this);
6
- this.scale = scale !== undefined ? scale : 1;
7
- this.scope = scope || TimerNode.GLOBAL;
8
- this.timeScale = timeScale !== undefined ? timeScale : scale !== undefined;
9
- }
10
-
11
- TimerNode.GLOBAL = 'global';
12
- TimerNode.LOCAL = 'local';
13
- TimerNode.DELTA = 'delta';
14
- TimerNode.prototype = Object.create(FloatNode.prototype);
15
- TimerNode.prototype.constructor = TimerNode;
16
- TimerNode.prototype.nodeType = 'Timer';
17
-
18
- TimerNode.prototype.getReadonly = function () {
19
- // never use TimerNode as readonly but aways as "uniform"
20
- return false;
21
- };
22
-
23
- TimerNode.prototype.getUnique = function () {
24
- // share TimerNode "uniform" input if is used on more time with others TimerNode
25
- return this.timeScale && (this.scope === TimerNode.GLOBAL || this.scope === TimerNode.DELTA);
26
- };
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
+ import UniformNode from '../core/UniformNode.js';
3
+ import { NodeUpdateType } from '../core/constants.js';
4
+
5
+ class TimerNode extends UniformNode {
6
+ constructor(scope = TimerNode.LOCAL) {
7
+ super(0);
8
+ this.scope = scope;
9
+ this.scale = 1;
10
+ this.updateType = NodeUpdateType.Frame;
11
+ }
27
12
 
28
- TimerNode.prototype.updateFrame = function (frame) {
29
- var scale = this.timeScale ? this.scale : 1;
13
+ update(frame) {
14
+ const scope = this.scope;
15
+ const scale = this.scale;
30
16
 
31
- switch (this.scope) {
32
- case TimerNode.LOCAL:
33
- this.value += frame.delta * scale;
34
- break;
17
+ if (scope === TimerNode.LOCAL) {
18
+ this.value += frame.deltaTime * scale;
19
+ } else if (scope === TimerNode.DELTA) {
20
+ this.value = frame.deltaTime * scale;
21
+ } else {
22
+ // global
23
+ this.value = frame.time * scale;
24
+ }
25
+ }
35
26
 
36
- case TimerNode.DELTA:
37
- this.value = frame.delta * scale;
38
- break;
27
+ serialize(data) {
28
+ super.serialize(data);
29
+ data.scope = this.scope;
30
+ data.scale = this.scale;
31
+ }
39
32
 
40
- default:
41
- this.value = frame.time * scale;
33
+ deserialize(data) {
34
+ super.deserialize(data);
35
+ this.scope = data.scope;
36
+ this.scale = data.scale;
42
37
  }
43
- };
44
38
 
45
- TimerNode.prototype.copy = function (source) {
46
- FloatNode.prototype.copy.call(this, source);
47
- this.scope = source.scope;
48
- this.scale = source.scale;
49
- this.timeScale = source.timeScale;
50
- return this;
51
- };
39
+ }
40
+
41
+ _defineProperty(TimerNode, "LOCAL", 'local');
52
42
 
53
- TimerNode.prototype.toJSON = function (meta) {
54
- var data = FloatNode.prototype.toJSON.call(this, meta);
55
- data.scope = this.scope;
56
- data.scale = this.scale;
57
- data.timeScale = this.timeScale;
58
- return data;
59
- };
43
+ _defineProperty(TimerNode, "GLOBAL", 'global');
60
44
 
61
- NodeLib.addKeyword('time', function () {
62
- return new TimerNode();
63
- });
45
+ _defineProperty(TimerNode, "DELTA", 'delta');
64
46
 
65
- export { TimerNode };
47
+ export default TimerNode;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Mesh{constructor(){super(e.Geometry,new t.MeshBasicMaterial({opacity:0,transparent:!0})),this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const i=new t.Vector3,r=new t.Vector3,o=new t.FramebufferTexture(16,16,t.RGBAFormat),s=new t.FramebufferTexture(16,16,t.RGBAFormat),a=e.Geometry,l=new t.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tuniform vec3 screenPosition;\n\t\t\t\tuniform vec2 scale;\n\n\t\t\t\tattribute vec3 position;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = vec4( 1.0, 0.0, 1.0, 1.0 );\n\n\t\t\t\t}",depthTest:!0,depthWrite:!1,transparent:!1}),c=new t.RawShaderMaterial({uniforms:{map:{value:o},scale:{value:null},screenPosition:{value:null}},vertexShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tuniform vec3 screenPosition;\n\t\t\t\tuniform vec2 scale;\n\n\t\t\t\tattribute vec3 position;\n\t\t\t\tattribute vec2 uv;\n\n\t\t\t\tvarying vec2 vUV;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUV = uv;\n\n\t\t\t\t\tgl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tuniform sampler2D map;\n\n\t\t\t\tvarying vec2 vUV;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texture2D( map, vUV );\n\n\t\t\t\t}",depthTest:!1,depthWrite:!1,transparent:!1}),u=new t.Mesh(a,l),v=[],p=n.Shader,f=new t.RawShaderMaterial({uniforms:{map:{value:null},occlusionMap:{value:s},color:{value:new t.Color(16777215)},scale:{value:new t.Vector2},screenPosition:{value:new t.Vector3}},vertexShader:p.vertexShader,fragmentShader:p.fragmentShader,blending:t.AdditiveBlending,transparent:!0,depthWrite:!1}),d=new t.Mesh(a,f);this.addElement=function(t){v.push(t)};const m=new t.Vector2,x=new t.Vector2,y=new t.Box2,h=new t.Vector4;this.onBeforeRender=function(t,e,n){t.getCurrentViewport(h);const p=h.w/h.z,b=h.z/2,g=h.w/2;let w=16/h.w;if(m.set(w*p,w),y.min.set(h.x,h.y),y.max.set(h.x+(h.z-16),h.y+(h.w-16)),r.setFromMatrixPosition(this.matrixWorld),r.applyMatrix4(n.matrixWorldInverse),!(r.z>0)&&(i.copy(r).applyMatrix4(n.projectionMatrix),x.x=h.x+i.x*b+b-8,x.y=h.y+i.y*g+g-8,y.containsPoint(x))){t.copyFramebufferToTexture(x,o);let e=l.uniforms;e.scale.value=m,e.screenPosition.value=i,t.renderBufferDirect(n,null,a,l,u,null),t.copyFramebufferToTexture(x,s),e=c.uniforms,e.scale.value=m,e.screenPosition.value=i,t.renderBufferDirect(n,null,a,c,u,null);const r=2*-i.x,p=2*-i.y;for(let e=0,o=v.length;e<o;e++){const o=v[e],s=f.uniforms;s.color.value.copy(o.color),s.map.value=o.texture,s.screenPosition.value.x=i.x+r*o.distance,s.screenPosition.value.y=i.y+p*o.distance,w=o.size/h.w;const l=h.w/h.z;s.scale.value.set(w*l,w),f.uniformsNeedUpdate=!0,t.renderBufferDirect(n,null,a,f,d,null)}}},this.dispose=function(){l.dispose(),c.dispose(),f.dispose(),o.dispose(),s.dispose();for(let t=0,e=v.length;t<e;t++)v[t].texture.dispose()}}}e.prototype.isLensflare=!0;class n{constructor(e,n=1,i=0,r=new t.Color(16777215)){this.texture=e,this.size=n,this.distance=i,this.color=r}}n.Shader={uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform vec3 screenPosition;\n\t\tuniform vec2 scale;\n\n\t\tuniform sampler2D occlusionMap;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\n\t\tvarying vec2 vUV;\n\t\tvarying float vVisibility;\n\n\t\tvoid main() {\n\n\t\t\tvUV = uv;\n\n\t\t\tvec2 pos = position.xy;\n\n\t\t\tvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\n\n\t\t\tvVisibility = visibility.r / 9.0;\n\t\t\tvVisibility *= 1.0 - visibility.g / 9.0;\n\t\t\tvVisibility *= visibility.b / 9.0;\n\n\t\t\tgl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D map;\n\t\tuniform vec3 color;\n\n\t\tvarying vec2 vUV;\n\t\tvarying float vVisibility;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texture = texture2D( map, vUV );\n\t\t\ttexture.a *= vVisibility;\n\t\t\tgl_FragColor = texture;\n\t\t\tgl_FragColor.rgb *= color;\n\n\t\t}"},e.Geometry=function(){const e=new t.BufferGeometry,n=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),i=new t.InterleavedBuffer(n,5);return e.setIndex([0,1,2,0,2,3]),e.setAttribute("position",new t.InterleavedBufferAttribute(i,3,0,!1)),e.setAttribute("uv",new t.InterleavedBufferAttribute(i,2,3,!1)),e}(),exports.Lensflare=e,exports.LensflareElement=n;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Mesh{constructor(){super(e.Geometry,new t.MeshBasicMaterial({opacity:0,transparent:!0})),this.type="Lensflare",this.frustumCulled=!1,this.renderOrder=1/0;const i=new t.Vector3,r=new t.Vector3,o=new t.DataTexture(new Uint8Array(768),16,16,t.RGBAFormat);o.minFilter=t.NearestFilter,o.magFilter=t.NearestFilter,o.wrapS=t.ClampToEdgeWrapping,o.wrapT=t.ClampToEdgeWrapping;const s=new t.DataTexture(new Uint8Array(768),16,16,t.RGBAFormat);s.minFilter=t.NearestFilter,s.magFilter=t.NearestFilter,s.wrapS=t.ClampToEdgeWrapping,s.wrapT=t.ClampToEdgeWrapping;const a=e.Geometry,l=new t.RawShaderMaterial({uniforms:{scale:{value:null},screenPosition:{value:null}},vertexShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tuniform vec3 screenPosition;\n\t\t\t\tuniform vec2 scale;\n\n\t\t\t\tattribute vec3 position;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = vec4( 1.0, 0.0, 1.0, 1.0 );\n\n\t\t\t\t}",depthTest:!0,depthWrite:!1,transparent:!1}),c=new t.RawShaderMaterial({uniforms:{map:{value:o},scale:{value:null},screenPosition:{value:null}},vertexShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tuniform vec3 screenPosition;\n\t\t\t\tuniform vec2 scale;\n\n\t\t\t\tattribute vec3 position;\n\t\t\t\tattribute vec2 uv;\n\n\t\t\t\tvarying vec2 vUV;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvUV = uv;\n\n\t\t\t\t\tgl_Position = vec4( position.xy * scale + screenPosition.xy, screenPosition.z, 1.0 );\n\n\t\t\t\t}",fragmentShader:"\n\n\t\t\t\tprecision highp float;\n\n\t\t\t\tuniform sampler2D map;\n\n\t\t\t\tvarying vec2 vUV;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_FragColor = texture2D( map, vUV );\n\n\t\t\t\t}",depthTest:!1,depthWrite:!1,transparent:!1}),u=new t.Mesh(a,l),v=[],p=n.Shader,d=new t.RawShaderMaterial({uniforms:{map:{value:null},occlusionMap:{value:s},color:{value:new t.Color(16777215)},scale:{value:new t.Vector2},screenPosition:{value:new t.Vector3}},vertexShader:p.vertexShader,fragmentShader:p.fragmentShader,blending:t.AdditiveBlending,transparent:!0,depthWrite:!1}),m=new t.Mesh(a,d);this.addElement=function(t){v.push(t)};const f=new t.Vector2,y=new t.Vector2,x=new t.Box2,h=new t.Vector4;this.onBeforeRender=function(t,e,n){t.getCurrentViewport(h);const p=h.w/h.z,g=h.z/2,w=h.w/2;let b=16/h.w;if(f.set(b*p,b),x.min.set(h.x,h.y),x.max.set(h.x+(h.z-16),h.y+(h.w-16)),r.setFromMatrixPosition(this.matrixWorld),r.applyMatrix4(n.matrixWorldInverse),!(r.z>0)&&(i.copy(r).applyMatrix4(n.projectionMatrix),y.x=h.x+i.x*g+g-8,y.y=h.y+i.y*w+w-8,x.containsPoint(y))){t.copyFramebufferToTexture(y,o);let e=l.uniforms;e.scale.value=f,e.screenPosition.value=i,t.renderBufferDirect(n,null,a,l,u,null),t.copyFramebufferToTexture(y,s),e=c.uniforms,e.scale.value=f,e.screenPosition.value=i,t.renderBufferDirect(n,null,a,c,u,null);const r=2*-i.x,p=2*-i.y;for(let e=0,o=v.length;e<o;e++){const o=v[e],s=d.uniforms;s.color.value.copy(o.color),s.map.value=o.texture,s.screenPosition.value.x=i.x+r*o.distance,s.screenPosition.value.y=i.y+p*o.distance,b=o.size/h.w;const l=h.w/h.z;s.scale.value.set(b*l,b),d.uniformsNeedUpdate=!0,t.renderBufferDirect(n,null,a,d,m,null)}}},this.dispose=function(){l.dispose(),c.dispose(),d.dispose(),o.dispose(),s.dispose();for(let t=0,e=v.length;t<e;t++)v[t].texture.dispose()}}}e.prototype.isLensflare=!0;class n{constructor(e,n=1,i=0,r=new t.Color(16777215)){this.texture=e,this.size=n,this.distance=i,this.color=r}}n.Shader={uniforms:{map:{value:null},occlusionMap:{value:null},color:{value:null},scale:{value:null},screenPosition:{value:null}},vertexShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform vec3 screenPosition;\n\t\tuniform vec2 scale;\n\n\t\tuniform sampler2D occlusionMap;\n\n\t\tattribute vec3 position;\n\t\tattribute vec2 uv;\n\n\t\tvarying vec2 vUV;\n\t\tvarying float vVisibility;\n\n\t\tvoid main() {\n\n\t\t\tvUV = uv;\n\n\t\t\tvec2 pos = position.xy;\n\n\t\t\tvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\n\t\t\tvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\n\n\t\t\tvVisibility = visibility.r / 9.0;\n\t\t\tvVisibility *= 1.0 - visibility.g / 9.0;\n\t\t\tvVisibility *= visibility.b / 9.0;\n\n\t\t\tgl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n\n\t\t}",fragmentShader:"\n\n\t\tprecision highp float;\n\n\t\tuniform sampler2D map;\n\t\tuniform vec3 color;\n\n\t\tvarying vec2 vUV;\n\t\tvarying float vVisibility;\n\n\t\tvoid main() {\n\n\t\t\tvec4 texture = texture2D( map, vUV );\n\t\t\ttexture.a *= vVisibility;\n\t\t\tgl_FragColor = texture;\n\t\t\tgl_FragColor.rgb *= color;\n\n\t\t}"},e.Geometry=function(){const e=new t.BufferGeometry,n=new Float32Array([-1,-1,0,0,0,1,-1,0,1,0,1,1,0,1,1,-1,1,0,0,1]),i=new t.InterleavedBuffer(n,5);return e.setIndex([0,1,2,0,2,3]),e.setAttribute("position",new t.InterleavedBufferAttribute(i,3,0,!1)),e.setAttribute("uv",new t.InterleavedBufferAttribute(i,2,3,!1)),e}(),exports.Lensflare=e,exports.LensflareElement=n;
@@ -1,4 +1,4 @@
1
- import { Mesh, MeshBasicMaterial, Vector3, FramebufferTexture, RGBAFormat, RawShaderMaterial, Color, Vector2, AdditiveBlending, Box2, Vector4, BufferGeometry, InterleavedBuffer, InterleavedBufferAttribute } from 'three';
1
+ import { Mesh, MeshBasicMaterial, Vector3, DataTexture, RGBAFormat, NearestFilter, ClampToEdgeWrapping, RawShaderMaterial, Color, Vector2, AdditiveBlending, Box2, Vector4, BufferGeometry, InterleavedBuffer, InterleavedBufferAttribute } from 'three';
2
2
 
3
3
  class Lensflare extends Mesh {
4
4
  constructor() {
@@ -13,8 +13,16 @@ class Lensflare extends Mesh {
13
13
  const positionScreen = new Vector3();
14
14
  const positionView = new Vector3(); // textures
15
15
 
16
- const tempMap = new FramebufferTexture(16, 16, RGBAFormat);
17
- const occlusionMap = new FramebufferTexture(16, 16, RGBAFormat); // material
16
+ const tempMap = new DataTexture(new Uint8Array(16 * 16 * 3), 16, 16, RGBAFormat);
17
+ tempMap.minFilter = NearestFilter;
18
+ tempMap.magFilter = NearestFilter;
19
+ tempMap.wrapS = ClampToEdgeWrapping;
20
+ tempMap.wrapT = ClampToEdgeWrapping;
21
+ const occlusionMap = new DataTexture(new Uint8Array(16 * 16 * 3), 16, 16, RGBAFormat);
22
+ occlusionMap.minFilter = NearestFilter;
23
+ occlusionMap.magFilter = NearestFilter;
24
+ occlusionMap.wrapS = ClampToEdgeWrapping;
25
+ occlusionMap.wrapT = ClampToEdgeWrapping; // material
18
26
 
19
27
  const geometry = Lensflare.Geometry;
20
28
  const material1a = new RawShaderMaterial({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-stdlib",
3
- "version": "2.8.9",
3
+ "version": "2.8.12",
4
4
  "private": false,
5
5
  "description": "stand-alone library of threejs examples",
6
6
  "main": "index.cjs.js",
@@ -22,7 +22,7 @@
22
22
  "dependencies": {
23
23
  "@babel/runtime": "^7.16.7",
24
24
  "@webgpu/glslang": "^0.0.15",
25
- "chevrotain": "^10.1.1",
25
+ "chevrotain": "^10.1.2",
26
26
  "draco3d": "^1.4.1",
27
27
  "fflate": "^0.6.9",
28
28
  "ktx-parse": "^0.2.1",
@@ -32,6 +32,6 @@
32
32
  "zstddec": "^0.0.2"
33
33
  },
34
34
  "peerDependencies": {
35
- "three": ">=0.137.0"
35
+ "three": ">=0.122.0"
36
36
  }
37
37
  }
@@ -1,42 +1,14 @@
1
1
  import { MeshBasicMaterial, WebGLRenderer, ShaderMaterial, WebGLRenderTarget } from 'three';
2
2
  import { Pass, FullScreenQuad } from './Pass';
3
3
  declare class AfterimagePass extends Pass {
4
- shader: {
5
- uniforms: {
6
- damp: {
7
- value: number;
8
- };
9
- tOld: {
10
- value: null;
11
- };
12
- tNew: {
13
- value: null;
14
- };
15
- };
16
- vertexShader: string;
17
- fragmentShader: string;
18
- };
4
+ shader: import("../shaders/AfterimageShader").IAfterimageShader;
19
5
  uniforms: any;
20
6
  textureComp: WebGLRenderTarget;
21
7
  textureOld: WebGLRenderTarget;
22
8
  shaderMaterial: ShaderMaterial;
23
9
  compFsQuad: FullScreenQuad<ShaderMaterial>;
24
10
  copyFsQuad: FullScreenQuad<MeshBasicMaterial>;
25
- constructor(damp?: number, shader?: {
26
- uniforms: {
27
- damp: {
28
- value: number;
29
- };
30
- tOld: {
31
- value: null;
32
- };
33
- tNew: {
34
- value: null;
35
- };
36
- };
37
- vertexShader: string;
38
- fragmentShader: string;
39
- });
11
+ constructor(damp?: number, shader?: import("../shaders/AfterimageShader").IAfterimageShader);
40
12
  render(renderer: WebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget): void;
41
13
  setSize(width: number, height: number): void;
42
14
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={uniforms:{tDiffuse:{value:null},exposure:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define saturate(a) clamp( a, 0.0, 1.0 )","uniform sampler2D tDiffuse;","uniform float exposure;","varying vec2 vUv;","vec3 RRTAndODTFit( vec3 v ) {","\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;","\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;","\treturn a / b;","}","vec3 ACESFilmicToneMapping( vec3 color ) {","\tconst mat3 ACESInputMat = mat3(","\t\tvec3( 0.59719, 0.07600, 0.02840 ),","\t\tvec3( 0.35458, 0.90834, 0.13383 ),","\t\tvec3( 0.04823, 0.01566, 0.83777 )","\t);","\tconst mat3 ACESOutputMat = mat3(","\t\tvec3( 1.60475, -0.10208, -0.00327 ),","\t\tvec3( -0.53108, 1.10813, -0.07276 ),","\t\tvec3( -0.07367, -0.00605, 1.07602 )","\t);","\tcolor = ACESInputMat * color;","\tcolor = RRTAndODTFit( color );","\tcolor = ACESOutputMat * color;","\treturn saturate( color );","}","void main() {","\tvec4 tex = texture2D( tDiffuse, vUv );","\ttex.rgb *= exposure / 0.6;","\tgl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );","}"].join("\n")};exports.ACESFilmicToneMappingShader=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={uniforms:{tDiffuse:{value:null},exposure:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define saturate(a) clamp( a, 0.0, 1.0 )","uniform sampler2D tDiffuse;","uniform float exposure;","varying vec2 vUv;","vec3 RRTAndODTFit( vec3 v ) {","\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;","\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;","\treturn a / b;","}","vec3 ACESFilmicToneMapping( vec3 color ) {","\tconst mat3 ACESInputMat = mat3(","\t\tvec3( 0.59719, 0.07600, 0.02840 ),","\t\tvec3( 0.35458, 0.90834, 0.13383 ),","\t\tvec3( 0.04823, 0.01566, 0.83777 )","\t);","\tconst mat3 ACESOutputMat = mat3(","\t\tvec3( 1.60475, -0.10208, -0.00327 ),","\t\tvec3( -0.53108, 1.10813, -0.07276 ),","\t\tvec3( -0.07367, -0.00605, 1.07602 )","\t);","\tcolor = ACESInputMat * color;","\tcolor = RRTAndODTFit( color );","\tcolor = ACESOutputMat * color;","\treturn saturate( color );","}","void main() {","\tvec4 tex = texture2D( tDiffuse, vUv );","\ttex.rgb *= exposure / 0.6;","\tgl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );","}"].join("\n")};exports.ACESFilmicToneMappingShader=t;
@@ -0,0 +1,9 @@
1
+ import type { IUniform, Texture } from 'three';
2
+ import type { IShader } from './types';
3
+ export declare type ACESFilmicToneMappingShaderUniforms = {
4
+ exposure: IUniform<number>;
5
+ tDiffuse: IUniform<Texture | null>;
6
+ };
7
+ export interface IACESFilmicToneMappingShader extends IShader<ACESFilmicToneMappingShaderUniforms> {
8
+ }
9
+ export declare const ACESFilmicToneMappingShader: IACESFilmicToneMappingShader;
@@ -5,7 +5,7 @@
5
5
  * this implementation of ACES is modified to accommodate a brighter viewing environment.
6
6
  * the scale factor of 1/0.6 is subjective. see discussion in #19621.
7
7
  */
8
- var ACESFilmicToneMappingShader = {
8
+ const ACESFilmicToneMappingShader = {
9
9
  uniforms: {
10
10
  tDiffuse: {
11
11
  value: null
@@ -1,16 +1,10 @@
1
- declare const AfterimageShader: {
2
- uniforms: {
3
- damp: {
4
- value: number;
5
- };
6
- tOld: {
7
- value: null;
8
- };
9
- tNew: {
10
- value: null;
11
- };
12
- };
13
- vertexShader: string;
14
- fragmentShader: string;
1
+ import type { IUniform, Texture } from 'three';
2
+ import type { IShader } from './types';
3
+ export declare type AfterimageShaderUniforms = {
4
+ damp: IUniform<number>;
5
+ tNew: IUniform<Texture | null>;
6
+ tOld: IUniform<Texture | null>;
15
7
  };
16
- export { AfterimageShader };
8
+ export interface IAfterimageShader extends IShader<AfterimageShaderUniforms> {
9
+ }
10
+ export declare const AfterimageShader: IAfterimageShader;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={uniforms:{},vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["void main() {","\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );","}"].join("\n")};exports.BasicShader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={uniforms:{},vertexShader:["void main() {","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["void main() {","\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );","}"].join("\n")};exports.BasicShader=e;
@@ -1,5 +1,5 @@
1
- export const BasicShader: {
2
- uniforms: {};
3
- vertexShader: string;
4
- fragmentShader: string;
5
- };
1
+ import type { IShader } from './types';
2
+ export declare type BasicShaderUniforms = {};
3
+ export interface IBasicShader extends IShader<BasicShaderUniforms> {
4
+ }
5
+ export declare const BasicShader: IBasicShader;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Simple test shader
3
3
  */
4
- var BasicShader = {
4
+ const BasicShader = {
5
5
  uniforms: {},
6
6
  vertexShader: ['void main() {', ' gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );', '}'].join('\n'),
7
7
  fragmentShader: ['void main() {', ' gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );', '}'].join('\n')
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 base = texture2D( tDiffuse, vUv );","\tvec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );","\tfloat lum = dot( lumCoeff, base.rgb );","\tvec3 blend = vec3( lum );","\tfloat L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );","\tvec3 result1 = 2.0 * base.rgb * blend;","\tvec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );","\tvec3 newColor = mix( result1, result2, L );","\tfloat A2 = opacity * base.a;","\tvec3 mixRGB = A2 * newColor.rgb;","\tmixRGB += ( ( 1.0 - A2 ) * base.rgb );","\tgl_FragColor = vec4( mixRGB, base.a );","}"].join("\n")};exports.BleachBypassShader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform sampler2D tDiffuse;","varying vec2 vUv;","void main() {","\tvec4 base = texture2D( tDiffuse, vUv );","\tvec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );","\tfloat lum = dot( lumCoeff, base.rgb );","\tvec3 blend = vec3( lum );","\tfloat L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );","\tvec3 result1 = 2.0 * base.rgb * blend;","\tvec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );","\tvec3 newColor = mix( result1, result2, L );","\tfloat A2 = opacity * base.a;","\tvec3 mixRGB = A2 * newColor.rgb;","\tmixRGB += ( ( 1.0 - A2 ) * base.rgb );","\tgl_FragColor = vec4( mixRGB, base.a );","}"].join("\n")};exports.BleachBypassShader=e;
@@ -1,10 +1,9 @@
1
- import { Uniform } from 'three';
2
-
3
- export const BleachBypassShader: {
4
- uniforms: {
5
- tDiffuse: Uniform;
6
- opacity: Uniform;
7
- };
8
- vertexShader: string;
9
- fragmentShader: string;
1
+ import type { IUniform, Texture } from 'three';
2
+ import type { IShader } from './types';
3
+ export declare type BleachBypassShaderUniforms = {
4
+ opacity: IUniform<number>;
5
+ tDiffuse: IUniform<Texture | null>;
10
6
  };
7
+ export interface IBleachBypassShader extends IShader<BleachBypassShaderUniforms> {
8
+ }
9
+ export declare const BleachBypassShader: IBleachBypassShader;
@@ -3,7 +3,7 @@
3
3
  * - based on Nvidia example
4
4
  * http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
5
5
  */
6
- var BleachBypassShader = {
6
+ const BleachBypassShader = {
7
7
  uniforms: {
8
8
  tDiffuse: {
9
9
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e={uniforms:{tDiffuse1:{value:null},tDiffuse2:{value:null},mixRatio:{value:.5},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform float mixRatio;","uniform sampler2D tDiffuse1;","uniform sampler2D tDiffuse2;","varying vec2 vUv;","void main() {","\tvec4 texel1 = texture2D( tDiffuse1, vUv );","\tvec4 texel2 = texture2D( tDiffuse2, vUv );","\tgl_FragColor = opacity * mix( texel1, texel2, mixRatio );","}"].join("\n")};exports.BlendShader=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={uniforms:{tDiffuse1:{value:null},tDiffuse2:{value:null},mixRatio:{value:.5},opacity:{value:1}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform float opacity;","uniform float mixRatio;","uniform sampler2D tDiffuse1;","uniform sampler2D tDiffuse2;","varying vec2 vUv;","void main() {","\tvec4 texel1 = texture2D( tDiffuse1, vUv );","\tvec4 texel2 = texture2D( tDiffuse2, vUv );","\tgl_FragColor = opacity * mix( texel1, texel2, mixRatio );","}"].join("\n")};exports.BlendShader=e;
@@ -1,11 +1,17 @@
1
- import { Uniform } from 'three';
2
-
3
- export const BlendShader: {
1
+ export declare const BlendShader: {
4
2
  uniforms: {
5
- tDiffuse1: Uniform;
6
- tDiffuse2: Uniform;
7
- mixRatio: Uniform;
8
- opacity: Uniform;
3
+ tDiffuse1: {
4
+ value: null;
5
+ };
6
+ tDiffuse2: {
7
+ value: null;
8
+ };
9
+ mixRatio: {
10
+ value: number;
11
+ };
12
+ opacity: {
13
+ value: number;
14
+ };
9
15
  };
10
16
  vertexShader: string;
11
17
  fragmentShader: string;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Blend two textures
3
3
  */
4
- var BlendShader = {
4
+ const BlendShader = {
5
5
  uniforms: {
6
6
  tDiffuse1: {
7
7
  value: null
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float maxblur;","uniform float aperture;","uniform float nearClip;","uniform float farClip;","uniform float focus;","uniform float aspect;","#include <packing>","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );","\t#else","\treturn orthographicDepthToViewZ( depth, nearClip, farClip );","\t#endif","}","void main() {","\tvec2 aspectcorrect = vec2( 1.0, aspect );","\tfloat viewZ = getViewZ( getDepth( vUv ) );","\tfloat factor = ( focus + viewZ );","\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );","\tvec2 dofblur9 = dofblur * 0.9;","\tvec2 dofblur7 = dofblur * 0.7;","\tvec2 dofblur4 = dofblur * 0.4;","\tvec4 col = vec4( 0.0 );","\tcol += texture2D( tColor, vUv.xy );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );","\tgl_FragColor = col / 41.0;","\tgl_FragColor.a = 1.0;","}"].join("\n")};exports.BokehShader=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float maxblur;","uniform float aperture;","uniform float nearClip;","uniform float farClip;","uniform float focus;","uniform float aspect;","#include <packing>","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","float getViewZ( const in float depth ) {","\t#if PERSPECTIVE_CAMERA == 1","\treturn perspectiveDepthToViewZ( depth, nearClip, farClip );","\t#else","\treturn orthographicDepthToViewZ( depth, nearClip, farClip );","\t#endif","}","void main() {","\tvec2 aspectcorrect = vec2( 1.0, aspect );","\tfloat viewZ = getViewZ( getDepth( vUv ) );","\tfloat factor = ( focus + viewZ );","\tvec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );","\tvec2 dofblur9 = dofblur * 0.9;","\tvec2 dofblur7 = dofblur * 0.7;","\tvec2 dofblur4 = dofblur * 0.4;","\tvec4 col = vec4( 0.0 );","\tcol += texture2D( tColor, vUv.xy );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.15, 0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.37, 0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.15, -0.37 ) * aspectcorrect ) * dofblur9 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.40, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur7 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, -0.4 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, 0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.4, 0.0 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );","\tcol += texture2D( tColor, vUv.xy + ( vec2( 0.0, 0.4 ) * aspectcorrect ) * dofblur4 );","\tgl_FragColor = col / 41.0;","\tgl_FragColor.a = 1.0;","}"].join("\n")};exports.BokehShader=t;
@@ -1,20 +1,19 @@
1
- import { Uniform } from 'three';
2
-
3
- export const BokehShader: {
4
- defines: {
5
- DEPTH_PACKING: number;
6
- PERSPECTIVE_CAMERA: number;
7
- };
8
- uniforms: {
9
- tColor: Uniform;
10
- tDepth: Uniform;
11
- focus: Uniform;
12
- aspect: Uniform;
13
- aperture: Uniform;
14
- maxblur: Uniform;
15
- nearClip: Uniform;
16
- farClip: Uniform;
17
- };
18
- vertexShader: string;
19
- fragmentShader: string;
1
+ import type { IUniform, Texture } from 'three';
2
+ import type { IShader } from './types';
3
+ export declare type BokehShaderDefines = {
4
+ DEPTH_PACKING: number;
5
+ PERSPECTIVE_CAMERA: number;
20
6
  };
7
+ export declare type BokehShaderUniforms = {
8
+ aperture: IUniform<number>;
9
+ aspect: IUniform<number>;
10
+ farClip: IUniform<number>;
11
+ focus: IUniform<number>;
12
+ maxblur: IUniform<number>;
13
+ nearClip: IUniform<number>;
14
+ tColor: IUniform<Texture | null>;
15
+ tDepth: IUniform<Texture | null>;
16
+ };
17
+ export interface IBokehShader extends IShader<BokehShaderUniforms, BokehShaderDefines> {
18
+ }
19
+ export declare const BokehShader: IBokehShader;
@@ -3,7 +3,7 @@
3
3
  * ported from GLSL shader by Martins Upitis
4
4
  * http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
5
5
  */
6
- var BokehShader = {
6
+ const BokehShader = {
7
7
  defines: {
8
8
  DEPTH_PACKING: 1,
9
9
  PERSPECTIVE_CAMERA: 1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t={uniforms:{textureWidth:{value:1},textureHeight:{value:1},focalDepth:{value:1},focalLength:{value:24},fstop:{value:.9},tColor:{value:null},tDepth:{value:null},maxblur:{value:1},showFocus:{value:0},manualdof:{value:0},vignetting:{value:0},depthblur:{value:0},threshold:{value:.5},gain:{value:2},bias:{value:.5},fringe:{value:.7},znear:{value:.1},zfar:{value:100},noise:{value:1},dithering:{value:1e-4},pentagon:{value:0},shaderFocus:{value:1},focusCoords:{value:new(require("three").Vector2)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float textureWidth;","uniform float textureHeight;","uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below","uniform float focalLength; //focal length in mm","uniform float fstop; //f-stop value","uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)","/*","make sure that these two values are the same for your camera, otherwise distances will be wrong.","*/","uniform float znear; // camera clipping start","uniform float zfar; // camera clipping end","//------------------------------------------","//user variables","const int samples = SAMPLES; //samples on the first ring","const int rings = RINGS; //ring count","const int maxringsamples = rings * samples;","uniform bool manualdof; // manual dof calculation","float ndofstart = 1.0; // near dof blur start","float ndofdist = 2.0; // near dof blur falloff distance","float fdofstart = 1.0; // far dof blur start","float fdofdist = 3.0; // far dof blur falloff distance","float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)","uniform bool vignetting; // use optical lens vignetting","float vignout = 1.3; // vignetting outer border","float vignin = 0.0; // vignetting inner border","float vignfade = 22.0; // f-stops till vignete fades","uniform bool shaderFocus;","// disable if you use external focalDepth value","uniform vec2 focusCoords;","// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)","// if center of screen use vec2(0.5, 0.5);","uniform float maxblur;","//clamp value of max blur (0.0 = no blur, 1.0 default)","uniform float threshold; // highlight threshold;","uniform float gain; // highlight gain;","uniform float bias; // bokeh edge bias","uniform float fringe; // bokeh chromatic aberration / fringing","uniform bool noise; //use noise instead of pattern for sample dithering","uniform float dithering;","uniform bool depthblur; // blur the depth buffer","float dbsize = 1.25; // depth blur size","/*","next part is experimental","not looking good with small sample and ring count","looks okay starting from samples = 4, rings = 4","*/","uniform bool pentagon; //use pentagon as bokeh shape?","float feather = 0.4; //pentagon shape feather","//------------------------------------------","float penta(vec2 coords) {","\t//pentagonal shape","\tfloat scale = float(rings) - 1.3;","\tvec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);","\tvec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);","\tvec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);","\tvec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);","\tvec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);","\tvec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);","\tvec4 one = vec4( 1.0 );","\tvec4 P = vec4((coords),vec2(scale, scale));","\tvec4 dist = vec4(0.0);","\tfloat inorout = -4.0;","\tdist.x = dot( P, HS0 );","\tdist.y = dot( P, HS1 );","\tdist.z = dot( P, HS2 );","\tdist.w = dot( P, HS3 );","\tdist = smoothstep( -feather, feather, dist );","\tinorout += dot( dist, one );","\tdist.x = dot( P, HS4 );","\tdist.y = HS5.w - abs( P.z );","\tdist = smoothstep( -feather, feather, dist );","\tinorout += dist.x;","\treturn clamp( inorout, 0.0, 1.0 );","}","float bdepth(vec2 coords) {","\t// Depth buffer blur","\tfloat d = 0.0;","\tfloat kernel[9];","\tvec2 offset[9];","\tvec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;","\toffset[0] = vec2(-wh.x,-wh.y);","\toffset[1] = vec2( 0.0, -wh.y);","\toffset[2] = vec2( wh.x -wh.y);","\toffset[3] = vec2(-wh.x, 0.0);","\toffset[4] = vec2( 0.0, 0.0);","\toffset[5] = vec2( wh.x, 0.0);","\toffset[6] = vec2(-wh.x, wh.y);","\toffset[7] = vec2( 0.0, wh.y);","\toffset[8] = vec2( wh.x, wh.y);","\tkernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;","\tkernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;","\tkernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;","\tfor( int i=0; i<9; i++ ) {","\t\tfloat tmp = texture2D(tDepth, coords + offset[i]).r;","\t\td += tmp * kernel[i];","\t}","\treturn d;","}","vec3 color(vec2 coords,float blur) {","\t//processing the sample","\tvec3 col = vec3(0.0);","\tvec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);","\tcol.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;","\tcol.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;","\tcol.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;","\tvec3 lumcoeff = vec3(0.299,0.587,0.114);","\tfloat lum = dot(col.rgb, lumcoeff);","\tfloat thresh = max((lum-threshold)*gain, 0.0);","\treturn col+mix(vec3(0.0),col,thresh*blur);","}","vec3 debugFocus(vec3 col, float blur, float depth) {","\tfloat edge = 0.002*depth; //distance based edge smoothing","\tfloat m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);","\tfloat e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);","\tcol = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);","\tcol = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);","\treturn col;","}","float linearize(float depth) {","\treturn -zfar * znear / (depth * (zfar - znear) - zfar);","}","float vignette() {","\tfloat dist = distance(vUv.xy, vec2(0.5,0.5));","\tdist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);","\treturn clamp(dist,0.0,1.0);","}","float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {","\tfloat rings2 = float(rings);","\tfloat step = PI*2.0 / float(ringsamples);","\tfloat pw = cos(j*step)*i;","\tfloat ph = sin(j*step)*i;","\tfloat p = 1.0;","\tif (pentagon) {","\t\tp = penta(vec2(pw,ph));","\t}","\tcol += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;","\treturn 1.0 * mix(1.0, i /rings2, bias) * p;","}","void main() {","\t//scene depth calculation","\tfloat depth = linearize(texture2D(tDepth,vUv.xy).x);","\t// Blur depth?","\tif ( depthblur ) {","\t\tdepth = linearize(bdepth(vUv.xy));","\t}","\t//focal plane calculation","\tfloat fDepth = focalDepth;","\tif (shaderFocus) {","\t\tfDepth = linearize(texture2D(tDepth,focusCoords).x);","\t}","\t// dof blur factor calculation","\tfloat blur = 0.0;","\tif (manualdof) {","\t\tfloat a = depth-fDepth; // Focal plane","\t\tfloat b = (a-fdofstart)/fdofdist; // Far DoF","\t\tfloat c = (-a-ndofstart)/ndofdist; // Near Dof","\t\tblur = (a>0.0) ? b : c;","\t} else {","\t\tfloat f = focalLength; // focal length in mm","\t\tfloat d = fDepth*1000.0; // focal plane in mm","\t\tfloat o = depth*1000.0; // depth in mm","\t\tfloat a = (o*f)/(o-f);","\t\tfloat b = (d*f)/(d-f);","\t\tfloat c = (d-f)/(d*fstop*CoC);","\t\tblur = abs(a-b)*c;","\t}","\tblur = clamp(blur,0.0,1.0);","\t// calculation of pattern for dithering","\tvec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;","\t// getting blur x and y step factor","\tfloat w = (1.0/textureWidth)*blur*maxblur+noise.x;","\tfloat h = (1.0/textureHeight)*blur*maxblur+noise.y;","\t// calculation of final color","\tvec3 col = vec3(0.0);","\tif(blur < 0.05) {","\t\t//some optimization thingy","\t\tcol = texture2D(tColor, vUv.xy).rgb;","\t} else {","\t\tcol = texture2D(tColor, vUv.xy).rgb;","\t\tfloat s = 1.0;","\t\tint ringsamples;","\t\tfor (int i = 1; i <= rings; i++) {","\t\t\t/*unboxstart*/","\t\t\tringsamples = i * samples;","\t\t\tfor (int j = 0 ; j < maxringsamples ; j++) {","\t\t\t\tif (j >= ringsamples) break;","\t\t\t\ts += gather(float(i), float(j), ringsamples, col, w, h, blur);","\t\t\t}","\t\t\t/*unboxend*/","\t\t}","\t\tcol /= s; //divide by sample count","\t}","\tif (showFocus) {","\t\tcol = debugFocus(col, blur, depth);","\t}","\tif (vignetting) {","\t\tcol *= vignette();","\t}","\tgl_FragColor.rgb = col;","\tgl_FragColor.a = 1.0;","} "].join("\n")},e={uniforms:{mNear:{value:1},mFar:{value:1e3}},vertexShader:["varying float vViewZDepth;","void main() {","\t#include <begin_vertex>","\t#include <project_vertex>","\tvViewZDepth = - mvPosition.z;","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","varying float vViewZDepth;","void main() {","\tfloat color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );","\tgl_FragColor = vec4( vec3( color ), 1.0 );","} "].join("\n")};exports.BokehDepthShader=e,exports.BokehShader2=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={uniforms:{textureWidth:{value:1},textureHeight:{value:1},focalDepth:{value:1},focalLength:{value:24},fstop:{value:.9},tColor:{value:null},tDepth:{value:null},maxblur:{value:1},showFocus:{value:0},manualdof:{value:0},vignetting:{value:0},depthblur:{value:0},threshold:{value:.5},gain:{value:2},bias:{value:.5},fringe:{value:.7},znear:{value:.1},zfar:{value:100},noise:{value:1},dithering:{value:1e-4},pentagon:{value:0},shaderFocus:{value:1},focusCoords:{value:new(require("three").Vector2)}},vertexShader:["varying vec2 vUv;","void main() {","\tvUv = uv;","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include <common>","varying vec2 vUv;","uniform sampler2D tColor;","uniform sampler2D tDepth;","uniform float textureWidth;","uniform float textureHeight;","uniform float focalDepth; //focal distance value in meters, but you may use autofocus option below","uniform float focalLength; //focal length in mm","uniform float fstop; //f-stop value","uniform bool showFocus; //show debug focus point and focal range (red = focal point, green = focal range)","/*","make sure that these two values are the same for your camera, otherwise distances will be wrong.","*/","uniform float znear; // camera clipping start","uniform float zfar; // camera clipping end","//------------------------------------------","//user variables","const int samples = SAMPLES; //samples on the first ring","const int rings = RINGS; //ring count","const int maxringsamples = rings * samples;","uniform bool manualdof; // manual dof calculation","float ndofstart = 1.0; // near dof blur start","float ndofdist = 2.0; // near dof blur falloff distance","float fdofstart = 1.0; // far dof blur start","float fdofdist = 3.0; // far dof blur falloff distance","float CoC = 0.03; //circle of confusion size in mm (35mm film = 0.03mm)","uniform bool vignetting; // use optical lens vignetting","float vignout = 1.3; // vignetting outer border","float vignin = 0.0; // vignetting inner border","float vignfade = 22.0; // f-stops till vignete fades","uniform bool shaderFocus;","// disable if you use external focalDepth value","uniform vec2 focusCoords;","// autofocus point on screen (0.0,0.0 - left lower corner, 1.0,1.0 - upper right)","// if center of screen use vec2(0.5, 0.5);","uniform float maxblur;","//clamp value of max blur (0.0 = no blur, 1.0 default)","uniform float threshold; // highlight threshold;","uniform float gain; // highlight gain;","uniform float bias; // bokeh edge bias","uniform float fringe; // bokeh chromatic aberration / fringing","uniform bool noise; //use noise instead of pattern for sample dithering","uniform float dithering;","uniform bool depthblur; // blur the depth buffer","float dbsize = 1.25; // depth blur size","/*","next part is experimental","not looking good with small sample and ring count","looks okay starting from samples = 4, rings = 4","*/","uniform bool pentagon; //use pentagon as bokeh shape?","float feather = 0.4; //pentagon shape feather","//------------------------------------------","float penta(vec2 coords) {","\t//pentagonal shape","\tfloat scale = float(rings) - 1.3;","\tvec4 HS0 = vec4( 1.0, 0.0, 0.0, 1.0);","\tvec4 HS1 = vec4( 0.309016994, 0.951056516, 0.0, 1.0);","\tvec4 HS2 = vec4(-0.809016994, 0.587785252, 0.0, 1.0);","\tvec4 HS3 = vec4(-0.809016994,-0.587785252, 0.0, 1.0);","\tvec4 HS4 = vec4( 0.309016994,-0.951056516, 0.0, 1.0);","\tvec4 HS5 = vec4( 0.0 ,0.0 , 1.0, 1.0);","\tvec4 one = vec4( 1.0 );","\tvec4 P = vec4((coords),vec2(scale, scale));","\tvec4 dist = vec4(0.0);","\tfloat inorout = -4.0;","\tdist.x = dot( P, HS0 );","\tdist.y = dot( P, HS1 );","\tdist.z = dot( P, HS2 );","\tdist.w = dot( P, HS3 );","\tdist = smoothstep( -feather, feather, dist );","\tinorout += dot( dist, one );","\tdist.x = dot( P, HS4 );","\tdist.y = HS5.w - abs( P.z );","\tdist = smoothstep( -feather, feather, dist );","\tinorout += dist.x;","\treturn clamp( inorout, 0.0, 1.0 );","}","float bdepth(vec2 coords) {","\t// Depth buffer blur","\tfloat d = 0.0;","\tfloat kernel[9];","\tvec2 offset[9];","\tvec2 wh = vec2(1.0/textureWidth,1.0/textureHeight) * dbsize;","\toffset[0] = vec2(-wh.x,-wh.y);","\toffset[1] = vec2( 0.0, -wh.y);","\toffset[2] = vec2( wh.x -wh.y);","\toffset[3] = vec2(-wh.x, 0.0);","\toffset[4] = vec2( 0.0, 0.0);","\toffset[5] = vec2( wh.x, 0.0);","\toffset[6] = vec2(-wh.x, wh.y);","\toffset[7] = vec2( 0.0, wh.y);","\toffset[8] = vec2( wh.x, wh.y);","\tkernel[0] = 1.0/16.0; kernel[1] = 2.0/16.0; kernel[2] = 1.0/16.0;","\tkernel[3] = 2.0/16.0; kernel[4] = 4.0/16.0; kernel[5] = 2.0/16.0;","\tkernel[6] = 1.0/16.0; kernel[7] = 2.0/16.0; kernel[8] = 1.0/16.0;","\tfor( int i=0; i<9; i++ ) {","\t\tfloat tmp = texture2D(tDepth, coords + offset[i]).r;","\t\td += tmp * kernel[i];","\t}","\treturn d;","}","vec3 color(vec2 coords,float blur) {","\t//processing the sample","\tvec3 col = vec3(0.0);","\tvec2 texel = vec2(1.0/textureWidth,1.0/textureHeight);","\tcol.r = texture2D(tColor,coords + vec2(0.0,1.0)*texel*fringe*blur).r;","\tcol.g = texture2D(tColor,coords + vec2(-0.866,-0.5)*texel*fringe*blur).g;","\tcol.b = texture2D(tColor,coords + vec2(0.866,-0.5)*texel*fringe*blur).b;","\tvec3 lumcoeff = vec3(0.299,0.587,0.114);","\tfloat lum = dot(col.rgb, lumcoeff);","\tfloat thresh = max((lum-threshold)*gain, 0.0);","\treturn col+mix(vec3(0.0),col,thresh*blur);","}","vec3 debugFocus(vec3 col, float blur, float depth) {","\tfloat edge = 0.002*depth; //distance based edge smoothing","\tfloat m = clamp(smoothstep(0.0,edge,blur),0.0,1.0);","\tfloat e = clamp(smoothstep(1.0-edge,1.0,blur),0.0,1.0);","\tcol = mix(col,vec3(1.0,0.5,0.0),(1.0-m)*0.6);","\tcol = mix(col,vec3(0.0,0.5,1.0),((1.0-e)-(1.0-m))*0.2);","\treturn col;","}","float linearize(float depth) {","\treturn -zfar * znear / (depth * (zfar - znear) - zfar);","}","float vignette() {","\tfloat dist = distance(vUv.xy, vec2(0.5,0.5));","\tdist = smoothstep(vignout+(fstop/vignfade), vignin+(fstop/vignfade), dist);","\treturn clamp(dist,0.0,1.0);","}","float gather(float i, float j, int ringsamples, inout vec3 col, float w, float h, float blur) {","\tfloat rings2 = float(rings);","\tfloat step = PI*2.0 / float(ringsamples);","\tfloat pw = cos(j*step)*i;","\tfloat ph = sin(j*step)*i;","\tfloat p = 1.0;","\tif (pentagon) {","\t\tp = penta(vec2(pw,ph));","\t}","\tcol += color(vUv.xy + vec2(pw*w,ph*h), blur) * mix(1.0, i/rings2, bias) * p;","\treturn 1.0 * mix(1.0, i /rings2, bias) * p;","}","void main() {","\t//scene depth calculation","\tfloat depth = linearize(texture2D(tDepth,vUv.xy).x);","\t// Blur depth?","\tif ( depthblur ) {","\t\tdepth = linearize(bdepth(vUv.xy));","\t}","\t//focal plane calculation","\tfloat fDepth = focalDepth;","\tif (shaderFocus) {","\t\tfDepth = linearize(texture2D(tDepth,focusCoords).x);","\t}","\t// dof blur factor calculation","\tfloat blur = 0.0;","\tif (manualdof) {","\t\tfloat a = depth-fDepth; // Focal plane","\t\tfloat b = (a-fdofstart)/fdofdist; // Far DoF","\t\tfloat c = (-a-ndofstart)/ndofdist; // Near Dof","\t\tblur = (a>0.0) ? b : c;","\t} else {","\t\tfloat f = focalLength; // focal length in mm","\t\tfloat d = fDepth*1000.0; // focal plane in mm","\t\tfloat o = depth*1000.0; // depth in mm","\t\tfloat a = (o*f)/(o-f);","\t\tfloat b = (d*f)/(d-f);","\t\tfloat c = (d-f)/(d*fstop*CoC);","\t\tblur = abs(a-b)*c;","\t}","\tblur = clamp(blur,0.0,1.0);","\t// calculation of pattern for dithering","\tvec2 noise = vec2(rand(vUv.xy), rand( vUv.xy + vec2( 0.4, 0.6 ) ) )*dithering*blur;","\t// getting blur x and y step factor","\tfloat w = (1.0/textureWidth)*blur*maxblur+noise.x;","\tfloat h = (1.0/textureHeight)*blur*maxblur+noise.y;","\t// calculation of final color","\tvec3 col = vec3(0.0);","\tif(blur < 0.05) {","\t\t//some optimization thingy","\t\tcol = texture2D(tColor, vUv.xy).rgb;","\t} else {","\t\tcol = texture2D(tColor, vUv.xy).rgb;","\t\tfloat s = 1.0;","\t\tint ringsamples;","\t\tfor (int i = 1; i <= rings; i++) {","\t\t\t/*unboxstart*/","\t\t\tringsamples = i * samples;","\t\t\tfor (int j = 0 ; j < maxringsamples ; j++) {","\t\t\t\tif (j >= ringsamples) break;","\t\t\t\ts += gather(float(i), float(j), ringsamples, col, w, h, blur);","\t\t\t}","\t\t\t/*unboxend*/","\t\t}","\t\tcol /= s; //divide by sample count","\t}","\tif (showFocus) {","\t\tcol = debugFocus(col, blur, depth);","\t}","\tif (vignetting) {","\t\tcol *= vignette();","\t}","\tgl_FragColor.rgb = col;","\tgl_FragColor.a = 1.0;","} "].join("\n")},e={uniforms:{mNear:{value:1},mFar:{value:1e3}},vertexShader:["varying float vViewZDepth;","void main() {","\t#include <begin_vertex>","\t#include <project_vertex>","\tvViewZDepth = - mvPosition.z;","}"].join("\n"),fragmentShader:["uniform float mNear;","uniform float mFar;","varying float vViewZDepth;","void main() {","\tfloat color = 1.0 - smoothstep( mNear, mFar, vViewZDepth );","\tgl_FragColor = vec4( vec3( color ), 1.0 );","} "].join("\n")};exports.BokehDepthShader=e,exports.BokehShader2=t;