modularize.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author Mugen87 / https://github.com/Mugen87
  4. */
  5. var fs = require( 'fs' );
  6. THREE = require( '../build/three.js' );
  7. var srcFolder = __dirname + '/../examples/js/';
  8. var dstFolder = __dirname + '/../examples/jsm/';
  9. var files = [
  10. { path: 'animation/AnimationClipCreator.js', dependencies: [], ignoreList: [] },
  11. { path: 'animation/CCDIKSolver.js', dependencies: [], ignoreList: [ 'SkinnedMesh' ] },
  12. { path: 'animation/MMDAnimationHelper.js', dependencies: [ { name: 'CCDIKSolver', path: 'animation/CCDIKSolver.js' }, { name: 'MMDPhysics', path: 'animation/MMDPhysics.js' } ], ignoreList: [ 'AnimationClip', 'Audio', 'Camera', 'SkinnedMesh' ] },
  13. { path: 'animation/MMDPhysics.js', dependencies: [], ignoreList: [ 'SkinnedMesh' ] },
  14. { path: 'animation/TimelinerController.js', dependencies: [], ignoreList: [] },
  15. { path: 'cameras/CinematicCamera.js', dependencies: [ { name: 'BokehShader', path: 'shaders/BokehShader2.js' }, { name: 'BokehDepthShader', path: 'shaders/BokehShader2.js' } ], ignoreList: [] },
  16. { path: 'controls/DragControls.js', dependencies: [], ignoreList: [] },
  17. { path: 'controls/DeviceOrientationControls.js', dependencies: [], ignoreList: [] },
  18. { path: 'controls/FirstPersonControls.js', dependencies: [], ignoreList: [] },
  19. { path: 'controls/FlyControls.js', dependencies: [], ignoreList: [] },
  20. { path: 'controls/OrbitControls.js', dependencies: [], ignoreList: [] },
  21. { path: 'controls/PointerLockControls.js', dependencies: [], ignoreList: [] },
  22. { path: 'controls/TrackballControls.js', dependencies: [], ignoreList: [] },
  23. { path: 'controls/TransformControls.js', dependencies: [], ignoreList: [] },
  24. { path: 'curves/CurveExtras.js', dependencies: [], ignoreList: [] },
  25. { path: 'curves/NURBSCurve.js', dependencies: [ { name: 'NURBSUtils', path: 'curves/NURBSUtils.js' } ], ignoreList: [] },
  26. { path: 'curves/NURBSSurface.js', dependencies: [ { name: 'NURBSUtils', path: 'curves/NURBSUtils.js' } ], ignoreList: [] },
  27. { path: 'curves/NURBSUtils.js', dependencies: [], ignoreList: [] },
  28. { path: 'effects/AnaglyphEffect.js', dependencies: [], ignoreList: [] },
  29. { path: 'effects/AsciiEffect.js', dependencies: [], ignoreList: [] },
  30. { path: 'effects/OutlineEffect.js', dependencies: [], ignoreList: [] },
  31. { path: 'effects/ParallaxBarrierEffect.js', dependencies: [], ignoreList: [] },
  32. { path: 'effects/PeppersGhostEffect.js', dependencies: [], ignoreList: [] },
  33. { path: 'effects/StereoEffect.js', dependencies: [], ignoreList: [] },
  34. { path: 'exporters/ColladaExporter.js', dependencies: [], ignoreList: [] },
  35. { path: 'exporters/DRACOExporter.js', dependencies: [], ignoreList: [ 'Geometry' ] },
  36. { path: 'exporters/GLTFExporter.js', dependencies: [], ignoreList: [ 'AnimationClip', 'Camera', 'Geometry', 'Material', 'Mesh', 'Object3D', 'RGBFormat', 'Scenes', 'ShaderMaterial', 'VertexColors' ] },
  37. { path: 'exporters/MMDExporter.js', dependencies: [ { name: 'MMDParser', path: 'libs/mmdparser.module.js' } ], ignoreList: [] },
  38. { path: 'exporters/OBJExporter.js', dependencies: [], ignoreList: [] },
  39. { path: 'exporters/PLYExporter.js', dependencies: [], ignoreList: [] },
  40. { path: 'exporters/STLExporter.js', dependencies: [], ignoreList: [] },
  41. { path: 'exporters/TypedGeometryExporter.js', dependencies: [], ignoreList: [] },
  42. { path: 'geometries/BoxLineGeometry.js', dependencies: [], ignoreList: [] },
  43. { path: 'geometries/ConvexGeometry.js', dependencies: [ { name: 'ConvexHull', path: 'math/ConvexHull.js' } ], ignoreList: [] },
  44. { path: 'geometries/DecalGeometry.js', dependencies: [], ignoreList: [] },
  45. { path: 'geometries/LightningStrike.js', dependencies: [ { name: 'SimplexNoise', path: 'math/SimplexNoise.js' } ], ignoreList: [ 'Mesh' ] },
  46. { path: 'geometries/ParametricGeometries.js', dependencies: [], ignoreList: [] },
  47. { path: 'geometries/TeapotBufferGeometry.js', dependencies: [], ignoreList: [] },
  48. { path: 'interactive/SelectionBox.js', dependencies: [], ignoreList: [] },
  49. { path: 'interactive/SelectionHelper.js', dependencies: [], ignoreList: [] },
  50. { path: 'lights/LightProbeGenerator.js', dependencies: [], ignoreList: [] },
  51. { path: 'lights/RectAreaLightUniformsLib.js', dependencies: [], ignoreList: [] },
  52. { path: 'lines/Line2.js', dependencies: [ { name: 'LineSegments2', path: 'lines/LineSegments2.js' }, { name: 'LineGeometry', path: 'lines/LineGeometry.js' }, { name: 'LineMaterial', path: 'lines/LineMaterial.js' } ], ignoreList: [] },
  53. { path: 'lines/LineGeometry.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' } ], ignoreList: [] },
  54. { path: 'lines/LineMaterial.js', dependencies: [], ignoreList: [] },
  55. { path: 'lines/LineSegments2.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' }, { name: 'LineMaterial', path: 'lines/LineMaterial.js' } ], ignoreList: [] },
  56. { path: 'lines/LineSegmentsGeometry.js', dependencies: [], ignoreList: [] },
  57. { path: 'lines/Wireframe.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' }, { name: 'LineMaterial', path: 'lines/LineMaterial.js' } ], ignoreList: [] },
  58. { path: 'lines/WireframeGeometry2.js', dependencies: [ { name: 'LineSegmentsGeometry', path: 'lines/LineSegmentsGeometry.js' } ], ignoreList: [] },
  59. { path: 'loaders/3MFLoader.js', dependencies: [], ignoreList: [] },
  60. { path: 'loaders/AMFLoader.js', dependencies: [], ignoreList: [] },
  61. { path: 'loaders/AssimpLoader.js', dependencies: [], ignoreList: [] },
  62. { path: 'loaders/BasisTextureLoader.js', dependencies: [], ignoreList: [] },
  63. { path: 'loaders/BVHLoader.js', dependencies: [], ignoreList: [ 'Bones' ] },
  64. { path: 'loaders/ColladaLoader.js', dependencies: [ { name: 'TGALoader', path: 'loaders/TGALoader.js' } ], ignoreList: [] },
  65. { path: 'loaders/DDSLoader.js', dependencies: [], ignoreList: [] },
  66. { path: 'loaders/DRACOLoader.js', dependencies: [], ignoreList: [ 'LoadingManager' ] },
  67. { path: 'loaders/EXRLoader.js', dependencies: [ { name: 'Zlib', path: 'libs/inflate.module.min.js' } ], ignoreList: [] },
  68. { path: 'loaders/FBXLoader.js', dependencies: [ { name: 'Zlib', path: 'libs/inflate.module.min.js' }, { name: 'NURBSCurve', path: 'curves/NURBSCurve.js' } ], ignoreList: [] },
  69. { path: 'loaders/GCodeLoader.js', dependencies: [], ignoreList: [] },
  70. { path: 'loaders/GLTFLoader.js', dependencies: [], ignoreList: [ 'NoSide', 'Matrix2', 'Camera', 'Texture' ] },
  71. { path: 'loaders/HDRCubeTextureLoader.js', dependencies: [ { name: 'RGBELoader', path: 'loaders/RGBELoader.js' } ], ignoreList: [] },
  72. { path: 'loaders/KMZLoader.js', dependencies: [ { name: 'ColladaLoader', path: 'loaders/ColladaLoader.js' } ], ignoreList: [] },
  73. { path: 'loaders/LDrawLoader.js', dependencies: [], ignoreList: [ 'Cache', 'Material', 'Object3D' ] },
  74. { path: 'loaders/LWOLoader.js', dependencies: [], ignoreList: [] },
  75. { path: 'loaders/KTXLoader.js', dependencies: [], ignoreList: [] },
  76. { path: 'loaders/MD2Loader.js', dependencies: [], ignoreList: [] },
  77. { path: 'loaders/MMDLoader.js', dependencies: [ { name: 'TGALoader', path: 'loaders/TGALoader.js' }, { name: 'MMDParser', path: 'libs/mmdparser.module.js' } ], ignoreList: [ 'Camera', 'LoadingManager' ] },
  78. { path: 'loaders/MTLLoader.js', dependencies: [], ignoreList: [ 'BackSide', 'DoubleSide', 'ClampToEdgeWrapping', 'MirroredRepeatWrapping' ] },
  79. { path: 'loaders/NRRDLoader.js', dependencies: [ { name: 'Zlib', path: 'libs/gunzip.module.min.js' }, { name: 'Volume', path: 'misc/Volume.js' } ], ignoreList: [] },
  80. { path: 'loaders/OBJLoader.js', dependencies: [], ignoreList: [] },
  81. { path: 'loaders/PCDLoader.js', dependencies: [], ignoreList: [] },
  82. { path: 'loaders/PDBLoader.js', dependencies: [], ignoreList: [] },
  83. { path: 'loaders/PLYLoader.js', dependencies: [], ignoreList: [ 'Mesh' ] },
  84. { path: 'loaders/PRWMLoader.js', dependencies: [], ignoreList: [] },
  85. { path: 'loaders/PVRLoader.js', dependencies: [], ignoreList: [] },
  86. { path: 'loaders/RGBELoader.js', dependencies: [], ignoreList: [ 'RGBAFormat' ] },
  87. { path: 'loaders/STLLoader.js', dependencies: [], ignoreList: [ 'Mesh', 'MeshPhongMaterial', 'VertexColors' ] },
  88. { path: 'loaders/SVGLoader.js', dependencies: [], ignoreList: [] },
  89. { path: 'loaders/TDSLoader.js', dependencies: [], ignoreList: [] },
  90. { path: 'loaders/TGALoader.js', dependencies: [], ignoreList: [] },
  91. { path: 'loaders/TTFLoader.js', dependencies: [], ignoreList: [ 'Font' ] },
  92. { path: 'loaders/VRMLLoader.js', dependencies: [ { name: 'chevrotain', path: 'libs/chevrotain.module.min.js' } ], ignoreList: [] },
  93. { path: 'loaders/VRMLoader.js', dependencies: [ { name: 'GLTFLoader', path: 'loaders/GLTFLoader.js' } ], ignoreList: [] },
  94. { path: 'loaders/VTKLoader.js', dependencies: [ { name: 'Zlib', path: 'libs/inflate.module.min.js' } ], ignoreList: [] },
  95. { path: 'loaders/XLoader.js', dependencies: [], ignoreList: [] },
  96. { path: 'math/ColorConverter.js', dependencies: [], ignoreList: [] },
  97. { path: 'math/ConvexHull.js', dependencies: [], ignoreList: [] },
  98. { path: 'math/ImprovedNoise.js', dependencies: [], ignoreList: [] },
  99. { path: 'math/Lut.js', dependencies: [], ignoreList: [] },
  100. { path: 'math/SimplexNoise.js', dependencies: [], ignoreList: [] },
  101. { path: 'misc/ConvexObjectBreaker.js', dependencies: [ { name: 'ConvexBufferGeometry', path: 'geometries/ConvexGeometry.js' } ], ignoreList: [ 'Matrix4' ] },
  102. { path: 'misc/GPUComputationRenderer.js', dependencies: [], ignoreList: [] },
  103. { path: 'misc/Gyroscope.js', dependencies: [], ignoreList: [] },
  104. { path: 'misc/MD2Character.js', dependencies: [ { name: 'MD2Loader', path: 'loaders/MD2Loader.js' } ], ignoreList: [] },
  105. { path: 'misc/MD2CharacterComplex.js', dependencies: [ { name: 'MD2Loader', path: 'loaders/MD2Loader.js' }, { name: 'MorphBlendMesh', path: 'misc/MorphBlendMesh.js' } ], ignoreList: [] },
  106. { path: 'misc/MorphAnimMesh.js', dependencies: [], ignoreList: [] },
  107. { path: 'misc/MorphBlendMesh.js', dependencies: [], ignoreList: [] },
  108. { path: 'misc/Ocean.js', dependencies: [ { name: 'OceanShaders', path: 'shaders/OceanShaders.js' } ], ignoreList: [] },
  109. { path: 'misc/RollerCoaster.js', dependencies: [], ignoreList: [] },
  110. { path: 'misc/Volume.js', dependencies: [ { name: 'VolumeSlice', path: 'misc/VolumeSlice.js' } ], ignoreList: [] },
  111. { path: 'misc/VolumeSlice.js', dependencies: [], ignoreList: [] },
  112. { path: 'modifiers/ExplodeModifier.js', dependencies: [], ignoreList: [] },
  113. { path: 'modifiers/SimplifyModifier.js', dependencies: [], ignoreList: [] },
  114. { path: 'modifiers/SubdivisionModifier.js', dependencies: [], ignoreList: [] },
  115. { path: 'modifiers/TessellateModifier.js', dependencies: [], ignoreList: [] },
  116. { path: 'objects/Fire.js', dependencies: [], ignoreList: [] },
  117. { path: 'objects/Lensflare.js', dependencies: [], ignoreList: [] },
  118. { path: 'objects/LightningStorm.js', dependencies: [ { name: 'LightningStrike', path: 'geometries/LightningStrike.js' } ], ignoreList: [ 'Material' ] },
  119. { path: 'objects/MarchingCubes.js', dependencies: [], ignoreList: [] },
  120. { path: 'objects/Reflector.js', dependencies: [], ignoreList: [] },
  121. { path: 'objects/Refractor.js', dependencies: [], ignoreList: [] },
  122. { path: 'objects/ReflectorRTT.js', dependencies: [ { name: 'Reflector', path: 'objects/Reflector.js' } ], ignoreList: [] },
  123. { path: 'objects/ShadowMesh.js', dependencies: [], ignoreList: [] },
  124. { path: 'objects/Sky.js', dependencies: [], ignoreList: [] },
  125. { path: 'objects/Water.js', dependencies: [], ignoreList: [] },
  126. { path: 'objects/Water2.js', dependencies: [ { name: 'Reflector', path: 'objects/Reflector.js' }, { name: 'Refractor', path: 'objects/Refractor.js' } ], ignoreList: [] },
  127. { path: 'postprocessing/AdaptiveToneMappingPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' }, { name: 'LuminosityShader', path: 'shaders/LuminosityShader.js' }, { name: 'ToneMapShader', path: 'shaders/ToneMapShader.js' } ], ignoreList: [] },
  128. { path: 'postprocessing/AfterimagePass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'AfterimageShader', path: 'shaders/AfterimageShader.js' } ], ignoreList: [] },
  129. { path: 'postprocessing/BloomPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' }, { name: 'ConvolutionShader', path: 'shaders/ConvolutionShader.js' } ], ignoreList: [] },
  130. { path: 'postprocessing/BokehPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'BokehShader', path: 'shaders/BokehShader.js' } ], ignoreList: [] },
  131. { path: 'postprocessing/ClearPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' } ], ignoreList: [] },
  132. { path: 'postprocessing/CubeTexturePass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' } ], ignoreList: [] },
  133. { path: 'postprocessing/DotScreenPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'DotScreenShader', path: 'shaders/DotScreenShader.js' } ], ignoreList: [] },
  134. { path: 'postprocessing/EffectComposer.js', dependencies: [ { name: 'CopyShader', path: 'shaders/CopyShader.js' }, { name: 'ShaderPass', path: 'postprocessing/ShaderPass.js' }, { name: 'MaskPass', path: 'postprocessing/MaskPass.js' }, { name: 'ClearMaskPass', path: 'postprocessing/MaskPass.js' } ], ignoreList: [] },
  135. { path: 'postprocessing/FilmPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'FilmShader', path: 'shaders/FilmShader.js' } ], ignoreList: [] },
  136. { path: 'postprocessing/GlitchPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'DigitalGlitch', path: 'shaders/DigitalGlitch.js' } ], ignoreList: [] },
  137. { path: 'postprocessing/HalftonePass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'HalftoneShader', path: 'shaders/HalftoneShader.js' } ], ignoreList: [] },
  138. { path: 'postprocessing/MaskPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' } ], ignoreList: [] },
  139. { path: 'postprocessing/OutlinePass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' } ], ignoreList: [] },
  140. { path: 'postprocessing/RenderPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' } ], ignoreList: [] },
  141. { path: 'postprocessing/SAOPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'SAOShader', path: 'shaders/SAOShader.js' }, { name: 'DepthLimitedBlurShader', path: 'shaders/DepthLimitedBlurShader.js' }, { name: 'BlurShaderUtils', path: 'shaders/DepthLimitedBlurShader.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' }, { name: 'UnpackDepthRGBAShader', path: 'shaders/UnpackDepthRGBAShader.js' } ], ignoreList: [] },
  142. { path: 'postprocessing/SavePass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' } ], ignoreList: [] },
  143. { path: 'postprocessing/ShaderPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' } ], ignoreList: [] },
  144. { path: 'postprocessing/SMAAPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'SMAAEdgesShader', path: 'shaders/SMAAShader.js' }, { name: 'SMAAWeightsShader', path: 'shaders/SMAAShader.js' }, { name: 'SMAABlendShader', path: 'shaders/SMAAShader.js' } ], ignoreList: [] },
  145. { path: 'postprocessing/SSAARenderPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' } ], ignoreList: [] },
  146. { path: 'postprocessing/SSAOPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'SimplexNoise', path: 'math/SimplexNoise.js' }, { name: 'SSAOShader', path: 'shaders/SSAOShader.js' }, { name: 'SSAOBlurShader', path: 'shaders/SSAOShader.js' }, { name: 'SSAODepthShader', path: 'shaders/SSAOShader.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' } ], ignoreList: [] },
  147. { path: 'postprocessing/TAARenderPass.js', dependencies: [ { name: 'SSAARenderPass', path: 'postprocessing/SSAARenderPass.js' } ], ignoreList: [] },
  148. { path: 'postprocessing/TexturePass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' } ], ignoreList: [] },
  149. { path: 'postprocessing/UnrealBloomPass.js', dependencies: [ { name: 'Pass', path: 'postprocessing/Pass.js' }, { name: 'CopyShader', path: 'shaders/CopyShader.js' }, { name: 'LuminosityHighPassShader', path: 'shaders/LuminosityHighPassShader.js' } ], ignoreList: [] },
  150. { path: 'renderers/CSS2DRenderer.js', dependencies: [], ignoreList: [] },
  151. { path: 'renderers/CSS3DRenderer.js', dependencies: [], ignoreList: [] },
  152. { path: 'renderers/Projector.js', dependencies: [], ignoreList: [] },
  153. { path: 'renderers/SVGRenderer.js', dependencies: [ { name: 'Projector', path: 'renderers/Projector.js' }, { name: 'RenderableFace', path: 'renderers/Projector.js' }, { name: 'RenderableLine', path: 'renderers/Projector.js' }, { name: 'RenderableSprite', path: 'renderers/Projector.js' } ], ignoreList: [] },
  154. { path: 'shaders/AfterimageShader.js', dependencies: [], ignoreList: [] },
  155. { path: 'shaders/BasicShader.js', dependencies: [], ignoreList: [] },
  156. { path: 'shaders/BleachBypassShader.js', dependencies: [], ignoreList: [] },
  157. { path: 'shaders/BlendShader.js', dependencies: [], ignoreList: [] },
  158. { path: 'shaders/BokehShader.js', dependencies: [], ignoreList: [] },
  159. { path: 'shaders/BokehShader2.js', dependencies: [], ignoreList: [] },
  160. { path: 'shaders/BrightnessContrastShader.js', dependencies: [], ignoreList: [] },
  161. { path: 'shaders/ColorCorrectionShader.js', dependencies: [], ignoreList: [] },
  162. { path: 'shaders/ColorifyShader.js', dependencies: [], ignoreList: [] },
  163. { path: 'shaders/ConvolutionShader.js', dependencies: [], ignoreList: [] },
  164. { path: 'shaders/CopyShader.js', dependencies: [], ignoreList: [] },
  165. { path: 'shaders/DepthLimitedBlurShader.js', dependencies: [], ignoreList: [] },
  166. { path: 'shaders/DigitalGlitch.js', dependencies: [], ignoreList: [] },
  167. { path: 'shaders/DOFMipMapShader.js', dependencies: [], ignoreList: [] },
  168. { path: 'shaders/DotScreenShader.js', dependencies: [], ignoreList: [] },
  169. { path: 'shaders/FilmShader.js', dependencies: [], ignoreList: [] },
  170. { path: 'shaders/FocusShader.js', dependencies: [], ignoreList: [] },
  171. { path: 'shaders/FreiChenShader.js', dependencies: [], ignoreList: [] },
  172. { path: 'shaders/FresnelShader.js', dependencies: [], ignoreList: [] },
  173. { path: 'shaders/FXAAShader.js', dependencies: [], ignoreList: [] },
  174. { path: 'shaders/GammaCorrectionShader.js', dependencies: [], ignoreList: [] },
  175. { path: 'shaders/GodRaysShader.js', dependencies: [], ignoreList: [ 'MeshDepthMaterial' ] },
  176. { path: 'shaders/HalftoneShader.js', dependencies: [], ignoreList: [] },
  177. { path: 'shaders/HorizontalBlurShader.js', dependencies: [], ignoreList: [] },
  178. { path: 'shaders/HorizontalTiltShiftShader.js', dependencies: [], ignoreList: [] },
  179. { path: 'shaders/HueSaturationShader.js', dependencies: [], ignoreList: [] },
  180. { path: 'shaders/KaleidoShader.js', dependencies: [], ignoreList: [] },
  181. { path: 'shaders/LuminosityHighPassShader.js', dependencies: [], ignoreList: [] },
  182. { path: 'shaders/LuminosityShader.js', dependencies: [], ignoreList: [] },
  183. { path: 'shaders/MirrorShader.js', dependencies: [], ignoreList: [] },
  184. { path: 'shaders/NormalMapShader.js', dependencies: [], ignoreList: [] },
  185. { path: 'shaders/OceanShaders.js', dependencies: [], ignoreList: [] },
  186. { path: 'shaders/ParallaxShader.js', dependencies: [], ignoreList: [] },
  187. { path: 'shaders/PixelShader.js', dependencies: [], ignoreList: [] },
  188. { path: 'shaders/RGBShiftShader.js', dependencies: [], ignoreList: [] },
  189. { path: 'shaders/SAOShader.js', dependencies: [], ignoreList: [] },
  190. { path: 'shaders/SepiaShader.js', dependencies: [], ignoreList: [] },
  191. { path: 'shaders/SMAAShader.js', dependencies: [], ignoreList: [] },
  192. { path: 'shaders/SobelOperatorShader.js', dependencies: [], ignoreList: [] },
  193. { path: 'shaders/SSAOShader.js', dependencies: [], ignoreList: [] },
  194. { path: 'shaders/TechnicolorShader.js', dependencies: [], ignoreList: [] },
  195. { path: 'shaders/ToneMapShader.js', dependencies: [], ignoreList: [] },
  196. { path: 'shaders/ToonShader.js', dependencies: [], ignoreList: [] },
  197. { path: 'shaders/TranslucentShader.js', dependencies: [], ignoreList: [] },
  198. { path: 'shaders/TriangleBlurShader.js', dependencies: [], ignoreList: [] },
  199. { path: 'shaders/UnpackDepthRGBAShader.js', dependencies: [], ignoreList: [] },
  200. { path: 'shaders/VerticalBlurShader.js', dependencies: [], ignoreList: [] },
  201. { path: 'shaders/VerticalTiltShiftShader.js', dependencies: [], ignoreList: [] },
  202. { path: 'shaders/VignetteShader.js', dependencies: [], ignoreList: [] },
  203. { path: 'shaders/VolumeShader.js', dependencies: [], ignoreList: [] },
  204. { path: 'shaders/WaterRefractionShader.js', dependencies: [], ignoreList: [] },
  205. { path: 'utils/BufferGeometryUtils.js', dependencies: [], ignoreList: [] },
  206. { path: 'utils/GeometryUtils.js', dependencies: [], ignoreList: [] },
  207. { path: 'utils/SceneUtils.js', dependencies: [], ignoreList: [] },
  208. { path: 'utils/ShadowMapViewer.js', dependencies: [ { name: 'UnpackDepthRGBAShader', path: 'shaders/UnpackDepthRGBAShader.js' } ], ignoreList: [ 'DirectionalLight', 'SpotLight' ] },
  209. { path: 'utils/SkeletonUtils.js', dependencies: [], ignoreList: [] },
  210. { path: 'utils/TypedArrayUtils.js', dependencies: [], ignoreList: [] },
  211. { path: 'utils/UVsDebug.js', dependencies: [], ignoreList: [ 'SphereBufferGeometry' ] },
  212. { path: 'WebGL.js', dependencies: [], ignoreList: [] },
  213. ];
  214. for ( var i = 0; i < files.length; i ++ ) {
  215. var file = files[ i ];
  216. convert( file.path, file.dependencies, file.ignoreList );
  217. }
  218. //
  219. function convert( path, exampleDependencies, ignoreList ) {
  220. var contents = fs.readFileSync( srcFolder + path, 'utf8' );
  221. var classNames = [];
  222. var coreDependencies = {};
  223. // imports
  224. contents = contents.replace( /^\/\*+[^*]*\*+(?:[^/*][^*]*\*+)*\//, function ( match ) {
  225. return `${match}\n\n_IMPORTS_`;
  226. } );
  227. // class name
  228. contents = contents.replace( /THREE\.([a-zA-Z0-9]+) = /g, function ( match, p1 ) {
  229. classNames.push( p1 );
  230. console.log( p1 );
  231. return `var ${p1} = `;
  232. } );
  233. contents = contents.replace( /(\'?)THREE\.([a-zA-Z0-9]+)(\.{0,1})/g, function ( match, p1, p2, p3 ) {
  234. if ( p1 === '\'' ) return match; // Inside a string
  235. if ( classNames.includes( p2 ) ) return `${p2}${p3}`;
  236. return match;
  237. } );
  238. // methods
  239. contents = contents.replace( /new THREE\.([a-zA-Z0-9]+)\(/g, function ( match, p1 ) {
  240. if ( ignoreList.includes( p1 ) ) return match;
  241. if ( p1 in THREE ) coreDependencies[ p1 ] = true;
  242. return `new ${p1}(`;
  243. } );
  244. // constants
  245. contents = contents.replace( /(\'?)THREE\.([a-zA-Z0-9_]+)/g, function ( match, p1, p2 ) {
  246. if ( ignoreList.includes( p2 ) ) return match;
  247. if ( p1 === '\'' ) return match; // Inside a string
  248. if ( classNames.includes( p2 ) ) return p2;
  249. if ( p2 in THREE ) coreDependencies[ p2 ] = true;
  250. // console.log( match, p2 );
  251. return `${p2}`;
  252. } );
  253. //
  254. var keys = Object.keys( coreDependencies )
  255. .filter( value => ! classNames.includes( value ) )
  256. .map( value => '\n\t' + value )
  257. .sort()
  258. .toString();
  259. var imports = '';
  260. // compute path prefix for imports/exports
  261. var level = path.split( '/' ).length - 1;
  262. var pathPrefix = '../'.repeat( level );
  263. // core imports
  264. if ( keys ) imports += `import {${keys}\n} from "${pathPrefix}../../build/three.module.js";`;
  265. // example imports
  266. for ( var dependency of exampleDependencies ) {
  267. imports += `\nimport { ${dependency.name} } from "${pathPrefix}${dependency.path}";`;
  268. }
  269. // exports
  270. var exports = `export { ${classNames.join( ", " )} };\n`;
  271. var output = contents.replace( '_IMPORTS_', imports ) + '\n' + exports;
  272. // console.log( output );
  273. fs.writeFileSync( dstFolder + path, output, 'utf-8' );
  274. }