@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,2464 @@
1
+ import {
2
+ BufferAttribute,
3
+ BufferGeometry,
4
+ Color,
5
+ FileLoader,
6
+ Group,
7
+ LineBasicMaterial,
8
+ LineSegments,
9
+ Loader,
10
+ Matrix4,
11
+ Mesh,
12
+ MeshStandardMaterial,
13
+ ShaderMaterial,
14
+ UniformsLib,
15
+ UniformsUtils,
16
+ Vector3,
17
+ Ray
18
+ } from 'three';
19
+
20
+ // Special surface finish tag types.
21
+ // Note: "MATERIAL" tag (e.g. GLITTER, SPECKLE) is not implemented
22
+ const FINISH_TYPE_DEFAULT = 0;
23
+ const FINISH_TYPE_CHROME = 1;
24
+ const FINISH_TYPE_PEARLESCENT = 2;
25
+ const FINISH_TYPE_RUBBER = 3;
26
+ const FINISH_TYPE_MATTE_METALLIC = 4;
27
+ const FINISH_TYPE_METAL = 5;
28
+
29
+ // State machine to search a subobject path.
30
+ // The LDraw standard establishes these various possible subfolders.
31
+ const FILE_LOCATION_TRY_PARTS = 0;
32
+ const FILE_LOCATION_TRY_P = 1;
33
+ const FILE_LOCATION_TRY_MODELS = 2;
34
+ const FILE_LOCATION_AS_IS = 3;
35
+ const FILE_LOCATION_TRY_RELATIVE = 4;
36
+ const FILE_LOCATION_TRY_ABSOLUTE = 5;
37
+ const FILE_LOCATION_NOT_FOUND = 6;
38
+
39
+ const MAIN_COLOUR_CODE = '16';
40
+ const MAIN_EDGE_COLOUR_CODE = '24';
41
+
42
+ const _tempVec0 = new Vector3();
43
+ const _tempVec1 = new Vector3();
44
+
45
+ class LDrawConditionalLineMaterial extends ShaderMaterial {
46
+
47
+ constructor( parameters ) {
48
+
49
+ super( {
50
+
51
+ uniforms: UniformsUtils.merge( [
52
+ UniformsLib.fog,
53
+ {
54
+ diffuse: {
55
+ value: new Color()
56
+ },
57
+ opacity: {
58
+ value: 1.0
59
+ }
60
+ }
61
+ ] ),
62
+
63
+ vertexShader: /* glsl */`
64
+ attribute vec3 control0;
65
+ attribute vec3 control1;
66
+ attribute vec3 direction;
67
+ varying float discardFlag;
68
+
69
+ #include <common>
70
+ #include <color_pars_vertex>
71
+ #include <fog_pars_vertex>
72
+ #include <logdepthbuf_pars_vertex>
73
+ #include <clipping_planes_pars_vertex>
74
+ void main() {
75
+ #include <color_vertex>
76
+
77
+ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
78
+ gl_Position = projectionMatrix * mvPosition;
79
+
80
+ // Transform the line segment ends and control points into camera clip space
81
+ vec4 c0 = projectionMatrix * modelViewMatrix * vec4( control0, 1.0 );
82
+ vec4 c1 = projectionMatrix * modelViewMatrix * vec4( control1, 1.0 );
83
+ vec4 p0 = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
84
+ vec4 p1 = projectionMatrix * modelViewMatrix * vec4( position + direction, 1.0 );
85
+
86
+ c0.xy /= c0.w;
87
+ c1.xy /= c1.w;
88
+ p0.xy /= p0.w;
89
+ p1.xy /= p1.w;
90
+
91
+ // Get the direction of the segment and an orthogonal vector
92
+ vec2 dir = p1.xy - p0.xy;
93
+ vec2 norm = vec2( -dir.y, dir.x );
94
+
95
+ // Get control point directions from the line
96
+ vec2 c0dir = c0.xy - p1.xy;
97
+ vec2 c1dir = c1.xy - p1.xy;
98
+
99
+ // If the vectors to the controls points are pointed in different directions away
100
+ // from the line segment then the line should not be drawn.
101
+ float d0 = dot( normalize( norm ), normalize( c0dir ) );
102
+ float d1 = dot( normalize( norm ), normalize( c1dir ) );
103
+ discardFlag = float( sign( d0 ) != sign( d1 ) );
104
+
105
+ #include <logdepthbuf_vertex>
106
+ #include <clipping_planes_vertex>
107
+ #include <fog_vertex>
108
+ }
109
+ `,
110
+
111
+ fragmentShader: /* glsl */`
112
+ uniform vec3 diffuse;
113
+ uniform float opacity;
114
+ varying float discardFlag;
115
+
116
+ #include <common>
117
+ #include <color_pars_fragment>
118
+ #include <fog_pars_fragment>
119
+ #include <logdepthbuf_pars_fragment>
120
+ #include <clipping_planes_pars_fragment>
121
+ void main() {
122
+
123
+ if ( discardFlag > 0.5 ) discard;
124
+
125
+ #include <clipping_planes_fragment>
126
+ vec3 outgoingLight = vec3( 0.0 );
127
+ vec4 diffuseColor = vec4( diffuse, opacity );
128
+ #include <logdepthbuf_fragment>
129
+ #include <color_fragment>
130
+ outgoingLight = diffuseColor.rgb; // simple shader
131
+ gl_FragColor = vec4( outgoingLight, diffuseColor.a );
132
+ #include <tonemapping_fragment>
133
+ #include <encodings_fragment>
134
+ #include <fog_fragment>
135
+ #include <premultiplied_alpha_fragment>
136
+ }
137
+ `,
138
+
139
+ } );
140
+
141
+ Object.defineProperties( this, {
142
+
143
+ opacity: {
144
+ get: function () {
145
+
146
+ return this.uniforms.opacity.value;
147
+
148
+ },
149
+
150
+ set: function ( value ) {
151
+
152
+ this.uniforms.opacity.value = value;
153
+
154
+ }
155
+ },
156
+
157
+ color: {
158
+ get: function () {
159
+
160
+ return this.uniforms.diffuse.value;
161
+
162
+ }
163
+ }
164
+
165
+ } );
166
+
167
+ this.setValues( parameters );
168
+ this.isLDrawConditionalLineMaterial = true;
169
+
170
+ }
171
+
172
+ }
173
+
174
+ class ConditionalLineSegments extends LineSegments {
175
+
176
+ constructor( geometry, material ) {
177
+
178
+ super( geometry, material );
179
+ this.isConditionalLine = true;
180
+
181
+ }
182
+
183
+ }
184
+
185
+ function generateFaceNormals( faces ) {
186
+
187
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
188
+
189
+ const face = faces[ i ];
190
+ const vertices = face.vertices;
191
+ const v0 = vertices[ 0 ];
192
+ const v1 = vertices[ 1 ];
193
+ const v2 = vertices[ 2 ];
194
+
195
+ _tempVec0.subVectors( v1, v0 );
196
+ _tempVec1.subVectors( v2, v1 );
197
+ face.faceNormal = new Vector3()
198
+ .crossVectors( _tempVec0, _tempVec1 )
199
+ .normalize();
200
+
201
+ }
202
+
203
+ }
204
+
205
+ const _ray = new Ray();
206
+ function smoothNormals( faces, lineSegments, checkSubSegments = false ) {
207
+
208
+ // NOTE: 1e2 is pretty coarse but was chosen to quantize the resulting value because
209
+ // it allows edges to be smoothed as expected (see minifig arms).
210
+ // --
211
+ // And the vector values are initialize multiplied by 1 + 1e-10 to account for floating
212
+ // point errors on vertices along quantization boundaries. Ie after matrix multiplication
213
+ // vertices that should be merged might be set to "1.7" and "1.6999..." meaning they won't
214
+ // get merged. This added epsilon attempts to push these error values to the same quantized
215
+ // value for the sake of hashing. See "AT-ST mini" dishes. See mrdoob/three#23169.
216
+
217
+ const hashMultiplier = ( 1 + 1e-10 ) * 1e2;
218
+ function hashVertex( v ) {
219
+
220
+ const x = ~ ~ ( v.x * hashMultiplier );
221
+ const y = ~ ~ ( v.y * hashMultiplier );
222
+ const z = ~ ~ ( v.z * hashMultiplier );
223
+
224
+ return `${ x },${ y },${ z }`;
225
+
226
+ }
227
+
228
+ function hashEdge( v0, v1 ) {
229
+
230
+ return `${ hashVertex( v0 ) }_${ hashVertex( v1 ) }`;
231
+
232
+ }
233
+
234
+ // converts the two vertices to a ray with a normalized direction and origin of 0, 0, 0 projected
235
+ // onto the original line.
236
+ function toNormalizedRay( v0, v1, targetRay ) {
237
+
238
+ targetRay.direction.subVectors( v1, v0 ).normalize();
239
+
240
+ const scalar = v0.dot( targetRay.direction );
241
+ targetRay.origin.copy( v0 ).addScaledVector( targetRay.direction, - scalar );
242
+
243
+ return targetRay;
244
+
245
+ }
246
+
247
+ function hashRay( ray ) {
248
+
249
+ return hashEdge( ray.origin, ray.direction );
250
+
251
+ }
252
+
253
+ const hardEdges = new Set();
254
+ const hardEdgeRays = new Map();
255
+ const halfEdgeList = {};
256
+ const normals = [];
257
+
258
+ // Save the list of hard edges by hash
259
+ for ( let i = 0, l = lineSegments.length; i < l; i ++ ) {
260
+
261
+ const ls = lineSegments[ i ];
262
+ const vertices = ls.vertices;
263
+ const v0 = vertices[ 0 ];
264
+ const v1 = vertices[ 1 ];
265
+ hardEdges.add( hashEdge( v0, v1 ) );
266
+ hardEdges.add( hashEdge( v1, v0 ) );
267
+
268
+ // only generate the hard edge ray map if we're checking subsegments because it's more expensive to check
269
+ // and requires more memory.
270
+ if ( checkSubSegments ) {
271
+
272
+ // add both ray directions to the map
273
+ const ray = toNormalizedRay( v0, v1, new Ray() );
274
+ const rh1 = hashRay( ray );
275
+ if ( ! hardEdgeRays.has( rh1 ) ) {
276
+
277
+ toNormalizedRay( v1, v0, ray );
278
+ const rh2 = hashRay( ray );
279
+
280
+ const info = {
281
+ ray,
282
+ distances: [],
283
+ };
284
+
285
+ hardEdgeRays.set( rh1, info );
286
+ hardEdgeRays.set( rh2, info );
287
+
288
+ }
289
+
290
+ // store both segments ends in min, max order in the distances array to check if a face edge is a
291
+ // subsegment later.
292
+ const info = hardEdgeRays.get( rh1 );
293
+ let d0 = info.ray.direction.dot( v0 );
294
+ let d1 = info.ray.direction.dot( v1 );
295
+ if ( d0 > d1 ) {
296
+
297
+ [ d0, d1 ] = [ d1, d0 ];
298
+
299
+ }
300
+
301
+ info.distances.push( d0, d1 );
302
+
303
+ }
304
+
305
+ }
306
+
307
+ // track the half edges associated with each triangle
308
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
309
+
310
+ const tri = faces[ i ];
311
+ const vertices = tri.vertices;
312
+ const vertCount = vertices.length;
313
+ for ( let i2 = 0; i2 < vertCount; i2 ++ ) {
314
+
315
+ const index = i2;
316
+ const next = ( i2 + 1 ) % vertCount;
317
+ const v0 = vertices[ index ];
318
+ const v1 = vertices[ next ];
319
+ const hash = hashEdge( v0, v1 );
320
+
321
+ // don't add the triangle if the edge is supposed to be hard
322
+ if ( hardEdges.has( hash ) ) {
323
+
324
+ continue;
325
+
326
+ }
327
+
328
+ // if checking subsegments then check to see if this edge lies on a hard edge ray and whether its within any ray bounds
329
+ if ( checkSubSegments ) {
330
+
331
+ toNormalizedRay( v0, v1, _ray );
332
+
333
+ const rayHash = hashRay( _ray );
334
+ if ( hardEdgeRays.has( rayHash ) ) {
335
+
336
+ const info = hardEdgeRays.get( rayHash );
337
+ const { ray, distances } = info;
338
+ let d0 = ray.direction.dot( v0 );
339
+ let d1 = ray.direction.dot( v1 );
340
+
341
+ if ( d0 > d1 ) {
342
+
343
+ [ d0, d1 ] = [ d1, d0 ];
344
+
345
+ }
346
+
347
+ // return early if the face edge is found to be a subsegment of a line edge meaning the edge will have "hard" normals
348
+ let found = false;
349
+ for ( let i = 0, l = distances.length; i < l; i += 2 ) {
350
+
351
+ if ( d0 >= distances[ i ] && d1 <= distances[ i + 1 ] ) {
352
+
353
+ found = true;
354
+ break;
355
+
356
+ }
357
+
358
+ }
359
+
360
+ if ( found ) {
361
+
362
+ continue;
363
+
364
+ }
365
+
366
+ }
367
+
368
+ }
369
+
370
+ const info = {
371
+ index: index,
372
+ tri: tri
373
+ };
374
+ halfEdgeList[ hash ] = info;
375
+
376
+ }
377
+
378
+ }
379
+
380
+ // Iterate until we've tried to connect all faces to share normals
381
+ while ( true ) {
382
+
383
+ // Stop if there are no more faces left
384
+ let halfEdge = null;
385
+ for ( const key in halfEdgeList ) {
386
+
387
+ halfEdge = halfEdgeList[ key ];
388
+ break;
389
+
390
+ }
391
+
392
+ if ( halfEdge === null ) {
393
+
394
+ break;
395
+
396
+ }
397
+
398
+ // Exhaustively find all connected faces
399
+ const queue = [ halfEdge ];
400
+ while ( queue.length > 0 ) {
401
+
402
+ // initialize all vertex normals in this triangle
403
+ const tri = queue.pop().tri;
404
+ const vertices = tri.vertices;
405
+ const vertNormals = tri.normals;
406
+ const faceNormal = tri.faceNormal;
407
+
408
+ // Check if any edge is connected to another triangle edge
409
+ const vertCount = vertices.length;
410
+ for ( let i2 = 0; i2 < vertCount; i2 ++ ) {
411
+
412
+ const index = i2;
413
+ const next = ( i2 + 1 ) % vertCount;
414
+ const v0 = vertices[ index ];
415
+ const v1 = vertices[ next ];
416
+
417
+ // delete this triangle from the list so it won't be found again
418
+ const hash = hashEdge( v0, v1 );
419
+ delete halfEdgeList[ hash ];
420
+
421
+ const reverseHash = hashEdge( v1, v0 );
422
+ const otherInfo = halfEdgeList[ reverseHash ];
423
+ if ( otherInfo ) {
424
+
425
+ const otherTri = otherInfo.tri;
426
+ const otherIndex = otherInfo.index;
427
+ const otherNormals = otherTri.normals;
428
+ const otherVertCount = otherNormals.length;
429
+ const otherFaceNormal = otherTri.faceNormal;
430
+
431
+ // NOTE: If the angle between faces is > 67.5 degrees then assume it's
432
+ // hard edge. There are some cases where the line segments do not line up exactly
433
+ // with or span multiple triangle edges (see Lunar Vehicle wheels).
434
+ if ( Math.abs( otherTri.faceNormal.dot( tri.faceNormal ) ) < 0.25 ) {
435
+
436
+ continue;
437
+
438
+ }
439
+
440
+ // if this triangle has already been traversed then it won't be in
441
+ // the halfEdgeList. If it has not then add it to the queue and delete
442
+ // it so it won't be found again.
443
+ if ( reverseHash in halfEdgeList ) {
444
+
445
+ queue.push( otherInfo );
446
+ delete halfEdgeList[ reverseHash ];
447
+
448
+ }
449
+
450
+ // share the first normal
451
+ const otherNext = ( otherIndex + 1 ) % otherVertCount;
452
+ if (
453
+ vertNormals[ index ] && otherNormals[ otherNext ] &&
454
+ vertNormals[ index ] !== otherNormals[ otherNext ]
455
+ ) {
456
+
457
+ otherNormals[ otherNext ].norm.add( vertNormals[ index ].norm );
458
+ vertNormals[ index ].norm = otherNormals[ otherNext ].norm;
459
+
460
+ }
461
+
462
+ let sharedNormal1 = vertNormals[ index ] || otherNormals[ otherNext ];
463
+ if ( sharedNormal1 === null ) {
464
+
465
+ // it's possible to encounter an edge of a triangle that has already been traversed meaning
466
+ // both edges already have different normals defined and shared. To work around this we create
467
+ // a wrapper object so when those edges are merged the normals can be updated everywhere.
468
+ sharedNormal1 = { norm: new Vector3() };
469
+ normals.push( sharedNormal1.norm );
470
+
471
+ }
472
+
473
+ if ( vertNormals[ index ] === null ) {
474
+
475
+ vertNormals[ index ] = sharedNormal1;
476
+ sharedNormal1.norm.add( faceNormal );
477
+
478
+ }
479
+
480
+ if ( otherNormals[ otherNext ] === null ) {
481
+
482
+ otherNormals[ otherNext ] = sharedNormal1;
483
+ sharedNormal1.norm.add( otherFaceNormal );
484
+
485
+ }
486
+
487
+ // share the second normal
488
+ if (
489
+ vertNormals[ next ] && otherNormals[ otherIndex ] &&
490
+ vertNormals[ next ] !== otherNormals[ otherIndex ]
491
+ ) {
492
+
493
+ otherNormals[ otherIndex ].norm.add( vertNormals[ next ].norm );
494
+ vertNormals[ next ].norm = otherNormals[ otherIndex ].norm;
495
+
496
+ }
497
+
498
+ let sharedNormal2 = vertNormals[ next ] || otherNormals[ otherIndex ];
499
+ if ( sharedNormal2 === null ) {
500
+
501
+ sharedNormal2 = { norm: new Vector3() };
502
+ normals.push( sharedNormal2.norm );
503
+
504
+ }
505
+
506
+ if ( vertNormals[ next ] === null ) {
507
+
508
+ vertNormals[ next ] = sharedNormal2;
509
+ sharedNormal2.norm.add( faceNormal );
510
+
511
+ }
512
+
513
+ if ( otherNormals[ otherIndex ] === null ) {
514
+
515
+ otherNormals[ otherIndex ] = sharedNormal2;
516
+ sharedNormal2.norm.add( otherFaceNormal );
517
+
518
+ }
519
+
520
+ }
521
+
522
+ }
523
+
524
+ }
525
+
526
+ }
527
+
528
+ // The normals of each face have been added up so now we average them by normalizing the vector.
529
+ for ( let i = 0, l = normals.length; i < l; i ++ ) {
530
+
531
+ normals[ i ].normalize();
532
+
533
+ }
534
+
535
+ }
536
+
537
+ function isPartType( type ) {
538
+
539
+ return type === 'Part' || type === 'Unofficial_Part';
540
+
541
+ }
542
+
543
+ function isPrimitiveType( type ) {
544
+
545
+ return /primitive/i.test( type ) || type === 'Subpart';
546
+
547
+ }
548
+
549
+ class LineParser {
550
+
551
+ constructor( line, lineNumber ) {
552
+
553
+ this.line = line;
554
+ this.lineLength = line.length;
555
+ this.currentCharIndex = 0;
556
+ this.currentChar = ' ';
557
+ this.lineNumber = lineNumber;
558
+
559
+ }
560
+
561
+ seekNonSpace() {
562
+
563
+ while ( this.currentCharIndex < this.lineLength ) {
564
+
565
+ this.currentChar = this.line.charAt( this.currentCharIndex );
566
+
567
+ if ( this.currentChar !== ' ' && this.currentChar !== '\t' ) {
568
+
569
+ return;
570
+
571
+ }
572
+
573
+ this.currentCharIndex ++;
574
+
575
+ }
576
+
577
+ }
578
+
579
+ getToken() {
580
+
581
+ const pos0 = this.currentCharIndex ++;
582
+
583
+ // Seek space
584
+ while ( this.currentCharIndex < this.lineLength ) {
585
+
586
+ this.currentChar = this.line.charAt( this.currentCharIndex );
587
+
588
+ if ( this.currentChar === ' ' || this.currentChar === '\t' ) {
589
+
590
+ break;
591
+
592
+ }
593
+
594
+ this.currentCharIndex ++;
595
+
596
+ }
597
+
598
+ const pos1 = this.currentCharIndex;
599
+
600
+ this.seekNonSpace();
601
+
602
+ return this.line.substring( pos0, pos1 );
603
+
604
+ }
605
+
606
+ getVector() {
607
+
608
+ return new Vector3( parseFloat( this.getToken() ), parseFloat( this.getToken() ), parseFloat( this.getToken() ) );
609
+
610
+ }
611
+
612
+ getRemainingString() {
613
+
614
+ return this.line.substring( this.currentCharIndex, this.lineLength );
615
+
616
+ }
617
+
618
+ isAtTheEnd() {
619
+
620
+ return this.currentCharIndex >= this.lineLength;
621
+
622
+ }
623
+
624
+ setToEnd() {
625
+
626
+ this.currentCharIndex = this.lineLength;
627
+
628
+ }
629
+
630
+ getLineNumberString() {
631
+
632
+ return this.lineNumber >= 0 ? ' at line ' + this.lineNumber : '';
633
+
634
+ }
635
+
636
+ }
637
+
638
+ // Fetches and parses an intermediate representation of LDraw parts files.
639
+ class LDrawParsedCache {
640
+
641
+ constructor( loader ) {
642
+
643
+ this.loader = loader;
644
+ this._cache = {};
645
+
646
+ }
647
+
648
+ cloneResult( original ) {
649
+
650
+ const result = {};
651
+
652
+ // vertices are transformed and normals computed before being converted to geometry
653
+ // so these pieces must be cloned.
654
+ result.faces = original.faces.map( face => {
655
+
656
+ return {
657
+ colorCode: face.colorCode,
658
+ material: face.material,
659
+ vertices: face.vertices.map( v => v.clone() ),
660
+ normals: face.normals.map( () => null ),
661
+ faceNormal: null
662
+ };
663
+
664
+ } );
665
+
666
+ result.conditionalSegments = original.conditionalSegments.map( face => {
667
+
668
+ return {
669
+ colorCode: face.colorCode,
670
+ material: face.material,
671
+ vertices: face.vertices.map( v => v.clone() ),
672
+ controlPoints: face.controlPoints.map( v => v.clone() )
673
+ };
674
+
675
+ } );
676
+
677
+ result.lineSegments = original.lineSegments.map( face => {
678
+
679
+ return {
680
+ colorCode: face.colorCode,
681
+ material: face.material,
682
+ vertices: face.vertices.map( v => v.clone() )
683
+ };
684
+
685
+ } );
686
+
687
+ // none if this is subsequently modified
688
+ result.type = original.type;
689
+ result.category = original.category;
690
+ result.keywords = original.keywords;
691
+ result.author = original.author;
692
+ result.subobjects = original.subobjects;
693
+ result.fileName = original.fileName;
694
+ result.totalFaces = original.totalFaces;
695
+ result.startingConstructionStep = original.startingConstructionStep;
696
+ result.materials = original.materials;
697
+ result.group = null;
698
+ return result;
699
+
700
+ }
701
+
702
+ async fetchData( fileName ) {
703
+
704
+ let triedLowerCase = false;
705
+ let locationState = FILE_LOCATION_TRY_PARTS;
706
+ while ( locationState !== FILE_LOCATION_NOT_FOUND ) {
707
+
708
+ let subobjectURL = fileName;
709
+ switch ( locationState ) {
710
+
711
+ case FILE_LOCATION_AS_IS:
712
+ locationState = locationState + 1;
713
+ break;
714
+
715
+ case FILE_LOCATION_TRY_PARTS:
716
+ subobjectURL = 'parts/' + subobjectURL;
717
+ locationState = locationState + 1;
718
+ break;
719
+
720
+ case FILE_LOCATION_TRY_P:
721
+ subobjectURL = 'p/' + subobjectURL;
722
+ locationState = locationState + 1;
723
+ break;
724
+
725
+ case FILE_LOCATION_TRY_MODELS:
726
+ subobjectURL = 'models/' + subobjectURL;
727
+ locationState = locationState + 1;
728
+ break;
729
+
730
+ case FILE_LOCATION_TRY_RELATIVE:
731
+ subobjectURL = fileName.substring( 0, fileName.lastIndexOf( '/' ) + 1 ) + subobjectURL;
732
+ locationState = locationState + 1;
733
+ break;
734
+
735
+ case FILE_LOCATION_TRY_ABSOLUTE:
736
+
737
+ if ( triedLowerCase ) {
738
+
739
+ // Try absolute path
740
+ locationState = FILE_LOCATION_NOT_FOUND;
741
+
742
+ } else {
743
+
744
+ // Next attempt is lower case
745
+ fileName = fileName.toLowerCase();
746
+ subobjectURL = fileName;
747
+ triedLowerCase = true;
748
+ locationState = FILE_LOCATION_TRY_PARTS;
749
+
750
+ }
751
+
752
+ break;
753
+
754
+ }
755
+
756
+ const loader = this.loader;
757
+ const fileLoader = new FileLoader( loader.manager );
758
+ fileLoader.setPath( loader.partsLibraryPath );
759
+ fileLoader.setRequestHeader( loader.requestHeader );
760
+ fileLoader.setWithCredentials( loader.withCredentials );
761
+
762
+ try {
763
+
764
+ const text = await fileLoader.loadAsync( subobjectURL );
765
+ return text;
766
+
767
+ } catch {
768
+
769
+ continue;
770
+
771
+ }
772
+
773
+ }
774
+
775
+ throw new Error( 'LDrawLoader: Subobject "' + fileName + '" could not be loaded.' );
776
+
777
+ }
778
+
779
+ parse( text, fileName = null ) {
780
+
781
+ const loader = this.loader;
782
+
783
+ // final results
784
+ const faces = [];
785
+ const lineSegments = [];
786
+ const conditionalSegments = [];
787
+ const subobjects = [];
788
+ const materials = {};
789
+
790
+ const getLocalMaterial = colorCode => {
791
+
792
+ return materials[ colorCode ] || null;
793
+
794
+ };
795
+
796
+ let type = 'Model';
797
+ let category = null;
798
+ let keywords = null;
799
+ let author = null;
800
+ let totalFaces = 0;
801
+
802
+ // split into lines
803
+ if ( text.indexOf( '\r\n' ) !== - 1 ) {
804
+
805
+ // This is faster than String.split with regex that splits on both
806
+ text = text.replace( /\r\n/g, '\n' );
807
+
808
+ }
809
+
810
+ const lines = text.split( '\n' );
811
+ const numLines = lines.length;
812
+
813
+ let parsingEmbeddedFiles = false;
814
+ let currentEmbeddedFileName = null;
815
+ let currentEmbeddedText = null;
816
+
817
+ let bfcCertified = false;
818
+ let bfcCCW = true;
819
+ let bfcInverted = false;
820
+ let bfcCull = true;
821
+
822
+ let startingConstructionStep = false;
823
+
824
+ // Parse all line commands
825
+ for ( let lineIndex = 0; lineIndex < numLines; lineIndex ++ ) {
826
+
827
+ const line = lines[ lineIndex ];
828
+
829
+ if ( line.length === 0 ) continue;
830
+
831
+ if ( parsingEmbeddedFiles ) {
832
+
833
+ if ( line.startsWith( '0 FILE ' ) ) {
834
+
835
+ // Save previous embedded file in the cache
836
+ this.setData( currentEmbeddedFileName, currentEmbeddedText );
837
+
838
+ // New embedded text file
839
+ currentEmbeddedFileName = line.substring( 7 );
840
+ currentEmbeddedText = '';
841
+
842
+ } else {
843
+
844
+ currentEmbeddedText += line + '\n';
845
+
846
+ }
847
+
848
+ continue;
849
+
850
+ }
851
+
852
+ const lp = new LineParser( line, lineIndex + 1 );
853
+ lp.seekNonSpace();
854
+
855
+ if ( lp.isAtTheEnd() ) {
856
+
857
+ // Empty line
858
+ continue;
859
+
860
+ }
861
+
862
+ // Parse the line type
863
+ const lineType = lp.getToken();
864
+
865
+ let material;
866
+ let colorCode;
867
+ let segment;
868
+ let ccw;
869
+ let doubleSided;
870
+ let v0, v1, v2, v3, c0, c1;
871
+
872
+ switch ( lineType ) {
873
+
874
+ // Line type 0: Comment or META
875
+ case '0':
876
+
877
+ // Parse meta directive
878
+ const meta = lp.getToken();
879
+
880
+ if ( meta ) {
881
+
882
+ switch ( meta ) {
883
+
884
+ case '!LDRAW_ORG':
885
+
886
+ type = lp.getToken();
887
+ break;
888
+
889
+ case '!COLOUR':
890
+
891
+ material = loader.parseColorMetaDirective( lp );
892
+ if ( material ) {
893
+
894
+ materials[ material.userData.code ] = material;
895
+
896
+ } else {
897
+
898
+ console.warn( 'LDrawLoader: Error parsing material' + lp.getLineNumberString() );
899
+
900
+ }
901
+
902
+ break;
903
+
904
+ case '!CATEGORY':
905
+
906
+ category = lp.getToken();
907
+ break;
908
+
909
+ case '!KEYWORDS':
910
+
911
+ const newKeywords = lp.getRemainingString().split( ',' );
912
+ if ( newKeywords.length > 0 ) {
913
+
914
+ if ( ! keywords ) {
915
+
916
+ keywords = [];
917
+
918
+ }
919
+
920
+ newKeywords.forEach( function ( keyword ) {
921
+
922
+ keywords.push( keyword.trim() );
923
+
924
+ } );
925
+
926
+ }
927
+
928
+ break;
929
+
930
+ case 'FILE':
931
+
932
+ if ( lineIndex > 0 ) {
933
+
934
+ // Start embedded text files parsing
935
+ parsingEmbeddedFiles = true;
936
+ currentEmbeddedFileName = lp.getRemainingString();
937
+ currentEmbeddedText = '';
938
+
939
+ bfcCertified = false;
940
+ bfcCCW = true;
941
+
942
+ }
943
+
944
+ break;
945
+
946
+ case 'BFC':
947
+
948
+ // Changes to the backface culling state
949
+ while ( ! lp.isAtTheEnd() ) {
950
+
951
+ const token = lp.getToken();
952
+
953
+ switch ( token ) {
954
+
955
+ case 'CERTIFY':
956
+ case 'NOCERTIFY':
957
+
958
+ bfcCertified = token === 'CERTIFY';
959
+ bfcCCW = true;
960
+
961
+ break;
962
+
963
+ case 'CW':
964
+ case 'CCW':
965
+
966
+ bfcCCW = token === 'CCW';
967
+
968
+ break;
969
+
970
+ case 'INVERTNEXT':
971
+
972
+ bfcInverted = true;
973
+
974
+ break;
975
+
976
+ case 'CLIP':
977
+ case 'NOCLIP':
978
+
979
+ bfcCull = token === 'CLIP';
980
+
981
+ break;
982
+
983
+ default:
984
+
985
+ console.warn( 'THREE.LDrawLoader: BFC directive "' + token + '" is unknown.' );
986
+
987
+ break;
988
+
989
+ }
990
+
991
+ }
992
+
993
+ break;
994
+
995
+ case 'STEP':
996
+
997
+ startingConstructionStep = true;
998
+
999
+ break;
1000
+
1001
+ case 'Author:':
1002
+
1003
+ author = lp.getToken();
1004
+
1005
+ break;
1006
+
1007
+ default:
1008
+ // Other meta directives are not implemented
1009
+ break;
1010
+
1011
+ }
1012
+
1013
+ }
1014
+
1015
+ break;
1016
+
1017
+ // Line type 1: Sub-object file
1018
+ case '1':
1019
+
1020
+ colorCode = lp.getToken();
1021
+ material = getLocalMaterial( colorCode );
1022
+
1023
+ const posX = parseFloat( lp.getToken() );
1024
+ const posY = parseFloat( lp.getToken() );
1025
+ const posZ = parseFloat( lp.getToken() );
1026
+ const m0 = parseFloat( lp.getToken() );
1027
+ const m1 = parseFloat( lp.getToken() );
1028
+ const m2 = parseFloat( lp.getToken() );
1029
+ const m3 = parseFloat( lp.getToken() );
1030
+ const m4 = parseFloat( lp.getToken() );
1031
+ const m5 = parseFloat( lp.getToken() );
1032
+ const m6 = parseFloat( lp.getToken() );
1033
+ const m7 = parseFloat( lp.getToken() );
1034
+ const m8 = parseFloat( lp.getToken() );
1035
+
1036
+ const matrix = new Matrix4().set(
1037
+ m0, m1, m2, posX,
1038
+ m3, m4, m5, posY,
1039
+ m6, m7, m8, posZ,
1040
+ 0, 0, 0, 1
1041
+ );
1042
+
1043
+ let fileName = lp.getRemainingString().trim().replace( /\\/g, '/' );
1044
+
1045
+ if ( loader.fileMap[ fileName ] ) {
1046
+
1047
+ // Found the subobject path in the preloaded file path map
1048
+ fileName = loader.fileMap[ fileName ];
1049
+
1050
+ } else {
1051
+
1052
+ // Standardized subfolders
1053
+ if ( fileName.startsWith( 's/' ) ) {
1054
+
1055
+ fileName = 'parts/' + fileName;
1056
+
1057
+ } else if ( fileName.startsWith( '48/' ) ) {
1058
+
1059
+ fileName = 'p/' + fileName;
1060
+
1061
+ }
1062
+
1063
+ }
1064
+
1065
+ subobjects.push( {
1066
+ material: material,
1067
+ colorCode: colorCode,
1068
+ matrix: matrix,
1069
+ fileName: fileName,
1070
+ inverted: bfcInverted,
1071
+ startingConstructionStep: startingConstructionStep
1072
+ } );
1073
+
1074
+ bfcInverted = false;
1075
+
1076
+ break;
1077
+
1078
+ // Line type 2: Line segment
1079
+ case '2':
1080
+
1081
+ colorCode = lp.getToken();
1082
+ material = getLocalMaterial( colorCode );
1083
+ v0 = lp.getVector();
1084
+ v1 = lp.getVector();
1085
+
1086
+ segment = {
1087
+ material: material,
1088
+ colorCode: colorCode,
1089
+ vertices: [ v0, v1 ],
1090
+ };
1091
+
1092
+ lineSegments.push( segment );
1093
+
1094
+ break;
1095
+
1096
+ // Line type 5: Conditional Line segment
1097
+ case '5':
1098
+
1099
+ colorCode = lp.getToken();
1100
+ material = getLocalMaterial( colorCode );
1101
+ v0 = lp.getVector();
1102
+ v1 = lp.getVector();
1103
+ c0 = lp.getVector();
1104
+ c1 = lp.getVector();
1105
+
1106
+ segment = {
1107
+ material: material,
1108
+ colorCode: colorCode,
1109
+ vertices: [ v0, v1 ],
1110
+ controlPoints: [ c0, c1 ],
1111
+ };
1112
+
1113
+ conditionalSegments.push( segment );
1114
+
1115
+ break;
1116
+
1117
+ // Line type 3: Triangle
1118
+ case '3':
1119
+
1120
+ colorCode = lp.getToken();
1121
+ material = getLocalMaterial( colorCode );
1122
+ ccw = bfcCCW;
1123
+ doubleSided = ! bfcCertified || ! bfcCull;
1124
+
1125
+ if ( ccw === true ) {
1126
+
1127
+ v0 = lp.getVector();
1128
+ v1 = lp.getVector();
1129
+ v2 = lp.getVector();
1130
+
1131
+ } else {
1132
+
1133
+ v2 = lp.getVector();
1134
+ v1 = lp.getVector();
1135
+ v0 = lp.getVector();
1136
+
1137
+ }
1138
+
1139
+ faces.push( {
1140
+ material: material,
1141
+ colorCode: colorCode,
1142
+ faceNormal: null,
1143
+ vertices: [ v0, v1, v2 ],
1144
+ normals: [ null, null, null ],
1145
+ } );
1146
+ totalFaces ++;
1147
+
1148
+ if ( doubleSided === true ) {
1149
+
1150
+ faces.push( {
1151
+ material: material,
1152
+ colorCode: colorCode,
1153
+ faceNormal: null,
1154
+ vertices: [ v2, v1, v0 ],
1155
+ normals: [ null, null, null ],
1156
+ } );
1157
+ totalFaces ++;
1158
+
1159
+ }
1160
+
1161
+ break;
1162
+
1163
+ // Line type 4: Quadrilateral
1164
+ case '4':
1165
+
1166
+ colorCode = lp.getToken();
1167
+ material = getLocalMaterial( colorCode );
1168
+ ccw = bfcCCW;
1169
+ doubleSided = ! bfcCertified || ! bfcCull;
1170
+
1171
+ if ( ccw === true ) {
1172
+
1173
+ v0 = lp.getVector();
1174
+ v1 = lp.getVector();
1175
+ v2 = lp.getVector();
1176
+ v3 = lp.getVector();
1177
+
1178
+ } else {
1179
+
1180
+ v3 = lp.getVector();
1181
+ v2 = lp.getVector();
1182
+ v1 = lp.getVector();
1183
+ v0 = lp.getVector();
1184
+
1185
+ }
1186
+
1187
+ // specifically place the triangle diagonal in the v0 and v1 slots so we can
1188
+ // account for the doubling of vertices later when smoothing normals.
1189
+ faces.push( {
1190
+ material: material,
1191
+ colorCode: colorCode,
1192
+ faceNormal: null,
1193
+ vertices: [ v0, v1, v2, v3 ],
1194
+ normals: [ null, null, null, null ],
1195
+ } );
1196
+ totalFaces += 2;
1197
+
1198
+ if ( doubleSided === true ) {
1199
+
1200
+ faces.push( {
1201
+ material: material,
1202
+ colorCode: colorCode,
1203
+ faceNormal: null,
1204
+ vertices: [ v3, v2, v1, v0 ],
1205
+ normals: [ null, null, null, null ],
1206
+ } );
1207
+ totalFaces += 2;
1208
+
1209
+ }
1210
+
1211
+ break;
1212
+
1213
+ default:
1214
+ throw new Error( 'LDrawLoader: Unknown line type "' + lineType + '"' + lp.getLineNumberString() + '.' );
1215
+
1216
+ }
1217
+
1218
+ }
1219
+
1220
+ if ( parsingEmbeddedFiles ) {
1221
+
1222
+ this.setData( currentEmbeddedFileName, currentEmbeddedText );
1223
+
1224
+ }
1225
+
1226
+ return {
1227
+ faces,
1228
+ conditionalSegments,
1229
+ lineSegments,
1230
+ type,
1231
+ category,
1232
+ keywords,
1233
+ author,
1234
+ subobjects,
1235
+ totalFaces,
1236
+ startingConstructionStep,
1237
+ materials,
1238
+ fileName,
1239
+ group: null
1240
+ };
1241
+
1242
+ }
1243
+
1244
+ // returns an (optionally cloned) instance of the data
1245
+ getData( fileName, clone = true ) {
1246
+
1247
+ const key = fileName.toLowerCase();
1248
+ const result = this._cache[ key ];
1249
+ if ( result === null || result instanceof Promise ) {
1250
+
1251
+ return null;
1252
+
1253
+ }
1254
+
1255
+ if ( clone ) {
1256
+
1257
+ return this.cloneResult( result );
1258
+
1259
+ } else {
1260
+
1261
+ return result;
1262
+
1263
+ }
1264
+
1265
+ }
1266
+
1267
+ // kicks off a fetch and parse of the requested data if it hasn't already been loaded. Returns when
1268
+ // the data is ready to use and can be retrieved synchronously with "getData".
1269
+ async ensureDataLoaded( fileName ) {
1270
+
1271
+ const key = fileName.toLowerCase();
1272
+ if ( ! ( key in this._cache ) ) {
1273
+
1274
+ // replace the promise with a copy of the parsed data for immediate processing
1275
+ this._cache[ key ] = this.fetchData( fileName ).then( text => {
1276
+
1277
+ const info = this.parse( text, fileName );
1278
+ this._cache[ key ] = info;
1279
+ return info;
1280
+
1281
+ } );
1282
+
1283
+ }
1284
+
1285
+ await this._cache[ key ];
1286
+
1287
+ }
1288
+
1289
+ // sets the data in the cache from parsed data
1290
+ setData( fileName, text ) {
1291
+
1292
+ const key = fileName.toLowerCase();
1293
+ this._cache[ key ] = this.parse( text, fileName );
1294
+
1295
+ }
1296
+
1297
+ }
1298
+
1299
+ // returns the material for an associated color code. If the color code is 16 for a face or 24 for
1300
+ // an edge then the passthroughColorCode is used.
1301
+ function getMaterialFromCode( colorCode, parentColorCode, materialHierarchy, forEdge ) {
1302
+
1303
+ const isPassthrough = ! forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
1304
+ if ( isPassthrough ) {
1305
+
1306
+ colorCode = parentColorCode;
1307
+
1308
+ }
1309
+
1310
+ return materialHierarchy[ colorCode ] || null;
1311
+
1312
+ }
1313
+
1314
+ // Class used to parse and build LDraw parts as three.js objects and cache them if they're a "Part" type.
1315
+ class LDrawPartsGeometryCache {
1316
+
1317
+ constructor( loader ) {
1318
+
1319
+ this.loader = loader;
1320
+ this.parseCache = new LDrawParsedCache( loader );
1321
+ this._cache = {};
1322
+
1323
+ }
1324
+
1325
+ // Convert the given file information into a mesh by processing subobjects.
1326
+ async processIntoMesh( info ) {
1327
+
1328
+ const loader = this.loader;
1329
+ const parseCache = this.parseCache;
1330
+ const faceMaterials = new Set();
1331
+
1332
+ // Processes the part subobject information to load child parts and merge geometry onto part
1333
+ // piece object.
1334
+ const processInfoSubobjects = async ( info, subobject = null ) => {
1335
+
1336
+ const subobjects = info.subobjects;
1337
+ const promises = [];
1338
+
1339
+ // Trigger load of all subobjects. If a subobject isn't a primitive then load it as a separate
1340
+ // group which lets instruction steps apply correctly.
1341
+ for ( let i = 0, l = subobjects.length; i < l; i ++ ) {
1342
+
1343
+ const subobject = subobjects[ i ];
1344
+ const promise = parseCache.ensureDataLoaded( subobject.fileName ).then( () => {
1345
+
1346
+ const subobjectInfo = parseCache.getData( subobject.fileName, false );
1347
+ if ( ! isPrimitiveType( subobjectInfo.type ) ) {
1348
+
1349
+ return this.loadModel( subobject.fileName ).catch( error => {
1350
+
1351
+ console.warn( error );
1352
+ return null;
1353
+
1354
+ } );
1355
+
1356
+ }
1357
+
1358
+ return processInfoSubobjects( parseCache.getData( subobject.fileName ), subobject );
1359
+
1360
+ } );
1361
+
1362
+ promises.push( promise );
1363
+
1364
+ }
1365
+
1366
+ const group = new Group();
1367
+ group.userData.category = info.category;
1368
+ group.userData.keywords = info.keywords;
1369
+ group.userData.author = info.author;
1370
+ group.userData.type = info.type;
1371
+ group.userData.fileName = info.fileName;
1372
+ info.group = group;
1373
+
1374
+ const subobjectInfos = await Promise.all( promises );
1375
+ for ( let i = 0, l = subobjectInfos.length; i < l; i ++ ) {
1376
+
1377
+ const subobject = info.subobjects[ i ];
1378
+ const subobjectInfo = subobjectInfos[ i ];
1379
+
1380
+ if ( subobjectInfo === null ) {
1381
+
1382
+ // the subobject failed to load
1383
+ continue;
1384
+
1385
+ }
1386
+
1387
+ // if the subobject was loaded as a separate group then apply the parent scopes materials
1388
+ if ( subobjectInfo.isGroup ) {
1389
+
1390
+ const subobjectGroup = subobjectInfo;
1391
+ subobject.matrix.decompose( subobjectGroup.position, subobjectGroup.quaternion, subobjectGroup.scale );
1392
+ subobjectGroup.userData.startingConstructionStep = subobject.startingConstructionStep;
1393
+ subobjectGroup.name = subobject.fileName;
1394
+
1395
+ loader.applyMaterialsToMesh( subobjectGroup, subobject.colorCode, info.materials );
1396
+ subobjectGroup.userData.colorCode = subobject.colorCode;
1397
+
1398
+ group.add( subobjectGroup );
1399
+ continue;
1400
+
1401
+ }
1402
+
1403
+ // add the subobject group if it has children in case it has both children and primitives
1404
+ if ( subobjectInfo.group.children.length ) {
1405
+
1406
+ group.add( subobjectInfo.group );
1407
+
1408
+ }
1409
+
1410
+ // transform the primitives into the local space of the parent piece and append them to
1411
+ // to the parent primitives list.
1412
+ const parentLineSegments = info.lineSegments;
1413
+ const parentConditionalSegments = info.conditionalSegments;
1414
+ const parentFaces = info.faces;
1415
+
1416
+ const lineSegments = subobjectInfo.lineSegments;
1417
+ const conditionalSegments = subobjectInfo.conditionalSegments;
1418
+
1419
+ const faces = subobjectInfo.faces;
1420
+ const matrix = subobject.matrix;
1421
+ const inverted = subobject.inverted;
1422
+ const matrixScaleInverted = matrix.determinant() < 0;
1423
+ const colorCode = subobject.colorCode;
1424
+
1425
+ const lineColorCode = colorCode === MAIN_COLOUR_CODE ? MAIN_EDGE_COLOUR_CODE : colorCode;
1426
+ for ( let i = 0, l = lineSegments.length; i < l; i ++ ) {
1427
+
1428
+ const ls = lineSegments[ i ];
1429
+ const vertices = ls.vertices;
1430
+ vertices[ 0 ].applyMatrix4( matrix );
1431
+ vertices[ 1 ].applyMatrix4( matrix );
1432
+ ls.colorCode = ls.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : ls.colorCode;
1433
+ ls.material = ls.material || getMaterialFromCode( ls.colorCode, ls.colorCode, info.materials, true );
1434
+
1435
+ parentLineSegments.push( ls );
1436
+
1437
+ }
1438
+
1439
+ for ( let i = 0, l = conditionalSegments.length; i < l; i ++ ) {
1440
+
1441
+ const os = conditionalSegments[ i ];
1442
+ const vertices = os.vertices;
1443
+ const controlPoints = os.controlPoints;
1444
+ vertices[ 0 ].applyMatrix4( matrix );
1445
+ vertices[ 1 ].applyMatrix4( matrix );
1446
+ controlPoints[ 0 ].applyMatrix4( matrix );
1447
+ controlPoints[ 1 ].applyMatrix4( matrix );
1448
+ os.colorCode = os.colorCode === MAIN_EDGE_COLOUR_CODE ? lineColorCode : os.colorCode;
1449
+ os.material = os.material || getMaterialFromCode( os.colorCode, os.colorCode, info.materials, true );
1450
+
1451
+ parentConditionalSegments.push( os );
1452
+
1453
+ }
1454
+
1455
+ for ( let i = 0, l = faces.length; i < l; i ++ ) {
1456
+
1457
+ const tri = faces[ i ];
1458
+ const vertices = tri.vertices;
1459
+ for ( let i = 0, l = vertices.length; i < l; i ++ ) {
1460
+
1461
+ vertices[ i ].applyMatrix4( matrix );
1462
+
1463
+ }
1464
+
1465
+ tri.colorCode = tri.colorCode === MAIN_COLOUR_CODE ? colorCode : tri.colorCode;
1466
+ tri.material = tri.material || getMaterialFromCode( tri.colorCode, colorCode, info.materials, false );
1467
+ faceMaterials.add( tri.colorCode );
1468
+
1469
+ // If the scale of the object is negated then the triangle winding order
1470
+ // needs to be flipped.
1471
+ if ( matrixScaleInverted !== inverted ) {
1472
+
1473
+ vertices.reverse();
1474
+
1475
+ }
1476
+
1477
+ parentFaces.push( tri );
1478
+
1479
+ }
1480
+
1481
+ info.totalFaces += subobjectInfo.totalFaces;
1482
+
1483
+ }
1484
+
1485
+ // Apply the parent subobjects pass through material code to this object. This is done several times due
1486
+ // to material scoping.
1487
+ if ( subobject ) {
1488
+
1489
+ loader.applyMaterialsToMesh( group, subobject.colorCode, info.materials );
1490
+ group.userData.colorCode = subobject.colorCode;
1491
+
1492
+ }
1493
+
1494
+ return info;
1495
+
1496
+ };
1497
+
1498
+ // Track material use to see if we need to use the normal smooth slow path for hard edges.
1499
+ for ( let i = 0, l = info.faces; i < l; i ++ ) {
1500
+
1501
+ faceMaterials.add( info.faces[ i ].colorCode );
1502
+
1503
+ }
1504
+
1505
+ await processInfoSubobjects( info );
1506
+
1507
+ if ( loader.smoothNormals ) {
1508
+
1509
+ const checkSubSegments = faceMaterials.size > 1;
1510
+ generateFaceNormals( info.faces );
1511
+ smoothNormals( info.faces, info.lineSegments, checkSubSegments );
1512
+
1513
+ }
1514
+
1515
+ // Add the primitive objects and metadata.
1516
+ const group = info.group;
1517
+ if ( info.faces.length > 0 ) {
1518
+
1519
+ group.add( createObject( info.faces, 3, false, info.totalFaces ) );
1520
+
1521
+ }
1522
+
1523
+ if ( info.lineSegments.length > 0 ) {
1524
+
1525
+ group.add( createObject( info.lineSegments, 2 ) );
1526
+
1527
+ }
1528
+
1529
+ if ( info.conditionalSegments.length > 0 ) {
1530
+
1531
+ group.add( createObject( info.conditionalSegments, 2, true ) );
1532
+
1533
+ }
1534
+
1535
+ return group;
1536
+
1537
+ }
1538
+
1539
+ hasCachedModel( fileName ) {
1540
+
1541
+ return fileName !== null && fileName.toLowerCase() in this._cache;
1542
+
1543
+ }
1544
+
1545
+ async getCachedModel( fileName ) {
1546
+
1547
+ if ( fileName !== null && this.hasCachedModel( fileName ) ) {
1548
+
1549
+ const key = fileName.toLowerCase();
1550
+ const group = await this._cache[ key ];
1551
+ return group.clone();
1552
+
1553
+ } else {
1554
+
1555
+ return null;
1556
+
1557
+ }
1558
+
1559
+ }
1560
+
1561
+ // Loads and parses the model with the given file name. Returns a cached copy if available.
1562
+ async loadModel( fileName ) {
1563
+
1564
+ const parseCache = this.parseCache;
1565
+ const key = fileName.toLowerCase();
1566
+ if ( this.hasCachedModel( fileName ) ) {
1567
+
1568
+ // Return cached model if available.
1569
+ return this.getCachedModel( fileName );
1570
+
1571
+ } else {
1572
+
1573
+ // Otherwise parse a new model.
1574
+ // Ensure the file data is loaded and pre parsed.
1575
+ await parseCache.ensureDataLoaded( fileName );
1576
+
1577
+ const info = parseCache.getData( fileName );
1578
+ const promise = this.processIntoMesh( info );
1579
+
1580
+ // Now that the file has loaded it's possible that another part parse has been waiting in parallel
1581
+ // so check the cache again to see if it's been added since the last async operation so we don't
1582
+ // do unnecessary work.
1583
+ if ( this.hasCachedModel( fileName ) ) {
1584
+
1585
+ return this.getCachedModel( fileName );
1586
+
1587
+ }
1588
+
1589
+ // Cache object if it's a part so it can be reused later.
1590
+ if ( isPartType( info.type ) ) {
1591
+
1592
+ this._cache[ key ] = promise;
1593
+
1594
+ }
1595
+
1596
+ // return a copy
1597
+ const group = await promise;
1598
+ return group.clone();
1599
+
1600
+ }
1601
+
1602
+ }
1603
+
1604
+ // parses the given model text into a renderable object. Returns cached copy if available.
1605
+ async parseModel( text ) {
1606
+
1607
+ const parseCache = this.parseCache;
1608
+ const info = parseCache.parse( text );
1609
+ if ( isPartType( info.type ) && this.hasCachedModel( info.fileName ) ) {
1610
+
1611
+ return this.getCachedModel( info.fileName );
1612
+
1613
+ }
1614
+
1615
+ return this.processIntoMesh( info );
1616
+
1617
+ }
1618
+
1619
+ }
1620
+
1621
+ function sortByMaterial( a, b ) {
1622
+
1623
+ if ( a.colorCode === b.colorCode ) {
1624
+
1625
+ return 0;
1626
+
1627
+ }
1628
+
1629
+ if ( a.colorCode < b.colorCode ) {
1630
+
1631
+ return - 1;
1632
+
1633
+ }
1634
+
1635
+ return 1;
1636
+
1637
+ }
1638
+
1639
+ function createObject( elements, elementSize, isConditionalSegments = false, totalElements = null ) {
1640
+
1641
+ // Creates a LineSegments (elementSize = 2) or a Mesh (elementSize = 3 )
1642
+ // With per face / segment material, implemented with mesh groups and materials array
1643
+
1644
+ // Sort the faces or line segments by color code to make later the mesh groups
1645
+ elements.sort( sortByMaterial );
1646
+
1647
+ if ( totalElements === null ) {
1648
+
1649
+ totalElements = elements.length;
1650
+
1651
+ }
1652
+
1653
+ const positions = new Float32Array( elementSize * totalElements * 3 );
1654
+ const normals = elementSize === 3 ? new Float32Array( elementSize * totalElements * 3 ) : null;
1655
+ const materials = [];
1656
+
1657
+ const quadArray = new Array( 6 );
1658
+ const bufferGeometry = new BufferGeometry();
1659
+ let prevMaterial = null;
1660
+ let index0 = 0;
1661
+ let numGroupVerts = 0;
1662
+ let offset = 0;
1663
+
1664
+ for ( let iElem = 0, nElem = elements.length; iElem < nElem; iElem ++ ) {
1665
+
1666
+ const elem = elements[ iElem ];
1667
+ let vertices = elem.vertices;
1668
+ if ( vertices.length === 4 ) {
1669
+
1670
+ quadArray[ 0 ] = vertices[ 0 ];
1671
+ quadArray[ 1 ] = vertices[ 1 ];
1672
+ quadArray[ 2 ] = vertices[ 2 ];
1673
+ quadArray[ 3 ] = vertices[ 0 ];
1674
+ quadArray[ 4 ] = vertices[ 2 ];
1675
+ quadArray[ 5 ] = vertices[ 3 ];
1676
+ vertices = quadArray;
1677
+
1678
+ }
1679
+
1680
+ for ( let j = 0, l = vertices.length; j < l; j ++ ) {
1681
+
1682
+ const v = vertices[ j ];
1683
+ const index = offset + j * 3;
1684
+ positions[ index + 0 ] = v.x;
1685
+ positions[ index + 1 ] = v.y;
1686
+ positions[ index + 2 ] = v.z;
1687
+
1688
+ }
1689
+
1690
+ // create the normals array if this is a set of faces
1691
+ if ( elementSize === 3 ) {
1692
+
1693
+ if ( ! elem.faceNormal ) {
1694
+
1695
+ const v0 = vertices[ 0 ];
1696
+ const v1 = vertices[ 1 ];
1697
+ const v2 = vertices[ 2 ];
1698
+ _tempVec0.subVectors( v1, v0 );
1699
+ _tempVec1.subVectors( v2, v1 );
1700
+ elem.faceNormal = new Vector3()
1701
+ .crossVectors( _tempVec0, _tempVec1 )
1702
+ .normalize();
1703
+
1704
+ }
1705
+
1706
+ let elemNormals = elem.normals;
1707
+ if ( elemNormals.length === 4 ) {
1708
+
1709
+ quadArray[ 0 ] = elemNormals[ 0 ];
1710
+ quadArray[ 1 ] = elemNormals[ 1 ];
1711
+ quadArray[ 2 ] = elemNormals[ 2 ];
1712
+ quadArray[ 3 ] = elemNormals[ 0 ];
1713
+ quadArray[ 4 ] = elemNormals[ 2 ];
1714
+ quadArray[ 5 ] = elemNormals[ 3 ];
1715
+ elemNormals = quadArray;
1716
+
1717
+ }
1718
+
1719
+ for ( let j = 0, l = elemNormals.length; j < l; j ++ ) {
1720
+
1721
+ // use face normal if a vertex normal is not provided
1722
+ let n = elem.faceNormal;
1723
+ if ( elemNormals[ j ] ) {
1724
+
1725
+ n = elemNormals[ j ].norm;
1726
+
1727
+ }
1728
+
1729
+ const index = offset + j * 3;
1730
+ normals[ index + 0 ] = n.x;
1731
+ normals[ index + 1 ] = n.y;
1732
+ normals[ index + 2 ] = n.z;
1733
+
1734
+ }
1735
+
1736
+ }
1737
+
1738
+ if ( prevMaterial !== elem.colorCode ) {
1739
+
1740
+ if ( prevMaterial !== null ) {
1741
+
1742
+ bufferGeometry.addGroup( index0, numGroupVerts, materials.length - 1 );
1743
+
1744
+ }
1745
+
1746
+ const material = elem.material;
1747
+
1748
+ if ( material !== null ) {
1749
+
1750
+ if ( elementSize === 3 ) {
1751
+
1752
+ materials.push( material );
1753
+
1754
+ } else if ( elementSize === 2 ) {
1755
+
1756
+ if ( isConditionalSegments ) {
1757
+
1758
+ materials.push( material.userData.edgeMaterial.userData.conditionalEdgeMaterial );
1759
+
1760
+ } else {
1761
+
1762
+ materials.push( material.userData.edgeMaterial );
1763
+
1764
+ }
1765
+
1766
+ }
1767
+
1768
+ } else {
1769
+
1770
+ // If a material has not been made available yet then keep the color code string in the material array
1771
+ // to save the spot for the material once a parent scopes materials are being applied to the object.
1772
+ materials.push( elem.colorCode );
1773
+
1774
+ }
1775
+
1776
+ prevMaterial = elem.colorCode;
1777
+ index0 = offset / 3;
1778
+ numGroupVerts = vertices.length;
1779
+
1780
+ } else {
1781
+
1782
+ numGroupVerts += vertices.length;
1783
+
1784
+ }
1785
+
1786
+ offset += 3 * vertices.length;
1787
+
1788
+ }
1789
+
1790
+ if ( numGroupVerts > 0 ) {
1791
+
1792
+ bufferGeometry.addGroup( index0, Infinity, materials.length - 1 );
1793
+
1794
+ }
1795
+
1796
+ bufferGeometry.setAttribute( 'position', new BufferAttribute( positions, 3 ) );
1797
+
1798
+ if ( normals !== null ) {
1799
+
1800
+ bufferGeometry.setAttribute( 'normal', new BufferAttribute( normals, 3 ) );
1801
+
1802
+ }
1803
+
1804
+ let object3d = null;
1805
+
1806
+ if ( elementSize === 2 ) {
1807
+
1808
+ if ( isConditionalSegments ) {
1809
+
1810
+ object3d = new ConditionalLineSegments( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
1811
+
1812
+ } else {
1813
+
1814
+ object3d = new LineSegments( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
1815
+
1816
+ }
1817
+
1818
+ } else if ( elementSize === 3 ) {
1819
+
1820
+ object3d = new Mesh( bufferGeometry, materials.length === 1 ? materials[ 0 ] : materials );
1821
+
1822
+ }
1823
+
1824
+ if ( isConditionalSegments ) {
1825
+
1826
+ object3d.isConditionalLine = true;
1827
+
1828
+ const controlArray0 = new Float32Array( elements.length * 3 * 2 );
1829
+ const controlArray1 = new Float32Array( elements.length * 3 * 2 );
1830
+ const directionArray = new Float32Array( elements.length * 3 * 2 );
1831
+ for ( let i = 0, l = elements.length; i < l; i ++ ) {
1832
+
1833
+ const os = elements[ i ];
1834
+ const vertices = os.vertices;
1835
+ const controlPoints = os.controlPoints;
1836
+ const c0 = controlPoints[ 0 ];
1837
+ const c1 = controlPoints[ 1 ];
1838
+ const v0 = vertices[ 0 ];
1839
+ const v1 = vertices[ 1 ];
1840
+ const index = i * 3 * 2;
1841
+ controlArray0[ index + 0 ] = c0.x;
1842
+ controlArray0[ index + 1 ] = c0.y;
1843
+ controlArray0[ index + 2 ] = c0.z;
1844
+ controlArray0[ index + 3 ] = c0.x;
1845
+ controlArray0[ index + 4 ] = c0.y;
1846
+ controlArray0[ index + 5 ] = c0.z;
1847
+
1848
+ controlArray1[ index + 0 ] = c1.x;
1849
+ controlArray1[ index + 1 ] = c1.y;
1850
+ controlArray1[ index + 2 ] = c1.z;
1851
+ controlArray1[ index + 3 ] = c1.x;
1852
+ controlArray1[ index + 4 ] = c1.y;
1853
+ controlArray1[ index + 5 ] = c1.z;
1854
+
1855
+ directionArray[ index + 0 ] = v1.x - v0.x;
1856
+ directionArray[ index + 1 ] = v1.y - v0.y;
1857
+ directionArray[ index + 2 ] = v1.z - v0.z;
1858
+ directionArray[ index + 3 ] = v1.x - v0.x;
1859
+ directionArray[ index + 4 ] = v1.y - v0.y;
1860
+ directionArray[ index + 5 ] = v1.z - v0.z;
1861
+
1862
+ }
1863
+
1864
+ bufferGeometry.setAttribute( 'control0', new BufferAttribute( controlArray0, 3, false ) );
1865
+ bufferGeometry.setAttribute( 'control1', new BufferAttribute( controlArray1, 3, false ) );
1866
+ bufferGeometry.setAttribute( 'direction', new BufferAttribute( directionArray, 3, false ) );
1867
+
1868
+ }
1869
+
1870
+ return object3d;
1871
+
1872
+ }
1873
+
1874
+ //
1875
+
1876
+ class LDrawLoader extends Loader {
1877
+
1878
+ constructor( manager ) {
1879
+
1880
+ super( manager );
1881
+
1882
+ // Array of THREE.Material
1883
+ this.materials = [];
1884
+ this.materialLibrary = {};
1885
+
1886
+ // This also allows to handle the embedded text files ("0 FILE" lines)
1887
+ this.partsCache = new LDrawPartsGeometryCache( this );
1888
+
1889
+ // 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.
1890
+ this.fileMap = {};
1891
+
1892
+ // Initializes the materials library with default materials
1893
+ this.setMaterials( [] );
1894
+
1895
+ // If this flag is set to true the vertex normals will be smoothed.
1896
+ this.smoothNormals = true;
1897
+
1898
+ // The path to load parts from the LDraw parts library from.
1899
+ this.partsLibraryPath = '';
1900
+
1901
+ // Material assigned to not available colors for meshes and edges
1902
+ this.missingColorMaterial = new MeshStandardMaterial( { color: 0xFF00FF, roughness: 0.3, metalness: 0 } );
1903
+ this.missingColorMaterial.name = 'Missing material';
1904
+ this.missingEdgeColorMaterial = new LineBasicMaterial( { color: 0xFF00FF } );
1905
+ this.missingEdgeColorMaterial.name = 'Missing material - Edge';
1906
+ this.missingConditionalEdgeColorMaterial = new LDrawConditionalLineMaterial( { fog: true, color: 0xFF00FF } );
1907
+ this.missingConditionalEdgeColorMaterial.name = 'Missing material - Conditional Edge';
1908
+ this.missingColorMaterial.userData.edgeMaterial = this.missingEdgeColorMaterial;
1909
+ this.missingEdgeColorMaterial.userData.conditionalEdgeMaterial = this.missingConditionalEdgeColorMaterial;
1910
+
1911
+ }
1912
+
1913
+ setPartsLibraryPath( path ) {
1914
+
1915
+ this.partsLibraryPath = path;
1916
+ return this;
1917
+
1918
+ }
1919
+
1920
+ async preloadMaterials( url ) {
1921
+
1922
+ const fileLoader = new FileLoader( this.manager );
1923
+ fileLoader.setPath( this.path );
1924
+ fileLoader.setRequestHeader( this.requestHeader );
1925
+ fileLoader.setWithCredentials( this.withCredentials );
1926
+
1927
+ const text = await fileLoader.loadAsync( url );
1928
+ const colorLineRegex = /^0 !COLOUR/;
1929
+ const lines = text.split( /[\n\r]/g );
1930
+ const materials = [];
1931
+ for ( let i = 0, l = lines.length; i < l; i ++ ) {
1932
+
1933
+ const line = lines[ i ];
1934
+ if ( colorLineRegex.test( line ) ) {
1935
+
1936
+ const directive = line.replace( colorLineRegex, '' );
1937
+ const material = this.parseColorMetaDirective( new LineParser( directive ) );
1938
+ materials.push( material );
1939
+
1940
+ }
1941
+
1942
+ }
1943
+
1944
+ this.setMaterials( materials );
1945
+
1946
+ }
1947
+
1948
+ load( url, onLoad, onProgress, onError ) {
1949
+
1950
+ const fileLoader = new FileLoader( this.manager );
1951
+ fileLoader.setPath( this.path );
1952
+ fileLoader.setRequestHeader( this.requestHeader );
1953
+ fileLoader.setWithCredentials( this.withCredentials );
1954
+ fileLoader.load( url, text => {
1955
+
1956
+ this.partsCache
1957
+ .parseModel( text, this.materialLibrary )
1958
+ .then( group => {
1959
+
1960
+ this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
1961
+ this.computeConstructionSteps( group );
1962
+ group.userData.fileName = url;
1963
+ onLoad( group );
1964
+
1965
+ } )
1966
+ .catch( onError );
1967
+
1968
+ }, onProgress, onError );
1969
+
1970
+ }
1971
+
1972
+ parse( text, onLoad ) {
1973
+
1974
+ this.partsCache
1975
+ .parseModel( text, this.materialLibrary )
1976
+ .then( group => {
1977
+
1978
+ this.applyMaterialsToMesh( group, MAIN_COLOUR_CODE, this.materialLibrary, true );
1979
+ this.computeConstructionSteps( group );
1980
+ group.userData.fileName = '';
1981
+ onLoad( group );
1982
+
1983
+ } );
1984
+
1985
+ }
1986
+
1987
+ setMaterials( materials ) {
1988
+
1989
+ this.materialLibrary = {};
1990
+ this.materials = [];
1991
+ for ( let i = 0, l = materials.length; i < l; i ++ ) {
1992
+
1993
+ this.addMaterial( materials[ i ] );
1994
+
1995
+ }
1996
+
1997
+ // Add default main triangle and line edge materials (used in pieces that can be colored with a main color)
1998
+ this.addMaterial( this.parseColorMetaDirective( new LineParser( 'Main_Colour CODE 16 VALUE #FF8080 EDGE #333333' ) ) );
1999
+ this.addMaterial( this.parseColorMetaDirective( new LineParser( 'Edge_Colour CODE 24 VALUE #A0A0A0 EDGE #333333' ) ) );
2000
+
2001
+ return this;
2002
+
2003
+ }
2004
+
2005
+ setFileMap( fileMap ) {
2006
+
2007
+ this.fileMap = fileMap;
2008
+
2009
+ return this;
2010
+
2011
+ }
2012
+
2013
+ addMaterial( material ) {
2014
+
2015
+ // Adds a material to the material library which is on top of the parse scopes stack. And also to the materials array
2016
+
2017
+ const matLib = this.materialLibrary;
2018
+ if ( ! matLib[ material.userData.code ] ) {
2019
+
2020
+ this.materials.push( material );
2021
+ matLib[ material.userData.code ] = material;
2022
+
2023
+ }
2024
+
2025
+ return this;
2026
+
2027
+ }
2028
+
2029
+ getMaterial( colorCode ) {
2030
+
2031
+ if ( colorCode.startsWith( '0x2' ) ) {
2032
+
2033
+ // Special 'direct' material value (RGB color)
2034
+ const color = colorCode.substring( 3 );
2035
+
2036
+ return this.parseColorMetaDirective( new LineParser( 'Direct_Color_' + color + ' CODE -1 VALUE #' + color + ' EDGE #' + color + '' ) );
2037
+
2038
+ }
2039
+
2040
+ return this.materialLibrary[ colorCode ] || null;
2041
+
2042
+ }
2043
+
2044
+ // Applies the appropriate materials to a prebuilt hierarchy of geometry. Assumes that color codes are present
2045
+ // in the material array if they need to be filled in.
2046
+ applyMaterialsToMesh( group, parentColorCode, materialHierarchy, finalMaterialPass = false ) {
2047
+
2048
+ // find any missing materials as indicated by a color code string and replace it with a material from the current material lib
2049
+ const loader = this;
2050
+ const parentIsPassthrough = parentColorCode === MAIN_COLOUR_CODE;
2051
+ group.traverse( c => {
2052
+
2053
+ if ( c.isMesh || c.isLineSegments ) {
2054
+
2055
+ if ( Array.isArray( c.material ) ) {
2056
+
2057
+ for ( let i = 0, l = c.material.length; i < l; i ++ ) {
2058
+
2059
+ if ( ! c.material[ i ].isMaterial ) {
2060
+
2061
+ c.material[ i ] = getMaterial( c, c.material[ i ] );
2062
+
2063
+ }
2064
+
2065
+ }
2066
+
2067
+ } else if ( ! c.material.isMaterial ) {
2068
+
2069
+ c.material = getMaterial( c, c.material );
2070
+
2071
+ }
2072
+
2073
+ }
2074
+
2075
+ } );
2076
+
2077
+
2078
+ // Returns the appropriate material for the object (line or face) given color code. If the code is "pass through"
2079
+ // (24 for lines, 16 for edges) then the pass through color code is used. If that is also pass through then it's
2080
+ // simply returned for the subsequent material application.
2081
+ function getMaterial( c, colorCode ) {
2082
+
2083
+ // if our parent is a passthrough color code and we don't have the current material color available then
2084
+ // return early.
2085
+ if ( parentIsPassthrough && ! ( colorCode in materialHierarchy ) && ! finalMaterialPass ) {
2086
+
2087
+ return colorCode;
2088
+
2089
+ }
2090
+
2091
+ const forEdge = c.isLineSegments || c.isConditionalLine;
2092
+ const isPassthrough = ! forEdge && colorCode === MAIN_COLOUR_CODE || forEdge && colorCode === MAIN_EDGE_COLOUR_CODE;
2093
+ if ( isPassthrough ) {
2094
+
2095
+ colorCode = parentColorCode;
2096
+
2097
+ }
2098
+
2099
+ let material = null;
2100
+ if ( colorCode in materialHierarchy ) {
2101
+
2102
+ material = materialHierarchy[ colorCode ];
2103
+
2104
+ } else if ( finalMaterialPass ) {
2105
+
2106
+ // see if we can get the final material from from the "getMaterial" function which will attempt to
2107
+ // parse the "direct" colors
2108
+ material = loader.getMaterial( colorCode );
2109
+ if ( material === null ) {
2110
+
2111
+ // otherwise throw a warning if this is final opportunity to set the material
2112
+ console.warn( `LDrawLoader: Material properties for code ${ colorCode } not available.` );
2113
+
2114
+ // And return the 'missing color' material
2115
+ material = loader.missingColorMaterial;
2116
+
2117
+ }
2118
+
2119
+
2120
+ } else {
2121
+
2122
+ return colorCode;
2123
+
2124
+ }
2125
+
2126
+ if ( c.isLineSegments ) {
2127
+
2128
+ material = material.userData.edgeMaterial;
2129
+
2130
+ if ( c.isConditionalLine ) {
2131
+
2132
+ material = material.userData.conditionalEdgeMaterial;
2133
+
2134
+ }
2135
+
2136
+ }
2137
+
2138
+ return material;
2139
+
2140
+ }
2141
+
2142
+ }
2143
+
2144
+ getMainMaterial() {
2145
+
2146
+ return this.getMaterial( MAIN_COLOUR_CODE );
2147
+
2148
+ }
2149
+
2150
+ getMainEdgeMaterial() {
2151
+
2152
+ const mat = this.getMaterial( MAIN_EDGE_COLOUR_CODE );
2153
+ return mat ? mat.userData.edgeMaterial : null;
2154
+
2155
+ }
2156
+
2157
+ parseColorMetaDirective( lineParser ) {
2158
+
2159
+ // Parses a color definition and returns a THREE.Material
2160
+
2161
+ let code = null;
2162
+
2163
+ // Triangle and line colors
2164
+ let color = 0xFF00FF;
2165
+ let edgeColor = 0xFF00FF;
2166
+
2167
+ // Transparency
2168
+ let alpha = 1;
2169
+ let isTransparent = false;
2170
+ // Self-illumination:
2171
+ let luminance = 0;
2172
+
2173
+ let finishType = FINISH_TYPE_DEFAULT;
2174
+
2175
+ let edgeMaterial = null;
2176
+
2177
+ const name = lineParser.getToken();
2178
+ if ( ! name ) {
2179
+
2180
+ throw new Error( 'LDrawLoader: Material name was expected after "!COLOUR tag' + lineParser.getLineNumberString() + '.' );
2181
+
2182
+ }
2183
+
2184
+ // Parse tag tokens and their parameters
2185
+ let token = null;
2186
+ while ( true ) {
2187
+
2188
+ token = lineParser.getToken();
2189
+
2190
+ if ( ! token ) {
2191
+
2192
+ break;
2193
+
2194
+ }
2195
+
2196
+ if ( ! parseLuminance( token ) ) {
2197
+
2198
+ switch ( token.toUpperCase() ) {
2199
+
2200
+ case 'CODE':
2201
+
2202
+ code = lineParser.getToken();
2203
+ break;
2204
+
2205
+ case 'VALUE':
2206
+
2207
+ color = lineParser.getToken();
2208
+ if ( color.startsWith( '0x' ) ) {
2209
+
2210
+ color = '#' + color.substring( 2 );
2211
+
2212
+ } else if ( ! color.startsWith( '#' ) ) {
2213
+
2214
+ throw new Error( 'LDrawLoader: Invalid color while parsing material' + lineParser.getLineNumberString() + '.' );
2215
+
2216
+ }
2217
+
2218
+ break;
2219
+
2220
+ case 'EDGE':
2221
+
2222
+ edgeColor = lineParser.getToken();
2223
+ if ( edgeColor.startsWith( '0x' ) ) {
2224
+
2225
+ edgeColor = '#' + edgeColor.substring( 2 );
2226
+
2227
+ } else if ( ! edgeColor.startsWith( '#' ) ) {
2228
+
2229
+ // Try to see if edge color is a color code
2230
+ edgeMaterial = this.getMaterial( edgeColor );
2231
+ if ( ! edgeMaterial ) {
2232
+
2233
+ throw new Error( 'LDrawLoader: Invalid edge color while parsing material' + lineParser.getLineNumberString() + '.' );
2234
+
2235
+ }
2236
+
2237
+ // Get the edge material for this triangle material
2238
+ edgeMaterial = edgeMaterial.userData.edgeMaterial;
2239
+
2240
+ }
2241
+
2242
+ break;
2243
+
2244
+ case 'ALPHA':
2245
+
2246
+ alpha = parseInt( lineParser.getToken() );
2247
+
2248
+ if ( isNaN( alpha ) ) {
2249
+
2250
+ throw new Error( 'LDrawLoader: Invalid alpha value in material definition' + lineParser.getLineNumberString() + '.' );
2251
+
2252
+ }
2253
+
2254
+ alpha = Math.max( 0, Math.min( 1, alpha / 255 ) );
2255
+
2256
+ if ( alpha < 1 ) {
2257
+
2258
+ isTransparent = true;
2259
+
2260
+ }
2261
+
2262
+ break;
2263
+
2264
+ case 'LUMINANCE':
2265
+
2266
+ if ( ! parseLuminance( lineParser.getToken() ) ) {
2267
+
2268
+ throw new Error( 'LDrawLoader: Invalid luminance value in material definition' + LineParser.getLineNumberString() + '.' );
2269
+
2270
+ }
2271
+
2272
+ break;
2273
+
2274
+ case 'CHROME':
2275
+ finishType = FINISH_TYPE_CHROME;
2276
+ break;
2277
+
2278
+ case 'PEARLESCENT':
2279
+ finishType = FINISH_TYPE_PEARLESCENT;
2280
+ break;
2281
+
2282
+ case 'RUBBER':
2283
+ finishType = FINISH_TYPE_RUBBER;
2284
+ break;
2285
+
2286
+ case 'MATTE_METALLIC':
2287
+ finishType = FINISH_TYPE_MATTE_METALLIC;
2288
+ break;
2289
+
2290
+ case 'METAL':
2291
+ finishType = FINISH_TYPE_METAL;
2292
+ break;
2293
+
2294
+ case 'MATERIAL':
2295
+ // Not implemented
2296
+ lineParser.setToEnd();
2297
+ break;
2298
+
2299
+ default:
2300
+ throw new Error( 'LDrawLoader: Unknown token "' + token + '" while parsing material' + lineParser.getLineNumberString() + '.' );
2301
+
2302
+ }
2303
+
2304
+ }
2305
+
2306
+ }
2307
+
2308
+ let material = null;
2309
+
2310
+ switch ( finishType ) {
2311
+
2312
+ case FINISH_TYPE_DEFAULT:
2313
+
2314
+ material = new MeshStandardMaterial( { color: color, roughness: 0.3, metalness: 0 } );
2315
+ break;
2316
+
2317
+ case FINISH_TYPE_PEARLESCENT:
2318
+
2319
+ // Try to imitate pearlescency by making the surface glossy
2320
+ material = new MeshStandardMaterial( { color: color, roughness: 0.3, metalness: 0.25 } );
2321
+ break;
2322
+
2323
+ case FINISH_TYPE_CHROME:
2324
+
2325
+ // Mirror finish surface
2326
+ material = new MeshStandardMaterial( { color: color, roughness: 0, metalness: 1 } );
2327
+ break;
2328
+
2329
+ case FINISH_TYPE_RUBBER:
2330
+
2331
+ // Rubber finish
2332
+ material = new MeshStandardMaterial( { color: color, roughness: 0.9, metalness: 0 } );
2333
+ break;
2334
+
2335
+ case FINISH_TYPE_MATTE_METALLIC:
2336
+
2337
+ // Brushed metal finish
2338
+ material = new MeshStandardMaterial( { color: color, roughness: 0.8, metalness: 0.4 } );
2339
+ break;
2340
+
2341
+ case FINISH_TYPE_METAL:
2342
+
2343
+ // Average metal finish
2344
+ material = new MeshStandardMaterial( { color: color, roughness: 0.2, metalness: 0.85 } );
2345
+ break;
2346
+
2347
+ default:
2348
+ // Should not happen
2349
+ break;
2350
+
2351
+ }
2352
+
2353
+ material.transparent = isTransparent;
2354
+ material.premultipliedAlpha = true;
2355
+ material.opacity = alpha;
2356
+ material.depthWrite = ! isTransparent;
2357
+ material.color.convertSRGBToLinear();
2358
+
2359
+ material.polygonOffset = true;
2360
+ material.polygonOffsetFactor = 1;
2361
+
2362
+ if ( luminance !== 0 ) {
2363
+
2364
+ material.emissive.set( material.color ).multiplyScalar( luminance );
2365
+
2366
+ }
2367
+
2368
+ if ( ! edgeMaterial ) {
2369
+
2370
+ // This is the material used for edges
2371
+ edgeMaterial = new LineBasicMaterial( {
2372
+ color: edgeColor,
2373
+ transparent: isTransparent,
2374
+ opacity: alpha,
2375
+ depthWrite: ! isTransparent
2376
+ } );
2377
+ edgeMaterial.userData.code = code;
2378
+ edgeMaterial.name = name + ' - Edge';
2379
+ edgeMaterial.color.convertSRGBToLinear();
2380
+
2381
+ // This is the material used for conditional edges
2382
+ edgeMaterial.userData.conditionalEdgeMaterial = new LDrawConditionalLineMaterial( {
2383
+
2384
+ fog: true,
2385
+ transparent: isTransparent,
2386
+ depthWrite: ! isTransparent,
2387
+ color: edgeColor,
2388
+ opacity: alpha,
2389
+
2390
+ } );
2391
+ edgeMaterial.userData.conditionalEdgeMaterial.color.convertSRGBToLinear();
2392
+ edgeMaterial.userData.conditionalEdgeMaterial.userData.code = code;
2393
+ edgeMaterial.userData.conditionalEdgeMaterial.name = name + ' - Conditional Edge';
2394
+
2395
+ }
2396
+
2397
+ material.userData.code = code;
2398
+ material.name = name;
2399
+
2400
+ material.userData.edgeMaterial = edgeMaterial;
2401
+
2402
+ this.addMaterial( material );
2403
+
2404
+ return material;
2405
+
2406
+ function parseLuminance( token ) {
2407
+
2408
+ // Returns success
2409
+
2410
+ let lum;
2411
+
2412
+ if ( token.startsWith( 'LUMINANCE' ) ) {
2413
+
2414
+ lum = parseInt( token.substring( 9 ) );
2415
+
2416
+ } else {
2417
+
2418
+ lum = parseInt( token );
2419
+
2420
+ }
2421
+
2422
+ if ( isNaN( lum ) ) {
2423
+
2424
+ return false;
2425
+
2426
+ }
2427
+
2428
+ luminance = Math.max( 0, Math.min( 1, lum / 255 ) );
2429
+
2430
+ return true;
2431
+
2432
+ }
2433
+
2434
+ }
2435
+
2436
+ computeConstructionSteps( model ) {
2437
+
2438
+ // Sets userdata.constructionStep number in Group objects and userData.numConstructionSteps number in the root Group object.
2439
+
2440
+ let stepNumber = 0;
2441
+
2442
+ model.traverse( c => {
2443
+
2444
+ if ( c.isGroup ) {
2445
+
2446
+ if ( c.userData.startingConstructionStep ) {
2447
+
2448
+ stepNumber ++;
2449
+
2450
+ }
2451
+
2452
+ c.userData.constructionStep = stepNumber;
2453
+
2454
+ }
2455
+
2456
+ } );
2457
+
2458
+ model.userData.numConstructionSteps = stepNumber + 1;
2459
+
2460
+ }
2461
+
2462
+ }
2463
+
2464
+ export { LDrawLoader };