@needle-tools/three 0.145.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +84 -0
  3. package/build/three.cjs +36042 -0
  4. package/build/three.js +36048 -0
  5. package/build/three.min.js +6 -0
  6. package/build/three.module.js +49769 -0
  7. package/examples/fonts/LICENSE +13 -0
  8. package/examples/fonts/README.md +11 -0
  9. package/examples/fonts/droid/NOTICE +190 -0
  10. package/examples/fonts/droid/README.txt +18 -0
  11. package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
  12. package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
  13. package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
  14. package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
  15. package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
  16. package/examples/fonts/gentilis_bold.typeface.json +1 -0
  17. package/examples/fonts/gentilis_regular.typeface.json +1 -0
  18. package/examples/fonts/helvetiker_bold.typeface.json +1 -0
  19. package/examples/fonts/helvetiker_regular.typeface.json +1 -0
  20. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  21. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  22. package/examples/fonts/open-sans/open-sans.css +9 -0
  23. package/examples/fonts/optimer_bold.typeface.json +1 -0
  24. package/examples/fonts/optimer_regular.typeface.json +1 -0
  25. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  26. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
  27. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  28. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  29. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  30. package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
  31. package/examples/fonts/ttf/README.md +9 -0
  32. package/examples/fonts/ttf/kenpixel.ttf +0 -0
  33. package/examples/js/animation/AnimationClipCreator.js +97 -0
  34. package/examples/js/animation/CCDIKSolver.js +433 -0
  35. package/examples/js/animation/MMDAnimationHelper.js +1117 -0
  36. package/examples/js/animation/MMDPhysics.js +1238 -0
  37. package/examples/js/cameras/CinematicCamera.js +157 -0
  38. package/examples/js/controls/ArcballControls.js +3037 -0
  39. package/examples/js/controls/DragControls.js +230 -0
  40. package/examples/js/controls/FirstPersonControls.js +334 -0
  41. package/examples/js/controls/FlyControls.js +347 -0
  42. package/examples/js/controls/OrbitControls.js +1075 -0
  43. package/examples/js/controls/PointerLockControls.js +153 -0
  44. package/examples/js/controls/TrackballControls.js +782 -0
  45. package/examples/js/controls/TransformControls.js +1386 -0
  46. package/examples/js/csm/CSM.js +382 -0
  47. package/examples/js/csm/CSMFrustum.js +133 -0
  48. package/examples/js/csm/CSMHelper.js +145 -0
  49. package/examples/js/csm/CSMShader.js +257 -0
  50. package/examples/js/curves/CurveExtras.js +348 -0
  51. package/examples/js/curves/NURBSCurve.js +75 -0
  52. package/examples/js/curves/NURBSSurface.js +54 -0
  53. package/examples/js/curves/NURBSUtils.js +476 -0
  54. package/examples/js/effects/AnaglyphEffect.js +100 -0
  55. package/examples/js/effects/AsciiEffect.js +259 -0
  56. package/examples/js/effects/OutlineEffect.js +454 -0
  57. package/examples/js/effects/ParallaxBarrierEffect.js +75 -0
  58. package/examples/js/effects/PeppersGhostEffect.js +166 -0
  59. package/examples/js/effects/StereoEffect.js +50 -0
  60. package/examples/js/environments/DebugEnvironment.js +53 -0
  61. package/examples/js/environments/RoomEnvironment.js +122 -0
  62. package/examples/js/exporters/ColladaExporter.js +504 -0
  63. package/examples/js/exporters/DRACOExporter.js +212 -0
  64. package/examples/js/exporters/EXRExporter.js +458 -0
  65. package/examples/js/exporters/GLTFExporter.js +2543 -0
  66. package/examples/js/exporters/MMDExporter.js +194 -0
  67. package/examples/js/exporters/OBJExporter.js +251 -0
  68. package/examples/js/exporters/PLYExporter.js +422 -0
  69. package/examples/js/exporters/STLExporter.js +190 -0
  70. package/examples/js/exporters/USDZExporter.js +523 -0
  71. package/examples/js/geometries/BoxLineGeometry.js +60 -0
  72. package/examples/js/geometries/ConvexGeometry.js +48 -0
  73. package/examples/js/geometries/DecalGeometry.js +291 -0
  74. package/examples/js/geometries/LightningStrike.js +874 -0
  75. package/examples/js/geometries/ParametricGeometries.js +215 -0
  76. package/examples/js/geometries/ParametricGeometry.js +108 -0
  77. package/examples/js/geometries/RoundedBoxGeometry.js +140 -0
  78. package/examples/js/geometries/TeapotGeometry.js +331 -0
  79. package/examples/js/geometries/TextGeometry.js +51 -0
  80. package/examples/js/helpers/LightProbeHelper.js +49 -0
  81. package/examples/js/helpers/OctreeHelper.js +74 -0
  82. package/examples/js/helpers/PositionalAudioHelper.js +89 -0
  83. package/examples/js/helpers/RectAreaLightHelper.js +74 -0
  84. package/examples/js/helpers/VertexNormalsHelper.js +72 -0
  85. package/examples/js/helpers/VertexTangentsHelper.js +62 -0
  86. package/examples/js/helpers/ViewHelper.js +266 -0
  87. package/examples/js/interactive/HTMLMesh.js +508 -0
  88. package/examples/js/interactive/InteractiveGroup.js +101 -0
  89. package/examples/js/interactive/SelectionBox.js +262 -0
  90. package/examples/js/interactive/SelectionHelper.js +91 -0
  91. package/examples/js/libs/ammo.wasm.js +822 -0
  92. package/examples/js/libs/ammo.wasm.wasm +0 -0
  93. package/examples/js/libs/basis/README.md +46 -0
  94. package/examples/js/libs/basis/basis_transcoder.js +21 -0
  95. package/examples/js/libs/basis/basis_transcoder.wasm +0 -0
  96. package/examples/js/libs/chevrotain.min.js +3 -0
  97. package/examples/js/libs/draco/README.md +32 -0
  98. package/examples/js/libs/draco/draco_decoder.js +52 -0
  99. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  100. package/examples/js/libs/draco/draco_encoder.js +33 -0
  101. package/examples/js/libs/draco/draco_wasm_wrapper.js +104 -0
  102. package/examples/js/libs/draco/gltf/draco_decoder.js +48 -0
  103. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  104. package/examples/js/libs/draco/gltf/draco_encoder.js +33 -0
  105. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +104 -0
  106. package/examples/js/libs/fflate.min.js +7 -0
  107. package/examples/js/libs/ktx-parse.umd.js +1 -0
  108. package/examples/js/libs/lottie_canvas.js +12751 -0
  109. package/examples/js/libs/meshopt_decoder.js +188 -0
  110. package/examples/js/libs/opentype.min.js +1 -0
  111. package/examples/js/libs/stats.min.js +5 -0
  112. package/examples/js/lights/LightProbeGenerator.js +228 -0
  113. package/examples/js/lights/RectAreaLightUniformsLib.js +56 -0
  114. package/examples/js/lines/Line2.js +19 -0
  115. package/examples/js/lines/LineGeometry.js +71 -0
  116. package/examples/js/lines/LineMaterial.js +642 -0
  117. package/examples/js/lines/LineSegments2.js +362 -0
  118. package/examples/js/lines/LineSegmentsGeometry.js +219 -0
  119. package/examples/js/lines/Wireframe.js +52 -0
  120. package/examples/js/lines/WireframeGeometry2.js +18 -0
  121. package/examples/js/loaders/3DMLoader.js +1370 -0
  122. package/examples/js/loaders/3MFLoader.js +1340 -0
  123. package/examples/js/loaders/AMFLoader.js +529 -0
  124. package/examples/js/loaders/BVHLoader.js +394 -0
  125. package/examples/js/loaders/BasisTextureLoader.js +736 -0
  126. package/examples/js/loaders/ColladaLoader.js +3821 -0
  127. package/examples/js/loaders/DDSLoader.js +245 -0
  128. package/examples/js/loaders/DRACOLoader.js +548 -0
  129. package/examples/js/loaders/EXRLoader.js +2136 -0
  130. package/examples/js/loaders/FBXLoader.js +3835 -0
  131. package/examples/js/loaders/FontLoader.js +169 -0
  132. package/examples/js/loaders/GCodeLoader.js +256 -0
  133. package/examples/js/loaders/GLTFLoader.js +4159 -0
  134. package/examples/js/loaders/HDRCubeTextureLoader.js +93 -0
  135. package/examples/js/loaders/KMZLoader.js +125 -0
  136. package/examples/js/loaders/KTXLoader.js +177 -0
  137. package/examples/js/loaders/LDrawLoader.js +2374 -0
  138. package/examples/js/loaders/LUT3dlLoader.js +139 -0
  139. package/examples/js/loaders/LUTCubeLoader.js +140 -0
  140. package/examples/js/loaders/LWOLoader.js +966 -0
  141. package/examples/js/loaders/LogLuvLoader.js +765 -0
  142. package/examples/js/loaders/LottieLoader.js +62 -0
  143. package/examples/js/loaders/MD2Loader.js +249 -0
  144. package/examples/js/loaders/MDDLoader.js +95 -0
  145. package/examples/js/loaders/MMDLoader.js +1924 -0
  146. package/examples/js/loaders/MTLLoader.js +501 -0
  147. package/examples/js/loaders/NRRDLoader.js +649 -0
  148. package/examples/js/loaders/OBJLoader.js +804 -0
  149. package/examples/js/loaders/PCDLoader.js +408 -0
  150. package/examples/js/loaders/PDBLoader.js +313 -0
  151. package/examples/js/loaders/PLYLoader.js +562 -0
  152. package/examples/js/loaders/PRWMLoader.js +260 -0
  153. package/examples/js/loaders/PVRLoader.js +227 -0
  154. package/examples/js/loaders/RGBELoader.js +467 -0
  155. package/examples/js/loaders/RGBMLoader.js +1415 -0
  156. package/examples/js/loaders/STLLoader.js +371 -0
  157. package/examples/js/loaders/SVGLoader.js +2655 -0
  158. package/examples/js/loaders/TDSLoader.js +1029 -0
  159. package/examples/js/loaders/TGALoader.js +486 -0
  160. package/examples/js/loaders/TIFFLoader.js +31 -0
  161. package/examples/js/loaders/TTFLoader.js +211 -0
  162. package/examples/js/loaders/TiltLoader.js +460 -0
  163. package/examples/js/loaders/VOXLoader.js +248 -0
  164. package/examples/js/loaders/VRMLLoader.js +3237 -0
  165. package/examples/js/loaders/VTKLoader.js +1095 -0
  166. package/examples/js/loaders/XYZLoader.js +91 -0
  167. package/examples/js/loaders/lwo/IFFParser.js +1148 -0
  168. package/examples/js/loaders/lwo/LWO2Parser.js +448 -0
  169. package/examples/js/loaders/lwo/LWO3Parser.js +402 -0
  170. package/examples/js/materials/MeshGouraudMaterial.js +385 -0
  171. package/examples/js/math/Capsule.js +120 -0
  172. package/examples/js/math/ColorConverter.js +33 -0
  173. package/examples/js/math/ConvexHull.js +1110 -0
  174. package/examples/js/math/ImprovedNoise.js +66 -0
  175. package/examples/js/math/Lut.js +171 -0
  176. package/examples/js/math/MeshSurfaceSampler.js +193 -0
  177. package/examples/js/math/OBB.js +341 -0
  178. package/examples/js/math/Octree.js +465 -0
  179. package/examples/js/math/SimplexNoise.js +459 -0
  180. package/examples/js/misc/ConvexObjectBreaker.js +485 -0
  181. package/examples/js/misc/GPUComputationRenderer.js +397 -0
  182. package/examples/js/misc/Gyroscope.js +60 -0
  183. package/examples/js/misc/MD2Character.js +244 -0
  184. package/examples/js/misc/MD2CharacterComplex.js +494 -0
  185. package/examples/js/misc/MorphAnimMesh.js +69 -0
  186. package/examples/js/misc/MorphBlendMesh.js +292 -0
  187. package/examples/js/misc/ProgressiveLightMap.js +331 -0
  188. package/examples/js/misc/RollerCoaster.js +437 -0
  189. package/examples/js/misc/TubePainter.js +161 -0
  190. package/examples/js/misc/Volume.js +466 -0
  191. package/examples/js/misc/VolumeSlice.js +224 -0
  192. package/examples/js/modifiers/CurveModifier.js +311 -0
  193. package/examples/js/modifiers/EdgeSplitModifier.js +258 -0
  194. package/examples/js/modifiers/SimplifyModifier.js +468 -0
  195. package/examples/js/modifiers/TessellateModifier.js +283 -0
  196. package/examples/js/objects/GroundProjectedEnv.js +193 -0
  197. package/examples/js/objects/Lensflare.js +347 -0
  198. package/examples/js/objects/LightningStorm.js +209 -0
  199. package/examples/js/objects/MarchingCubes.js +738 -0
  200. package/examples/js/objects/Reflector.js +214 -0
  201. package/examples/js/objects/ReflectorForSSRPass.js +319 -0
  202. package/examples/js/objects/Refractor.js +261 -0
  203. package/examples/js/objects/ShadowMesh.js +60 -0
  204. package/examples/js/objects/Sky.js +223 -0
  205. package/examples/js/objects/Water.js +287 -0
  206. package/examples/js/objects/Water2.js +306 -0
  207. package/examples/js/physics/AmmoPhysics.js +256 -0
  208. package/examples/js/physics/OimoPhysics.js +215 -0
  209. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +342 -0
  210. package/examples/js/postprocessing/AfterimagePass.js +70 -0
  211. package/examples/js/postprocessing/BloomPass.js +114 -0
  212. package/examples/js/postprocessing/BokehPass.js +103 -0
  213. package/examples/js/postprocessing/ClearPass.js +44 -0
  214. package/examples/js/postprocessing/CubeTexturePass.js +57 -0
  215. package/examples/js/postprocessing/DotScreenPass.js +49 -0
  216. package/examples/js/postprocessing/EffectComposer.js +279 -0
  217. package/examples/js/postprocessing/FilmPass.js +50 -0
  218. package/examples/js/postprocessing/GlitchPass.js +105 -0
  219. package/examples/js/postprocessing/HalftonePass.js +75 -0
  220. package/examples/js/postprocessing/LUTPass.js +184 -0
  221. package/examples/js/postprocessing/MaskPass.js +92 -0
  222. package/examples/js/postprocessing/OutlinePass.js +589 -0
  223. package/examples/js/postprocessing/Pass.js +75 -0
  224. package/examples/js/postprocessing/RenderPass.js +74 -0
  225. package/examples/js/postprocessing/SAOPass.js +366 -0
  226. package/examples/js/postprocessing/SMAAPass.js +153 -0
  227. package/examples/js/postprocessing/SSAARenderPass.js +156 -0
  228. package/examples/js/postprocessing/SSAOPass.js +351 -0
  229. package/examples/js/postprocessing/SSRPass.js +550 -0
  230. package/examples/js/postprocessing/SavePass.js +51 -0
  231. package/examples/js/postprocessing/ShaderPass.js +63 -0
  232. package/examples/js/postprocessing/TAARenderPass.js +128 -0
  233. package/examples/js/postprocessing/TexturePass.js +46 -0
  234. package/examples/js/postprocessing/UnrealBloomPass.js +357 -0
  235. package/examples/js/renderers/CSS2DRenderer.js +197 -0
  236. package/examples/js/renderers/CSS3DRenderer.js +258 -0
  237. package/examples/js/renderers/Projector.js +874 -0
  238. package/examples/js/renderers/SVGRenderer.js +537 -0
  239. package/examples/js/shaders/ACESFilmicToneMappingShader.js +92 -0
  240. package/examples/js/shaders/AfterimageShader.js +63 -0
  241. package/examples/js/shaders/BasicShader.js +30 -0
  242. package/examples/js/shaders/BleachBypassShader.js +65 -0
  243. package/examples/js/shaders/BlendShader.js +57 -0
  244. package/examples/js/shaders/BokehShader.js +159 -0
  245. package/examples/js/shaders/BokehShader2.js +428 -0
  246. package/examples/js/shaders/BrightnessContrastShader.js +61 -0
  247. package/examples/js/shaders/ColorCorrectionShader.js +56 -0
  248. package/examples/js/shaders/ColorifyShader.js +51 -0
  249. package/examples/js/shaders/ConvolutionShader.js +97 -0
  250. package/examples/js/shaders/CopyShader.js +48 -0
  251. package/examples/js/shaders/DOFMipMapShader.js +63 -0
  252. package/examples/js/shaders/DepthLimitedBlurShader.js +180 -0
  253. package/examples/js/shaders/DigitalGlitch.js +130 -0
  254. package/examples/js/shaders/DotScreenShader.js +76 -0
  255. package/examples/js/shaders/FXAAShader.js +286 -0
  256. package/examples/js/shaders/FilmShader.js +113 -0
  257. package/examples/js/shaders/FocusShader.js +98 -0
  258. package/examples/js/shaders/FreiChenShader.js +97 -0
  259. package/examples/js/shaders/GammaCorrectionShader.js +44 -0
  260. package/examples/js/shaders/GodRaysShader.js +297 -0
  261. package/examples/js/shaders/HalftoneShader.js +339 -0
  262. package/examples/js/shaders/HorizontalBlurShader.js +62 -0
  263. package/examples/js/shaders/HorizontalTiltShiftShader.js +68 -0
  264. package/examples/js/shaders/HueSaturationShader.js +72 -0
  265. package/examples/js/shaders/KaleidoShader.js +63 -0
  266. package/examples/js/shaders/LuminosityHighPassShader.js +71 -0
  267. package/examples/js/shaders/LuminosityShader.js +49 -0
  268. package/examples/js/shaders/MMDToonShader.js +100 -0
  269. package/examples/js/shaders/MirrorShader.js +59 -0
  270. package/examples/js/shaders/NormalMapShader.js +59 -0
  271. package/examples/js/shaders/PixelShader.js +51 -0
  272. package/examples/js/shaders/RGBShiftShader.js +59 -0
  273. package/examples/js/shaders/SAOShader.js +213 -0
  274. package/examples/js/shaders/SMAAShader.js +466 -0
  275. package/examples/js/shaders/SSAOShader.js +299 -0
  276. package/examples/js/shaders/SSRShader.js +393 -0
  277. package/examples/js/shaders/SepiaShader.js +55 -0
  278. package/examples/js/shaders/SobelOperatorShader.js +92 -0
  279. package/examples/js/shaders/SubsurfaceScatteringShader.js +49 -0
  280. package/examples/js/shaders/TechnicolorShader.js +46 -0
  281. package/examples/js/shaders/ToneMapShader.js +87 -0
  282. package/examples/js/shaders/ToonShader.js +351 -0
  283. package/examples/js/shaders/TriangleBlurShader.js +74 -0
  284. package/examples/js/shaders/UnpackDepthRGBAShader.js +50 -0
  285. package/examples/js/shaders/VerticalBlurShader.js +62 -0
  286. package/examples/js/shaders/VerticalTiltShiftShader.js +68 -0
  287. package/examples/js/shaders/VignetteShader.js +56 -0
  288. package/examples/js/shaders/VolumeShader.js +300 -0
  289. package/examples/js/shaders/WaterRefractionShader.js +88 -0
  290. package/examples/js/textures/FlakesTexture.js +41 -0
  291. package/examples/js/utils/BufferGeometryUtils.js +1094 -0
  292. package/examples/js/utils/CameraUtils.js +86 -0
  293. package/examples/js/utils/GPUStatsPanel.js +134 -0
  294. package/examples/js/utils/GeometryCompressionUtils.js +574 -0
  295. package/examples/js/utils/GeometryUtils.js +173 -0
  296. package/examples/js/utils/LDrawUtils.js +182 -0
  297. package/examples/js/utils/PackedPhongMaterial.js +107 -0
  298. package/examples/js/utils/SceneUtils.js +103 -0
  299. package/examples/js/utils/ShadowMapViewer.js +180 -0
  300. package/examples/js/utils/SkeletonUtils.js +507 -0
  301. package/examples/js/utils/UVsDebug.js +135 -0
  302. package/examples/js/utils/WorkerPool.js +115 -0
  303. package/examples/jsm/animation/AnimationClipCreator.js +114 -0
  304. package/examples/jsm/animation/CCDIKSolver.js +482 -0
  305. package/examples/jsm/animation/MMDAnimationHelper.js +1207 -0
  306. package/examples/jsm/animation/MMDPhysics.js +1406 -0
  307. package/examples/jsm/cameras/CinematicCamera.js +209 -0
  308. package/examples/jsm/capabilities/WebGL.js +91 -0
  309. package/examples/jsm/capabilities/WebGPU.js +39 -0
  310. package/examples/jsm/controls/ArcballControls.js +3216 -0
  311. package/examples/jsm/controls/DragControls.js +220 -0
  312. package/examples/jsm/controls/FirstPersonControls.js +325 -0
  313. package/examples/jsm/controls/FlyControls.js +284 -0
  314. package/examples/jsm/controls/OrbitControls.js +1249 -0
  315. package/examples/jsm/controls/PointerLockControls.js +157 -0
  316. package/examples/jsm/controls/TrackballControls.js +814 -0
  317. package/examples/jsm/controls/TransformControls.js +1558 -0
  318. package/examples/jsm/csm/CSM.js +378 -0
  319. package/examples/jsm/csm/CSMFrustum.js +152 -0
  320. package/examples/jsm/csm/CSMHelper.js +193 -0
  321. package/examples/jsm/csm/CSMShader.js +251 -0
  322. package/examples/jsm/curves/CurveExtras.js +422 -0
  323. package/examples/jsm/curves/NURBSCurve.js +80 -0
  324. package/examples/jsm/curves/NURBSSurface.js +52 -0
  325. package/examples/jsm/curves/NURBSUtils.js +487 -0
  326. package/examples/jsm/effects/AnaglyphEffect.js +168 -0
  327. package/examples/jsm/effects/AsciiEffect.js +266 -0
  328. package/examples/jsm/effects/OutlineEffect.js +553 -0
  329. package/examples/jsm/effects/ParallaxBarrierEffect.js +116 -0
  330. package/examples/jsm/effects/PeppersGhostEffect.js +153 -0
  331. package/examples/jsm/effects/StereoEffect.js +55 -0
  332. package/examples/jsm/environments/DebugEnvironment.js +52 -0
  333. package/examples/jsm/environments/RoomEnvironment.js +144 -0
  334. package/examples/jsm/exporters/ColladaExporter.js +713 -0
  335. package/examples/jsm/exporters/DRACOExporter.js +225 -0
  336. package/examples/jsm/exporters/EXRExporter.js +507 -0
  337. package/examples/jsm/exporters/GLTFExporter.js +2870 -0
  338. package/examples/jsm/exporters/KTX2Exporter.js +281 -0
  339. package/examples/jsm/exporters/MMDExporter.js +217 -0
  340. package/examples/jsm/exporters/OBJExporter.js +284 -0
  341. package/examples/jsm/exporters/PLYExporter.js +521 -0
  342. package/examples/jsm/exporters/STLExporter.js +195 -0
  343. package/examples/jsm/exporters/USDZExporter.js +1112 -0
  344. package/examples/jsm/geometries/BoxLineGeometry.js +69 -0
  345. package/examples/jsm/geometries/ConvexGeometry.js +59 -0
  346. package/examples/jsm/geometries/DecalGeometry.js +356 -0
  347. package/examples/jsm/geometries/LightningStrike.js +1017 -0
  348. package/examples/jsm/geometries/ParametricGeometries.js +254 -0
  349. package/examples/jsm/geometries/ParametricGeometry.js +129 -0
  350. package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -0
  351. package/examples/jsm/geometries/TeapotGeometry.js +704 -0
  352. package/examples/jsm/geometries/TextGeometry.js +57 -0
  353. package/examples/jsm/helpers/LightProbeHelper.js +130 -0
  354. package/examples/jsm/helpers/OctreeHelper.js +72 -0
  355. package/examples/jsm/helpers/PositionalAudioHelper.js +109 -0
  356. package/examples/jsm/helpers/RectAreaLightHelper.js +85 -0
  357. package/examples/jsm/helpers/VertexNormalsHelper.js +96 -0
  358. package/examples/jsm/helpers/VertexTangentsHelper.js +88 -0
  359. package/examples/jsm/helpers/ViewHelper.js +319 -0
  360. package/examples/jsm/interactive/HTMLMesh.js +550 -0
  361. package/examples/jsm/interactive/InteractiveGroup.js +116 -0
  362. package/examples/jsm/interactive/SelectionBox.js +227 -0
  363. package/examples/jsm/interactive/SelectionHelper.js +97 -0
  364. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +37071 -0
  365. package/examples/jsm/libs/OimoPhysics/index.js +43 -0
  366. package/examples/jsm/libs/chevrotain.module.min.js +141 -0
  367. package/examples/jsm/libs/ecsy.module.js +1792 -0
  368. package/examples/jsm/libs/fflate.module.js +2474 -0
  369. package/examples/jsm/libs/flow.module.js +4552 -0
  370. package/examples/jsm/libs/ktx-parse.module.js +1 -0
  371. package/examples/jsm/libs/lil-gui.module.min.js +8 -0
  372. package/examples/jsm/libs/meshopt_decoder.module.js +178 -0
  373. package/examples/jsm/libs/mikktspace.module.js +128 -0
  374. package/examples/jsm/libs/mmdparser.module.js +11530 -0
  375. package/examples/jsm/libs/motion-controllers.module.js +397 -0
  376. package/examples/jsm/libs/opentype.module.js +14568 -0
  377. package/examples/jsm/libs/potpack.module.js +125 -0
  378. package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
  379. package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
  380. package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
  381. package/examples/jsm/libs/stats.module.js +167 -0
  382. package/examples/jsm/libs/tween.module.min.js +3 -0
  383. package/examples/jsm/libs/utif.module.js +1579 -0
  384. package/examples/jsm/libs/zstddec.module.js +1 -0
  385. package/examples/jsm/lights/LightProbeGenerator.js +250 -0
  386. package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -0
  387. package/examples/jsm/lines/Line2.js +19 -0
  388. package/examples/jsm/lines/LineGeometry.js +79 -0
  389. package/examples/jsm/lines/LineMaterial.js +702 -0
  390. package/examples/jsm/lines/LineSegments2.js +355 -0
  391. package/examples/jsm/lines/LineSegmentsGeometry.js +241 -0
  392. package/examples/jsm/lines/Wireframe.js +56 -0
  393. package/examples/jsm/lines/WireframeGeometry2.js +24 -0
  394. package/examples/jsm/loaders/3DMLoader.js +1495 -0
  395. package/examples/jsm/loaders/3MFLoader.js +1473 -0
  396. package/examples/jsm/loaders/AMFLoader.js +518 -0
  397. package/examples/jsm/loaders/BVHLoader.js +437 -0
  398. package/examples/jsm/loaders/BasisTextureLoader.js +790 -0
  399. package/examples/jsm/loaders/ColladaLoader.js +4092 -0
  400. package/examples/jsm/loaders/DDSLoader.js +274 -0
  401. package/examples/jsm/loaders/DRACOLoader.js +561 -0
  402. package/examples/jsm/loaders/EXRLoader.js +2310 -0
  403. package/examples/jsm/loaders/FBXLoader.js +4137 -0
  404. package/examples/jsm/loaders/FontLoader.js +183 -0
  405. package/examples/jsm/loaders/GCodeLoader.js +262 -0
  406. package/examples/jsm/loaders/GLTFLoader.js +5221 -0
  407. package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -0
  408. package/examples/jsm/loaders/IFCLoader.js +2431 -0
  409. package/examples/jsm/loaders/KMZLoader.js +130 -0
  410. package/examples/jsm/loaders/KTX2Loader.js +753 -0
  411. package/examples/jsm/loaders/KTXLoader.js +176 -0
  412. package/examples/jsm/loaders/LDrawLoader.js +2464 -0
  413. package/examples/jsm/loaders/LUT3dlLoader.js +151 -0
  414. package/examples/jsm/loaders/LUTCubeLoader.js +153 -0
  415. package/examples/jsm/loaders/LWOLoader.js +1069 -0
  416. package/examples/jsm/loaders/LogLuvLoader.js +606 -0
  417. package/examples/jsm/loaders/LottieLoader.js +73 -0
  418. package/examples/jsm/loaders/MD2Loader.js +399 -0
  419. package/examples/jsm/loaders/MDDLoader.js +102 -0
  420. package/examples/jsm/loaders/MMDLoader.js +2242 -0
  421. package/examples/jsm/loaders/MTLLoader.js +567 -0
  422. package/examples/jsm/loaders/NRRDLoader.js +671 -0
  423. package/examples/jsm/loaders/OBJLoader.js +905 -0
  424. package/examples/jsm/loaders/PCDLoader.js +453 -0
  425. package/examples/jsm/loaders/PDBLoader.js +227 -0
  426. package/examples/jsm/loaders/PLYLoader.js +564 -0
  427. package/examples/jsm/loaders/PRWMLoader.js +299 -0
  428. package/examples/jsm/loaders/PVRLoader.js +251 -0
  429. package/examples/jsm/loaders/RGBELoader.js +468 -0
  430. package/examples/jsm/loaders/RGBMLoader.js +1065 -0
  431. package/examples/jsm/loaders/STLLoader.js +399 -0
  432. package/examples/jsm/loaders/SVGLoader.js +2950 -0
  433. package/examples/jsm/loaders/TDSLoader.js +1124 -0
  434. package/examples/jsm/loaders/TGALoader.js +517 -0
  435. package/examples/jsm/loaders/TIFFLoader.js +36 -0
  436. package/examples/jsm/loaders/TTFLoader.js +221 -0
  437. package/examples/jsm/loaders/TiltLoader.js +514 -0
  438. package/examples/jsm/loaders/USDZLoader.js +618 -0
  439. package/examples/jsm/loaders/VOXLoader.js +305 -0
  440. package/examples/jsm/loaders/VRMLLoader.js +3493 -0
  441. package/examples/jsm/loaders/VTKLoader.js +1154 -0
  442. package/examples/jsm/loaders/XYZLoader.js +100 -0
  443. package/examples/jsm/loaders/ifc/web-ifc-api.js +47504 -0
  444. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  445. package/examples/jsm/loaders/lwo/IFFParser.js +1218 -0
  446. package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
  447. package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
  448. package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
  449. package/examples/jsm/math/Capsule.js +137 -0
  450. package/examples/jsm/math/ColorConverter.js +36 -0
  451. package/examples/jsm/math/ConvexHull.js +1271 -0
  452. package/examples/jsm/math/ImprovedNoise.js +71 -0
  453. package/examples/jsm/math/Lut.js +203 -0
  454. package/examples/jsm/math/MeshSurfaceSampler.js +211 -0
  455. package/examples/jsm/math/OBB.js +423 -0
  456. package/examples/jsm/math/Octree.js +462 -0
  457. package/examples/jsm/math/SimplexNoise.js +444 -0
  458. package/examples/jsm/misc/ConvexObjectBreaker.js +525 -0
  459. package/examples/jsm/misc/GPUComputationRenderer.js +454 -0
  460. package/examples/jsm/misc/Gyroscope.js +66 -0
  461. package/examples/jsm/misc/MD2Character.js +276 -0
  462. package/examples/jsm/misc/MD2CharacterComplex.js +576 -0
  463. package/examples/jsm/misc/MorphAnimMesh.js +75 -0
  464. package/examples/jsm/misc/MorphBlendMesh.js +322 -0
  465. package/examples/jsm/misc/ProgressiveLightMap.js +321 -0
  466. package/examples/jsm/misc/RollerCoaster.js +560 -0
  467. package/examples/jsm/misc/TubePainter.js +205 -0
  468. package/examples/jsm/misc/Volume.js +460 -0
  469. package/examples/jsm/misc/VolumeSlice.js +227 -0
  470. package/examples/jsm/modifiers/CurveModifier.js +325 -0
  471. package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -0
  472. package/examples/jsm/modifiers/SimplifyModifier.js +525 -0
  473. package/examples/jsm/modifiers/TessellateModifier.js +307 -0
  474. package/examples/jsm/node-editor/NodeEditor.js +857 -0
  475. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +14 -0
  476. package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
  477. package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
  478. package/examples/jsm/node-editor/accessors/UVEditor.js +25 -0
  479. package/examples/jsm/node-editor/core/BaseNode.js +96 -0
  480. package/examples/jsm/node-editor/core/DataFile.js +59 -0
  481. package/examples/jsm/node-editor/core/FileEditor.js +20 -0
  482. package/examples/jsm/node-editor/core/FileURLEditor.js +29 -0
  483. package/examples/jsm/node-editor/display/BlendEditor.js +44 -0
  484. package/examples/jsm/node-editor/display/NormalMapEditor.js +49 -0
  485. package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
  486. package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
  487. package/examples/jsm/node-editor/examples/matcap.json +1 -0
  488. package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
  489. package/examples/jsm/node-editor/examples/rim.json +1 -0
  490. package/examples/jsm/node-editor/inputs/ColorEditor.js +96 -0
  491. package/examples/jsm/node-editor/inputs/FloatEditor.js +23 -0
  492. package/examples/jsm/node-editor/inputs/SliderEditor.js +67 -0
  493. package/examples/jsm/node-editor/inputs/TextureEditor.js +155 -0
  494. package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
  495. package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
  496. package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
  497. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +84 -0
  498. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +102 -0
  499. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +118 -0
  500. package/examples/jsm/node-editor/math/AngleEditor.js +40 -0
  501. package/examples/jsm/node-editor/math/DotEditor.js +35 -0
  502. package/examples/jsm/node-editor/math/InvertEditor.js +39 -0
  503. package/examples/jsm/node-editor/math/LimiterEditor.js +62 -0
  504. package/examples/jsm/node-editor/math/NormalizeEditor.js +28 -0
  505. package/examples/jsm/node-editor/math/OperatorEditor.js +63 -0
  506. package/examples/jsm/node-editor/math/PowerEditor.js +44 -0
  507. package/examples/jsm/node-editor/math/TrigonometryEditor.js +45 -0
  508. package/examples/jsm/node-editor/procedural/CheckerEditor.js +27 -0
  509. package/examples/jsm/node-editor/scene/MeshEditor.js +102 -0
  510. package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
  511. package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
  512. package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
  513. package/examples/jsm/node-editor/utils/OscillatorEditor.js +43 -0
  514. package/examples/jsm/node-editor/utils/PreviewEditor.js +170 -0
  515. package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
  516. package/examples/jsm/node-editor/utils/TimerEditor.js +58 -0
  517. package/examples/jsm/nodes/Nodes.js +346 -0
  518. package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
  519. package/examples/jsm/nodes/accessors/BufferNode.js +24 -0
  520. package/examples/jsm/nodes/accessors/CameraNode.js +67 -0
  521. package/examples/jsm/nodes/accessors/CubeTextureNode.js +107 -0
  522. package/examples/jsm/nodes/accessors/InstanceNode.js +58 -0
  523. package/examples/jsm/nodes/accessors/MaterialNode.js +152 -0
  524. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +23 -0
  525. package/examples/jsm/nodes/accessors/ModelNode.js +21 -0
  526. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +30 -0
  527. package/examples/jsm/nodes/accessors/NormalNode.js +79 -0
  528. package/examples/jsm/nodes/accessors/Object3DNode.js +122 -0
  529. package/examples/jsm/nodes/accessors/PointUVNode.js +21 -0
  530. package/examples/jsm/nodes/accessors/PositionNode.js +83 -0
  531. package/examples/jsm/nodes/accessors/ReferenceNode.js +65 -0
  532. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
  533. package/examples/jsm/nodes/accessors/SkinningNode.js +109 -0
  534. package/examples/jsm/nodes/accessors/StorageBufferNode.js +21 -0
  535. package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
  536. package/examples/jsm/nodes/accessors/TextureNode.js +100 -0
  537. package/examples/jsm/nodes/accessors/UVNode.js +41 -0
  538. package/examples/jsm/nodes/accessors/UserDataNode.js +23 -0
  539. package/examples/jsm/nodes/core/ArrayUniformNode.js +23 -0
  540. package/examples/jsm/nodes/core/AttributeNode.js +94 -0
  541. package/examples/jsm/nodes/core/BypassNode.js +38 -0
  542. package/examples/jsm/nodes/core/CodeNode.js +50 -0
  543. package/examples/jsm/nodes/core/ConstNode.js +29 -0
  544. package/examples/jsm/nodes/core/ContextNode.js +52 -0
  545. package/examples/jsm/nodes/core/ExpressionNode.js +32 -0
  546. package/examples/jsm/nodes/core/FunctionCallNode.js +82 -0
  547. package/examples/jsm/nodes/core/FunctionNode.js +105 -0
  548. package/examples/jsm/nodes/core/InputNode.js +62 -0
  549. package/examples/jsm/nodes/core/InstanceIndexNode.js +21 -0
  550. package/examples/jsm/nodes/core/Node.js +354 -0
  551. package/examples/jsm/nodes/core/NodeAttribute.js +14 -0
  552. package/examples/jsm/nodes/core/NodeBuilder.js +815 -0
  553. package/examples/jsm/nodes/core/NodeCode.js +15 -0
  554. package/examples/jsm/nodes/core/NodeFrame.js +59 -0
  555. package/examples/jsm/nodes/core/NodeFunction.js +22 -0
  556. package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -0
  557. package/examples/jsm/nodes/core/NodeKeywords.js +80 -0
  558. package/examples/jsm/nodes/core/NodeParser.js +11 -0
  559. package/examples/jsm/nodes/core/NodeUniform.js +28 -0
  560. package/examples/jsm/nodes/core/NodeUtils.js +125 -0
  561. package/examples/jsm/nodes/core/NodeVar.js +14 -0
  562. package/examples/jsm/nodes/core/NodeVarying.js +14 -0
  563. package/examples/jsm/nodes/core/PropertyNode.js +36 -0
  564. package/examples/jsm/nodes/core/TempNode.js +50 -0
  565. package/examples/jsm/nodes/core/UniformNode.js +46 -0
  566. package/examples/jsm/nodes/core/VarNode.js +97 -0
  567. package/examples/jsm/nodes/core/VaryingNode.js +54 -0
  568. package/examples/jsm/nodes/core/constants.js +21 -0
  569. package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
  570. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
  571. package/examples/jsm/nodes/display/ColorSpaceNode.js +95 -0
  572. package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
  573. package/examples/jsm/nodes/display/NormalMapNode.js +93 -0
  574. package/examples/jsm/nodes/display/ToneMappingNode.js +51 -0
  575. package/examples/jsm/nodes/fog/FogNode.js +31 -0
  576. package/examples/jsm/nodes/fog/FogRangeNode.js +27 -0
  577. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +33 -0
  578. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
  579. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +27 -0
  580. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
  581. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +18 -0
  582. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
  583. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +94 -0
  584. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +22 -0
  585. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +12 -0
  586. package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
  587. package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
  588. package/examples/jsm/nodes/gpgpu/ComputeNode.js +65 -0
  589. package/examples/jsm/nodes/lighting/AONode.js +25 -0
  590. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +37 -0
  591. package/examples/jsm/nodes/lighting/EnvironmentNode.js +66 -0
  592. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +50 -0
  593. package/examples/jsm/nodes/lighting/LightingContextNode.js +75 -0
  594. package/examples/jsm/nodes/lighting/LightingNode.js +19 -0
  595. package/examples/jsm/nodes/lighting/LightsNode.js +120 -0
  596. package/examples/jsm/nodes/lighting/PunctualLightNode.js +68 -0
  597. package/examples/jsm/nodes/loaders/NodeLoader.js +107 -0
  598. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +73 -0
  599. package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
  600. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +46 -0
  601. package/examples/jsm/nodes/materials/Materials.js +53 -0
  602. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +48 -0
  603. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
  604. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +168 -0
  605. package/examples/jsm/nodes/materials/NodeMaterial.js +229 -0
  606. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +52 -0
  607. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +106 -0
  608. package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
  609. package/examples/jsm/nodes/materialx/MaterialXNodes.js +55 -0
  610. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
  611. package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
  612. package/examples/jsm/nodes/math/CondNode.js +60 -0
  613. package/examples/jsm/nodes/math/MathNode.js +243 -0
  614. package/examples/jsm/nodes/math/OperatorNode.js +214 -0
  615. package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -0
  616. package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -0
  617. package/examples/jsm/nodes/parsers/WGSLNodeFunction.js +104 -0
  618. package/examples/jsm/nodes/parsers/WGSLNodeParser.js +14 -0
  619. package/examples/jsm/nodes/procedural/CheckerNode.js +34 -0
  620. package/examples/jsm/nodes/shadernode/ShaderNode.js +264 -0
  621. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +299 -0
  622. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +131 -0
  623. package/examples/jsm/nodes/utils/ArrayElementNode.js +31 -0
  624. package/examples/jsm/nodes/utils/ConvertNode.js +47 -0
  625. package/examples/jsm/nodes/utils/JoinNode.js +42 -0
  626. package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
  627. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +33 -0
  628. package/examples/jsm/nodes/utils/OscNode.js +74 -0
  629. package/examples/jsm/nodes/utils/RemapNode.js +34 -0
  630. package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
  631. package/examples/jsm/nodes/utils/SplitNode.js +102 -0
  632. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +58 -0
  633. package/examples/jsm/nodes/utils/TimerNode.js +84 -0
  634. package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
  635. package/examples/jsm/objects/Lensflare.js +378 -0
  636. package/examples/jsm/objects/LightningStorm.js +245 -0
  637. package/examples/jsm/objects/MarchingCubes.js +1172 -0
  638. package/examples/jsm/objects/Reflector.js +269 -0
  639. package/examples/jsm/objects/ReflectorForSSRPass.js +349 -0
  640. package/examples/jsm/objects/Refractor.js +332 -0
  641. package/examples/jsm/objects/ShadowMesh.js +80 -0
  642. package/examples/jsm/objects/Sky.js +219 -0
  643. package/examples/jsm/objects/Water.js +329 -0
  644. package/examples/jsm/objects/Water2.js +358 -0
  645. package/examples/jsm/offscreen/jank.js +45 -0
  646. package/examples/jsm/offscreen/offscreen.js +8 -0
  647. package/examples/jsm/offscreen/scene.js +86 -0
  648. package/examples/jsm/physics/AmmoPhysics.js +286 -0
  649. package/examples/jsm/physics/OimoPhysics.js +231 -0
  650. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +369 -0
  651. package/examples/jsm/postprocessing/AfterimagePass.js +90 -0
  652. package/examples/jsm/postprocessing/BloomPass.js +150 -0
  653. package/examples/jsm/postprocessing/BokehPass.js +131 -0
  654. package/examples/jsm/postprocessing/ClearPass.js +46 -0
  655. package/examples/jsm/postprocessing/CubeTexturePass.js +78 -0
  656. package/examples/jsm/postprocessing/DotScreenPass.js +58 -0
  657. package/examples/jsm/postprocessing/EffectComposer.js +310 -0
  658. package/examples/jsm/postprocessing/FilmPass.js +59 -0
  659. package/examples/jsm/postprocessing/GlitchPass.js +118 -0
  660. package/examples/jsm/postprocessing/HalftonePass.js +77 -0
  661. package/examples/jsm/postprocessing/LUTPass.js +173 -0
  662. package/examples/jsm/postprocessing/MaskPass.js +101 -0
  663. package/examples/jsm/postprocessing/OutlinePass.js +646 -0
  664. package/examples/jsm/postprocessing/Pass.js +80 -0
  665. package/examples/jsm/postprocessing/RenderPass.js +81 -0
  666. package/examples/jsm/postprocessing/SAOPass.js +413 -0
  667. package/examples/jsm/postprocessing/SMAAPass.js +188 -0
  668. package/examples/jsm/postprocessing/SSAARenderPass.js +224 -0
  669. package/examples/jsm/postprocessing/SSAOPass.js +450 -0
  670. package/examples/jsm/postprocessing/SSRPass.js +645 -0
  671. package/examples/jsm/postprocessing/SavePass.js +62 -0
  672. package/examples/jsm/postprocessing/ShaderPass.js +68 -0
  673. package/examples/jsm/postprocessing/TAARenderPass.js +167 -0
  674. package/examples/jsm/postprocessing/TexturePass.js +60 -0
  675. package/examples/jsm/postprocessing/UnrealBloomPass.js +403 -0
  676. package/examples/jsm/renderers/CSS2DRenderer.js +210 -0
  677. package/examples/jsm/renderers/CSS3DRenderer.js +313 -0
  678. package/examples/jsm/renderers/Projector.js +918 -0
  679. package/examples/jsm/renderers/SVGRenderer.js +553 -0
  680. package/examples/jsm/renderers/webgl/nodes/SlotNode.js +26 -0
  681. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +733 -0
  682. package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +49 -0
  683. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +129 -0
  684. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +144 -0
  685. package/examples/jsm/renderers/webgpu/WebGPUBinding.js +22 -0
  686. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +255 -0
  687. package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +43 -0
  688. package/examples/jsm/renderers/webgpu/WebGPUBufferUtils.js +33 -0
  689. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +78 -0
  690. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +82 -0
  691. package/examples/jsm/renderers/webgpu/WebGPUInfo.js +74 -0
  692. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +36 -0
  693. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +22 -0
  694. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +38 -0
  695. package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +199 -0
  696. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +735 -0
  697. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +296 -0
  698. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
  699. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +969 -0
  700. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +73 -0
  701. package/examples/jsm/renderers/webgpu/WebGPUSampler.js +29 -0
  702. package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +20 -0
  703. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +40 -0
  704. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +183 -0
  705. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +794 -0
  706. package/examples/jsm/renderers/webgpu/WebGPUUniform.js +136 -0
  707. package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +18 -0
  708. package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +299 -0
  709. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
  710. package/examples/jsm/renderers/webgpu/constants.js +261 -0
  711. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +801 -0
  712. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +39 -0
  713. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampler.js +21 -0
  714. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniform.js +135 -0
  715. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +83 -0
  716. package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +87 -0
  717. package/examples/jsm/shaders/AfterimageShader.js +56 -0
  718. package/examples/jsm/shaders/BasicShader.js +27 -0
  719. package/examples/jsm/shaders/BleachBypassShader.js +60 -0
  720. package/examples/jsm/shaders/BlendShader.js +48 -0
  721. package/examples/jsm/shaders/BokehShader.js +143 -0
  722. package/examples/jsm/shaders/BokehShader2.js +390 -0
  723. package/examples/jsm/shaders/BrightnessContrastShader.js +54 -0
  724. package/examples/jsm/shaders/ColorCorrectionShader.js +50 -0
  725. package/examples/jsm/shaders/ColorifyShader.js +49 -0
  726. package/examples/jsm/shaders/ConvolutionShader.js +101 -0
  727. package/examples/jsm/shaders/CopyShader.js +43 -0
  728. package/examples/jsm/shaders/DOFMipMapShader.js +54 -0
  729. package/examples/jsm/shaders/DepthLimitedBlurShader.js +166 -0
  730. package/examples/jsm/shaders/DigitalGlitch.js +101 -0
  731. package/examples/jsm/shaders/DotScreenShader.js +68 -0
  732. package/examples/jsm/shaders/FXAAShader.js +286 -0
  733. package/examples/jsm/shaders/FilmShader.js +100 -0
  734. package/examples/jsm/shaders/FocusShader.js +87 -0
  735. package/examples/jsm/shaders/FreiChenShader.js +94 -0
  736. package/examples/jsm/shaders/GammaCorrectionShader.js +41 -0
  737. package/examples/jsm/shaders/GodRaysShader.js +313 -0
  738. package/examples/jsm/shaders/HalftoneShader.js +310 -0
  739. package/examples/jsm/shaders/HorizontalBlurShader.js +57 -0
  740. package/examples/jsm/shaders/HorizontalTiltShiftShader.js +61 -0
  741. package/examples/jsm/shaders/HueSaturationShader.js +65 -0
  742. package/examples/jsm/shaders/KaleidoShader.js +56 -0
  743. package/examples/jsm/shaders/LuminosityHighPassShader.js +64 -0
  744. package/examples/jsm/shaders/LuminosityShader.js +46 -0
  745. package/examples/jsm/shaders/MMDToonShader.js +123 -0
  746. package/examples/jsm/shaders/MirrorShader.js +54 -0
  747. package/examples/jsm/shaders/NormalMapShader.js +53 -0
  748. package/examples/jsm/shaders/PixelShader.js +44 -0
  749. package/examples/jsm/shaders/RGBShiftShader.js +52 -0
  750. package/examples/jsm/shaders/SAOShader.js +188 -0
  751. package/examples/jsm/shaders/SMAAShader.js +460 -0
  752. package/examples/jsm/shaders/SSAOShader.js +288 -0
  753. package/examples/jsm/shaders/SSRShader.js +364 -0
  754. package/examples/jsm/shaders/SepiaShader.js +50 -0
  755. package/examples/jsm/shaders/SobelOperatorShader.js +90 -0
  756. package/examples/jsm/shaders/SubsurfaceScatteringShader.js +88 -0
  757. package/examples/jsm/shaders/TechnicolorShader.js +43 -0
  758. package/examples/jsm/shaders/ToneMapShader.js +73 -0
  759. package/examples/jsm/shaders/ToonShader.js +318 -0
  760. package/examples/jsm/shaders/TriangleBlurShader.js +72 -0
  761. package/examples/jsm/shaders/UnpackDepthRGBAShader.js +45 -0
  762. package/examples/jsm/shaders/VerticalBlurShader.js +57 -0
  763. package/examples/jsm/shaders/VerticalTiltShiftShader.js +61 -0
  764. package/examples/jsm/shaders/VignetteShader.js +49 -0
  765. package/examples/jsm/shaders/VolumeShader.js +289 -0
  766. package/examples/jsm/shaders/WaterRefractionShader.js +90 -0
  767. package/examples/jsm/textures/FlakesTexture.js +40 -0
  768. package/examples/jsm/utils/BufferGeometryUtils.js +1222 -0
  769. package/examples/jsm/utils/CameraUtils.js +73 -0
  770. package/examples/jsm/utils/GPUStatsPanel.js +128 -0
  771. package/examples/jsm/utils/GeometryCompressionUtils.js +639 -0
  772. package/examples/jsm/utils/GeometryUtils.js +221 -0
  773. package/examples/jsm/utils/LDrawUtils.js +202 -0
  774. package/examples/jsm/utils/PackedPhongMaterial.js +251 -0
  775. package/examples/jsm/utils/SceneUtils.js +125 -0
  776. package/examples/jsm/utils/ShadowMapViewer.js +210 -0
  777. package/examples/jsm/utils/SkeletonUtils.js +596 -0
  778. package/examples/jsm/utils/UVsDebug.js +165 -0
  779. package/examples/jsm/utils/WorkerPool.js +102 -0
  780. package/examples/jsm/webxr/ARButton.js +208 -0
  781. package/examples/jsm/webxr/OculusHandModel.js +108 -0
  782. package/examples/jsm/webxr/OculusHandPointerModel.js +394 -0
  783. package/examples/jsm/webxr/Text2D.js +38 -0
  784. package/examples/jsm/webxr/VRButton.js +201 -0
  785. package/examples/jsm/webxr/XRControllerModelFactory.js +310 -0
  786. package/examples/jsm/webxr/XREstimatedLight.js +223 -0
  787. package/examples/jsm/webxr/XRHandMeshModel.js +108 -0
  788. package/examples/jsm/webxr/XRHandModelFactory.js +105 -0
  789. package/examples/jsm/webxr/XRHandPrimitiveModel.js +103 -0
  790. package/package.json +179 -0
  791. package/src/Three.Legacy.js +320 -0
  792. package/src/Three.js +180 -0
  793. package/src/animation/AnimationAction.js +700 -0
  794. package/src/animation/AnimationClip.js +473 -0
  795. package/src/animation/AnimationMixer.js +770 -0
  796. package/src/animation/AnimationObjectGroup.js +387 -0
  797. package/src/animation/AnimationUtils.js +361 -0
  798. package/src/animation/KeyframeTrack.js +462 -0
  799. package/src/animation/PropertyBinding.js +719 -0
  800. package/src/animation/PropertyMixer.js +318 -0
  801. package/src/animation/tracks/BooleanKeyframeTrack.js +19 -0
  802. package/src/animation/tracks/ColorKeyframeTrack.js +15 -0
  803. package/src/animation/tracks/NumberKeyframeTrack.js +12 -0
  804. package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -0
  805. package/src/animation/tracks/StringKeyframeTrack.js +15 -0
  806. package/src/animation/tracks/VectorKeyframeTrack.js +12 -0
  807. package/src/audio/Audio.js +391 -0
  808. package/src/audio/AudioAnalyser.js +40 -0
  809. package/src/audio/AudioContext.js +25 -0
  810. package/src/audio/AudioListener.js +137 -0
  811. package/src/audio/PositionalAudio.js +138 -0
  812. package/src/cameras/ArrayCamera.js +17 -0
  813. package/src/cameras/Camera.js +68 -0
  814. package/src/cameras/CubeCamera.js +107 -0
  815. package/src/cameras/OrthographicCamera.js +136 -0
  816. package/src/cameras/PerspectiveCamera.js +233 -0
  817. package/src/cameras/StereoCamera.js +100 -0
  818. package/src/constants.js +181 -0
  819. package/src/core/BufferAttribute.js +493 -0
  820. package/src/core/BufferGeometry.js +1092 -0
  821. package/src/core/Clock.js +74 -0
  822. package/src/core/EventDispatcher.js +87 -0
  823. package/src/core/GLBufferAttribute.js +58 -0
  824. package/src/core/InstancedBufferAttribute.js +39 -0
  825. package/src/core/InstancedBufferGeometry.js +46 -0
  826. package/src/core/InstancedInterleavedBuffer.js +48 -0
  827. package/src/core/InterleavedBuffer.js +145 -0
  828. package/src/core/InterleavedBufferAttribute.js +331 -0
  829. package/src/core/Layers.js +60 -0
  830. package/src/core/Object3D.js +944 -0
  831. package/src/core/Raycaster.js +110 -0
  832. package/src/core/Uniform.js +17 -0
  833. package/src/core/UniformsGroup.js +92 -0
  834. package/src/extras/DataUtils.js +170 -0
  835. package/src/extras/Earcut.js +789 -0
  836. package/src/extras/ImageUtils.js +129 -0
  837. package/src/extras/PMREMGenerator.js +900 -0
  838. package/src/extras/ShapeUtils.js +92 -0
  839. package/src/extras/core/Curve.js +416 -0
  840. package/src/extras/core/CurvePath.js +252 -0
  841. package/src/extras/core/Interpolations.js +79 -0
  842. package/src/extras/core/Path.js +196 -0
  843. package/src/extras/core/Shape.js +102 -0
  844. package/src/extras/core/ShapePath.js +291 -0
  845. package/src/extras/curves/ArcCurve.js +17 -0
  846. package/src/extras/curves/CatmullRomCurve3.js +255 -0
  847. package/src/extras/curves/CubicBezierCurve.js +78 -0
  848. package/src/extras/curves/CubicBezierCurve3.js +79 -0
  849. package/src/extras/curves/Curves.js +10 -0
  850. package/src/extras/curves/EllipseCurve.js +156 -0
  851. package/src/extras/curves/LineCurve.js +90 -0
  852. package/src/extras/curves/LineCurve3.js +75 -0
  853. package/src/extras/curves/QuadraticBezierCurve.js +74 -0
  854. package/src/extras/curves/QuadraticBezierCurve3.js +75 -0
  855. package/src/extras/curves/SplineCurve.js +97 -0
  856. package/src/geometries/BoxGeometry.js +170 -0
  857. package/src/geometries/CapsuleGeometry.js +33 -0
  858. package/src/geometries/CircleGeometry.js +91 -0
  859. package/src/geometries/ConeGeometry.js +31 -0
  860. package/src/geometries/CylinderGeometry.js +276 -0
  861. package/src/geometries/DodecahedronGeometry.js +66 -0
  862. package/src/geometries/EdgesGeometry.js +142 -0
  863. package/src/geometries/ExtrudeGeometry.js +804 -0
  864. package/src/geometries/Geometries.js +21 -0
  865. package/src/geometries/IcosahedronGeometry.js +42 -0
  866. package/src/geometries/LatheGeometry.js +179 -0
  867. package/src/geometries/OctahedronGeometry.js +37 -0
  868. package/src/geometries/PlaneGeometry.js +88 -0
  869. package/src/geometries/PolyhedronGeometry.js +309 -0
  870. package/src/geometries/RingGeometry.js +118 -0
  871. package/src/geometries/ShapeGeometry.js +185 -0
  872. package/src/geometries/SphereGeometry.js +127 -0
  873. package/src/geometries/TetrahedronGeometry.js +34 -0
  874. package/src/geometries/TorusGeometry.js +110 -0
  875. package/src/geometries/TorusKnotGeometry.js +157 -0
  876. package/src/geometries/TubeGeometry.js +193 -0
  877. package/src/geometries/WireframeGeometry.js +137 -0
  878. package/src/helpers/ArrowHelper.js +114 -0
  879. package/src/helpers/AxesHelper.js +68 -0
  880. package/src/helpers/Box3Helper.js +56 -0
  881. package/src/helpers/BoxHelper.js +113 -0
  882. package/src/helpers/CameraHelper.js +269 -0
  883. package/src/helpers/DirectionalLightHelper.js +89 -0
  884. package/src/helpers/GridHelper.js +56 -0
  885. package/src/helpers/HemisphereLightHelper.js +85 -0
  886. package/src/helpers/PlaneHelper.js +63 -0
  887. package/src/helpers/PointLightHelper.js +91 -0
  888. package/src/helpers/PolarGridHelper.js +96 -0
  889. package/src/helpers/SkeletonHelper.js +128 -0
  890. package/src/helpers/SpotLightHelper.js +92 -0
  891. package/src/lights/AmbientLight.js +17 -0
  892. package/src/lights/AmbientLightProbe.js +21 -0
  893. package/src/lights/DirectionalLight.js +43 -0
  894. package/src/lights/DirectionalLightShadow.js +16 -0
  895. package/src/lights/HemisphereLight.js +34 -0
  896. package/src/lights/HemisphereLightProbe.js +30 -0
  897. package/src/lights/Light.js +58 -0
  898. package/src/lights/LightProbe.js +47 -0
  899. package/src/lights/LightShadow.js +147 -0
  900. package/src/lights/PointLight.js +57 -0
  901. package/src/lights/PointLightShadow.js +96 -0
  902. package/src/lights/RectAreaLight.js +56 -0
  903. package/src/lights/SpotLight.js +71 -0
  904. package/src/lights/SpotLightShadow.js +50 -0
  905. package/src/loaders/AnimationLoader.js +66 -0
  906. package/src/loaders/AudioLoader.js +60 -0
  907. package/src/loaders/BufferGeometryLoader.js +224 -0
  908. package/src/loaders/Cache.js +42 -0
  909. package/src/loaders/CompressedTextureLoader.js +134 -0
  910. package/src/loaders/CubeTextureLoader.js +56 -0
  911. package/src/loaders/DataTextureLoader.js +114 -0
  912. package/src/loaders/FileLoader.js +281 -0
  913. package/src/loaders/ImageBitmapLoader.js +99 -0
  914. package/src/loaders/ImageLoader.js +91 -0
  915. package/src/loaders/Loader.js +70 -0
  916. package/src/loaders/LoaderUtils.js +75 -0
  917. package/src/loaders/LoadingManager.js +142 -0
  918. package/src/loaders/MaterialLoader.js +355 -0
  919. package/src/loaders/ObjectLoader.js +1081 -0
  920. package/src/loaders/TextureLoader.js +41 -0
  921. package/src/materials/LineBasicMaterial.js +45 -0
  922. package/src/materials/LineDashedMaterial.js +35 -0
  923. package/src/materials/Material.js +493 -0
  924. package/src/materials/Materials.js +39 -0
  925. package/src/materials/MeshBasicMaterial.js +81 -0
  926. package/src/materials/MeshDepthMaterial.js +54 -0
  927. package/src/materials/MeshDistanceMaterial.js +52 -0
  928. package/src/materials/MeshLambertMaterial.js +116 -0
  929. package/src/materials/MeshMatcapMaterial.js +81 -0
  930. package/src/materials/MeshNormalMaterial.js +61 -0
  931. package/src/materials/MeshPhongMaterial.js +120 -0
  932. package/src/materials/MeshPhysicalMaterial.js +198 -0
  933. package/src/materials/MeshStandardMaterial.js +124 -0
  934. package/src/materials/MeshToonMaterial.js +102 -0
  935. package/src/materials/PointsMaterial.js +50 -0
  936. package/src/materials/RawShaderMaterial.js +17 -0
  937. package/src/materials/ShaderMaterial.js +182 -0
  938. package/src/materials/ShadowMaterial.js +37 -0
  939. package/src/materials/SpriteMaterial.js +54 -0
  940. package/src/math/Box2.js +203 -0
  941. package/src/math/Box3.js +532 -0
  942. package/src/math/Color.js +605 -0
  943. package/src/math/ColorManagement.js +74 -0
  944. package/src/math/Cylindrical.js +61 -0
  945. package/src/math/Euler.js +324 -0
  946. package/src/math/Frustum.js +162 -0
  947. package/src/math/Interpolant.js +241 -0
  948. package/src/math/Line3.js +115 -0
  949. package/src/math/MathUtils.js +321 -0
  950. package/src/math/Matrix3.js +333 -0
  951. package/src/math/Matrix4.js +860 -0
  952. package/src/math/Plane.js +205 -0
  953. package/src/math/Quaternion.js +678 -0
  954. package/src/math/Ray.js +496 -0
  955. package/src/math/Sphere.js +250 -0
  956. package/src/math/Spherical.js +86 -0
  957. package/src/math/SphericalHarmonics3.js +243 -0
  958. package/src/math/Triangle.js +299 -0
  959. package/src/math/Vector2.js +464 -0
  960. package/src/math/Vector3.js +715 -0
  961. package/src/math/Vector4.js +644 -0
  962. package/src/math/interpolants/CubicInterpolant.js +151 -0
  963. package/src/math/interpolants/DiscreteInterpolant.js +26 -0
  964. package/src/math/interpolants/LinearInterpolant.js +38 -0
  965. package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -0
  966. package/src/objects/Bone.js +17 -0
  967. package/src/objects/Group.js +17 -0
  968. package/src/objects/InstancedMesh.js +126 -0
  969. package/src/objects/LOD.js +195 -0
  970. package/src/objects/Line.js +222 -0
  971. package/src/objects/LineLoop.js +17 -0
  972. package/src/objects/LineSegments.js +55 -0
  973. package/src/objects/Mesh.js +397 -0
  974. package/src/objects/Points.js +166 -0
  975. package/src/objects/Skeleton.js +281 -0
  976. package/src/objects/SkinnedMesh.js +151 -0
  977. package/src/objects/Sprite.js +181 -0
  978. package/src/renderers/WebGL1Renderer.js +7 -0
  979. package/src/renderers/WebGL3DRenderTarget.js +22 -0
  980. package/src/renderers/WebGLArrayRenderTarget.js +22 -0
  981. package/src/renderers/WebGLCubeRenderTarget.js +146 -0
  982. package/src/renderers/WebGLMultipleRenderTargets.js +82 -0
  983. package/src/renderers/WebGLRenderTarget.js +110 -0
  984. package/src/renderers/WebGLRenderer.js +2280 -0
  985. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
  986. package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
  987. package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +7 -0
  988. package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
  989. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +18 -0
  990. package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
  991. package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +3 -0
  992. package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
  993. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +304 -0
  994. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +42 -0
  995. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
  996. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +18 -0
  997. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
  998. package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +33 -0
  999. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
  1000. package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
  1001. package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
  1002. package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -0
  1003. package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -0
  1004. package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -0
  1005. package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -0
  1006. package/src/renderers/shaders/ShaderChunk/common.glsl.js +118 -0
  1007. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +191 -0
  1008. package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
  1009. package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
  1010. package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +36 -0
  1011. package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
  1012. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
  1013. package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
  1014. package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
  1015. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -0
  1016. package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
  1017. package/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js +3 -0
  1018. package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +11 -0
  1019. package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
  1020. package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +66 -0
  1021. package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
  1022. package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
  1023. package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +46 -0
  1024. package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
  1025. package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
  1026. package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
  1027. package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
  1028. package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
  1029. package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
  1030. package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +121 -0
  1031. package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
  1032. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -0
  1033. package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
  1034. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +199 -0
  1035. package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -0
  1036. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +32 -0
  1037. package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
  1038. package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
  1039. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +223 -0
  1040. package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
  1041. package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +34 -0
  1042. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +120 -0
  1043. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +264 -0
  1044. package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
  1045. package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +28 -0
  1046. package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
  1047. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
  1048. package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -0
  1049. package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -0
  1050. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
  1051. package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
  1052. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +19 -0
  1053. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +19 -0
  1054. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
  1055. package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
  1056. package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
  1057. package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -0
  1058. package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -0
  1059. package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -0
  1060. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +46 -0
  1061. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +41 -0
  1062. package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
  1063. package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
  1064. package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
  1065. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
  1066. package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +12 -0
  1067. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +54 -0
  1068. package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -0
  1069. package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +13 -0
  1070. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
  1071. package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
  1072. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +321 -0
  1073. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -0
  1074. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +63 -0
  1075. package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
  1076. package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
  1077. package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +33 -0
  1078. package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
  1079. package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
  1080. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
  1081. package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
  1082. package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
  1083. package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +77 -0
  1084. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
  1085. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +116 -0
  1086. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +7 -0
  1087. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +10 -0
  1088. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +7 -0
  1089. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +7 -0
  1090. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +17 -0
  1091. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +7 -0
  1092. package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +15 -0
  1093. package/src/renderers/shaders/ShaderChunk.js +265 -0
  1094. package/src/renderers/shaders/ShaderLib/background.glsl.js +35 -0
  1095. package/src/renderers/shaders/ShaderLib/cube.glsl.js +38 -0
  1096. package/src/renderers/shaders/ShaderLib/depth.glsl.js +92 -0
  1097. package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +73 -0
  1098. package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
  1099. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +70 -0
  1100. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +115 -0
  1101. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +123 -0
  1102. package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +107 -0
  1103. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +82 -0
  1104. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +125 -0
  1105. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +216 -0
  1106. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +117 -0
  1107. package/src/renderers/shaders/ShaderLib/points.glsl.js +71 -0
  1108. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +49 -0
  1109. package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
  1110. package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -0
  1111. package/src/renderers/shaders/ShaderLib.js +331 -0
  1112. package/src/renderers/shaders/UniformsLib.js +218 -0
  1113. package/src/renderers/shaders/UniformsUtils.js +80 -0
  1114. package/src/renderers/webgl/WebGLAnimation.js +53 -0
  1115. package/src/renderers/webgl/WebGLAttributes.js +193 -0
  1116. package/src/renderers/webgl/WebGLBackground.js +228 -0
  1117. package/src/renderers/webgl/WebGLBindingStates.js +623 -0
  1118. package/src/renderers/webgl/WebGLBufferRenderer.js +61 -0
  1119. package/src/renderers/webgl/WebGLCapabilities.js +121 -0
  1120. package/src/renderers/webgl/WebGLClipping.js +167 -0
  1121. package/src/renderers/webgl/WebGLCubeMaps.js +99 -0
  1122. package/src/renderers/webgl/WebGLCubeUVMaps.js +130 -0
  1123. package/src/renderers/webgl/WebGLExtensions.js +96 -0
  1124. package/src/renderers/webgl/WebGLGeometries.js +195 -0
  1125. package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +71 -0
  1126. package/src/renderers/webgl/WebGLInfo.js +72 -0
  1127. package/src/renderers/webgl/WebGLLights.js +574 -0
  1128. package/src/renderers/webgl/WebGLMaterials.js +677 -0
  1129. package/src/renderers/webgl/WebGLMorphtargets.js +300 -0
  1130. package/src/renderers/webgl/WebGLObjects.js +72 -0
  1131. package/src/renderers/webgl/WebGLProgram.js +901 -0
  1132. package/src/renderers/webgl/WebGLPrograms.js +542 -0
  1133. package/src/renderers/webgl/WebGLProperties.js +48 -0
  1134. package/src/renderers/webgl/WebGLRenderLists.js +238 -0
  1135. package/src/renderers/webgl/WebGLRenderStates.js +107 -0
  1136. package/src/renderers/webgl/WebGLShader.js +12 -0
  1137. package/src/renderers/webgl/WebGLShaderCache.js +124 -0
  1138. package/src/renderers/webgl/WebGLShadowMap.js +374 -0
  1139. package/src/renderers/webgl/WebGLState.js +1263 -0
  1140. package/src/renderers/webgl/WebGLTextures.js +1944 -0
  1141. package/src/renderers/webgl/WebGLUniforms.js +1050 -0
  1142. package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
  1143. package/src/renderers/webgl/WebGLUtils.js +266 -0
  1144. package/src/renderers/webxr/WebXRController.js +307 -0
  1145. package/src/renderers/webxr/WebXRManager.js +731 -0
  1146. package/src/scenes/Fog.js +37 -0
  1147. package/src/scenes/FogExp2.js +34 -0
  1148. package/src/scenes/Scene.js +71 -0
  1149. package/src/textures/CanvasTexture.js +17 -0
  1150. package/src/textures/CompressedTexture.js +28 -0
  1151. package/src/textures/CubeTexture.js +33 -0
  1152. package/src/textures/Data3DTexture.js +35 -0
  1153. package/src/textures/DataArrayTexture.js +27 -0
  1154. package/src/textures/DataTexture.js +22 -0
  1155. package/src/textures/DepthTexture.js +36 -0
  1156. package/src/textures/FramebufferTexture.js +25 -0
  1157. package/src/textures/Source.js +123 -0
  1158. package/src/textures/Texture.js +308 -0
  1159. package/src/textures/VideoTexture.js +55 -0
  1160. package/src/utils.js +71 -0
@@ -0,0 +1,2374 @@
1
+ ( function () {
2
+
3
+ // Note: "MATERIAL" tag (e.g. GLITTER, SPECKLE) is not implemented
4
+
5
+ const FINISH_TYPE_DEFAULT = 0;
6
+ const FINISH_TYPE_CHROME = 1;
7
+ const FINISH_TYPE_PEARLESCENT = 2;
8
+ const FINISH_TYPE_RUBBER = 3;
9
+ const FINISH_TYPE_MATTE_METALLIC = 4;
10
+ const FINISH_TYPE_METAL = 5; // State machine to search a subobject path.
11
+ // The LDraw standard establishes these various possible subfolders.
12
+
13
+ const FILE_LOCATION_TRY_PARTS = 0;
14
+ const FILE_LOCATION_TRY_P = 1;
15
+ const FILE_LOCATION_TRY_MODELS = 2;
16
+ const FILE_LOCATION_AS_IS = 3;
17
+ const FILE_LOCATION_TRY_RELATIVE = 4;
18
+ const FILE_LOCATION_TRY_ABSOLUTE = 5;
19
+ const FILE_LOCATION_NOT_FOUND = 6;
20
+ const MAIN_COLOUR_CODE = '16';
21
+ const MAIN_EDGE_COLOUR_CODE = '24';
22
+
23
+ const _tempVec0 = new THREE.Vector3();
24
+
25
+ const _tempVec1 = new THREE.Vector3();
26
+
27
+ class LDrawConditionalLineMaterial extends THREE.ShaderMaterial {
28
+
29
+ constructor( parameters ) {
30
+
31
+ super( {
32
+ uniforms: THREE.UniformsUtils.merge( [ THREE.UniformsLib.fog, {
33
+ diffuse: {
34
+ value: new THREE.Color()
35
+ },
36
+ opacity: {
37
+ value: 1.0
38
+ }
39
+ } ] ),
40
+ vertexShader:
41
+ /* glsl */
42
+ `
43
+ attribute vec3 control0;
44
+ attribute vec3 control1;
45
+ attribute vec3 direction;
46
+ varying float discardFlag;
47
+
48
+ #include <common>
49
+ #include <color_pars_vertex>
50
+ #include <fog_pars_vertex>
51
+ #include <logdepthbuf_pars_vertex>
52
+ #include <clipping_planes_pars_vertex>
53
+ void main() {
54
+ #include <color_vertex>
55
+
56
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
57
+ gl_Position = projectionMatrix * mvPosition;
58
+
59
+ // Transform the line segment ends and control points into camera clip space
60
+ vec4 c0 = projectionMatrix * modelViewMatrix * vec4( control0, 1.0 );
61
+ vec4 c1 = projectionMatrix * modelViewMatrix * vec4( control1, 1.0 );
62
+ vec4 p0 = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
63
+ vec4 p1 = projectionMatrix * modelViewMatrix * vec4( position + direction, 1.0 );
64
+
65
+ c0.xy /= c0.w;
66
+ c1.xy /= c1.w;
67
+ p0.xy /= p0.w;
68
+ p1.xy /= p1.w;
69
+
70
+ // Get the direction of the segment and an orthogonal vector
71
+ vec2 dir = p1.xy - p0.xy;
72
+ vec2 norm = vec2( -dir.y, dir.x );
73
+
74
+ // Get control point directions from the line
75
+ vec2 c0dir = c0.xy - p1.xy;
76
+ vec2 c1dir = c1.xy - p1.xy;
77
+
78
+ // If the vectors to the controls points are pointed in different directions away
79
+ // from the line segment then the line should not be drawn.
80
+ float d0 = dot( normalize( norm ), normalize( c0dir ) );
81
+ float d1 = dot( normalize( norm ), normalize( c1dir ) );
82
+ discardFlag = float( sign( d0 ) != sign( d1 ) );
83
+
84
+ #include <logdepthbuf_vertex>
85
+ #include <clipping_planes_vertex>
86
+ #include <fog_vertex>
87
+ }
88
+ `,
89
+ fragmentShader:
90
+ /* glsl */
91
+ `
92
+ uniform vec3 diffuse;
93
+ uniform float opacity;
94
+ varying float discardFlag;
95
+
96
+ #include <common>
97
+ #include <color_pars_fragment>
98
+ #include <fog_pars_fragment>
99
+ #include <logdepthbuf_pars_fragment>
100
+ #include <clipping_planes_pars_fragment>
101
+ void main() {
102
+
103
+ if ( discardFlag > 0.5 ) discard;
104
+
105
+ #include <clipping_planes_fragment>
106
+ vec3 outgoingLight = vec3( 0.0 );
107
+ vec4 diffuseColor = vec4( diffuse, opacity );
108
+ #include <logdepthbuf_fragment>
109
+ #include <color_fragment>
110
+ outgoingLight = diffuseColor.rgb; // simple shader
111
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );
112
+ #include <tonemapping_fragment>
113
+ #include <encodings_fragment>
114
+ #include <fog_fragment>
115
+ #include <premultiplied_alpha_fragment>
116
+ }
117
+ `
118
+ } );
119
+ Object.defineProperties( this, {
120
+ opacity: {
121
+ get: function () {
122
+
123
+ return this.uniforms.opacity.value;
124
+
125
+ },
126
+ set: function ( value ) {
127
+
128
+ this.uniforms.opacity.value = value;
129
+
130
+ }
131
+ },
132
+ color: {
133
+ get: function () {
134
+
135
+ return this.uniforms.diffuse.value;
136
+
137
+ }
138
+ }
139
+ } );
140
+ this.setValues( parameters );
141
+ this.isLDrawConditionalLineMaterial = true;
142
+
143
+ }
144
+
145
+ }
146
+
147
+ class ConditionalLineSegments extends THREE.LineSegments {
148
+
149
+ constructor( geometry, material ) {
150
+
151
+ super( geometry, material );
152
+ this.isConditionalLine = true;
153
+
154
+ }
155
+
156
+ }
157
+
158
+ function generateFaceNormals( faces ) {
159
+
160
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
161
+
162
+ const face = faces[ i ];
163
+ const vertices = face.vertices;
164
+ const v0 = vertices[ 0 ];
165
+ const v1 = vertices[ 1 ];
166
+ const v2 = vertices[ 2 ];
167
+
168
+ _tempVec0.subVectors( v1, v0 );
169
+
170
+ _tempVec1.subVectors( v2, v1 );
171
+
172
+ face.faceNormal = new THREE.Vector3().crossVectors( _tempVec0, _tempVec1 ).normalize();
173
+
174
+ }
175
+
176
+ }
177
+
178
+ const _ray = new THREE.Ray();
179
+
180
+ function smoothNormals( faces, lineSegments, checkSubSegments = false ) {
181
+
182
+ // NOTE: 1e2 is pretty coarse but was chosen to quantize the resulting value because
183
+ // it allows edges to be smoothed as expected (see minifig arms).
184
+ // --
185
+ // And the vector values are initialize multiplied by 1 + 1e-10 to account for floating
186
+ // point errors on vertices along quantization boundaries. Ie after matrix multiplication
187
+ // vertices that should be merged might be set to "1.7" and "1.6999..." meaning they won't
188
+ // get merged. This added epsilon attempts to push these error values to the same quantized
189
+ // value for the sake of hashing. See "AT-ST mini" dishes. See mrdoob/three#23169.
190
+ const hashMultiplier = ( 1 + 1e-10 ) * 1e2;
191
+
192
+ function hashVertex( v ) {
193
+
194
+ const x = ~ ~ ( v.x * hashMultiplier );
195
+ const y = ~ ~ ( v.y * hashMultiplier );
196
+ const z = ~ ~ ( v.z * hashMultiplier );
197
+ return `${x},${y},${z}`;
198
+
199
+ }
200
+
201
+ function hashEdge( v0, v1 ) {
202
+
203
+ return `${hashVertex( v0 )}_${hashVertex( v1 )}`;
204
+
205
+ } // converts the two vertices to a ray with a normalized direction and origin of 0, 0, 0 projected
206
+ // onto the original line.
207
+
208
+
209
+ function toNormalizedRay( v0, v1, targetRay ) {
210
+
211
+ targetRay.direction.subVectors( v1, v0 ).normalize();
212
+ const scalar = v0.dot( targetRay.direction );
213
+ targetRay.origin.copy( v0 ).addScaledVector( targetRay.direction, - scalar );
214
+ return targetRay;
215
+
216
+ }
217
+
218
+ function hashRay( ray ) {
219
+
220
+ return hashEdge( ray.origin, ray.direction );
221
+
222
+ }
223
+
224
+ const hardEdges = new Set();
225
+ const hardEdgeRays = new Map();
226
+ const halfEdgeList = {};
227
+ const normals = []; // Save the list of hard edges by hash
228
+
229
+ for ( let i = 0, l = lineSegments.length; i < l; i ++ ) {
230
+
231
+ const ls = lineSegments[ i ];
232
+ const vertices = ls.vertices;
233
+ const v0 = vertices[ 0 ];
234
+ const v1 = vertices[ 1 ];
235
+ hardEdges.add( hashEdge( v0, v1 ) );
236
+ hardEdges.add( hashEdge( v1, v0 ) ); // only generate the hard edge ray map if we're checking subsegments because it's more expensive to check
237
+ // and requires more memory.
238
+
239
+ if ( checkSubSegments ) {
240
+
241
+ // add both ray directions to the map
242
+ const ray = toNormalizedRay( v0, v1, new THREE.Ray() );
243
+ const rh1 = hashRay( ray );
244
+
245
+ if ( ! hardEdgeRays.has( rh1 ) ) {
246
+
247
+ toNormalizedRay( v1, v0, ray );
248
+ const rh2 = hashRay( ray );
249
+ const info = {
250
+ ray,
251
+ distances: []
252
+ };
253
+ hardEdgeRays.set( rh1, info );
254
+ hardEdgeRays.set( rh2, info );
255
+
256
+ } // store both segments ends in min, max order in the distances array to check if a face edge is a
257
+ // subsegment later.
258
+
259
+
260
+ const info = hardEdgeRays.get( rh1 );
261
+ let d0 = info.ray.direction.dot( v0 );
262
+ let d1 = info.ray.direction.dot( v1 );
263
+
264
+ if ( d0 > d1 ) {
265
+
266
+ [ d0, d1 ] = [ d1, d0 ];
267
+
268
+ }
269
+
270
+ info.distances.push( d0, d1 );
271
+
272
+ }
273
+
274
+ } // track the half edges associated with each triangle
275
+
276
+
277
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
278
+
279
+ const tri = faces[ i ];
280
+ const vertices = tri.vertices;
281
+ const vertCount = vertices.length;
282
+
283
+ for ( let i2 = 0; i2 < vertCount; i2 ++ ) {
284
+
285
+ const index = i2;
286
+ const next = ( i2 + 1 ) % vertCount;
287
+ const v0 = vertices[ index ];
288
+ const v1 = vertices[ next ];
289
+ const hash = hashEdge( v0, v1 ); // don't add the triangle if the edge is supposed to be hard
290
+
291
+ if ( hardEdges.has( hash ) ) {
292
+
293
+ continue;
294
+
295
+ } // if checking subsegments then check to see if this edge lies on a hard edge ray and whether its within any ray bounds
296
+
297
+
298
+ if ( checkSubSegments ) {
299
+
300
+ toNormalizedRay( v0, v1, _ray );
301
+ const rayHash = hashRay( _ray );
302
+
303
+ if ( hardEdgeRays.has( rayHash ) ) {
304
+
305
+ const info = hardEdgeRays.get( rayHash );
306
+ const {
307
+ ray,
308
+ distances
309
+ } = info;
310
+ let d0 = ray.direction.dot( v0 );
311
+ let d1 = ray.direction.dot( v1 );
312
+
313
+ if ( d0 > d1 ) {
314
+
315
+ [ d0, d1 ] = [ d1, d0 ];
316
+
317
+ } // return early if the face edge is found to be a subsegment of a line edge meaning the edge will have "hard" normals
318
+
319
+
320
+ let found = false;
321
+
322
+ for ( let i = 0, l = distances.length; i < l; i += 2 ) {
323
+
324
+ if ( d0 >= distances[ i ] && d1 <= distances[ i + 1 ] ) {
325
+
326
+ found = true;
327
+ break;
328
+
329
+ }
330
+
331
+ }
332
+
333
+ if ( found ) {
334
+
335
+ continue;
336
+
337
+ }
338
+
339
+ }
340
+
341
+ }
342
+
343
+ const info = {
344
+ index: index,
345
+ tri: tri
346
+ };
347
+ halfEdgeList[ hash ] = info;
348
+
349
+ }
350
+
351
+ } // Iterate until we've tried to connect all faces to share normals
352
+
353
+
354
+ while ( true ) {
355
+
356
+ // Stop if there are no more faces left
357
+ let halfEdge = null;
358
+
359
+ for ( const key in halfEdgeList ) {
360
+
361
+ halfEdge = halfEdgeList[ key ];
362
+ break;
363
+
364
+ }
365
+
366
+ if ( halfEdge === null ) {
367
+
368
+ break;
369
+
370
+ } // Exhaustively find all connected faces
371
+
372
+
373
+ const queue = [ halfEdge ];
374
+
375
+ while ( queue.length > 0 ) {
376
+
377
+ // initialize all vertex normals in this triangle
378
+ const tri = queue.pop().tri;
379
+ const vertices = tri.vertices;
380
+ const vertNormals = tri.normals;
381
+ const faceNormal = tri.faceNormal; // Check if any edge is connected to another triangle edge
382
+
383
+ const vertCount = vertices.length;
384
+
385
+ for ( let i2 = 0; i2 < vertCount; i2 ++ ) {
386
+
387
+ const index = i2;
388
+ const next = ( i2 + 1 ) % vertCount;
389
+ const v0 = vertices[ index ];
390
+ const v1 = vertices[ next ]; // delete this triangle from the list so it won't be found again
391
+
392
+ const hash = hashEdge( v0, v1 );
393
+ delete halfEdgeList[ hash ];
394
+ const reverseHash = hashEdge( v1, v0 );
395
+ const otherInfo = halfEdgeList[ reverseHash ];
396
+
397
+ if ( otherInfo ) {
398
+
399
+ const otherTri = otherInfo.tri;
400
+ const otherIndex = otherInfo.index;
401
+ const otherNormals = otherTri.normals;
402
+ const otherVertCount = otherNormals.length;
403
+ const otherFaceNormal = otherTri.faceNormal; // NOTE: If the angle between faces is > 67.5 degrees then assume it's
404
+ // hard edge. There are some cases where the line segments do not line up exactly
405
+ // with or span multiple triangle edges (see Lunar Vehicle wheels).
406
+
407
+ if ( Math.abs( otherTri.faceNormal.dot( tri.faceNormal ) ) < 0.25 ) {
408
+
409
+ continue;
410
+
411
+ } // if this triangle has already been traversed then it won't be in
412
+ // the halfEdgeList. If it has not then add it to the queue and delete
413
+ // it so it won't be found again.
414
+
415
+
416
+ if ( reverseHash in halfEdgeList ) {
417
+
418
+ queue.push( otherInfo );
419
+ delete halfEdgeList[ reverseHash ];
420
+
421
+ } // share the first normal
422
+
423
+
424
+ const otherNext = ( otherIndex + 1 ) % otherVertCount;
425
+
426
+ if ( vertNormals[ index ] && otherNormals[ otherNext ] && vertNormals[ index ] !== otherNormals[ otherNext ] ) {
427
+
428
+ otherNormals[ otherNext ].norm.add( vertNormals[ index ].norm );
429
+ vertNormals[ index ].norm = otherNormals[ otherNext ].norm;
430
+
431
+ }
432
+
433
+ let sharedNormal1 = vertNormals[ index ] || otherNormals[ otherNext ];
434
+
435
+ if ( sharedNormal1 === null ) {
436
+
437
+ // it's possible to encounter an edge of a triangle that has already been traversed meaning
438
+ // both edges already have different normals defined and shared. To work around this we create
439
+ // a wrapper object so when those edges are merged the normals can be updated everywhere.
440
+ sharedNormal1 = {
441
+ norm: new THREE.Vector3()
442
+ };
443
+ normals.push( sharedNormal1.norm );
444
+
445
+ }
446
+
447
+ if ( vertNormals[ index ] === null ) {
448
+
449
+ vertNormals[ index ] = sharedNormal1;
450
+ sharedNormal1.norm.add( faceNormal );
451
+
452
+ }
453
+
454
+ if ( otherNormals[ otherNext ] === null ) {
455
+
456
+ otherNormals[ otherNext ] = sharedNormal1;
457
+ sharedNormal1.norm.add( otherFaceNormal );
458
+
459
+ } // share the second normal
460
+
461
+
462
+ if ( vertNormals[ next ] && otherNormals[ otherIndex ] && vertNormals[ next ] !== otherNormals[ otherIndex ] ) {
463
+
464
+ otherNormals[ otherIndex ].norm.add( vertNormals[ next ].norm );
465
+ vertNormals[ next ].norm = otherNormals[ otherIndex ].norm;
466
+
467
+ }
468
+
469
+ let sharedNormal2 = vertNormals[ next ] || otherNormals[ otherIndex ];
470
+
471
+ if ( sharedNormal2 === null ) {
472
+
473
+ sharedNormal2 = {
474
+ norm: new THREE.Vector3()
475
+ };
476
+ normals.push( sharedNormal2.norm );
477
+
478
+ }
479
+
480
+ if ( vertNormals[ next ] === null ) {
481
+
482
+ vertNormals[ next ] = sharedNormal2;
483
+ sharedNormal2.norm.add( faceNormal );
484
+
485
+ }
486
+
487
+ if ( otherNormals[ otherIndex ] === null ) {
488
+
489
+ otherNormals[ otherIndex ] = sharedNormal2;
490
+ sharedNormal2.norm.add( otherFaceNormal );
491
+
492
+ }
493
+
494
+ }
495
+
496
+ }
497
+
498
+ }
499
+
500
+ } // The normals of each face have been added up so now we average them by normalizing the vector.
501
+
502
+
503
+ for ( let i = 0, l = normals.length; i < l; i ++ ) {
504
+
505
+ normals[ i ].normalize();
506
+
507
+ }
508
+
509
+ }
510
+
511
+ function isPartType( type ) {
512
+
513
+ return type === 'Part' || type === 'Unofficial_Part';
514
+
515
+ }
516
+
517
+ function isPrimitiveType( type ) {
518
+
519
+ return /primitive/i.test( type ) || type === 'Subpart';
520
+
521
+ }
522
+
523
+ class LineParser {
524
+
525
+ constructor( line, lineNumber ) {
526
+
527
+ this.line = line;
528
+ this.lineLength = line.length;
529
+ this.currentCharIndex = 0;
530
+ this.currentChar = ' ';
531
+ this.lineNumber = lineNumber;
532
+
533
+ }
534
+
535
+ seekNonSpace() {
536
+
537
+ while ( this.currentCharIndex < this.lineLength ) {
538
+
539
+ this.currentChar = this.line.charAt( this.currentCharIndex );
540
+
541
+ if ( this.currentChar !== ' ' && this.currentChar !== '\t' ) {
542
+
543
+ return;
544
+
545
+ }
546
+
547
+ this.currentCharIndex ++;
548
+
549
+ }
550
+
551
+ }
552
+
553
+ getToken() {
554
+
555
+ const pos0 = this.currentCharIndex ++; // Seek space
556
+
557
+ while ( this.currentCharIndex < this.lineLength ) {
558
+
559
+ this.currentChar = this.line.charAt( this.currentCharIndex );
560
+
561
+ if ( this.currentChar === ' ' || this.currentChar === '\t' ) {
562
+
563
+ break;
564
+
565
+ }
566
+
567
+ this.currentCharIndex ++;
568
+
569
+ }
570
+
571
+ const pos1 = this.currentCharIndex;
572
+ this.seekNonSpace();
573
+ return this.line.substring( pos0, pos1 );
574
+
575
+ }
576
+
577
+ getVector() {
578
+
579
+ return new THREE.Vector3( parseFloat( this.getToken() ), parseFloat( this.getToken() ), parseFloat( this.getToken() ) );
580
+
581
+ }
582
+
583
+ getRemainingString() {
584
+
585
+ return this.line.substring( this.currentCharIndex, this.lineLength );
586
+
587
+ }
588
+
589
+ isAtTheEnd() {
590
+
591
+ return this.currentCharIndex >= this.lineLength;
592
+
593
+ }
594
+
595
+ setToEnd() {
596
+
597
+ this.currentCharIndex = this.lineLength;
598
+
599
+ }
600
+
601
+ getLineNumberString() {
602
+
603
+ return this.lineNumber >= 0 ? ' at line ' + this.lineNumber : '';
604
+
605
+ }
606
+
607
+ } // Fetches and parses an intermediate representation of LDraw parts files.
608
+
609
+
610
+ class LDrawParsedCache {
611
+
612
+ constructor( loader ) {
613
+
614
+ this.loader = loader;
615
+ this._cache = {};
616
+
617
+ }
618
+
619
+ cloneResult( original ) {
620
+
621
+ const result = {}; // vertices are transformed and normals computed before being converted to geometry
622
+ // so these pieces must be cloned.
623
+
624
+ result.faces = original.faces.map( face => {
625
+
626
+ return {
627
+ colorCode: face.colorCode,
628
+ material: face.material,
629
+ vertices: face.vertices.map( v => v.clone() ),
630
+ normals: face.normals.map( () => null ),
631
+ faceNormal: null
632
+ };
633
+
634
+ } );
635
+ result.conditionalSegments = original.conditionalSegments.map( face => {
636
+
637
+ return {
638
+ colorCode: face.colorCode,
639
+ material: face.material,
640
+ vertices: face.vertices.map( v => v.clone() ),
641
+ controlPoints: face.controlPoints.map( v => v.clone() )
642
+ };
643
+
644
+ } );
645
+ result.lineSegments = original.lineSegments.map( face => {
646
+
647
+ return {
648
+ colorCode: face.colorCode,
649
+ material: face.material,
650
+ vertices: face.vertices.map( v => v.clone() )
651
+ };
652
+
653
+ } ); // none if this is subsequently modified
654
+
655
+ result.type = original.type;
656
+ result.category = original.category;
657
+ result.keywords = original.keywords;
658
+ result.author = original.author;
659
+ result.subobjects = original.subobjects;
660
+ result.fileName = original.fileName;
661
+ result.totalFaces = original.totalFaces;
662
+ result.startingConstructionStep = original.startingConstructionStep;
663
+ result.materials = original.materials;
664
+ result.group = null;
665
+ return result;
666
+
667
+ }
668
+
669
+ async fetchData( fileName ) {
670
+
671
+ let triedLowerCase = false;
672
+ let locationState = FILE_LOCATION_TRY_PARTS;
673
+
674
+ while ( locationState !== FILE_LOCATION_NOT_FOUND ) {
675
+
676
+ let subobjectURL = fileName;
677
+
678
+ switch ( locationState ) {
679
+
680
+ case FILE_LOCATION_AS_IS:
681
+ locationState = locationState + 1;
682
+ break;
683
+
684
+ case FILE_LOCATION_TRY_PARTS:
685
+ subobjectURL = 'parts/' + subobjectURL;
686
+ locationState = locationState + 1;
687
+ break;
688
+
689
+ case FILE_LOCATION_TRY_P:
690
+ subobjectURL = 'p/' + subobjectURL;
691
+ locationState = locationState + 1;
692
+ break;
693
+
694
+ case FILE_LOCATION_TRY_MODELS:
695
+ subobjectURL = 'models/' + subobjectURL;
696
+ locationState = locationState + 1;
697
+ break;
698
+
699
+ case FILE_LOCATION_TRY_RELATIVE:
700
+ subobjectURL = fileName.substring( 0, fileName.lastIndexOf( '/' ) + 1 ) + subobjectURL;
701
+ locationState = locationState + 1;
702
+ break;
703
+
704
+ case FILE_LOCATION_TRY_ABSOLUTE:
705
+ if ( triedLowerCase ) {
706
+
707
+ // Try absolute path
708
+ locationState = FILE_LOCATION_NOT_FOUND;
709
+
710
+ } else {
711
+
712
+ // Next attempt is lower case
713
+ fileName = fileName.toLowerCase();
714
+ subobjectURL = fileName;
715
+ triedLowerCase = true;
716
+ locationState = FILE_LOCATION_TRY_PARTS;
717
+
718
+ }
719
+
720
+ break;
721
+
722
+ }
723
+
724
+ const loader = this.loader;
725
+ const fileLoader = new THREE.FileLoader( loader.manager );
726
+ fileLoader.setPath( loader.partsLibraryPath );
727
+ fileLoader.setRequestHeader( loader.requestHeader );
728
+ fileLoader.setWithCredentials( loader.withCredentials );
729
+
730
+ try {
731
+
732
+ const text = await fileLoader.loadAsync( subobjectURL );
733
+ return text;
734
+
735
+ } catch {
736
+
737
+ continue;
738
+
739
+ }
740
+
741
+ }
742
+
743
+ throw new Error( 'LDrawLoader: Subobject "' + fileName + '" could not be loaded.' );
744
+
745
+ }
746
+
747
+ parse( text, fileName = null ) {
748
+
749
+ const loader = this.loader; // final results
750
+
751
+ const faces = [];
752
+ const lineSegments = [];
753
+ const conditionalSegments = [];
754
+ const subobjects = [];
755
+ const materials = {};
756
+
757
+ const getLocalMaterial = colorCode => {
758
+
759
+ return materials[ colorCode ] || null;
760
+
761
+ };
762
+
763
+ let type = 'Model';
764
+ let category = null;
765
+ let keywords = null;
766
+ let author = null;
767
+ let totalFaces = 0; // split into lines
768
+
769
+ if ( text.indexOf( '\r\n' ) !== - 1 ) {
770
+
771
+ // This is faster than String.split with regex that splits on both
772
+ text = text.replace( /\r\n/g, '\n' );
773
+
774
+ }
775
+
776
+ const lines = text.split( '\n' );
777
+ const numLines = lines.length;
778
+ let parsingEmbeddedFiles = false;
779
+ let currentEmbeddedFileName = null;
780
+ let currentEmbeddedText = null;
781
+ let bfcCertified = false;
782
+ let bfcCCW = true;
783
+ let bfcInverted = false;
784
+ let bfcCull = true;
785
+ let startingConstructionStep = false; // Parse all line commands
786
+
787
+ for ( let lineIndex = 0; lineIndex < numLines; lineIndex ++ ) {
788
+
789
+ const line = lines[ lineIndex ];
790
+ if ( line.length === 0 ) continue;
791
+
792
+ if ( parsingEmbeddedFiles ) {
793
+
794
+ if ( line.startsWith( '0 FILE ' ) ) {
795
+
796
+ // Save previous embedded file in the cache
797
+ this.setData( currentEmbeddedFileName, currentEmbeddedText ); // New embedded text file
798
+
799
+ currentEmbeddedFileName = line.substring( 7 );
800
+ currentEmbeddedText = '';
801
+
802
+ } else {
803
+
804
+ currentEmbeddedText += line + '\n';
805
+
806
+ }
807
+
808
+ continue;
809
+
810
+ }
811
+
812
+ const lp = new LineParser( line, lineIndex + 1 );
813
+ lp.seekNonSpace();
814
+
815
+ if ( lp.isAtTheEnd() ) {
816
+
817
+ // Empty line
818
+ continue;
819
+
820
+ } // Parse the line type
821
+
822
+
823
+ const lineType = lp.getToken();
824
+ let material;
825
+ let colorCode;
826
+ let segment;
827
+ let ccw;
828
+ let doubleSided;
829
+ let v0, v1, v2, v3, c0, c1;
830
+
831
+ switch ( lineType ) {
832
+
833
+ // Line type 0: Comment or META
834
+ case '0':
835
+ // Parse meta directive
836
+ const meta = lp.getToken();
837
+
838
+ if ( meta ) {
839
+
840
+ switch ( meta ) {
841
+
842
+ case '!LDRAW_ORG':
843
+ type = lp.getToken();
844
+ break;
845
+
846
+ case '!COLOUR':
847
+ material = loader.parseColorMetaDirective( lp );
848
+
849
+ if ( material ) {
850
+
851
+ materials[ material.userData.code ] = material;
852
+
853
+ } else {
854
+
855
+ console.warn( 'LDrawLoader: Error parsing material' + lp.getLineNumberString() );
856
+
857
+ }
858
+
859
+ break;
860
+
861
+ case '!CATEGORY':
862
+ category = lp.getToken();
863
+ break;
864
+
865
+ case '!KEYWORDS':
866
+ const newKeywords = lp.getRemainingString().split( ',' );
867
+
868
+ if ( newKeywords.length > 0 ) {
869
+
870
+ if ( ! keywords ) {
871
+
872
+ keywords = [];
873
+
874
+ }
875
+
876
+ newKeywords.forEach( function ( keyword ) {
877
+
878
+ keywords.push( keyword.trim() );
879
+
880
+ } );
881
+
882
+ }
883
+
884
+ break;
885
+
886
+ case 'FILE':
887
+ if ( lineIndex > 0 ) {
888
+
889
+ // Start embedded text files parsing
890
+ parsingEmbeddedFiles = true;
891
+ currentEmbeddedFileName = lp.getRemainingString();
892
+ currentEmbeddedText = '';
893
+ bfcCertified = false;
894
+ bfcCCW = true;
895
+
896
+ }
897
+
898
+ break;
899
+
900
+ case 'BFC':
901
+ // Changes to the backface culling state
902
+ while ( ! lp.isAtTheEnd() ) {
903
+
904
+ const token = lp.getToken();
905
+
906
+ switch ( token ) {
907
+
908
+ case 'CERTIFY':
909
+ case 'NOCERTIFY':
910
+ bfcCertified = token === 'CERTIFY';
911
+ bfcCCW = true;
912
+ break;
913
+
914
+ case 'CW':
915
+ case 'CCW':
916
+ bfcCCW = token === 'CCW';
917
+ break;
918
+
919
+ case 'INVERTNEXT':
920
+ bfcInverted = true;
921
+ break;
922
+
923
+ case 'CLIP':
924
+ case 'NOCLIP':
925
+ bfcCull = token === 'CLIP';
926
+ break;
927
+
928
+ default:
929
+ console.warn( 'THREE.LDrawLoader: BFC directive "' + token + '" is unknown.' );
930
+ break;
931
+
932
+ }
933
+
934
+ }
935
+
936
+ break;
937
+
938
+ case 'STEP':
939
+ startingConstructionStep = true;
940
+ break;
941
+
942
+ case 'Author:':
943
+ author = lp.getToken();
944
+ break;
945
+
946
+ default:
947
+ // Other meta directives are not implemented
948
+ break;
949
+
950
+ }
951
+
952
+ }
953
+
954
+ break;
955
+ // Line type 1: Sub-object file
956
+
957
+ case '1':
958
+ colorCode = lp.getToken();
959
+ material = getLocalMaterial( colorCode );
960
+ const posX = parseFloat( lp.getToken() );
961
+ const posY = parseFloat( lp.getToken() );
962
+ const posZ = parseFloat( lp.getToken() );
963
+ const m0 = parseFloat( lp.getToken() );
964
+ const m1 = parseFloat( lp.getToken() );
965
+ const m2 = parseFloat( lp.getToken() );
966
+ const m3 = parseFloat( lp.getToken() );
967
+ const m4 = parseFloat( lp.getToken() );
968
+ const m5 = parseFloat( lp.getToken() );
969
+ const m6 = parseFloat( lp.getToken() );
970
+ const m7 = parseFloat( lp.getToken() );
971
+ const m8 = parseFloat( lp.getToken() );
972
+ const matrix = new THREE.Matrix4().set( m0, m1, m2, posX, m3, m4, m5, posY, m6, m7, m8, posZ, 0, 0, 0, 1 );
973
+ let fileName = lp.getRemainingString().trim().replace( /\\/g, '/' );
974
+
975
+ if ( loader.fileMap[ fileName ] ) {
976
+
977
+ // Found the subobject path in the preloaded file path map
978
+ fileName = loader.fileMap[ fileName ];
979
+
980
+ } else {
981
+
982
+ // Standardized subfolders
983
+ if ( fileName.startsWith( 's/' ) ) {
984
+
985
+ fileName = 'parts/' + fileName;
986
+
987
+ } else if ( fileName.startsWith( '48/' ) ) {
988
+
989
+ fileName = 'p/' + fileName;
990
+
991
+ }
992
+
993
+ }
994
+
995
+ subobjects.push( {
996
+ material: material,
997
+ colorCode: colorCode,
998
+ matrix: matrix,
999
+ fileName: fileName,
1000
+ inverted: bfcInverted,
1001
+ startingConstructionStep: startingConstructionStep
1002
+ } );
1003
+ bfcInverted = false;
1004
+ break;
1005
+ // Line type 2: Line segment
1006
+
1007
+ case '2':
1008
+ colorCode = lp.getToken();
1009
+ material = getLocalMaterial( colorCode );
1010
+ v0 = lp.getVector();
1011
+ v1 = lp.getVector();
1012
+ segment = {
1013
+ material: material,
1014
+ colorCode: colorCode,
1015
+ vertices: [ v0, v1 ]
1016
+ };
1017
+ lineSegments.push( segment );
1018
+ break;
1019
+ // Line type 5: Conditional Line segment
1020
+
1021
+ case '5':
1022
+ colorCode = lp.getToken();
1023
+ material = getLocalMaterial( colorCode );
1024
+ v0 = lp.getVector();
1025
+ v1 = lp.getVector();
1026
+ c0 = lp.getVector();
1027
+ c1 = lp.getVector();
1028
+ segment = {
1029
+ material: material,
1030
+ colorCode: colorCode,
1031
+ vertices: [ v0, v1 ],
1032
+ controlPoints: [ c0, c1 ]
1033
+ };
1034
+ conditionalSegments.push( segment );
1035
+ break;
1036
+ // Line type 3: Triangle
1037
+
1038
+ case '3':
1039
+ colorCode = lp.getToken();
1040
+ material = getLocalMaterial( colorCode );
1041
+ ccw = bfcCCW;
1042
+ doubleSided = ! bfcCertified || ! bfcCull;
1043
+
1044
+ if ( ccw === true ) {
1045
+
1046
+ v0 = lp.getVector();
1047
+ v1 = lp.getVector();
1048
+ v2 = lp.getVector();
1049
+
1050
+ } else {
1051
+
1052
+ v2 = lp.getVector();
1053
+ v1 = lp.getVector();
1054
+ v0 = lp.getVector();
1055
+
1056
+ }
1057
+
1058
+ faces.push( {
1059
+ material: material,
1060
+ colorCode: colorCode,
1061
+ faceNormal: null,
1062
+ vertices: [ v0, v1, v2 ],
1063
+ normals: [ null, null, null ]
1064
+ } );
1065
+ totalFaces ++;
1066
+
1067
+ if ( doubleSided === true ) {
1068
+
1069
+ faces.push( {
1070
+ material: material,
1071
+ colorCode: colorCode,
1072
+ faceNormal: null,
1073
+ vertices: [ v2, v1, v0 ],
1074
+ normals: [ null, null, null ]
1075
+ } );
1076
+ totalFaces ++;
1077
+
1078
+ }
1079
+
1080
+ break;
1081
+ // Line type 4: Quadrilateral
1082
+
1083
+ case '4':
1084
+ colorCode = lp.getToken();
1085
+ material = getLocalMaterial( colorCode );
1086
+ ccw = bfcCCW;
1087
+ doubleSided = ! bfcCertified || ! bfcCull;
1088
+
1089
+ if ( ccw === true ) {
1090
+
1091
+ v0 = lp.getVector();
1092
+ v1 = lp.getVector();
1093
+ v2 = lp.getVector();
1094
+ v3 = lp.getVector();
1095
+
1096
+ } else {
1097
+
1098
+ v3 = lp.getVector();
1099
+ v2 = lp.getVector();
1100
+ v1 = lp.getVector();
1101
+ v0 = lp.getVector();
1102
+
1103
+ } // specifically place the triangle diagonal in the v0 and v1 slots so we can
1104
+ // account for the doubling of vertices later when smoothing normals.
1105
+
1106
+
1107
+ faces.push( {
1108
+ material: material,
1109
+ colorCode: colorCode,
1110
+ faceNormal: null,
1111
+ vertices: [ v0, v1, v2, v3 ],
1112
+ normals: [ null, null, null, null ]
1113
+ } );
1114
+ totalFaces += 2;
1115
+
1116
+ if ( doubleSided === true ) {
1117
+
1118
+ faces.push( {
1119
+ material: material,
1120
+ colorCode: colorCode,
1121
+ faceNormal: null,
1122
+ vertices: [ v3, v2, v1, v0 ],
1123
+ normals: [ null, null, null, null ]
1124
+ } );
1125
+ totalFaces += 2;
1126
+
1127
+ }
1128
+
1129
+ break;
1130
+
1131
+ default:
1132
+ throw new Error( 'LDrawLoader: Unknown line type "' + lineType + '"' + lp.getLineNumberString() + '.' );
1133
+
1134
+ }
1135
+
1136
+ }
1137
+
1138
+ if ( parsingEmbeddedFiles ) {
1139
+
1140
+ this.setData( currentEmbeddedFileName, currentEmbeddedText );
1141
+
1142
+ }
1143
+
1144
+ return {
1145
+ faces,
1146
+ conditionalSegments,
1147
+ lineSegments,
1148
+ type,
1149
+ category,
1150
+ keywords,
1151
+ author,
1152
+ subobjects,
1153
+ totalFaces,
1154
+ startingConstructionStep,
1155
+ materials,
1156
+ fileName,
1157
+ group: null
1158
+ };
1159
+
1160
+ } // returns an (optionally cloned) instance of the data
1161
+
1162
+
1163
+ getData( fileName, clone = true ) {
1164
+
1165
+ const key = fileName.toLowerCase();
1166
+ const result = this._cache[ key ];
1167
+
1168
+ if ( result === null || result instanceof Promise ) {
1169
+
1170
+ return null;
1171
+
1172
+ }
1173
+
1174
+ if ( clone ) {
1175
+
1176
+ return this.cloneResult( result );
1177
+
1178
+ } else {
1179
+
1180
+ return result;
1181
+
1182
+ }
1183
+
1184
+ } // kicks off a fetch and parse of the requested data if it hasn't already been loaded. Returns when
1185
+ // the data is ready to use and can be retrieved synchronously with "getData".
1186
+
1187
+
1188
+ async ensureDataLoaded( fileName ) {
1189
+
1190
+ const key = fileName.toLowerCase();
1191
+
1192
+ if ( ! ( key in this._cache ) ) {
1193
+
1194
+ // replace the promise with a copy of the parsed data for immediate processing
1195
+ this._cache[ key ] = this.fetchData( fileName ).then( text => {
1196
+
1197
+ const info = this.parse( text, fileName );
1198
+ this._cache[ key ] = info;
1199
+ return info;
1200
+
1201
+ } );
1202
+
1203
+ }
1204
+
1205
+ await this._cache[ key ];
1206
+
1207
+ } // sets the data in the cache from parsed data
1208
+
1209
+
1210
+ setData( fileName, text ) {
1211
+
1212
+ const key = fileName.toLowerCase();
1213
+ this._cache[ key ] = this.parse( text, fileName );
1214
+
1215
+ }
1216
+
1217
+ } // returns the material for an associated color code. If the color code is 16 for a face or 24 for
1218
+ // an edge then the passthroughColorCode is used.
1219
+
1220
+
1221
+ function getMaterialFromCode( colorCode, parentColorCode, materialHierarchy, forEdge ) {
1222
+
1223
+ const isPassthrough = ! forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
1224
+
1225
+ if ( isPassthrough ) {
1226
+
1227
+ colorCode = parentColorCode;
1228
+
1229
+ }
1230
+
1231
+ return materialHierarchy[ colorCode ] || null;
1232
+
1233
+ } // Class used to parse and build LDraw parts as three.js objects and cache them if they're a "Part" type.
1234
+
1235
+
1236
+ class LDrawPartsGeometryCache {
1237
+
1238
+ constructor( loader ) {
1239
+
1240
+ this.loader = loader;
1241
+ this.parseCache = new LDrawParsedCache( loader );
1242
+ this._cache = {};
1243
+
1244
+ } // Convert the given file information into a mesh by processing subobjects.
1245
+
1246
+
1247
+ async processIntoMesh( info ) {
1248
+
1249
+ const loader = this.loader;
1250
+ const parseCache = this.parseCache;
1251
+ const faceMaterials = new Set(); // Processes the part subobject information to load child parts and merge geometry onto part
1252
+ // piece object.
1253
+
1254
+ const processInfoSubobjects = async ( info, subobject = null ) => {
1255
+
1256
+ const subobjects = info.subobjects;
1257
+ const promises = []; // Trigger load of all subobjects. If a subobject isn't a primitive then load it as a separate
1258
+ // group which lets instruction steps apply correctly.
1259
+
1260
+ for ( let i = 0, l = subobjects.length; i < l; i ++ ) {
1261
+
1262
+ const subobject = subobjects[ i ];
1263
+ const promise = parseCache.ensureDataLoaded( subobject.fileName ).then( () => {
1264
+
1265
+ const subobjectInfo = parseCache.getData( subobject.fileName, false );
1266
+
1267
+ if ( ! isPrimitiveType( subobjectInfo.type ) ) {
1268
+
1269
+ return this.loadModel( subobject.fileName ).catch( error => {
1270
+
1271
+ console.warn( error );
1272
+ return null;
1273
+
1274
+ } );
1275
+
1276
+ }
1277
+
1278
+ return processInfoSubobjects( parseCache.getData( subobject.fileName ), subobject );
1279
+
1280
+ } );
1281
+ promises.push( promise );
1282
+
1283
+ }
1284
+
1285
+ const group = new THREE.Group();
1286
+ group.userData.category = info.category;
1287
+ group.userData.keywords = info.keywords;
1288
+ group.userData.author = info.author;
1289
+ group.userData.type = info.type;
1290
+ group.userData.fileName = info.fileName;
1291
+ info.group = group;
1292
+ const subobjectInfos = await Promise.all( promises );
1293
+
1294
+ for ( let i = 0, l = subobjectInfos.length; i < l; i ++ ) {
1295
+
1296
+ const subobject = info.subobjects[ i ];
1297
+ const subobjectInfo = subobjectInfos[ i ];
1298
+
1299
+ if ( subobjectInfo === null ) {
1300
+
1301
+ // the subobject failed to load
1302
+ continue;
1303
+
1304
+ } // if the subobject was loaded as a separate group then apply the parent scopes materials
1305
+
1306
+
1307
+ if ( subobjectInfo.isGroup ) {
1308
+
1309
+ const subobjectGroup = subobjectInfo;
1310
+ subobject.matrix.decompose( subobjectGroup.position, subobjectGroup.quaternion, subobjectGroup.scale );
1311
+ subobjectGroup.userData.startingConstructionStep = subobject.startingConstructionStep;
1312
+ subobjectGroup.name = subobject.fileName;
1313
+ loader.applyMaterialsToMesh( subobjectGroup, subobject.colorCode, info.materials );
1314
+ subobjectGroup.userData.colorCode = subobject.colorCode;
1315
+ group.add( subobjectGroup );
1316
+ continue;
1317
+
1318
+ } // add the subobject group if it has children in case it has both children and primitives
1319
+
1320
+
1321
+ if ( subobjectInfo.group.children.length ) {
1322
+
1323
+ group.add( subobjectInfo.group );
1324
+
1325
+ } // transform the primitives into the local space of the parent piece and append them to
1326
+ // to the parent primitives list.
1327
+
1328
+
1329
+ const parentLineSegments = info.lineSegments;
1330
+ const parentConditionalSegments = info.conditionalSegments;
1331
+ const parentFaces = info.faces;
1332
+ const lineSegments = subobjectInfo.lineSegments;
1333
+ const conditionalSegments = subobjectInfo.conditionalSegments;
1334
+ const faces = subobjectInfo.faces;
1335
+ const matrix = subobject.matrix;
1336
+ const inverted = subobject.inverted;
1337
+ const matrixScaleInverted = matrix.determinant() < 0;
1338
+ const colorCode = subobject.colorCode;
1339
+ const lineColorCode = colorCode === MAIN_COLOUR_CODE ? MAIN_EDGE_COLOUR_CODE : colorCode;
1340
+
1341
+ for ( let i = 0, l = lineSegments.length; i < l; i ++ ) {
1342
+
1343
+ const ls = lineSegments[ i ];
1344
+ const vertices = ls.vertices;
1345
+ vertices[ 0 ].applyMatrix4( matrix );
1346
+ vertices[ 1 ].applyMatrix4( matrix );
1347
+ ls.colorCode = ls.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : ls.colorCode;
1348
+ ls.material = ls.material || getMaterialFromCode( ls.colorCode, ls.colorCode, info.materials, true );
1349
+ parentLineSegments.push( ls );
1350
+
1351
+ }
1352
+
1353
+ for ( let i = 0, l = conditionalSegments.length; i < l; i ++ ) {
1354
+
1355
+ const os = conditionalSegments[ i ];
1356
+ const vertices = os.vertices;
1357
+ const controlPoints = os.controlPoints;
1358
+ vertices[ 0 ].applyMatrix4( matrix );
1359
+ vertices[ 1 ].applyMatrix4( matrix );
1360
+ controlPoints[ 0 ].applyMatrix4( matrix );
1361
+ controlPoints[ 1 ].applyMatrix4( matrix );
1362
+ os.colorCode = os.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : os.colorCode;
1363
+ os.material = os.material || getMaterialFromCode( os.colorCode, os.colorCode, info.materials, true );
1364
+ parentConditionalSegments.push( os );
1365
+
1366
+ }
1367
+
1368
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
1369
+
1370
+ const tri = faces[ i ];
1371
+ const vertices = tri.vertices;
1372
+
1373
+ for ( let i = 0, l = vertices.length; i < l; i ++ ) {
1374
+
1375
+ vertices[ i ].applyMatrix4( matrix );
1376
+
1377
+ }
1378
+
1379
+ tri.colorCode = tri.colorCode === MAIN_COLOUR_CODE ? colorCode : tri.colorCode;
1380
+ tri.material = tri.material || getMaterialFromCode( tri.colorCode, colorCode, info.materials, false );
1381
+ faceMaterials.add( tri.colorCode ); // If the scale of the object is negated then the triangle winding order
1382
+ // needs to be flipped.
1383
+
1384
+ if ( matrixScaleInverted !== inverted ) {
1385
+
1386
+ vertices.reverse();
1387
+
1388
+ }
1389
+
1390
+ parentFaces.push( tri );
1391
+
1392
+ }
1393
+
1394
+ info.totalFaces += subobjectInfo.totalFaces;
1395
+
1396
+ } // Apply the parent subobjects pass through material code to this object. This is done several times due
1397
+ // to material scoping.
1398
+
1399
+
1400
+ if ( subobject ) {
1401
+
1402
+ loader.applyMaterialsToMesh( group, subobject.colorCode, info.materials );
1403
+ group.userData.colorCode = subobject.colorCode;
1404
+
1405
+ }
1406
+
1407
+ return info;
1408
+
1409
+ }; // Track material use to see if we need to use the normal smooth slow path for hard edges.
1410
+
1411
+
1412
+ for ( let i = 0, l = info.faces; i < l; i ++ ) {
1413
+
1414
+ faceMaterials.add( info.faces[ i ].colorCode );
1415
+
1416
+ }
1417
+
1418
+ await processInfoSubobjects( info );
1419
+
1420
+ if ( loader.smoothNormals ) {
1421
+
1422
+ const checkSubSegments = faceMaterials.size > 1;
1423
+ generateFaceNormals( info.faces );
1424
+ smoothNormals( info.faces, info.lineSegments, checkSubSegments );
1425
+
1426
+ } // Add the primitive objects and metadata.
1427
+
1428
+
1429
+ const group = info.group;
1430
+
1431
+ if ( info.faces.length > 0 ) {
1432
+
1433
+ group.add( createObject( info.faces, 3, false, info.totalFaces ) );
1434
+
1435
+ }
1436
+
1437
+ if ( info.lineSegments.length > 0 ) {
1438
+
1439
+ group.add( createObject( info.lineSegments, 2 ) );
1440
+
1441
+ }
1442
+
1443
+ if ( info.conditionalSegments.length > 0 ) {
1444
+
1445
+ group.add( createObject( info.conditionalSegments, 2, true ) );
1446
+
1447
+ }
1448
+
1449
+ return group;
1450
+
1451
+ }
1452
+
1453
+ hasCachedModel( fileName ) {
1454
+
1455
+ return fileName !== null && fileName.toLowerCase() in this._cache;
1456
+
1457
+ }
1458
+
1459
+ async getCachedModel( fileName ) {
1460
+
1461
+ if ( fileName !== null && this.hasCachedModel( fileName ) ) {
1462
+
1463
+ const key = fileName.toLowerCase();
1464
+ const group = await this._cache[ key ];
1465
+ return group.clone();
1466
+
1467
+ } else {
1468
+
1469
+ return null;
1470
+
1471
+ }
1472
+
1473
+ } // Loads and parses the model with the given file name. Returns a cached copy if available.
1474
+
1475
+
1476
+ async loadModel( fileName ) {
1477
+
1478
+ const parseCache = this.parseCache;
1479
+ const key = fileName.toLowerCase();
1480
+
1481
+ if ( this.hasCachedModel( fileName ) ) {
1482
+
1483
+ // Return cached model if available.
1484
+ return this.getCachedModel( fileName );
1485
+
1486
+ } else {
1487
+
1488
+ // Otherwise parse a new model.
1489
+ // Ensure the file data is loaded and pre parsed.
1490
+ await parseCache.ensureDataLoaded( fileName );
1491
+ const info = parseCache.getData( fileName );
1492
+ const promise = this.processIntoMesh( info ); // Now that the file has loaded it's possible that another part parse has been waiting in parallel
1493
+ // so check the cache again to see if it's been added since the last async operation so we don't
1494
+ // do unnecessary work.
1495
+
1496
+ if ( this.hasCachedModel( fileName ) ) {
1497
+
1498
+ return this.getCachedModel( fileName );
1499
+
1500
+ } // Cache object if it's a part so it can be reused later.
1501
+
1502
+
1503
+ if ( isPartType( info.type ) ) {
1504
+
1505
+ this._cache[ key ] = promise;
1506
+
1507
+ } // return a copy
1508
+
1509
+
1510
+ const group = await promise;
1511
+ return group.clone();
1512
+
1513
+ }
1514
+
1515
+ } // parses the given model text into a renderable object. Returns cached copy if available.
1516
+
1517
+
1518
+ async parseModel( text ) {
1519
+
1520
+ const parseCache = this.parseCache;
1521
+ const info = parseCache.parse( text );
1522
+
1523
+ if ( isPartType( info.type ) && this.hasCachedModel( info.fileName ) ) {
1524
+
1525
+ return this.getCachedModel( info.fileName );
1526
+
1527
+ }
1528
+
1529
+ return this.processIntoMesh( info );
1530
+
1531
+ }
1532
+
1533
+ }
1534
+
1535
+ function sortByMaterial( a, b ) {
1536
+
1537
+ if ( a.colorCode === b.colorCode ) {
1538
+
1539
+ return 0;
1540
+
1541
+ }
1542
+
1543
+ if ( a.colorCode < b.colorCode ) {
1544
+
1545
+ return - 1;
1546
+
1547
+ }
1548
+
1549
+ return 1;
1550
+
1551
+ }
1552
+
1553
+ function createObject( elements, elementSize, isConditionalSegments = false, totalElements = null ) {
1554
+
1555
+ // Creates a THREE.LineSegments (elementSize = 2) or a THREE.Mesh (elementSize = 3 )
1556
+ // With per face / segment material, implemented with mesh groups and materials array
1557
+ // Sort the faces or line segments by color code to make later the mesh groups
1558
+ elements.sort( sortByMaterial );
1559
+
1560
+ if ( totalElements === null ) {
1561
+
1562
+ totalElements = elements.length;
1563
+
1564
+ }
1565
+
1566
+ const positions = new Float32Array( elementSize * totalElements * 3 );
1567
+ const normals = elementSize === 3 ? new Float32Array( elementSize * totalElements * 3 ) : null;
1568
+ const materials = [];
1569
+ const quadArray = new Array( 6 );
1570
+ const bufferGeometry = new THREE.BufferGeometry();
1571
+ let prevMaterial = null;
1572
+ let index0 = 0;
1573
+ let numGroupVerts = 0;
1574
+ let offset = 0;
1575
+
1576
+ for ( let iElem = 0, nElem = elements.length; iElem < nElem; iElem ++ ) {
1577
+
1578
+ const elem = elements[ iElem ];
1579
+ let vertices = elem.vertices;
1580
+
1581
+ if ( vertices.length === 4 ) {
1582
+
1583
+ quadArray[ 0 ] = vertices[ 0 ];
1584
+ quadArray[ 1 ] = vertices[ 1 ];
1585
+ quadArray[ 2 ] = vertices[ 2 ];
1586
+ quadArray[ 3 ] = vertices[ 0 ];
1587
+ quadArray[ 4 ] = vertices[ 2 ];
1588
+ quadArray[ 5 ] = vertices[ 3 ];
1589
+ vertices = quadArray;
1590
+
1591
+ }
1592
+
1593
+ for ( let j = 0, l = vertices.length; j < l; j ++ ) {
1594
+
1595
+ const v = vertices[ j ];
1596
+ const index = offset + j * 3;
1597
+ positions[ index + 0 ] = v.x;
1598
+ positions[ index + 1 ] = v.y;
1599
+ positions[ index + 2 ] = v.z;
1600
+
1601
+ } // create the normals array if this is a set of faces
1602
+
1603
+
1604
+ if ( elementSize === 3 ) {
1605
+
1606
+ if ( ! elem.faceNormal ) {
1607
+
1608
+ const v0 = vertices[ 0 ];
1609
+ const v1 = vertices[ 1 ];
1610
+ const v2 = vertices[ 2 ];
1611
+
1612
+ _tempVec0.subVectors( v1, v0 );
1613
+
1614
+ _tempVec1.subVectors( v2, v1 );
1615
+
1616
+ elem.faceNormal = new THREE.Vector3().crossVectors( _tempVec0, _tempVec1 ).normalize();
1617
+
1618
+ }
1619
+
1620
+ let elemNormals = elem.normals;
1621
+
1622
+ if ( elemNormals.length === 4 ) {
1623
+
1624
+ quadArray[ 0 ] = elemNormals[ 0 ];
1625
+ quadArray[ 1 ] = elemNormals[ 1 ];
1626
+ quadArray[ 2 ] = elemNormals[ 2 ];
1627
+ quadArray[ 3 ] = elemNormals[ 0 ];
1628
+ quadArray[ 4 ] = elemNormals[ 2 ];
1629
+ quadArray[ 5 ] = elemNormals[ 3 ];
1630
+ elemNormals = quadArray;
1631
+
1632
+ }
1633
+
1634
+ for ( let j = 0, l = elemNormals.length; j < l; j ++ ) {
1635
+
1636
+ // use face normal if a vertex normal is not provided
1637
+ let n = elem.faceNormal;
1638
+
1639
+ if ( elemNormals[ j ] ) {
1640
+
1641
+ n = elemNormals[ j ].norm;
1642
+
1643
+ }
1644
+
1645
+ const index = offset + j * 3;
1646
+ normals[ index + 0 ] = n.x;
1647
+ normals[ index + 1 ] = n.y;
1648
+ normals[ index + 2 ] = n.z;
1649
+
1650
+ }
1651
+
1652
+ }
1653
+
1654
+ if ( prevMaterial !== elem.colorCode ) {
1655
+
1656
+ if ( prevMaterial !== null ) {
1657
+
1658
+ bufferGeometry.addGroup( index0, numGroupVerts, materials.length - 1 );
1659
+
1660
+ }
1661
+
1662
+ const material = elem.material;
1663
+
1664
+ if ( material !== null ) {
1665
+
1666
+ if ( elementSize === 3 ) {
1667
+
1668
+ materials.push( material );
1669
+
1670
+ } else if ( elementSize === 2 ) {
1671
+
1672
+ if ( isConditionalSegments ) {
1673
+
1674
+ materials.push( material.userData.edgeMaterial.userData.conditionalEdgeMaterial );
1675
+
1676
+ } else {
1677
+
1678
+ materials.push( material.userData.edgeMaterial );
1679
+
1680
+ }
1681
+
1682
+ }
1683
+
1684
+ } else {
1685
+
1686
+ // If a material has not been made available yet then keep the color code string in the material array
1687
+ // to save the spot for the material once a parent scopes materials are being applied to the object.
1688
+ materials.push( elem.colorCode );
1689
+
1690
+ }
1691
+
1692
+ prevMaterial = elem.colorCode;
1693
+ index0 = offset / 3;
1694
+ numGroupVerts = vertices.length;
1695
+
1696
+ } else {
1697
+
1698
+ numGroupVerts += vertices.length;
1699
+
1700
+ }
1701
+
1702
+ offset += 3 * vertices.length;
1703
+
1704
+ }
1705
+
1706
+ if ( numGroupVerts > 0 ) {
1707
+
1708
+ bufferGeometry.addGroup( index0, Infinity, materials.length - 1 );
1709
+
1710
+ }
1711
+
1712
+ bufferGeometry.setAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
1713
+
1714
+ if ( normals !== null ) {
1715
+
1716
+ bufferGeometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
1717
+
1718
+ }
1719
+
1720
+ let object3d = null;
1721
+
1722
+ if ( elementSize === 2 ) {
1723
+
1724
+ if ( isConditionalSegments ) {
1725
+
1726
+ object3d = new ConditionalLineSegments( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
1727
+
1728
+ } else {
1729
+
1730
+ object3d = new THREE.LineSegments( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
1731
+
1732
+ }
1733
+
1734
+ } else if ( elementSize === 3 ) {
1735
+
1736
+ object3d = new THREE.Mesh( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
1737
+
1738
+ }
1739
+
1740
+ if ( isConditionalSegments ) {
1741
+
1742
+ object3d.isConditionalLine = true;
1743
+ const controlArray0 = new Float32Array( elements.length * 3 * 2 );
1744
+ const controlArray1 = new Float32Array( elements.length * 3 * 2 );
1745
+ const directionArray = new Float32Array( elements.length * 3 * 2 );
1746
+
1747
+ for ( let i = 0, l = elements.length; i < l; i ++ ) {
1748
+
1749
+ const os = elements[ i ];
1750
+ const vertices = os.vertices;
1751
+ const controlPoints = os.controlPoints;
1752
+ const c0 = controlPoints[ 0 ];
1753
+ const c1 = controlPoints[ 1 ];
1754
+ const v0 = vertices[ 0 ];
1755
+ const v1 = vertices[ 1 ];
1756
+ const index = i * 3 * 2;
1757
+ controlArray0[ index + 0 ] = c0.x;
1758
+ controlArray0[ index + 1 ] = c0.y;
1759
+ controlArray0[ index + 2 ] = c0.z;
1760
+ controlArray0[ index + 3 ] = c0.x;
1761
+ controlArray0[ index + 4 ] = c0.y;
1762
+ controlArray0[ index + 5 ] = c0.z;
1763
+ controlArray1[ index + 0 ] = c1.x;
1764
+ controlArray1[ index + 1 ] = c1.y;
1765
+ controlArray1[ index + 2 ] = c1.z;
1766
+ controlArray1[ index + 3 ] = c1.x;
1767
+ controlArray1[ index + 4 ] = c1.y;
1768
+ controlArray1[ index + 5 ] = c1.z;
1769
+ directionArray[ index + 0 ] = v1.x - v0.x;
1770
+ directionArray[ index + 1 ] = v1.y - v0.y;
1771
+ directionArray[ index + 2 ] = v1.z - v0.z;
1772
+ directionArray[ index + 3 ] = v1.x - v0.x;
1773
+ directionArray[ index + 4 ] = v1.y - v0.y;
1774
+ directionArray[ index + 5 ] = v1.z - v0.z;
1775
+
1776
+ }
1777
+
1778
+ bufferGeometry.setAttribute( 'control0', new THREE.BufferAttribute( controlArray0, 3, false ) );
1779
+ bufferGeometry.setAttribute( 'control1', new THREE.BufferAttribute( controlArray1, 3, false ) );
1780
+ bufferGeometry.setAttribute( 'direction', new THREE.BufferAttribute( directionArray, 3, false ) );
1781
+
1782
+ }
1783
+
1784
+ return object3d;
1785
+
1786
+ } //
1787
+
1788
+
1789
+ class LDrawLoader extends THREE.Loader {
1790
+
1791
+ constructor( manager ) {
1792
+
1793
+ super( manager ); // Array of THREE.Material
1794
+
1795
+ this.materials = [];
1796
+ this.materialLibrary = {}; // This also allows to handle the embedded text files ("0 FILE" lines)
1797
+
1798
+ this.partsCache = new LDrawPartsGeometryCache( this ); // This object is a map from file names to paths. It agilizes the paths search. If it is not set then files will be searched by trial and error.
1799
+
1800
+ this.fileMap = {}; // Initializes the materials library with default materials
1801
+
1802
+ this.setMaterials( [] ); // If this flag is set to true the vertex normals will be smoothed.
1803
+
1804
+ this.smoothNormals = true; // The path to load parts from the LDraw parts library from.
1805
+
1806
+ this.partsLibraryPath = ''; // Material assigned to not available colors for meshes and edges
1807
+
1808
+ this.missingColorMaterial = new THREE.MeshStandardMaterial( {
1809
+ color: 0xFF00FF,
1810
+ roughness: 0.3,
1811
+ metalness: 0
1812
+ } );
1813
+ this.missingColorMaterial.name = 'Missing material';
1814
+ this.missingEdgeColorMaterial = new THREE.LineBasicMaterial( {
1815
+ color: 0xFF00FF
1816
+ } );
1817
+ this.missingEdgeColorMaterial.name = 'Missing material - Edge';
1818
+ this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( {
1819
+ fog: true,
1820
+ color: 0xFF00FF
1821
+ } );
1822
+ this.missingConditionalEdgeColorMaterial.name = 'Missing material - Conditional Edge';
1823
+ this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
1824
+ this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
1825
+
1826
+ }
1827
+
1828
+ setPartsLibraryPath( path ) {
1829
+
1830
+ this.partsLibraryPath = path;
1831
+ return this;
1832
+
1833
+ }
1834
+
1835
+ async preloadMaterials( url ) {
1836
+
1837
+ const fileLoader = new THREE.FileLoader( this.manager );
1838
+ fileLoader.setPath( this.path );
1839
+ fileLoader.setRequestHeader( this.requestHeader );
1840
+ fileLoader.setWithCredentials( this.withCredentials );
1841
+ const text = await fileLoader.loadAsync( url );
1842
+ const colorLineRegex = /^0 !COLOUR/;
1843
+ const lines = text.split( /[\n\r]/g );
1844
+ const materials = [];
1845
+
1846
+ for ( let i = 0, l = lines.length; i < l; i ++ ) {
1847
+
1848
+ const line = lines[ i ];
1849
+
1850
+ if ( colorLineRegex.test( line ) ) {
1851
+
1852
+ const directive = line.replace( colorLineRegex, '' );
1853
+ const material = this.parseColorMetaDirective( new LineParser( directive ) );
1854
+ materials.push( material );
1855
+
1856
+ }
1857
+
1858
+ }
1859
+
1860
+ this.setMaterials( materials );
1861
+
1862
+ }
1863
+
1864
+ load( url, onLoad, onProgress, onError ) {
1865
+
1866
+ const fileLoader = new THREE.FileLoader( this.manager );
1867
+ fileLoader.setPath( this.path );
1868
+ fileLoader.setRequestHeader( this.requestHeader );
1869
+ fileLoader.setWithCredentials( this.withCredentials );
1870
+ fileLoader.load( url, text => {
1871
+
1872
+ this.partsCache.parseModel( text, this.materialLibrary ).then( group => {
1873
+
1874
+ this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
1875
+ this.computeConstructionSteps( group );
1876
+ group.userData.fileName = url;
1877
+ onLoad( group );
1878
+
1879
+ } ).catch( onError );
1880
+
1881
+ }, onProgress, onError );
1882
+
1883
+ }
1884
+
1885
+ parse( text, onLoad ) {
1886
+
1887
+ this.partsCache.parseModel( text, this.materialLibrary ).then( group => {
1888
+
1889
+ this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
1890
+ this.computeConstructionSteps( group );
1891
+ group.userData.fileName = '';
1892
+ onLoad( group );
1893
+
1894
+ } );
1895
+
1896
+ }
1897
+
1898
+ setMaterials( materials ) {
1899
+
1900
+ this.materialLibrary = {};
1901
+ this.materials = [];
1902
+
1903
+ for ( let i = 0, l = materials.length; i < l; i ++ ) {
1904
+
1905
+ this.addMaterial( materials[ i ] );
1906
+
1907
+ } // Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
1908
+
1909
+
1910
+ this.addMaterial( this.parseColorMetaDirective( new LineParser( 'Main_Colour CODE 16 VALUE #FF8080 EDGE #333333' ) ) );
1911
+ this.addMaterial( this.parseColorMetaDirective( new LineParser( 'Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333' ) ) );
1912
+ return this;
1913
+
1914
+ }
1915
+
1916
+ setFileMap( fileMap ) {
1917
+
1918
+ this.fileMap = fileMap;
1919
+ return this;
1920
+
1921
+ }
1922
+
1923
+ addMaterial( material ) {
1924
+
1925
+ // Adds a material to the material library which is on top of the parse scopes stack. And also to the materials array
1926
+ const matLib = this.materialLibrary;
1927
+
1928
+ if ( ! matLib[ material.userData.code ] ) {
1929
+
1930
+ this.materials.push( material );
1931
+ matLib[ material.userData.code ] = material;
1932
+
1933
+ }
1934
+
1935
+ return this;
1936
+
1937
+ }
1938
+
1939
+ getMaterial( colorCode ) {
1940
+
1941
+ if ( colorCode.startsWith( '0x2' ) ) {
1942
+
1943
+ // Special 'direct' material value (RGB color)
1944
+ const color = colorCode.substring( 3 );
1945
+ return this.parseColorMetaDirective( new LineParser( 'Direct_Color_' + color + ' CODE -1 VALUE #' + color + ' EDGE #' + color + '' ) );
1946
+
1947
+ }
1948
+
1949
+ return this.materialLibrary[ colorCode ] || null;
1950
+
1951
+ } // Applies the appropriate materials to a prebuilt hierarchy of geometry. Assumes that color codes are present
1952
+ // in the material array if they need to be filled in.
1953
+
1954
+
1955
+ applyMaterialsToMesh( group, parentColorCode, materialHierarchy, finalMaterialPass = false ) {
1956
+
1957
+ // find any missing materials as indicated by a color code string and replace it with a material from the current material lib
1958
+ const loader = this;
1959
+ const parentIsPassthrough = parentColorCode === MAIN_COLOUR_CODE;
1960
+ group.traverse( c => {
1961
+
1962
+ if ( c.isMesh || c.isLineSegments ) {
1963
+
1964
+ if ( Array.isArray( c.material ) ) {
1965
+
1966
+ for ( let i = 0, l = c.material.length; i < l; i ++ ) {
1967
+
1968
+ if ( ! c.material[ i ].isMaterial ) {
1969
+
1970
+ c.material[ i ] = getMaterial( c, c.material[ i ] );
1971
+
1972
+ }
1973
+
1974
+ }
1975
+
1976
+ } else if ( ! c.material.isMaterial ) {
1977
+
1978
+ c.material = getMaterial( c, c.material );
1979
+
1980
+ }
1981
+
1982
+ }
1983
+
1984
+ } ); // Returns the appropriate material for the object (line or face) given color code. If the code is "pass through"
1985
+ // (24 for lines, 16 for edges) then the pass through color code is used. If that is also pass through then it's
1986
+ // simply returned for the subsequent material application.
1987
+
1988
+ function getMaterial( c, colorCode ) {
1989
+
1990
+ // if our parent is a passthrough color code and we don't have the current material color available then
1991
+ // return early.
1992
+ if ( parentIsPassthrough && ! ( colorCode in materialHierarchy ) && ! finalMaterialPass ) {
1993
+
1994
+ return colorCode;
1995
+
1996
+ }
1997
+
1998
+ const forEdge = c.isLineSegments || c.isConditionalLine;
1999
+ const isPassthrough = ! forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
2000
+
2001
+ if ( isPassthrough ) {
2002
+
2003
+ colorCode = parentColorCode;
2004
+
2005
+ }
2006
+
2007
+ let material = null;
2008
+
2009
+ if ( colorCode in materialHierarchy ) {
2010
+
2011
+ material = materialHierarchy[ colorCode ];
2012
+
2013
+ } else if ( finalMaterialPass ) {
2014
+
2015
+ // see if we can get the final material from from the "getMaterial" function which will attempt to
2016
+ // parse the "direct" colors
2017
+ material = loader.getMaterial( colorCode );
2018
+
2019
+ if ( material === null ) {
2020
+
2021
+ // otherwise throw a warning if this is final opportunity to set the material
2022
+ console.warn( `LDrawLoader: Material properties for code ${colorCode} not available.` ); // And return the 'missing color' material
2023
+
2024
+ material = loader.missingColorMaterial;
2025
+
2026
+ }
2027
+
2028
+ } else {
2029
+
2030
+ return colorCode;
2031
+
2032
+ }
2033
+
2034
+ if ( c.isLineSegments ) {
2035
+
2036
+ material = material.userData.edgeMaterial;
2037
+
2038
+ if ( c.isConditionalLine ) {
2039
+
2040
+ material = material.userData.conditionalEdgeMaterial;
2041
+
2042
+ }
2043
+
2044
+ }
2045
+
2046
+ return material;
2047
+
2048
+ }
2049
+
2050
+ }
2051
+
2052
+ getMainMaterial() {
2053
+
2054
+ return this.getMaterial( MAIN_COLOUR_CODE );
2055
+
2056
+ }
2057
+
2058
+ getMainEdgeMaterial() {
2059
+
2060
+ const mat = this.getMaterial( MAIN_EDGE_COLOUR_CODE );
2061
+ return mat ? mat.userData.edgeMaterial : null;
2062
+
2063
+ }
2064
+
2065
+ parseColorMetaDirective( lineParser ) {
2066
+
2067
+ // Parses a color definition and returns a THREE.Material
2068
+ let code = null; // Triangle and line colors
2069
+
2070
+ let color = 0xFF00FF;
2071
+ let edgeColor = 0xFF00FF; // Transparency
2072
+
2073
+ let alpha = 1;
2074
+ let isTransparent = false; // Self-illumination:
2075
+
2076
+ let luminance = 0;
2077
+ let finishType = FINISH_TYPE_DEFAULT;
2078
+ let edgeMaterial = null;
2079
+ const name = lineParser.getToken();
2080
+
2081
+ if ( ! name ) {
2082
+
2083
+ throw new Error( 'LDrawLoader: Material name was expected after "!COLOUR tag' + lineParser.getLineNumberString() + '.' );
2084
+
2085
+ } // Parse tag tokens and their parameters
2086
+
2087
+
2088
+ let token = null;
2089
+
2090
+ while ( true ) {
2091
+
2092
+ token = lineParser.getToken();
2093
+
2094
+ if ( ! token ) {
2095
+
2096
+ break;
2097
+
2098
+ }
2099
+
2100
+ if ( ! parseLuminance( token ) ) {
2101
+
2102
+ switch ( token.toUpperCase() ) {
2103
+
2104
+ case 'CODE':
2105
+ code = lineParser.getToken();
2106
+ break;
2107
+
2108
+ case 'VALUE':
2109
+ color = lineParser.getToken();
2110
+
2111
+ if ( color.startsWith( '0x' ) ) {
2112
+
2113
+ color = '#' + color.substring( 2 );
2114
+
2115
+ } else if ( ! color.startsWith( '#' ) ) {
2116
+
2117
+ throw new Error( 'LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.' );
2118
+
2119
+ }
2120
+
2121
+ break;
2122
+
2123
+ case 'EDGE':
2124
+ edgeColor = lineParser.getToken();
2125
+
2126
+ if ( edgeColor.startsWith( '0x' ) ) {
2127
+
2128
+ edgeColor = '#' + edgeColor.substring( 2 );
2129
+
2130
+ } else if ( ! edgeColor.startsWith( '#' ) ) {
2131
+
2132
+ // Try to see if edge color is a color code
2133
+ edgeMaterial = this.getMaterial( edgeColor );
2134
+
2135
+ if ( ! edgeMaterial ) {
2136
+
2137
+ throw new Error( 'LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.' );
2138
+
2139
+ } // Get the edge material for this triangle material
2140
+
2141
+
2142
+ edgeMaterial = edgeMaterial.userData.edgeMaterial;
2143
+
2144
+ }
2145
+
2146
+ break;
2147
+
2148
+ case 'ALPHA':
2149
+ alpha = parseInt( lineParser.getToken() );
2150
+
2151
+ if ( isNaN( alpha ) ) {
2152
+
2153
+ throw new Error( 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.' );
2154
+
2155
+ }
2156
+
2157
+ alpha = Math.max( 0, Math.min( 1, alpha / 255 ) );
2158
+
2159
+ if ( alpha < 1 ) {
2160
+
2161
+ isTransparent = true;
2162
+
2163
+ }
2164
+
2165
+ break;
2166
+
2167
+ case 'LUMINANCE':
2168
+ if ( ! parseLuminance( lineParser.getToken() ) ) {
2169
+
2170
+ throw new Error( 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.' );
2171
+
2172
+ }
2173
+
2174
+ break;
2175
+
2176
+ case 'CHROME':
2177
+ finishType = FINISH_TYPE_CHROME;
2178
+ break;
2179
+
2180
+ case 'PEARLESCENT':
2181
+ finishType = FINISH_TYPE_PEARLESCENT;
2182
+ break;
2183
+
2184
+ case 'RUBBER':
2185
+ finishType = FINISH_TYPE_RUBBER;
2186
+ break;
2187
+
2188
+ case 'MATTE_METALLIC':
2189
+ finishType = FINISH_TYPE_MATTE_METALLIC;
2190
+ break;
2191
+
2192
+ case 'METAL':
2193
+ finishType = FINISH_TYPE_METAL;
2194
+ break;
2195
+
2196
+ case 'MATERIAL':
2197
+ // Not implemented
2198
+ lineParser.setToEnd();
2199
+ break;
2200
+
2201
+ default:
2202
+ throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
2203
+
2204
+ }
2205
+
2206
+ }
2207
+
2208
+ }
2209
+
2210
+ let material = null;
2211
+
2212
+ switch ( finishType ) {
2213
+
2214
+ case FINISH_TYPE_DEFAULT:
2215
+ material = new THREE.MeshStandardMaterial( {
2216
+ color: color,
2217
+ roughness: 0.3,
2218
+ metalness: 0
2219
+ } );
2220
+ break;
2221
+
2222
+ case FINISH_TYPE_PEARLESCENT:
2223
+ // Try to imitate pearlescency by making the surface glossy
2224
+ material = new THREE.MeshStandardMaterial( {
2225
+ color: color,
2226
+ roughness: 0.3,
2227
+ metalness: 0.25
2228
+ } );
2229
+ break;
2230
+
2231
+ case FINISH_TYPE_CHROME:
2232
+ // Mirror finish surface
2233
+ material = new THREE.MeshStandardMaterial( {
2234
+ color: color,
2235
+ roughness: 0,
2236
+ metalness: 1
2237
+ } );
2238
+ break;
2239
+
2240
+ case FINISH_TYPE_RUBBER:
2241
+ // Rubber finish
2242
+ material = new THREE.MeshStandardMaterial( {
2243
+ color: color,
2244
+ roughness: 0.9,
2245
+ metalness: 0
2246
+ } );
2247
+ break;
2248
+
2249
+ case FINISH_TYPE_MATTE_METALLIC:
2250
+ // Brushed metal finish
2251
+ material = new THREE.MeshStandardMaterial( {
2252
+ color: color,
2253
+ roughness: 0.8,
2254
+ metalness: 0.4
2255
+ } );
2256
+ break;
2257
+
2258
+ case FINISH_TYPE_METAL:
2259
+ // Average metal finish
2260
+ material = new THREE.MeshStandardMaterial( {
2261
+ color: color,
2262
+ roughness: 0.2,
2263
+ metalness: 0.85
2264
+ } );
2265
+ break;
2266
+
2267
+ default:
2268
+ // Should not happen
2269
+ break;
2270
+
2271
+ }
2272
+
2273
+ material.transparent = isTransparent;
2274
+ material.premultipliedAlpha = true;
2275
+ material.opacity = alpha;
2276
+ material.depthWrite = ! isTransparent;
2277
+ material.color.convertSRGBToLinear();
2278
+ material.polygonOffset = true;
2279
+ material.polygonOffsetFactor = 1;
2280
+
2281
+ if ( luminance !== 0 ) {
2282
+
2283
+ material.emissive.set( material.color ).multiplyScalar( luminance );
2284
+
2285
+ }
2286
+
2287
+ if ( ! edgeMaterial ) {
2288
+
2289
+ // This is the material used for edges
2290
+ edgeMaterial = new THREE.LineBasicMaterial( {
2291
+ color: edgeColor,
2292
+ transparent: isTransparent,
2293
+ opacity: alpha,
2294
+ depthWrite: ! isTransparent
2295
+ } );
2296
+ edgeMaterial.userData.code = code;
2297
+ edgeMaterial.name = name + ' - Edge';
2298
+ edgeMaterial.color.convertSRGBToLinear(); // This is the material used for conditional edges
2299
+
2300
+ edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial( {
2301
+ fog: true,
2302
+ transparent: isTransparent,
2303
+ depthWrite: ! isTransparent,
2304
+ color: edgeColor,
2305
+ opacity: alpha
2306
+ } );
2307
+ edgeMaterial.userData.conditionalEdgeMaterial.color.convertSRGBToLinear();
2308
+ edgeMaterial.userData.conditionalEdgeMaterial.userData.code = code;
2309
+ edgeMaterial.userData.conditionalEdgeMaterial.name = name + ' - Conditional Edge';
2310
+
2311
+ }
2312
+
2313
+ material.userData.code = code;
2314
+ material.name = name;
2315
+ material.userData.edgeMaterial = edgeMaterial;
2316
+ this.addMaterial( material );
2317
+ return material;
2318
+
2319
+ function parseLuminance( token ) {
2320
+
2321
+ // Returns success
2322
+ let lum;
2323
+
2324
+ if ( token.startsWith( 'LUMINANCE' ) ) {
2325
+
2326
+ lum = parseInt( token.substring( 9 ) );
2327
+
2328
+ } else {
2329
+
2330
+ lum = parseInt( token );
2331
+
2332
+ }
2333
+
2334
+ if ( isNaN( lum ) ) {
2335
+
2336
+ return false;
2337
+
2338
+ }
2339
+
2340
+ luminance = Math.max( 0, Math.min( 1, lum / 255 ) );
2341
+ return true;
2342
+
2343
+ }
2344
+
2345
+ }
2346
+
2347
+ computeConstructionSteps( model ) {
2348
+
2349
+ // Sets userdata.constructionStep number in THREE.Group objects and userData.numConstructionSteps number in the root THREE.Group object.
2350
+ let stepNumber = 0;
2351
+ model.traverse( c => {
2352
+
2353
+ if ( c.isGroup ) {
2354
+
2355
+ if ( c.userData.startingConstructionStep ) {
2356
+
2357
+ stepNumber ++;
2358
+
2359
+ }
2360
+
2361
+ c.userData.constructionStep = stepNumber;
2362
+
2363
+ }
2364
+
2365
+ } );
2366
+ model.userData.numConstructionSteps = stepNumber + 1;
2367
+
2368
+ }
2369
+
2370
+ }
2371
+
2372
+ THREE.LDrawLoader = LDrawLoader;
2373
+
2374
+ } )();